procount / pinn

An enhanced Operating System installer for the Raspberry Pi
1.12k stars 123 forks source link

Add support for gamepad selection of OS #2

Closed colinchilds closed 4 years ago

colinchilds commented 8 years ago

For those of us who have Retropie installed, it would be awesome to be able to select the OS to boot into using the gamepad already plugged into the device, rather than having to plug in a keyboard or mouse.

procount commented 8 years ago

Thanks for the suggestion

Norde commented 6 years ago

This would be a very nice enhancement !

This requires additional kernel modules (like xpad for xbox controler). Does addition of such modules is conceivable for PINN?

procount commented 6 years ago

PINN does not use a modular kernel, so it's a bit problematic at the moment. But I hope to be able to do something about it at some point, just not immediately.

Norde commented 6 years ago

What, not immediately ??? 😡 :smile:

Effectively, without modular kernel, there's no easy implementation possible. Do you know some alternative/ tricky way ?

By the way, thank you for all your work on PINN!

andrebadaia commented 5 years ago

I am interested in this solution too! Maybe you can instruct us to recompile PINN for that support! Thanks!

procount commented 5 years ago

PINN now includes modular kernel support, so if you have some drivers for your gamepads (preferably in source format) I can take a look at what is needed to include them .

Please note that I cannot support Bluetooth controllers yet, but USB or gpio drivers should be ok.

andrebadaia commented 5 years ago

It's awesome!!! I have various types of joysticks, but the XBOX 360 is OK. It uses the xpad driver on linux, isn't?

procount commented 5 years ago

I don't have any gamepads to test his feature, so I'm going to have to rely on everyone else to provide feedback on this. I've added an xpad and joystick driver to PINN and uploaded a test version to https://sourceforge.net/projects/pinn/files/testing/joystick-33d.zip/download .

If you want to test it, please download joystick-33d.zip and install it to a blank FAT32 formatted SD-card just as you would pinn-lite.zip.

I haven't added any support into PINN to actually use the driver yet, so at this stage it's just a question of testing whether the gamepad can be detected and is usable.

Please boot PINN with your USB gamepad attached. Once booted, drop into the recovery shell by pressing the ctrl-alt-f2 combination and login with the username/password of root/raspberry. At the prompt type

jstest /dev/js0

Make a note of any text that is displayed. Press the buttons on your joystick and make a note of any messages that are created.

andrebadaia commented 5 years ago

It's worked! The PINN detects the joystick correctly, and all axes and buttons were detected by jstest on /dev/input/js0. The variations of axes go to -32768 to 32767, and buttons, switch between on and off. Thanks a lot for the effort!!

procount commented 5 years ago

@andrebadaia Could you please post some output from jstest so I can see what it produces? What do you expect the joystick buttons to do in PINN?

lurch commented 5 years ago

<tongue-in-cheek> Can you add a game of Tetris to PINN, so that we have something to do while waiting for the OSes to install? </tongue> :wink:

andrebadaia commented 5 years ago

It is just equal to Linux, the same buttons and axes in the same place. I'll map for you:

Axis 0: Left Analog X Axis 1: Left Analog Y Axis 2: LT Axis 3: Right Analog X Axis 4: Right Analog Y Axis 5: RT Axis 6: D-pad X Axis 7: D-pad Y Button 0: A Button 1: B Button 2: X Button 3: Y Button 4: LB Button 5: RB Button 6: Back Button 7: Start Button 8: Mode Button 9: Left Analog Click Button 10:Right Analog Click

image

About the use, I expect the behavior is the same when the package xserver-xorg-input-joystick of X, when the left analog controls the mouse pointer, A and B are the left and Right click. The other buttons have other functions, but the minimal usability is enough (just for select OSes).

procount commented 5 years ago

Can you add a game of Tetris to PINN

What? Tetris? What's wrong with Minesweeper? 😉

lurch commented 5 years ago

but the minimal usability is enough (just for select OSes).

Presumably the minimal usability for just selecting which OS to boot is UP, DOWN and SELECT ? Might be hard to implement xserver-xorg-input-joystick, given that PINN doesn't use X...

procount commented 5 years ago

I'll probably do something like duplicating the CEC remote functionality

andrebadaia commented 5 years ago

In fact, the joystick replaces the mouse on X, but you can improve the funcionality associating some important functions to the buttons and axes. It's not like a keyboard, but helps a lot!!! I use PINN with Raspbian, Retropie and OSMC, connected on my TV, and all controlled by joystick (I use a virtual keyboard on Raspbian, together with xserver-xorg-input-joystick), but I need the keyboard to choose the OS on PINN.

procount commented 5 years ago

I have made a first attempt in https://sourceforge.net/projects/pinn/files/testing/joystick-33e.zip/download It compiles, but I've done NO testing whatsoever, so it's probably very buggy at the moment. If you have time to try it out and feed back I would appreciate it. I just mapped left analog to the mouse cursor, A=left click, X =Cancel (Esc).

andrebadaia commented 5 years ago

Yes, it didn't work. The gamepad does nothing on GUI (it continues working on jstest).

procount commented 5 years ago

Sourceforge has been a bit slow and hasn't indicated anyone had downloaded the file, so I was lazy and pushed up several versions of the same file with various fixes in it. The early ones wouldn't have worked but I thought the last one would have worked. Can you check you have the latest one? I pushed it up at 15:16 (BST)

andrebadaia commented 5 years ago

I tried again (I've downloaded the last one version presented in sourceforge files) and it doesn't work too.

procount commented 5 years ago

OK thanks. I'll create a debug version to display some traces in /tmp/debug and we'll see if we can find out what is going on. Out of interest, does that file contain anything related to the joystick already?

andrebadaia commented 5 years ago

Sorry, I don't understand your question. What do you mean?

procount commented 5 years ago

Once booted, drop into the recovery shell by pressing the ctrl-alt-f2 combination and login with the username/password of root/raspberry. At the prompt type less /tmp/debug Browse using the cursor keys to see if there is any mention of the joystick. Press 'q' to quit.

You could also try tail -f /tmp/debug And then press the joystick buttons and see if there are any messages displayed.

procount commented 5 years ago

I pushed up joystick-33f.zip with more trace & debug messages.

andrebadaia commented 5 years ago

less /tmp/debug

It recognizes the joystick (Microsoft X-BOX 360 pad - 8 axes, 11 buttons), load CEC mappings from ":/cec_keys.json" and load joystick mappings from ":/joy_keys.json". No error reported.

Pressing the buttons and axes didn't make any difference.

andrebadaia commented 5 years ago

Where are the files cec_keys and joy_keys.json? I didn't find them on PINN or SETTINGS partitions...

procount commented 5 years ago

Is that still with v3.3e or the new v3.3.f?

andrebadaia commented 5 years ago

3.3e. I'll try the 3.3f.

procount commented 5 years ago

Where are the files cec_keys and joy_keys.json? I didn't find them on PINN or SETTINGS partition..

https://github.com/procount/pinn/blob/master/README_PINN.md#cec-control

andrebadaia commented 5 years ago

Do I have to create these files?

procount commented 5 years ago

No. Not for this testing - it will just complicate matters. I was just answering your question.

andrebadaia commented 5 years ago

The /temp/debug output is here (3.3f):

image

procount commented 5 years ago

It would be more nteresting to see the log after that, after you have pressed all the buttons on your joystick.

To capture the debug logs you can do the following: Press Ctrl-Alt-F2 to get to the recovery shell. Use the username:root password:raspberry.

cd \tmp
mount -o remount,rw /mnt
cp debug /mnt/debug.txt
sync

Now you can turn off the Pi, put your SD card in a PC and copy the debug.txt file to your PC.

andrebadaia commented 5 years ago

That's it.

debug.txt

procount commented 5 years ago

Thanks. Interesting. I assume you pressed joystick buttons during all of that debug capture, so as nothing is being detected I shall have to think again.

andrebadaia commented 5 years ago

I did the test again, to be sure... I pressed all gamepad buttons for almost 1 minute. debug.txt

procount commented 5 years ago

Try Joystick-33g.zip

andrebadaia commented 5 years ago

It's a beginning! The mouse pointer started to move in g revision!

Reports: The Y axis is inverted; The moviment is not fluid, seems like jumps... If you try to hold the axis, the pointer goes crazy! The A button is ok, I could navigate on all the PINN windows with it; The X button closes the window - if you press it on boot window, the PINN reboots.

Well, that's it! You are on the right track!

debug_g.txt

procount commented 5 years ago

Yay! That's mostly as expected. The mouse movement will never be smooth like a proper mouse, but I can improve it.

f you try to hold the axis, the pointer goes crazy!

I'm not sure what you mean by that?

andrebadaia commented 5 years ago

When you hold the axis (for the left, for example), the pointer goes to other position, down, or up! You have to "press and leave" the axis to get the right moviment.

procount commented 5 years ago

Can you try joystick-33h? I've added some more buttons etc. Try the left and right analog, plus D-pad. The right analog joystick should behave differently and have some acceleration which you can alter by modifying joy_keys.json where you can also see the mappings I added in joy_keys.json. This is similar to the cec_keys.json and documented in the previous link I sent you: https://github.com/procount/pinn/blob/master/README_PINN.md#cec-control You should be able to map any button onto any of the available keys. Please try it out and experiment with the key buttons to see which works best with the joystick.

procount commented 5 years ago

Do you have any more feedback on this? Does it work better now?

andrebadaia commented 5 years ago

I am sorry, I am back to work and I had no time to keep testing...

Norde commented 5 years ago

I'll be able to test this during october :)

Just out of curiosity, what prevents / makes complicated the support of gamepad via bluetooth?

procount commented 5 years ago

Mainly bluetooth itself. NOOBS & PINN are designed to be quite small and the bluetooth stack can be quite large. There are also complications with having to pair devices (and remember them). I intend to look at it at some point, as I have a bluetooth keyboard I would like to use with PINN myself, but I have more pressing issues to look at first.

Norde commented 5 years ago

Ah yes I understand, a lot of work for a non-essential function ^^

Anyway thank you for all the work done on Pinn!

procount commented 4 years ago

Joysticks and gamepads supported in v3.3.2

Norde commented 4 years ago

Sorry, I'm arriving a little (a lot) late for the tests.

I'm using an Xbox one controller (rev 1708) with a rpi3B +.

Something strange happen with pinn 3.3.2 (and testing version 33h) : My controller is detected (in /dev/input/js0). However the controller seems not "paired" (the home button of the controller light up when pairing is ok, if not controller is just charging).

Most of time light stay off (and not input is detected). In rare case controller pair well after random time (light is up and inputs works) and launching jstest (on /dev/input/js0) force this pairing and then controller works.

And there's nothing in the debug log about this (only "loading CEC and joystick mapping" when pairing is ok).

Some clue about this strange behavior ?

procount commented 4 years ago

What do you mean by "paired"? PINN dies not support Bluetooth, only USB, and there Is no pairing in USB.

Norde commented 4 years ago

I'm using USB of course. I say "paired" in oposition of "charging" (Xbox One controller has a battery), i misspoke.

The gamepad is recognized under /dev/input/js0 but only charging (input are not listened), except in rare random cases (that I can't reproduce) or when i'm listen with jstest wich seems force the "input listening state".