summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/Src/ControllerInterface/DInput
diff options
context:
space:
mode:
authorskidau <skidau@gmail.com>2012-12-30 13:41:48 +1100
committerskidau <skidau@gmail.com>2012-12-30 13:41:48 +1100
commit5ccbcf455e437031cb2542db0804a341cc9150cc (patch)
treeb035364abe28750f52617f84b0d3153d6a20ec03 /Source/Core/InputCommon/Src/ControllerInterface/DInput
parent94116bf89c917309b7e7b2a2b46bf2f43f3219db (diff)
Added preliminary GameCube Steering Wheel emulation via a PC Force Feedback Steering Wheel.
Diffstat (limited to 'Source/Core/InputCommon/Src/ControllerInterface/DInput')
-rw-r--r--Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/Src/ControllerInterface/DInput/DInputJoystick.cpp
index 08d62bcfc1..5f80b6f32b 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<ControllerInterface::Device*>& devices, HWND hwnd)
{
std::list<DIDEVICEINSTANCE> joysticks;
- idi8->EnumDevices( DI8DEVCLASS_GAMECTRL, DIEnumDevicesCallback, (LPVOID)&joysticks, DIEDFL_ATTACHEDONLY );
+ idi8->EnumDevices( DI8DEVCLASS_GAMECTRL, DIEnumDevicesCallback, (LPVOID)&joysticks, DIEDFL_FORCEFEEDBACK | DIEDFL_ATTACHEDONLY );
// this is used to number the joysticks
// multiple joysticks with the same name shall get unique ids starting at 0
@@ -254,9 +254,9 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI
for (unsigned int offset = 0; offset < DIJOFS_BUTTON(0) / sizeof(LONG); ++offset)
{
range.diph.dwObj = offset * sizeof(LONG);
- // try to set some nice power of 2 values (8192)
- range.lMin = -(1 << 13);
- range.lMax = (1 << 13);
+ // try to set some nice power of 2 values (128) to match the GameCube controls
+ range.lMin = -(1 << 7);
+ range.lMax = (1 << 7);
m_device->SetProperty(DIPROP_RANGE, &range.diph);
// but i guess not all devices support setting range
// so i getproperty right afterward incase it didn't set :P
@@ -281,17 +281,19 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI
if ( objects.size() )
{
// temporary
- DWORD rgdwAxes[] = {DIJOFS_X, DIJOFS_Y};
- LONG rglDirection[] = {0, 0};
+ DWORD rgdwAxes[2] = {DIJOFS_X, DIJOFS_Y};
+ LONG rglDirection[2] = {-200, 0};
DIEFFECT eff;
ZeroMemory(&eff, sizeof(eff));
eff.dwSize = sizeof(DIEFFECT);
eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
eff.dwDuration = INFINITE; // (4 * DI_SECONDS)
+ eff.dwSamplePeriod = 0;
eff.dwGain = DI_FFNOMINALMAX;
eff.dwTriggerButton = DIEB_NOTRIGGER;
- eff.cAxes = std::min((DWORD)2, (DWORD)objects.size());
+ eff.dwTriggerRepeatInterval = 0;
+ eff.cAxes = std::min((DWORD)1, (DWORD)objects.size());
eff.rgdwAxes = rgdwAxes;
eff.rglDirection = rglDirection;
@@ -310,7 +312,12 @@ Joystick::Joystick( /*const LPCDIDEVICEINSTANCE lpddi, */const LPDIRECTINPUTDEVI
{
// ugly if ladder
if (0 == f)
+ {
+ DICONSTANTFORCE diCF = {-10000};
+ diCF.lMagnitude = DI_FFNOMINALMAX;
eff.cbTypeSpecificParams = sizeof(DICONSTANTFORCE);
+ eff.lpvTypeSpecificParams = &diCF;
+ }
else if (1 == f)
eff.cbTypeSpecificParams = sizeof(DIRAMPFORCE);
else
@@ -528,7 +535,11 @@ ControlState Joystick::Hat::GetState() const
void Joystick::ForceConstant::SetState(const ControlState state)
{
- const LONG new_val = LONG(10000 * state);
+ float force = abs(state - 0.5) * 2;
+ if (state < 0.5)
+ force = -force;
+
+ const LONG new_val = LONG(10000 * force);
LONG &val = params.lMagnitude;
if (val != new_val)