Skip to content

Commit

Permalink
Fix: 修复 keystate 在打开对话框后失效的问题 (#212)
Browse files Browse the repository at this point in the history
使用 GetOpenFileName 等打开对话框后,keystate 失效,但按键消息正常。原因是 GetKeyState 是通过处理按键消息来判断按键状态,需要在消息队列的窗口线程中使用。(如果在其它线程,猜测目前的底层实现是会获取最新创建的一个窗口线程的按键状态,因此一开始未打开对话框时是正常的。)。
chore: 忽略 ./out 目录 (Visual Studio Cmake生成目录)
  • Loading branch information
yixy-only authored Jul 8, 2024
1 parent 9695128 commit c96738e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@

/build
/temp
/out
5 changes: 1 addition & 4 deletions src/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,7 @@ int keystate(int key)
if (key < 0 || key >= MAX_KEY_VCODE) {
return -1;
}
SHORT s = GetKeyState(key);
if (((USHORT)s & 0x8000) == 0) {
pg->keystatemap[key] = 0;
}

return pg->keystatemap[key];
}

Expand Down

0 comments on commit c96738e

Please sign in to comment.