Suggestions (#3) - wminput should exit when wiimote powers off (#11) - Message List
I've actually manage to make a poor hack of this functionality, but I'm sure someone with more knowledge of Bluez, the Wiimote could do a better job, and C programing for GNU/Linux could do a better job.
If you want I can make a patch against the version I am using for this, but all I did was raise SIG_INT when reading from the Bluez socket returned 0 bytes (as opposed to -1).
By doing this, I was able to make a simple Ruby script that uses hcitool to scan for any visible wiimotes every so often. If it finds one, it runs wminput with this data. Upon turning the wiimote off, wminput quits and the loop repeats.
Good call. Somehow, during all the hours I've spent with the wiimote, I've never gotten around to using the power button to disconnect. Need to do a little more than SIG_INT, though - there's a lot of memory to free, files to close, etc.
The Ruby script sounds like a winner - you can create a wiki page for it by going to http://abstrakraft.org/cwiid/wiki/<PageName>, provided <PageName> doesn't already exist.dsmith03/27/07 12:47:21 (6 years ago)
It would also be nice if this script was called when the computer loses contact with the wiimote. This could include when there is a bluetooth error or the wiimote batteries die. I've had both happen to me and wminput starts eating up memory and freaking out.nickishappy04/02/07 08:57:49 (6 years ago)
Handily enough, as far as I can see, both of these things should appear to Bluez and thus wminput the same as powering down the wiimote appears. I think. I'd expect in both cases a read from the Bluez socket would return 0 bytes, the same as when the wiimote shuts down. If wminput were modified to close gracefully when contact with the wiimote were lost for whatever reason, then any script like the one I wrote would continue. In most cases this would involve attempting to restart wminput.Heavybell04/02/07 09:31:54 (6 years ago)
I have created a page here: http://abstrakraft.org/cwiid/wiki/wiimote_connect.rb
I must say I feel such a tiny script is unworthy of such a page, but maybe it'll be of some use later, should I put together my planned OSD daemon.Heavybell04/02/07 09:47:53 (6 years ago)
This is my current action item, I hope to finish it within the next couple of days. Essentially, libwiimote will deliver a wiimote_error_mesg on error (disconnect or read error), after which the bluetooth listener thread will exit, and it will be the lib user's (wminput's) responsibility to respond to this message by disconnecting, and possibly exiting. Just gotta make sure I've handled all possible states.
I think we might be due for an incremental release once this, and possibly #16 are closed.dsmith04/03/07 01:41:13 (6 years ago)
Message #67dsmith04/05/07 04:16:46 (6 years ago)
It works like a charm so far. I also tested it against my and Meavybell's script and all is good. Thanks for the hard work!nickishappy04/05/07 04:43:24 (6 years ago)