mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-16 16:00:30 +02:00
Add a class for keyboard input
Removes the windows-specific hack from sceCtrl to read keyboard input and instead add a hack to PPSSPPWindows. The input mapping is still hardcoded and is the same as it was in sceCtrl. Add an std::list to WindowsHost that, curretly, contains a hardcoded list of preferred `InputDevice`s. Devices are tried in-order until one of them reports success. Xinput is preferred over Keyboard. Keyboard always returns success. Pointers are stored in the std::list for polymorphism. Change XinputDevice to report failure as soon as a device can't be queried, instead of only a frame later.
This commit is contained in:
1 parent
2210b19244
commit
7e7e9a0452
10 files changed
+91
-46
No files matched your search
@@ -0,0 +1,46 @@
|
||||
#include "KeyboardDevice.h"
|
||||
#include "../Common/CommonTypes.h"
|
||||
#include "../Core/HLE/sceCtrl.h"
|
||||
#include "WinUser.h"
|
||||
|
||||
static const unsigned short key_ctrl_map[] = {
|
||||
VK_SPACE, CTRL_START,
|
||||
'V', CTRL_SELECT,
|
||||
'A', CTRL_SQUARE,
|
||||
'S', CTRL_TRIANGLE,
|
||||
'X', CTRL_CIRCLE,
|
||||
'Z', CTRL_CROSS,
|
||||
'Q', CTRL_LTRIGGER,
|
||||
'W', CTRL_RTRIGGER,
|
||||
VK_UP, CTRL_UP,
|
||||
VK_DOWN, CTRL_DOWN,
|
||||
VK_LEFT, CTRL_LEFT,
|
||||
VK_RIGHT, CTRL_RIGHT,
|
||||
};
|
||||
int KeyboardDevice::UpdateState() {
|
||||
float analogX = 0;
|
||||
float analogY = 0;
|
||||
for (int i = 0; i < sizeof(key_ctrl_map)/sizeof(key_ctrl_map[0]); i += 2) {
|
||||
if (!GetAsyncKeyState(key_ctrl_map[i]))
|
||||
__CtrlButtonUp(key_ctrl_map[i+1]);
|
||||
else {
|
||||
__CtrlButtonDown(key_ctrl_map[i+1]);
|
||||
switch (key_ctrl_map[i]) {
|
||||
case VK_UP:
|
||||
analogY -= .8f;
|
||||
break;
|
||||
case VK_DOWN:
|
||||
analogY += .8f;
|
||||
break;
|
||||
case VK_LEFT:
|
||||
analogX -= .8f;
|
||||
break;
|
||||
case VK_RIGHT:
|
||||
analogX += .8f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
__CtrlSetAnalog(analogX, analogY);
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user