* 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
This commit is contained in:
skidau 2013-01-01 13:49:22 +11:00
parent 5ccbcf455e
commit 51603f0522
3 changed files with 22 additions and 4 deletions

View File

@ -92,6 +92,10 @@ int CSIDevice_GCSteeringWheel::RunBuffer(u8* _pBuffer, int _iLength)
} }
break; break;
// Seen in F-Zero GX
case CMD_MOTOR_OFF:
break;
// DEFAULT // DEFAULT
default: default:
{ {
@ -144,12 +148,12 @@ bool CSIDevice_GCSteeringWheel::GetData(u32& _Hi, u32& _Low)
Movie::CheckPadStatus(&PadStatus, ISIDevice::m_iDeviceNumber); Movie::CheckPadStatus(&PadStatus, ISIDevice::m_iDeviceNumber);
// Thankfully changing mode does not change the high bits ;) // Thankfully changing mode does not change the high bits ;)
_Hi = (u32)((u8)PadStatus.stickY); _Hi = (u32)((u8)PadStatus.stickX); // Steering
_Hi |= (u32)((u8)PadStatus.stickX << 8); _Hi |= 0x800; // Pedal connected flag
_Hi |= (u32)((u16)(PadStatus.button | PAD_USE_ORIGIN) << 16); _Hi |= (u32)((u16)(PadStatus.button | PAD_USE_ORIGIN) << 16);
// Low bits are packed differently per mode // 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 = (u8)(PadStatus.analogB >> 4); // Top 4 bits
_Low |= (u32)((u8)(PadStatus.analogA >> 4) << 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.substickY << 16); // All 8 bits
_Low |= (u32)((u8)PadStatus.substickX << 24); // 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... :( ) // Keep track of the special button combos (embedded in controller hardware... :( )
EButtonCombo tempCombo; EButtonCombo tempCombo;

View File

@ -33,6 +33,7 @@ private:
CMD_RESET = 0x00, CMD_RESET = 0x00,
CMD_ORIGIN = 0x41, CMD_ORIGIN = 0x41,
CMD_RECALIBRATE = 0x42, CMD_RECALIBRATE = 0x42,
CMD_MOTOR_OFF = 0xff,
}; };
struct SOrigin struct SOrigin

View File

@ -145,7 +145,7 @@ LCleanup:
void InitJoystick(IDirectInput8* const idi8, std::vector<ControllerInterface::Device*>& devices, HWND hwnd) void InitJoystick(IDirectInput8* const idi8, std::vector<ControllerInterface::Device*>& devices, HWND hwnd)
{ {
std::list<DIDEVICEINSTANCE> joysticks; std::list<DIDEVICEINSTANCE> 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 // this is used to number the joysticks
// multiple joysticks with the same name shall get unique ids starting at 0 // multiple joysticks with the same name shall get unique ids starting at 0