Changeset b6f2ebc in mainline for kernel/genarch/src/kbrd/kbrd.c
- Timestamp:
- 2009-03-12T17:52:33Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a0e1b48
- Parents:
- a7efdec
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/kbrd/kbrd.c
ra7efdec rb6f2ebc 27 27 */ 28 28 29 /** @addtogroup genarch 29 /** @addtogroup genarch 30 30 * @{ 31 31 */ 32 32 /** 33 33 * @file 34 * @brief 34 * @brief Keyboard processing. 35 35 */ 36 36 … … 54 54 55 55 #ifdef CONFIG_SUN_KBD 56 # define IGNORE_CODE 0x7f 57 #endif 58 59 #define KEY_RELEASE 0x80 60 61 #define PRESSED_SHIFT (1 << 0) 62 #define PRESSED_CAPSLOCK (1 << 1) 63 #define LOCKED_CAPSLOCK (1 << 0) 64 65 chardev_t kbrdin; 66 static chardev_t *kbdout; 67 68 static void kbrdin_suspend(chardev_t *d) 69 { 70 } 71 72 static void kbrdin_resume(chardev_t *d) 73 { 74 } 75 76 chardev_operations_t kbrdin_ops = { 77 .suspend = kbrdin_suspend, 78 .resume = kbrdin_resume, 56 #define IGNORE_CODE 0x7f 57 #endif 58 59 #define KEY_RELEASE 0x80 60 61 #define PRESSED_SHIFT (1 << 0) 62 #define PRESSED_CAPSLOCK (1 << 1) 63 #define LOCKED_CAPSLOCK (1 << 0) 64 65 static indev_t kbrdout; 66 67 indev_operations_t kbrdout_ops = { 68 .poll = NULL 79 69 }; 80 70 81 SPINLOCK_INITIALIZE(keylock); 82 static volatile int keyflags; 83 static volatile int lockflags; 71 SPINLOCK_INITIALIZE(keylock); /**< keylock protects keyflags and lockflags. */ 72 static volatile int keyflags; /**< Tracking of multiple keypresses. */ 73 static volatile int lockflags; /**< Tracking of multiple keys lockings. */ 84 74 85 75 static void key_released(uint8_t); … … 88 78 static void kkbrd(void *arg) 89 79 { 90 chardev_t *in = (chardev_t *) arg; 91 uint8_t sc; 92 93 while (1) { 94 sc = _getc(in); 95 80 indev_t *in = (indev_t *) arg; 81 82 while (true) { 83 uint8_t sc = _getc(in); 84 96 85 #ifdef CONFIG_SUN_KBD 97 86 if (sc == IGNORE_CODE) … … 106 95 } 107 96 108 109 void kbrd_init(chardev_t *devout) 110 { 111 thread_t *t; 112 113 chardev_initialize("kbrd", &kbrdin, &kbrdin_ops); 114 kbdout = devout; 97 void kbrd_init(indev_t *devin) 98 { 99 indev_initialize("kbrd", &kbrdout, &kbrdout_ops); 100 thread_t *thread 101 = thread_create(kkbrd, devin, TASK, 0, "kkbrd", false); 115 102 116 t = thread_create(kkbrd, &kbrdin, TASK, 0, "kkbrd", false); 117 ASSERT(t); 118 thread_ready(t); 103 if (thread) { 104 stdin = &kbrdout; 105 thread_ready(thread); 106 } 119 107 } 120 108 … … 154 142 bool shift, capslock; 155 143 bool letter = false; 156 144 157 145 spinlock_lock(&keylock); 158 146 switch (sc) { 159 147 case SC_LSHIFT: 160 148 case SC_RSHIFT: 161 149 keyflags |= PRESSED_SHIFT; 162 150 break; 163 151 case SC_CAPSLOCK: … … 167 155 break; 168 156 case SC_LEFTARR: 169 chardev_push_character(kbdout, 0x1b);170 chardev_push_character(kbdout, 0x5b);171 chardev_push_character(kbdout, 0x44);157 indev_push_character(stdin, 0x1b); 158 indev_push_character(stdin, 0x5b); 159 indev_push_character(stdin, 0x44); 172 160 break; 173 161 case SC_RIGHTARR: 174 chardev_push_character(kbdout, 0x1b);175 chardev_push_character(kbdout, 0x5b);176 chardev_push_character(kbdout, 0x43);162 indev_push_character(stdin, 0x1b); 163 indev_push_character(stdin, 0x5b); 164 indev_push_character(stdin, 0x43); 177 165 break; 178 166 case SC_UPARR: 179 chardev_push_character(kbdout, 0x1b);180 chardev_push_character(kbdout, 0x5b);181 chardev_push_character(kbdout, 0x41);167 indev_push_character(stdin, 0x1b); 168 indev_push_character(stdin, 0x5b); 169 indev_push_character(stdin, 0x41); 182 170 break; 183 171 case SC_DOWNARR: 184 chardev_push_character(kbdout, 0x1b);185 chardev_push_character(kbdout, 0x5b);186 chardev_push_character(kbdout, 0x42);172 indev_push_character(stdin, 0x1b); 173 indev_push_character(stdin, 0x5b); 174 indev_push_character(stdin, 0x42); 187 175 break; 188 176 case SC_HOME: 189 chardev_push_character(kbdout, 0x1b);190 chardev_push_character(kbdout, 0x4f);191 chardev_push_character(kbdout, 0x48);177 indev_push_character(stdin, 0x1b); 178 indev_push_character(stdin, 0x4f); 179 indev_push_character(stdin, 0x48); 192 180 break; 193 181 case SC_END: 194 chardev_push_character(kbdout, 0x1b);195 chardev_push_character(kbdout, 0x4f);196 chardev_push_character(kbdout, 0x46);182 indev_push_character(stdin, 0x1b); 183 indev_push_character(stdin, 0x4f); 184 indev_push_character(stdin, 0x46); 197 185 break; 198 186 case SC_DELETE: 199 chardev_push_character(kbdout, 0x1b);200 chardev_push_character(kbdout, 0x5b);201 chardev_push_character(kbdout, 0x33);202 chardev_push_character(kbdout, 0x7e);187 indev_push_character(stdin, 0x1b); 188 indev_push_character(stdin, 0x5b); 189 indev_push_character(stdin, 0x33); 190 indev_push_character(stdin, 0x7e); 203 191 break; 204 192 default: 205 193 letter = islower(ascii); 206 194 capslock = (keyflags & PRESSED_CAPSLOCK) || 207 195 (lockflags & LOCKED_CAPSLOCK); … … 211 199 if (shift) 212 200 map = sc_secondary_map; 213 chardev_push_character(kbdout, map[sc]);201 indev_push_character(stdin, map[sc]); 214 202 break; 215 203 }
Note:
See TracChangeset
for help on using the changeset viewer.