1 /*
2  * Tux Racer
3  * Copyright (C) 1999-2001 Jasmin F. Patry
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  */
19 
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif
24 
25 #ifndef _KEYBOARD_H_
26 #define _KEYBOARD_H_
27 
28 #include "tuxracer.h"
29 
30 typedef enum {
31     FIXED_KEY,
32     CONFIGURABLE_KEY,
33     DEFAULT_CALLBACK
34 } keymap_class_t;
35 
36 typedef char* (*key_func_t)();
37 typedef void (*key_cb_t)( int key, bool_t special, bool_t release,
38 			  int x, int y );
39 
40 typedef struct {
41     game_mode_t mode;
42     keymap_class_t keymap_class;
43     char *keys;
44     key_func_t key_func;
45     key_cb_t key_cb;
46 } keymap_t;
47 
48 #define START_KEYBOARD_CB( name ) \
49     void name ( int key, bool_t special, bool_t release, int x, int y ) { \
50     player_data_t *plyr = get_player_data( local_player() ); \
51     plyr = plyr + 1 - 1; /* to suppress warnings */
52 
53 
54 #define END_KEYBOARD_CB }
55 
56 void init_keyboard();
57 int add_keymap_entry( game_mode_t mode, keymap_class_t keymap_class,
58 		      char *keys, key_func_t key_func, key_cb_t key_cb );
59 
60 #endif
61 
62 #ifdef __cplusplus
63 } /* extern "C" */
64 #endif
65