Solved PSP + GPIO Buttons Raspbian Kodi
#1
Hello everyone !

I encounter a problem regarding the buttons in Kodi. The buttons aren't working even tho' it's working on the "desktop" and retropie.

I put a Pi Zero W into a PSP. Connected the GPIO to the controls of the PSP. I then installed a Raspbian Image. I apt-get install kodi to get kodi. And also installed Retropie manually using this link.
I use retrogame.cfg file to make the buttons work. And copy the retrogame in /usr/local/bin/retrogame (both files has been given to me so I don't really know thing about them, sorry).

Code:
# Sample configuration file for retrogame.
# Really minimal syntax, typically two elements per line w/space delimiter:
# 1) a key name (from keyTable.h; shortened from /usr/include/linux/input.h).
# 2) a GPIO pin number; when grounded, will simulate corresponding keypress.
# Uses Broadcom pin numbers for GPIO.
# If first element is GND, the corresponding pin (or pins, multiple can be
# given) is a LOW-level output; an extra ground pin for connecting buttons.
# A '#' character indicates a comment to end-of-line.
# File can be edited "live," no need to restart retrogame!

# Here's a pin configuration for the PSPi v2 project:

UP         23  # Up
DOWN       27  # Down
LEFT       22  # Left
RIGHT      17  # Right
Q          19  # Square
ENTER      16  # X
Y          20  # Triangle
ESC        26  # Circle
LEFTCTRL   24  # Left Trigger
RIGHTCTRL  21  # Right Trigger
S          12  # Start
D           6  # Select
VOLUMEDOWN 25  # Volume Down
VOLUMEUP    5  # Volume Up


# For configurations with few buttons (e.g. Cupcade), a key can be followed
# by multiple pin numbers.  When those pins are all held for a few seconds,
# this will generate the corresponding keypress (e.g. ESC to exit ROM).
# Only ONE such combo is supported within the file though; later entries
# will override earlier.

I checked several post about the subject but I can't make it work :
Kodi forum post
Kodi forum post 2

When I start the PSP I end up on the shell. From there I just use the Up button to get the last lines. I can enter kodi like that. Once there the buttons aren't working. When I start emulationstation or StartX it's working fine. It looks like the buttons are well "simulated" on those like I would use the keyboard but not in Kodi

Can someone help me to figure out how to get that working in Kodi ?

Thanks all
Reply
#2
Did you installed the binary addon kodi-peripheral-joystick ? It is needed for joystick support, if you installed Kodi through the RetroPie option, it is already installed, if not you can install it with:
Code:
sudo apt-get install kodi-peripheral-joystick

Than you may need to configure the buttons to your likings like explained here:
http://kodi.wiki/view/HOW-TO:Configure_controllers


If after that your joystick still doesn't work, you have to create a config xml file for Kodi like you had to retrogame. It is explained here:
http://kodi.wiki/view/Keymap
Reply
#3
Hello and thanks for your answer.

I tried to configure the controller already. I didn't say it but before this I tried a Retropie Image and installed Kodi from there. Same problem, buttons works in Retropie not in Kodi. And when I try to make a new input in the controller the timer just go to 0 and I can't put any key, like the buttons are not recognize.

I checked the link with the Keymap already but as I'm running the stuff on a PSP which structure should I take ? Remote ? Gamepad ? Keyboard ?
Custom Joystick and I put retrogame like that ?

Code:
<joystick name="retrogame">
  <button id="27">Down</button>
</joystick>

A other thing. The joystick from the PSP is connected to the Gamepad so basically the input from the gamepad are the same for the joystick it's exactly the same wiring.

EDIT :

So I tried like that, I created a new file psp.xml that I put here : ~/.kodi/userdata/keymaps

I wrote this inside :

Code:
<keymap>
  <global>
    <joystick name="retrogame">
    <button id="27">Down</button>
    <button id="23">Up</button>
    </joystick>
  </global>
</keymap>

It is not working either.
Is there any manipulation to do to "activate" the .xml file maybe so that Kodi recognize it ? Should I use a different structure ?

Thanks
Reply
#4
Well the http://kodi.wiki/view/keymap is outdated, and doesn't follow the same structure from the new peripheral-joystick from Kodi 17.X.

I can't assist you much because since Kodi 17, I never needed to edit keymaps manually, all joysticks I tested works OOTB, but here is the addon code:
https://github.com/xbmc/peripheral.joystick

Take a look at the already defined xmls there and try to match the buttons with the key codes/ids of your PSP.
Also check the issues in the link above, garbear explains how to make a custom config.
Reply
#5
Hey there,

I checked all the files, I made one myself, didn't work out so far. I opened a issue topic as well with the same content from here.

There are to many configuration files and .xml everywhere... Peripheral.Joystick - ./kodi/userdata/keymaps . I don't even know which one is used when Kodi starts. My USB keyboard is where ?
I tried to change the existing keyboard.xml file with the GPIO button like this :

Code:
<keymap>
  <global>
    <keyboard>
.....
      <key id="26">Back</key>
.....
    </keyboard>
  </global>
</keymap>

Doesn't work either, it's like unchanged.

Any other things I could try ?
Reply
#6
If a joystick device is found at Kodi start, it will load the xml which contains the corresponding joystick device name tag in it. Custom keymaps created at ~/.kodi/userdata/keymaps/ have priority.

The key/button ids are not the GPIO numbers, but the keys that you get in kodi.log when you press them or by running:
Code:
jstest /dev/input/js0

And you can find your joystick device name in kodi.log or by running:
Code:
cat /proc/bus/input/devices
Reply
#7
When I check Kodi log I have this not far from the end :

Code:
Found input device /dev/input/event3
opened device 'retrogame' (file name /dev/input/event3), m_bSkipNonKeyEvents 0

Lower in the file I found this :

Code:
Keyboard: scancode : 0x67, sym: 0x0111, unicode: 0x0000, modifier: 0x0
OnKey: up (0xf080) pressed, action is Up

and some others OnKey, but those are my keyboard in USB when I quit Kodi...
I didn't find anything from the PSP buttons and retrogame in the logs regarding a key press action. Even tho it looks like it is loaded (retrogame).

The jstest /dev/input/js0 isn't working for me (even with joystick installed).

And the cat /proc/bus/input/devices shows 4 blocks. 3 of them are the Microsoft Keyboard (as I have a keyboard and a pad for the mouse integrated to the keyboard) and the last one is retrogame :

Code:
I: Bus=0003 Vendor=0001 Product=0001 Version=0001
N: Name="retrogame"
P: Phys=
S: Sysfs=/devices/virtual/input/input3
U: Uniq=
H: Hqndlers=kbd event3
B: PROP=0
B: EV=3
B: KEY=1682 0 1 b0210002
Reply
#8
Code:
jstest /dev/input/event3
Reply
#9
Code:
jstest is not fully compatible with your kernel. Unable to retrieve button map
Joystick unknown has 2 axes and 2 buttons
testing ... interrupt to exit
jstest error reading : invalid argument

:/
Reply
#10
Your best bet is to ask support from that retrogame software, which I think is from Adafruit.

Or use mkarcadejoystick (instalable from RetroPie) instead which seems to do something like retrogame and works with Kodi.

PS: GPioneer seems to be another option, but I never tried it:
https://github.com/mholgatem/gpioneer
Reply
#11
Thanks for the help man, I really appreciate it, I'm on it since 6 hours now, I will continue tomorrow if I find the strenght ^^
Thank you for the links
Reply
#12
Ok !
I tried bot of them and I could'nt get mkarcadejoystick to work, nevertheless GPioneer works perfectly and with the web intrerface it is really easy to set up !

Thanks again,

SOLVED !

Asso
Reply

Logout Mark Read Team Forum Stats Members Help
PSP + GPIO Buttons Raspbian Kodi1