The input system (that is, the class that handles dinput and xinput) handles the API calls and provides events through some event handler interface which is currently implemented by the "game" class (that is, the class I instanciate from main() that keeps all the stuff). Quote:Where do you handle the connect/disconnect event? In the input system or in game/player? Do you allow him to move with both? Or if XInput controller is connected you ignore the input from the DInput one?įor example, if the game supports up to 3 players, how do you handle it? If someone has both an XInput and a DInput controler connected (in slots #1 and #5). Do you always suppose player 1 uses controller #1 or can he use controller #2 if somehow the XInput device with the xinput id=1 is not connected, but the one with the id=2 is?ģ. How do you associate a player with a controller, and what happens if the controller is disconnected or reconnected? When and how is this association set?Ģ. Now, the question is how do you handle them in the game?ġ. The rest (#4, #5.) being instances of cDIGamepad class, but only if such controllers were detected at initialization.Īnd during gameplay, you test the #1-#4 controllers for connect/disconnect events. If I understand it right, you have a list of controllers with the first four (#1.#4) being instances of a cXIGamepad class, even if the controllers are not connected at initialization. For a while I wanted to check for new devices at runtime instead of just initialization for DInput devices too but I'm lazy :).Īnyway if you need some help for a particular part of the implementation, I can provide more details. It's just XInput devices get few additional events, mostly when the headset is connected/disconnected. So when something changes I simply send an event to the "main" class (or the one that handles input or whatever). However since I keep the previous data in my little class, I can check if something changed (such as if it's now enabled while it was disabled before). While running, upon "update" (I just call an update() once per frame), I normally check the DInput devices and same for XInput devices. Basically gamepads #1 to #4 will be XInput gamepads, anything above will be DInput gamepads.Ĭreate the devices for non-XInput devices (the WMI stuff from the DirectX SDK). Then I have some vector with both XInput and DInput pads (instances from each), however it's initialized with a size of XUSER_MAX_COUNT and instances of the xinput gamepads (with enabled = false). The XInput one doesn't have much info other than the GUIDs for the headset, battery state/level and knowing whether the pad is enabled or not. I just have some gamepad base class (with the buttons/sticks/triggers states) and some inherited version for XInput and DInput. Or at least, let me know how you support XInput and DirectInput in your games? So, can anyone give me some advice or point me to some tech docs about this? Since one keeps such a device connected I suppose he wants to use it - if not he should remove it before starting the game.Īfter that, if the game should support more players than the number of old gamepads found, I instance some cXIGamePad classes, that tests for the 360 device, allowing the player to plug them in later, or remove them as they like. One idea is to test first for non-360 controllers with DI and instance cDIGamePad classes for these. I'm also considering the fact that the 360 controller can be wireless and I think it's common to start the game before you activate your controller. I want to deal with the fact that the 360 controllers can be tested during the game (plugged in later), while the old devices can't and should be tested at input initialization. I know the basic idea from the MS XInput docs, but I'd like to know the best way to organize the input, from a "Techical Requiremets" point of view. I need some advice on how to support both XInput (360 controller) and DirectInput.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |