Fix missing slider joystick handling on Windows

(cherry picked from commit aa01b327d6)
This commit is contained in:
Bastiaan Olij 2020-06-20 19:03:15 +10:00 committed by Rémi Verschelde
parent cdbbc75e90
commit 70fb79efa0
2 changed files with 11 additions and 6 deletions

View File

@ -179,6 +179,7 @@ bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE *instance) {
sprintf_s(uid, "%04x%04x%04x%04x%04x%04x%04x%04x", type, 0, vendor, 0, product, 0, version, 0); sprintf_s(uid, "%04x%04x%04x%04x%04x%04x%04x%04x", type, 0, vendor, 0, product, 0, version, 0);
id_to_change = joypad_count; id_to_change = joypad_count;
slider_count = 0;
joy->di_joy->SetDataFormat(&c_dfDIJoystick2); joy->di_joy->SetDataFormat(&c_dfDIJoystick2);
joy->di_joy->SetCooperativeLevel(*hWnd, DISCL_FOREGROUND); joy->di_joy->SetCooperativeLevel(*hWnd, DISCL_FOREGROUND);
@ -215,9 +216,12 @@ void JoypadWindows::setup_joypad_object(const DIDEVICEOBJECTINSTANCE *ob, int p_
ofs = DIJOFS_RY; ofs = DIJOFS_RY;
else if (ob->guidType == GUID_RzAxis) else if (ob->guidType == GUID_RzAxis)
ofs = DIJOFS_RZ; ofs = DIJOFS_RZ;
else if (ob->guidType == GUID_Slider) else if (ob->guidType == GUID_Slider) {
ofs = DIJOFS_SLIDER(0); if (slider_count < 2) {
else ofs = DIJOFS_SLIDER(slider_count);
slider_count++;
}
} else
return; return;
prop_range.diph.dwSize = sizeof(DIPROPRANGE); prop_range.diph.dwSize = sizeof(DIPROPRANGE);
prop_range.diph.dwHeaderSize = sizeof(DIPROPHEADER); prop_range.diph.dwHeaderSize = sizeof(DIPROPHEADER);
@ -419,9 +423,9 @@ void JoypadWindows::process_joypads() {
} }
// on mingw, these constants are not constants // on mingw, these constants are not constants
int count = 6; int count = 8;
unsigned int axes[] = { DIJOFS_X, DIJOFS_Y, DIJOFS_Z, DIJOFS_RX, DIJOFS_RY, DIJOFS_RZ }; unsigned int axes[] = { DIJOFS_X, DIJOFS_Y, DIJOFS_Z, DIJOFS_RX, DIJOFS_RY, DIJOFS_RZ, DIJOFS_SLIDER(0), DIJOFS_SLIDER(1) };
int values[] = { js.lX, js.lY, js.lZ, js.lRx, js.lRy, js.lRz }; int values[] = { js.lX, js.lY, js.lZ, js.lRx, js.lRy, js.lRz, js.rglSlider[0], js.rglSlider[1] };
for (int j = 0; j < joy->joy_axis.size(); j++) { for (int j = 0; j < joy->joy_axis.size(); j++) {

View File

@ -120,6 +120,7 @@ private:
InputDefault *input; InputDefault *input;
int id_to_change; int id_to_change;
int slider_count;
int joypad_count; int joypad_count;
bool attached_joypads[JOYPADS_MAX]; bool attached_joypads[JOYPADS_MAX];
dinput_gamepad d_joypads[JOYPADS_MAX]; dinput_gamepad d_joypads[JOYPADS_MAX];