[AD] Linux keyboard LEDs

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Here's a patch to fix the problem.  Currently we're explicitly
setting the states of the LEDs, without affecting the kernel's
caps/num/scroll flags; there is an alternate ioctl to change
just those flags and let the kernel update the LEDs, which seems
to be newer (from `man console_ioctl') but in the kernel source
is commented `don't use them - they will go away without
warning' -- so I stuck with the current system.  Note that using
those, we could read the state according to the kernel and start
with the correct state, rather than defaulting to no flags set.

I've made it reset the LEDs to mirroring the kernel's flags on
exit, which is necessary -- but maybe we should read the old
value and reset that one afterwards, in case someone had
deliberately turned them off or something.  That's pretty
pathological though, in many ways it's more useful if Allegro
does reenable them. :)

George

diff -urN all3929-8/include/xalleg.h all3929-9/include/xalleg.h
--- all3929-8/include/xalleg.h	Thu Jan  1 01:00:00 1970
+++ all3929-9/include/xalleg.h	Sat Dec 18 15:31:12 1999
@@ -0,0 +1,139 @@
+/*         ______   ___    ___
+ *        /\  _  \ /\_ \  /\_ \
+ *        \ \ \L\ \\//\ \ \//\ \      __     __   _ __   ___
+ *         \ \  __ \ \ \ \  \ \ \   /'__`\ /'_ `\/\`'__\/ __`\
+ *          \ \ \/\ \ \_\ \_ \_\ \_/\  __//\ \L\ \ \ \//\ \L\ \
+ *           \ \_\ \_\/\____\/\____\ \____\ \____ \ \_\\ \____/
+ *            \/_/\/_/\/____/\/____/\/____/\/___L\ \/_/ \/___/
+ *                                           /\____/
+ *                                           \_/__/
+ *
+ *      X header file for the Allegro library.
+ *
+ *      This prototypes some things which might be useful to 
+ *      the calling application, but you don't need it.
+ */
+
+
+#ifndef X_ALLEGRO_H
+#define X_ALLEGRO_H
+
+#ifdef __cplusplus
+   extern "C" {
+#endif
+
+#ifndef ALLEGRO_H
+#error Please include allegro.h before xalleg.h!
+#endif
+
+
+#include "allegro/aintern.h"
+#include "allegro/aintunix.h"
+
+#ifdef ALLEGRO_XWINDOWS_WITH_XF86DGA
+#include <pwd.h>
+#endif
+#include <string.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/cursorfont.h>
+#include <X11/keysym.h>
+
+#ifdef ALLEGRO_XWINDOWS_WITH_SHM
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <X11/extensions/XShm.h>
+#endif
+
+#ifdef ALLEGRO_XWINDOWS_WITH_XF86DGA
+#include <X11/extensions/xf86dga.h>
+#include <X11/extensions/xf86vmode.h>
+#endif
+
+
+/* X-Windows resources used by the library.  */
+extern struct _xwin_type
+{
+   Display *display;
+   int screen;
+   Window window;
+   GC gc;
+   Visual *visual;
+   Colormap colormap;
+   XImage *ximage;
+   Cursor cursor;
+   int cursor_shape;
+
+   void (*bank_switch)(int line);
+   void (*screen_to_buffer)(int sx, int sy, int sw, int sh);
+   void (*set_colors)(PALETTE p, int from, int to);
+
+   unsigned char *screen_data;
+   unsigned char **screen_line;
+   unsigned char **buffer_line;
+
+   int scroll_x;
+   int scroll_y;
+
+   int window_width;
+   int window_height;
+   int window_depth;
+
+   int screen_width;
+   int screen_height;
+   int screen_depth;
+
+   int virtual_width;
+   int virtual_height;
+
+   int mouse_warped;
+   int keycode_to_scancode[256];
+
+   int matching_formats;
+   int fast_visual_depth;
+   int visual_is_truecolor;
+
+   int rsize;
+   int gsize;
+   int bsize;
+   int rshift;
+   int gshift;
+   int bshift;
+
+   unsigned long cmap[0x1000];
+   unsigned long rmap[0x100];
+   unsigned long gmap[0x100];
+   unsigned long bmap[0x100];
+
+#ifdef ALLEGRO_XWINDOWS_WITH_SHM
+   XShmSegmentInfo shminfo;
+#endif
+   int use_shm;
+
+#ifdef ALLEGRO_XWINDOWS_WITH_XF86DGA
+   int in_dga_mode;
+   int keyboard_grabbed;
+   int mouse_grabbed;
+
+   XF86VidModeModeInfo **modesinfo;
+   int num_modes;
+#endif
+
+   char window_title[1024];
+   char application_name[1024];
+   char application_class[1024];
+} _xwin;
+
+
+
+AL_METHOD (int, _xwin_window_creator, (void));
+AL_METHOD (void, _xwin_window_defaultor, (void));
+
+
+
+#ifdef __cplusplus
+   }
+#endif
+
+#endif
+
diff -urN all3929-8/src/x/xwin.c all3929-9/src/x/xwin.c
--- all3929-8/src/x/xwin.c	Sun Dec 12 21:51:26 1999
+++ all3929-9/src/x/xwin.c	Sat Dec 18 15:32:08 1999
@@ -50,77 +50,7 @@
 
 
 /* X-Windows resources used by the library.  */
