[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Re: swap ctrl<->caps lock problem



just in case anyone is interested: there actually IS a way to swap
capslock and ctrl. use one of the attached kernel patches depending on
your kernel version. these fix the adb weirdness about sending key up
and down events. i didn't come up with this myself (i only did the 2.6
"port") so credits go out to the guy (or girl?) who did this.

for 2.4 kernels use this:

--snip--

--- drivers/macintosh/adbhid.c.orig     Mon Aug 27 21:28:19 2001
+++ drivers/macintosh/adbhid.c  Tue Aug 28 22:05:33 2001
@@ -139,14 +139,46 @@
 {
        int up_flag;
 
+#if 1
+       static int caps_lock_down = 0;
+#endif
+
+#if 1
+       if (1) {
+               /* HACK to fix caps-lock on Powerbook(?) keyboards */
+               switch (keycode) {
+               case 0x39:
+                       caps_lock_down = 1;
+                       break;
+               case 0xff:
+                       if (caps_lock_down) {
+                               /* 'caps-lock' is down, must be
+                                * 'caps-lock' being released
+                                */
+                               caps_lock_down = 0;
+                               keycode = 0xb9;
+                       } else {
+                               /* must be 'caps-lock' being pressed
+                                */
+                               keycode = 0x39;
+                       }
+                       break;
+               }
+       }
+#endif
+
        up_flag = (keycode & 0x80);
        keycode &= 0x7f;
 
        switch (keycode) {
        case 0x39: /* Generate down/up events for CapsLock everytime. */
+if (0) {
                input_report_key(&adbhid[id]->input, KEY_CAPSLOCK, 1);
                input_report_key(&adbhid[id]->input, KEY_CAPSLOCK, 0);
                return;
+} else {
+               break;
+}
        case 0x3f: /* ignore Powerbook Fn key */
                return;
        }

--snap--

and for 2.6 kernels use this:

--snip--

*** adbhid_old.c        Sun Dec 28 22:29:14 2003
--- adbhid.c    Sun Dec 28 22:36:47 2003
***************
*** 167,182 ****
--- 167,215 ----
        struct adbhid *ahid = adbhid[id];
        int up_flag;
  
+ #if 1
+       static int caps_lock_down = 0;
+ #endif
+ 
+ #if 1
+       if (1) {
+               /* HACK to fix caps-lock on Powerbook(?) keyboards */
+               switch (keycode) {
+               case 0x39:
+                       caps_lock_down = 1;
+                       break;
+               case 0xff:
+                       if (caps_lock_down) {
+                               /* 'caps-lock' is down, must be
+                                * 'caps-lock' being released
+                                */
+                               caps_lock_down = 0;
+                               keycode = 0xb9;
+                       } else {
+                               /* must be 'caps-lock' being pressed
+                                */
+                               keycode = 0x39;
+                       }
+                       break;
+               }
+       }
+ #endif
+ 
+ 
        up_flag = (keycode & 0x80);
        keycode &= 0x7f;
  
        switch (keycode) {
        case ADB_KEY_CAPSLOCK: /* Generate down/up events for CapsLock
everytime. */
+       if (0) {
                input_regs(&ahid->input, regs);
                input_report_key(&ahid->input, KEY_CAPSLOCK, 1);
                input_report_key(&ahid->input, KEY_CAPSLOCK, 0);
                input_sync(&ahid->input);
                return;
+       } else {
+               break;
+       }
  #ifdef CONFIG_PPC_PMAC
        case ADB_KEY_POWER_OLD: /* Power key on PBook 3400 needs
remapping */
                switch(pmac_call_feature(PMAC_FTR_GET_MB_INFO,

--snap--

hth,

ali.

-- 
spot-media
Alexander Meyer
Systemadministrator
Lange Reihe 2
20099 Hamburg
Fon:  +49(0)40-248 28 711
Fax:  +49(0)40-248 28 880
mailto:meyer@spot-media.de
http://www.spot-media.de

Key ID: 0xFA4FC80C
Fp: A7EA 9023 88D7 96A3 50C4  957F C38B 0657 FA4F C80C

Attachment: pgpgvSKLowURt.pgp
Description: PGP signature


Reply to: