[AD] X11/keyboard related patches for V4.0.2 |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Hi!
I made some X11/keyboard related patches for V4.0.2, and
Elias Pschernig asked me to send it to this list, together with some
notes.
I added missing (at least for me) numeric pad keys and fixed some
other problems. I mostly wrote comments into the code where I made
modification. Please ask, if more explanations are necessary.
To the changing of MOUSE_WARP_DELAY: I'm not sure if it is good.
Stephan
--- allegro-4.0.2/src/x/xwin.c Wed Jul 3 22:18:11 2002
+++ allegro_test/src/x/xwin.c Fri Oct 17 14:53:00 2003
@@ -143,7 +143,8 @@
static Colormap _xdga_colormap[2];
#endif
-#define MOUSE_WARP_DELAY 200
+/* maybe this helps to have a faster/smoother mouse key */
+#define MOUSE_WARP_DELAY 20 /*200*/
static char _xwin_driver_desc[256] = EMPTY_STRING;
@@ -1966,13 +1967,15 @@
switch (event->type) {
case KeyPress:
- if (keyboard_got_focus && _xwin_keyboard_focused) {
+ /* no, do it everytime in order to stay in sync */
+ /*if (keyboard_got_focus && _xwin_keyboard_focused)*/ {
int state = 0;
if (event->xkey.state & Mod5Mask)
state |= KB_SCROLOCK_FLAG;
- if (event->xkey.state & Mod2Mask)
+ /* not good for X11, as X11 directly deliveres the right PAD codes */
+ /*if (event->xkey.state & Mod2Mask)*/
state |= KB_NUMLOCK_FLAG;
if (event->xkey.state & LockMask)
@@ -2172,7 +2175,7 @@
static void _xwin_private_handle_input(void)
{
int i, events;
- static XEvent event[5];
+ XEvent event;
if (_xwin.display == 0)
return;
@@ -2200,22 +2203,18 @@
if (events <= 0)
return;
- /* Limit amount of events we read at once. */
- if (events > 5)
- events = 5;
-
- /* Read pending events. */
- for (i = 0; i < events; i++)
- XNextEvent(_xwin.display, &event[i]);
-
/* Process all events. */
for (i = 0; i < events; i++)
- _xwin_private_process_event(&event[i]);
+ {
+ XNextEvent(_xwin.display, &event);
+ _xwin_private_process_event(&event);
+ }
}
void _xwin_handle_input(void)
{
- if (_xwin.lock_count) return;
+ /* no, we don't leave here to avoid loosing key release events which ist rather bad... */
+ /*if (_xwin.lock_count) return;*/
XLOCK();
@@ -2456,8 +2455,8 @@
/* Mappings between KeySym and Allegro scancodes. */
static struct
{
- KeySym keysym;
- int scancode;
+ KeySym keysym; /* from /usr/include/X11/keysymdef.h */
+ int scancode; /* from include/allegro/keyboard.h */
} _xwin_keysym_to_scancode[] =
{
{ XK_Escape, 0x01 },
@@ -2576,6 +2575,19 @@
{ XK_KP_Enter, 0x1C | 0x80 },
{ XK_KP_Insert, 0x52 },
{ XK_KP_Delete, 0x53 },
+
+ /* missing PAD keys */
+ { XK_KP_1, 0x4F },
+ { XK_KP_2, 0x50 },
+ { XK_KP_3, 0x51 },
+ { XK_KP_4, 0x4B },
+ { XK_KP_5, 0x4C },
+ { XK_KP_6, 0x4D },
+ { XK_KP_7, 0x47 },
+ { XK_KP_8, 0x48 },
+ { XK_KP_9, 0x49 },
+ { XK_KP_0, 0x52 },
+ {XK_KP_Decimal, 0x53 },
{ NoSymbol, 0 },
};