Figured out a way to test joypad input without having one(PPJoy w/ Print Screen mapped to a button), and took out some redundant code.
This commit is contained in:
parent
e9bb9102ae
commit
816da56c87
|
@ -191,79 +191,6 @@ int DTestButtonJoy(ButtConfig *bc)
|
|||
return(0);
|
||||
}
|
||||
|
||||
// Ugetab: I can't test this. It may be inefficient, or even ineffective
|
||||
int DTestButtonJoyImmediate(ButtConfig *bc)
|
||||
{
|
||||
uint32 x; //mbg merge 7/17/06 changed to uint
|
||||
|
||||
for(x=0;x<bc->NumC;x++)
|
||||
{
|
||||
HRESULT dival;
|
||||
int n = bc->DeviceNum[x];
|
||||
|
||||
if(n == 0xFF)
|
||||
continue;
|
||||
|
||||
if(bc->ButtType[x] != BUTTC_JOYSTICK) continue;
|
||||
if(n >= numjoysticks) continue;
|
||||
|
||||
while((dival = IDirectInputDevice7_Poll(Joysticks[n])) != DI_OK)
|
||||
{
|
||||
if(dival == DI_NOEFFECT) break;
|
||||
|
||||
if(!JoyAutoRestore(dival,Joysticks[n]))
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
IDirectInputDevice7_GetDeviceState(Joysticks[n],sizeof(DIJOYSTATE2),&StatusSaveImmediate[n]);
|
||||
HavePolled[n] = 1;
|
||||
|
||||
|
||||
if(bc->ButtonNum[x]&0x8000) /* Axis "button" */
|
||||
{
|
||||
int sa = bc->ButtonNum[x]&3;
|
||||
long source;
|
||||
|
||||
if(sa == 0) source=((int64)StatusSaveImmediate[n].lX - ranges[n].MinX) * 262144 /
|
||||
(ranges[n].MaxX - ranges[n].MinX) - 131072;
|
||||
else if(sa == 1) source=((int64)StatusSaveImmediate[n].lY - ranges[n].MinY) * 262144 /
|
||||
(ranges[n].MaxY - ranges[n].MinY) - 131072;
|
||||
else if(sa == 2) source=((int64)StatusSaveImmediate[n].lZ - ranges[n].MinZ) * 262144 /
|
||||
(ranges[n].MaxZ - ranges[n].MinZ) - 131072;
|
||||
|
||||
/* Now, source is of the range -131072 to 131071. Good enough. */
|
||||
if(bc->ButtonNum[x] & 0x4000)
|
||||
{
|
||||
if(source <= (0 - 262144/4))
|
||||
return(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(source >= (262144/4))
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
else if(bc->ButtonNum[x]&0x2000) /* Hat "button" */
|
||||
{
|
||||
int wpov = StatusSaveImmediate[n].rgdwPOV[(bc->ButtonNum[x] >> 4) &3];
|
||||
int tpov = bc->ButtonNum[x] & 3;
|
||||
|
||||
if(POVFix(wpov, 0) == tpov || POVFix(wpov, 1) == tpov)
|
||||
return(1);
|
||||
}
|
||||
else /* Normal button */
|
||||
{
|
||||
if(StatusSaveImmediate[n].rgbButtons[bc->ButtonNum[x] & 127]&0x80)
|
||||
return(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int canax[MAX_JOYSTICKS][3];
|
||||
|
||||
/* Now the fun configuration test begins. */
|
||||
|
|
|
@ -17,7 +17,6 @@ void JoyClearBC(ButtConfig *bc);
|
|||
|
||||
void UpdateJoysticks(void);
|
||||
int DTestButtonJoy(ButtConfig *bc);
|
||||
int DTestButtonJoyImmediate(ButtConfig *bc);
|
||||
|
||||
#define JOYBACKACCESS_OLDSTYLE 1
|
||||
#define JOYBACKACCESS_TASEDIT 2
|
||||
|
|
|
@ -58,14 +58,14 @@ int DTestButtonImmediate(ButtConfig *bc)
|
|||
}
|
||||
}
|
||||
}
|
||||
if(DTestButtonJoyImmediate(bc)) return(1); // Needs joystick.h
|
||||
if(DTestButtonJoy(bc)) return(1); // Needs joystick.h. Tested with PPJoy mapped with Print Screen
|
||||
return(0);
|
||||
}
|
||||
|
||||
uint32 GetGamepadPressedImmediate()
|
||||
{
|
||||
// Get selected joypad buttons, ignoring NES polling
|
||||
// Basically checks for immediate joypad input.
|
||||
// Basically checks for immediate gamepad input.
|
||||
extern ButtConfig GamePadConfig[4][10];
|
||||
extern int allowUDLR;
|
||||
|
||||
|
|
Loading…
Reference in New Issue