]> icculus.org git repositories - btb/d2x.git/blob - ui/keytrap.c
more header cleanup
[btb/d2x.git] / ui / keytrap.c
1
2 #ifdef HAVE_CONFIG_H
3 #include "conf.h"
4 #endif
5
6 #include <stdlib.h>
7 #include <string.h>
8
9 #include "fix.h"
10 #include "gr.h"
11 #include "ui.h"
12 #include "key.h"
13
14
15 UI_GADGET_KEYTRAP * ui_add_gadget_keytrap( UI_WINDOW * wnd, int key_to_trap, int (*function_to_call)(void)  )
16 {
17         UI_GADGET_KEYTRAP * keytrap;
18
19         keytrap = (UI_GADGET_KEYTRAP *)ui_gadget_add( wnd, 8, 0, 0, 0, 0 );
20         keytrap->parent = (UI_GADGET *)keytrap;
21
22         keytrap->trap_key = key_to_trap;
23         keytrap->user_function = function_to_call;
24
25         return keytrap;
26
27 }
28
29 void ui_keytrap_do( UI_GADGET_KEYTRAP * keytrap, int keypress )
30 {
31         int result;
32
33         if ( keypress == keytrap->trap_key )
34         {
35                 result = keytrap->user_function();
36         }
37 }