Hey folks,

and here goes the patch. I hope I've done this Right (TM), but it seems
to work correctly.

Cheers,

Till
? directfb-avifile.pc
? directfb-swf.pc
? lock-key.patch
? log
Index: include/directfb.h
===================================================================
RCS file: /cvs/directfb/DirectFB/include/directfb.h,v
retrieving revision 1.75
diff -u -r1.75 directfb.h
--- include/directfb.h  27 Jan 2002 20:20:58 -0000      1.75
+++ include/directfb.h  1 Feb 2002 22:03:17 -0000
@@ -1806,8 +1806,21 @@
           DIMK_SHIFT          = 0x00000001,  /* any shift key down? */
           DIMK_CTRL           = 0x00000002,  /* any ctrl key down? */
           DIMK_ALT            = 0x00000004,  /* alt key down? */
-          DIMK_ALTGR          = 0x00000008   /* altgr key down? */
+          DIMK_ALTGR          = 0x00000008,  /* altgr key down? */
+          DIMK_CAPS           = 0x00000010,  /* caps-lock key down? */
+          DIMK_NUM            = 0x00000020,  /* num-lock key down? */
+          DIMK_SCROLL         = 0x00000040   /* scroll-lock key down? */
      } DFBInputDeviceModifierKeys;
+
+
+     /*
+      * Flags specifying the keyboard LEDs currently lit
+      */
+     typedef enum {
+          DILS_SCR          = 0x00000001,  /* scroll lock led */
+          DILS_NUM          = 0x00000002,  /* num lock led */
+          DILS_CAP          = 0x00000004   /* cpas lock led */
+     } DFBInputDeviceLEDState;
 
      /*
       * Flags specifying which buttons are currently down.
Index: inputdrivers/keyboard/keyboard.c
===================================================================
RCS file: /cvs/directfb/DirectFB/inputdrivers/keyboard/keyboard.c,v
retrieving revision 1.17
diff -u -r1.17 keyboard.c
--- inputdrivers/keyboard/keyboard.c    27 Jan 2002 16:31:41 -0000      1.17
+++ inputdrivers/keyboard/keyboard.c    1 Feb 2002 22:03:18 -0000
@@ -59,6 +59,7 @@
      InputDevice                *device;
      struct termios              old_ts;
      DFBInputDeviceModifierKeys  modifier_state;
+     DFBInputDeviceLEDState      led_state;
      pthread_t                   thread;
 } KeyboardData;
 
@@ -170,6 +171,14 @@
      return DIKC_UNKNOWN;
 }
 
+#define TOGGLE_LED(flag)       data->led_state & flag ?\
+                                   (data->led_state &= ~flag):\
+                                  (data->led_state |= flag);
+
+#define TOGGLE_LOCK(flag)      data->modifier_state & flag ?\
+                                   (data->modifier_state &= ~flag):\
+                                  (data->modifier_state |= flag);
+
 static DFBInputEvent
 keyboard_handle_code( KeyboardData  *data, unsigned char code )
 {
@@ -193,7 +202,7 @@
      entry.kb_value = 0;
 
      ioctl( dfb_vt->fd, KDGKBENT, &entry );
-
+     ioctl( dfb_vt->fd, KDGETLED, &data->led_state );
      {
           DFBInputEvent event;
 
@@ -227,9 +236,30 @@
                      else
                           data->modifier_state &= ~DIMK_ALTGR;
                      break;
-                default:
+              case DIKC_CAPSLOCK:
+                     if (keydown) {
+                          TOGGLE_LOCK( DIMK_CAPS );
+                         TOGGLE_LED( DILS_CAP );
+                    }
+                    break;
+               case DIKC_NUMLOCK:
+                     if (keydown) {
+                          TOGGLE_LOCK( DIMK_NUM );
+                         TOGGLE_LED( DILS_NUM );
+                    }
+                    break;
+               case DIKC_SCRLOCK:
+                     if (keydown) {
+                          TOGGLE_LOCK( DIMK_SCROLL );
+                         TOGGLE_LED( DILS_SCR );
+                    }
+                    break;
+              default:
                     break;
           }
+         /* set the led lights and the actual flags */
+         ioctl( dfb_vt->fd, KDSETLED, data->led_state );
+         ioctl( dfb_vt->fd, KDSKBLED, data->led_state );
 
           if (data->modifier_state & DIMK_SHIFT) {
                if (data->modifier_state & DIMK_ALT)
@@ -243,6 +273,11 @@
                entry.kb_table = K_ALTTAB;
                ioctl( dfb_vt->fd, KDGKBENT, &entry );
           }
+         if ( ((entry.kb_value & 0xFF00) >> 8 == KT_LETTER) &&
+               (data->modifier_state & DIMK_CAPS)) { 
+              entry.kb_table = K_SHIFTTAB;
+               ioctl( dfb_vt->fd, KDGKBENT, &entry );
+         }
 
           event.modifiers = data->modifier_state;
           event.key_ascii = keyboard_get_ascii( entry.kb_value );

Reply via email to