Permalink
Browse files

Merge pull request #3536 from davilla/joystick

Android Joystick Handling
  • Loading branch information...
2 parents 6eb2007 + 65edc72 commit a17e191ff5006953c7a55bd2a950343599202f6f @davilla davilla committed Nov 2, 2013
View
@@ -3094,7 +3094,7 @@ bool CApplication::ProcessEventServer(float frameTime)
m_lastAxisMap[joystickName].erase(wKeyID);
}
- return ProcessJoystickEvent(joystickName, wKeyID, isAxis, fAmount);
+ return ProcessJoystickEvent(joystickName, wKeyID, isAxis ? JACTIVE_AXIS : JACTIVE_BUTTON, fAmount);
}
else
{
@@ -3138,7 +3138,7 @@ bool CApplication::ProcessEventServer(float frameTime)
for (map<std::string, map<int, float> >::iterator iter = m_lastAxisMap.begin(); iter != m_lastAxisMap.end(); ++iter)
{
for (map<int, float>::iterator iterAxis = (*iter).second.begin(); iterAxis != (*iter).second.end(); ++iterAxis)
- ProcessJoystickEvent((*iter).first, (*iterAxis).first, true, (*iterAxis).second);
+ ProcessJoystickEvent((*iter).first, (*iterAxis).first, JACTIVE_AXIS, (*iterAxis).second);
}
}
@@ -3162,7 +3162,7 @@ bool CApplication::ProcessEventServer(float frameTime)
return false;
}
-bool CApplication::ProcessJoystickEvent(const std::string& joystickName, int wKeyID, bool isAxis, float fAmount, unsigned int holdTime /*=0*/)
+bool CApplication::ProcessJoystickEvent(const std::string& joystickName, int wKeyID, short inputType, float fAmount, unsigned int holdTime /*=0*/)
{
#if defined(HAS_EVENT_SERVER)
m_idleTimer.StartZero();
@@ -3183,7 +3183,7 @@ bool CApplication::ProcessJoystickEvent(const std::string& joystickName, int wKe
bool fullRange = false;
// Translate using regular joystick translator.
- if (CButtonTranslator::GetInstance().TranslateJoystickString(iWin, joystickName.c_str(), wKeyID, isAxis ? JACTIVE_AXIS : JACTIVE_BUTTON, actionID, actionName, fullRange))
+ if (CButtonTranslator::GetInstance().TranslateJoystickString(iWin, joystickName.c_str(), wKeyID, inputType, actionID, actionName, fullRange))
return ExecuteInputAction( CAction(actionID, fAmount, 0.0f, actionName, holdTime) );
else
CLog::Log(LOGDEBUG, "ERROR mapping joystick action. Joystick: %s %i",joystickName.c_str(), wKeyID);
View
@@ -373,6 +373,9 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
#if defined(TARGET_DARWIN_IOS)
friend class CWinEventsIOS;
#endif
+#if defined(TARGET_ANDROID)
+ friend class CWinEventsAndroid;
+#endif
// screensaver
bool m_bScreenSave;
ADDON::AddonPtr m_screenSaver;
@@ -442,7 +445,7 @@ class CApplication : public CXBApplicationEx, public IPlayerCallback, public IMs
bool ProcessGamepad(float frameTime);
bool ProcessEventServer(float frameTime);
bool ProcessPeripherals(float frameTime);
- bool ProcessJoystickEvent(const std::string& joystickName, int button, bool isAxis, float fAmount, unsigned int holdTime = 0);
+ bool ProcessJoystickEvent(const std::string& joystickName, int button, short inputType, float fAmount, unsigned int holdTime = 0);
bool ExecuteInputAction(const CAction &action);
int GetActiveWindowID(void);
@@ -32,3 +32,21 @@
#define AKEYCODE_FORWARD 125
#define AKEYCODE_MEDIA_PLAY 126
#define AKEYCODE_MEDIA_EJECT 129
+
+#define AINPUT_SOURCE_CLASS_JOYSTICK 0x00000010
+
+#define AINPUT_SOURCE_GAMEPAD (0x00000400 | AINPUT_SOURCE_CLASS_BUTTON)
+#define AINPUT_SOURCE_JOYSTICK (0x01000000 | AINPUT_SOURCE_CLASS_JOYSTICK)
+
+// 1st stick X, Y
+#define AMOTION_EVENT_AXIS_X 0
+#define AMOTION_EVENT_AXIS_Y 1
+// 2nd stick X, Y
+#define AMOTION_EVENT_AXIS_Z 11
+#define AMOTION_EVENT_AXIS_RZ 14
+// d-pad X, Y
+#define AMOTION_EVENT_AXIS_HAT_X 15
+#define AMOTION_EVENT_AXIS_HAT_Y 16
+// trigger left, right
+#define AMOTION_EVENT_AXIS_LTRIGGER 17
+#define AMOTION_EVENT_AXIS_RTRIGGER 18
Oops, something went wrong.

0 comments on commit a17e191

Please sign in to comment.