I have a mini linux PC (headless), and I’d like to use it as a gateway for a bluetooth remote to IP.
I have no problem with the IP side of things, I’m just a little bit in the fog for the bluetooth side of things.
How can I get the bluetooth events from my code? Is it device based (would mean I just open() the right device) or is there some API?
Basically, what I want is to poll for keypress on the remote and that’s it.
In pseudo code, this would be something like:
handle = open_bluetooth();
for event in poll(handle):
do_something_with(event.key)
I’m a bit unsure because most of the documentation I find is to make the remote acts like a regular keyboard, but as I’d like to be headless (no Xserver, no TTY console, only SSH for admin) this is not what I want.
As for the language, my control software is in ruby, but I have no problem making a C extension if needed.
I figured how to do it.
It’s quite simple actually, just call POSIX
openon the character device, then readstruct input_event(more than one at a time, because a keypress generates more than one event, you get the syn, the key and sometimes the misc event).For info on the struct, look into header
linux/input.h.