diff -u -N -r linux-2.2.16.orig/CREDITS linux-2.2.16/CREDITS --- linux-2.2.16.orig/CREDITS Tue Apr 11 15:21:23 2000 +++ linux-2.2.16/CREDITS Thu Apr 13 00:01:12 2000 @@ -1683,6 +1683,7 @@ E: vanrein@cs.utwente.nl W: http://www.cs.utwente.nl/~vanrein D: Memory, the BadRAM subsystem dealing with statically challanged RAM modules. +D: Funkey, the support for nonstd function keys through the /dev/funkey device. S: Binnenes 67 S: 9407 CX Assen S: The Netherlands diff -u -N -r linux-2.2.16.orig/Documentation/Configure.help linux-2.2.16/Documentation/Configure.help --- linux-2.2.16.orig/Documentation/Configure.help Tue Apr 11 15:21:24 2000 +++ linux-2.2.16/Documentation/Configure.help Wed Apr 12 23:09:11 2000 @@ -8401,6 +8401,17 @@ or change their colors depending on the virtual console they're on. See Documentation/VGA-softcursor.txt for more information. +Funny Functional Key support +CONFIG_FUNKEY + New keyboards are sometimes equipped with special keys for functions + such as volume control, that should not generate text but invoke a + function instead. Handling through the console is dependent of the + kbd_mode and is generally unsupported under XFree86. + By selecting this option, a character special device /dev/funkey can + be tapped for such keys. + Sail to http://home.zonnet.nl/vanrein/funkey for information and the + matching "funky" daemon. + Support for PowerMac keyboard CONFIG_MAC_KEYBOARD This option allows you to use an ADB keyboard attached to your diff -u -N -r linux-2.2.16.orig/drivers/char/Config.in linux-2.2.16/drivers/char/Config.in --- linux-2.2.16.orig/drivers/char/Config.in Tue Jan 4 19:12:14 2000 +++ linux-2.2.16/drivers/char/Config.in Wed Apr 12 21:12:21 2000 @@ -8,6 +8,7 @@ if [ "$CONFIG_VT" = "y" ]; then bool 'Support for console on virtual terminal' CONFIG_VT_CONSOLE fi +bool 'Funny/Function Key support' CONFIG_FUNKEY tristate 'Standard/generic (dumb) serial support' CONFIG_SERIAL if [ "$CONFIG_SERIAL" = "y" ]; then bool ' Support for console on serial port' CONFIG_SERIAL_CONSOLE Binary files linux-2.2.16.orig/drivers/char/cdcons.rpm and linux-2.2.16/drivers/char/cdcons.rpm differ diff -u -N -r linux-2.2.16.orig/drivers/char/keyboard.c linux-2.2.16/drivers/char/keyboard.c --- linux-2.2.16.orig/drivers/char/keyboard.c Mon Aug 9 21:05:01 1999 +++ linux-2.2.16/drivers/char/keyboard.c Thu Apr 13 00:09:39 2000 @@ -4,6 +4,8 @@ * Written for linux by Johan Myreen as a translation from * the assembly version by Linus (with diacriticals added) * + * Support for /dev/funkey added by Rick van Rein, April 2000 + * * Some additional features added by Christoph Niemann (ChN), March 1993 * * Loadable keymaps by Risto Kankkunen, May 1993 @@ -33,9 +35,11 @@ #include #include #include +#include #include #include +#include #include #include @@ -108,17 +112,25 @@ static k_handfn do_self, do_fn, do_spec, do_pad, do_dead, do_cons, do_cur, do_shift, do_meta, do_ascii, do_lock, do_lowercase, do_slock, do_dead2, +#ifdef CONFIG_FUNKEY + do_funkey, do_ignore; +#else do_ignore; +#endif static k_hand key_handler[16] = { do_self, do_fn, do_spec, do_pad, do_dead, do_cons, do_cur, do_shift, do_meta, do_ascii, do_lock, do_lowercase, do_slock, do_dead2, +#ifdef CONFIG_FUNKEY + do_funkey, do_ignore +#else do_ignore, do_ignore +#endif }; /* Key types processed even in raw modes */ -#define TYPES_ALLOWED_IN_RAW_MODE ((1 << KT_SPEC) | (1 << KT_SHIFT)) +#define TYPES_ALLOWED_IN_RAW_MODE ((1 << KT_SPEC) | (1 << KT_SHIFT) | (1 << KT_FUNKEY)) typedef void (*void_fnp)(void); typedef void (void_fn)(void); @@ -142,7 +154,10 @@ 255, SIZE(func_table) - 1, SIZE(spec_fn_table) - 1, NR_PAD - 1, NR_DEAD - 1, 255, 3, NR_SHIFT - 1, 255, NR_ASCII - 1, NR_LOCK - 1, 255, - NR_LOCK - 1, 255 + NR_LOCK - 1, 255, +#ifdef CONFIG_FUNKEY + 127, +#endif }; const int NR_TYPES = SIZE(max_vals); @@ -381,6 +396,33 @@ put_queue(10); } +#ifdef CONFIG_FUNKEY + +static struct wait_queue * funkey_wait = NULL; +static unsigned char funkey_queue [256]; +static unsigned char funkey_wpos=0; +static unsigned char funkey_rpos=0; + +void put_funkey_queue (int ch) +{ + funkey_queue [funkey_wpos++] = ch & 0xff; + if (funkey_wpos != funkey_rpos) { + wake_up(&funkey_wait); + } +} + +unsigned char get_funkey_queue (void) +{ + if (funkey_wpos == funkey_rpos) { + interruptible_sleep_on (&funkey_wait); + if (funkey_wpos == funkey_rpos) + return 0; + } + return funkey_queue [funkey_rpos++]; +} + +#endif + static void caps_toggle(void) { if (rep) @@ -637,6 +679,15 @@ printk(KERN_ERR "do_fn called with value=%d\n", value); } +#ifdef CONFIG_FUNKEY +static void do_funkey(unsigned char value, char up_flag) +{ + if (up_flag) + value |= 0x80; + put_funkey_queue (value); +} +#endif + static void do_pad(unsigned char value, char up_flag) { static const char *pad_chars = "0123456789+-*/\015,.?()"; @@ -885,6 +936,71 @@ return leds; } + +#ifdef CONFIG_FUNKEY + +ssize_t read_funkey (struct file *f, char *buf, size_t toget, loff_t *offs) +{ + unsigned char keycode=get_funkey_queue (); + int err; + if (!keycode) + return -EINTR; + if (err=verify_area (VERIFY_WRITE, buf, 1L)) + return err; + put_user (keycode, buf); + return 1; +} + +ssize_t write_funkey (struct file *f, char *buf, size_t toget, loff_t *offs) +{ + return -EINVAL; +} + +static int funkey_opencnt=0; +int open_funkey (struct inode *in, struct file *f) +{ + if (funkey_opencnt) + return -EBUSY; + funkey_opencnt++; + funkey_rpos=funkey_wpos; + return 0; +} + +int close_funkey (struct inode *in, struct file *f) +{ + funkey_opencnt--; + return 0; +} + +/* The /dev/funkey device broadcasts the key codes from the + * keyboard, regardless of the kbd_mode of the console and regardless of + * settings in the keymaps. + */ +static struct file_operations funkey_file_operations = { + NULL, /* seek */ + read_funkey, + write_funkey, + NULL, /* readdir */ + NULL, /* poll */ + NULL, /* ioctl */ + NULL, /* mmap */ + open_funkey, + NULL, /* flush */ + close_funkey, + NULL, /* revalidate */ + NULL /* sync */ +}; + + + +void init_dev_funkey (void) +{ + register_chrdev (0, "funkey", &funkey_file_operations); +} + +#endif + + /* * This routine is the bottom half of the keyboard interrupt * routine, and runs with all interrupts enabled. It does @@ -929,5 +1045,10 @@ kbd_init_hw(); init_bh(KEYBOARD_BH, kbd_bh); mark_bh(KEYBOARD_BH); + +#ifdef CONFIG_FUNKEY + init_dev_funkey (); +#endif + return 0; } diff -u -N -r linux-2.2.16.orig/drivers/char/testkeys linux-2.2.16/drivers/char/testkeys --- linux-2.2.16.orig/drivers/char/testkeys Thu Jan 1 01:00:00 1970 +++ linux-2.2.16/drivers/char/testkeys Wed Apr 12 23:00:20 2000 @@ -0,0 +1 @@ +keycode 123 = F40 diff -u -N -r linux-2.2.16.orig/include/linux/keyboard.h linux-2.2.16/include/linux/keyboard.h --- linux-2.2.16.orig/include/linux/keyboard.h Thu Jul 30 20:17:12 1998 +++ linux-2.2.16/include/linux/keyboard.h Wed Apr 12 22:15:16 2000 @@ -43,6 +43,7 @@ #define KT_ASCII 9 #define KT_LOCK 10 #define KT_SLOCK 12 +#define KT_FUNKEY 14 #define K(t,v) (((t)<<8)|(v)) #define KTYP(x) ((x) >> 8)