Jump to content


How do the big companies switch controls?.


6 replies to this topic

#1 3DModelerMan

    Member

  • Members
  • PipPip
  • 80 posts

Posted 04 December 2008 - 07:04 PM

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: .
Lightspeed compilers are to slow...we need LUDICROUS SPEED!!!

#2 JarkkoL

    Senior Member

  • Members
  • PipPipPipPip
  • 474 posts

Posted 04 December 2008 - 07:33 PM

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.

#3 3DModelerMan

    Member

  • Members
  • PipPip
  • 80 posts

Posted 04 December 2008 - 11:31 PM

Oh, that's kinda what I had thought.
Thanks:lol: .
Lightspeed compilers are to slow...we need LUDICROUS SPEED!!!

#4 Nils Pipenbrinck

    Senior Member

  • Members
  • PipPipPipPip
  • 597 posts

Posted 05 December 2008 - 05:01 AM

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.
My music: http://myspace.com/planetarchh <-- my music

My stuff: torus.untergrund.net <-- some diy electronic stuff and more.

#5 poita

    Senior Member

  • Members
  • PipPipPipPip
  • 322 posts

Posted 06 December 2008 - 01:03 PM

Quote

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 :)

#6 3DModelerMan

    Member

  • Members
  • PipPip
  • 80 posts

Posted 06 December 2008 - 03:43 PM

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:
Lightspeed compilers are to slow...we need LUDICROUS SPEED!!!

#7 SmokingRope

    Valued Member

  • Members
  • PipPipPip
  • 210 posts

Posted 06 December 2008 - 04:22 PM

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users