mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-13 00:58:29 +02:00
Added preliminary GameCube Steering Wheel emulation via a PC Force Feedback Steering Wheel.
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user