diff --git a/configure.in b/configure.in
index beb8aacd69e6a..e3fcd04db16ee 100644
--- a/configure.in
+++ b/configure.in
@@ -2153,6 +2153,9 @@ else
final_message="$final_message\n Joystick:\tNo"
fi
+# --enable-joystick is for SDL joysticks, use joystick.h for Linux Joystick API
+AC_CHECK_HEADER([linux/joystick.h], AC_DEFINE([HAS_LINUX_JOYSTICK],[1],[Define if we have linux/joystick.h]),)
+
if test "$use_xrandr" = "yes"; then
final_message="$final_message\n XRandR:\tYes"
USE_XRANDR=1
diff --git a/project/VS2010Express/XBMC.vcxproj b/project/VS2010Express/XBMC.vcxproj
index 0b1c0c62ad09b..1854e296c88a1 100644
--- a/project/VS2010Express/XBMC.vcxproj
+++ b/project/VS2010Express/XBMC.vcxproj
@@ -626,6 +626,8 @@
+
+
@@ -634,7 +636,8 @@
-
+
+
@@ -1031,13 +1034,17 @@
-
+
+
+
+
+
@@ -2917,4 +2924,4 @@
-
\ No newline at end of file
+
diff --git a/project/VS2010Express/XBMC.vcxproj.filters b/project/VS2010Express/XBMC.vcxproj.filters
index 829f0531d74b9..4e94f4cd013ef 100644
--- a/project/VS2010Express/XBMC.vcxproj.filters
+++ b/project/VS2010Express/XBMC.vcxproj.filters
@@ -2484,9 +2484,6 @@
utils
-
- input\windows
-
filesystem
@@ -3113,6 +3110,18 @@
cores\dvdplayer\DVDCodecs\Video
+
+ input
+
+
+ input
+
+
+ input\windows
+
+
+ input\windows
+
@@ -5593,9 +5602,6 @@
utils
-
- input\windows
-
filesystem
@@ -6112,6 +6118,21 @@
utils
+
+ input
+
+
+ input
+
+
+ input
+
+
+ input\windows
+
+
+ input\windows
+
win32
diff --git a/system/keymaps/joystick.Microsoft.Xbox.360.Controller.xml b/system/keymaps/joystick.Microsoft.Xbox.360.Controller.xml
index 4a1fe438a5a8f..0379304460068 100644
--- a/system/keymaps/joystick.Microsoft.Xbox.360.Controller.xml
+++ b/system/keymaps/joystick.Microsoft.Xbox.360.Controller.xml
@@ -74,6 +74,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -167,6 +168,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -200,6 +202,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -233,6 +236,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -270,6 +274,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -352,6 +357,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -399,6 +405,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -440,6 +447,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -477,6 +485,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -540,6 +549,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -575,6 +585,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -608,6 +619,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -641,6 +653,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -706,6 +719,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -743,6 +757,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -780,6 +795,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -813,6 +829,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -852,6 +869,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -887,6 +905,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -922,6 +941,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -959,6 +979,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -992,6 +1013,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -1035,6 +1057,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -1070,6 +1093,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -1103,6 +1127,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -1136,6 +1161,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -1169,6 +1195,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -1202,6 +1229,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -1235,6 +1263,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -1270,6 +1299,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -1303,6 +1333,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -1336,6 +1367,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -1369,6 +1401,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -1404,6 +1437,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -1437,6 +1471,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
@@ -1472,6 +1507,7 @@
+ XBMC-Compatible XInput Controller
Afterglow Gamepad for Xbox 360 (Controller)
Controller (Gamepad F310)
Controller (Gamepad for Xbox 360)
diff --git a/system/settings/settings.xml b/system/settings/settings.xml
index ca2ac561f2d69..3b509153ad4b1 100644
--- a/system/settings/settings.xml
+++ b/system/settings/settings.xml
@@ -2600,9 +2600,12 @@
true
- HAS_SDL_JOYSTICK
+ HAS_JOYSTICK
0
true
+
+
+
diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp
index 265881f41135b..e583de25b5908 100644
--- a/xbmc/Application.cpp
+++ b/xbmc/Application.cpp
@@ -328,10 +328,8 @@
#include "input/windows/IRServerSuite.h"
#endif
-#if defined(TARGET_WINDOWS)
-#include "input/windows/WINJoystick.h"
-#elif defined(HAS_SDL_JOYSTICK) || defined(HAS_EVENT_SERVER)
-#include "input/SDLJoystick.h"
+#if defined(HAS_JOYSTICK) || defined(HAS_EVENT_SERVER)
+#include "input/JoystickManager.h"
#endif
#if defined(TARGET_ANDROID)
@@ -366,6 +364,7 @@ using namespace ANNOUNCEMENT;
using namespace PVR;
using namespace EPG;
using namespace PERIPHERALS;
+using namespace JOYSTICK;
using namespace XbmcThreads;
@@ -1515,9 +1514,9 @@ bool CApplication::Initialize()
// reset our screensaver (starts timers etc.)
ResetScreenSaver();
-#ifdef HAS_SDL_JOYSTICK
- g_Joystick.SetEnabled(CSettings::Get().GetBool("input.enablejoystick") &&
- CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0 );
+#ifdef HAS_JOYSTICK
+ CJoystickManager::Get().SetEnabled(CSettings::Get().GetBool("input.enablejoystick") &&
+ CPeripheralImon::GetCountOfImonsConflictWithDInput() == 0);
#endif
return true;
@@ -2970,94 +2969,11 @@ void CApplication::FrameMove(bool processEvents, bool processGUI)
bool CApplication::ProcessGamepad(float frameTime)
{
-#ifdef HAS_SDL_JOYSTICK
- if (!m_AppFocused)
- return false;
-
- int iWin = GetActiveWindowID();
- int bid = 0;
- g_Joystick.Update();
- if (g_Joystick.GetButton(bid))
- {
- // reset Idle Timer
- m_idleTimer.StartZero();
-
- ResetScreenSaver();
- if (WakeUpScreenSaverAndDPMS())
- {
- g_Joystick.Reset(true);
- return true;
- }
-
- int actionID;
- CStdString actionName;
- bool fullrange;
- if (CButtonTranslator::GetInstance().TranslateJoystickString(iWin, g_Joystick.GetJoystick().c_str(), bid, JACTIVE_BUTTON, actionID, actionName, fullrange))
- {
- CAction action(actionID, 1.0f, 0.0f, actionName);
- g_Joystick.Reset();
- g_Mouse.SetActive(false);
- return ExecuteInputAction(action);
- }
- else
- {
- g_Joystick.Reset();
- }
- }
- if (g_Joystick.GetAxis(bid))
+#ifdef HAS_JOYSTICK
+ if (m_AppFocused && CJoystickManager::Get().Count() > 0)
{
- if (g_Joystick.GetAmount() < 0)
- {
- bid = -bid;
- }
-
- int actionID;
- CStdString actionName;
- bool fullrange;
- if (CButtonTranslator::GetInstance().TranslateJoystickString(iWin, g_Joystick.GetJoystick().c_str(), bid, JACTIVE_AXIS, actionID, actionName, fullrange))
- {
- ResetScreenSaver();
- if (WakeUpScreenSaverAndDPMS())
- {
- return true;
- }
-
- CAction action(actionID, fullrange ? (g_Joystick.GetAmount() + 1.0f)/2.0f : fabs(g_Joystick.GetAmount()), 0.0f, actionName);
- g_Joystick.Reset();
- g_Mouse.SetActive(false);
- return ExecuteInputAction(action);
- }
- else
- {
- g_Joystick.ResetAxis(abs(bid));
- }
- }
- int position = 0;
- if (g_Joystick.GetHat(bid, position))
- {
- // reset Idle Timer
- m_idleTimer.StartZero();
-
- ResetScreenSaver();
- if (WakeUpScreenSaverAndDPMS())
- {
- g_Joystick.Reset();
- return true;
- }
-
- int actionID;
- CStdString actionName;
- bool fullrange;
-
- bid = position<<16|bid;
-
- if (bid && CButtonTranslator::GetInstance().TranslateJoystickString(iWin, g_Joystick.GetJoystick().c_str(), bid, JACTIVE_HAT, actionID, actionName, fullrange))
- {
- CAction action(actionID, 1.0f, 0.0f, actionName);
- g_Joystick.Reset();
- g_Mouse.SetActive(false);
- return ExecuteInputAction(action);
- }
+ CJoystickManager::Get().Update();
+ return true;
}
#endif
return false;
@@ -3263,8 +3179,9 @@ bool CApplication::ProcessJoystickEvent(const std::string& joystickName, int wKe
if (WakeUpScreenSaverAndDPMS())
return true;
-#ifdef HAS_SDL_JOYSTICK
- g_Joystick.Reset();
+#ifdef HAS_JOYSTICK
+ // Reset the action repeat event
+ CJoystickManager::Get().Reset();
#endif
g_Mouse.SetActive(false);
diff --git a/xbmc/Application.h b/xbmc/Application.h
index e3a26c5e7cb43..cb0ea6db016d1 100644
--- a/xbmc/Application.h
+++ b/xbmc/Application.h
@@ -251,6 +251,9 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
bool ExecuteXBMCAction(std::string action);
+ bool ExecuteInputAction(const CAction &action);
+ int GetActiveWindowID(void);
+
static bool OnEvent(XBMC_Event& newEvent);
CNetwork& getNetwork();
@@ -448,8 +451,6 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
bool ProcessEventServer(float frameTime);
bool ProcessPeripherals(float frameTime);
bool ProcessJoystickEvent(const std::string& joystickName, int button, short inputType, float fAmount, unsigned int holdTime = 0);
- bool ExecuteInputAction(const CAction &action);
- int GetActiveWindowID(void);
float NavigationIdleTime();
static bool AlwaysProcess(const CAction& action);
diff --git a/xbmc/SystemGlobals.cpp b/xbmc/SystemGlobals.cpp
index 2dd1734f7acef..cece7c63d0e77 100644
--- a/xbmc/SystemGlobals.cpp
+++ b/xbmc/SystemGlobals.cpp
@@ -37,11 +37,6 @@
#ifdef HAS_PYTHON
#include "interfaces/python/XBPython.h"
#endif
-#if defined(TARGET_WINDOWS)
-#include "input/windows/WINJoystick.h"
-#elif defined(HAS_SDL_JOYSTICK)
-#include "input/SDLJoystick.h"
-#endif
#if defined(HAS_FILESYSTEM_RAR)
#include "filesystem/RarManager.h"
@@ -63,9 +58,6 @@
CGUITextureManager g_TextureManager;
CGUILargeTextureManager g_largeTextureManager;
CMouseStat g_Mouse;
-#if defined(HAS_SDL_JOYSTICK)
- CJoystick g_Joystick;
-#endif
CGUIPassword g_passwordManager;
CGUIInfoManager g_infoManager;
diff --git a/xbmc/input/ButtonTranslator.cpp b/xbmc/input/ButtonTranslator.cpp
index 4407d8d1fca87..9915d197912d6 100644
--- a/xbmc/input/ButtonTranslator.cpp
+++ b/xbmc/input/ButtonTranslator.cpp
@@ -35,10 +35,8 @@
#include "utils/XBMCTinyXML.h"
#include "XBIRRemote.h"
-#if defined(TARGET_WINDOWS)
-#include "input/windows/WINJoystick.h"
-#elif defined(HAS_SDL_JOYSTICK) || defined(HAS_EVENT_SERVER)
-#include "SDLJoystick.h"
+#if defined(HAS_JOYSTICK) || defined(HAS_EVENT_SERVER)
+#include "JoystickManager.h"
#endif
#define JOYSTICK_DEFAULT_MAP "_xbmc_"
@@ -269,6 +267,28 @@ static const ActionMapping actions[] =
{ "noop" , ACTION_NOOP}
};
+/* static */
+bool CButtonTranslator::IsAnalog(int actionID)
+{
+ switch (actionID)
+ {
+ case ACTION_ANALOG_SEEK_FORWARD:
+ case ACTION_ANALOG_SEEK_BACK:
+ case ACTION_ANALOG_FORWARD:
+ case ACTION_ANALOG_REWIND:
+ case ACTION_ANALOG_MOVE:
+ case ACTION_CURSOR_LEFT:
+ case ACTION_CURSOR_RIGHT:
+ case ACTION_VOLUME_UP:
+ case ACTION_VOLUME_DOWN:
+ case ACTION_ZOOM_IN:
+ case ACTION_ZOOM_OUT:
+ return true;
+ default:
+ return false;
+ }
+}
+
static const ActionMapping windows[] =
{{"home" , WINDOW_HOME},
{"programs" , WINDOW_PROGRAMS},
@@ -742,7 +762,7 @@ int CButtonTranslator::TranslateLircRemoteString(const char* szDevice, const cha
}
#endif
-#if defined(HAS_SDL_JOYSTICK) || defined(HAS_EVENT_SERVER)
+#if defined(HAS_JOYSTICK) || defined(HAS_EVENT_SERVER)
void CButtonTranslator::MapJoystickActions(int windowID, TiXmlNode *pJoystick)
{
string joyname = JOYSTICK_DEFAULT_MAP; // default global map name
@@ -1126,7 +1146,7 @@ void CButtonTranslator::MapWindowActions(TiXmlNode *pWindow, int windowID)
}
}
-#if defined(HAS_SDL_JOYSTICK) || defined(HAS_EVENT_SERVER)
+#if defined(HAS_JOYSTICK) || defined(HAS_EVENT_SERVER)
if ((pDevice = pWindow->FirstChild("joystick")) != NULL)
{
// map joystick actions
@@ -1461,7 +1481,7 @@ void CButtonTranslator::Clear()
lircRemotesMap.clear();
#endif
-#if defined(HAS_SDL_JOYSTICK) || defined(HAS_EVENT_SERVER)
+#if defined(HAS_JOYSTICK) || defined(HAS_EVENT_SERVER)
m_joystickButtonMap.clear();
m_joystickAxisMap.clear();
m_joystickHatMap.clear();
diff --git a/xbmc/input/ButtonTranslator.h b/xbmc/input/ButtonTranslator.h
index 11ac033cc1e2d..c49cda449efb1 100644
--- a/xbmc/input/ButtonTranslator.h
+++ b/xbmc/input/ButtonTranslator.h
@@ -25,7 +25,7 @@
#include