From 736b5a2659f4ac26abd50698d8b29c96e80d241a Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Tue, 15 May 2012 12:24:09 +0000 Subject: [PATCH] input: support up to 16 buttons in Xbox-like pads. --- src/platform/d3d9/d3d9input.cpp | 5 ++++- src/platform/xbox/xboxinput.cpp | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/platform/d3d9/d3d9input.cpp b/src/platform/d3d9/d3d9input.cpp index b13e616e..4c0b5780 100644 --- a/src/platform/d3d9/d3d9input.cpp +++ b/src/platform/d3d9/d3d9input.cpp @@ -53,7 +53,7 @@ D3d9Input::D3d9Input() Stick *stick = Input::CreateStick(); stick->SetAxisCount(4); - stick->SetButtonCount(0); + stick->SetButtonCount(16); m_data->m_joysticks.Push(i, stick); } #endif @@ -94,6 +94,9 @@ void D3d9Input::TickDraw(float seconds) m_data->m_joysticks[i].m2->SetAxis(1, -(float)state.Gamepad.sThumbLY / 32768.f); m_data->m_joysticks[i].m2->SetAxis(2, (float)state.Gamepad.sThumbRX / 32768.f); m_data->m_joysticks[i].m2->SetAxis(3, -(float)state.Gamepad.sThumbRY / 32768.f); + + for (int b = 0; b < 16; b++) + m_data->m_joysticks[i].m2->SetButton(b, ((uint16_t)(state.Gamepad.wButtons) >> b) & 1); } #endif } diff --git a/src/platform/xbox/xboxinput.cpp b/src/platform/xbox/xboxinput.cpp index da6f21b2..ac2cb0a4 100644 --- a/src/platform/xbox/xboxinput.cpp +++ b/src/platform/xbox/xboxinput.cpp @@ -53,7 +53,7 @@ XboxInput::XboxInput() Stick *stick = Input::CreateStick(); stick->SetAxisCount(4); - stick->SetButtonCount(0); + stick->SetButtonCount(16); m_data->m_joysticks.Push(i, stick); } #endif @@ -94,6 +94,9 @@ void XboxInput::TickDraw(float seconds) m_data->m_joysticks[i].m2->SetAxis(1, -(float)state.Gamepad.sThumbLY / 32768.f); m_data->m_joysticks[i].m2->SetAxis(2, (float)state.Gamepad.sThumbRX / 32768.f); m_data->m_joysticks[i].m2->SetAxis(3, -(float)state.Gamepad.sThumbRY / 32768.f); + + for (int b = 0; b < 16; b++) + m_data->m_joysticks[i].m2->SetButton(b, ((uint16_t)(state.Gamepad.wButtons) >> b) & 1); } #endif }