Search code examples
windowshiddirectinputgamepad

Exclusive directinput


I am trying to build an application that have exclusive access over a gamepad. Which mean when my application run, no other application will receive or react to the gamepad action like button press, wheel move,...

My approach to the present is using DirectInput, set flag: DISCL_EXCLUSIVE | DISCL_BACKGROUND.

However, I realize that it seems the DISCL_EXCLUSIVE has no effect? Whenever i set DISCL_EXCLUSIVE or DISCL_NONEXCLUSIVE it is the same.

And yesterday I found this: http://www.gamedev.net/topic/656250-directinput-exclusive-access-to-joypad/ According what he mention, this flag does nothing?

So is there any other solution for my problem? Thanks.


Solution

  • But DISCL_EXCLUSIVE | DISCL_BACKGROUND is not going to give you exclusive access to the device. A foreground application will always have precedence, exclusive or not. You shouldn't steal control from the user.

    So what is it good for? Multiple applications running in the background. That's pretty much the only use case, and also the only point that's reasonable from the user perspective. When an application requests exclusive access to a device that's already being used exclusively, one of them will fail (IIRC the older one) and will have to reacquire the device (which it of course shouldn't, because that will simply end in a war for control :)).

    For most cases, you should simply use DISCL_NONEXCLUSIVE | DISCL_FOREGROUND. Exclusive background access is only intended for things like controlling your media player or something like that :)