}
}
-void HandleGadgetsKeyInput(KeySym key)
+void HandleGadgetsKeyInput(Key key)
{
struct GadgetInfo *gi = last_gi;
char text[MAX_GADGET_TEXTSIZE];
text_length = strlen(gi->text.value);
cursor_pos = gi->text.cursor_position;
- letter = getCharFromKeySym(key);
+ letter = getCharFromKey(key);
legal_letter = (gi->type == GD_TYPE_TEXTINPUT_NUMERIC ?
letter >= '0' && letter <= '9' :
letter != 0);
gi->text.cursor_position++;
DrawGadget(gi, DG_PRESSED, DG_DIRECT);
}
- else if (key == XK_Left && cursor_pos > 0)
+ else if (key == KEY_Left && cursor_pos > 0)
{
gi->text.cursor_position--;
DrawGadget(gi, DG_PRESSED, DG_DIRECT);
}
- else if (key == XK_Right && cursor_pos < text_length)
+ else if (key == KEY_Right && cursor_pos < text_length)
{
gi->text.cursor_position++;
DrawGadget(gi, DG_PRESSED, DG_DIRECT);
}
- else if (key == XK_BackSpace && cursor_pos > 0)
+ else if (key == KEY_BackSpace && cursor_pos > 0)
{
strcpy(text, gi->text.value);
strcpy(&gi->text.value[cursor_pos - 1], &text[cursor_pos]);
gi->text.cursor_position--;
DrawGadget(gi, DG_PRESSED, DG_DIRECT);
}
- else if (key == XK_Delete && cursor_pos < text_length)
+ else if (key == KEY_Delete && cursor_pos < text_length)
{
strcpy(text, gi->text.value);
strcpy(&gi->text.value[cursor_pos], &text[cursor_pos + 1]);
DrawGadget(gi, DG_PRESSED, DG_DIRECT);
}
- else if (key == XK_Return)
+ else if (key == KEY_Return)
{
CheckRangeOfNumericInputGadget(gi);
DrawGadget(gi, DG_UNPRESSED, DG_DIRECT);
void ClickOnGadget(struct GadgetInfo *, int);
void HandleGadgets(int, int, int);
-void HandleGadgetsKeyInput(KeySym);
+void HandleGadgetsKeyInput(Key);
#endif
}
}
-void HandleLevelEditorKeyInput(KeySym key)
+void HandleLevelEditorKeyInput(Key key)
{
- char letter = getCharFromKeySym(key);
+ char letter = getCharFromKey(key);
int button = MB_LEFT;
if (drawing_function == GADGET_ID_TEXT &&
{
if (letter)
DrawLevelText(0, 0, letter, TEXT_WRITECHAR);
- else if (key == XK_Delete || key == XK_BackSpace)
+ else if (key == KEY_Delete || key == KEY_BackSpace)
DrawLevelText(0, 0, 0, TEXT_BACKSPACE);
- else if (key == XK_Return)
+ else if (key == KEY_Return)
DrawLevelText(0, 0, 0, TEXT_NEWLINE);
}
else if (button_status == MB_RELEASED)
switch (key)
{
- case XK_Left:
+ case KEY_Left:
id = GADGET_ID_SCROLL_LEFT;
break;
- case XK_Right:
+ case KEY_Right:
id = GADGET_ID_SCROLL_RIGHT;
break;
- case XK_Up:
+ case KEY_Up:
id = GADGET_ID_SCROLL_UP;
break;
- case XK_Down:
+ case KEY_Down:
id = GADGET_ID_SCROLL_DOWN;
break;
- case XK_Page_Up:
+ case KEY_Page_Up:
id = GADGET_ID_SCROLL_LIST_UP;
button = 3;
break;
- case XK_Page_Down:
+ case KEY_Page_Down:
id = GADGET_ID_SCROLL_LIST_DOWN;
button = 3;
break;
ClickOnGadget(level_editor_gadget[id], button);
else if (letter == '.')
ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button);
- else if (key == XK_space || key == XK_Return)
+ else if (key == KEY_space || key == KEY_Return)
ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button);
else
for (i=0; i<ED_NUM_CTRL_BUTTONS; i++)
void CreateLevelEditorGadgets();
void UnmapLevelEditorGadgets();
void DrawLevelEd(void);
-void HandleLevelEditorKeyInput(KeySym);
+void HandleLevelEditorKeyInput(Key);
void HandleEditorGadgetInfoText(void *ptr);
#endif
void HandleKeyEvent(KeyEvent *event)
{
int key_status = (event->type==EVENT_KEYPRESS ? KEY_PRESSED : KEY_RELEASED);
- KeySym key;
-
- if (game_status == PLAYING)
- {
- /* use '0' instead of 'event->state' to get the key without modifiers */
- key = XLookupKeysym(event, 0);
- }
- else
- {
- /* get the key with all modifiers */
- char buffer[10];
- int buffer_size = 10;
- XComposeStatus compose;
- int char_count;
-
- char_count = XLookupString(event, buffer, buffer_size, &key, &compose);
- buffer[char_count] = '\0';
- }
+ boolean with_modifiers = (game_status == PLAYING ? FALSE : TRUE);
+ Key key = GetEventKey(event, with_modifiers);
HandleKey(key, key_status);
}
break;
case TYPENAME:
- HandleTypeName(0, XK_Return);
+ HandleTypeName(0, KEY_Return);
break;
case CHOOSELEVEL:
}
}
-void HandleKey(KeySym key, int key_status)
+void HandleKey(Key key, int key_status)
{
int joy = 0;
static struct SetupKeyboardInfo custom_key;
static struct
{
- KeySym *keysym_custom;
- KeySym keysym_default;
+ Key *key_custom;
+ Key key_default;
byte action;
} key_info[] =
{
custom_key = setup.input[pnr].key;
for (i=0; i<6; i++)
- if (key == *key_info[i].keysym_custom)
+ if (key == *key_info[i].key_custom)
key_action |= key_info[i].action;
if (key_status == KEY_PRESSED)
int i;
for (i=0; i<6; i++)
- if (key == key_info[i].keysym_default)
+ if (key == key_info[i].key_default)
joy |= key_info[i].action;
}
if (key_status == KEY_RELEASED)
return;
- if ((key == XK_Return || key == XK_space) &&
+ if ((key == KEY_Return || key == KEY_space) &&
game_status == PLAYING && AllPlayersGone)
{
CloseDoor(DOOR_CLOSE_1);
}
/* allow quick escape to the main menu with the Escape key */
- if (key == XK_Escape && game_status != MAINMENU)
+ if (key == KEY_Escape && game_status != MAINMENU)
{
CloseDoor(DOOR_CLOSE_1 | DOOR_OPEN_2 | DOOR_NO_DELAY);
game_status = MAINMENU;
case SETUPINPUT:
switch(key)
{
- case XK_Return:
- case XK_space:
+ case KEY_Return:
+ case KEY_space:
if (game_status == MAINMENU)
HandleMainMenu(0,0, 0,0, MB_MENU_CHOICE);
else if (game_status == CHOOSELEVEL)
HandleSetupInputScreen(0,0, 0,0, MB_MENU_CHOICE);
break;
- case XK_Page_Up:
+ case KEY_Page_Up:
if (game_status == CHOOSELEVEL)
HandleChooseLevel(0,0, 0,-SCR_FIELDY, MB_MENU_MARK);
break;
- case XK_Page_Down:
+ case KEY_Page_Down:
if (game_status == CHOOSELEVEL)
HandleChooseLevel(0,0, 0,SCR_FIELDY, MB_MENU_MARK);
break;
case HALLOFFAME:
switch(key)
{
- case XK_Return:
- case XK_space:
+ case KEY_Return:
+ case KEY_space:
game_status = MAINMENU;
DrawMainMenu();
BackToFront();
break;
- case XK_Page_Up:
+ case KEY_Page_Up:
HandleHallOfFame(0,0, 0,-SCR_FIELDY, MB_MENU_MARK);
break;
- case XK_Page_Down:
+ case KEY_Page_Down:
HandleHallOfFame(0,0, 0,SCR_FIELDY, MB_MENU_MARK);
break;
{
#ifdef DEBUG
- case XK_0:
- case XK_1:
- case XK_2:
- case XK_3:
- case XK_4:
- case XK_5:
- case XK_6:
- case XK_7:
- case XK_8:
- case XK_9:
- if (key == XK_0)
+ case KEY_0:
+ case KEY_1:
+ case KEY_2:
+ case KEY_3:
+ case KEY_4:
+ case KEY_5:
+ case KEY_6:
+ case KEY_7:
+ case KEY_8:
+ case KEY_9:
+ if (key == KEY_0)
{
if (GameFrameDelay == 500)
GameFrameDelay = GAME_FRAME_DELAY;
GameFrameDelay = 500;
}
else
- GameFrameDelay = (key - XK_0) * 10;
+ GameFrameDelay = (key - KEY_0) * 10;
printf("Game speed == %d%% (%d ms delay between two frames)\n",
GAME_FRAME_DELAY * 100 / GameFrameDelay, GameFrameDelay);
break;
#if 0
- case XK_a:
+ case KEY_a:
if (ScrollStepSize == TILEX/8)
ScrollStepSize = TILEX/4;
else
#endif
#if 0
- case XK_m:
+ case KEY_m:
if (MoveSpeed == 8)
{
MoveSpeed = 4;
break;
#endif
- case XK_f:
+ case KEY_f:
ScrollStepSize = TILEX/8;
printf("ScrollStepSize == %d (1/8)\n", ScrollStepSize);
break;
- case XK_g:
+ case KEY_g:
ScrollStepSize = TILEX/4;
printf("ScrollStepSize == %d (1/4)\n", ScrollStepSize);
break;
- case XK_h:
+ case KEY_h:
ScrollStepSize = TILEX/2;
printf("ScrollStepSize == %d (1/2)\n", ScrollStepSize);
break;
- case XK_l:
+ case KEY_l:
ScrollStepSize = TILEX;
printf("ScrollStepSize == %d (1/1)\n", ScrollStepSize);
break;
#ifndef MSDOS
- case XK_Q:
+ case KEY_Q:
#endif
- case XK_q:
+ case KEY_q:
local_player->dynamite = 1000;
break;
#if 0
- case XK_z:
+ case KEY_z:
{
int i;
void HandleNoXEvent(void);
void HandleButton(int, int, int);
-void HandleKey(KeySym, int);
+void HandleKey(Key, int);
void HandleJoystick();
#endif
#define TYPE_BOOLEAN 1
#define TYPE_SWITCH 2
-#define TYPE_KEYSYM 3
+#define TYPE_KEY 3
#define TYPE_INTEGER 4
#define TYPE_STRING 5
{ TYPE_INTEGER, &sii.joy.ylower, ".joy.ylower" },
{ TYPE_INTEGER, &sii.joy.snap, ".joy.snap_field" },
{ TYPE_INTEGER, &sii.joy.bomb, ".joy.place_bomb" },
- { TYPE_KEYSYM, &sii.key.left, ".key.move_left" },
- { TYPE_KEYSYM, &sii.key.right, ".key.move_right" },
- { TYPE_KEYSYM, &sii.key.up, ".key.move_up" },
- { TYPE_KEYSYM, &sii.key.down, ".key.move_down" },
- { TYPE_KEYSYM, &sii.key.snap, ".key.snap_field" },
- { TYPE_KEYSYM, &sii.key.bomb, ".key.place_bomb" },
+ { TYPE_KEY, &sii.key.left, ".key.move_left" },
+ { TYPE_KEY, &sii.key.right, ".key.move_right" },
+ { TYPE_KEY, &sii.key.up, ".key.move_up" },
+ { TYPE_KEY, &sii.key.down, ".key.move_down" },
+ { TYPE_KEY, &sii.key.snap, ".key.snap_field" },
+ { TYPE_KEY, &sii.key.bomb, ".key.place_bomb" },
/* level directory info */
{ TYPE_STRING, &ldi.name, "name" },
si->input[i].joy.ylower = JOYSTICK_YLOWER;
si->input[i].joy.snap = (i == 0 ? JOY_BUTTON_1 : 0);
si->input[i].joy.bomb = (i == 0 ? JOY_BUTTON_2 : 0);
- si->input[i].key.left = (i == 0 ? DEFAULT_KEY_LEFT : KEY_UNDEFINDED);
- si->input[i].key.right = (i == 0 ? DEFAULT_KEY_RIGHT : KEY_UNDEFINDED);
- si->input[i].key.up = (i == 0 ? DEFAULT_KEY_UP : KEY_UNDEFINDED);
- si->input[i].key.down = (i == 0 ? DEFAULT_KEY_DOWN : KEY_UNDEFINDED);
- si->input[i].key.snap = (i == 0 ? DEFAULT_KEY_SNAP : KEY_UNDEFINDED);
- si->input[i].key.bomb = (i == 0 ? DEFAULT_KEY_BOMB : KEY_UNDEFINDED);
+ si->input[i].key.left = (i == 0 ? DEFAULT_KEY_LEFT : KEY_UNDEFINED);
+ si->input[i].key.right = (i == 0 ? DEFAULT_KEY_RIGHT : KEY_UNDEFINED);
+ si->input[i].key.up = (i == 0 ? DEFAULT_KEY_UP : KEY_UNDEFINED);
+ si->input[i].key.down = (i == 0 ? DEFAULT_KEY_DOWN : KEY_UNDEFINED);
+ si->input[i].key.snap = (i == 0 ? DEFAULT_KEY_SNAP : KEY_UNDEFINED);
+ si->input[i].key.bomb = (i == 0 ? DEFAULT_KEY_BOMB : KEY_UNDEFINED);
}
}
*(boolean *)setup_value = get_string_boolean_value(token_value);
break;
- case TYPE_KEYSYM:
- *(KeySym *)setup_value = getKeySymFromX11KeyName(token_value);
+ case TYPE_KEY:
+ *(Key *)setup_value = getKeyFromX11KeyName(token_value);
break;
case TYPE_INTEGER:
strcat(entry, (*(boolean *)setup_value ? "on" : "off"));
break;
- case TYPE_KEYSYM:
+ case TYPE_KEY:
{
- KeySym keysym = *(KeySym *)setup_value;
- char *keyname = getKeyNameFromKeySym(keysym);
+ Key key = *(Key *)setup_value;
+ char *keyname = getKeyNameFromKey(key);
- strcat(entry, getX11KeyNameFromKeySym(keysym));
+ strcat(entry, getX11KeyNameFromKey(key));
for (i=strlen(entry); i<50; i++)
strcat(entry, " ");
struct SetupKeyboardInfo
{
- KeySym left;
- KeySym right;
- KeySym up;
- KeySym down;
- KeySym snap;
- KeySym bomb;
+ Key left;
+ Key right;
+ Key up;
+ Key down;
+ Key snap;
+ Key bomb;
};
struct SetupInputInfo
#define NUM_SOUNDS 62
/* default input keys */
-#define KEY_UNDEFINDED XK_VoidSymbol
-#define DEFAULT_KEY_LEFT XK_Left
-#define DEFAULT_KEY_RIGHT XK_Right
-#define DEFAULT_KEY_UP XK_Up
-#define DEFAULT_KEY_DOWN XK_Down
-#define DEFAULT_KEY_SNAP XK_Shift_L
-#define DEFAULT_KEY_BOMB XK_Shift_R
-#define DEFAULT_KEY_OKAY XK_Return
-#define DEFAULT_KEY_CANCEL XK_Escape
+#define DEFAULT_KEY_LEFT KEY_Left
+#define DEFAULT_KEY_RIGHT KEY_Right
+#define DEFAULT_KEY_UP KEY_Up
+#define DEFAULT_KEY_DOWN KEY_Down
+#define DEFAULT_KEY_SNAP KEY_Shift_L
+#define DEFAULT_KEY_BOMB KEY_Shift_R
+#define DEFAULT_KEY_OKAY KEY_Return
+#define DEFAULT_KEY_CANCEL KEY_Escape
/* directions for moving */
#define MV_NO_MOVING 0
putFile32BitInteger(file, chunk_length, byte_order);
}
-#define TRANSLATE_KEYSYM_TO_KEYNAME 0
-#define TRANSLATE_KEYSYM_TO_X11KEYNAME 1
-#define TRANSLATE_X11KEYNAME_TO_KEYSYM 2
+#define TRANSLATE_KEY_TO_KEYNAME 0
+#define TRANSLATE_KEY_TO_X11KEYNAME 1
+#define TRANSLATE_X11KEYNAME_TO_KEY 2
-void translate_keyname(KeySym *keysym, char **x11name, char **name, int mode)
+void translate_keyname(Key *keysym, char **x11name, char **name, int mode)
{
static struct
{
- KeySym keysym;
+ Key key;
char *x11name;
char *name;
} translate_key[] =
{
/* normal cursor keys */
- { XK_Left, "XK_Left", "cursor left" },
- { XK_Right, "XK_Right", "cursor right" },
- { XK_Up, "XK_Up", "cursor up" },
- { XK_Down, "XK_Down", "cursor down" },
+ { KEY_Left, "XK_Left", "cursor left" },
+ { KEY_Right, "XK_Right", "cursor right" },
+ { KEY_Up, "XK_Up", "cursor up" },
+ { KEY_Down, "XK_Down", "cursor down" },
/* keypad cursor keys */
-#ifdef XK_KP_Left
- { XK_KP_Left, "XK_KP_Left", "keypad left" },
- { XK_KP_Right, "XK_KP_Right", "keypad right" },
- { XK_KP_Up, "XK_KP_Up", "keypad up" },
- { XK_KP_Down, "XK_KP_Down", "keypad down" },
+#ifdef KEY_KP_Left
+ { KEY_KP_Left, "XK_KP_Left", "keypad left" },
+ { KEY_KP_Right, "XK_KP_Right", "keypad right" },
+ { KEY_KP_Up, "XK_KP_Up", "keypad up" },
+ { KEY_KP_Down, "XK_KP_Down", "keypad down" },
#endif
/* other keypad keys */
-#ifdef XK_KP_Enter
- { XK_KP_Enter, "XK_KP_Enter", "keypad enter" },
- { XK_KP_Add, "XK_KP_Add", "keypad +" },
- { XK_KP_Subtract, "XK_KP_Subtract", "keypad -" },
- { XK_KP_Multiply, "XK_KP_Multiply", "keypad mltply" },
- { XK_KP_Divide, "XK_KP_Divide", "keypad /" },
- { XK_KP_Separator, "XK_KP_Separator", "keypad ," },
+#ifdef KEY_KP_Enter
+ { KEY_KP_Enter, "XK_KP_Enter", "keypad enter" },
+ { KEY_KP_Add, "XK_KP_Add", "keypad +" },
+ { KEY_KP_Subtract, "XK_KP_Subtract", "keypad -" },
+ { KEY_KP_Multiply, "XK_KP_Multiply", "keypad mltply" },
+ { KEY_KP_Divide, "XK_KP_Divide", "keypad /" },
+ { KEY_KP_Separator, "XK_KP_Separator", "keypad ," },
#endif
/* modifier keys */
- { XK_Shift_L, "XK_Shift_L", "left shift" },
- { XK_Shift_R, "XK_Shift_R", "right shift" },
- { XK_Control_L, "XK_Control_L", "left control" },
- { XK_Control_R, "XK_Control_R", "right control" },
- { XK_Meta_L, "XK_Meta_L", "left meta" },
- { XK_Meta_R, "XK_Meta_R", "right meta" },
- { XK_Alt_L, "XK_Alt_L", "left alt" },
- { XK_Alt_R, "XK_Alt_R", "right alt" },
- { XK_Mode_switch, "XK_Mode_switch", "mode switch" },
- { XK_Multi_key, "XK_Multi_key", "multi key" },
+ { KEY_Shift_L, "XK_Shift_L", "left shift" },
+ { KEY_Shift_R, "XK_Shift_R", "right shift" },
+ { KEY_Control_L, "XK_Control_L", "left control" },
+ { KEY_Control_R, "XK_Control_R", "right control" },
+ { KEY_Meta_L, "XK_Meta_L", "left meta" },
+ { KEY_Meta_R, "XK_Meta_R", "right meta" },
+ { KEY_Alt_L, "XK_Alt_L", "left alt" },
+ { KEY_Alt_R, "XK_Alt_R", "right alt" },
+ { KEY_Mode_switch, "XK_Mode_switch", "mode switch" },
+ { KEY_Multi_key, "XK_Multi_key", "multi key" },
/* some special keys */
- { XK_BackSpace, "XK_BackSpace", "backspace" },
- { XK_Delete, "XK_Delete", "delete" },
- { XK_Insert, "XK_Insert", "insert" },
- { XK_Tab, "XK_Tab", "tab" },
- { XK_Home, "XK_Home", "home" },
- { XK_End, "XK_End", "end" },
- { XK_Page_Up, "XK_Page_Up", "page up" },
- { XK_Page_Down, "XK_Page_Down", "page down" },
+ { KEY_BackSpace, "XK_BackSpace", "backspace" },
+ { KEY_Delete, "XK_Delete", "delete" },
+ { KEY_Insert, "XK_Insert", "insert" },
+ { KEY_Tab, "XK_Tab", "tab" },
+ { KEY_Home, "XK_Home", "home" },
+ { KEY_End, "XK_End", "end" },
+ { KEY_Page_Up, "XK_Page_Up", "page up" },
+ { KEY_Page_Down, "XK_Page_Down", "page down" },
/* ASCII 0x20 to 0x40 keys (except numbers) */
- { XK_space, "XK_space", "space" },
- { XK_exclam, "XK_exclam", "!" },
- { XK_quotedbl, "XK_quotedbl", "\"" },
- { XK_numbersign, "XK_numbersign", "#" },
- { XK_dollar, "XK_dollar", "$" },
- { XK_percent, "XK_percent", "%" },
- { XK_ampersand, "XK_ampersand", "&" },
- { XK_apostrophe, "XK_apostrophe", "'" },
- { XK_parenleft, "XK_parenleft", "(" },
- { XK_parenright, "XK_parenright", ")" },
- { XK_asterisk, "XK_asterisk", "*" },
- { XK_plus, "XK_plus", "+" },
- { XK_comma, "XK_comma", "," },
- { XK_minus, "XK_minus", "-" },
- { XK_period, "XK_period", "." },
- { XK_slash, "XK_slash", "/" },
- { XK_colon, "XK_colon", ":" },
- { XK_semicolon, "XK_semicolon", ";" },
- { XK_less, "XK_less", "<" },
- { XK_equal, "XK_equal", "=" },
- { XK_greater, "XK_greater", ">" },
- { XK_question, "XK_question", "?" },
- { XK_at, "XK_at", "@" },
+ { KEY_space, "XK_space", "space" },
+ { KEY_exclam, "XK_exclam", "!" },
+ { KEY_quotedbl, "XK_quotedbl", "\"" },
+ { KEY_numbersign, "XK_numbersign", "#" },
+ { KEY_dollar, "XK_dollar", "$" },
+ { KEY_percent, "XK_percent", "%" },
+ { KEY_ampersand, "XK_ampersand", "&" },
+ { KEY_apostrophe, "XK_apostrophe", "'" },
+ { KEY_parenleft, "XK_parenleft", "(" },
+ { KEY_parenright, "XK_parenright", ")" },
+ { KEY_asterisk, "XK_asterisk", "*" },
+ { KEY_plus, "XK_plus", "+" },
+ { KEY_comma, "XK_comma", "," },
+ { KEY_minus, "XK_minus", "-" },
+ { KEY_period, "XK_period", "." },
+ { KEY_slash, "XK_slash", "/" },
+ { KEY_colon, "XK_colon", ":" },
+ { KEY_semicolon, "XK_semicolon", ";" },
+ { KEY_less, "XK_less", "<" },
+ { KEY_equal, "XK_equal", "=" },
+ { KEY_greater, "XK_greater", ">" },
+ { KEY_question, "XK_question", "?" },
+ { KEY_at, "XK_at", "@" },
/* more ASCII keys */
- { XK_bracketleft, "XK_bracketleft", "[" },
- { XK_backslash, "XK_backslash", "backslash" },
- { XK_bracketright, "XK_bracketright", "]" },
- { XK_asciicircum, "XK_asciicircum", "circumflex" },
- { XK_underscore, "XK_underscore", "_" },
- { XK_grave, "XK_grave", "grave" },
- { XK_quoteleft, "XK_quoteleft", "quote left" },
- { XK_braceleft, "XK_braceleft", "brace left" },
- { XK_bar, "XK_bar", "bar" },
- { XK_braceright, "XK_braceright", "brace right" },
- { XK_asciitilde, "XK_asciitilde", "ascii tilde" },
+ { KEY_bracketleft, "XK_bracketleft", "[" },
+ { KEY_backslash, "XK_backslash", "backslash" },
+ { KEY_bracketright, "XK_bracketright", "]" },
+ { KEY_asciicircum, "XK_asciicircum", "circumflex" },
+ { KEY_underscore, "XK_underscore", "_" },
+ { KEY_grave, "XK_grave", "grave" },
+ { KEY_quoteleft, "XK_quoteleft", "quote left" },
+ { KEY_braceleft, "XK_braceleft", "brace left" },
+ { KEY_bar, "XK_bar", "bar" },
+ { KEY_braceright, "XK_braceright", "brace right" },
+ { KEY_asciitilde, "XK_asciitilde", "ascii tilde" },
/* special (non-ASCII) keys */
- { XK_Adiaeresis, "XK_Adiaeresis", "Ä" },
- { XK_Odiaeresis, "XK_Odiaeresis", "Ö" },
- { XK_Udiaeresis, "XK_Udiaeresis", "Ü" },
- { XK_adiaeresis, "XK_adiaeresis", "ä" },
- { XK_odiaeresis, "XK_odiaeresis", "ö" },
- { XK_udiaeresis, "XK_udiaeresis", "ü" },
- { XK_ssharp, "XK_ssharp", "sharp s" },
+ { KEY_Adiaeresis, "XK_Adiaeresis", "Ä" },
+ { KEY_Odiaeresis, "XK_Odiaeresis", "Ö" },
+ { KEY_Udiaeresis, "XK_Udiaeresis", "Ü" },
+ { KEY_adiaeresis, "XK_adiaeresis", "ä" },
+ { KEY_odiaeresis, "XK_odiaeresis", "ö" },
+ { KEY_udiaeresis, "XK_udiaeresis", "ü" },
+ { KEY_ssharp, "XK_ssharp", "sharp s" },
/* end-of-array identifier */
{ 0, NULL, NULL }
int i;
- if (mode == TRANSLATE_KEYSYM_TO_KEYNAME)
+ if (mode == TRANSLATE_KEY_TO_KEYNAME)
{
static char name_buffer[30];
- KeySym key = *keysym;
-
- if (key >= XK_A && key <= XK_Z)
- sprintf(name_buffer, "%c", 'A' + (char)(key - XK_A));
- else if (key >= XK_a && key <= XK_z)
- sprintf(name_buffer, "%c", 'a' + (char)(key - XK_a));
- else if (key >= XK_0 && key <= XK_9)
- sprintf(name_buffer, "%c", '0' + (char)(key - XK_0));
- else if (key >= XK_KP_0 && key <= XK_KP_9)
- sprintf(name_buffer, "keypad %c", '0' + (char)(key - XK_KP_0));
- else if (key >= XK_F1 && key <= XK_F24)
- sprintf(name_buffer, "function F%d", (int)(key - XK_F1 + 1));
- else if (key == KEY_UNDEFINDED)
+ Key key = *keysym;
+
+ if (key >= KEY_A && key <= KEY_Z)
+ sprintf(name_buffer, "%c", 'A' + (char)(key - KEY_A));
+ else if (key >= KEY_a && key <= KEY_z)
+ sprintf(name_buffer, "%c", 'a' + (char)(key - KEY_a));
+ else if (key >= KEY_0 && key <= KEY_9)
+ sprintf(name_buffer, "%c", '0' + (char)(key - KEY_0));
+ else if (key >= KEY_KP_0 && key <= KEY_KP_9)
+ sprintf(name_buffer, "keypad %c", '0' + (char)(key - KEY_KP_0));
+ else if (key >= KEY_F1 && key <= KEY_F24)
+ sprintf(name_buffer, "function F%d", (int)(key - KEY_F1 + 1));
+ else if (key == KEY_UNDEFINED)
strcpy(name_buffer, "(undefined)");
else
{
do
{
- if (key == translate_key[i].keysym)
+ if (key == translate_key[i].key)
{
strcpy(name_buffer, translate_key[i].name);
break;
*name = name_buffer;
}
- else if (mode == TRANSLATE_KEYSYM_TO_X11KEYNAME)
+ else if (mode == TRANSLATE_KEY_TO_X11KEYNAME)
{
static char name_buffer[30];
- KeySym key = *keysym;
-
- if (key >= XK_A && key <= XK_Z)
- sprintf(name_buffer, "XK_%c", 'A' + (char)(key - XK_A));
- else if (key >= XK_a && key <= XK_z)
- sprintf(name_buffer, "XK_%c", 'a' + (char)(key - XK_a));
- else if (key >= XK_0 && key <= XK_9)
- sprintf(name_buffer, "XK_%c", '0' + (char)(key - XK_0));
- else if (key >= XK_KP_0 && key <= XK_KP_9)
- sprintf(name_buffer, "XK_KP_%c", '0' + (char)(key - XK_KP_0));
- else if (key >= XK_F1 && key <= XK_F24)
- sprintf(name_buffer, "XK_F%d", (int)(key - XK_F1 + 1));
- else if (key == KEY_UNDEFINDED)
+ Key key = *keysym;
+
+ if (key >= KEY_A && key <= KEY_Z)
+ sprintf(name_buffer, "XK_%c", 'A' + (char)(key - KEY_A));
+ else if (key >= KEY_a && key <= KEY_z)
+ sprintf(name_buffer, "XK_%c", 'a' + (char)(key - KEY_a));
+ else if (key >= KEY_0 && key <= KEY_9)
+ sprintf(name_buffer, "XK_%c", '0' + (char)(key - KEY_0));
+ else if (key >= KEY_KP_0 && key <= KEY_KP_9)
+ sprintf(name_buffer, "XK_KP_%c", '0' + (char)(key - KEY_KP_0));
+ else if (key >= KEY_F1 && key <= KEY_F24)
+ sprintf(name_buffer, "XK_F%d", (int)(key - KEY_F1 + 1));
+ else if (key == KEY_UNDEFINED)
strcpy(name_buffer, "[undefined]");
else
{
do
{
- if (key == translate_key[i].keysym)
+ if (key == translate_key[i].key)
{
strcpy(name_buffer, translate_key[i].x11name);
break;
*x11name = name_buffer;
}
- else if (mode == TRANSLATE_X11KEYNAME_TO_KEYSYM)
+ else if (mode == TRANSLATE_X11KEYNAME_TO_KEY)
{
- KeySym key = XK_VoidSymbol;
+ Key key = KEY_UNDEFINED;
char *name_ptr = *x11name;
if (strncmp(name_ptr, "XK_", 3) == 0 && strlen(name_ptr) == 4)
char c = name_ptr[3];
if (c >= 'A' && c <= 'Z')
- key = XK_A + (KeySym)(c - 'A');
+ key = KEY_A + (Key)(c - 'A');
else if (c >= 'a' && c <= 'z')
- key = XK_a + (KeySym)(c - 'a');
+ key = KEY_a + (Key)(c - 'a');
else if (c >= '0' && c <= '9')
- key = XK_0 + (KeySym)(c - '0');
+ key = KEY_0 + (Key)(c - '0');
}
else if (strncmp(name_ptr, "XK_KP_", 6) == 0 && strlen(name_ptr) == 7)
{
char c = name_ptr[6];
if (c >= '0' && c <= '9')
- key = XK_0 + (KeySym)(c - '0');
+ key = KEY_0 + (Key)(c - '0');
}
else if (strncmp(name_ptr, "XK_F", 4) == 0 && strlen(name_ptr) <= 6)
{
d = atoi(&name_ptr[4]);
if (d >=1 && d <= 24)
- key = XK_F1 + (KeySym)(d - 1);
+ key = KEY_F1 + (Key)(d - 1);
}
else if (strncmp(name_ptr, "XK_", 3) == 0)
{
{
if (strcmp(name_ptr, translate_key[i].x11name) == 0)
{
- key = translate_key[i].keysym;
+ key = translate_key[i].key;
break;
}
}
}
if (value != -1)
- key = (KeySym)value;
+ key = (Key)value;
}
*keysym = key;
}
}
-char *getKeyNameFromKeySym(KeySym keysym)
+char *getKeyNameFromKey(Key key)
{
char *name;
- translate_keyname(&keysym, NULL, &name, TRANSLATE_KEYSYM_TO_KEYNAME);
+ translate_keyname(&key, NULL, &name, TRANSLATE_KEY_TO_KEYNAME);
return name;
}
-char *getX11KeyNameFromKeySym(KeySym keysym)
+char *getX11KeyNameFromKey(Key key)
{
char *x11name;
- translate_keyname(&keysym, &x11name, NULL, TRANSLATE_KEYSYM_TO_X11KEYNAME);
+ translate_keyname(&key, &x11name, NULL, TRANSLATE_KEY_TO_X11KEYNAME);
return x11name;
}
-KeySym getKeySymFromX11KeyName(char *x11name)
+Key getKeyFromX11KeyName(char *x11name)
{
- KeySym keysym;
+ Key key;
- translate_keyname(&keysym, &x11name, NULL, TRANSLATE_X11KEYNAME_TO_KEYSYM);
- return keysym;
+ translate_keyname(&key, &x11name, NULL, TRANSLATE_X11KEYNAME_TO_KEY);
+ return key;
}
-char getCharFromKeySym(KeySym keysym)
+char getCharFromKey(Key key)
{
- char *keyname = getKeyNameFromKeySym(keysym);
+ char *keyname = getKeyNameFromKey(key);
char letter = 0;
if (strlen(keyname) == 1)
void putFile32BitInteger(FILE *, int, int);
void getFileChunk(FILE *, char *, int *, int);
void putFileChunk(FILE *, char *, int, int);
-char *getKeyNameFromKeySym(KeySym);
-char *getX11KeyNameFromKeySym(KeySym);
-KeySym getKeySymFromX11KeyName(char *);
-char getCharFromKeySym(KeySym);
+char *getKeyNameFromKey(Key);
+char *getX11KeyNameFromKey(Key);
+Key getKeyFromX11KeyName(char *);
+char getCharFromKey(Key);
char *getJoyNameFromJoySymbol(int);
int getJoySymbolFromJoyName(char *);
int getJoystickNrFromDeviceName(char *);
XKeyEvent xkey;
} XEvent;
-unsigned char get_ascii(KeySym);
void XMapWindow(Display *, Window);
Display *XOpenDisplay(char *);
Window XCreateSimpleWindow(Display *, Window, int, int,
static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
-#ifdef MSDOS
-extern unsigned char get_ascii(KeySym);
-#endif
-
void DrawHeadline()
{
int x = SX + (SXSIZE - strlen(PROGRAM_TITLE_STRING) * FONT1_XSIZE) / 2;
BackToFront();
}
-void HandleTypeName(int newxpos, KeySym key)
+void HandleTypeName(int newxpos, Key key)
{
static int xpos = 0, ypos = 2;
return;
}
- if (((key >= XK_A && key <= XK_Z) || (key >= XK_a && key <= XK_z)) &&
+ if (((key >= KEY_A && key <= KEY_Z) || (key >= KEY_a && key <= KEY_z)) &&
xpos < MAX_PLAYER_NAME_LEN)
{
char ascii;
- if (key >= XK_A && key <= XK_Z)
- ascii = 'A' + (char)(key - XK_A);
+ if (key >= KEY_A && key <= KEY_Z)
+ ascii = 'A' + (char)(key - KEY_A);
else
- ascii = 'a' + (char)(key - XK_a);
+ ascii = 'a' + (char)(key - KEY_a);
setup.player_name[xpos] = ascii;
setup.player_name[xpos + 1] = 0;
setup.player_name, FS_BIG, FC_YELLOW);
DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
}
- else if ((key == XK_Delete || key == XK_BackSpace) && xpos > 0)
+ else if ((key == KEY_Delete || key == KEY_BackSpace) && xpos > 0)
{
xpos--;
setup.player_name[xpos] = 0;
DrawGraphic(xpos + 6, ypos, GFX_KUGEL_ROT);
DrawGraphic(xpos + 7, ypos, GFX_LEERRAUM);
}
- else if (key == XK_Return && xpos > 0)
+ else if (key == KEY_Return && xpos > 0)
{
DrawText(SX + 6*32, SY + ypos*32, setup.player_name, FS_BIG, FC_RED);
DrawGraphic(xpos + 6, ypos, GFX_LEERRAUM);
else
x = y = 0; /* no action */
- if (ABS(dy) == SCR_FIELDY) /* handle XK_Page_Up, XK_Page_Down */
+ if (ABS(dy) == SCR_FIELDY) /* handle KEY_Page_Up, KEY_Page_Down */
{
dy = SIGN(dy);
step = num_page_entries - 1;
return;
}
- if (ABS(dy) == SCR_FIELDY) /* handle XK_Page_Up, XK_Page_Down */
+ if (ABS(dy) == SCR_FIELDY) /* handle KEY_Page_Up, KEY_Page_Down */
step = MAX_LEVEL_SERIES_ON_SCREEN - 1;
if (dy < 0)
static struct SetupKeyboardInfo custom_key;
static struct
{
- KeySym *keysym;
+ Key *key;
char *text;
} custom[] =
{
DrawText(SX + 3*32, SY + ypos*32,
(setup.input[player_nr].use_joystick ?
custom[i].text :
- getKeyNameFromKeySym(*custom[i].keysym)),
+ getKeyNameFromKey(*custom[i].key)),
FS_BIG, FC_YELLOW);
}
}
static struct SetupKeyboardInfo custom_key;
static struct
{
- KeySym *keysym;
+ Key *key;
char *text;
} customize_step[] =
{
DrawText(SX, SY + (2+2*step_nr+1)*32,
"Key:", FS_BIG, FC_RED);
DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
- getKeyNameFromKeySym(*customize_step[step_nr].keysym),
+ getKeyNameFromKey(*customize_step[step_nr].key),
FS_BIG, FC_BLUE);
while(!finished)
{
case EVENT_KEYPRESS:
{
- KeySym key = XLookupKeysym((KeyEvent *)&event,
- ((KeyEvent *)&event)->state);
+ Key key = GetEventKey((KeyEvent *)&event, TRUE);
- if (key == XK_Escape || (key == XK_Return && step_nr == 6))
+ if (key == KEY_Escape || (key == KEY_Return && step_nr == 6))
{
finished = TRUE;
break;
}
/* press 'Enter' to keep the existing key binding */
- if (key == XK_Return || step_nr == 6)
- key = *customize_step[step_nr].keysym;
+ if (key == KEY_Return || step_nr == 6)
+ key = *customize_step[step_nr].key;
/* check if key already used */
for (i=0; i<step_nr; i++)
- if (*customize_step[i].keysym == key)
+ if (*customize_step[i].key == key)
break;
if (i < step_nr)
break;
/* got new key binding */
- *customize_step[step_nr].keysym = key;
+ *customize_step[step_nr].key = key;
DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
" ", FS_BIG, FC_YELLOW);
DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
- getKeyNameFromKeySym(key), FS_BIG, FC_YELLOW);
+ getKeyNameFromKey(key), FS_BIG, FC_YELLOW);
step_nr++;
/* un-highlight last query */
DrawText(SX, SY+(2+2*step_nr+1)*32,
"Key:", FS_BIG, FC_RED);
DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
- getKeyNameFromKeySym(*customize_step[step_nr].keysym),
+ getKeyNameFromKey(*customize_step[step_nr].key),
FS_BIG, FC_BLUE);
}
break;
switch(event.type)
{
case EVENT_KEYPRESS:
- switch(XLookupKeysym((KeyEvent *)&event,
- ((KeyEvent *)&event)->state))
+ switch(GetEventKey((KeyEvent *)&event, TRUE))
{
- case XK_Return:
+ case KEY_Return:
if (check_remaining == 0)
result = 1;
break;
- case XK_Escape:
+ case KEY_Escape:
result = 0;
break;
void DrawHelpScreenCreditsText(void);
void DrawHelpScreen(void);
void HandleHelpScreen(int);
-void HandleTypeName(int, KeySym);
+void HandleTypeName(int, Key);
void DrawChooseLevel(void);
void HandleChooseLevel(int, int, int, int, int);
void DrawHallOfFame(int);
inline void KeyboardAutoRepeatOn()
{
-#ifndef USE_SDL_LIBRARY
+#ifdef USE_SDL_LIBRARY
+ SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY / 2,
+ SDL_DEFAULT_REPEAT_INTERVAL / 2);
+ SDL_EnableUNICODE(1);
+#else
XAutoRepeatOn(display);
#endif
}
inline void KeyboardAutoRepeatOff()
{
-#ifndef USE_SDL_LIBRARY
+#ifdef USE_SDL_LIBRARY
+ SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
+ SDL_EnableUNICODE(0);
+#else
XAutoRepeatOff(display);
#endif
}
#endif
}
+inline Key GetEventKey(KeyEvent *event, boolean with_modifiers)
+{
+#ifdef USE_SDL_LIBRARY
+#if 0
+ printf("0x%x, 0x%x\n",
+ event->keysym.sym, event->keysym.unicode);
+#endif
+ if (with_modifiers && event->keysym.unicode != 0)
+ return event->keysym.unicode;
+ else
+ return event->keysym.sym;
+#else
+#if 0
+ printf("0x%x, 0x%x\n",
+ (unsigned int)XLookupKeysym(event, 0),
+ (unsigned int)XLookupKeysym(event, event->state));
+#endif
+ if (with_modifiers)
+ return XLookupKeysym(event, event->state);
+ else
+ return XLookupKeysym(event, 0);
+#endif
+}
+
inline void dummy()
{
#ifdef USE_SDL_LIBRARY
#endif
#ifdef USE_SDL_LIBRARY
-typedef SDL_Surface *Bitmap;
-typedef SDL_Surface *DrawWindow;
-typedef SDL_Surface *DrawBuffer;
-#else
-typedef Pixmap Bitmap;
-typedef Window DrawWindow;
-typedef Drawable DrawBuffer;
-#endif
-#ifdef USE_SDL_LIBRARY
+typedef SDL_Surface *Bitmap;
+typedef SDL_Surface *DrawWindow;
+typedef SDL_Surface *DrawBuffer;
+
+typedef SDLKey Key;
typedef SDL_Event Event;
typedef SDL_MouseButtonEvent ButtonEvent;
typedef SDL_MouseMotionEvent MotionEvent;
-typedef XKeyEvent KeyEvent;
+typedef SDL_KeyboardEvent KeyEvent;
typedef XExposeEvent ExposeEvent;
typedef XFocusChangeEvent FocusChangeEvent;
typedef XClientMessageEvent ClientMessageEvent;
#define EVENT_MAPNOTIFY SDL_USEREVENT + 4
#define EVENT_UNMAPNOTIFY SDL_USEREVENT + 5
-#else
+#define KEY_UNDEFINED SDLK_UNKNOWN
+
+#define KEY_Return SDLK_RETURN
+#define KEY_Escape SDLK_ESCAPE
+
+#define KEY_Left SDLK_LEFT
+#define KEY_Right SDLK_RIGHT
+#define KEY_Up SDLK_UP
+#define KEY_Down SDLK_DOWN
+
+#ifdef SDLK_KP_LEFT
+#define KEY_KP_Left SDLK_KP_LEFT
+#define KEY_KP_Right SDLK_KP_RIGHT
+#define KEY_KP_Up SDLK_KP_UP
+#define KEY_KP_Down SDLK_KP_DOWN
+#endif
+
+#define KEY_KP_Enter SDLK_KP_ENTER
+#define KEY_KP_Add SDLK_KP_PLUS
+#define KEY_KP_Subtract SDLK_KP_MINUS
+#define KEY_KP_Multiply SDLK_KP_MULTIPLY
+#define KEY_KP_Divide SDLK_KP_DIVIDE
+#define KEY_KP_Separator SDLK_KP_PERIOD
+
+#define KEY_Shift_L SDLK_LSHIFT
+#define KEY_Shift_R SDLK_RSHIFT
+#define KEY_Control_L SDLK_LCTRL
+#define KEY_Control_R SDLK_RCTRL
+#define KEY_Meta_L SDLK_LMETA
+#define KEY_Meta_R SDLK_RMETA
+#define KEY_Alt_L SDLK_LALT
+#define KEY_Alt_R SDLK_RALT
+#define KEY_Mode_switch SDLK_MODE
+#define KEY_Multi_key KEY_UNDEFINED /* undefined */
+
+#define KEY_BackSpace SDLK_BACKSPACE
+#define KEY_Delete SDLK_DELETE
+#define KEY_Insert SDLK_INSERT
+#define KEY_Tab SDLK_TAB
+#define KEY_Home SDLK_HOME
+#define KEY_End SDLK_END
+#define KEY_Page_Up SDLK_PAGEUP
+#define KEY_Page_Down SDLK_PAGEDOWN
+
+#define KEY_space SDLK_SPACE
+#define KEY_exclam SDLK_EXCLAIM
+#define KEY_quotedbl SDLK_QUOTEDBL
+#define KEY_numbersign SDLK_HASH
+#define KEY_dollar SDLK_DOLLAR
+#define KEY_percent KEY_UNDEFINED /* undefined */
+#define KEY_ampersand SDLK_AMPERSAND
+#define KEY_apostrophe SDLK_QUOTE
+#define KEY_parenleft SDLK_LEFTPAREN
+#define KEY_parenright SDLK_RIGHTPAREN
+#define KEY_asterisk SDLK_ASTERISK
+#define KEY_plus SDLK_PLUS
+#define KEY_comma SDLK_COMMA
+#define KEY_minus SDLK_MINUS
+#define KEY_period SDLK_PERIOD
+#define KEY_slash SDLK_SLASH
+
+#define KEY_colon SDLK_COLON
+#define KEY_semicolon SDLK_SEMICOLON
+#define KEY_less SDLK_LESS
+#define KEY_equal SDLK_EQUALS
+#define KEY_greater SDLK_GREATER
+#define KEY_question SDLK_QUESTION
+#define KEY_at SDLK_AT
+
+#define KEY_bracketleft SDLK_LEFTBRACKET
+#define KEY_backslash SDLK_BACKSLASH
+#define KEY_bracketright SDLK_RIGHTBRACKET
+#define KEY_asciicircum SDLK_CARET
+#define KEY_underscore SDLK_UNDERSCORE
+#define KEY_grave SDLK_BACKQUOTE
+
+#define KEY_quoteleft KEY_UNDEFINED /* undefined */
+#define KEY_braceleft KEY_UNDEFINED /* undefined */
+#define KEY_bar KEY_UNDEFINED /* undefined */
+#define KEY_braceright KEY_UNDEFINED /* undefined */
+#define KEY_asciitilde KEY_UNDEFINED /* undefined */
+
+#define KEY_Adiaeresis SDLK_WORLD_36
+#define KEY_Odiaeresis SDLK_WORLD_54
+#define KEY_Udiaeresis SDLK_WORLD_60
+#define KEY_adiaeresis SDLK_WORLD_68
+#define KEY_odiaeresis SDLK_WORLD_86
+#define KEY_udiaeresis SDLK_WORLD_92
+#define KEY_ssharp SDLK_WORLD_63
+
+#ifndef SDLK_A
+#define SDLK_A 65
+#define SDLK_B 66
+#define SDLK_C 67
+#define SDLK_D 68
+#define SDLK_E 69
+#define SDLK_F 70
+#define SDLK_G 71
+#define SDLK_H 72
+#define SDLK_I 73
+#define SDLK_J 74
+#define SDLK_K 75
+#define SDLK_L 76
+#define SDLK_M 77
+#define SDLK_N 78
+#define SDLK_O 79
+#define SDLK_P 80
+#define SDLK_Q 81
+#define SDLK_R 82
+#define SDLK_S 83
+#define SDLK_T 84
+#define SDLK_U 85
+#define SDLK_V 86
+#define SDLK_W 87
+#define SDLK_X 88
+#define SDLK_Y 89
+#define SDLK_Z 90
+#endif
+
+#define KEY_A SDLK_A
+#define KEY_B SDLK_B
+#define KEY_C SDLK_C
+#define KEY_D SDLK_D
+#define KEY_E SDLK_E
+#define KEY_F SDLK_F
+#define KEY_G SDLK_G
+#define KEY_H SDLK_H
+#define KEY_I SDLK_I
+#define KEY_J SDLK_J
+#define KEY_K SDLK_K
+#define KEY_L SDLK_L
+#define KEY_M SDLK_M
+#define KEY_N SDLK_N
+#define KEY_O SDLK_O
+#define KEY_P SDLK_P
+#define KEY_Q SDLK_Q
+#define KEY_R SDLK_R
+#define KEY_S SDLK_S
+#define KEY_T SDLK_T
+#define KEY_U SDLK_U
+#define KEY_V SDLK_V
+#define KEY_W SDLK_W
+#define KEY_X SDLK_X
+#define KEY_Y SDLK_Y
+#define KEY_Z SDLK_Z
+
+#define KEY_a SDLK_a
+#define KEY_b SDLK_b
+#define KEY_c SDLK_c
+#define KEY_d SDLK_d
+#define KEY_e SDLK_e
+#define KEY_f SDLK_f
+#define KEY_g SDLK_g
+#define KEY_h SDLK_h
+#define KEY_i SDLK_i
+#define KEY_j SDLK_j
+#define KEY_k SDLK_k
+#define KEY_l SDLK_l
+#define KEY_m SDLK_m
+#define KEY_n SDLK_n
+#define KEY_o SDLK_o
+#define KEY_p SDLK_p
+#define KEY_q SDLK_q
+#define KEY_r SDLK_r
+#define KEY_s SDLK_s
+#define KEY_t SDLK_t
+#define KEY_u SDLK_u
+#define KEY_v SDLK_v
+#define KEY_w SDLK_w
+#define KEY_x SDLK_x
+#define KEY_y SDLK_y
+#define KEY_z SDLK_z
+
+#define KEY_0 SDLK_0
+#define KEY_1 SDLK_1
+#define KEY_2 SDLK_2
+#define KEY_3 SDLK_3
+#define KEY_4 SDLK_4
+#define KEY_5 SDLK_5
+#define KEY_6 SDLK_6
+#define KEY_7 SDLK_7
+#define KEY_8 SDLK_8
+#define KEY_9 SDLK_9
+
+#define KEY_KP_0 SDLK_KP0
+#define KEY_KP_1 SDLK_KP1
+#define KEY_KP_2 SDLK_KP2
+#define KEY_KP_3 SDLK_KP3
+#define KEY_KP_4 SDLK_KP4
+#define KEY_KP_5 SDLK_KP5
+#define KEY_KP_6 SDLK_KP6
+#define KEY_KP_7 SDLK_KP7
+#define KEY_KP_8 SDLK_KP8
+#define KEY_KP_9 SDLK_KP9
+
+#define KEY_F1 SDLK_F1
+#define KEY_F2 SDLK_F2
+#define KEY_F3 SDLK_F3
+#define KEY_F4 SDLK_F4
+#define KEY_F5 SDLK_F5
+#define KEY_F6 SDLK_F6
+#define KEY_F7 SDLK_F7
+#define KEY_F8 SDLK_F8
+#define KEY_F9 SDLK_F9
+#define KEY_F10 SDLK_F10
+#define KEY_F11 SDLK_F11
+#define KEY_F12 SDLK_F12
+#define KEY_F13 SDLK_F13
+#define KEY_F14 SDLK_F14
+#define KEY_F15 SDLK_F15
+#define KEY_F16 KEY_UNDEFINED
+#define KEY_F17 KEY_UNDEFINED
+#define KEY_F18 KEY_UNDEFINED
+#define KEY_F19 KEY_UNDEFINED
+#define KEY_F20 KEY_UNDEFINED
+#define KEY_F21 KEY_UNDEFINED
+#define KEY_F22 KEY_UNDEFINED
+#define KEY_F23 KEY_UNDEFINED
+#define KEY_F24 KEY_UNDEFINED
+
+#else /* X11 type definitions */
+
+typedef Pixmap Bitmap;
+typedef Window DrawWindow;
+typedef Drawable DrawBuffer;
+
+typedef KeySym Key;
typedef XEvent Event;
typedef XButtonEvent ButtonEvent;
#define EVENT_MAPNOTIFY MapNotify
#define EVENT_UNMAPNOTIFY UnmapNotify
+#define KEY_UNDEFINED XK_VoidSymbol
+
+#define KEY_Return XK_Return
+#define KEY_Escape XK_Escape
+
+#define KEY_Left XK_Left
+#define KEY_Right XK_Right
+#define KEY_Up XK_Up
+#define KEY_Down XK_Down
+
+#ifdef XK_KP_Left
+#define KEY_KP_Left XK_KP_Left
+#define KEY_KP_Right XK_KP_Right
+#define KEY_KP_Up XK_KP_Up
+#define KEY_KP_Down XK_KP_Down
+#endif
+
+#ifdef XK_KP_Enter
+#define KEY_KP_Enter XK_KP_Enter
+#define KEY_KP_Add XK_KP_Add
+#define KEY_KP_Subtract XK_KP_Subtract
+#define KEY_KP_Multiply XK_KP_Multiply
+#define KEY_KP_Divide XK_KP_Divide
+#define KEY_KP_Separator XK_KP_Separator
+#endif
+
+#define KEY_Shift_L XK_Shift_L
+#define KEY_Shift_R XK_Shift_R
+#define KEY_Control_L XK_Control_L
+#define KEY_Control_R XK_Control_R
+#define KEY_Meta_L XK_Meta_L
+#define KEY_Meta_R XK_Meta_R
+#define KEY_Alt_L XK_Alt_L
+#define KEY_Alt_R XK_Alt_R
+#define KEY_Mode_switch XK_Mode_switch
+#define KEY_Multi_key XK_Multi_key
+
+#define KEY_BackSpace XK_BackSpace
+#define KEY_Delete XK_Delete
+#define KEY_Insert XK_Insert
+#define KEY_Tab XK_Tab
+#define KEY_Home XK_Home
+#define KEY_End XK_End
+#define KEY_Page_Up XK_Page_Up
+#define KEY_Page_Down XK_Page_Down
+
+#define KEY_space XK_space
+#define KEY_exclam XK_exclam
+#define KEY_quotedbl XK_quotedbl
+#define KEY_numbersign XK_numbersign
+#define KEY_dollar XK_dollar
+#define KEY_percent XK_percent
+#define KEY_ampersand XK_ampersand
+#define KEY_apostrophe XK_apostrophe
+#define KEY_parenleft XK_parenleft
+#define KEY_parenright XK_parenright
+#define KEY_asterisk XK_asterisk
+#define KEY_plus XK_plus
+#define KEY_comma XK_comma
+#define KEY_minus XK_minus
+#define KEY_period XK_period
+#define KEY_slash XK_slash
+
+#define KEY_colon XK_colon
+#define KEY_semicolon XK_semicolon
+#define KEY_less XK_less
+#define KEY_equal XK_equal
+#define KEY_greater XK_greater
+#define KEY_question XK_question
+#define KEY_at XK_at
+
+#define KEY_bracketleft XK_bracketleft
+#define KEY_backslash XK_backslash
+#define KEY_bracketright XK_bracketright
+#define KEY_asciicircum XK_asciicircum
+#define KEY_underscore XK_underscore
+#define KEY_grave XK_grave
+
+#define KEY_quoteleft XK_quoteleft
+#define KEY_braceleft XK_braceleft
+#define KEY_bar XK_bar
+#define KEY_braceright XK_braceright
+#define KEY_asciitilde XK_asciitilde
+
+#define KEY_Adiaeresis XK_Adiaeresis
+#define KEY_Odiaeresis XK_Odiaeresis
+#define KEY_Udiaeresis XK_Udiaeresis
+#define KEY_adiaeresis XK_adiaeresis
+#define KEY_odiaeresis XK_odiaeresis
+#define KEY_udiaeresis XK_udiaeresis
+#define KEY_ssharp XK_ssharp
+
+#define KEY_A XK_A
+#define KEY_B XK_B
+#define KEY_C XK_C
+#define KEY_D XK_D
+#define KEY_E XK_E
+#define KEY_F XK_F
+#define KEY_G XK_G
+#define KEY_H XK_H
+#define KEY_I XK_I
+#define KEY_J XK_J
+#define KEY_K XK_K
+#define KEY_L XK_L
+#define KEY_M XK_M
+#define KEY_N XK_N
+#define KEY_O XK_O
+#define KEY_P XK_P
+#define KEY_Q XK_Q
+#define KEY_R XK_R
+#define KEY_S XK_S
+#define KEY_T XK_T
+#define KEY_U XK_U
+#define KEY_V XK_V
+#define KEY_W XK_W
+#define KEY_X XK_X
+#define KEY_Y XK_Y
+#define KEY_Z XK_Z
+
+#define KEY_a XK_a
+#define KEY_b XK_b
+#define KEY_c XK_c
+#define KEY_d XK_d
+#define KEY_e XK_e
+#define KEY_f XK_f
+#define KEY_g XK_g
+#define KEY_h XK_h
+#define KEY_i XK_i
+#define KEY_j XK_j
+#define KEY_k XK_k
+#define KEY_l XK_l
+#define KEY_m XK_m
+#define KEY_n XK_n
+#define KEY_o XK_o
+#define KEY_p XK_p
+#define KEY_q XK_q
+#define KEY_r XK_r
+#define KEY_s XK_s
+#define KEY_t XK_t
+#define KEY_u XK_u
+#define KEY_v XK_v
+#define KEY_w XK_w
+#define KEY_x XK_x
+#define KEY_y XK_y
+#define KEY_z XK_z
+
+#define KEY_0 XK_0
+#define KEY_1 XK_1
+#define KEY_2 XK_2
+#define KEY_3 XK_3
+#define KEY_4 XK_4
+#define KEY_5 XK_5
+#define KEY_6 XK_6
+#define KEY_7 XK_7
+#define KEY_8 XK_8
+#define KEY_9 XK_9
+
+#define KEY_KP_0 XK_KP_0
+#define KEY_KP_1 XK_KP_1
+#define KEY_KP_2 XK_KP_2
+#define KEY_KP_3 XK_KP_3
+#define KEY_KP_4 XK_KP_4
+#define KEY_KP_5 XK_KP_5
+#define KEY_KP_6 XK_KP_6
+#define KEY_KP_7 XK_KP_7
+#define KEY_KP_8 XK_KP_8
+#define KEY_KP_9 XK_KP_9
+
+#define KEY_F1 XK_F1
+#define KEY_F2 XK_F2
+#define KEY_F3 XK_F3
+#define KEY_F4 XK_F4
+#define KEY_F5 XK_F5
+#define KEY_F6 XK_F6
+#define KEY_F7 XK_F7
+#define KEY_F8 XK_F8
+#define KEY_F9 XK_F9
+#define KEY_F10 XK_F10
+#define KEY_F11 XK_F11
+#define KEY_F12 XK_F12
+#define KEY_F13 XK_F13
+#define KEY_F14 XK_F14
+#define KEY_F15 XK_F15
+#define KEY_F16 XK_F16
+#define KEY_F17 XK_F17
+#define KEY_F18 XK_F18
+#define KEY_F19 XK_F19
+#define KEY_F20 XK_F20
+#define KEY_F21 XK_F21
+#define KEY_F22 XK_F22
+#define KEY_F23 XK_F23
+#define KEY_F24 XK_F24
+
#endif
inline void ClearRectangle(Bitmap, int, int, int, int);
inline boolean PendingEvent();
inline void NextEvent(Event *event);
+inline Key GetEventKey(KeyEvent *, boolean);
+
#endif /* SYSTEM_H */
void DrawInitText(char *text, int ypos, int color)
{
-#ifdef USE_SDL_LIBRARY
if (window && pix[PIX_SMALLFONT])
- {
- ClearRectangle(window, 0, ypos, WIN_XSIZE, FONT2_YSIZE);
- DrawTextExt(window, gc, (WIN_XSIZE - strlen(text) * FONT2_XSIZE)/2,
- ypos, text, FS_SMALL, color);
- SDL_Flip(window);
- }
-#else
- if (display && window && pix[PIX_SMALLFONT])
{
ClearRectangle(window, 0, ypos, WIN_XSIZE, FONT2_YSIZE);
DrawTextExt(window, gc, (WIN_XSIZE - strlen(text) * FONT2_XSIZE)/2,
ypos, text, FS_SMALL, color);
FlushDisplay();
}
-#endif
}
void DrawTextFCentered(int y, int font_type, char *format, ...)
}
case EVENT_KEYPRESS:
- switch(XLookupKeysym((KeyEvent *)&event,
- ((KeyEvent *)&event)->state))
+ switch(GetEventKey((KeyEvent *)&event, TRUE))
{
- case XK_Return:
+ case KEY_Return:
result = 1;
break;
- case XK_Escape:
+ case KEY_Escape:
result = 0;
break;