A: 

Allow your users to define the keys to use for each action ...

or use the arrow keys .. that should be pretty universal :)

Gaby
I thought about mapping keys to actions, but it would be hard to intercept that shift key... for example, you want to use shift for slow as in Counter-Strike, and you press 1 to change weapon. What you need to do is to invert effect of shift so you get normal key. And this inverting will be hard in different layouts. (if you would walk and want to change weapon you would generate shift + 1 = ! and ! wouldn't be mapped to any action)
Raven
A: 

Turn the keyboard input into metadata, so you could allow users to configure at their will but also provide different keyboard shortcuts depending on the keyboard layout used in a config file .

pastjean
+1  A: 

The common approach seems to be to ignore the problem. Worse-is-better in its early stage.

Unfortunately I'm using svorak keyboard layout so it really doesn't just work for me.

I've been approaching this same problem by binding into multiple keys on the keyboard. So that player jumps from both x and j -keys. It doesn't do so well in something that isn't shoot-jump -kind of game.

Nice stuff would be if you could just find row/col or some driver-near interface to your keyboard.

Some auto-keyboard configuration software would be neat though I've not yet seen anything like that. Maybe we should write one?

Cheery
hmmm... that should go to assembly level if we want row column stuff.. however shouldn't be so hard if I find way to connect it later in c++ project. I was helping my friend with game in pascal where there was no other way then assembly, but I forgot on that one. Will try but I'm not sure if it will be cross-platform. Ok but so far best answer ;)
Raven
It's just not the PC keyboard problem. It's PC human-interface-device-universal problem and sloppy implementation of linux kernel HID isn't going to make it easier. This platform is just far much more challenging for the input than any game console with its monoculture ever can be.
Cheery
Is there way to get raw keyboard data? it's just about Windows is translating those data to specific characters defined by layout, but T-key should be still T-key even if Windows would input Č.
Raven
I'm not aware about windows stuff. Though I've seen SDL apps that ignore my keyboard layout entirely..
Cheery
could you wtill get to them? And thanks for pointing on SDL. I'm going to try it. I tried GLFW already but it seems to not work with GLUT.
Raven
+1  A: 

First up, separate keypresses from text entry. You shouldn't care what letter or number comes up when you press a key with shift as well - the operating system should handle that and generate an event you can use in the rare times you need the text. Usually, you should just look for the key press and any shift presses and act on those.

Second, load the bindings from keys to commands from a data file, rather than hardcoding it. Distribute default bindings for QWERTY and whatever default layout you have. If the data format is quite straightforward then people won't mind customising it to fit their keyboard and preferences. You can also add an in-game keybinding editor later.

This isn't really about OpenGL since by default that doesn't care about keypresses. Perhaps you are using an addon library or extension that handles keys for you - ensure that whatever you're using can give you individual key values and the state of shift/alt/ctrl independently, and that it also provides text input via an independent system.

Kylotan
Actually the title should be for GLUT. If you knwo GLUT you know, that what you get from keyboard function is Key and X,Y values of mouse in that time. And there's problem, the Key retourned by it is layout specific so same key produce š in slovak and 3 in english. So how can I look for key press, or better, for what keypress? One solution would be let user to give š as binding, but I'll still suffer from "You press a, SHIFT and release a you got: a down, A up". So a is still pressed. And these are 2 problems but solving one comes to other. Something like constant key ID would be needed..
Raven
+1  A: 

If you're getting a "character" every time user presses something, then your keyboard routines aren't suitable for game input - only for text entry.

You need to use input routines that completely ignore keyboard layout switching and operate on some kind of raw keycodes (so when user presses shift+a, you'll know that shift is pressed and that "a" key is pressed, but you won't get "A" character). Also, routines should allow you to query if a key is pressed or not.

For windows that is DirectInput or XInput. For cross-platform this is libsdl and SDL_GetKeyState. And you'll need to provide keymapping options for the user. Glut probably isn't suitable for your task.

SigTerm
Yes, you posted right at time I was reading about SDLK (or SDL Key, cross-platform equivalent of VK). Looks like SDL is way to go, and GLUT is good for handling window stuff (creation, resizing) and next things like NURBS, but isn't suitable for input. I got MS Reclusa keyboard so I doubt about my keyboard is quite wrong. What's wrong is the way GLUT receives keyboard input (e.g. it mixes shift+a to A immediatly, giving me no freedom). I take this as solved, even I don't have working example I looked around SDL and I think there will be way to make good cross-platform input with it. Thanks!
Raven