I've owned a Logitech Wingman Gamepad Extreme since pretty much forever, and although it's been battered over the years, it's still mostly functional. As a gamepad, it has 10 buttons. What's special about it, though, is that the device also has a mode in which a gravity sensor kicks in and produces two extra axes, allowing me to pretend I'm really talking to a joystick. It looks a bit weird though, since you end up playing your games by wobbling the gamepad around a bit.
About 10 years ago, I first learned how to write GObjects by writing a
GObject-based joystick API. Unfortunately, I lost the code at some point
due to an overzealous rm -rf
call. I had planned to rewrite it, but
that never really happened.
About a year back, I needed to write a user interface for a customer
where a joystick would be a major part of the interaction. The code
there was written in Qt, so I write an event-based joystick API in Qt.
As it happened, I also noticed that jstest
would output names for the
actual buttons and axes; I had never noticed this, because due to my 10
buttons and 4 axes, which by default produce a lot of output, the
jstest
program would just scroll the names off my screen whenever I
plugged it in. But the names are there, and it's not too difficult.
Refreshing my memory on the joystick API made me remember how much fun
it is, and I wrote the beginnings of what I (at the time) called
"libgjs", for "Gobject JoyStick". I didn't really finish it though,
until today. I did notice in the mean time that someone else released
GObject bindings for javascript and also called that gjs, so in the
interest of avoiding confusion I decided to rename my library to
libjoy
. Not only will this allow me all kinds of interesting puns like
"today I am releasing more joy", it also makes for a more compact API
(compare joy_stick_open()
against gjs_joystick_open()
).
The library also comes with a libjoy-gtk
that creates a
GtkListStore*
which is automatically updated as joysticks are added
and removed to the system; and a joytest
program, a graphical joystick
test program which also serves as an example of how to use the API.
still TODO:
- Clean up the API a bit. There's a bit too much use of
GError
in there. - Improve the UI. I suck at interface design. Patches are welcome.
- Differentiate between
JS_EVENT_INIT
kernel-level events, and normal events. - Improve the documentation to the extent that gtk-doc (and, thus, GObject-Introspection) will work.
What's there is functional, though.
Update: if you're going to talk about code, it's usually a good idea to link to said code. Thanks, Emanuele, for pointing that out