Unfortunately, I don't think Monkey supports detecting what's plugged in. If I remember right, this was because of an issue with the XNA target. You'll have to set it up manually by either checking for any button, or by checking for specific buttons. Either way, you'll have to log the state of each controller manually. And disconnection would effectively be the same.
But just because Monkey doesn't support it, that doesn't mean GLFW doesn't. So, assuming you're using one of the GLFW targets (Doesn't work with GLFW2; see below for a full example with GLFW2 support), you could do the following:
The 'JoyID' argument (Just 'joy' in GLFW) works like 'JoyX', it starts at controller zero. Though, Monkey (To my knowledge) doesn't currently support 16 controllers (Without some hacks), so 1-4 should be fine detection-wise. You might want to stick to those constants for the sake of compatibility. And in-fact, I should have made them globals, and just put them in the external area, but I wanted to show what they were.
And if you really wanted to (And I wasn't lazy), you could use my 'input' module, but that'd require code changes, not to mention myself putting in the work of setting it up on GitHub. If you were to do something like that, you'd get some added features relating to remapping.
|