Having a little trouble with a usb controller on the android version

Alright, to start off, i’m using android 5.1.1 on a HardKernel Odroid-C2, emulators run great (except psx but that could be the game i’m using). Even goldeneye 007 and perfect dark are playable. BUT i’m having trouble with my controller. My controller is a Teensy 2.0, 23 buttons 1 joystick, but set to 8 analogs (6 of which are locked in the middle) So only the first 2 X/Y analogs do anything.

My problem is… sometimes it works… sometimes it doesn’t. I checked my connections, Android treats the joystick as an easy way to get through the OS pretty easily and treats the buttons all as a screen tap. But Retroarch seems very finicky, Sometimes it’ll use the buttons to work through the menus. sometimes it’ll detect the teensy as a device, and once in a great while it’ll detect it once an emulator has started. but 9/10 times it won’t. OR it’ll detect it prior to starting a core, but once the core has started, it’ll no longer detect it. If it works in the menu, i’ll get into a game, (SMB for snes for example) and it’ll stop working there. Then when i close the core and back in the main menu, it’ll still not work. And i end up having to use the keyboard to get around.

My autoconfig file that i made While the controller worked in the menu is


input_driver = "android"
input_device = "LynxDroid"
input_vendor_id = "5824"
input_product_id = "1157"
input_b_btn = "194"
input_y_btn = "202"
input_select_btn = "192"
input_start_btn = "193"
input_up_btn = "189"
input_down_btn = "190"
input_left_btn = "188"
input_right_btn = "191"
input_a_btn = "195"
input_x_btn = "199"
input_l_btn = "0"
input_r_btn = "203"
input_l2_btn = "0"
input_l_x_plus_axis = "+0"
input_l_x_minus_axis = "-0"
input_l_y_plus_axis = "+1" input_l_y_minus_axis = "-1"

I don’t know why some of the buttons like, L and L2 are 0, they should be button 17 and button 18, but this could have something to do with it being android.

So if anyone has any clue as to what the cause could be, please let me know. (so far, reicast from their 2016-5-22 build is the only emulator that runs flawlessly. with the controller) Setting up all the buttons to emulate keyboard keys is a partial option, it could break other emulators, so i’d prefer if it was a last resort kind of thing. As some games/emulators will do keyboard keys or gamepad, but not both.

Edit: Found an unusual temporary half-solution. If i unplug the teensy and plug it back in every time it stops working, it’ll sometimes start working again. This won’t be an option once my portable lynxdroid (atari lynx model 2) build is complete. I can’t be switching the thing on and off every time i get a hiccup. it needs to be working ALL the time.

Oh, and i’m using the 6-11 nightly build But it doesn’t really matter what build i use, only problem i’ve been having with the nightly build is sometimes it’ll say it’s not installed. not sure the cause of that, but that’s another issue i’ll deal with later.

http://libretro.com/forums/showthread.php?t=5811 Try these solutions.

Well the tincore keymapper will likely be needed for other programs, android games. If it does what i think it does, maps usb/BT controller buttons into onscreen touch presses. But sadly that’s not a solution.

I don’t know the cause of this, and i tried a lot of different things. Using the playstore stable build (because of another bug), The usb controller will work, if i disconnect it and plug it back in So everything seems to be configured right… Start retroarch, Does controller work? if yes, then yay, if no then disconnect and reconnect controller, 19/20 times reconnecting it will work. While in retroarch, start a core, once a game is started, does the controller work? if yes, then yay, if not then disconnect and reconnect the controller and 9/10 times it’ll work now. Close the core, and back in retroarch, and it repeats. So every time i go between retroarch’s front end, or a game, i have to disconnect and reconnect the controller. The chance the controller works right away is incredibly low, like 1/20 if that. I almost always have to unplug it and plug it back in.

Something is preventing the controller from working between these sections.

Also, only setting the input/joypad drivers to android seem to work on the playstore build. But maybe it’s just me, but i’m getting a bad button limit, about 1/3 of my buttons just go to 0, so is there a 16 button limit? This joypad problem and the uninstalling nightly problem seem to be the only things holding my project back right now.

Read the full thread, try the solution about disabling autoconfig and mapping the buttons using bind all.

Did that. Didn’t work. I’ll read through the thread again, but i tried a LOT of stuff over the last few days. Some stuff breaks it completely, some stuff just goes back to what i’ve been having. Because my autoconfig, just does the same thing the bind all keys do, (except the ones left blank) There’s just no difference.

The controller works. If i unplug it and plug it back in after starting retroarch, and again after starting a game.

Alright, here’s my settings. The input driver can be changed to null with zero change, the joypad driver can be changed to null or hid(nightly which doesn’t persist for me yet). Changing it to hid in the stable does nothing, and if memory serves correct, did nothing in the nightly… Changing the joypad driver to linuxraw (manually with a text editor on the cfg file) does the same thing as it being set to android.

As you can see, autoconfig is off, and the other various settings are like that.

This picture is Pre-reconnect on the controller, at this stage, the controller functions do not work, and the device index says N/A.

This is what the post-reconnect, after i unplugged and plugged the usb controller back in and now the controller works. As you can see, it now says LynxDroid, which is my Teensy’s HID Descriptor.

Could it be something to do with how retroarch checks the device index on app start? or core change?

Mmm does your controller work on stand alone android emulators without disconnecting? I guess you could try to use tincore to simulate another external controller, see if that helps:http://tincore.freewiki.in/index.php/Usage:_Simulate_Controller

yes it works with other standalone emulators. Works beautifully with reicast, just wish reicast worked as beautiful in and of it’self. Does the android have a 16 button limit? i can’t seem to get more than 16 to work?

