1 /* William Perry 1997 */
6 #include "console-tty.h"
9 #include "events-mod.h"
16 #if (!defined(__linux__)) /* possible under xterm */
21 #include <linux/keyboard.h>
25 handle_gpm_read (struct Lisp_Event *event, struct console *con, int fd)
32 if (!Gpm_GetEvent(&ev))
36 event->channel = CONSOLE_SELECTED_FRAME (con);
38 /* Whow, wouldn't named defines be NICE!?!?! */
41 if (ev.modifiers & 1) modifiers |= MOD_SHIFT;
42 if (ev.modifiers & 2) modifiers |= MOD_META;
43 if (ev.modifiers & 4) modifiers |= MOD_CONTROL;
44 if (ev.modifiers & 8) modifiers |= MOD_META;
46 if (ev.type & GPM_DOWN)
48 else if (ev.type & GPM_UP)
50 else if (ev.type & GPM_MOVE) {
55 if (ev.buttons & GPM_B_LEFT)
57 else if (ev.buttons & GPM_B_MIDDLE)
59 else if (ev.buttons & GPM_B_RIGHT)
66 type == GPM_DOWN ? button_press_event : button_release_event;
67 event->event.button.x = ev.x;
68 event->event.button.y = ev.y;
69 event->event.button.button = button;
70 event->event.button.modifiers = modifiers;
73 event->event_type = pointer_motion_event;
74 event->event.motion.x = ev.x;
75 event->event.motion.y = ev.y;
76 event->event.motion.modifiers = modifiers;
84 connect_to_gpm (struct console *con)
86 /* Only do this if we are running after dumping and really interactive */
87 if (!noninteractive && initialized) {
88 /* We really only want to do this on a TTY */
89 CONSOLE_TTY_MOUSE_FD (con) = -1;
90 if (EQ (CONSOLE_TYPE (con), Qtty)) {
94 conn.eventMask = GPM_DOWN|GPM_UP|GPM_MOVE;
95 conn.defaultMask = GPM_MOVE;
97 conn.maxMod = ((1<<KG_SHIFT)|(1<<KG_ALT)|(1<<KG_CTRL));
99 rval = Gpm_Open (&conn, 0);
101 case -1: /* General failure */
103 case -2: /* We are running under an XTerm */
107 set_descriptor_non_blocking (gpm_fd);
108 CONSOLE_TTY_MOUSE_FD (con) = gpm_fd;