From 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 Mon Sep 17 00:00:00 2001 From: Joe Hunkeler Date: Tue, 11 Aug 2015 16:51:37 -0400 Subject: Repatch (from linux) of OSX IRAF --- unix/sun/arrow.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 unix/sun/arrow.c (limited to 'unix/sun/arrow.c') diff --git a/unix/sun/arrow.c b/unix/sun/arrow.c new file mode 100644 index 00000000..1cc55aad --- /dev/null +++ b/unix/sun/arrow.c @@ -0,0 +1,66 @@ +/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + */ + +#include +#include +#include + +/* + * ARROW.C -- Code to enable and disable the arrow key function-key mappings + * (R8,10,12,14). + */ + +#define NKEYS 4 +static unsigned char station[NKEYS] = { 0x45, 0x5b, 0x5d, 0x71 }; +static unsigned char entry[NKEYS] = { RF(8), RF(10), RF(12), RF(14) }; +static struct kiockey o_key[NKEYS]; + + +/* DISABLE_ARROW_KEYS -- Save the arrow key keyboard translation table + * entries, and then disable the mapping of the function keys to the ANSI + * arrow key sequences. This is necessary to read the function key as + * an event rather than an escape sequence in a Sunview event handler. + */ +disable_arrow_keys() +{ + register int fd, i; + struct kiockey key; + int status = 0; + + if ((fd = open ("/dev/kbd", 2)) == -1) + return (-1); + + for (i=0; i < NKEYS; i++) { + o_key[i].kio_station = station[i]; + if ((status = ioctl (fd, KIOCGETKEY, &o_key[i])) != 0) + break; + key = o_key[i]; + key.kio_entry = entry[i]; + if ((status = ioctl (fd, KIOCSETKEY, &key)) != 0) + break; + } + + close (fd); + return (status); +} + + +/* ENABLE_ARROW_KEYS -- Restore the saved arrow key keyboard translation table + * entries. + */ +enable_arrow_keys() +{ + register int fd, i; + struct kiockey key; + int status = 0; + + if ((fd = open ("/dev/kbd", 2)) == -1) + return (-1); + + for (i=0; i < NKEYS; i++) + if ((status = ioctl (fd, KIOCSETKEY, &o_key[i])) != 0) + break; + + close (fd); + return (status); +} -- cgit