summaryrefslogtreecommitdiff
path: root/console-client/pc-kbd.c
diff options
context:
space:
mode:
authorMarco Gerards <marco@gnu.org>2005-01-06 21:43:53 +0000
committerMarco Gerards <marco@gnu.org>2005-01-06 21:43:53 +0000
commit38fc4e4d1cef98a8b3d60b717647a9c65d91307f (patch)
tree805792e935ebbf353301070209d0af1aea1d908f /console-client/pc-kbd.c
parent4456094d61a6f5baabadc18096fc1f516921b736 (diff)
2005-01-06 Marco Gerards <metgerards@student.han.nl>
* Makefile (SRCS): Add `trans.c'. (LCLHDRS): Add `mach-inputdev.h'. (HURDLIBS): Add `netfs', `fshelp' and `iohelp'. (modules): Add `pc_mouse'. (pc_kbd.so.$(hurd-version)): Add `kdioctlServer.o' and `kbd-repeat.c'. (pc_mouse.so.$(hurd-version)): New variable. * console.c: Include <trans.h>. (DEFAULT_CONSOLE_NODE): New macro. (saved_id, saved_cons, consnode_path): New variables. (console_move_mouse): New function. (console_switch_away): New function. (console_switch_back): Likewise. (cons_vcons_set_mousecursor_pos): Likewise. (cons_vcons_set_mousecursor_status): Likewise. (options): Add the option `--console-node'. (parse_opt): Parse the options that were added to `options'. (main): Setup the console client translator node. * display.h (display_ops): New members `set_mousecursor_pos' and `set_mousecursor_status'. * driver.c (driver_start): Change the type of `i' to `unsigned int'. * driver.h (driver_ops): New members `save_status' and `restore_status'. * input.h (console_switch_away): New prototype. (console_switch_back): Likewise. (console_move_mouse): Likewise. * kbd-repeat.c: New file. * mach-inputdev.h: Likewise. * pc-mouse.c: Likewise. * trans.c: Likewise. * trans.h: Likewise. * pc-kbd.c: Include <argp.h> and "mach-inputdev.h". (DEFAULT_REPEATER_NODE): New macro. (repeater_node, cnode): New variables. (kev_type, mouse_motion, Scancode, m_deltaX, m_deltaY, MOUSE_LEFT) (MOUSE_MIDDLE, MOUSE_RIGHT, MOUSE_MOTION, KEYBD_EVENT) (IOCPARM_MASK, IOC_OUT, IOC_IN, _IOC, _IOR, _IOW, KDSKBDMODE, (KB_EVENT, KB_ASCII, KDGKBDTYPE, KB_VANILLAKB, KDSETLEDS): Removed. (gnumach_v1_input_next): Call the repeater when repeating is active. (doc, options, argp): New variables. (parse_opt): New function. (pc_kbd_init): Function rewritten. (pc_kbd_start): Initialize the repeater, when it is active. (pc_kbd_fini): Destroy the console node. * vga.c (vga_mousecursor): New struct. (vga_mousecursor_t): New type. (mousecursor): New variable. (hide_mousecursor): New function. (draw_mousecursor): Likewise. (vga_display_restore_status): Likewise. (vga_display_update): Likewise. (vga_set_mousecursor_pos): Likewise. (vga_set_mousecursor_status): Likewise. (vga_display_scroll): Update the mousecursor state. (driver_vga_ops): Add `vga_display_restore_status'. (vga_display_op): Add `vga_display_update', `vga_set_mousecursor_pos' and `vga_set_mousecursor_status'.
Diffstat (limited to 'console-client/pc-kbd.c')
-rw-r--r--console-client/pc-kbd.c153
1 files changed, 71 insertions, 82 deletions
diff --git a/console-client/pc-kbd.c b/console-client/pc-kbd.c
index 485eace1..35e25617 100644
--- a/console-client/pc-kbd.c
+++ b/console-client/pc-kbd.c
@@ -1,5 +1,5 @@
/* pc-kbd.c - The PC Keyboard input driver.
- Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc.
Written by Marcus Brinkmann.
This file is part of the GNU Hurd.
@@ -23,6 +23,7 @@
#include <string.h>
#include <iconv.h>
#include <sys/mman.h>
+#include <argp.h>
#include <device/device.h>
#include <cthreads.h>
@@ -31,8 +32,12 @@
#include <hurd/cons.h>
#include "driver.h"
+#include "mach-inputdev.h"
+/* The default name of the node of the repeater. */
+#define DEFAULT_REPEATER_NODE "kbd"
+
/* The keyboard device in the kernel. */
static device_t kbd_dev;
@@ -52,6 +57,11 @@ int gnumach_v1_compat;
/* Forward declaration. */
static struct input_ops pc_kbd_ops;
+/* The name of the repeater node. */
+static char *repeater_node;
+
+/* The repeater node. */
+static consnode_t cnode;
/* A list of scan codes generated by the keyboard, in the set 2 encoding. */
enum scancode
@@ -558,87 +568,6 @@ enum scancode sc_set1_to_set2_x1[] =
SC_X1_DEL
};
-
-/* This gross stuff is cut & pasted from Mach sources, as Mach doesn't
- export the interface we are using here. */
-
-/*
- * Mach Operating System
- * Copyright (c) 1991,1990,1989 Carnegie Mellon University
- * All Rights Reserved.
- *
- * Permission to use, copy, modify and distribute this software and its
- * documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
- * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie Mellon
- * the rights to redistribute these changes.
- */
-
-typedef u_short kev_type; /* kd event type */
-
-/* (used for event records) */
-struct mouse_motion {
- short mm_deltaX; /* units? */
- short mm_deltaY;
-};
-typedef u_char Scancode;
-
-typedef struct {
- kev_type type; /* see below */
- struct timeval time; /* timestamp */
- union { /* value associated with event */
- boolean_t up; /* MOUSE_LEFT .. MOUSE_RIGHT */
- Scancode sc; /* KEYBD_EVENT */
- struct mouse_motion mmotion; /* MOUSE_MOTION */
- } value;
-} kd_event;
-#define m_deltaX mmotion.mm_deltaX
-#define m_deltaY mmotion.mm_deltaY
-
-/*
- * kd_event ID's.
- */
-#define MOUSE_LEFT 1 /* mouse left button up/down */
-#define MOUSE_MIDDLE 2
-#define MOUSE_RIGHT 3
-#define MOUSE_MOTION 4 /* mouse motion */
-#define KEYBD_EVENT 5 /* key up/down */
-
-
-#define IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */
-#define IOC_OUT 0x40000000 /* copy out parameters */
-#define IOC_IN 0x80000000U /* copy in parameters */
-#define _IOC(inout,group,num,len) \
- (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num))
-#define _IOR(g,n,t) _IOC(IOC_OUT, (g), (n), sizeof(t))
-#define _IOW(g,n,t) _IOC(IOC_IN, (g), (n), sizeof(t))
-
-#define KDSKBDMODE _IOW('K', 1, int) /* set keyboard mode */
-#define KB_EVENT 1
-#define KB_ASCII 2
-
-#define KDGKBDTYPE _IOR('K', 2, int) /* get keyboard type */
-#define KB_VANILLAKB 0
-
-#define KDSETLEDS _IOW('K', 5, int) /* set keyboard leds */
-
-
-/* End of Mach code. */
-
static enum scancode
gnumach_v1_input_next ()
{
@@ -658,6 +587,13 @@ gnumach_v1_input_next ()
terminate. */
if (err)
return 0;
+
+ if (kbd_repeater_opened && data_buf.type == KEYBD_EVENT)
+ {
+ kbd_repeat_key (&data_buf);
+ data_buf.type = 0;
+ continue;
+ }
}
while (data_buf.type != KEYBD_EVENT);
@@ -1090,10 +1026,56 @@ input_loop (any_t unused)
+
+static const char doc[] = "PC Keyboard Driver";
+
+static const struct argp_option options[] =
+ {
+ {"repeat", 'r', "NODE", OPTION_ARG_OPTIONAL,
+ "Set a repeater translator on NODE (default: " DEFAULT_REPEATER_NODE ")"},
+ { 0 }
+ };
+
+static error_t
+parse_opt (int key, char *arg, struct argp_state *state)
+{
+ int *pos = (int *) state->input;
+
+ switch (key)
+ {
+ case 'r':
+ repeater_node = arg ? arg: DEFAULT_REPEATER_NODE;
+ break;
+
+ case ARGP_KEY_END:
+ break;
+
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+
+ *pos = state->next;
+ return 0;
+}
+
+static struct argp argp = {options, parse_opt, 0, doc};
+
/* Initialize the PC keyboard driver. */
static error_t
pc_kbd_init (void **handle, int no_exit, int argc, char *argv[], int *next)
{
+ error_t err;
+ int pos = 1;
+
+ /* Parse the arguments. */
+ err = argp_parse (&argp, argc, argv, ARGP_IN_ORDER | ARGP_NO_EXIT
+ | ARGP_SILENT, 0 , &pos);
+ *next += pos - 1;
+
+ if (err && err != EINVAL)
+ return err;
+
+
return 0;
}
@@ -1158,6 +1140,10 @@ pc_kbd_start (void *handle)
iconv_close (cd);
return err;
}
+
+ if (repeater_node)
+ kbd_setrepeater (repeater_node, &cnode);
+
cthread_detach (cthread_fork (input_loop, NULL));
return 0;
@@ -1177,6 +1163,9 @@ pc_kbd_fini (void *handle, int force)
mach_port_deallocate (mach_task_self (), kbd_dev);
iconv_close (cd);
+ console_unregister_consnode (cnode);
+ console_destroy_consnode (cnode);
+
return 0;
}