forked from len0rd/rockbox
Made handle_events a polling function to allow button scanning
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@146 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
f9429cc11b
commit
5d4094fc98
2 changed files with 70 additions and 69 deletions
|
@ -91,6 +91,8 @@ static char *default_defaults[] = {
|
|||
0
|
||||
};
|
||||
|
||||
extern Display* dpy;
|
||||
|
||||
static XrmOptionDescRec *merged_options;
|
||||
static int merged_options_size;
|
||||
static char **merged_defaults;
|
||||
|
@ -179,9 +181,10 @@ static Atom XA_WM_PROTOCOLS, XA_WM_DELETE_WINDOW;
|
|||
/* Dead-trivial event handling: exits if "q" or "ESC" are typed.
|
||||
Exit if the WM_PROTOCOLS WM_DELETE_WINDOW ClientMessage is received.
|
||||
*/
|
||||
void
|
||||
int
|
||||
screenhack_handle_event (Display *dpy, XEvent *event)
|
||||
{
|
||||
int key=0;
|
||||
switch (event->xany.type)
|
||||
{
|
||||
case KeyPress:
|
||||
|
@ -189,14 +192,9 @@ screenhack_handle_event (Display *dpy, XEvent *event)
|
|||
KeySym keysym;
|
||||
unsigned char c = 0;
|
||||
XLookupString (&event->xkey, &c, 1, &keysym, 0);
|
||||
if (c == 'q' ||
|
||||
c == 'Q' ||
|
||||
c == 3 || /* ^C */
|
||||
c == 27) /* ESC */
|
||||
exit (0);
|
||||
else if (! (keysym >= XK_Shift_L && keysym <= XK_Hyper_R))
|
||||
if (! (keysym >= XK_Shift_L && keysym <= XK_Hyper_R))
|
||||
XBell (dpy, 0); /* beep for non-chord keys */
|
||||
|
||||
key = keysym;
|
||||
fprintf(stderr, "KEY PRESSED: %c (%02x)\n", c, c);
|
||||
}
|
||||
break;
|
||||
|
@ -244,18 +242,21 @@ screenhack_handle_event (Display *dpy, XEvent *event)
|
|||
}
|
||||
break;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
screenhack_handle_events (Display *dpy)
|
||||
int
|
||||
screenhack_handle_events (void)
|
||||
{
|
||||
int key=0;
|
||||
while (XPending (dpy))
|
||||
{
|
||||
XEvent event;
|
||||
XNextEvent (dpy, &event);
|
||||
screenhack_handle_event (dpy, &event);
|
||||
key=screenhack_handle_event (dpy, &event);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -89,8 +89,8 @@ extern XrmOptionDescRec options [];
|
|||
extern char *defaults [];
|
||||
|
||||
extern void screenhack (Display*,Window);
|
||||
extern void screenhack_handle_event (Display*, XEvent*);
|
||||
extern void screenhack_handle_events (Display*);
|
||||
extern int screenhack_handle_event (Display*, XEvent*);
|
||||
extern int screenhack_handle_events (void);
|
||||
extern void screen_redraw();
|
||||
extern void screen_resized();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue