![]() |
| | #1 |
| Registered User Join Date: Jul 2006
Posts: 158
| Function keys and strange results I'm writing a small game for fun and I'm having a problem with the function keys, specifically F1-F4. Code: #include <curses.h>
void input()
{
int choice;
choice = getch();
printw("%c\n", choice);
refresh();
}
Code: if(choice == KEY_F(1)) // or F2,F3,F3
{
...
}
I'm on linux, if that's of any help. Last edited by divineleft; 11-10-2006 at 08:26 PM. |
| divineleft is offline | |
| | #2 |
| and the hat of Jobseeking Join Date: Aug 2001 Location: The edge of the known universe
Posts: 21,680
| Can you post a short and complete ncurses program which prints your function keys? Your F1 to F4 keys are generating ANSI Escape sequences, which is something they can be programmed to do in various kinds of terminal emulation modes. How you change that depends on what you're using. |
| Salem is offline | |
| | #3 |
| Registered User Join Date: Jul 2006
Posts: 158
| Sure. Code: #include <curses.h>
#include <iostream>
void menu();
int main()
{
initscr();
keypad(stdscr, TRUE);
noecho();
scrollok(stdscr, TRUE);
menu();
endwin();
return 0;
}
void menu()
{
int choice;
while (choice = getch())
{
printw("%c\n", choice);
refresh();
}
}
|
| divineleft is offline | |
| | #4 |
| . Join Date: Nov 2003
Posts: 293
| ncurses returns an integer - some keys like F1 send 265, if I remember, by default in ncurses. Which is beyond the limits for unsigned char. getch() returns an integer. |
| jim mcnamara is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| ToUnicodeEx and dead keys inside system wide hooks | RevengerPT | Windows Programming | 1 | 08-13-2009 02:51 PM |
| Strange Keyboard | MadCow257 | Tech Board | 5 | 05-12-2005 10:54 PM |
| Strange Direct Input Behaviour | Diamonds | Windows Programming | 2 | 06-23-2003 04:34 PM |