aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRainer Hochecker <fernetmenta@online.de>2013-11-09 23:09:55 -0800
committerRainer Hochecker <fernetmenta@online.de>2013-11-09 23:09:55 -0800
commit38c19ba69c5d160e0b647978fb396e6966b3641e (patch)
treec02e0429dca5a03432bb1a9c5eee09dd222636dd
parent21c181048847664e3146c195fa38f1c129ee0685 (diff)
parent1560550480302e4768d1e183f038b709dd5a52fd (diff)
Merge pull request #3603 from fritsch/microsoft-js
Input: Devices with 37 axis and 57 buttons are keyboards (@microsoft)
-rw-r--r--xbmc/input/SDLJoystick.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/xbmc/input/SDLJoystick.cpp b/xbmc/input/SDLJoystick.cpp
index d209c44112..cdb128ddfb 100644
--- a/xbmc/input/SDLJoystick.cpp
+++ b/xbmc/input/SDLJoystick.cpp
@@ -25,6 +25,7 @@
#include "settings/AdvancedSettings.h"
#include "settings/Setting.h"
#include "utils/log.h"
+#include "utils/StringUtils.h"
#include <math.h>
@@ -105,14 +106,24 @@ void CJoystick::Initialize()
continue;
}
#endif
-
- m_Joysticks.push_back(joy);
if (joy)
{
- m_JoystickNames.push_back(string(SDL_JoystickName(i)));
- CLog::Log(LOGNOTICE, "Enabled Joystick: %s", SDL_JoystickName(i));
- CLog::Log(LOGNOTICE, "Details: Total Axis: %d Total Hats: %d Total Buttons: %d",
- SDL_JoystickNumAxes(joy), SDL_JoystickNumHats(joy), SDL_JoystickNumButtons(joy));
+ // Some (Microsoft) Keyboards are recognized as Joysticks by modern kernels
+ // Don't enumerate them
+ // https://bugs.launchpad.net/ubuntu/+source/linux/+bug/390959
+ // NOTICE: Enabled Joystick: Microsoft Wired Keyboard 600
+ // Details: Total Axis: 37 Total Hats: 0 Total Buttons: 57
+ int num_axis = SDL_JoystickNumAxes(joy);
+ if (num_axis > 20 && StringUtils::FindWords(SDL_JoystickName(i), "keyboard") != std::string::npos)
+ CLog::Log(LOGNOTICE, "Your Joystick is a Keyboard, ignoring it: %s Axis: %d", SDL_JoystickName(i), num_axis);
+ else
+ {
+ m_JoystickNames.push_back(string(SDL_JoystickName(i)));
+ CLog::Log(LOGNOTICE, "Enabled Joystick: %s", SDL_JoystickName(i));
+ CLog::Log(LOGNOTICE, "Details: Total Axis: %d Total Hats: %d Total Buttons: %d",
+ num_axis, SDL_JoystickNumHats(joy), SDL_JoystickNumButtons(joy));
+ m_Joysticks.push_back(joy);
+ }
}
else
{