1 /* 2 * input.h 3 * User input (mouse and keyboard) 4 * AYM 1998-06-16 5 */ 6 7 8 /* 9 This file is part of Yadex. 10 11 Yadex incorporates code from DEU 5.21 that was put in the public domain in 12 1994 by Rapha�l Quinet and Brendon Wyber. 13 14 The rest of Yadex is Copyright � 1997-2003 Andr� Majorel and others. 15 16 This program is free software; you can redistribute it and/or modify it under 17 the terms of the GNU General Public License as published by the Free Software 18 Foundation; either version 2 of the License, or (at your option) any later 19 version. 20 21 This program is distributed in the hope that it will be useful, but WITHOUT 22 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 23 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 24 25 You should have received a copy of the GNU General Public License along with 26 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 27 Place, Suite 330, Boston, MA 02111-1307, USA. 28 */ 29 30 31 typedef unsigned short inpev_t; 32 typedef struct 33 { 34 // Window events 35 int width; // New window width 36 int height; // New window height 37 // Mouse events 38 char in_window; // <>0 iff mouse pointer is in window 39 char butl; // <>0 iff left mouse button is depressed 40 char butm; // <>0 iff middle mouse button is depressed 41 char butr; // <>0 iff right mouse button is depressed 42 int x; // Mouse pointer position 43 int y; 44 // Keyboard 45 char shift; // <>0 iff either [Shift] is pressed 46 char ctrl; // <>0 iff either [Ctrl] is pressed 47 char alt; // <>0 iff either [Alt]/[Meta] is pressed 48 char scroll_lock; // Always 0 for the moment 49 // General 50 inpev_t key; // Code of last event (key, mouse, resize, expose...) 51 unsigned long time; // Date of event in ms (1) 52 } input_status_t; 53 54 /* Notes: 55 (1) Defined only for the following events: key, button, motion 56 enter and leave. 57 */ 58 59 /* Events and key codes */ 60 const inpev_t YK_BACKSPACE = '\b'; 61 const inpev_t YK_TAB = '\t'; 62 const inpev_t YK_RETURN = '\r'; 63 const inpev_t YK_ESC = 0x1b; 64 const inpev_t YK_DEL = 0x7f; 65 const inpev_t YK_ = 256; 66 const inpev_t YK_BACKTAB = 257; 67 const inpev_t YK_DOWN = 258; 68 const inpev_t YK_END = 259; 69 const inpev_t YK_F1 = 260; 70 const inpev_t YK_F2 = 261; 71 const inpev_t YK_F3 = 262; 72 const inpev_t YK_F4 = 263; 73 const inpev_t YK_F5 = 264; 74 const inpev_t YK_F6 = 265; 75 const inpev_t YK_F7 = 266; 76 const inpev_t YK_F8 = 267; 77 const inpev_t YK_F9 = 268; 78 const inpev_t YK_F10 = 269; 79 const inpev_t YK_HOME = 270; 80 const inpev_t YK_INS = 271; 81 const inpev_t YK_LEFT = 272; 82 const inpev_t YK_PU = 273; 83 const inpev_t YK_PD = 274; 84 const inpev_t YK_RIGHT = 275; 85 const inpev_t YK_UP = 276; 86 const inpev_t YK__LAST = 277; // Marks the end of key events 87 88 // Those are not key numbers but window events 89 const inpev_t YE_RESIZE = 278; 90 const inpev_t YE_EXPOSE = 279; 91 92 // Those are not key numbers but mouse events 93 const inpev_t YE_BUTL_PRESS = 280; 94 const inpev_t YE_BUTL_RELEASE = 281; 95 const inpev_t YE_BUTM_PRESS = 282; 96 const inpev_t YE_BUTM_RELEASE = 283; 97 const inpev_t YE_BUTR_PRESS = 284; 98 const inpev_t YE_BUTR_RELEASE = 285; 99 const inpev_t YE_WHEEL_UP = 286; // Negative, normally bound to button 4 100 const inpev_t YE_WHEEL_DOWN = 287; // Positive, normally bound to button 5 101 const inpev_t YE_ENTER = 288; 102 const inpev_t YE_LEAVE = 289; 103 const inpev_t YE_MOTION = 290; 104 105 // Those are not key numbers but application events 106 // (i.e. generated internally) 107 const inpev_t YE_ZOOM_CHANGED = 291; 108 109 // Those are ORed with the other key numbers : 110 const inpev_t YK_SHIFT = 0x2000; 111 const inpev_t YK_CTRL = 0X4000; 112 const inpev_t YK_ALT = 0x8000; 113 114 /* Defined in input.c -- see the comment there */ 115 extern input_status_t is; 116 117 /* Whether c is an "ordinary" character, that is a printable (non- 118 control) character. We cannot use isprint because its argument 119 must be <= 255 and in considers A0H-FFH non-printable. */ 120 #define is_ordinary(c) ((c) < 256 && ((c) & 0x60) && (c) != 0x7f) 121 122 /* Apply this to is.key to find out whether it contains a key press event. */ 123 #define event_is_key(n) (((n) & (YK_SHIFT-1)) > 0 && ((n) & (YK_SHIFT-1)) < YK__LAST) 124 125 void init_input_status (); 126 void get_input_status (); 127 int has_input_event (); 128 int have_key (); 129 int get_key (); 130 void get_key_or_click (); 131 const char *key_to_string (inpev_t k); 132 133 134