diff options
author | 2023-03-29 15:11:07 +1100 | |
---|---|---|
committer | 2023-03-29 15:11:07 +1100 | |
commit | 664f2107750db3d5740149fed8e4d2db49fce65b (patch) | |
tree | 06176611e92d67188d457cabf1f242a73b07eb90 | |
parent | 1302585d33108600b9d4f2cd8af569de3d9a5d42 (diff) |
osd/modules/input/input_dinput.cpp: Adjusted heuristics to work better with newer DualShock/DualSense controllers.
-rw-r--r-- | src/osd/modules/input/input_dinput.cpp | 32 | ||||
-rw-r--r-- | src/osd/modules/input/input_dinput.h | 18 |
2 files changed, 25 insertions, 25 deletions
diff --git a/src/osd/modules/input/input_dinput.cpp b/src/osd/modules/input/input_dinput.cpp index 6cbe668c108..eec5904b3ac 100644 --- a/src/osd/modules/input/input_dinput.cpp +++ b/src/osd/modules/input/input_dinput.cpp @@ -51,13 +51,13 @@ might expect from the HID mapping. Gamepads: -Axis Logitech Xinput Switch -X Left X Left X Left X -Y Left Y Left Y Left Y -Z Right X Triggers -Rx Right X Right X -Ry Right Y Right Y -Rz Right Y +Axis Logitech DS4 Xinput Switch +X Left X Left X Left X Left X +Y Left Y Left Y Left Y Left Y +Z Right X Right X Triggers +Rx Left trigger Right X Right X +Ry Right trigger Right Y Right Y +Rz Right Y Right Y Thrustmaster controllers: @@ -1041,12 +1041,11 @@ void dinput_joystick_device::configure(input_device &device) { axisitems[0], axisitems[1] }, { ITEM_ID_INVALID, ITEM_ID_INVALID } }; input_item_id pedalaxis = ITEM_ID_INVALID; - if ((ITEM_ID_INVALID != axisitems[3]) && (ITEM_ID_INVALID != axisitems[4])) + if ((ITEM_ID_INVALID != axisitems[2]) && (ITEM_ID_INVALID != axisitems[5])) { - // assume Rx/Ry are right stick and Z is triggers if present - stickaxes[1][0] = axisitems[3]; - stickaxes[1][1] = axisitems[4]; - pedalaxis = axisitems[2]; + // assume Z/Rz are right stick + stickaxes[1][0] = axisitems[2]; + stickaxes[1][1] = axisitems[5]; add_twin_stick_assignments( assignments, stickaxes[0][0], @@ -1062,11 +1061,12 @@ void dinput_joystick_device::configure(input_device &device) ITEM_ID_INVALID, ITEM_ID_INVALID); } - else if ((ITEM_ID_INVALID != axisitems[2]) && (ITEM_ID_INVALID != axisitems[5])) + else if ((ITEM_ID_INVALID != axisitems[3]) && (ITEM_ID_INVALID != axisitems[4])) { - // assume Z/Rz are right stick - stickaxes[1][0] = axisitems[2]; - stickaxes[1][1] = axisitems[5]; + // assume Rx/Ry are right stick and Z is triggers if present + stickaxes[1][0] = axisitems[3]; + stickaxes[1][1] = axisitems[4]; + pedalaxis = axisitems[2]; add_twin_stick_assignments( assignments, stickaxes[0][0], diff --git a/src/osd/modules/input/input_dinput.h b/src/osd/modules/input/input_dinput.h index 037c9c0c511..b7fc942aaec 100644 --- a/src/osd/modules/input/input_dinput.h +++ b/src/osd/modules/input/input_dinput.h @@ -24,6 +24,7 @@ #include <mutex> #include <string> #include <string_view> +#include <type_traits> #include <utility> #include <windows.h> @@ -87,17 +88,10 @@ public: template <typename T> HRESULT enum_attached_devices(int devclass, T &&callback) const { - struct helper - { - static BOOL CALLBACK callback(LPCDIDEVICEINSTANCE instance, LPVOID ref) - { - return (*reinterpret_cast<T *>(ref))(instance); - } - }; return m_dinput->EnumDevices( devclass, - &helper::callback, - reinterpret_cast<LPVOID>(&callback), + &di_emun_devices_cb<std::remove_reference_t<T> >, + LPVOID(&callback), DIEDFL_ATTACHEDONLY); } @@ -128,6 +122,12 @@ private: static std::string make_id(LPCDIDEVICEINSTANCE instance); + template <typename T> + static BOOL CALLBACK di_emun_devices_cb(LPCDIDEVICEINSTANCE instance, LPVOID ref) + { + return (*reinterpret_cast<T *>(ref))(instance); + } + Microsoft::WRL::ComPtr<IDirectInput8> m_dinput; dynamic_module::ptr m_dinput_dll; }; |