This commit is contained in:
turanszkij
2015-06-18 23:03:51 +02:00
commit e4c1147629
476 changed files with 137108 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
#include "XInput.h"
XInput::XInput(void)
{
g_bDeadZoneOn = true;
for(int i=0;i<MAX_CONTROLLERS;++i){
controllers[i] = CONTROLLER_STATE();
controllers[i].bConnected=false;
}
}
HRESULT XInput::UpdateControllerState()
{
DWORD dwResult;
for( DWORD i = 0; i < MAX_CONTROLLERS; i++ )
{
// Simply get the state of the controller from XInput.
dwResult = XInputGetState( i, controllers[i].state );
if( dwResult == ERROR_SUCCESS )
controllers[i].bConnected = true;
else
controllers[i].bConnected = false;
}
return S_OK;
}
DWORD XInput::GetButtons(SHORT newPlayerIndex)
{
if(controllers[newPlayerIndex].bConnected)
return controllers[newPlayerIndex].state->Gamepad.wButtons;
return 0;
}
DWORD XInput::GetDirections(short newPlayerIndex){
if(controllers[newPlayerIndex].bConnected)
return controllers[newPlayerIndex].state->Gamepad.wButtons;
return 0;
/*if(dir == (XINPUT_GAMEPAD_DPAD_LEFT || XINPUT_GAMEPAD_DPAD_RIGHT || XINPUT_GAMEPAD_DPAD_UP || XINPUT_GAMEPAD_DPAD_DOWN ||
XINPUT_GAMEPAD_DPAD_LEFT+XINPUT_GAMEPAD_DPAD_UP || XINPUT_GAMEPAD_DPAD_RIGHT+XINPUT_GAMEPAD_DPAD_DOWN || XINPUT_GAMEPAD_DPAD_UP+XINPUT_GAMEPAD_DPAD_RIGHT || XINPUT_GAMEPAD_DPAD_DOWN+XINPUT_GAMEPAD_DPAD_LEFT)
)
return dir;*/
//TODO!!!
//return dir;
}
bool XInput::isButtonDown(short newPlayerIndex,DWORD checkforButton){
if(controllers[newPlayerIndex].bConnected)
return controllers[newPlayerIndex].state->Gamepad.wButtons & checkforButton;
return false;
}
void XInput::CleanUp()
{
delete(this);
}