Overclock.net banner
1 - 9 of 9 Posts

· Registered
Joined
·
3,279 Posts
Discussion Starter · #1 ·
Hey, I have written a simple test of curses (PDcurses) keyboard input, it works but when I hold 2 keys down at the same time I only get the most recent key press. How would I monitor or poll only one key at a time and check if they are being pressed? Hopefully this can be done with curses but I'm afraid I might have to pick a input library like OIS or DirectInput, I think GLUT can also do it.

This is for a console based game.
 

· Premium Member
Joined
·
14,563 Posts
Quote:
Originally Posted by Darkknight512;13001131
Hey, I have written a simple test of curses (PDcurses) keyboard input, it works but when I hold 2 keys down at the same time I only get the most recent key press. How would I monitor or poll only one key at a time and check if they are being pressed? Hopefully this can be done with curses but I'm afraid I might have to pick a input library like OIS or DirectInput, I think GLUT can also do it.

This is for a console based game.
You need raw access to the keyboard, and curses will not provide this.
 

· Registered
Joined
·
3,279 Posts
Discussion Starter · #3 ·
Quote:
Originally Posted by error10;13001670
You need raw access to the keyboard, and curses will not provide this.
Do you know of a library that would allow it? I'm looking for a library that will let me check from my program, if the key is being held down or not.
 

· Premium Member
Joined
·
14,563 Posts
Quote:
Originally Posted by Darkknight512;13002201
Do you know of a library that would allow it? I'm looking for a library that will let me check from my program, if the key is being held down or not.
GLUT would be just fine for this. Of course you would have to be running in a windowing system, and there goes the whole curses thing out the window (no pun intended). Time to redesign your app.
 

· Registered
Joined
·
3,279 Posts
Discussion Starter · #5 ·
Alright thanks, I'm currently just testing out these libraries by making a basic pong game. What I intend to do after this is to write a console based text RPG engine that will somehow be very easily modifiable, so far I have done some research in XML to do that.

I know it is possible to read when a button is down or up with the windows libraries but I am trying to avoid tying myself to an OS is possible. This is pretty much my first large project and will probably never need to be ported but I guess it is better to make sure it is portable if it needs to be.

Are there any other tings you could think of that would work well for me?
 

· Premium Member
Joined
·
14,563 Posts
Quote:
Originally Posted by ShamrockMan;13010163
You could try using SDL (Simple DirectMedia Layer, cross platform library for making games). Its worked well enough for me in the past.
Seconded. SDL wraps up everything for you.

As for it being a console game, if you really need raw keyboard access, you can't run it on a console; it simply does not provide any way to gain raw keyboard access. You will have to make it a fully graphical application.
 

· Registered
Joined
·
2,815 Posts
Quote:
Originally Posted by Darkknight512;13001131
Hey, I have written a simple test of curses (PDcurses) keyboard input, it works but when I hold 2 keys down at the same time I only get the most recent key press. How would I monitor or poll only one key at a time and check if they are being pressed? Hopefully this can be done with curses but I'm afraid I might have to pick a input library like OIS or DirectInput, I think GLUT can also do it.

This is for a console based game.
You mean something like GetKeyState?
 

· Registered
Joined
·
3,279 Posts
Discussion Starter · #9 ·
Quote:
Originally Posted by Kirmie;13013804
You mean something like GetKeyState?
That's pretty much what I am looking for but that is in Windows.h and I don't want to tie myself to and operating system, I'm here to look for an alternative to GetKeyState.
 
1 - 9 of 9 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top