Subject: Patch to force function buttons to be function keys
To: None <port-macppc@netbsd.org>
From: Nathan J. Williams <nathanw@wasabisystems.com>
List: port-macppc
Date: 07/23/2003 18:14:18
--=HAMASMOIS-fraud-bank-high-security-Telex-PLO-Aladdin-Area-51-MD2-SCU
I finally got annoyed at the fact that Mac OS X likes to reprogram the
keyboard controller such that, on by iBook (dual USB), F1-F6 and F12
send "button" events (adjust volume, adjust brightness, eject, etc),
since I use F-keys to switch windows under X in NetBSD. Not knowing
how to reprogram the keyboard controller back (Mac OS 9 can do it, but
it's undone most times I boot into OS X), I came up with this patch
which takes the button events and turns them back into keyboard
events.
Comments?
- Nathan
--=HAMASMOIS-fraud-bank-high-security-Telex-PLO-Aladdin-Area-51-MD2-SCU
Content-Type: text/x-patch
Content-Disposition: attachment; filename=forcefn-diff
Content-Description: Patch to turn f-key \"buttons\" into f-key events.
Index: abtn.c
===================================================================
RCS file: /cvsroot/src/sys/arch/macppc/dev/abtn.c,v
retrieving revision 1.8
diff -u -r1.8 abtn.c
--- abtn.c 2003/07/15 02:43:26 1.8
+++ abtn.c 2003/07/23 22:06:34
@@ -33,6 +33,7 @@
#include <sys/device.h>
#include <sys/systm.h>
+#include <macppc/dev/akbdvar.h>
#include <macppc/dev/adbvar.h>
#include <macppc/dev/pm_direct.h>
@@ -109,6 +110,8 @@
SetADBInfo(&adbinfo, sc->adbaddr);
}
+extern struct cfdriver akbd_cd;
+
void
abtn_adbcomplete(buffer, data, adb_command)
caddr_t buffer, data;
@@ -116,8 +119,42 @@
{
struct abtn_softc *sc = (struct abtn_softc *)data;
u_int cmd;
+#ifdef FORCE_FUNCTION_KEYS
+ int key = 0;
+#endif
cmd = buffer[1];
+
+#ifdef FORCE_FUNCTION_KEYS
+ switch (cmd & 0x7f) {
+ case 0xa: /* f1 */
+ key = 122;
+ break;
+ case 0x9: /* f2 */
+ key = 120;
+ break;
+ case 0x8: /* f3 */
+ key = 99;
+ break;
+ case 0x7: /* f4 */
+ key = 118;
+ break;
+ case 0x6: /* f5 */
+ key = 96;
+ break;
+ case 0x7f: /* f6 */
+ key = 97;
+ break;
+ case 0xb: /* f7 */
+ key = 111;
+ break;
+ }
+ if (key != 0) {
+ key |= cmd & 0x80;
+ kbd_passup(akbd_cd.cd_devs[0],key);
+ return;
+ }
+#endif
if (cmd >= BUTTON_DEPRESS)
return;
Index: akbd.c
===================================================================
RCS file: /cvsroot/src/sys/arch/macppc/dev/akbd.c,v
retrieving revision 1.30
diff -u -r1.30 akbd.c
--- akbd.c 2003/07/15 02:43:27 1.30
+++ akbd.c 2003/07/23 22:06:34
@@ -67,7 +67,6 @@
static void akbdattach __P((struct device *, struct device *, void *));
void kbd_adbcomplete __P((caddr_t buffer, caddr_t data_area, int adb_command));
static void kbd_processevent __P((adb_event_t *event, struct akbd_softc *));
-static void kbd_passup __P((struct akbd_softc *sc, int));
#ifdef notyet
static u_char getleds __P((int));
static int setleds __P((struct akbd_softc *, u_char));
Index: akbdvar.h
===================================================================
RCS file: /cvsroot/src/sys/arch/macppc/dev/akbdvar.h,v
retrieving revision 1.8
diff -u -r1.8 akbdvar.h
--- akbdvar.h 2002/09/05 19:23:11 1.8
+++ akbdvar.h 2003/07/23 22:06:34
@@ -68,5 +68,6 @@
#define LED_SCROLL_LOCK 0x4
void kbd_adbcomplete __P((caddr_t buffer, caddr_t data_area, int adb_command));
+void kbd_passup __P((struct akbd_softc *sc, int));
#endif /* _MACPPC_KBDVAR_H_ */
--=HAMASMOIS-fraud-bank-high-security-Telex-PLO-Aladdin-Area-51-MD2-SCU--