29 lines
No EOL
795 B
C#
29 lines
No EOL
795 B
C#
using System.Runtime.InteropServices;
|
|
|
|
namespace Domain {
|
|
public static class Win32API {
|
|
private static bool _cTrencadaWasPressed;
|
|
private static bool _cTrencadaPressed;
|
|
//VK_OEM_2 = 0xBF | cedilla
|
|
//https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
|
|
private const int Key = 0xBF;
|
|
|
|
public static void UpdateInput() {
|
|
_cTrencadaWasPressed = _cTrencadaPressed;
|
|
if (_cTrencadaPressed && GetAsyncKeyState(Key) == 0) {
|
|
_cTrencadaPressed = false;
|
|
return;
|
|
}
|
|
if (!_cTrencadaPressed && GetAsyncKeyState(Key) != 0) {
|
|
_cTrencadaPressed = true;
|
|
}
|
|
}
|
|
|
|
public static bool CTrencadaDown() {
|
|
return _cTrencadaPressed && !_cTrencadaWasPressed;
|
|
}
|
|
|
|
[DllImport("User32.dll")]
|
|
private static extern short GetAsyncKeyState(int vKey);
|
|
}
|
|
} |