mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #4458 from Kingcom/KeyStateFix
Correct use of GetAsyncKeyState
This commit is contained in:
commit
ebd3763c7e
4 changed files with 30 additions and 22 deletions
|
@ -806,7 +806,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))
|
||||
{
|
||||
|
@ -840,28 +840,28 @@ 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));
|
||||
scrollAddressIntoView();
|
||||
break;
|
||||
case VK_UP:
|
||||
setCurAddress(curAddress - instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(curAddress - instructionSize, KeyDownAsync(VK_SHIFT));
|
||||
scrollAddressIntoView();
|
||||
break;
|
||||
case VK_NEXT:
|
||||
if (curAddress != windowEnd - instructionSize && curAddressIsVisible()) {
|
||||
setCurAddress(windowEnd - instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(windowEnd - instructionSize, GetAsyncKeyState(VK_SHIFT));
|
||||
scrollAddressIntoView();
|
||||
} else {
|
||||
setCurAddress(curAddress + visibleRows * instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(curAddress + visibleRows * instructionSize, KeyDownAsync(VK_SHIFT));
|
||||
scrollAddressIntoView();
|
||||
}
|
||||
break;
|
||||
case VK_PRIOR:
|
||||
if (curAddress != windowStart && curAddressIsVisible()) {
|
||||
setCurAddress(windowStart, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(windowStart, KeyDownAsync(VK_SHIFT));
|
||||
scrollAddressIntoView();
|
||||
} else {
|
||||
setCurAddress(curAddress - visibleRows * instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(curAddress - visibleRows * instructionSize, KeyDownAsync(VK_SHIFT));
|
||||
scrollAddressIntoView();
|
||||
}
|
||||
break;
|
||||
|
@ -961,7 +961,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);
|
||||
if (button == 1)
|
||||
{
|
||||
if (newAddress == curAddress && hasFocus)
|
||||
|
@ -987,7 +987,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));
|
||||
redraw();
|
||||
}
|
||||
else if (button == 2)
|
||||
|
@ -1154,7 +1154,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));
|
||||
// TODO: Perhaps don't do this every time, but on a timer?
|
||||
redraw();
|
||||
}
|
||||
|
@ -1289,7 +1289,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);
|
||||
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));
|
||||
scrollAddressIntoView();
|
||||
break;
|
||||
case VK_UP:
|
||||
setCurAddress(curAddress - instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(curAddress - instructionSize, KeyDownAsync(VK_SHIFT));
|
||||
scrollAddressIntoView();
|
||||
break;
|
||||
case VK_NEXT:
|
||||
if (curAddress != windowEnd - instructionSize && curAddressIsVisible()) {
|
||||
setCurAddress(windowEnd - instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(windowEnd - instructionSize, KeyDownAsync(VK_SHIFT));
|
||||
scrollAddressIntoView();
|
||||
} else {
|
||||
setCurAddress(curAddress + visibleRows * instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(curAddress + visibleRows * instructionSize, KeyDownAsync(VK_SHIFT));
|
||||
scrollAddressIntoView();
|
||||
}
|
||||
break;
|
||||
case VK_PRIOR:
|
||||
if (curAddress != windowStart && curAddressIsVisible()) {
|
||||
setCurAddress(windowStart, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(windowStart, KeyDownAsync(VK_SHIFT));
|
||||
scrollAddressIntoView();
|
||||
} else {
|
||||
setCurAddress(curAddress - visibleRows * instructionSize, GetAsyncKeyState(VK_SHIFT) != 0);
|
||||
setCurAddress(curAddress - visibleRows * instructionSize, KeyDownAsync(VK_SHIFT));
|
||||
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