Retroplayer on Android

  Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Montellese Offline
Team Kodi Developer
Posts: 4,834
Joined: Jan 2009
Reputation: 72
Location: Switzerland
Post: #16
(2016-02-10 22:36)Hedda Wrote:  Cool! Could the team please consider doing the same for Apple's official Game Controller Framework + API in iOS 7 and OS X 10.9 or later?

http://forum.kodi.tv/showthread.php?tid=204398
I don't own and I also don't want to own any apple devices so somebody else will have to step up and do the work.

Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
(This post was last modified: 2016-02-10 22:42 by Montellese.)
find quote
Montellese Offline
Team Kodi Developer
Posts: 4,834
Joined: Jan 2009
Reputation: 72
Location: Switzerland
Post: #17
Figured out how to setup the input device callbacks which are now forwarded to CPeripheralBusAndroid so no polling needed on android.

Now the next step is to revive the joystick input logic and forward the input evens appropriately.

Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
find quote
ironic_monkey Offline
Posting Freak
Posts: 1,423
Joined: Nov 2013
Reputation: 66
Post: #18
i still don't get why this has to be done in core and all other handling is done in the add-on.
find quote
Montellese Offline
Team Kodi Developer
Posts: 4,834
Joined: Jan 2009
Reputation: 72
Location: Switzerland
Post: #19
(2016-02-11 08:16)ironic_monkey Wrote:  i still don't get why this has to be done in core and all other handling is done in the add-on.

I don't know how familiar you are with the android NDK and API.
There are two parts to implementing this for android (and probably any other platform / API):
  • Getting and maintaining the list of connected peripheral joysticks. On android this can either be done by polling InputManager.getInputDeviceIds() and then using the IDs to retrieve the input device objects through InputManager.getInputDevice() or by implementing and registering an InputDeviceListener. I've done both (because I couldn't get the InputDeviceListener to work at first so both work but obviously the listener is the nicer approach. And exposing the JNI environment isn't something I'd like to do because you can take down the whole app if you mess something up with the JNI environment. The problem is that to access these methods from android's Java API you need to make JNI calls and for that you need to have access to the JNI environment. So we'd have to explicitly write an android specific API for binary add-ons to call the methods mentioned above. For the InputDeviceListener approach it gets even more complicated. You need a Java implementation of the listener which then forwards the calls to native implementations through JNI. Registering the listener only seems to be possible in a Java thread that has been setup as a Looper. The main activity's thread is setup as a Looper thread by default so I just used that to register the implementation of the listener. Doing this from a binary add-on would require yet more android specific API definitions. Either way you'd require the Java wrapper implementation of the listener so this would not be doable purely in a binary add-on.
  • Getting and processing the input events. In a native android application AFAIK you can only have a single input event handler and you need to register it with your app's main activity. We obviously have an input event handler to also be able to handle touch and keyboard input so we automatically also receive any joystick input events in that handler. We'd again have to write an android specific API to somehow forward specific events to a binary addon method implementation. We already do the "forward this specific event to this handler" but this is all in the android platform specific code and we turn the events into general Kodi events before passing them on to the input pump which injects the events into Kodi's input handling thread.

So theoretically it would be doable in a binary addon but we'd have to write quite a few android specific API methods which are of no use to any other binary addon type and we'd run the risk of exposing stuff like the JNI environment which have to be treated very carefully.

Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
find quote
ironic_monkey Offline
Posting Freak
Posts: 1,423
Joined: Nov 2013
Reputation: 66
Post: #20
makes sense. i naively thought this would be exposed through the ndk.
find quote
Montellese Offline
Team Kodi Developer
Posts: 4,834
Joined: Jan 2009
Reputation: 72
Location: Switzerland
Post: #21
Well input events are, haven't checked for the input manager and listener stuff but it's still bound to the main activity.
NVidia seems to have some kind of native controller support library (for Shield TV) but haven't had the time to look into it yet.

Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
(This post was last modified: 2016-02-11 09:56 by Montellese.)
find quote
Montellese Offline
Team Kodi Developer
Posts: 4,834
Joined: Jan 2009
Reputation: 72
Location: Switzerland
Post: #22
After a few more hours and stealing a lot of code from the peripheral addon stuff I have the buttions (A, B, X, Y, Back, Menu, Left Shoulder, Right Shoulder, Left Stick, Right Stick) working. Now to the D-Pad :-)

Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
find quote
Montellese Offline
Team Kodi Developer
Posts: 4,834
Joined: Jan 2009
Reputation: 72
Location: Switzerland
Post: #23
OK I got everything working and now I just need to clean up all the commits etc.

Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
find quote
a1rwulf Offline
Team-Kodi Member
Posts: 295
Joined: Oct 2014
Reputation: 9
Post: #24
nice!
find quote
garbear Online
Team-Kodi Developer
Posts: 1,749
Joined: Dec 2010
Reputation: 112
Location: city of angels
Post: #25
cool. anything else blocking the controller input PR? once this is in, I can start rebasing the rest of retroplayer so we can get it running on android

BTC: 1JtXwJdGdE9YnYgThWBT2StFCU5sEYkbVD (personal), https://kodi.tv/contribute/donate-bitcoin (foundation). Donations in the form of controllers, especially ones that don't work in Kodi, are also appreciated.
find quote
Montellese Offline
Team Kodi Developer
Posts: 4,834
Joined: Jan 2009
Reputation: 72
Location: Switzerland
Post: #26
What's the status on iOS? Does it compile but is missing specific joystick support? Unfortunately I won't be able to help out on that.

Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
find quote
garbear Online
Team-Kodi Developer
Posts: 1,749
Joined: Dec 2010
Reputation: 112
Location: city of angels
Post: #27
as long as iOS compiles, we can add support for the gamepad controller framework later

BTC: 1JtXwJdGdE9YnYgThWBT2StFCU5sEYkbVD (personal), https://kodi.tv/contribute/donate-bitcoin (foundation). Donations in the form of controllers, especially ones that don't work in Kodi, are also appreciated.
find quote
kraakie Offline
Junior Member
Posts: 3
Joined: Aug 2014
Reputation: 0
Post: #28
is there a build for android or do i have to compile it myself ??

little bit confused Smile
find quote
garbear Online
Team-Kodi Developer
Posts: 1,749
Joined: Dec 2010
Reputation: 112
Location: city of angels
Post: #29
I don't plan to backport the android support from the first half of retroplayer, based on 17 alpha, to the branch I've been releasing, based on 15.2. If someone else does the backport we'll see android in the near future, otherwise we'll have to wait til I've rebased the second half on 17 alpha. (this will take at least a month or two)

BTC: 1JtXwJdGdE9YnYgThWBT2StFCU5sEYkbVD (personal), https://kodi.tv/contribute/donate-bitcoin (foundation). Donations in the form of controllers, especially ones that don't work in Kodi, are also appreciated.
find quote
Solo0815 Offline
Posting Freak
Posts: 927
Joined: Sep 2004
Reputation: 9
Location: Germany
Post: #30
Looking forward to have your PR8807 integrated in Kodi. First half in Kodi is better than nothing Wink
Keep up the good work!

PC: Kubuntu 16.10 and Win7/10 --- Wetek Play: LibreELEC 7.95.x --- RPi3: 7.95.x --- NAS: OMV 2.x
find quote