views:

50

answers:

2

I am writing an input system for a game that needs to be able to handle keyboard schemes that are not just qwerty. In designing the system, I must take into consideration:

  • Two types of input: standard shooter controls (lots of buttons being pressed and raw samples collected) and flight sim controls (the button's label is what the user presses to toggle something)
  • Alternative software keyboard layouts (dvorak, azerty, etc) as supplied by the OS
  • Alternative hardware keyboard layouts that supply Unicode characters

My initial inclination is to sample the USB HID unicode scancodes. Interested on thoughts on what I need to do to be compatible with the world's input devices and recommendation of input APIs on both platforms.

+2  A: 

Simple solution is to allow customization of input. In the control customization, record what key the OS tells you has been pressed. In game, when you get a key press, check it against your list of bound keys and do the appropriate action.

Anon.
Right, so if I get the char on the keyboard in ASCII, what happens when I plug in a keyboard from a region that has an umlaut on it?
sludge
Then the user will need to reconfigure their controls for the new keyboard. What else do you want, the ability to magically guess which key the user wants to use?
Anon.
+1 - user-defined mappings are the only sensible way. I don't know if it's even possible to detect whether the user has plugged in a different keyboard type or not.But regarding the ASCII comment - you don't read ASCII, simple as that. Both MacOS and Windows give you key events with unique key identifiers, so you'd map those to in-game actions.
Kylotan
A: 

It looks You need a cross platform library for games. You can look at SDL:
http://www.libsdl.org/

It is quite popular in game development.
http://en.wikipedia.org/wiki/List_of_games_using_SDL

The library is quite modular. You can only use part that control input.

Michas
Quite modular but quite a selfish asshole too. It doesn't work if you don't use its main mangling, and hence it's incompatible with any other library that wants to do that too (such as allegro).
Lo'oris