diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2010-04-29 18:51:04 +0000 |
|---|---|---|
| committer | Jordan Woyak <jordan.woyak@gmail.com> | 2010-04-29 18:51:04 +0000 |
| commit | 22c2276cef00c92ecaa814c777ab72de86477e90 (patch) | |
| tree | a3f68bec6cdefcc59eb70cc22061dcfd38619a08 /Source/Core/InputCommon/Src/ControllerInterface/DirectInput | |
| parent | 81f06220cec97e093d75e862f98e4b2853cd89a7 (diff) | |
New Wiimote Plugin: Added "Upright Wiimote" option. Fixed a nunchuk problem in ZTP and Wii Sports with some Hacks. Some work on emulated Swing and Speaker (disabled). Fixes/Cleanups. ControllerInterface: Fixed an issue when a DInput device reports the same axis more than once. Fixed some old comments.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5422 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/InputCommon/Src/ControllerInterface/DirectInput')
| -rw-r--r-- | Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputJoystick.cpp | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputJoystick.cpp b/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputJoystick.cpp index 44b0e1ee08..2b6bf6bb76 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputJoystick.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputJoystick.cpp @@ -4,6 +4,11 @@ #include "DirectInputJoystick.h" +inline bool operator<(const GUID & lhs, const GUID & rhs) +{ + return memcmp(&lhs, &rhs, sizeof(GUID)) < 0 ? true : false; +} + namespace ciface { namespace DirectInput @@ -231,8 +236,18 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI } // get up to 6 axes and 2 sliders std::vector<DIDEVICEOBJECTINSTANCE> axes; + m_device->EnumObjects( DIEnumDeviceObjectsCallback, (LPVOID)&axes, DIDFT_ABSAXIS ); + unsigned int cur_slider = 0; - m_device->EnumObjects( DIEnumDeviceObjectsCallback, (LPVOID)&axes, DIDFT_AXIS ); + + // map of axis offsets in joystate dataformat based on axis guidType + std::map<GUID,int> types; + types[GUID_XAxis] = 0; + types[GUID_YAxis] = 1; + types[GUID_ZAxis] = 2; + types[GUID_RxAxis] = 3; + types[GUID_RyAxis] = 4; + types[GUID_RzAxis] = 5; // going in reverse leaves the list more organized in the end for me :/ std::vector<DIDEVICEOBJECTINSTANCE>::const_reverse_iterator i = axes.rbegin(), @@ -254,24 +269,25 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI if ( DI_OK == m_device->GetProperty( DIPROP_RANGE, &range.diph ) ) { int offset = -1; - const GUID type = i->guidType; - - // figure out which axis this is - if ( type == GUID_XAxis ) - offset = 0; - else if ( type == GUID_YAxis ) - offset = 1; - else if ( type == GUID_ZAxis ) - offset = 2; - else if ( type == GUID_RxAxis ) - offset = 3; - else if ( type == GUID_RyAxis ) - offset = 4; - else if ( type == GUID_RzAxis ) - offset = 5; - else if ( type == GUID_Slider ) - if ( cur_slider < 2 ) + + if (GUID_Slider ==i->guidType) + { + // max of 2 sliders / limit of used data format + if (cur_slider < 2) offset = 6 + cur_slider++; + } + else + { + // don't add duplicate axes, some buggy drivers report the same axis twice + const std::map<GUID,int>::iterator f = types.find(i->guidType); + if (types.end() != f) + { + offset = f->second; + // remove from the map so it isn't added again + types.erase(f); + } + } + if ( offset >= 0 ) { |
