HTPC Controlled By Gamepad - Home/Launcher Button
- Inicie sesión ou rexístrese para enviar comentarios
I'm trying to create a game console-like environment with a PC and free software. On a side note, I wonder how many other people are interested in this sort of thing, especially considering the beautiful small HTPC models available at ThinkPenguin.
I've managed to get my computer paired with a bluetooth game controller at boot, and the controller works perfectly with games like rRootage, SuperTuxKart, and FreeDink; as well as XBMC, which is essential.
Everything is ready to go except one thing: I need a way to launch XBMC from the controller. I don't want it to start without the controller (I use my PC for regular stuff when I'm not gaming on it). I've decided I want to launch a process from .xsessionrc that watches for BTN_MODE to be sent from the controller indicating I've pressed the guide button, which will then launch XBMC or do whatever else I want. However I don't know how to do this. I think I need to watch /dev/input/event or uinput.
This guide does something similar, watching for events from LIRC http://forum.xbmc.org/showthread.php?tid=129256 . How can I look for events from the controller? xboxdrv says events are sent to event10 or js0.
Does xev see the keypresses from the controller?
If yes, those can be used with xbindkeys.
I don't know why I didn't think of that. I use xbindkeys for other things.
In any case, it doesn't work; seems to only get keyboard and mouse events, and the manpage doesn't seem to indicate I could connect it to other events.
That's exactly like what I would be looking for, though, so I'm now hunting around for something similar to xev/xbindkeys that can watch /dev/input/event* and uinput.
Here's something promising: >evtest /dev/input/event10< detects and outputs joystick button events.
Without something like xbindkeys or irxevent that can see and act on this input, however, it's not quite useful. But at least I can see that there is data watchable from the command line.
Packages I'd look at
amora-cli
evtest
inputlirc
rinputd
anyremote
bluez
bluez-tools
lembas: thanks. It seems like you think I should find an extra device to send commands to start the program?
Progress: I've been unable to find anything like xbindkeys or irxevent that can watch an arbitray device in /dev/input. I thought briefly of browsing and modifying the source code of either program, but instead I think I SHOULD be able to do something this simple with a shell script.
evtest offers something interesting: the --query option queries the current state of a certain button and returns 0 if it is not pressed, non-zero if it is. I can set up a watch command like this >watch evtest --query /dev/input/event10 EV_KEY BTN_MODE<, but I still need to figure out how to write a script that will run this command and then do something based on the return code from >evtest<.
EDIT: if I invoke >watch< with the --errexit option it will exit once >evtest< returns non-zero, meaning button was pressed. Perhaps then my shell script could invoke >watch< and then start XBMC once it quits. It's not the most elegant method, but it may work for starters.
Yeah, I was thinking that there should be something that wouldn't require polling.
Try putting this into /etc/X11/xorg.conf (you might have to create one, sudo X -configure)
Section "InputDevice"
Identifier "whatever"
Driver "evdev"
Option "Device" "/dev/input/event10"
Option "AutoServerLayout" "true"
EndSection
Restart X, now can xev see it? The buttons (like the guide button) might need remapping via evdev options or perhaps using xinput if they overlap with mouse or something.
lembas: I found /etc/X11/xorg.conf and inserted the section. Still no response from xev. I double-checked with evtest and the controller is still sending input.
Getting X to notice controller input would be great, because "polling" with watch/evtest seems terribly inefficient to me, and I could throw the XBMC start script into my xbindkeysrc file.
I know nothing about configuring Xorg. If I did maybe I could poke around and get this idea to work.
EDIT: I've started reading some xorg.conf tutorials to see if I can understand if/how it's possible to do this.
I'll have to revisit this project at a later time. For the time being I'm working on a more "universal access" temporary solution. Whenever I get a home/launcher button working and this thread is closed I'll post information about the solution at noxbanners.net
I found these pages on Xorg configuration and Joystick drivers for Xorg on ArchWiki. These tips should do the trick or at least get me somewhere.
have you tried playing with xserver-xorg-input-joystick it allows a joystick to be used like a mouse...
I did actually try the Xorg joystick driver, after reading about it on ArchWiki. It was working well, too.
But today it just about quit. I was using it to send keys to Xorg, but now it won't do that anymore. I can't think of anything that may have changed to cause this.
It's very frustrating.
EDIT: it was my dumb mistake. The joystick driver for Xorg maps buttons very reliably.
Just some other ideas:
http://community.linuxmint.com/tutorial/view/1110
You could use Xdotool:
http://packages.ubuntu.com/lucid/xdotool
or joy2key:
http://packages.ubuntu.com/lucid/joy2key
Or qjoypad:
http://packages.ubuntu.com/saucy/qjoypad
I remember that I had good success with joy2key, my Saitek USB gamepad and some free FPS back then which had no joystick support.
HTH,
Holger
Darksoul71: thanks. I'll check those out since there's more I want to do with joysticks.
However, I've had good success with the Xorg joystick input driver mentioned by ZykotiK9. It allows me to preserve all of the buttons and axes on the controller but still. have X input.
The mouse emulation provided by the driver is buggy, so I diabled that in the config (after installing xserver-xorg-input-joystick, read "man joystick" and edit /usr/share/X11/xorg.conf.d/50-joystick.conf). I first used "xmodmap -pk" to find an unused media key like XF86Game and added that to "MapButton9" in the config. This is detectable by xbindkeys, so I can have the Guide button start XBMC now.
The driver can send multiple keys per button, so I mapped Guide to ESC and F9(for Atari800) so I can exit
most games without the keyboard. I mapped Start to P to pause Kenta Cho games. Thanks to the driver and XBMC I have a pretty impressive Trisquel gamebox coming together.
- Inicie sesión ou rexístrese para enviar comentarios