 |
|
 |
|
Next: PCRobots variant
|
| Author |
Message |
External

Since: Feb 02, 2005 Posts: 82
|
(Msg. 1) Posted: Mon Jul 31, 2006 2:56 pm
Post subject: ncurses, c: keypad-home & keypad-end don't work properly Archived from groups: rec>games>roguelike>development (more info?)
|
|
|
Hi,
I have the following c code that determins user input for movment:
switch (getch()) {
case KEY_UP:
<snip>
break;
case KEY_DOWN:
<snip>
break;
case KEY_LEFT:
<snip>
break;
case KEY_RIGHT:
<snip>
break;
case KEY_HOME:
<snip>
break;
case KEY_PPAGE:
<snip>
break;
case KEY_END:
<snip>
break;
case KEY_NPAGE:
<snip>
break;
}
Now almost all of these keys function as expected, except KEY_HOME and
KEY_END:
they are not triggered by the home/end keypad keys (only the other
home/end key above the arrow keys).
Any idea what's wrong?
Thanks in advance,
Ido. >> Stay informed about: ncurses, c: keypad-home & keypad-end don't work properly |
|
| Back to top |
|
 |  |
External

Since: Mar 23, 2005 Posts: 552
|
(Msg. 2) Posted: Mon Jul 31, 2006 11:22 pm
Post subject: Re: ncurses, c: keypad-home & keypad-end don't work properly [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
External

Since: Feb 02, 2005 Posts: 82
|
(Msg. 3) Posted: Mon Jul 31, 2006 11:28 pm
Post subject: Re: ncurses, c: keypad-home & keypad-end don't work properly [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
External

Since: Feb 02, 2005 Posts: 82
|
(Msg. 4) Posted: Mon Jul 31, 2006 11:50 pm
Post subject: Re: ncurses, c: keypad-home & keypad-end don't work properly [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Ido.Yehieli.TakeThisOut@gmail.com wrote:
> getch() gets a keypress (the loop get one step
> forward), but it isn't recognised as KEY_A1 or KEY_C1.
I had another idea, and it brought some strange results: i tried to
print the int value of the char being pressed- the home above the arrow
keys give 262 (as it should), the end above the arrow keys gives 360
(also as it should) but the home & end on the keypad _both_ give the
same value of 126!
Strange...How can i solve this problem?
Ido. >> Stay informed about: ncurses, c: keypad-home & keypad-end don't work properly |
|
| Back to top |
|
 |  |
External

Since: Feb 02, 2005 Posts: 82
|
(Msg. 5) Posted: Mon Jul 31, 2006 11:59 pm
Post subject: Re: ncurses, c: keypad-home & keypad-end don't work properly [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
External

Since: Feb 02, 2005 Posts: 82
|
(Msg. 6) Posted: Tue Aug 01, 2006 12:05 am
Post subject: Re: ncurses, c: keypad-home & keypad-end don't work properly [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Radomir 'The Sheep' Dopieralski wrote:
> Have you tried it with different terms?
> For example, linux console, xterm, vt100...
> It may be a question of bad terminal definition...
Bravo! The Sheep to the rescue once more...
I've tried it with xterm instead of the GnomeTerminal I normally use
and it works now.
Thanks a lot to both of you guys.
Ido. >> Stay informed about: ncurses, c: keypad-home & keypad-end don't work properly |
|
| Back to top |
|
 |  |
|
Radomir 'The Sheep' Dopie
|
External

Since: Jun 14, 2006 Posts: 217
|
(Msg. 7) Posted: Tue Aug 01, 2006 3:55 am
Post subject: Re: ncurses, c: keypad-home & keypad-end don't work properly [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
At 31 Jul 2006 23:50:57 -0700,
Ido.Yehieli RemoveThis @gmail.com wrote:
> Ido.Yehieli RemoveThis @gmail.com wrote:
>> getch() gets a keypress (the loop get one step
>> forward), but it isn't recognised as KEY_A1 or KEY_C1.
> I had another idea, and it brought some strange results: i tried to
> print the int value of the char being pressed- the home above the arrow
> keys give 262 (as it should), the end above the arrow keys gives 360
> (also as it should) but the home & end on the keypad _both_ give the
> same value of 126!
> Strange...How can i solve this problem?
Have you tried to enable the numpad mode in ncurses?
--
Radomir `The Sheep' Dopieralski
"Computer Science is no more about computers than
astronomy is about telescopes." [Edsger Wybe Dijkstra] >> Stay informed about: ncurses, c: keypad-home & keypad-end don't work properly |
|
| Back to top |
|
 |  |
|
Radomir 'The Sheep' Dopie
|
External

Since: Jun 14, 2006 Posts: 217
|
(Msg. 8) Posted: Tue Aug 01, 2006 3:55 am
Post subject: Re: ncurses, c: keypad-home & keypad-end don't work properly [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
At 31 Jul 2006 23:59:46 -0700,
Ido.Yehieli.DeleteThis@gmail.com wrote:
> Radomir 'The Sheep' Dopieralski wrote:
>> Have you tried to enable the numpad mode in ncurses?
> Do you mean keypad mode? I have seen no mention of 'numpad' in
> ncurses.h (keypad is on BTW)
Yes, sorry.
Have you tried it with different terms?
For example, linux console, xterm, vt100...
It may be a question of bad terminal definition...
--
Radomir `The Sheep' Dopieralski
"Computer Science is no more about computers than
astronomy is about telescopes." [Edsger Wybe Dijkstra] >> Stay informed about: ncurses, c: keypad-home & keypad-end don't work properly |
|
| Back to top |
|
 |  |
External

Since: Jul 20, 2006 Posts: 43
|
(Msg. 9) Posted: Tue Aug 01, 2006 9:44 am
Post subject: Re: ncurses, c: keypad-home & keypad-end don't work properly [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
look at
http://roguelike.cvs.sourceforge.net/roguelike/arogue5.8/mdport.c?revi...n=1.3&v
if you want to see how i added keypad support to the origianl versions
of rogue. it is fairly involved because ncurses, pdcurses and various
terminal emulators do things slightly differently (windows version of
pdcurses has best support). there is a function md_getchar(WINDOW *win)
that returns the next keystroke while converting all keypad entry into
standard rogue movement keys. It handles the standard curses defined
keystrokes or attempts to decode the raw keystrokes if the curses
implementation fails to process the key.
Ido.Yehieli RemoveThis @gmail.com wrote:
> Radomir 'The Sheep' Dopieralski wrote:
> > Have you tried it with different terms?
> > For example, linux console, xterm, vt100...
> > It may be a question of bad terminal definition...
>
> Bravo! The Sheep to the rescue once more...
> I've tried it with xterm instead of the GnomeTerminal I normally use
> and it works now.
>
> Thanks a lot to both of you guys.
>
> Ido. >> Stay informed about: ncurses, c: keypad-home & keypad-end don't work properly |
|
| Back to top |
|
 |  |
External

Since: Feb 02, 2005 Posts: 82
|
(Msg. 10) Posted: Wed Aug 02, 2006 3:48 am
Post subject: Re: ncurses, c: keypad-home & keypad-end don't work properly [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Yendor wrote:
> if you want to see how i added keypad support to the origianl versions
> of rogue. it is fairly involved because ncurses, pdcurses and various
> terminal emulators do things slightly differently.
Thanks for the tip, it is surley more portable then my solution, but
atm i want to frist get the basic game complete before I worry about
such things. After all- it can always be changed later, and the
keyboard input routine are kind of used as a black box for the rest of
the code so I'd wager it wouldn't be more difficult to add it later
then it is now.
Ido. >> Stay informed about: ncurses, c: keypad-home & keypad-end don't work properly |
|
| Back to top |
|
 |  |
External

