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

Re: switch from ADB to linux keycodes ...



>>>>> On Tue, 28 Aug 2001 09:05:36 -0700, "Gregory P. Keeney" <gregory.p.keeney@lmco.com> said:

g> I would recomend not using the diff I posted... There are some problems
g> (which others, more wise than I,predicted). I really don't know anything
g> of how ADB works, and I have no previous experience working with the
g> linux kernel. I really had no grounds to expect my code to work
g> correctly.

        What problems did you experience?  My first attempt was
similar and I noticed that it would occassionally get into a bad
state, as if a spurious 0xff keycode has caused the temp state
variable for the CapsLock key to be "inverted".  The only way to get
out would be to cause another extra 0xff to be generated.  (One way
seems to be to go in and out of "xmon".)

        Has anyone tried the original code for OSX to see if it's
completely stable?

        I've attached a slightly different patch for adbhid.c which
may be a little more tolerant of spurious 0xff keycodes.  You should
be able to hit CapsLock again if it gets into a bad state.  (This only
generates the extra CapsLock press/release events so you still need
something like "loadkeys" to remap to Control.)  Yeah, it's still a
hack and we need something better.
-- 
Gregorio Gervasio, Jr.
gtgj@pacbell.net
--- 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;
 	}

Reply to: