I'm writing an ASCII side scroller in C and I'm having trouble with input handling.
I'm using select() see if there's a character in the buffer and then read it as a key press. This works fine if I'm only reading one key at a time.
But there are parts of the game where you need to do multiple things at once such as jump and move forward or jump and shoot. In these cases while player is holding one key he presses another. How do I read both in that case?
>>3
Don't use an OS, write something that boots, enters 32 bit mode, etc.
Name:
Anonymous2011-09-20 15:01
You shouldn't be using arson for such a task . Really u want a lower level access to The keyboard hardware state. On Linux I imagine sdl will provide such a facility, you may want to look at how it does this . You would then check states of relevant keys and perform actions based on this.
yes, you will want a non file based method of getting the input, like >>5-kun suggested. Under linux, you would also use keypresses from X windows. You could also use a cross platform gui library and only use it to get keypresses. If you want it to be able to work on linux without X, you'll have to either use a library that provides that for you, or do some low level stuff with the key board. I'm not sure how to do it without X, but it is obviously possible as X has to work somehow.
Name:
Anonymous2011-09-21 19:02
I don't know the names since I used it a long time ago but basically there are variables for vertical and horizontal positioning that you can ask by way of system calls, you need to be constantly sweeping this and extracting the press of one, press of another one, and remove of them by any order to make sure it only registers as one press and so on. You'll also have to make sure your machine takes the keyboard layout into consideration when returning a value, this level of abstraction usually doesn't, so you'll have to download some mappings or test it yourself on multiple keyboards
anyways, basically system calls that return if a certain decoder is lit on a certain way of the keyboard, and constantly checking this and abstracting to extract only valid presses, and another layer to decode the specific keyboard correctly
good luck it is actually simple and a useful challenge