mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Correct use of GetAsyncKeyState
This commit is contained in:
parent
95b466fc4f
commit
a972b5d0dc
4 changed files with 29 additions and 21 deletions
|
@ -802,7 +802,7 @@ void CtrlDisAsmView::onKeyDown(WPARAM wParam, LPARAM lParam)
|
|||
u32 windowEnd = windowStart+visibleRows*instructionSize;
|
||||
keyTaken = true;
|
||||
|
||||
if (GetAsyncKeyState(VK_CONTROL))
|
||||
if (KeyDownAsync(VK_CONTROL))
|
||||
{
|
||||
switch (tolower(wParam & 0xFFFF))
|
||||
{
|
||||
|
@ -836,11 +836,11 @@ void CtrlDisAsmView::onKeyDown(WPARAM wParam, LPARAM lParam)
|
|||
switch (wParam & 0xFFFF)
|
||||
{
|
||||
case VK_DOWN:
|
||||
setCurAddress(curAddress + instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(curAddress + instructionSize, KeyDownAsync(VK_SHIFT) != 0);
|
||||
scrollAddressIntoView();
|
||||
break;
|
||||
case VK_UP:
|
||||
setCurAddress(curAddress - instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(curAddress - instructionSize, KeyDownAsync(VK_SHIFT) != 0);
|
||||
scrollAddressIntoView();
|
||||
break;
|
||||
case VK_NEXT:
|
||||
|
@ -848,16 +848,16 @@ void CtrlDisAsmView::onKeyDown(WPARAM wParam, LPARAM lParam)
|
|||
setCurAddress(windowEnd - instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
scrollAddressIntoView();
|
||||
} else {
|
||||
setCurAddress(curAddress + visibleRows * instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(curAddress + visibleRows * instructionSize, KeyDownAsync(VK_SHIFT) != 0);
|
||||
scrollAddressIntoView();
|
||||
}
|
||||
break;
|
||||
case VK_PRIOR:
|
||||
if (curAddress != windowStart && curAddressIsVisible()) {
|
||||
setCurAddress(windowStart, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(windowStart, KeyDownAsync(VK_SHIFT) != 0);
|
||||
scrollAddressIntoView();
|
||||
} else {
|
||||
setCurAddress(curAddress - visibleRows * instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(curAddress - visibleRows * instructionSize, KeyDownAsync(VK_SHIFT) != 0);
|
||||
scrollAddressIntoView();
|
||||
}
|
||||
break;
|
||||
|
@ -957,7 +957,7 @@ void CtrlDisAsmView::onMouseDown(WPARAM wParam, LPARAM lParam, int button)
|
|||
int y = HIWORD(lParam);
|
||||
|
||||
u32 newAddress = yToAddress(y);
|
||||
bool extend = GetAsyncKeyState(VK_SHIFT) != 0;
|
||||
bool extend = KeyDownAsync(VK_SHIFT) != 0;
|
||||
if (button == 1)
|
||||
{
|
||||
if (newAddress == curAddress && hasFocus)
|
||||
|
@ -983,7 +983,7 @@ void CtrlDisAsmView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)
|
|||
{
|
||||
int x = LOWORD(lParam);
|
||||
int y = HIWORD(lParam);
|
||||
setCurAddress(yToAddress(y), GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(yToAddress(y), KeyDownAsync(VK_SHIFT) != 0);
|
||||
redraw();
|
||||
}
|
||||
else if (button == 2)
|
||||
|
@ -1152,7 +1152,7 @@ void CtrlDisAsmView::onMouseMove(WPARAM wParam, LPARAM lParam, int button)
|
|||
{
|
||||
int x = LOWORD(lParam);
|
||||
int y = HIWORD(lParam);
|
||||
setCurAddress(yToAddress(y), GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(yToAddress(y), KeyDownAsync(VK_SHIFT) != 0);
|
||||
// TODO: Perhaps don't do this every time, but on a timer?
|
||||
redraw();
|
||||
}
|
||||
|
@ -1287,7 +1287,7 @@ void CtrlDisAsmView::search(bool continueSearch)
|
|||
}
|
||||
|
||||
// cancel search
|
||||
if ((searchAddress % 256) == 0 && GetAsyncKeyState(VK_ESCAPE))
|
||||
if ((searchAddress % 256) == 0 && KeyDownAsync(VK_ESCAPE))
|
||||
{
|
||||
searching = false;
|
||||
return;
|
||||
|
|
|
@ -302,7 +302,7 @@ void CtrlMemView::onVScroll(WPARAM wParam, LPARAM lParam)
|
|||
|
||||
void CtrlMemView::onKeyDown(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (GetAsyncKeyState(VK_CONTROL))
|
||||
if (KeyDownAsync(VK_CONTROL))
|
||||
{
|
||||
switch (tolower(wParam & 0xFFFF))
|
||||
{
|
||||
|
@ -354,7 +354,7 @@ void CtrlMemView::onKeyDown(WPARAM wParam, LPARAM lParam)
|
|||
|
||||
void CtrlMemView::onChar(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (GetAsyncKeyState(VK_CONTROL) || wParam == VK_TAB) return;
|
||||
if (KeyDownAsync(VK_CONTROL) || wParam == VK_TAB) return;
|
||||
|
||||
if (!Memory::IsValidAddress(curAddress))
|
||||
{
|
||||
|
@ -649,12 +649,12 @@ void CtrlMemView::search(bool continueSearch)
|
|||
while (index < endIndex)
|
||||
{
|
||||
// cancel search
|
||||
if ((index % 256) == 0 && GetAsyncKeyState(VK_ESCAPE))
|
||||
if ((index % 256) == 0 && KeyDownAsync(VK_ESCAPE))
|
||||
{
|
||||
searching = false;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (memcmp(&dataPointer[index],searchData.data(),searchData.size()) == 0)
|
||||
{
|
||||
matchAddress = index+segmentStart;
|
||||
|
|
|
@ -264,7 +264,7 @@ void CtrlDisplayListView::onMouseDown(WPARAM wParam, LPARAM lParam, int button)
|
|||
int line = y/rowHeight;
|
||||
u32 newAddress = windowStart + line*instructionSize;
|
||||
|
||||
bool extend = GetAsyncKeyState(VK_SHIFT) != 0;
|
||||
bool extend = KeyDownAsync(VK_SHIFT) != 0;
|
||||
if (button == 1)
|
||||
{
|
||||
if (newAddress == curAddress && hasFocus)
|
||||
|
@ -412,28 +412,28 @@ void CtrlDisplayListView::onKeyDown(WPARAM wParam, LPARAM lParam)
|
|||
switch (wParam & 0xFFFF)
|
||||
{
|
||||
case VK_DOWN:
|
||||
setCurAddress(curAddress + instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(curAddress + instructionSize, KeyDownAsync(VK_SHIFT) != 0);
|
||||
scrollAddressIntoView();
|
||||
break;
|
||||
case VK_UP:
|
||||
setCurAddress(curAddress - instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(curAddress - instructionSize, KeyDownAsync(VK_SHIFT) != 0);
|
||||
scrollAddressIntoView();
|
||||
break;
|
||||
case VK_NEXT:
|
||||
if (curAddress != windowEnd - instructionSize && curAddressIsVisible()) {
|
||||
setCurAddress(windowEnd - instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(windowEnd - instructionSize, KeyDownAsync(VK_SHIFT) != 0);
|
||||
scrollAddressIntoView();
|
||||
} else {
|
||||
setCurAddress(curAddress + visibleRows * instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(curAddress + visibleRows * instructionSize, KeyDownAsync(VK_SHIFT) != 0);
|
||||
scrollAddressIntoView();
|
||||
}
|
||||
break;
|
||||
case VK_PRIOR:
|
||||
if (curAddress != windowStart && curAddressIsVisible()) {
|
||||
setCurAddress(windowStart, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(windowStart, KeyDownAsync(VK_SHIFT) != 0);
|
||||
scrollAddressIntoView();
|
||||
} else {
|
||||
setCurAddress(curAddress - visibleRows * instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(curAddress - visibleRows * instructionSize, KeyDownAsync(VK_SHIFT) != 0);
|
||||
scrollAddressIntoView();
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -17,6 +17,14 @@ struct GenericListViewColumn
|
|||
float size;
|
||||
};
|
||||
|
||||
// the most significant bit states whether the key is currently down.
|
||||
// simply checking if it's != 0 is not enough, as bit0 is set if
|
||||
// the key was pressed between the last call to GetAsyncKeyState
|
||||
inline bool KeyDownAsync(int vkey)
|
||||
{
|
||||
return (GetAsyncKeyState(vkey) & 0x8000) != 0;
|
||||
}
|
||||
|
||||
class GenericListControl
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Add table
Reference in a new issue