Skip to content

Commit

Permalink
Added GC Steering Wheel emulation.
Browse files Browse the repository at this point in the history
To set it up, change the Port 1 controller to "Steering Wheel" under the GameCube tab.  This will tell the game that you have a force feedback steering wheel connected.
In the Gamecube Pad Settings, change the Rumble Motor to "Constant".
Configure the controls:

Main Stick Left/Right = Steer Left/Right
Main Stick Up = Accelerate
Main Stick Down = Brake

Thanks to ulao for the device communications info.
  • Loading branch information
skidau committed Jan 4, 2013
2 parents 9b51c99 + 3fd1b4e commit 4d6056f
Show file tree
Hide file tree
Showing 13 changed files with 519 additions and 14 deletions.
1 change: 1 addition & 0 deletions Source/Core/Core/CMakeLists.txt
Expand Up @@ -115,6 +115,7 @@ set(SRCS Src/ActionReplay.cpp
Src/HW/SI_Device.cpp
Src/HW/SI_DeviceGBA.cpp
Src/HW/SI_DeviceGCController.cpp
Src/HW/SI_DeviceGCSteeringWheel.cpp
Src/HW/Sram.cpp
Src/HW/StreamADPCM.cpp
Src/HW/SystemTimers.cpp
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/Core.vcxproj
Expand Up @@ -301,6 +301,7 @@
<ClCompile Include="Src\HW\SI_DeviceAMBaseboard.cpp" />
<ClCompile Include="Src\HW\SI_DeviceGBA.cpp" />
<ClCompile Include="Src\HW\SI_DeviceGCController.cpp" />
<ClCompile Include="Src\HW\SI_DeviceGCSteeringWheel.cpp" />
<ClCompile Include="Src\HW\Sram.cpp" />
<ClCompile Include="Src\HW\StreamADPCM.cpp" />
<ClCompile Include="Src\HW\SystemTimers.cpp" />
Expand Down Expand Up @@ -503,6 +504,7 @@
<ClInclude Include="Src\HW\SI_DeviceAMBaseboard.h" />
<ClInclude Include="Src\HW\SI_DeviceGBA.h" />
<ClInclude Include="Src\HW\SI_DeviceGCController.h" />
<ClInclude Include="Src\HW\SI_DeviceGCSteeringWheel.h" />
<ClInclude Include="Src\HW\Sram.h" />
<ClInclude Include="Src\HW\StreamADPCM.h" />
<ClInclude Include="Src\HW\SystemTimers.h" />
Expand Down
6 changes: 6 additions & 0 deletions Source/Core/Core/Core.vcxproj.filters
Expand Up @@ -290,6 +290,9 @@
<ClCompile Include="Src\HW\SI_DeviceGCController.cpp">
<Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
</ClCompile>
<ClCompile Include="Src\HW\SI_DeviceGCSteeringWheel.cpp">
<Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
</ClCompile>
<ClCompile Include="Src\HW\VideoInterface.cpp">
<Filter>HW %28Flipper/Hollywood%29\VI - Video Interface</Filter>
</ClCompile>
Expand Down Expand Up @@ -814,6 +817,9 @@
<ClInclude Include="Src\HW\SI_DeviceGCController.h">
<Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
</ClInclude>
<ClInclude Include="Src\HW\SI_DeviceGCSteeringWheel.h">
<Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
</ClInclude>
<ClInclude Include="Src\HW\SI.h">
<Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
</ClInclude>
Expand Down
27 changes: 26 additions & 1 deletion Source/Core/Core/Src/HW/GCPad.cpp
Expand Up @@ -101,7 +101,32 @@ void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
{
// TODO: this has potential to not stop rumble if user is messing with GUI at the perfect time
// set rumble
((GCPad*)g_plugin.controllers[ _numPAD ])->SetOutput( 1 == _uType && _uStrength > 2 );
if (1 == _uType && _uStrength > 2)
{
((GCPad*)g_plugin.controllers[ _numPAD ])->SetOutput(255);
}
}
}

// __________________________________________________________________________________________________
// Function: Motor
// Purpose: For devices with constant Force feedback
// input: Type - 06 = Motor On, 04 = Motor Off
// Strength - 00 = Left Strong, 127 = Left Weak, 128 = Right Weak, 255 = Right Strong
// output: none
//
void Motor(u8 _numPAD, unsigned int _uType, unsigned int _uStrength)
{
std::unique_lock<std::recursive_mutex> lk(g_plugin.controls_lock, std::try_to_lock);

if (lk.owns_lock())
{
// TODO: this has potential to not stop rumble if user is messing with GUI at the perfect time
// set rumble
if (_uType == 06)
{
((GCPad*)g_plugin.controllers[ _numPAD ])->SetOutput(_uStrength);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions Source/Core/Core/Src/HW/GCPad.h
Expand Up @@ -32,6 +32,7 @@ InputPlugin *GetPlugin();

void GetStatus(u8 _numPAD, SPADStatus* _pPADStatus);
void Rumble(u8 _numPAD, unsigned int _uType, unsigned int _uStrength);
void Motor(u8 _numPAD, unsigned int _uType, unsigned int _uStrength);

bool GetMicButton(u8 pad);
}
Expand Down
7 changes: 5 additions & 2 deletions Source/Core/Core/Src/HW/GCPadEmu.cpp
Expand Up @@ -130,10 +130,13 @@ void GCPad::GetInput(SPADStatus* const pad)
}
}

void GCPad::SetOutput(const bool on)
void GCPad::SetOutput(const u8 on)
{
// only rumble if window has focus or background input is enabled
m_rumble->controls[0]->control_ref->State(on && (Host_RendererHasFocus() || m_options[0].settings[0]->value));
if (Host_RendererHasFocus() || m_options[0].settings[0]->value)
m_rumble->controls[0]->control_ref->State((float)on / 255);
else
m_rumble->controls[0]->control_ref->State(0);
}

void GCPad::LoadDefaults(const ControllerInterface& ciface)
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/Src/HW/GCPadEmu.h
Expand Up @@ -28,7 +28,7 @@ class GCPad : public ControllerEmu

GCPad(const unsigned int index);
void GetInput(SPADStatus* const pad);
void SetOutput(const bool on);
void SetOutput(const u8 on);

bool GetMicButton() const;

Expand Down
5 changes: 5 additions & 0 deletions Source/Core/Core/Src/HW/SI_Device.cpp
Expand Up @@ -17,6 +17,7 @@

#include "SI_Device.h"
#include "SI_DeviceGCController.h"
#include "SI_DeviceGCSteeringWheel.h"
#include "SI_DeviceGBA.h"
#include "SI_DeviceAMBaseboard.h"

Expand Down Expand Up @@ -76,6 +77,10 @@ ISIDevice* SIDevice_Create(const SIDevices device, const int port_number)
return new CSIDevice_GCController(device, port_number);
break;

case SIDEVICE_GC_STEERING:
return new CSIDevice_GCSteeringWheel(device, port_number);
break;

case SIDEVICE_GC_TARUKONGA:
return new CSIDevice_TaruKonga(device, port_number);
break;
Expand Down

0 comments on commit 4d6056f

Please sign in to comment.