Since: Jun 01, 2004 Posts: 260
|
(Msg. 11) Posted: Wed Aug 02, 2006 9:09 am
Post subject: Re: ncurses, c: keypad-home & keypad-end don't work properly [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Ido.Yehieli.RemoveThis@gmail.com wrote:
> Thanks for the tip, it is surley more portable then my solution, but
> atm i want to frist get the basic game complete before I worry about
> such things. After all- it can always be changed later, and the
> keyboard input routine are kind of used as a black box for the rest of
> the code so I'd wager it wouldn't be more difficult to add it later
> then it is now.
The tip we should all take to heart though is that if we want to
make a portable game we need to "wrap" the input routines. Something
needs to have a chance to postprocess what Curses gives you and make
odd bits of it into the codes your game uses (and while we're at it,
give the user the chance to remap inputs to different keys).
I dunno though; there is some joy in nonportable input if it lets
you distinguish between, say, keypad-9 and keyboard-9. Or check the
shift state when somebody hits an arrow key. Etc... messing with
raw IOCTLs and hardware scancodes directly gets you stuff you can't
do portably. But it also multiplies the number of ways things can
go wrong, and most roguelikes that use more than just curses-
compatible input routines also manifest some annoying bugs when
used with a different keyboard layout.
Bear >> Stay informed about: ncurses, c: keypad-home & keypad-end don't work properly |
|
| Back to top |
|
 |  |
External

Since: Feb 02, 2005 Posts: 82
|
(Msg. 12) Posted: Wed Aug 02, 2006 9:42 am
Post subject: Re: ncurses, c: keypad-home & keypad-end don't work properly [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Ray Dillinger wrote:
> The tip we should all take to heart though is that if we want to
> make a portable game we need to "wrap" the input routines. Something
> needs to have a chance to postprocess what Curses gives you and make
> odd bits of it into the codes your game uses (and while we're at it,
> give the user the chance to remap inputs to different keys).
Sure, in production code, after I've implemented all the basics, not in
a project i started 3 days ago...
When (if) I'll get all the basic functionality coded, I'll start
thinking about things like that.
Ido. >> Stay informed about: ncurses, c: keypad-home & keypad-end don't work properly |
|
| Back to top |
|
 |  |
External

Since: Jul 02, 2006 Posts: 56
|
(Msg. 13) Posted: Wed Aug 02, 2006 2:36 pm
Post subject: Re: ncurses, c: keypad-home & keypad-end don't work properly [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
I encountered similar problems with "special" keys. Under a linux
terminal the 'end' key behaved like an 'arrow left' key. And under
windows sometimes 'page up' and 'page down' let the console window
crash (disappear). By the way, I'm using my own wrapper. And I did not
yet find a way to fix this, so I decided to leave 'special' keys for
now and concentrate on numpad and letters only. >> Stay informed about: ncurses, c: keypad-home & keypad-end don't work properly |
|
| Back to top |
|
 |  |
| Related Topics: | ncurses in windows - My code won't compile under windows, quite obviously because I don't have ncurses installed. However, ncurses seems to be only for Linux. Is there some windows equivalent?
7DRL: Invader - Well, I've talked myself into attempting a game for the 7DRL challenge. :-) Invader will be a sci-fi RL where the player is the planet's only hope of stopping a dread alien invasion ship. The character's base of operations will be their docked ship. ....
7DRL: TBA! :P - I'm going to throw my hat into the 7drl arena by taking on a project I've wanted to do for ages. I think it will get me past the mental block of actually getting started. My concept is based around the remains of a post apocalyptic world with gang..
7DRL : Commander - It is 13.40 in my time zone (GMT +100). Time to start my 7DRL project: Commander. I will do it in Free Pascal. Plans are quite big so there is real danger of failure. Good luck to all participants of 7DRL contest. -- Michal ''Ancient'' Bielinski
7DRL : Valley of Ge-Hinnom - Info : @ goes chase to Moloch, java, using my library, so if I fail at least I can post an updated library. T. |
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
 |
|
|