1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2002 by Björn Stenberg
*
* All files in this archive are subject to the GNU General Public License.
* See the file COPYING in the source tree root for full license agreement.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "button.h"
#include "kernel.h"
#include "X11/keysym.h"
static int release_mask;
static int repeat_mask;
/*
*Initialize buttons
*/
void button_init()
{
}
int button_set_repeat(int newmask)
{
int oldmask = repeat_mask;
repeat_mask = newmask;
return oldmask;
}
int button_set_release(int newmask)
{
int oldmask = release_mask;
release_mask = newmask;
return oldmask;
}
/*
* Translate X keys to Recorder keys
*
* We simulate recorder keys on the numeric keypad:
*
* 4,6,8,2 = Left, Right, Up, Down
* 5 = Play/pause
* Div,Mul,Sub = The tree menu keys
* +,Enter = On, Off
*
* Alternative Keys For Laptop or VNC Users
* Recorder:
* Space=Play Q=On A=Off 1,2,3 = F1,F2,F3
* Player:
* Q=On Return=Menu
*/
/* from uibasic.c */
extern int screenhack_handle_events (void);
static int get_raw_button (void)
{
int k = screenhack_handle_events();
switch(k)
{
case XK_KP_Left:
case XK_Left:
case XK_KP_4:
return BUTTON_LEFT;
case XK_KP_Right:
case XK_Right:
case XK_KP_6:
return BUTTON_RIGHT;
case XK_KP_Up:
case XK_Up:
case XK_KP_8:
return BUTTON_UP;
case XK_KP_Down:
case XK_Down:
case XK_KP_2:
return BUTTON_DOWN;
#ifdef HAVE_RECORDER_KEYPAD
case XK_KP_Space:
case XK_KP_5:
case XK_KP_Begin:
case XK_space:
return BUTTON_PLAY;
case XK_KP_Enter:
case XK_A:
case XK_a:
return BUTTON_OFF;
case XK_KP_Add:
case XK_Q:
case XK_q:
return BUTTON_ON;
case XK_KP_Divide:
case XK_1:
return BUTTON_F1;
case XK_KP_Multiply:
case XK_2:
return BUTTON_F2;
case XK_KP_Subtract:
case XK_3:
return BUTTON_F3;
#else
case XK_KP_Add:
case XK_Q:
case XK_q:
return BUTTON_ON;
case XK_KP_Enter:
case XK_Return:
return BUTTON_MENU;
#endif
default:
return 0;
}
}
/*
* Get the currently pressed button.
* Returns one of BUTTON_xxx codes, with possibly a modifier bit set.
* No modifier bits are set when the button is first pressed.
* BUTTON_HELD bit is while the button is being held.
* BUTTON_REL bit is set when button has been released.
*/
int button_get(bool block)
{
int bits;
do {
bits = get_raw_button();
if(block && !bits)
x11_sleep(HZ/10);
else
break;
} while(1);
return bits;
}
/* -----------------------------------------------------------------
* local variables:
* eval: (load-file "rockbox-mode.el")
* end:
*/
|