| CODE |
if TRUE == XGetDeviceChanges( XDEVICE_TYPE_GAMEPAD, &insertions, &removals ); // returns true is the function call was a sucess
for int i=0;i<4;i++ { // check for removals first if( removals & (1< { // device type gamepad was removed from port # i XInputClose(...); } if ( insertions & (1< { // device type of gamepad was inserted in port # i XInputOpen(XDEVICE_TYPE_GAMEPAD, ...); } }
|
thats basically all there is to is.. Obviously things are a little different for kb and mouse but its mosltly the same. Ports are numbered 0 through 3 with 0 being the first of the left.
Something interesting here, most other gaming devices are detected as type gampad. You can check if a wheel/snowboard/lightgun or whatever is inserted by calling XInputGetCapabilities() passing the device handle returned by XInputOpen and a XINPUT_CAPABILITIES structure.
for example
| CODE |
if ( insertions....
handle = XInputOpen(XDEVICE_TYPE_GAMEPAD,...) XINPUT_CAPABILITIES caps; XInputGetCapabilities(handle, &caps); if( caps.SubType == XINPUT_DEVSUBTYPE_GC_GAMEPAD ) // its a standard config gamepad inserted if( caps.SubType == XINPUT_DEVSUBTYPE_GC_SNOWBOARD) // its a snowboard inserted
.. an so on
|
You will find those defines in xbox.h