The android OS itself has zero problems with using the controller and it’s 3 hid functions. the joystick moves between the apps in the menu, and all the gamepad buttons act as a screen tap on what ever is highlighted. keyboard keys also work if in that mode, and mouse mode works too, (though i’ll need to tweak it… a lot… slow cursor travel)

Also i did a lot of tweaking on the teensy, and redid part the hid code. saw some improvement. The teensy emulates a usb keyboard, mouse, and joystick all at once, even if no mouse commands are present(yet), (this doesn’t interfere with other mice, that i know of., it hasn’t yet in the year i’ve been using them.) By redoing the hid code, the joystick is more responsive, in that it needs fewer reconnects, but now the keyboard commands are giving me trouble. Any buttons over #16 on the gamepad show as 0 in retroarch. So my guess is android doesn’t support more than 16 buttons on a controller. This wasn’t a problem with retropie’s SDL. so i don’t know if android can support SDL inputs without having to recompile the whole android OS. Because of the 16 button limit, i’m having to use any additional buttons as keyboard keys. (my other emulators don’t need more than 16, but retroarch will, for me) So i can get flawless keyboard emulation and awful joystick emulation, or somewhat good joystick emulation with awful keyboard emulation. Retroarch is the only app that’s giving me trouble atm. Where i’ll regularly need to disconnect and reconnect. linuxraw as the joypad driver seems to be the best for the gamepad so far. The most compatible with my new tweaks. (i had to edit retroarch.cfg manually to use it)

Tincore is like a last resort kind of thing, since it may not be compatible with everything else i’ll be using it on.

Short version, The teensy will have multiple profiles, a gamepad profile which has 16 gamepad buttons, 1-2 joysticks, and the rest of the GPIOs will be used for keyboard keys, with the exception of 1, which will switch to my secondary profile, which will turn the joystick into a mouse, and turn all GPIOs into keyboard keys for use with hopefully OpenMW when it’s ready, and similar games.

As far as i know retroarch input system relies on input devices, one device assigned to one port, so maybe the keyboard and mouse emulation is causing issues? Also tincore does not make permanent changes to your input device so you can just turn off tincore when you do not need it and you controller will work the same again. Using tincore you could just remap all your controller buttons to kb input, that way you could maybe use more than 16 buttons in retroarch . There are also apps to remap your controller buttons that do not require root like gamekeyboard+ and key redefiner.

yeah i considered it could be the keyboard and mouse that’s also the problem. Thing is, i need the keyboard and mouse, or, i will as my build comes to a close.

It’s quickly becoming a pain in the butt. Gamepad compatibility is a little better, but now keyboard compatibility is down. the 16 button limit seems to be an android limitation. Since i tried a joystick test app, and sure enough it didn’t go above 16 either. I’ll usually get keyboard OR gamepad. And i’d be ok mapping all my buttons to keyboard keys, if not for 1 little thing… the joystick(s) or rather, PSVita thumbsticks. If i want to play certain games that rely on such, using joystick to keyboard emulation is not an option. So i have to have the gamepad being recognized, and i have to have keyboard for my >16 buttons.

Edit: I could disable the keyboard, if i could JUST get 17 buttons (which may not be out of the question.) DPAD = 4 ABC/XYZ = 6 Triggers = 4 Start, Select = 2 … That’s 16 already And then hotkey would be #17. Using one of the other buttons isn’t a great idea for a hotkey, due to some games using button combos. I noticed all buttons above 16, say 0 as the button number. so technically a 17th could be 0, i’ll have to look into it.

Re-edit: ok, this 17th button is sorta working, but it still doesn’t solve my initial reconnect issue.

Maybe this could help you?

Sounds like your issue.

Naw, that’s not it, that looks like it’s caused by the / in the name. I renamed mine in the hid configuration file to LynxDroid which is why in one of the screenshots it says LynxDroid in retroarch. The problem is literally, sometimes it’ll work, sometimes it won’t, and when it doesn’t i need to reconnect it, which is literally, i pull the usb’s ground pin, and plug it back in. And it’s only with retroarch so far.

Are there any input drivers besides linuxraw, or android that would be better? Or would it be possible to disable the keyboard on the teensy from within android? For example, i could go through the device manager on windows and disable the hid keyboard, without it affecting the mouse/joystict function.

Have you tried a retroarch clean install to test your controller? maybe some of your settings are messing with your controller? you could try to backup all your config files and try a clean install with the default configs and see if that works. Also how are you launching retroarch?

tried that, and just clicking the retroarch icon that i moved to my droid’s homescreen. I’ve even tried reinstalling android…

As for removing Keyboard from the teensy’s HID code… that’s been proving a bit more difficult than i was expecting. So i’ve not had a lot of luck there. (I got it so it stopped registering the keyboard but it stopped registering the gamepad too, and couldn’t figure out why.

I will try… try… try try try again. Since i’m going with a touchscreen in my build. i’ll be able to get rid of the joystick to mouse support, so if i can remove mouse and keyboard, then it’ll maybe work. i hope.

Have you tried using your controller on retroarch in a different android device? To discard if it is a device specific issue.

sadly, my phone does not support OTG (i just checked to make sure), Though if any of you have a teensy 2.0 and an android device that supports it, i’ll gladly upload my code.

Well i tried removing keyboard from the Teensy’s hid code. There are so many little details that even if i get it to compile, it breaks it altogether. Maybe this can be changed on Retroarch’s end. Similar to how emulationstation has absolutely none of these issues. Emulationstation doesn’t have problems with button limits, or keyboard/mouse/joystick altogether on one teensy device, but it uses SDL2. So is there any way to enable SDL2 on android and in the android’s retroarch?