From 51603f052220b6240ac9c316ab791c3738e260ef Mon Sep 17 00:00:00 2001 From: skidau Date: Tue, 1 Jan 2013 13:49:22 +1100 Subject: [PATCH] * Implemented working pedal support. * Changed the mapping of the steering wheel to: Main Stick Left/Right = Steer Left/Right Main Stick Up = Accelerate Main Stick Down = Brake * Fixed non-force feedback controllers that were not detected --- .../Core/Src/HW/SI_DeviceGCSteeringWheel.cpp | 23 ++++++++++++++++--- .../Core/Src/HW/SI_DeviceGCSteeringWheel.h | 1 + .../DInput/DInputJoystick.cpp | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/Src/HW/SI_DeviceGCSteeringWheel.cpp b/Source/Core/Core/Src/HW/SI_DeviceGCSteeringWheel.cpp index 113fe186b1..7783261da9 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceGCSteeringWheel.cpp +++ b/Source/Core/Core/Src/HW/SI_DeviceGCSteeringWheel.cpp @@ -92,6 +92,10 @@ int CSIDevice_GCSteeringWheel::RunBuffer(u8* _pBuffer, int _iLength) } break; + // Seen in F-Zero GX + case CMD_MOTOR_OFF: + break; + // DEFAULT default: { @@ -144,12 +148,12 @@ bool CSIDevice_GCSteeringWheel::GetData(u32& _Hi, u32& _Low) Movie::CheckPadStatus(&PadStatus, ISIDevice::m_iDeviceNumber); // Thankfully changing mode does not change the high bits ;) - _Hi = (u32)((u8)PadStatus.stickY); - _Hi |= (u32)((u8)PadStatus.stickX << 8); + _Hi = (u32)((u8)PadStatus.stickX); // Steering + _Hi |= 0x800; // Pedal connected flag _Hi |= (u32)((u16)(PadStatus.button | PAD_USE_ORIGIN) << 16); // Low bits are packed differently per mode - if (m_Mode == 0 || m_Mode == 5 || m_Mode == 6 || m_Mode == 7) + if (m_Mode == 0 || m_Mode == 5 || m_Mode == 7) { _Low = (u8)(PadStatus.analogB >> 4); // Top 4 bits _Low |= (u32)((u8)(PadStatus.analogA >> 4) << 4); // Top 4 bits @@ -192,6 +196,19 @@ bool CSIDevice_GCSteeringWheel::GetData(u32& _Hi, u32& _Low) _Low |= (u32)((u8)PadStatus.substickY << 16); // All 8 bits _Low |= (u32)((u8)PadStatus.substickX << 24); // All 8 bits } + else if (m_Mode == 6) + { + _Low = (u8)PadStatus.triggerRight; // All 8 bits + _Low |= (u32)((u8)PadStatus.triggerLeft << 8); // All 8 bits + + // The GC Steering Wheel appears to have combined pedals + // (both the Accelerate and Brake pedals are mapped to a single axis) + // We use the stickY axis for the pedals. + if (PadStatus.stickY < 128) + _Low |= (u32)((u8)(255 - ((PadStatus.stickY & 0x7f) * 2)) << 16); // All 8 bits (Brake) + if (PadStatus.stickY >= 128) + _Low |= (u32)((u8)((PadStatus.stickY & 0x7f) * 2) << 24); // All 8 bits (Accelerate) + } // Keep track of the special button combos (embedded in controller hardware... :( ) EButtonCombo tempCombo; diff --git a/Source/Core/Core/Src/HW/SI_DeviceGCSteeringWheel.h b/Source/Core/Core/Src/HW/SI_DeviceGCSteeringWheel.h index 1814c8d6e4..2245765863 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceGCSteeringWheel.h +++ b/Source/Core/Core/Src/HW/SI_DeviceGCSteeringWheel.h @@ -33,6 +33,7 @@ private: CMD_RESET = 0x00, CMD_ORIGIN = 0x41, CMD_RECALIBRATE = 0x42, + CMD_MOTOR_OFF = 0xff, }; struct SOrigin diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp index 5f80b6f32b..b7ac3bf82e 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp +++ b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp @@ -145,7 +145,7 @@ LCleanup: void InitJoystick(IDirectInput8* const idi8, std::vector& devices, HWND hwnd) { std::list joysticks; - idi8->EnumDevices( DI8DEVCLASS_GAMECTRL, DIEnumDevicesCallback, (LPVOID)&joysticks, DIEDFL_FORCEFEEDBACK | DIEDFL_ATTACHEDONLY ); + idi8->EnumDevices( DI8DEVCLASS_GAMECTRL, DIEnumDevicesCallback, (LPVOID)&joysticks, DIEDFL_ATTACHEDONLY ); // this is used to number the joysticks // multiple joysticks with the same name shall get unique ids starting at 0