Mouse detection / mouse lost after reconnecting


I’m posting this in advanced, because I think a system hack is needed. Sorry if it turns out I’m just a dumbass (-:

I’m creating a puzzle where a player finds a mouse, plugs it into a usb port and plays a game on our Raspberry Pi (with OF 0.7.4) to get a code. If the mouse is present when the app starts, it works fine. The problem I’m running into, is that OF doesn’t recognise the mouse when it’s removed and reconnected. I get the following through ssh:

[notice ] Got device
[notice ] node: %s
[notice ] subsystem: %s
[notice ] devtype: %s
[notice ] action: %s

so no device details…

I’ve read a post about this event notice and it was suggested to use a powered usb hub, so I installed one, but there’s no difference. It doesn’t matter if the mouse was present when the app started. Also, when I don’t run my app and just use the Raspbian desktop, the mouse will simply work once reconnected. So I’m guessing it must be an OF issue…

My questions are:
(- Am I missing something obvious?)

  • Is there a way to catch this got device event in my app? And then maybe setup the mouse manually in my code?
  • Is it possible to setup the mouse every few seconds, so it wouldn’t take too long to become responsive?
  • Will an upgrade to 0.8.4 solve things? I’m using 0.7.4, because at the time 0.8 just wouldn’t install on the Raspberry.



A few hours (and some swearing) later…

I’ve stumbled upon ofAppEGLWindow.cpp and there’s actually a comment going “TODO: a way to setup mouse and keyboard if they are not plugged in upon start”. So I kept it simple and just added a call to setupNativeMouse() above the “Got device” logging statement in readNativeUDevEvents(), and voila!

This is - admitted - a bit of a stinky solution, but since the mouse is the only thing that’s ever going to be connected to this Raspberry: why the h*ll not. TODO: check if the connected device actually is a mouse with the filter_mouse thingy that’s already in place and it should probably be decent (-:

So yeah, I’m a dumbass for not diving into the openFrameWorks source sooner (actually thought it was all binaries, pwa pwa pwaaaaaaaa)… Let that be the lesson then.