support multiple game devices.

This commit is contained in:
zeromus 2009-10-30 06:05:43 +00:00
parent a248e403d6
commit 67a9a34dfa
2 changed files with 290 additions and 272 deletions

View File

@ -19,7 +19,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//*/ //*/
//TODO - rumble is broken. hopefully nobody will notice
#ifdef __MINGW32__ #ifdef __MINGW32__
#define _WIN32_IE 0x0501 #define _WIN32_IE 0x0501
@ -276,19 +276,20 @@ typedef char TcDIBuf[512];
TcDIBuf cDIBuf; TcDIBuf cDIBuf;
LPDIRECTINPUT8 pDI; LPDIRECTINPUT8 pDI;
LPDIRECTINPUTDEVICE8 pJoystick;
DIDEVCAPS DIJoycap; DIDEVCAPS DIJoycap;
LPDIRECTINPUTEFFECT pEffect; LPDIRECTINPUTEFFECT pEffect;
char JoystickName[255];
BOOL Feedback; BOOL Feedback;
static LPDIRECTINPUT8 tmp_pDI = NULL; static LPDIRECTINPUT8 tmp_pDI = NULL;
static BOOL tmp_Feedback = FALSE;
static char tmp_device_name[255] = { 0 }; static char tmp_device_name[255] = { 0 };
static LPDIRECTINPUTDEVICE8 tmp_Device = NULL; static LPDIRECTINPUTDEVICE8 tmp_Device = NULL;
static LPDIRECTINPUTDEVICE8 tmp_Joystick = NULL; static LPDIRECTINPUTDEVICE8 tmp_Joystick = NULL;
std::vector<LPDIRECTINPUTDEVICE8> joyDevices;
std::vector<std::string> joyDeviceNames;
std::vector<bool> joyDeviceFeedback;
BOOL CALLBACK EnumCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef) BOOL CALLBACK EnumCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
{ {
if ( FAILED( tmp_pDI->CreateDevice(lpddi->guidInstance, &tmp_Device, NULL) ) ) if ( FAILED( tmp_pDI->CreateDevice(lpddi->guidInstance, &tmp_Device, NULL) ) )
@ -297,25 +298,21 @@ BOOL CALLBACK EnumCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
return DIENUM_CONTINUE; return DIENUM_CONTINUE;
} }
strcpy(tmp_device_name, lpddi->tszProductName); joyDevices.push_back(tmp_Device);
if (lpddi->guidFFDriver.Data1) tmp_Feedback = TRUE; joyDeviceNames.push_back(lpddi->tszProductName);
return DIENUM_STOP; if (lpddi->guidFFDriver.Data1) joyDeviceFeedback.push_back(true);
else joyDeviceFeedback.push_back(false);
return DIENUM_CONTINUE;
} }
LPDIRECTINPUTDEVICE8 EnumDevices(LPDIRECTINPUT8 pDI) static void EnumDevices(LPDIRECTINPUT8 pDI)
{ {
tmp_pDI = pDI; tmp_pDI = pDI;
tmp_Feedback = FALSE; pDI->EnumDevices(DI8DEVCLASS_GAMECTRL,
memset(tmp_device_name, 0, 255);
if( FAILED( pDI->EnumDevices(DI8DEVCLASS_GAMECTRL,
EnumCallback, EnumCallback,
NULL, NULL,
DIEDFL_ATTACHEDONLY) ) ) DIEDFL_ATTACHEDONLY);
return NULL;
Feedback = tmp_Feedback;
strcpy(JoystickName, tmp_device_name);
return tmp_Device;
} }
BOOL CALLBACK EnumObjects(const DIDEVICEOBJECTINSTANCE* pdidoi,VOID* pContext) BOOL CALLBACK EnumObjects(const DIDEVICEOBJECTINSTANCE* pdidoi,VOID* pContext)
@ -439,90 +436,99 @@ static void SaveInputConfig()
BOOL di_init() BOOL di_init()
{ {
Feedback = FALSE;
HWND hParentWnd = MainWindow->getHWnd(); HWND hParentWnd = MainWindow->getHWnd();
pDI = NULL; pDI = NULL;
pJoystick = NULL;
Feedback = FALSE;
memset(cDIBuf, 0, sizeof(cDIBuf)); memset(cDIBuf, 0, sizeof(cDIBuf));
memset(JoystickName, 0, sizeof(JoystickName));
if(FAILED(DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION,IID_IDirectInput8,(void**)&pDI,NULL))) if(FAILED(DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION,IID_IDirectInput8,(void**)&pDI,NULL)))
return FALSE; return FALSE;
memset(&JoystickF,0,sizeof(JoystickF));
pJoystick = EnumDevices(pDI); EnumDevices(pDI);
if (pJoystick) for(int i=0;i<(int)joyDevices.size();i++) {
{ JoystickF[i].Attached = true;
if(!FAILED(pJoystick->SetDataFormat(&c_dfDIJoystick2))) JoystickF[i].Device = joyDevices[i];
LPDIRECTINPUTDEVICE8 pJoystick = joyDevices[i];
if (pJoystick)
{ {
if(FAILED(pJoystick->SetCooperativeLevel(hParentWnd,DISCL_BACKGROUND|DISCL_EXCLUSIVE))) if(!FAILED(pJoystick->SetDataFormat(&c_dfDIJoystick2)))
{ {
pJoystick->Release(); if(FAILED(pJoystick->SetCooperativeLevel(hParentWnd,DISCL_BACKGROUND|DISCL_EXCLUSIVE)))
pJoystick = NULL; {
pJoystick->Release();
pJoystick = NULL;
}
else
{
tmp_Joystick = pJoystick;
pJoystick->EnumObjects(::EnumObjects, (VOID*)hParentWnd, DIDFT_ALL);
memset(&DIJoycap,0,sizeof(DIDEVCAPS));
DIJoycap.dwSize=sizeof(DIDEVCAPS);
pJoystick->GetCapabilities(&DIJoycap);
}
} }
else else
{ {
tmp_Joystick = pJoystick; JoystickF[i].Attached = false;
pJoystick->EnumObjects(::EnumObjects, (VOID*)hParentWnd, DIDFT_ALL); JoystickF[i].Device = NULL;
memset(&DIJoycap,0,sizeof(DIDEVCAPS)); pJoystick->Release();
DIJoycap.dwSize=sizeof(DIDEVCAPS); pJoystick = NULL;
pJoystick->GetCapabilities(&DIJoycap);
} }
} }
else
if (pJoystick)
{ {
pJoystick->Release(); DIPROPDWORD dipdw;
pJoystick = NULL; dipdw.diph.dwSize = sizeof(DIPROPDWORD);
} dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
} dipdw.diph.dwObj = 0;
dipdw.diph.dwHow = DIPH_DEVICE;
dipdw.dwData = 0;
if ( !FAILED( pJoystick->SetProperty(DIPROP_AUTOCENTER, &dipdw.diph) ) )
{
DWORD rgdwAxes[1] = { DIJOFS_Y };
LONG rglDirection[2] = { 0 };
DICONSTANTFORCE cf = { 0 };
DIEFFECT eff;
if (pJoystick) cf.lMagnitude = (DI_FFNOMINALMAX * 100);
{
DIPROPDWORD dipdw; memset(&eff, 0, sizeof(eff));
dipdw.diph.dwSize = sizeof(DIPROPDWORD); eff.dwSize = sizeof(DIEFFECT);
dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
dipdw.diph.dwObj = 0; eff.dwDuration = INFINITE;
dipdw.diph.dwHow = DIPH_DEVICE; eff.dwSamplePeriod = 0;
dipdw.dwData = 0; eff.dwGain = DI_FFNOMINALMAX;
if ( !FAILED( pJoystick->SetProperty(DIPROP_AUTOCENTER, &dipdw.diph) ) ) eff.dwTriggerButton = DIEB_NOTRIGGER;
eff.dwTriggerRepeatInterval = 0;
eff.cAxes = 1;
eff.rgdwAxes = rgdwAxes;
eff.rglDirection = rglDirection;
eff.lpEnvelope = 0;
eff.cbTypeSpecificParams = sizeof( DICONSTANTFORCE );
eff.lpvTypeSpecificParams = &cf;
eff.dwStartDelay = 0;
//if( FAILED( pJoystick->CreateEffect(GUID_ConstantForce, &eff, &pEffect, NULL) ) )
// Feedback = FALSE;
}
else
//Feedback = FALSE;
{}
}
INFO("DirectX Input: \n");
if (pJoystick != NULL)
{ {
DWORD rgdwAxes[1] = { DIJOFS_Y }; INFO(" - gamecontrol successfully inited: %s\n", joyDeviceNames[i].c_str());
LONG rglDirection[2] = { 0 }; if (joyDeviceFeedback[i]) INFO("\t\t\t\t (with FeedBack support)\n");
DICONSTANTFORCE cf = { 0 };
DIEFFECT eff;
cf.lMagnitude = (DI_FFNOMINALMAX * 100);
memset(&eff, 0, sizeof(eff));
eff.dwSize = sizeof(DIEFFECT);
eff.dwFlags = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
eff.dwDuration = INFINITE;
eff.dwSamplePeriod = 0;
eff.dwGain = DI_FFNOMINALMAX;
eff.dwTriggerButton = DIEB_NOTRIGGER;
eff.dwTriggerRepeatInterval = 0;
eff.cAxes = 1;
eff.rgdwAxes = rgdwAxes;
eff.rglDirection = rglDirection;
eff.lpEnvelope = 0;
eff.cbTypeSpecificParams = sizeof( DICONSTANTFORCE );
eff.lpvTypeSpecificParams = &cf;
eff.dwStartDelay = 0;
if( FAILED( pJoystick->CreateEffect(GUID_ConstantForce, &eff, &pEffect, NULL) ) )
Feedback = FALSE;
} }
else
Feedback = FALSE;
}
INFO("DirectX Input: \n");
if (pJoystick != NULL)
{
INFO(" - gamecontrol successfully inited: %s\n", JoystickName);
if (Feedback) INFO("\t\t\t\t (with FeedBack support)\n");
} }
paused = FALSE; paused = FALSE;
@ -530,10 +536,10 @@ BOOL di_init()
return TRUE; return TRUE;
} }
BOOL JoystickEnabled() //BOOL JoystickEnabled()
{ //{
return (pJoystick==NULL?FALSE:TRUE); // return (pJoystick==NULL?FALSE:TRUE);
} //}
HWND funky; HWND funky;
@ -643,69 +649,73 @@ void S9xUpdateJoyState()
{ {
memset(&Joystick[0],0,sizeof(Joystick[0])); memset(&Joystick[0],0,sizeof(Joystick[0]));
int C = 0; for(int C=0;C<16;C++)
if (pJoystick)
{ {
DIJOYSTATE2 JoyStatus; if(!JoystickF[C].Attached) continue;
LPDIRECTINPUTDEVICE8 pJoystick = JoystickF[C].Device;
HRESULT hr=pJoystick->Poll(); if (pJoystick)
if (FAILED(hr))
pJoystick->Acquire();
else
{ {
hr=pJoystick->GetDeviceState(sizeof(JoyStatus),&JoyStatus); DIJOYSTATE2 JoyStatus;
if (FAILED(hr)) hr=pJoystick->Acquire();
HRESULT hr=pJoystick->Poll();
if (FAILED(hr))
pJoystick->Acquire();
else else
{ {
CheckAxis_game(JoyStatus.lX,-10000,10000,Joystick[0].Left,Joystick[0].Right); hr=pJoystick->GetDeviceState(sizeof(JoyStatus),&JoyStatus);
CheckAxis_game(JoyStatus.lY,-10000,10000,Joystick[0].Up,Joystick[0].Down); if (FAILED(hr)) hr=pJoystick->Acquire();
else
switch (JoyStatus.rgdwPOV[0])
{ {
case JOY_POVBACKWARD: CheckAxis_game(JoyStatus.lX,-10000,10000,Joystick[0].Left,Joystick[0].Right);
Joystick[C].PovDown = true; CheckAxis_game(JoyStatus.lY,-10000,10000,Joystick[0].Up,Joystick[0].Down);
break;
case 4500: switch (JoyStatus.rgdwPOV[0])
//Joystick[C].PovUpRight = true; {
Joystick[C].PovUp = true; case JOY_POVBACKWARD:
Joystick[C].PovRight = true; Joystick[C].PovDown = true;
break; break;
case 13500: case 4500:
//Joystick[C].PovDnRight = true; //Joystick[C].PovUpRight = true;
Joystick[C].PovDown = true; Joystick[C].PovUp = true;
Joystick[C].PovRight = true; Joystick[C].PovRight = true;
break; break;
case 22500: case 13500:
//Joystick[C].PovDnLeft = true; //Joystick[C].PovDnRight = true;
Joystick[C].PovDown = true; Joystick[C].PovDown = true;
Joystick[C].PovLeft = true; Joystick[C].PovRight = true;
break; break;
case 31500: case 22500:
//Joystick[C].PovUpLeft = true; //Joystick[C].PovDnLeft = true;
Joystick[C].PovUp = true; Joystick[C].PovDown = true;
Joystick[C].PovLeft = true; Joystick[C].PovLeft = true;
break; break;
case 31500:
//Joystick[C].PovUpLeft = true;
Joystick[C].PovUp = true;
Joystick[C].PovLeft = true;
break;
case JOY_POVFORWARD: case JOY_POVFORWARD:
Joystick[C].PovUp = true; Joystick[C].PovUp = true;
break; break;
case JOY_POVLEFT: case JOY_POVLEFT:
Joystick[C].PovLeft = true; Joystick[C].PovLeft = true;
break; break;
case JOY_POVRIGHT: case JOY_POVRIGHT:
Joystick[C].PovRight = true; Joystick[C].PovRight = true;
break; break;
default:
break;
}
for(int B=0;B<128;B++)
if( JoyStatus.rgbButtons[B] )
Joystick[C].Button[B] = true;
default:
break;
} }
for(int B=0;B<128;B++)
if( JoyStatus.rgbButtons[B] )
Joystick[C].Button[B] = true;
} }
} }
} }
@ -713,157 +723,162 @@ void S9xUpdateJoyState()
void di_poll_scan() void di_poll_scan()
{ {
int C = 0; for(int C=0;C<16;C++)
if (pJoystick)
{ {
DIJOYSTATE2 JoyStatus; //if(!JoystickF[C].Attached) continue;
LPDIRECTINPUTDEVICE8 pJoystick = JoystickF[C].Device;
HRESULT hr=pJoystick->Poll(); if(!pJoystick) continue;
if (FAILED(hr)) if (pJoystick)
pJoystick->Acquire();
else
{ {
hr=pJoystick->GetDeviceState(sizeof(JoyStatus),&JoyStatus); DIJOYSTATE2 JoyStatus;
if (FAILED(hr)) hr=pJoystick->Acquire();
HRESULT hr=pJoystick->Poll();
if (FAILED(hr))
pJoystick->Acquire();
else else
{ {
CheckAxis(0,0,JoyStatus.lX,-10000,10000,Joystick[0].Left,Joystick[0].Right); hr=pJoystick->GetDeviceState(sizeof(JoyStatus),&JoyStatus);
CheckAxis(0,2,JoyStatus.lY,-10000,10000,Joystick[0].Down,Joystick[0].Up); if (FAILED(hr)) hr=pJoystick->Acquire();
else
switch (JoyStatus.rgdwPOV[0])
{ {
case JOY_POVBACKWARD: CheckAxis(0,0,JoyStatus.lX,-10000,10000,Joystick[C].Left,Joystick[C].Right);
if( !JoystickF[C].PovDown) CheckAxis(0,2,JoyStatus.lY,-10000,10000,Joystick[C].Down,Joystick[C].Up);
{ JoystickChanged( C, 7); }
switch (JoyStatus.rgdwPOV[0])
{
case JOY_POVBACKWARD:
if( !JoystickF[C].PovDown)
{ JoystickChanged( C, 7); }
JoystickF[C].PovDown = true; JoystickF[C].PovDown = true;
JoystickF[C].PovUp = false; JoystickF[C].PovUp = false;
JoystickF[C].PovLeft = false; JoystickF[C].PovLeft = false;
JoystickF[C].PovRight = false; JoystickF[C].PovRight = false;
JoystickF[C].PovDnLeft = false; JoystickF[C].PovDnLeft = false;
JoystickF[C].PovDnRight = false; JoystickF[C].PovDnRight = false;
JoystickF[C].PovUpLeft = false; JoystickF[C].PovUpLeft = false;
JoystickF[C].PovUpRight = false; JoystickF[C].PovUpRight = false;
break; break;
case 4500: case 4500:
if( !JoystickF[C].PovUpRight) if( !JoystickF[C].PovUpRight)
{ JoystickChanged( C, 52); } { JoystickChanged( C, 52); }
JoystickF[C].PovDown = false; JoystickF[C].PovDown = false;
JoystickF[C].PovUp = false; JoystickF[C].PovUp = false;
JoystickF[C].PovLeft = false; JoystickF[C].PovLeft = false;
JoystickF[C].PovRight = false; JoystickF[C].PovRight = false;
JoystickF[C].PovDnLeft = false; JoystickF[C].PovDnLeft = false;
JoystickF[C].PovDnRight = false; JoystickF[C].PovDnRight = false;
JoystickF[C].PovUpLeft = false; JoystickF[C].PovUpLeft = false;
JoystickF[C].PovUpRight = true; JoystickF[C].PovUpRight = true;
break; break;
case 13500: case 13500:
if( !JoystickF[C].PovDnRight) if( !JoystickF[C].PovDnRight)
{ JoystickChanged( C, 50); } { JoystickChanged( C, 50); }
JoystickF[C].PovDown = false; JoystickF[C].PovDown = false;
JoystickF[C].PovUp = false; JoystickF[C].PovUp = false;
JoystickF[C].PovLeft = false; JoystickF[C].PovLeft = false;
JoystickF[C].PovRight = false; JoystickF[C].PovRight = false;
JoystickF[C].PovDnLeft = false; JoystickF[C].PovDnLeft = false;
JoystickF[C].PovDnRight = true; JoystickF[C].PovDnRight = true;
JoystickF[C].PovUpLeft = false; JoystickF[C].PovUpLeft = false;
JoystickF[C].PovUpRight = false; JoystickF[C].PovUpRight = false;
break; break;
case 22500: case 22500:
if( !JoystickF[C].PovDnLeft) if( !JoystickF[C].PovDnLeft)
{ JoystickChanged( C, 49); } { JoystickChanged( C, 49); }
JoystickF[C].PovDown = false; JoystickF[C].PovDown = false;
JoystickF[C].PovUp = false; JoystickF[C].PovUp = false;
JoystickF[C].PovLeft = false; JoystickF[C].PovLeft = false;
JoystickF[C].PovRight = false; JoystickF[C].PovRight = false;
JoystickF[C].PovDnLeft = true; JoystickF[C].PovDnLeft = true;
JoystickF[C].PovDnRight = false; JoystickF[C].PovDnRight = false;
JoystickF[C].PovUpLeft = false; JoystickF[C].PovUpLeft = false;
JoystickF[C].PovUpRight = false; JoystickF[C].PovUpRight = false;
break; break;
case 31500: case 31500:
if( !JoystickF[C].PovUpLeft) if( !JoystickF[C].PovUpLeft)
{ JoystickChanged( C, 51); } { JoystickChanged( C, 51); }
JoystickF[C].PovDown = false; JoystickF[C].PovDown = false;
JoystickF[C].PovUp = false; JoystickF[C].PovUp = false;
JoystickF[C].PovLeft = false; JoystickF[C].PovLeft = false;
JoystickF[C].PovRight = false; JoystickF[C].PovRight = false;
JoystickF[C].PovDnLeft = false; JoystickF[C].PovDnLeft = false;
JoystickF[C].PovDnRight = false; JoystickF[C].PovDnRight = false;
JoystickF[C].PovUpLeft = true; JoystickF[C].PovUpLeft = true;
JoystickF[C].PovUpRight = false; JoystickF[C].PovUpRight = false;
break; break;
case JOY_POVFORWARD: case JOY_POVFORWARD:
if( !JoystickF[C].PovUp) if( !JoystickF[C].PovUp)
{ JoystickChanged( C, 6); } { JoystickChanged( C, 6); }
JoystickF[C].PovDown = false; JoystickF[C].PovDown = false;
JoystickF[C].PovUp = true; JoystickF[C].PovUp = true;
JoystickF[C].PovLeft = false; JoystickF[C].PovLeft = false;
JoystickF[C].PovRight = false; JoystickF[C].PovRight = false;
JoystickF[C].PovDnLeft = false; JoystickF[C].PovDnLeft = false;
JoystickF[C].PovDnRight = false; JoystickF[C].PovDnRight = false;
JoystickF[C].PovUpLeft = false; JoystickF[C].PovUpLeft = false;
JoystickF[C].PovUpRight = false; JoystickF[C].PovUpRight = false;
break; break;
case JOY_POVLEFT: case JOY_POVLEFT:
if( !JoystickF[C].PovLeft) if( !JoystickF[C].PovLeft)
{ JoystickChanged( C, 4); } { JoystickChanged( C, 4); }
JoystickF[C].PovDown = false; JoystickF[C].PovDown = false;
JoystickF[C].PovUp = false; JoystickF[C].PovUp = false;
JoystickF[C].PovLeft = true; JoystickF[C].PovLeft = true;
JoystickF[C].PovRight = false; JoystickF[C].PovRight = false;
JoystickF[C].PovDnLeft = false; JoystickF[C].PovDnLeft = false;
JoystickF[C].PovDnRight = false; JoystickF[C].PovDnRight = false;
JoystickF[C].PovUpLeft = false; JoystickF[C].PovUpLeft = false;
JoystickF[C].PovUpRight = false; JoystickF[C].PovUpRight = false;
break; break;
case JOY_POVRIGHT: case JOY_POVRIGHT:
if( !JoystickF[C].PovRight) if( !JoystickF[C].PovRight)
{ JoystickChanged( C, 5); } { JoystickChanged( C, 5); }
JoystickF[C].PovDown = false; JoystickF[C].PovDown = false;
JoystickF[C].PovUp = false; JoystickF[C].PovUp = false;
JoystickF[C].PovLeft = false; JoystickF[C].PovLeft = false;
JoystickF[C].PovRight = true; JoystickF[C].PovRight = true;
JoystickF[C].PovDnLeft = false; JoystickF[C].PovDnLeft = false;
JoystickF[C].PovDnRight = false; JoystickF[C].PovDnRight = false;
JoystickF[C].PovUpLeft = false; JoystickF[C].PovUpLeft = false;
JoystickF[C].PovUpRight = false; JoystickF[C].PovUpRight = false;
break; break;
default: default:
JoystickF[C].PovDown = false; JoystickF[C].PovDown = false;
JoystickF[C].PovUp = false; JoystickF[C].PovUp = false;
JoystickF[C].PovLeft = false; JoystickF[C].PovLeft = false;
JoystickF[C].PovRight = false; JoystickF[C].PovRight = false;
JoystickF[C].PovDnLeft = false; JoystickF[C].PovDnLeft = false;
JoystickF[C].PovDnRight = false; JoystickF[C].PovDnRight = false;
JoystickF[C].PovUpLeft = false; JoystickF[C].PovUpLeft = false;
JoystickF[C].PovUpRight = false; JoystickF[C].PovUpRight = false;
break; break;
}
for(int B=0;B<128;B++)
if( JoyStatus.rgbButtons[B] )
{
if( !JoystickF[C].Button[B])
{
JoystickChanged( C, (short)(8+B));
JoystickF[C].Button[B] = true;
} }
}
for(int B=0;B<128;B++) else
if( JoyStatus.rgbButtons[B] ) { JoystickF[C].Button[B] = false; }
{
if( !JoystickF[C].Button[B])
{
JoystickChanged( C, (short)(8+B));
JoystickF[C].Button[B] = true;
}
}
else
{ JoystickF[C].Button[B] = false; }
}
} }
} }
} } // C loop
} }
@ -1941,8 +1956,8 @@ switch(msg)
//for( C = 0; C != 16; C ++) //for( C = 0; C != 16; C ++)
// JoystickF[C].Attached = joyGetDevCaps( JOYSTICKID1+C, &JoystickF[C].Caps, sizeof( JOYCAPS)) == JOYERR_NOERROR; // JoystickF[C].Attached = joyGetDevCaps( JOYSTICKID1+C, &JoystickF[C].Caps, sizeof( JOYCAPS)) == JOYERR_NOERROR;
memset(&JoystickF[0],0,sizeof(JoystickF[0])); //memset(&JoystickF[0],0,sizeof(JoystickF[0]));
JoystickF[0].Attached = pJoystick != NULL; //JoystickF[0].Attached = pJoystick != NULL;
//for(i=1;i<6;i++) //for(i=1;i<6;i++)

View File

@ -24,6 +24,8 @@
#define INPUTDX_INCLUDED #define INPUTDX_INCLUDED
#include <mmsystem.h> #include <mmsystem.h>
#define DIRECTINPUT_VERSION 0x0800
#include "directx/dinput.h"
typedef struct typedef struct
{ {
@ -79,6 +81,7 @@ struct SJoypad {
struct SJoyState{ struct SJoyState{
LPDIRECTINPUTDEVICE8 Device;
bool Attached; bool Attached;
JOYCAPS Caps; JOYCAPS Caps;
int Threshold; int Threshold;
@ -102,7 +105,7 @@ struct SJoyState{
bool VDown; bool VDown;
bool ZUp; bool ZUp;
bool ZDown; bool ZDown;
bool Button[32]; bool Button[128];
}; };
extern SJoypad Joypad[16]; extern SJoypad Joypad[16];