From 958fd29593f13ca2d80424fa213710f91d1bc193 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 2 Dec 2012 16:04:50 -0800 Subject: [PATCH] On Windows, separate analog and digital arrows. This fixes the Tales of Eternia menu and movement. --- Windows/KeyboardDevice.cpp | 48 +++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/Windows/KeyboardDevice.cpp b/Windows/KeyboardDevice.cpp index c69f97b90c..8d3cf30c37 100644 --- a/Windows/KeyboardDevice.cpp +++ b/Windows/KeyboardDevice.cpp @@ -17,30 +17,46 @@ static const unsigned short key_ctrl_map[] = { VK_LEFT, CTRL_LEFT, VK_RIGHT, CTRL_RIGHT, }; + +static const unsigned short analog_ctrl_map[] = { + 'I', CTRL_UP, + 'K', CTRL_DOWN, + 'J', CTRL_LEFT, + 'L', 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; - } } } + + float analogX = 0; + float analogY = 0; + for (int i = 0; i < sizeof(analog_ctrl_map)/sizeof(analog_ctrl_map[0]); i += 2) { + if (!GetAsyncKeyState(analog_ctrl_map[i])) { + continue; + } + + switch (analog_ctrl_map[i + 1]) { + case CTRL_UP: + analogY -= .8f; + break; + case CTRL_DOWN: + analogY += .8f; + break; + case CTRL_LEFT: + analogX -= .8f; + break; + case CTRL_RIGHT: + analogX += .8f; + break; + } + } + __CtrlSetAnalog(analogX, analogY); return 0; } \ No newline at end of file