mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-09-21 11:51:48 +02:00
Improve the SDL/XInput hackery of my last commit. Fixes the device refresh button crash.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5628 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
08636392b6
commit
0af55bd85b
2 changed files with 20 additions and 18 deletions
|
@ -18,11 +18,11 @@ namespace ciface
|
||||||
namespace SDL
|
namespace SDL
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// just a struct with an int that is set to ZERO by default
|
||||||
struct ZeroedInt{ZeroedInt():value(0){}unsigned int value;};
|
struct ZeroedInt{ZeroedInt():value(0){}unsigned int value;};
|
||||||
|
|
||||||
void Init( std::vector<ControllerInterface::Device*>& devices )
|
void Init( std::vector<ControllerInterface::Device*>& devices )
|
||||||
{
|
{
|
||||||
// just a struct with an int that is set to ZERO by default
|
|
||||||
|
|
||||||
// this is used to number the joysticks
|
// this is used to number the joysticks
|
||||||
// multiple joysticks with the same name shall get unique ids starting at 0
|
// multiple joysticks with the same name shall get unique ids starting at 0
|
||||||
std::map<std::string, ZeroedInt> name_counts;
|
std::map<std::string, ZeroedInt> name_counts;
|
||||||
|
@ -55,22 +55,23 @@ Joystick::Joystick(SDL_Joystick* const joystick, const int sdl_index, const unsi
|
||||||
// to not use SDL for an XInput device
|
// to not use SDL for an XInput device
|
||||||
// too many people on the forums pick the SDL device and ask:
|
// too many people on the forums pick the SDL device and ask:
|
||||||
// "why don't my 360 gamepad triggers/rumble work correctly"
|
// "why don't my 360 gamepad triggers/rumble work correctly"
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// checking the name is probably good (and hacky) enough
|
// checking the name is probably good (and hacky) enough
|
||||||
// but i'll double check with the num of buttons/axes
|
// but i'll double check with the num of buttons/axes
|
||||||
if (
|
std::string lcasename = GetName();
|
||||||
("Controller (Xbox 360 Wireless Receiver for Windows)" == GetName())
|
std::transform(lcasename.begin(), lcasename.end(), lcasename.begin(), tolower);
|
||||||
&& (10 == SDL_JoystickNumButtons(joystick))
|
|
||||||
&& (5 == SDL_JoystickNumAxes(joystick))
|
|
||||||
&& (1 == SDL_JoystickNumHats(joystick))
|
|
||||||
&& (0 == SDL_JoystickNumBalls(joystick))
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// this device won't be used
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
if ((std::string::npos != lcasename.find("xbox 360"))
|
||||||
|
&& (10 == SDL_JoystickNumButtons(joystick))
|
||||||
|
&& (5 == SDL_JoystickNumAxes(joystick))
|
||||||
|
&& (1 == SDL_JoystickNumHats(joystick))
|
||||||
|
&& (0 == SDL_JoystickNumBalls(joystick))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// this device won't be used
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// get buttons
|
// get buttons
|
||||||
for ( int i = 0; i < SDL_JoystickNumButtons( m_joystick ); ++i )
|
for ( int i = 0; i < SDL_JoystickNumButtons( m_joystick ); ++i )
|
||||||
|
|
|
@ -600,7 +600,8 @@ void GamepadPage::RefreshDevices( wxCommandEvent& event )
|
||||||
g_plugin->controls_crit.Enter(); // enter
|
g_plugin->controls_crit.Enter(); // enter
|
||||||
|
|
||||||
// refresh devices
|
// refresh devices
|
||||||
g_plugin->controller_interface.DeInit();
|
// TODO: remove hackery of not deinting SDL
|
||||||
|
g_plugin->controller_interface.DeInit(true);
|
||||||
g_plugin->controller_interface.Init();
|
g_plugin->controller_interface.Init();
|
||||||
|
|
||||||
// update all control references
|
// update all control references
|
||||||
|
|
Loading…
Reference in a new issue