Suggestions (#3) - wminput should exit when wiimote powers off (#11) - Message List

wminput should exit when wiimote powers off
 unsolved

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.

  • Message #36

    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.

    • Message #45

      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.

  • Message #41

    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.

    • Message #44

      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.

  • Message #51

    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.

  • Message #67

    Check out r65, #12 - this should take care of it, let me know if you run into any problems.

    • Message #69

      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!

Attachments

No attachments created.