-static struct
-{
-   Display *display;
-   int screen;
-   Window window;
-   GC gc;
-   Visual *visual;
-   Colormap colormap;
-   XImage *ximage;
-   Cursor cursor;
-   int cursor_shape;
-
-   void (*bank_switch)(int line);
-   void (*screen_to_buffer)(int sx, int sy, int sw, int sh);
-   void (*set_colors)(PALETTE p, int from, int to);
-
-   unsigned char *screen_data;
-   unsigned char **screen_line;
-   unsigned char **buffer_line;
-
-   int scroll_x;
-   int scroll_y;
-
-   int window_width;
-   int window_height;
-   int window_depth;
-
-   int screen_width;
-   int screen_height;
-   int screen_depth;
-
-   int virtual_width;
-   int virtual_height;
-
-   int mouse_warped;
-   int keycode_to_scancode[256];
-
-   int matching_formats;
-   int fast_visual_depth;
-   int visual_is_truecolor;
-
-   int rsize;
-   int gsize;
-   int bsize;
-   int rshift;
-   int gshift;
-   int bshift;
-
-   unsigned long cmap[0x1000];
-   unsigned long rmap[0x100];
-   unsigned long gmap[0x100];
-   unsigned long bmap[0x100];
-
-#ifdef ALLEGRO_XWINDOWS_WITH_SHM
-   XShmSegmentInfo shminfo;
-#endif
-   int use_shm;
-
-#ifdef ALLEGRO_XWINDOWS_WITH_XF86DGA
-   int in_dga_mode;
-   int keyboard_grabbed;
-   int mouse_grabbed;
-
-   XF86VidModeModeInfo **modesinfo;
-   int num_modes;
-#endif
-
-   char window_title[1024];
-   char application_name[1024];
-   char application_class[1024];
-} _xwin =
+struct _xwin_type _xwin =
 {
    0,           /* display */
    0,           /* screen */
@@ -434,7 +364,7 @@
    XInstallColormap(_xwin.display, _xwin.colormap);
 
    /* Set default window parameters.  */
-   _xwin_private_set_window_defaults();
+   (*_xwin_window_defaultor)();
 
    /* Map window.  */
    XMapWindow(_xwin.display, _xwin.window);
@@ -485,7 +415,7 @@
 {
    int result;
    DISABLE();
-   result = _xwin_private_create_window();
+   result = (*_xwin_window_creator)();
    ENABLE();
    return result;
 }
@@ -796,7 +726,7 @@
    }
 
    _xwin_private_destroy_ximage();
-   _xwin_private_set_window_defaults();
+   (*_xwin_window_defaultor)();
 }
 
 void _xwin_destroy_screen(void)
@@ -2997,4 +2927,10 @@
    return result;
 }
 #endif
+
+
+
+/* Hook functions */
+int (*_xwin_window_creator)(void) = &_xwin_private_create_window;
+void (*_xwin_window_defaultor)(void) = &_xwin_private_set_window_defaults;
 
diff -urN all3929-8/src/x/xwin.h all3929-9/src/x/xwin.h
--- all3929-8/src/x/xwin.h	Sun Dec 12 21:51:26 1999
+++ all3929-9/src/x/xwin.h	Sat Dec 18 15:29:00 1999
@@ -22,6 +22,8 @@
 extern "C" {
 #endif
 
+#include "xalleg.h"
+
    /* Defined in xwin.c.  */
    AL_VAR(int, _xwin_last_line);
    AL_VAR(int, _xwin_in_gfx_call);


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/