Changeset 215abc1 in mainline
- Timestamp:
- 2009-06-03T18:49:33Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 05b9912
- Parents:
- bbdbf86
- Location:
- uspace/srv/kbd
- Files:
-
- 12 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/kbd/Makefile
rbbdbf86 r215abc1 47 47 genarch/gsp.c \ 48 48 genarch/stroke.c \ 49 generic/key _buffer.c49 generic/keybuffer.c 50 50 51 51 ARCH_SOURCES = -
uspace/srv/kbd/ctl/gxe_fb.c
rbbdbf86 r215abc1 37 37 38 38 #include <kbd.h> 39 #include < kbd/kbd.h>40 #include < kbd/keycode.h>39 #include <io/console.h> 40 #include <io/keycode.h> 41 41 #include <kbd_ctl.h> 42 42 #include <gsp.h> -
uspace/srv/kbd/ctl/pc.c
rbbdbf86 r215abc1 33 33 /** 34 34 * @file 35 * @brief 35 * @brief PC keyboard controller driver. 36 36 */ 37 37 38 38 #include <kbd.h> 39 #include < kbd/kbd.h>40 #include < kbd/keycode.h>39 #include <io/console.h> 40 #include <io/keycode.h> 41 41 #include <kbd_ctl.h> 42 42 #include <gsp.h> … … 189 189 void kbd_ctl_parse_scancode(int scancode) 190 190 { 191 kbd_ev_type_t type;191 console_ev_type_t type; 192 192 unsigned int key; 193 193 int *map; … … 214 214 if (scancode & 0x80) { 215 215 scancode &= ~0x80; 216 type = KE _RELEASE;216 type = KEY_RELEASE; 217 217 } else { 218 type = KE _PRESS;218 type = KEY_PRESS; 219 219 } 220 220 -
uspace/srv/kbd/ctl/stty.c
rbbdbf86 r215abc1 37 37 38 38 #include <kbd.h> 39 #include <kbd/kbd.h> 40 #include <kbd/keycode.h> 39 #include <io/keycode.h> 41 40 #include <kbd_ctl.h> 42 41 #include <gsp.h> -
uspace/srv/kbd/ctl/sun.c
rbbdbf86 r215abc1 37 37 38 38 #include <kbd.h> 39 #include < kbd/kbd.h>40 #include < kbd/keycode.h>39 #include <io/console.h> 40 #include <io/keycode.h> 41 41 #include <kbd_ctl.h> 42 42 … … 53 53 void kbd_ctl_parse_scancode(int scancode) 54 54 { 55 kbd_ev_type_t type;55 console_ev_type_t type; 56 56 unsigned int key; 57 57 … … 64 64 if (scancode & KBD_KEY_RELEASE) { 65 65 scancode &= ~KBD_KEY_RELEASE; 66 type = KE _RELEASE;66 type = KEY_RELEASE; 67 67 } else { 68 type = KE _PRESS;68 type = KEY_PRESS; 69 69 } 70 70 -
uspace/srv/kbd/genarch/stroke.c
rbbdbf86 r215abc1 32 32 /** 33 33 * @file 34 * @brief 34 * @brief Stroke simulator. 35 35 * 36 36 * When simulating a keyboard using a serial TTY we need to convert the 37 37 * recognized strokes (such as Shift-A) to sequences of key presses and 38 38 * releases (such as 'press Shift, press A, release A, release Shift'). 39 * 39 40 */ 40 41 41 42 #include <stroke.h> 42 43 #include <kbd.h> 43 #include < kbd/kbd.h>44 #include < kbd/keycode.h>44 #include <io/console.h> 45 #include <io/keycode.h> 45 46 46 47 /** Correspondence between modifers and the modifier keycodes. */ … … 59 60 while (mods_keys[i][0] != 0) { 60 61 if (mod & mods_keys[i][0]) { 61 kbd_push_ev(KE _PRESS, mods_keys[i][1]);62 kbd_push_ev(KEY_PRESS, mods_keys[i][1]); 62 63 } 63 64 ++i; … … 66 67 /* Simulate key press and release. */ 67 68 if (key != 0) { 68 kbd_push_ev(KE _PRESS, key);69 kbd_push_ev(KE _RELEASE, key);69 kbd_push_ev(KEY_PRESS, key); 70 kbd_push_ev(KEY_RELEASE, key); 70 71 } 71 72 … … 74 75 while (mods_keys[i][0] != 0) { 75 76 if (mod & mods_keys[i][0]) { 76 kbd_push_ev(KE _RELEASE, mods_keys[i][1]);77 kbd_push_ev(KEY_RELEASE, mods_keys[i][1]); 77 78 } 78 79 ++i; … … 82 83 /** 83 84 * @} 84 */ 85 */ -
uspace/srv/kbd/generic/kbd.c
rbbdbf86 r215abc1 29 29 /** 30 30 * @addtogroup kbdgen generic 31 * @brief 32 * @ingroup 31 * @brief HelenOS generic uspace keyboard handler. 32 * @ingroup kbd 33 33 * @{ 34 */ 34 */ 35 35 /** @file 36 36 */ … … 47 47 #include <errno.h> 48 48 #include <libadt/fifo.h> 49 #include < kbd/kbd.h>50 #include < kbd/keycode.h>49 #include <io/console.h> 50 #include <io/keycode.h> 51 51 52 52 #include <kbd.h> 53 #include <key _buffer.h>53 #include <keybuffer.h> 54 54 #include <kbd_port.h> 55 55 #include <kbd_ctl.h> … … 89 89 void kbd_push_ev(int type, unsigned int key) 90 90 { 91 kbd_event_t ev;91 console_event_t ev; 92 92 unsigned mod_mask; 93 93 … … 103 103 104 104 if (mod_mask != 0) { 105 if (type == KE _PRESS)105 if (type == KEY_PRESS) 106 106 mods = mods | mod_mask; 107 107 else … … 117 117 118 118 if (mod_mask != 0) { 119 if (type == KE _PRESS) {119 if (type == KEY_PRESS) { 120 120 /* 121 121 * Only change lock state on transition from released … … 134 134 printf("keycode: %u\n", key); 135 135 */ 136 if (type == KE _PRESS && (mods & KM_LCTRL) &&136 if (type == KEY_PRESS && (mods & KM_LCTRL) && 137 137 key == KC_F1) { 138 138 active_layout = 0; … … 141 141 } 142 142 143 if (type == KE _PRESS && (mods & KM_LCTRL) &&143 if (type == KEY_PRESS && (mods & KM_LCTRL) && 144 144 key == KC_F2) { 145 145 active_layout = 1; … … 148 148 } 149 149 150 if (type == KE _PRESS && (mods & KM_LCTRL) &&150 if (type == KEY_PRESS && (mods & KM_LCTRL) && 151 151 key == KC_F3) { 152 152 active_layout = 2; -
uspace/srv/kbd/generic/keybuffer.c
rbbdbf86 r215abc1 28 28 29 29 /** @addtogroup kbdgen 30 * @brief 31 * @ingroup 30 * @brief HelenOS generic uspace keyboard handler. 31 * @ingroup kbd 32 32 * @{ 33 */ 33 */ 34 34 /** @file 35 35 */ 36 #include <key_buffer.h> 36 37 #include <keybuffer.h> 37 38 #include <futex.h> 38 39 … … 59 60 60 61 /** Get free space in buffer. 61 * This function is useful for processing some scancodes that are translated 62 * 63 * This function is useful for processing some scancodes that are translated 62 64 * to more than one character. 65 * 63 66 * @return empty buffer space 67 * 64 68 */ 65 int keybuffer_available(keybuffer_t *keybuffer)69 size_t keybuffer_available(keybuffer_t *keybuffer) 66 70 { 67 71 return KEYBUFFER_SIZE - keybuffer->items; … … 69 73 70 74 /** 75 * 71 76 * @return nonzero, if buffer is not empty. 77 * 72 78 */ 73 intkeybuffer_empty(keybuffer_t *keybuffer)79 bool keybuffer_empty(keybuffer_t *keybuffer) 74 80 { 75 81 return (keybuffer->items == 0); … … 80 86 * If the buffer is full, the event is ignored. 81 87 * 82 * @param keybuffer The keybuffer. 83 * @param ev The event to push. 88 * @param keybuffer The keybuffer. 89 * @param ev The event to push. 90 * 84 91 */ 85 void keybuffer_push(keybuffer_t *keybuffer, const kbd_event_t *ev)92 void keybuffer_push(keybuffer_t *keybuffer, const console_event_t *ev) 86 93 { 87 94 futex_down(&keybuffer_futex); 95 88 96 if (keybuffer->items < KEYBUFFER_SIZE) { 89 97 keybuffer->fifo[keybuffer->tail] = *ev; … … 91 99 keybuffer->items++; 92 100 } 101 93 102 futex_up(&keybuffer_futex); 94 103 } … … 96 105 /** Pop event from buffer. 97 106 * 98 * @param edst Pointer to where the event should be saved. 99 * @return Zero on empty buffer, nonzero otherwise. 107 * @param edst Pointer to where the event should be saved. 108 * 109 * @return True if an event was popped. 110 * 100 111 */ 101 int keybuffer_pop(keybuffer_t *keybuffer, kbd_event_t *edst)112 bool keybuffer_pop(keybuffer_t *keybuffer, console_event_t *edst) 102 113 { 103 114 futex_down(&keybuffer_futex); 115 104 116 if (keybuffer->items > 0) { 105 117 keybuffer->items--; 106 *edst = (keybuffer->fifo[keybuffer->head]) 118 *edst = (keybuffer->fifo[keybuffer->head]); 107 119 keybuffer->head = (keybuffer->head + 1) % KEYBUFFER_SIZE; 108 120 futex_up(&keybuffer_futex); 109 return 1; 121 122 return true; 110 123 } 124 111 125 futex_up(&keybuffer_futex); 112 return 0; 126 127 return false; 113 128 } 114 129 115 130 /** 116 131 * @} 117 */ 132 */ -
uspace/srv/kbd/include/kbd.h
rbbdbf86 r215abc1 28 28 29 29 /** @addtogroup kbdgen generic 30 * @brief 31 * @ingroup 30 * @brief HelenOS generic uspace keyboard handler. 31 * @ingroup kbd 32 32 * @{ 33 */ 33 */ 34 34 /** @file 35 35 */ … … 38 38 #define KBD_KBD_H_ 39 39 40 #include <key _buffer.h>40 #include <keybuffer.h> 41 41 #include <ipc/ipc.h> 42 42 43 #define KBD_EVENT 44 #define KBD_MS_LEFT 45 #define KBD_MS_RIGHT 46 #define KBD_MS_MIDDLE 47 #define KBD_MS_MOVE 43 #define KBD_EVENT 1024 44 #define KBD_MS_LEFT 1025 45 #define KBD_MS_RIGHT 1026 46 #define KBD_MS_MIDDLE 1027 47 #define KBD_MS_MOVE 1028 48 48 49 49 typedef enum { 50 KBD_YIELD 50 KBD_YIELD = IPC_FIRST_USER_METHOD, 51 51 KBD_RECLAIM 52 52 } kbd_request_t; … … 62 62 /** 63 63 * @} 64 */ 65 64 */ -
uspace/srv/kbd/include/keybuffer.h
rbbdbf86 r215abc1 28 28 29 29 /** @addtogroup kbdgen 30 * @brief 31 * @ingroup 30 * @brief HelenOS generic uspace keyboard handler. 31 * @ingroup kbd 32 32 * @{ 33 */ 33 */ 34 34 /** @file 35 35 */ 36 36 37 #ifndef __KEY _BUFFER_H__38 #define __KEY _BUFFER_H__37 #ifndef __KEYBUFFER_H__ 38 #define __KEYBUFFER_H__ 39 39 40 40 #include <sys/types.h> 41 #include <kbd/kbd.h> 41 #include <io/console.h> 42 #include <bool.h> 42 43 43 44 /** Size of buffer for pressed keys */ 44 #define KEYBUFFER_SIZE 12845 #define KEYBUFFER_SIZE 128 45 46 46 47 typedef struct { 47 kbd_event_t fifo[KEYBUFFER_SIZE];48 console_event_t fifo[KEYBUFFER_SIZE]; 48 49 unsigned long head; 49 50 unsigned long tail; … … 53 54 extern void keybuffer_free(keybuffer_t *); 54 55 extern void keybuffer_init(keybuffer_t *); 55 extern int keybuffer_available(keybuffer_t *);56 extern intkeybuffer_empty(keybuffer_t *);57 extern void keybuffer_push(keybuffer_t *, const kbd_event_t *);58 extern int keybuffer_pop(keybuffer_t *, kbd_event_t *);56 extern size_t keybuffer_available(keybuffer_t *); 57 extern bool keybuffer_empty(keybuffer_t *); 58 extern void keybuffer_push(keybuffer_t *, const console_event_t *); 59 extern bool keybuffer_pop(keybuffer_t *, console_event_t *); 59 60 60 61 #endif … … 62 63 /** 63 64 * @} 64 */ 65 65 */ -
uspace/srv/kbd/include/layout.h
rbbdbf86 r215abc1 28 28 29 29 /** @addtogroup kbdgen generic 30 * @brief 31 * @ingroup 30 * @brief HelenOS generic uspace keyboard handler. 31 * @ingroup kbd 32 32 * @{ 33 */ 33 */ 34 34 /** @file 35 35 */ … … 38 38 #define KBD_LAYOUT_H_ 39 39 40 #include <kbd/kbd.h>41 40 #include <sys/types.h> 41 #include <io/console.h> 42 42 43 43 typedef struct { 44 44 void (*reset)(void); 45 wchar_t (*parse_ev)( kbd_event_t *);45 wchar_t (*parse_ev)(console_event_t *); 46 46 } layout_op_t; 47 47 … … 54 54 /** 55 55 * @} 56 */ 57 56 */ -
uspace/srv/kbd/layout/cz.c
rbbdbf86 r215abc1 28 28 29 29 /** @addtogroup kbd 30 * @brief 30 * @brief US QWERTY leyout. 31 31 * @{ 32 */ 32 */ 33 33 34 34 #include <kbd.h> 35 #include < kbd/kbd.h>36 #include < kbd/keycode.h>35 #include <io/console.h> 36 #include <io/keycode.h> 37 37 #include <bool.h> 38 38 #include <layout.h> 39 39 40 40 static void layout_reset(void); 41 static wchar_t layout_parse_ev( kbd_event_t *ev);41 static wchar_t layout_parse_ev(console_event_t *ev); 42 42 43 43 enum m_state { 44 44 ms_start, 45 45 ms_hacek, 46 ms_carka 46 ms_carka 47 47 }; 48 48 … … 273 273 } 274 274 275 static wchar_t parse_ms_hacek( kbd_event_t *ev)275 static wchar_t parse_ms_hacek(console_event_t *ev) 276 276 { 277 277 wchar_t c; … … 291 291 } 292 292 293 static wchar_t parse_ms_carka( kbd_event_t *ev)293 static wchar_t parse_ms_carka(console_event_t *ev) 294 294 { 295 295 wchar_t c; … … 309 309 } 310 310 311 static wchar_t parse_ms_start( kbd_event_t *ev)311 static wchar_t parse_ms_start(console_event_t *ev) 312 312 { 313 313 wchar_t c; … … 384 384 } 385 385 386 static wchar_t layout_parse_ev( kbd_event_t *ev)387 { 388 if (ev->type != KE _PRESS)389 return '\0';390 386 static wchar_t layout_parse_ev(console_event_t *ev) 387 { 388 if (ev->type != KEY_PRESS) 389 return 0; 390 391 391 if (key_is_mod(ev->key)) 392 return '\0';393 392 return 0; 393 394 394 switch (mstate) { 395 case ms_start: return parse_ms_start(ev); 396 case ms_hacek: return parse_ms_hacek(ev); 397 case ms_carka: return parse_ms_carka(ev); 395 case ms_start: 396 return parse_ms_start(ev); 397 case ms_hacek: 398 return parse_ms_hacek(ev); 399 case ms_carka: 400 return parse_ms_carka(ev); 398 401 } 399 402 } … … 401 404 /** 402 405 * @} 403 */ 406 */ -
uspace/srv/kbd/layout/us_dvorak.c
rbbdbf86 r215abc1 33 33 34 34 #include <kbd.h> 35 #include < kbd/kbd.h>36 #include < kbd/keycode.h>35 #include <io/console.h> 36 #include <io/keycode.h> 37 37 #include <layout.h> 38 38 39 39 static void layout_reset(void); 40 static wchar_t layout_parse_ev( kbd_event_t *ev);40 static wchar_t layout_parse_ev(console_event_t *ev); 41 41 42 42 layout_op_t us_dvorak_op = { … … 210 210 } 211 211 212 static wchar_t layout_parse_ev( kbd_event_t *ev)212 static wchar_t layout_parse_ev(console_event_t *ev) 213 213 { 214 214 wchar_t c; -
uspace/srv/kbd/layout/us_qwerty.c
rbbdbf86 r215abc1 33 33 34 34 #include <kbd.h> 35 #include < kbd/kbd.h>36 #include < kbd/keycode.h>35 #include <io/console.h> 36 #include <io/keycode.h> 37 37 #include <layout.h> 38 38 39 39 static void layout_reset(void); 40 static wchar_t layout_parse_ev( kbd_event_t *ev);40 static wchar_t layout_parse_ev(console_event_t *ev); 41 41 42 42 layout_op_t us_qwerty_op = { … … 204 204 } 205 205 206 static wchar_t layout_parse_ev( kbd_event_t *ev)206 static wchar_t layout_parse_ev(console_event_t *ev) 207 207 { 208 208 wchar_t c;
Note:
See TracChangeset
for help on using the changeset viewer.