mirror of
https://github.com/babalae/better-genshin-impact
synced 2025-01-07 03:17:16 +08:00
35 lines
824 B
C#
35 lines
824 B
C#
using Vanara.PInvoke;
|
|
|
|
namespace Fischless.WindowsInput;
|
|
|
|
public class WindowsInputDeviceStateAdaptor : IInputDeviceStateAdaptor
|
|
{
|
|
public bool IsKeyDown(User32.VK keyCode)
|
|
{
|
|
short keyState = User32.GetKeyState((ushort)keyCode);
|
|
return keyState < 0;
|
|
}
|
|
|
|
public bool IsKeyUp(User32.VK keyCode)
|
|
{
|
|
return !IsKeyDown(keyCode);
|
|
}
|
|
|
|
public bool IsHardwareKeyDown(User32.VK keyCode)
|
|
{
|
|
short asyncKeyState = User32.GetAsyncKeyState((ushort)keyCode);
|
|
return asyncKeyState < 0;
|
|
}
|
|
|
|
public bool IsHardwareKeyUp(User32.VK keyCode)
|
|
{
|
|
return !IsHardwareKeyDown(keyCode);
|
|
}
|
|
|
|
public bool IsTogglingKeyInEffect(User32.VK keyCode)
|
|
{
|
|
short keyState = User32.GetKeyState((ushort)keyCode);
|
|
return (keyState & 1) == 1;
|
|
}
|
|
}
|