我试图在我正在处理的项目中使用 GetAsyncKeyState
。唯一的问题是我不知道它返回什么值,也不知道如何检查它。根据MSNdocumentation :
Type: SHORT
If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState. However, you should not rely on this last behavior; for more information, see the Remarks.
我知道 SHORT
类型是一个数字,但我在 StackOverflow 和互联网上看到了很多不同的答案,但是当 GetAsyncKeyState 的计算结果为 true 时,它的返回值是多少?返回 0 还是 0x8001?
最佳答案
返回值可以是 4 个可能值之一:
- 0x0000
- 0x0001
- 0x8000
- 0x8001
使用 & 0x8000
(或者 < 0
因为 SHORT
是有符号类型)检查“最高有效位是否设置”(这使得有符号类型为负)。
使用 & 0x0001
检查“最低有效位是否已设置”。
关于ruby - 什么是 GetAsyncKeyState 返回值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53249586/