[HID] Make winkey key checks more readable.

This commit is contained in:
gibbed 2018-06-05 08:15:59 -05:00
parent 8d5d6c5a59
commit 43b987da1e
1 changed files with 22 additions and 22 deletions

View File

@ -91,66 +91,66 @@ X_RESULT WinKeyInputDriver::GetState(uint32_t user_index,
if (window_->has_focus()) { if (window_->has_focus()) {
if (IS_KEY_TOGGLED(VK_CAPITAL) || IS_KEY_DOWN(VK_SHIFT)) { if (IS_KEY_TOGGLED(VK_CAPITAL) || IS_KEY_DOWN(VK_SHIFT)) {
// dpad toggled // dpad toggled
if (IS_KEY_DOWN(0x41)) { if (IS_KEY_DOWN('A')) {
// A // A
buttons |= 0x0004; // XINPUT_GAMEPAD_DPAD_LEFT buttons |= 0x0004; // XINPUT_GAMEPAD_DPAD_LEFT
} }
if (IS_KEY_DOWN(0x44)) { if (IS_KEY_DOWN('D')) {
// D // D
buttons |= 0x0008; // XINPUT_GAMEPAD_DPAD_RIGHT buttons |= 0x0008; // XINPUT_GAMEPAD_DPAD_RIGHT
} }
if (IS_KEY_DOWN(0x53)) { if (IS_KEY_DOWN('S')) {
// S // S
buttons |= 0x0002; // XINPUT_GAMEPAD_DPAD_DOWN buttons |= 0x0002; // XINPUT_GAMEPAD_DPAD_DOWN
} }
if (IS_KEY_DOWN(0x57)) { if (IS_KEY_DOWN('W')) {
// W // W
buttons |= 0x0001; // XINPUT_GAMEPAD_DPAD_UP buttons |= 0x0001; // XINPUT_GAMEPAD_DPAD_UP
} }
} else { } else {
// left stick // left stick
if (IS_KEY_DOWN(0x41)) { if (IS_KEY_DOWN('A')) {
// A // A
thumb_lx += SHRT_MIN; thumb_lx += SHRT_MIN;
} }
if (IS_KEY_DOWN(0x44)) { if (IS_KEY_DOWN('D')) {
// D // D
thumb_lx += SHRT_MAX; thumb_lx += SHRT_MAX;
} }
if (IS_KEY_DOWN(0x53)) { if (IS_KEY_DOWN('S')) {
// S // S
thumb_ly += SHRT_MIN; thumb_ly += SHRT_MIN;
} }
if (IS_KEY_DOWN(0x57)) { if (IS_KEY_DOWN('W')) {
// W // W
thumb_ly += SHRT_MAX; thumb_ly += SHRT_MAX;
} }
} }
if (IS_KEY_DOWN(0x46)) { if (IS_KEY_DOWN('F')) {
// F // F
buttons |= 0x0040; // XINPUT_GAMEPAD_LEFT_THUMB buttons |= 0x0040; // XINPUT_GAMEPAD_LEFT_THUMB
} }
// Right stick // Right stick
if (IS_KEY_DOWN(0x26)) { if (IS_KEY_DOWN(VK_UP)) {
// Up // Up
thumb_ry += SHRT_MAX; thumb_ry += SHRT_MAX;
} }
if (IS_KEY_DOWN(0x28)) { if (IS_KEY_DOWN(VK_DOWN)) {
// Down // Down
thumb_ry += SHRT_MIN; thumb_ry += SHRT_MIN;
} }
if (IS_KEY_DOWN(0x27)) { if (IS_KEY_DOWN(VK_RIGHT)) {
// Right // Right
thumb_rx += SHRT_MAX; thumb_rx += SHRT_MAX;
} }
if (IS_KEY_DOWN(0x25)) { if (IS_KEY_DOWN(VK_LEFT)) {
// Left // Left
thumb_rx += SHRT_MIN; thumb_rx += SHRT_MIN;
} }
if (IS_KEY_DOWN(0x4C)) { if (IS_KEY_DOWN('L')) {
// L // L
buttons |= 0x4000; // XINPUT_GAMEPAD_X buttons |= 0x4000; // XINPUT_GAMEPAD_X
} }
@ -162,39 +162,39 @@ X_RESULT WinKeyInputDriver::GetState(uint32_t user_index,
// ; // ;
buttons |= 0x1000; // XINPUT_GAMEPAD_A buttons |= 0x1000; // XINPUT_GAMEPAD_A
} }
if (IS_KEY_DOWN(0x50)) { if (IS_KEY_DOWN('P')) {
// P // P
buttons |= 0x8000; // XINPUT_GAMEPAD_Y buttons |= 0x8000; // XINPUT_GAMEPAD_Y
} }
if (IS_KEY_DOWN(0x4B)) { if (IS_KEY_DOWN('K')) {
// K // K
buttons |= 0x0080; // XINPUT_GAMEPAD_RIGHT_THUMB buttons |= 0x0080; // XINPUT_GAMEPAD_RIGHT_THUMB
} }
if (IS_KEY_DOWN(0x51) || IS_KEY_DOWN(0x49)) { if (IS_KEY_DOWN('Q') || IS_KEY_DOWN('I')) {
// Q / I // Q / I
left_trigger = 0xFF; left_trigger = 0xFF;
} }
if (IS_KEY_DOWN(0x45) || IS_KEY_DOWN(0x4F)) { if (IS_KEY_DOWN('E') || IS_KEY_DOWN('O')) {
// E / O // E / O
right_trigger = 0xFF; right_trigger = 0xFF;
} }
if (IS_KEY_DOWN(0x5A)) { if (IS_KEY_DOWN('Z')) {
// Z // Z
buttons |= 0x0020; // XINPUT_GAMEPAD_BACK buttons |= 0x0020; // XINPUT_GAMEPAD_BACK
} }
if (IS_KEY_DOWN(0x58)) { if (IS_KEY_DOWN('X')) {
// X // X
buttons |= 0x0010; // XINPUT_GAMEPAD_START buttons |= 0x0010; // XINPUT_GAMEPAD_START
} }
if (IS_KEY_DOWN(0x31)) { if (IS_KEY_DOWN('1')) {
// 1 // 1
buttons |= 0x0100; // XINPUT_GAMEPAD_LEFT_SHOULDER buttons |= 0x0100; // XINPUT_GAMEPAD_LEFT_SHOULDER
} }
if (IS_KEY_DOWN(0x33)) { if (IS_KEY_DOWN('3')) {
// 3 // 3
buttons |= 0x0200; // XINPUT_GAMEPAD_RIGHT_SHOULDER buttons |= 0x0200; // XINPUT_GAMEPAD_RIGHT_SHOULDER
} }