diff options
Diffstat (limited to 'uisimulator/x11/button-x11.c')
-rw-r--r-- | uisimulator/x11/button-x11.c | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/uisimulator/x11/button-x11.c b/uisimulator/x11/button-x11.c new file mode 100644 index 0000000000..4bc780bed6 --- /dev/null +++ b/uisimulator/x11/button-x11.c | |||
@@ -0,0 +1,108 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Björn Stenberg | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #define HAVE_RECORDER_KEYPAD | ||
20 | #include "types.h" | ||
21 | #include "button.h" | ||
22 | |||
23 | #include "X11/keysym.h" | ||
24 | |||
25 | /* | ||
26 | *Initialize buttons | ||
27 | */ | ||
28 | void button_init() | ||
29 | { | ||
30 | } | ||
31 | |||
32 | /* | ||
33 | * Translate X keys to Recorder keys | ||
34 | * | ||
35 | * We simulate recorder keys on the numeric keypad: | ||
36 | * | ||
37 | * 4,6,8,2 = Left, Right, Up, Down | ||
38 | * 5 = Play/pause | ||
39 | * Div,Mul,Sub = The tree menu keys | ||
40 | * +,Enter = On, Off | ||
41 | * | ||
42 | */ | ||
43 | static int get_raw_button (void) | ||
44 | { | ||
45 | int k = screenhack_handle_events(); | ||
46 | switch(k) | ||
47 | { | ||
48 | case XK_KP_Left: | ||
49 | case XK_Left: | ||
50 | case XK_KP_4: | ||
51 | return BUTTON_LEFT; | ||
52 | |||
53 | case XK_KP_Right: | ||
54 | case XK_Right: | ||
55 | case XK_KP_6: | ||
56 | return BUTTON_RIGHT; | ||
57 | |||
58 | case XK_KP_Up: | ||
59 | case XK_Up: | ||
60 | case XK_KP_8: | ||
61 | return BUTTON_UP; | ||
62 | |||
63 | case XK_KP_Down: | ||
64 | case XK_Down: | ||
65 | case XK_KP_2: | ||
66 | return BUTTON_DOWN; | ||
67 | |||
68 | case XK_KP_Space: | ||
69 | case XK_KP_5: | ||
70 | return BUTTON_PLAY; | ||
71 | |||
72 | case XK_KP_Enter: | ||
73 | return BUTTON_OFF; | ||
74 | |||
75 | case XK_KP_Add: | ||
76 | return BUTTON_ON; | ||
77 | |||
78 | case XK_KP_Divide: | ||
79 | return BUTTON_F1; | ||
80 | |||
81 | case XK_KP_Multiply: | ||
82 | return BUTTON_F2; | ||
83 | |||
84 | case XK_KP_Subtract: | ||
85 | return BUTTON_F3; | ||
86 | |||
87 | default: | ||
88 | return 0; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | /* | ||
93 | * Get the currently pressed button. | ||
94 | * Returns one of BUTTON_xxx codes, with possibly a modifier bit set. | ||
95 | * No modifier bits are set when the button is first pressed. | ||
96 | * BUTTON_HELD bit is while the button is being held. | ||
97 | * BUTTON_REL bit is set when button has been released. | ||
98 | */ | ||
99 | int button_get(void) | ||
100 | { | ||
101 | return get_raw_button(); | ||
102 | } | ||
103 | |||
104 | /* ----------------------------------------------------------------- | ||
105 | * local variables: | ||
106 | * eval: (load-file "rockbox-mode.el") | ||
107 | * end: | ||
108 | */ | ||