Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Android Joystick Handling #3536

Merged
merged 6 commits into from

4 participants

@davilla
Collaborator

Add native android joystick handling, Works OOTB with Ouya, GameStick and Nvidia/Shield.

Much thanks to Koying for putting up with the old man, Nvidia for donating a few Shields for development work as well as Pivos/GameStick for the initial implementation and Ouya for dev units.

@garbear
Collaborator

perfect, thank you for creating this PR davilla. When I finish the Joystick API pr I'll be able to migrate over the joystick processing from CWinEventsAndroid.

Getting to know the Android layer is still something I've been meaning to do, so there's little I can check but I'll do a quick review.

@davilla
Collaborator

merged and ready to go.

xbmc/android/activity/AndroidKey.cpp
((35 lines not shown))
XBMC_Key((uint8_t)keycode, sym, modifiers, true);
+#endif
@jmarshallnz Owner

is the ifdef block supposed to surround the XBMC_Key() routine (or is only the debug stuff?)

@davilla Collaborator
davilla added a note

no, that's a bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
xbmc/android/activity/EventLoop.cpp
@@ -133,24 +134,41 @@ void CEventLoop::processActivity(int32_t command)
int32_t CEventLoop::processInput(AInputEvent* event)
{
- int32_t type = AInputEvent_getType(event);
- switch (type)
+ int32_t rtn = 0;
+ int32_t type = AInputEvent_getType(event);
+ int32_t source = AInputEvent_getSource(event);
+ int32_t repeat = AKeyEvent_getRepeatCount(event);
+ int32_t keycod = AKeyEvent_getKeyCode(event);
@jmarshallnz Owner

is there a plan to use these last two?

@davilla Collaborator
davilla added a note

when debug is enabled, yes.

@jmarshallnz Owner

Not in this function though - appears only to be a switch on type and on source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jmarshallnz jmarshallnz commented on the diff
xbmc/windowing/android/WinEventsAndroid.cpp
((215 lines not shown))
+ input_device.id, input_device.name.c_str());
+ m_input_devices.push_back(input_device);
+ }
+
+ if (type == XBMC_JOYAXISMOTION || type == XBMC_JOYHATMOTION)
+ {
+ // Joystick autorepeat -> only handle axis
+ CSingleLock lock(m_lasteventCond);
+ m_lastevent.push(pumpEvent);
+ }
+
+ if (fabs(amount) >= ALMOST_ZERO)
+ {
+ ret |= g_application.ProcessJoystickEvent(input_device.name,
+ item, input_type, amount, holdTime);
+ }
@jmarshallnz Owner

Amount is always 1.0 or 0.0 as things are. This seems a bit odd to me, as I'd have thought that 0.5 should be a valid value for one of the axes to take?

Maybe there is supposed to be a line in the XBMC_JOYAXISMOTION case with amount = pumpEvent.jaxis.fvalue; ?

@davilla Collaborator
davilla added a note

As you should know, one never should try for == with floats, they just don't work that way in hardware. So >= ALMOST_ZERO means +/- 1.0 in this case.

@jmarshallnz Owner

ATM, amount can only ever possibly be 0 or 1. Should you maybe have a line of code assigning pumpEvent.jaxis.fvalue to amount ?

@jmarshallnz Owner

@davillla, @koying? Surely as things are the analog sticks are functioning as dpads. No analog at all as amount is never set to anything other than 0 or 1.

@koying Collaborator
koying added a note

Indeed. To be discussed with @garbear for his refactor, I guess.
XBMC analog seek stuff seems broken, now, so if a stick has no dpad, that renders it useless. IMO, ideally, we should be able to assign up/down/... to a true analog stick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@jmarshallnz
Owner

Looks good other than those minors.

@davilla davilla merged commit a17e191 into xbmc:master
@koying

@davilla Any specific reasons for filtering key events? Right mouse button sends a KeyEvent.KEYCODE_BACK and it doesn't seem to be trapped by us anymore, so I suspect this filters it out.

Collaborator

I confirm this cause right mouse button to go back to desktop

Collaborator

k

@davilla davilla deleted the davilla:joystick branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 1, 2013
  1. @davilla
  2. @davilla
  3. @koying @davilla

    FIX: Enable Hat handling in Application::ProcessJoystick

    koying authored davilla committed
  4. @koying @davilla

    FIX: [droid] proper joystick Hat support

    koying authored davilla committed
Commits on Nov 2, 2013
  1. @davilla

    PR: fixup PR comments

    davilla authored
  2. @koying @davilla

    FIX: [droid] joystick debugging spam

    koying authored davilla committed
Something went wrong with that request. Please try again.