mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
commit
300bcf4938
1 changed files with 3 additions and 6 deletions
|
|
@ -27,7 +27,7 @@ namespace Dalamud.Game.ClientState.Keys
|
||||||
// The array is accessed in a way that this limit doesn't appear to exist
|
// The array is accessed in a way that this limit doesn't appear to exist
|
||||||
// but there is other state data past this point, and keys beyond here aren't
|
// but there is other state data past this point, and keys beyond here aren't
|
||||||
// generally valid for most things anyway
|
// generally valid for most things anyway
|
||||||
private const int MaxKeyCodeIndex = 0xA0;
|
private const int MaxKeyCode = 0xF0;
|
||||||
private readonly IntPtr bufferBase;
|
private readonly IntPtr bufferBase;
|
||||||
private readonly IntPtr indexBase;
|
private readonly IntPtr indexBase;
|
||||||
private VirtualKey[] validVirtualKeyCache = null;
|
private VirtualKey[] validVirtualKeyCache = null;
|
||||||
|
|
@ -104,7 +104,7 @@ namespace Dalamud.Game.ClientState.Keys
|
||||||
/// <param name="vkCode">Virtual key code.</param>
|
/// <param name="vkCode">Virtual key code.</param>
|
||||||
/// <returns>If the code is valid.</returns>
|
/// <returns>If the code is valid.</returns>
|
||||||
public bool IsVirtualKeyValid(int vkCode)
|
public bool IsVirtualKeyValid(int vkCode)
|
||||||
=> vkCode > 0 && vkCode < MaxKeyCodeIndex && this.ConvertVirtualKey(vkCode) != 0;
|
=> this.ConvertVirtualKey(vkCode) != 0;
|
||||||
|
|
||||||
/// <inheritdoc cref="IsVirtualKeyValid(int)"/>
|
/// <inheritdoc cref="IsVirtualKeyValid(int)"/>
|
||||||
public bool IsVirtualKeyValid(VirtualKey vkCode)
|
public bool IsVirtualKeyValid(VirtualKey vkCode)
|
||||||
|
|
@ -136,7 +136,7 @@ namespace Dalamud.Game.ClientState.Keys
|
||||||
/// <returns>Converted value.</returns>
|
/// <returns>Converted value.</returns>
|
||||||
private unsafe byte ConvertVirtualKey(int vkCode)
|
private unsafe byte ConvertVirtualKey(int vkCode)
|
||||||
{
|
{
|
||||||
if (vkCode <= 0 || vkCode >= 240)
|
if (vkCode <= 0 || vkCode >= MaxKeyCode)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return *(byte*)(this.indexBase + vkCode);
|
return *(byte*)(this.indexBase + vkCode);
|
||||||
|
|
@ -149,9 +149,6 @@ namespace Dalamud.Game.ClientState.Keys
|
||||||
/// <returns>A reference to the indexed array.</returns>
|
/// <returns>A reference to the indexed array.</returns>
|
||||||
private unsafe ref int GetRefValue(int vkCode)
|
private unsafe ref int GetRefValue(int vkCode)
|
||||||
{
|
{
|
||||||
if (vkCode < 0 || vkCode > MaxKeyCodeIndex)
|
|
||||||
throw new ArgumentException($"Keycode state is only valid up to {MaxKeyCodeIndex}");
|
|
||||||
|
|
||||||
vkCode = this.ConvertVirtualKey(vkCode);
|
vkCode = this.ConvertVirtualKey(vkCode);
|
||||||
|
|
||||||
if (vkCode == 0)
|
if (vkCode == 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue