How do the big companies switch controls?.

29423feee2c8904e56009913425351b3
0
3DModelerMan 101 Dec 04, 2008 at 19:04

How do big companiesthat do PC games (e.g Microsoft, Ubisoft) go around switching out control schemes?. Do they have a single receiver class that maps all the functions to buttons on like, a single stick joystick, and the same for dual stick and keyboard?. With everything controlled by a state machine?. I’m just curious about this cause I had a couple ideas for my game that I wanted to check if they were anything similar to the big guys.
Thanks:lol: .

6 Replies

Please log in or register to post a reply.

Fe8a5d0ee91f9db7f5b82b8fd4a4e1e6
0
JarkkoL 102 Dec 04, 2008 at 19:33

You can have a config file which specifies binding from device input to a command. In the application you then define what specific command does. E.g. the config file could look something like:
key_space jump
and then in the application you bind what the command “jump” does by binding the command e.g. to some function.

29423feee2c8904e56009913425351b3
0
3DModelerMan 101 Dec 04, 2008 at 23:31

Oh, that’s kinda what I had thought.
Thanks:lol: .

B91eae75cd6245bd8074bd0c3f1cc495
0
Nils_Pipenbrinck 101 Dec 05, 2008 at 05:01

I’m not micro or ubisoft, but I did the following:

Per default all actions have been mapped to keyboard + mouse because I assumed that these are always present.

Once a controller appeared on DirectInput I did the following:

  • if it was an unkown controller I popped up a config-dialog and let the user assing/test the config. The button/axis to event-mapping was saved (along with a hash of device-name, driver-hash and user-name) to an internal config.

  • if it was a known controller (e.g. the user has alredy configured it) I used the mapping of it to override the default key/mouse inputs.

That worked pretty well and allowed the user to use different input devices for their game. Even multiple input-devices at once.

Something I still remember was how hard it was to write stable and failsafe DirectInput code. If you are going to write such code I suggest to buy a hand full of different controllers. The cheaper they are, the more fun it is to get them working.

A little horror-story: a PS2-Pad to USB converter thing from asia returned strings in unicode-format every once in a while. All strings were defined as char*, so my buffers have *sometimes* been to small. I never found out under which circumstances the driver did this, but the problem never occured as long as visual studio was running :-(

Same controller also disconnected and connected itself every couple of minutes (and switched between unicode and ascii device name reporting). Finding the occasional crash in my code was a *lot* of fun. I learned quite a bit about remote-debugging that way.

36b416ed76cbaff49c8f6b7511458883
0
poita 101 Dec 06, 2008 at 13:03

A little horror-story: a PS2-Pad to USB converter thing from asia returned strings in unicode-format every once in a while. All strings were defined as char*, so my buffers have *sometimes* been to small. I never found out under which circumstances the driver did this, but the problem never occured as long as visual studio was running :-( Same controller also disconnected and connected itself every couple of minutes (and switched between unicode and ascii device name reporting). Finding the occasional crash in my code was a *lot* of fun. I learned quite a bit about remote-debugging that way.

Haha. Sounds like fun :)

29423feee2c8904e56009913425351b3
0
3DModelerMan 101 Dec 06, 2008 at 15:43

I remember the satisfaction I got after I figured out why my events were’nt working. It was the first time I had done any joystick or gamepad programming, I was getting frustrated with doing it. Then I fixed it and was so satisfied when I got my program to return 0; when I pressed the 1 button.:lol:

860fe478a2545d6c07b88c759292499e
0
SmokingRope 101 Dec 06, 2008 at 16:22

The way i do it is create a keymap object that knows how to look-up the state of any key on any supported input device. For each game action I need, I instantiate a keymap, tell it the keys to use, and when the state of the keymap is correct perform the relevant action. This let’s you use multiple input devices for the same action and you can extend the keymap object for multi-key-combinations or other special input types.

I’ve also tried a pure-event-based system in the past and it is inconvenient if you need multi-key combinations. Furthermore, the number of event types tends to grow rather larger as your game matures. Consider for example how the event for a jump action is a “keypress” while movement keys are related to a “key down” and “key up” event. With an event based system you’re stuck associating your event handlers with the type of event and forwarding things based on these associations. It turns into a lot of extra work.