Rasbian +SDL + ps3 gamepad + headless

Hi I got a pi 1B that I'd like to attach some stepper motors to. I also like to control these motors via a ps3 gamepad attached to usb.

I use SDL, since it has gamepad/joystick support.

When I run my code on a laptop (debian) it works fine. However I get no joystick events on the pi.

At first, I did not get events on the laptop either, when I initialized only the joystick sub system. But also initializing the video sub system made it work.

Problem is that the pi is headless, so initializing the video sub system fails there.

Does anyone have any suggestions to get around this?

Mean while, I found my old ada fruit tft screen, which I'll try to get to work again.

Reply to
Björn Lundin
Loading thread data ...

ok, got that to work + autologin to console, and now the joystickevents works, in console mode

Still, it would be nice if I would not need a screen to get joystick events from SDL ...

--
--
Reply to
Björn Lundin

Can you use something like the 'od' shell utility to see what's coming from the USB connection? If its emitting a character stream od should do the trick.

--
martin@   | Martin Gregorie 
gregorie. | Essex, UK 
 Click to see the full signature
Reply to
Martin Gregorie

Good idea - I'll check tonight

Reply to
Björn Lundin

it does emit characters from /dev/input/js0. However, I do not see a usable pattern.

I see hexcodes flying by when pressing a button, but not the same hexcodes when I press the same again. It seems that the raw USB protocol is a bit too much for me to use.

I do NOT see hexcodes when releasing the button though. Which is a bit strange, the SDL lib sees both press and release of a button. Or perhaps THAT is strange, given no chars emitted on release. Not what I see anyway.

No I think I let that go, and use the SDL and tft-screen.It may actually come in handy in the project anyway.

(a joystick controllable stand for a telescope)

Reply to
Björn Lundin

Hmm, the tft-screen uses a lot of gpio ports. A lot. There are only 7 let and I need at least 8. And from a previous project I already got a soldered board, that does not easily switch ports :-(

So - new SD-card with rasbian fixed. The old one (with tft-support) kept bugging me even with no tft. Turns out that writing to the ports that some kernel driver thinks is the I2c channel for a display is something that makes the OS reboot ...

Funnily - with a new rabian - SDL does work wrt joystick events in headless mode. It does not fail initializing the screen anymore.

However, I do not really trust it, so i looked for another solution, and found

and some sample code at

which is my current solution

Reply to
Björn Lundin

jstest --event /dev/input/js0

might give you some parseable output

Reply to
Stefan Enzinger

Thanks, I saw it mentioned in the code for polling joystick events I referenced before.

I think I'll stick with the current solution though.

--
--
Reply to
Björn Lundin

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.