mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Fixes Issue 2164
Conflicts are due to same file name when omitting full path git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4982 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -441,23 +441,19 @@
|
|||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\SConscript"
|
RelativePath=".\Src\SDL_Util.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\SDL.cpp"
|
RelativePath=".\Src\SDL_Util.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\SDL.h"
|
RelativePath=".\Src\XInput_Util.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\Src\XInput.cpp"
|
RelativePath=".\Src\XInput_Util.h"
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\Src\XInput.h"
|
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
|
@ -4,6 +4,26 @@
|
|||||||
|
|
||||||
namespace InputCommon
|
namespace InputCommon
|
||||||
{
|
{
|
||||||
|
enum EButtonType
|
||||||
|
{
|
||||||
|
CTL_AXIS = 0,
|
||||||
|
CTL_HAT,
|
||||||
|
CTL_BUTTON,
|
||||||
|
CTL_KEY,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ETriggerType
|
||||||
|
{
|
||||||
|
CTL_TRIGGER_SDL = 0,
|
||||||
|
CTL_TRIGGER_XINPUT,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum EXInputTrigger
|
||||||
|
{
|
||||||
|
XI_TRIGGER_L = 0,
|
||||||
|
XI_TRIGGER_R,
|
||||||
|
};
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ files = [
|
|||||||
'Configuration.cpp',
|
'Configuration.cpp',
|
||||||
'EventHandler.cpp',
|
'EventHandler.cpp',
|
||||||
'InputCommon.cpp',
|
'InputCommon.cpp',
|
||||||
'SDL.cpp',
|
'SDL_Util.cpp',
|
||||||
]
|
]
|
||||||
|
|
||||||
if env['HAVE_X11']:
|
if env['HAVE_X11']:
|
||||||
|
@ -1,219 +1,222 @@
|
|||||||
|
|
||||||
// Project description
|
// Project description
|
||||||
// -------------------
|
// -------------------
|
||||||
// Name: SDL Input
|
// Name: SDL Input
|
||||||
// Description: Common SDL Input Functions
|
// Description: Common SDL Input Functions
|
||||||
//
|
//
|
||||||
// Author: Falcon4ever (nJoy@falcon4ever.com, www.multigesture.net), JPeterson etc
|
// Author: Falcon4ever (nJoy@falcon4ever.com, www.multigesture.net), JPeterson etc
|
||||||
// Copyright (C) 2003 Dolphin Project.
|
// Copyright (C) 2003 Dolphin Project.
|
||||||
//
|
//
|
||||||
|
|
||||||
//
|
//
|
||||||
// Licensetype: GNU General Public License (GPL)
|
// Licensetype: GNU General Public License (GPL)
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, version 2.0.
|
// the Free Software Foundation, version 2.0.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License 2.0 for more details.
|
// GNU General Public License 2.0 for more details.
|
||||||
//
|
//
|
||||||
// A copy of the GPL 2.0 should have been included with the program.
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
// If not, see http://www.gnu.org/licenses/
|
// If not, see http://www.gnu.org/licenses/
|
||||||
//
|
//
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#define _SDL_MAIN_ // Avoid certain declarations in SDL.h
|
#define _SDL_MAIN_ // Avoid certain declarations in SDL.h
|
||||||
#include "SDL.h" // Local
|
#include "InputCommon.h"
|
||||||
#include "XInput.h"
|
#include "SDL_Util.h" // Local
|
||||||
|
#ifdef _WIN32
|
||||||
namespace InputCommon
|
#include "XInput_Util.h"
|
||||||
{
|
#endif
|
||||||
|
|
||||||
|
namespace InputCommon
|
||||||
// Search attached devices. Populate joyinfo for all attached physical devices.
|
{
|
||||||
// -----------------------
|
|
||||||
bool SearchDevices(std::vector<CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads)
|
|
||||||
{
|
// Search attached devices. Populate joyinfo for all attached physical devices.
|
||||||
if (!SDL_WasInit(0))
|
// -----------------------
|
||||||
#if SDL_VERSION_ATLEAST(1, 3, 0)
|
bool SearchDevices(std::vector<CONTROLLER_INFO> &_joyinfo, int &_NumPads, int &_NumGoodPads)
|
||||||
if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC) < 0)
|
{
|
||||||
#else
|
if (!SDL_WasInit(0))
|
||||||
if (SDL_Init(SDL_INIT_JOYSTICK) < 0)
|
#if SDL_VERSION_ATLEAST(1, 3, 0)
|
||||||
#endif
|
if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_HAPTIC) < 0)
|
||||||
{
|
#else
|
||||||
PanicAlert("Could not initialize SDL: %s", SDL_GetError());
|
if (SDL_Init(SDL_INIT_JOYSTICK) < 0)
|
||||||
return false;
|
#endif
|
||||||
}
|
{
|
||||||
|
PanicAlert("Could not initialize SDL: %s", SDL_GetError());
|
||||||
// Get device status
|
return false;
|
||||||
int numjoy = SDL_NumJoysticks();
|
}
|
||||||
for (int i = 0; i < numjoy; i++ )
|
|
||||||
{
|
// Get device status
|
||||||
CONTROLLER_INFO Tmp;
|
int numjoy = SDL_NumJoysticks();
|
||||||
|
for (int i = 0; i < numjoy; i++ )
|
||||||
Tmp.joy = SDL_JoystickOpen(i);
|
{
|
||||||
Tmp.ID = i;
|
CONTROLLER_INFO Tmp;
|
||||||
Tmp.NumAxes = SDL_JoystickNumAxes(Tmp.joy);
|
|
||||||
Tmp.NumButtons = SDL_JoystickNumButtons(Tmp.joy);
|
Tmp.joy = SDL_JoystickOpen(i);
|
||||||
Tmp.NumBalls = SDL_JoystickNumBalls(Tmp.joy);
|
Tmp.ID = i;
|
||||||
Tmp.NumHats = SDL_JoystickNumHats(Tmp.joy);
|
Tmp.NumAxes = SDL_JoystickNumAxes(Tmp.joy);
|
||||||
Tmp.Name = SDL_JoystickName(i);
|
Tmp.NumButtons = SDL_JoystickNumButtons(Tmp.joy);
|
||||||
|
Tmp.NumBalls = SDL_JoystickNumBalls(Tmp.joy);
|
||||||
// Check if the device is okay
|
Tmp.NumHats = SDL_JoystickNumHats(Tmp.joy);
|
||||||
if ( Tmp.NumAxes == 0
|
Tmp.Name = SDL_JoystickName(i);
|
||||||
&& Tmp.NumBalls == 0
|
|
||||||
&& Tmp.NumButtons == 0
|
// Check if the device is okay
|
||||||
&& Tmp.NumHats == 0
|
if ( Tmp.NumAxes == 0
|
||||||
)
|
&& Tmp.NumBalls == 0
|
||||||
{
|
&& Tmp.NumButtons == 0
|
||||||
Tmp.Good = false;
|
&& Tmp.NumHats == 0
|
||||||
}
|
)
|
||||||
else
|
{
|
||||||
{
|
Tmp.Good = false;
|
||||||
_NumGoodPads++;
|
}
|
||||||
Tmp.Good = true;
|
else
|
||||||
}
|
{
|
||||||
|
_NumGoodPads++;
|
||||||
_joyinfo.push_back(Tmp);
|
Tmp.Good = true;
|
||||||
|
}
|
||||||
// We have now read the values we need so we close the device
|
|
||||||
// if (SDL_JoystickOpened(i)) SDL_JoystickClose(_joyinfo[i].joy);
|
_joyinfo.push_back(Tmp);
|
||||||
}
|
|
||||||
|
// We have now read the values we need so we close the device
|
||||||
_NumPads = (int)_joyinfo.size();
|
// if (SDL_JoystickOpened(i)) SDL_JoystickClose(_joyinfo[i].joy);
|
||||||
|
}
|
||||||
return true;
|
|
||||||
}
|
_NumPads = (int)_joyinfo.size();
|
||||||
|
|
||||||
|
return true;
|
||||||
// Avoid extreme axis values
|
}
|
||||||
// ---------------------
|
|
||||||
/* Function: We have to avoid very big values to becuse some triggers are -0x8000 in the
|
|
||||||
unpressed state (and then go from -0x8000 to 0x8000 as they are fully pressed) */
|
// Avoid extreme axis values
|
||||||
bool AvoidValues(int value, bool NoTriggerFilter)
|
// ---------------------
|
||||||
{
|
/* Function: We have to avoid very big values to becuse some triggers are -0x8000 in the
|
||||||
// Avoid detecting very small or very big (for triggers) values
|
unpressed state (and then go from -0x8000 to 0x8000 as they are fully pressed) */
|
||||||
if( (value > -0x2000 && value < 0x2000) // Small values
|
bool AvoidValues(int value, bool NoTriggerFilter)
|
||||||
|| ((value < -0x6000 || value > 0x6000) && !NoTriggerFilter)) // Big values
|
{
|
||||||
return true; // Avoid
|
// Avoid detecting very small or very big (for triggers) values
|
||||||
else
|
if( (value > -0x2000 && value < 0x2000) // Small values
|
||||||
return false; // Keep
|
|| ((value < -0x6000 || value > 0x6000) && !NoTriggerFilter)) // Big values
|
||||||
}
|
return true; // Avoid
|
||||||
|
else
|
||||||
|
return false; // Keep
|
||||||
// Detect a pressed button
|
}
|
||||||
// ---------------------
|
|
||||||
void GetButton(SDL_Joystick *joy, int ControllerID, int buttons, int axes, int hats,
|
|
||||||
int &KeyboardKey, int &value, int &type, int &pressed, bool &Succeed, bool &Stop,
|
// Detect a pressed button
|
||||||
bool LeftRight, bool Axis, bool XInput, bool Button, bool Hat, bool NoTriggerFilter)
|
// ---------------------
|
||||||
{
|
void GetButton(SDL_Joystick *joy, int ControllerID, int buttons, int axes, int hats,
|
||||||
// It needs the wxWidgets excape keycode
|
int &KeyboardKey, int &value, int &type, int &pressed, bool &Succeed, bool &Stop,
|
||||||
static const int WXK_ESCAPE = 27;
|
bool LeftRight, bool Axis, bool XInput, bool Button, bool Hat, bool NoTriggerFilter)
|
||||||
|
{
|
||||||
// Update the internal status
|
// It needs the wxWidgets excape keycode
|
||||||
SDL_JoystickUpdate();
|
static const int WXK_ESCAPE = 27;
|
||||||
|
|
||||||
// For the triggers we accept both a digital or an analog button
|
// Update the internal status
|
||||||
if(Axis)
|
SDL_JoystickUpdate();
|
||||||
{
|
|
||||||
for(int i = 0; i < axes; i++)
|
// For the triggers we accept both a digital or an analog button
|
||||||
{
|
if(Axis)
|
||||||
value = SDL_JoystickGetAxis(joy, i);
|
{
|
||||||
|
for(int i = 0; i < axes; i++)
|
||||||
if(AvoidValues(value, NoTriggerFilter)) continue; // Avoid values
|
{
|
||||||
|
value = SDL_JoystickGetAxis(joy, i);
|
||||||
pressed = i + (LeftRight ? 1000 : 0); // Identify the analog triggers
|
|
||||||
type = InputCommon::CTL_AXIS;
|
if(AvoidValues(value, NoTriggerFilter)) continue; // Avoid values
|
||||||
Succeed = true;
|
|
||||||
}
|
pressed = i + (LeftRight ? 1000 : 0); // Identify the analog triggers
|
||||||
}
|
type = InputCommon::CTL_AXIS;
|
||||||
|
Succeed = true;
|
||||||
// Check for a hat
|
}
|
||||||
if(Hat)
|
}
|
||||||
{
|
|
||||||
for(int i = 0; i < hats; i++)
|
// Check for a hat
|
||||||
{
|
if(Hat)
|
||||||
value = SDL_JoystickGetHat(joy, i);
|
{
|
||||||
if(value)
|
for(int i = 0; i < hats; i++)
|
||||||
{
|
{
|
||||||
pressed = i;
|
value = SDL_JoystickGetHat(joy, i);
|
||||||
type = InputCommon::CTL_HAT;
|
if(value)
|
||||||
Succeed = true;
|
{
|
||||||
}
|
pressed = i;
|
||||||
}
|
type = InputCommon::CTL_HAT;
|
||||||
}
|
Succeed = true;
|
||||||
|
}
|
||||||
// Check for a button
|
}
|
||||||
if(Button)
|
}
|
||||||
{
|
|
||||||
for(int i = 0; i < buttons; i++)
|
// Check for a button
|
||||||
{
|
if(Button)
|
||||||
// Some kind of bug in SDL 1.3 would give button 9 and 10 (nonexistent) the value 48 on the 360 pad
|
{
|
||||||
if (SDL_JoystickGetButton(joy, i) > 1) continue;
|
for(int i = 0; i < buttons; i++)
|
||||||
|
{
|
||||||
if(SDL_JoystickGetButton(joy, i))
|
// Some kind of bug in SDL 1.3 would give button 9 and 10 (nonexistent) the value 48 on the 360 pad
|
||||||
{
|
if (SDL_JoystickGetButton(joy, i) > 1) continue;
|
||||||
pressed = i;
|
|
||||||
type = InputCommon::CTL_BUTTON;
|
if(SDL_JoystickGetButton(joy, i))
|
||||||
Succeed = true;
|
{
|
||||||
}
|
pressed = i;
|
||||||
}
|
type = InputCommon::CTL_BUTTON;
|
||||||
}
|
Succeed = true;
|
||||||
|
}
|
||||||
// Check for a XInput trigger
|
}
|
||||||
#ifdef _WIN32
|
}
|
||||||
if(XInput && LeftRight)
|
|
||||||
{
|
// Check for a XInput trigger
|
||||||
for(int i = 0; i <= InputCommon::XI_TRIGGER_R; i++)
|
#ifdef _WIN32
|
||||||
{
|
if(XInput && LeftRight)
|
||||||
if(XInput::GetXI(ControllerID, i))
|
{
|
||||||
{
|
for(int i = 0; i <= InputCommon::XI_TRIGGER_R; i++)
|
||||||
pressed = i + 1000;
|
{
|
||||||
type = InputCommon::CTL_AXIS;
|
if(XInput::GetXI(ControllerID, i))
|
||||||
Succeed = true;
|
{
|
||||||
}
|
pressed = i + 1000;
|
||||||
}
|
type = InputCommon::CTL_AXIS;
|
||||||
}
|
Succeed = true;
|
||||||
#endif
|
}
|
||||||
|
}
|
||||||
// Check for keyboard action
|
}
|
||||||
if (KeyboardKey)
|
#endif
|
||||||
{
|
|
||||||
if(Button)
|
// Check for keyboard action
|
||||||
{
|
if (KeyboardKey)
|
||||||
// Todo: Add a separate keyboard vector to remove this restriction
|
{
|
||||||
if(KeyboardKey >= buttons)
|
if(Button)
|
||||||
{
|
{
|
||||||
pressed = KeyboardKey;
|
// Todo: Add a separate keyboard vector to remove this restriction
|
||||||
type = InputCommon::CTL_BUTTON;
|
if(KeyboardKey >= buttons)
|
||||||
Succeed = true;
|
{
|
||||||
KeyboardKey = 0;
|
pressed = KeyboardKey;
|
||||||
if(pressed == WXK_ESCAPE) pressed = -1; // Check for the escape key
|
type = InputCommon::CTL_BUTTON;
|
||||||
}
|
Succeed = true;
|
||||||
// Else show the error message
|
KeyboardKey = 0;
|
||||||
else
|
if(pressed == WXK_ESCAPE) pressed = -1; // Check for the escape key
|
||||||
{
|
}
|
||||||
pressed = KeyboardKey;
|
// Else show the error message
|
||||||
KeyboardKey = -1;
|
else
|
||||||
Stop = true;
|
{
|
||||||
}
|
pressed = KeyboardKey;
|
||||||
}
|
KeyboardKey = -1;
|
||||||
// Only accept the escape key
|
Stop = true;
|
||||||
else if (KeyboardKey == WXK_ESCAPE)
|
}
|
||||||
{
|
}
|
||||||
Succeed = true;
|
// Only accept the escape key
|
||||||
KeyboardKey = 0;
|
else if (KeyboardKey == WXK_ESCAPE)
|
||||||
pressed = -1;
|
{
|
||||||
}
|
Succeed = true;
|
||||||
}
|
KeyboardKey = 0;
|
||||||
}
|
pressed = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
} // InputCommon
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // InputCommon
|
||||||
|
|
@ -1,98 +1,78 @@
|
|||||||
// Copyright (C) 2003 Dolphin Project.
|
// Copyright (C) 2003 Dolphin Project.
|
||||||
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, version 2.0.
|
// the Free Software Foundation, version 2.0.
|
||||||
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License 2.0 for more details.
|
// GNU General Public License 2.0 for more details.
|
||||||
|
|
||||||
// A copy of the GPL 2.0 should have been included with the program.
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
// If not, see http://www.gnu.org/licenses/
|
// If not, see http://www.gnu.org/licenses/
|
||||||
|
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
#ifndef _SDL_h
|
#ifndef _SDL_h
|
||||||
#define _SDL_h
|
#define _SDL_h
|
||||||
|
|
||||||
|
|
||||||
#include <iostream> // System
|
#include <iostream> // System
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <SDL.h> // Externals
|
#include <SDL.h> // Externals
|
||||||
#include <SDL_version.h>
|
#include <SDL_version.h>
|
||||||
#if SDL_VERSION_ATLEAST(1, 3, 0)
|
#if SDL_VERSION_ATLEAST(1, 3, 0)
|
||||||
#include <SDL_haptic.h>
|
#include <SDL_haptic.h>
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
#include <SDL/SDL_version.h>
|
#include <SDL/SDL_version.h>
|
||||||
#if SDL_VERSION_ATLEAST(1, 3, 0)
|
#if SDL_VERSION_ATLEAST(1, 3, 0)
|
||||||
#include <SDL/SDL_haptic.h>
|
#include <SDL/SDL_haptic.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Common.h" // Common
|
#include "Common.h" // Common
|
||||||
|
|
||||||
|
|
||||||
namespace InputCommon
|
namespace InputCommon
|
||||||
{
|
{
|
||||||
|
|
||||||
enum EButtonType
|
struct CONTROLLER_INFO // CONNECTED WINDOWS DEVICES INFO
|
||||||
{
|
{
|
||||||
CTL_AXIS = 0,
|
int NumAxes; // Amount of Axes
|
||||||
CTL_HAT,
|
int NumButtons; // Amount of Buttons
|
||||||
CTL_BUTTON,
|
int NumBalls; // Amount of Balls
|
||||||
CTL_KEY,
|
int NumHats; // Amount of Hats (POV)
|
||||||
};
|
std::string Name; // Joypad/stickname
|
||||||
|
int ID; // SDL joystick device ID
|
||||||
enum ETriggerType
|
bool Good; // Pad is good (it has at least one button or axis)
|
||||||
{
|
SDL_Joystick *joy; // SDL joystick device
|
||||||
CTL_TRIGGER_SDL = 0,
|
};
|
||||||
CTL_TRIGGER_XINPUT,
|
|
||||||
};
|
|
||||||
|
// General functions
|
||||||
enum EXInputTrigger
|
bool SearchDevices(std::vector<CONTROLLER_INFO> &_joyinfo, int &NumPads, int &NumGoodPads);
|
||||||
{
|
void GetButton(SDL_Joystick*, int,int,int,int, int&,int&,int&,int&,bool&,bool&, bool,bool,bool,bool,bool,bool);
|
||||||
XI_TRIGGER_L = 0,
|
|
||||||
XI_TRIGGER_R,
|
// Value conversion
|
||||||
};
|
float Deg2Rad(float Deg);
|
||||||
|
float Rad2Deg(float Rad);
|
||||||
struct CONTROLLER_INFO // CONNECTED WINDOWS DEVICES INFO
|
int Pad_Convert(int _val);
|
||||||
{
|
float SquareDistance(float deg);
|
||||||
int NumAxes; // Amount of Axes
|
bool IsDeadZone(float DeadZone, int x, int y);
|
||||||
int NumButtons; // Amount of Buttons
|
void Square2Circle(int &_x, int &_y, int _Diagonal, bool Circle2Square = false);
|
||||||
int NumBalls; // Amount of Balls
|
void RadiusAdjustment(s8 &_x, s8 &_y, int _Radius);
|
||||||
int NumHats; // Amount of Hats (POV)
|
// Input configuration
|
||||||
std::string Name; // Joypad/stickname
|
std::string VKToString(int keycode);
|
||||||
int ID; // SDL joystick device ID
|
|
||||||
bool Good; // Pad is good (it has at least one button or axis)
|
|
||||||
SDL_Joystick *joy; // SDL joystick device
|
} // InputCommon
|
||||||
};
|
|
||||||
|
|
||||||
|
#endif // _SDL_h
|
||||||
// General functions
|
|
||||||
bool SearchDevices(std::vector<CONTROLLER_INFO> &_joyinfo, int &NumPads, int &NumGoodPads);
|
|
||||||
void GetButton(SDL_Joystick*, int,int,int,int, int&,int&,int&,int&,bool&,bool&, bool,bool,bool,bool,bool,bool);
|
|
||||||
|
|
||||||
// Value conversion
|
|
||||||
float Deg2Rad(float Deg);
|
|
||||||
float Rad2Deg(float Rad);
|
|
||||||
int Pad_Convert(int _val);
|
|
||||||
float SquareDistance(float deg);
|
|
||||||
bool IsDeadZone(float DeadZone, int x, int y);
|
|
||||||
void Square2Circle(int &_x, int &_y, int _Diagonal, bool Circle2Square = false);
|
|
||||||
void RadiusAdjustment(s8 &_x, s8 &_y, int _Radius);
|
|
||||||
// Input configuration
|
|
||||||
std::string VKToString(int keycode);
|
|
||||||
|
|
||||||
|
|
||||||
} // InputCommon
|
|
||||||
|
|
||||||
|
|
||||||
#endif // _SDL_h
|
|
@ -1,136 +1,124 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Licensetype: GNU General Public License (GPL)
|
// Licensetype: GNU General Public License (GPL)
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, version 2.0.
|
// the Free Software Foundation, version 2.0.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License 2.0 for more details.
|
// GNU General Public License 2.0 for more details.
|
||||||
//
|
//
|
||||||
// A copy of the GPL 2.0 should have been included with the program.
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
// If not, see http://www.gnu.org/licenses/
|
// If not, see http://www.gnu.org/licenses/
|
||||||
//
|
//
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// File description
|
// File description
|
||||||
/* -------------------
|
/* -------------------
|
||||||
Function: This file will get the status of the analog triggers of any connected XInput device.
|
Function: This file will get the status of the analog triggers of any connected XInput device.
|
||||||
This code was made with the help of SimpleController.cpp in the June 2008 Microsoft DirectX SDK
|
This code was made with the help of SimpleController.cpp in the June 2008 Microsoft DirectX SDK
|
||||||
Samples.
|
Samples.
|
||||||
|
|
||||||
///////////////////////////////////////////////////// */
|
///////////////////////////////////////////////////// */
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
|
||||||
// Includes
|
// Includes
|
||||||
// -------------------
|
// -------------------
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <XInput.h> // XInput API
|
#include <XInput.h> // XInput API
|
||||||
|
#include "InputCommon.h"
|
||||||
#include "SDL.h" // Local
|
|
||||||
|
namespace XInput
|
||||||
|
{
|
||||||
|
|
||||||
namespace XInput
|
// Declarations
|
||||||
{
|
// -------------------
|
||||||
|
|
||||||
|
#define MAX_CONTROLLERS 4 // XInput handles up to 4 controllers
|
||||||
|
|
||||||
// Declarations
|
struct CONTROLER_STATE
|
||||||
// -------------------
|
{
|
||||||
|
XINPUT_STATE state;
|
||||||
#define MAX_CONTROLLERS 4 // XInput handles up to 4 controllers
|
bool bConnected;
|
||||||
|
};
|
||||||
struct CONTROLER_STATE
|
CONTROLER_STATE g_Controllers[MAX_CONTROLLERS];
|
||||||
{
|
|
||||||
XINPUT_STATE state;
|
|
||||||
bool bConnected;
|
// Init
|
||||||
};
|
// -------------------
|
||||||
CONTROLER_STATE g_Controllers[MAX_CONTROLLERS];
|
/* Function: Calculate the number of connected XInput devices
|
||||||
|
Todo: Implement this to figure out if there are multiple XInput controllers connected,
|
||||||
|
we currently only try to connect to XInput device 0 */
|
||||||
|
void Init()
|
||||||
|
{
|
||||||
// Init
|
// Init state
|
||||||
// -------------------
|
//ZeroMemory( g_Controllers, sizeof( CONTROLER_STATE ) * MAX_CONTROLLERS );
|
||||||
/* Function: Calculate the number of connected XInput devices
|
|
||||||
Todo: Implement this to figure out if there are multiple XInput controllers connected,
|
// Declaration
|
||||||
we currently only try to connect to XInput device 0 */
|
DWORD dwResult;
|
||||||
void Init()
|
|
||||||
{
|
// Calculate the number of connected XInput devices
|
||||||
// Init state
|
for( DWORD i = 0; i < MAX_CONTROLLERS; i++ )
|
||||||
//ZeroMemory( g_Controllers, sizeof( CONTROLER_STATE ) * MAX_CONTROLLERS );
|
{
|
||||||
|
// Simply get the state of the controller from XInput.
|
||||||
// Declaration
|
dwResult = XInputGetState( i, &g_Controllers[i].state );
|
||||||
DWORD dwResult;
|
|
||||||
|
if( dwResult == ERROR_SUCCESS )
|
||||||
// Calculate the number of connected XInput devices
|
g_Controllers[i].bConnected = true;
|
||||||
for( DWORD i = 0; i < MAX_CONTROLLERS; i++ )
|
else
|
||||||
{
|
g_Controllers[i].bConnected = false;
|
||||||
// Simply get the state of the controller from XInput.
|
}
|
||||||
dwResult = XInputGetState( i, &g_Controllers[i].state );
|
|
||||||
|
}
|
||||||
if( dwResult == ERROR_SUCCESS )
|
|
||||||
g_Controllers[i].bConnected = true;
|
|
||||||
else
|
// Get the trigger status
|
||||||
g_Controllers[i].bConnected = false;
|
// -------------------
|
||||||
}
|
int GetXI(int Controller, int Button)
|
||||||
|
{
|
||||||
}
|
// Update the internal status
|
||||||
|
DWORD dwResult;
|
||||||
|
dwResult = XInputGetState(Controller, &g_Controllers[Controller].state);
|
||||||
|
|
||||||
|
if (dwResult != ERROR_SUCCESS) return -1;
|
||||||
// Get the trigger status
|
|
||||||
// -------------------
|
switch (Button)
|
||||||
int GetXI(int Controller, int Button)
|
{
|
||||||
{
|
case InputCommon::XI_TRIGGER_L:
|
||||||
// Update the internal status
|
return g_Controllers[Controller].state.Gamepad.bLeftTrigger;
|
||||||
DWORD dwResult;
|
|
||||||
dwResult = XInputGetState(Controller, &g_Controllers[Controller].state);
|
case InputCommon::XI_TRIGGER_R:
|
||||||
|
return g_Controllers[Controller].state.Gamepad.bRightTrigger;
|
||||||
if (dwResult != ERROR_SUCCESS) return -1;
|
|
||||||
|
default:
|
||||||
switch (Button)
|
return 0;
|
||||||
{
|
}
|
||||||
case InputCommon::XI_TRIGGER_L:
|
}
|
||||||
return g_Controllers[Controller].state.Gamepad.bLeftTrigger;
|
|
||||||
|
|
||||||
case InputCommon::XI_TRIGGER_R:
|
// Check if a certain controller is connected
|
||||||
return g_Controllers[Controller].state.Gamepad.bRightTrigger;
|
// -------------------
|
||||||
|
bool IsConnected(int Controller)
|
||||||
default:
|
{
|
||||||
return 0;
|
DWORD dwResult = XInputGetState( Controller, &g_Controllers[Controller].state );
|
||||||
}
|
|
||||||
}
|
// Update the connected status
|
||||||
|
if( dwResult == ERROR_SUCCESS )
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
// Check if a certain controller is connected
|
}
|
||||||
// -------------------
|
|
||||||
bool IsConnected(int Controller)
|
} // XInput
|
||||||
{
|
|
||||||
DWORD dwResult = XInputGetState( Controller, &g_Controllers[Controller].state );
|
|
||||||
|
|
||||||
// Update the connected status
|
|
||||||
if( dwResult == ERROR_SUCCESS )
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // XInput
|
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -1,46 +1,43 @@
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Licensetype: GNU General Public License (GPL)
|
// Licensetype: GNU General Public License (GPL)
|
||||||
//
|
//
|
||||||
// This program is free software: you can redistribute it and/or modify
|
// This program is free software: you can redistribute it and/or modify
|
||||||
// it under the terms of the GNU General Public License as published by
|
// it under the terms of the GNU General Public License as published by
|
||||||
// the Free Software Foundation, version 2.0.
|
// the Free Software Foundation, version 2.0.
|
||||||
//
|
//
|
||||||
// This program is distributed in the hope that it will be useful,
|
// This program is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License 2.0 for more details.
|
// GNU General Public License 2.0 for more details.
|
||||||
//
|
//
|
||||||
// A copy of the GPL 2.0 should have been included with the program.
|
// A copy of the GPL 2.0 should have been included with the program.
|
||||||
// If not, see http://www.gnu.org/licenses/
|
// If not, see http://www.gnu.org/licenses/
|
||||||
//
|
//
|
||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
|
||||||
// Includes
|
// Includes
|
||||||
// ----------
|
// ----------
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
namespace XInput
|
||||||
|
{
|
||||||
namespace XInput
|
|
||||||
{
|
// Declarations
|
||||||
|
// ----------
|
||||||
|
void Init();
|
||||||
// Declarations
|
int GetXI(int Controller, int Button);
|
||||||
// ----------
|
bool IsConnected(int Controller);
|
||||||
void Init();
|
|
||||||
int GetXI(int Controller, int Button);
|
|
||||||
bool IsConnected(int Controller);
|
} // XInput
|
||||||
|
|
||||||
|
#endif
|
||||||
} // XInput
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -22,9 +22,10 @@
|
|||||||
|
|
||||||
#include <vector> // System
|
#include <vector> // System
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include "../../../Core/InputCommon/Src/SDL.h" // Core
|
#include "../../../Core/InputCommon/Src/InputCommon.h" // Core
|
||||||
|
#include "../../../Core/InputCommon/Src/SDL_Util.h"
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "../../../Core/InputCommon/Src/XInput.h"
|
#include "../../../Core/InputCommon/Src/XInput_Util.h"
|
||||||
#elif defined(HAVE_X11) && HAVE_X11
|
#elif defined(HAVE_X11) && HAVE_X11
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
@ -23,12 +23,6 @@
|
|||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "EmuDefinitions.h" // for joyinfo
|
#include "EmuDefinitions.h" // for joyinfo
|
||||||
|
|
||||||
enum TriggerType
|
|
||||||
{
|
|
||||||
CTL_TRIGGER_SDL = 0,
|
|
||||||
CTL_TRIGGER_XINPUT
|
|
||||||
};
|
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(WiimotePadConfigDialog,wxDialog)
|
BEGIN_EVENT_TABLE(WiimotePadConfigDialog,wxDialog)
|
||||||
|
|
||||||
EVT_CLOSE(WiimotePadConfigDialog::OnClose)
|
EVT_CLOSE(WiimotePadConfigDialog::OnClose)
|
||||||
|
@ -21,8 +21,11 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "../../../Core/InputCommon/Src/SDL.h" // Core
|
#include "../../../Core/InputCommon/Src/InputCommon.h" // Core
|
||||||
#include "../../../Core/InputCommon/Src/XInput.h"
|
#include "../../../Core/InputCommon/Src/SDL_Util.h"
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "../../../Core/InputCommon/Src/XInput_Util.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "pluginspecs_wiimote.h"
|
#include "pluginspecs_wiimote.h"
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "../../../Core/InputCommon/Src/SDL.h" // Core
|
|
||||||
#include "../../../Core/InputCommon/Src/XInput.h"
|
|
||||||
|
|
||||||
#include "Common.h" // Common
|
#include "Common.h" // Common
|
||||||
#include "MathUtil.h"
|
#include "MathUtil.h"
|
||||||
|
@ -18,9 +18,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "../../../Core/InputCommon/Src/SDL.h" // Core
|
|
||||||
#include "../../../Core/InputCommon/Src/XInput.h"
|
|
||||||
|
|
||||||
#include "Common.h" // Common
|
#include "Common.h" // Common
|
||||||
#include "StringUtil.h" // for ArrayToString()
|
#include "StringUtil.h" // for ArrayToString()
|
||||||
#include "IniFile.h"
|
#include "IniFile.h"
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "../../../Core/InputCommon/Src/SDL.h" // Core
|
|
||||||
|
|
||||||
#include "wiimote_hid.h"
|
#include "wiimote_hid.h"
|
||||||
#include "EmuDefinitions.h"
|
#include "EmuDefinitions.h"
|
||||||
#include "ChunkFile.h"
|
#include "ChunkFile.h"
|
||||||
|
@ -19,9 +19,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "../../../Core/InputCommon/Src/SDL.h" // Core
|
|
||||||
#include "../../../Core/InputCommon/Src/XInput.h"
|
|
||||||
|
|
||||||
#include "Common.h" // Common
|
#include "Common.h" // Common
|
||||||
#include "StringUtil.h" // for ArrayToString()
|
#include "StringUtil.h" // for ArrayToString()
|
||||||
#include "IniFile.h"
|
#include "IniFile.h"
|
||||||
|
@ -16,10 +16,7 @@
|
|||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include "../../../Core/InputCommon/Src/SDL.h" // Core
|
|
||||||
#include "EmuDefinitions.h"
|
#include "EmuDefinitions.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include "XInput.h"
|
#include "XInput.h"
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user