Changeset f2f99ae in mainline
- Timestamp:
- 2011-06-12T11:27:57Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- af897ff0
- Parents:
- 4f3f9659
- Location:
- uspace
- Files:
-
- 3 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhid/Makefile
r4f3f9659 rf2f99ae 43 43 BINARY = usbhid 44 44 45 STOLEN_LAYOUT_SOURCES = \46 kbd/layout/us_qwerty.c \47 kbd/layout/us_dvorak.c \48 kbd/layout/cz.c49 50 45 SOURCES = \ 51 46 main.c \ … … 61 56 $(STOLEN_LAYOUT_SOURCES) 62 57 63 EXTRA_CLEAN = $(STOLEN_LAYOUT_SOURCES)64 65 58 SRV_KBD = $(USPACE_PREFIX)/srv/hid/kbd 66 59 67 60 include $(USPACE_PREFIX)/Makefile.common 68 69 kbd/layout/%.c: $(SRV_KBD)/layout/%.c70 ln -sfn ../../$< $@ -
uspace/drv/usbhid/kbd/kbddev.c
r4f3f9659 rf2f99ae 40 40 41 41 #include <io/keycode.h> 42 #include <io/console.h> 42 43 #include <ipc/kbd.h> 43 44 #include <async.h> … … 63 64 #include "kbddev.h" 64 65 65 #include "layout.h"66 66 #include "conv.h" 67 67 #include "kbdrepeat.h" … … 73 73 74 74 /*----------------------------------------------------------------------------*/ 75 /** Default modifiers when the keyboard is initialized. */ 75 76 76 static const unsigned DEFAULT_ACTIVE_MODS = KM_NUM_LOCK; 77 77 … … 154 154 155 155 /*----------------------------------------------------------------------------*/ 156 /* Keyboard layouts */157 /*----------------------------------------------------------------------------*/158 159 #define NUM_LAYOUTS 3160 161 /** Keyboard layout map. */162 static layout_op_t *layout[NUM_LAYOUTS] = {163 &us_qwerty_op,164 &us_dvorak_op,165 &cz_op166 };167 168 static int active_layout = 0;169 170 /*----------------------------------------------------------------------------*/171 156 /* IPC method handler */ 172 157 /*----------------------------------------------------------------------------*/ … … 311 296 unsigned int key) 312 297 { 313 kbd_event_t ev; 314 unsigned mod_mask; 315 316 /* 317 * These parts are copy-pasted from the AT keyboard driver. 318 * 319 * They definitely require some refactoring, but will keep it for later 320 * when the console and keyboard system is changed in HelenOS. 321 */ 322 switch (key) { 323 case KC_LCTRL: mod_mask = KM_LCTRL; break; 324 case KC_RCTRL: mod_mask = KM_RCTRL; break; 325 case KC_LSHIFT: mod_mask = KM_LSHIFT; break; 326 case KC_RSHIFT: mod_mask = KM_RSHIFT; break; 327 case KC_LALT: mod_mask = KM_LALT; break; 328 case KC_RALT: mod_mask = KM_RALT; break; 329 default: mod_mask = 0; break; 330 } 331 332 if (mod_mask != 0) { 333 if (type == KEY_PRESS) 334 kbd_dev->mods = kbd_dev->mods | mod_mask; 335 else 336 kbd_dev->mods = kbd_dev->mods & ~mod_mask; 337 } 338 339 switch (key) { 340 case KC_CAPS_LOCK: mod_mask = KM_CAPS_LOCK; break; 341 case KC_NUM_LOCK: mod_mask = KM_NUM_LOCK; break; 342 case KC_SCROLL_LOCK: mod_mask = KM_SCROLL_LOCK; break; 343 default: mod_mask = 0; break; 344 } 345 346 if (mod_mask != 0) { 347 if (type == KEY_PRESS) { 348 /* 349 * Only change lock state on transition from released 350 * to pressed. This prevents autorepeat from messing 351 * up the lock state. 352 */ 353 unsigned int locks_old = kbd_dev->lock_keys; 354 355 kbd_dev->mods = 356 kbd_dev->mods ^ (mod_mask & ~kbd_dev->lock_keys); 357 kbd_dev->lock_keys = kbd_dev->lock_keys | mod_mask; 358 359 /* Update keyboard lock indicator lights. */ 360 if (kbd_dev->lock_keys != locks_old 361 && hid_dev != NULL) { // ugly hack 362 usb_kbd_set_led(hid_dev, kbd_dev); 363 } 364 } else { 365 kbd_dev->lock_keys = kbd_dev->lock_keys & ~mod_mask; 366 } 367 } 368 369 if (key == KC_CAPS_LOCK || key == KC_NUM_LOCK || key == KC_SCROLL_LOCK) { 370 // do not send anything to the console, this is our business 371 return; 372 } 373 374 if (type == KEY_PRESS && (kbd_dev->mods & KM_LCTRL) && key == KC_F1) { 375 active_layout = 0; 376 layout[active_layout]->reset(); 377 return; 378 } 379 380 if (type == KEY_PRESS && (kbd_dev->mods & KM_LCTRL) && key == KC_F2) { 381 active_layout = 1; 382 layout[active_layout]->reset(); 383 return; 384 } 385 386 if (type == KEY_PRESS && (kbd_dev->mods & KM_LCTRL) && key == KC_F3) { 387 active_layout = 2; 388 layout[active_layout]->reset(); 389 return; 390 } 391 392 ev.type = type; 393 ev.key = key; 394 ev.mods = kbd_dev->mods; 395 396 ev.c = layout[active_layout]->parse_ev(&ev); 397 398 usb_log_debug2("Sending key %d to the console\n", ev.key); 298 usb_log_debug2("Sending kbdev event %d/%d to the console\n", type, key); 399 299 if (kbd_dev->console_phone < 0) { 400 300 usb_log_warning( … … 403 303 } 404 304 405 async_obsolete_msg_4(kbd_dev->console_phone, KBD_EVENT, ev.type, ev.key, 406 ev.mods, ev.c); 305 async_obsolete_msg_2(kbd_dev->console_phone, KBD_EVENT, type, key); 407 306 } 408 307 … … 787 686 /* 788 687 * Modifiers and locks 789 */ 688 */ 790 689 kbd_dev->modifiers = 0; 791 690 kbd_dev->mods = DEFAULT_ACTIVE_MODS; … … 794 693 /* 795 694 * Autorepeat 796 */ 695 */ 797 696 kbd_dev->repeat.key_new = 0; 798 697 kbd_dev->repeat.key_repeated = 0; -
uspace/srv/hid/console/console.c
r4f3f9659 rf2f99ae 973 973 974 974 /* Start fibril for checking on hot-plugged keyboards. */ 975 check_new_devices_in_background(connect_keyboard, "keyboard");975 // check_new_devices_in_background(connect_keyboard, "keyboard"); 976 976 check_new_devices_in_background(connect_mouse, "mouse"); 977 977 -
uspace/srv/hid/kbd/Makefile
r4f3f9659 rf2f99ae 62 62 ctl/apple.c \ 63 63 ctl/gxe_fb.c \ 64 ctl/kbdev.c \ 64 65 ctl/pc.c \ 65 66 ctl/stty.c \ -
uspace/srv/hid/kbd/generic/kbd.c
r4f3f9659 rf2f99ae 239 239 240 240 /* Initialize port driver. */ 241 if ((*kdev->port_ops->init)(kdev) != 0) 242 goto fail; 241 if (kdev->port_ops != NULL) { 242 if ((*kdev->port_ops->init)(kdev) != 0) 243 goto fail; 244 } 243 245 244 246 /* Initialize controller driver. */ … … 307 309 kbd_add_dev(&ns16550_port, &sun_ctl); 308 310 #endif 309 /* Silence warning on abs32le about kbd_add_dev() being unused */310 (void) kbd_add_dev;311 311 } 312 312 … … 319 319 320 320 /* Yield port */ 321 (*kdev->port_ops->yield)(); 321 if (kdev->port_ops != NULL) 322 (*kdev->port_ops->yield)(); 322 323 } 323 324 } … … 331 332 332 333 /* Reclaim port */ 333 (*kdev->port_ops->reclaim)(); 334 if (kdev->port_ops != NULL) 335 (*kdev->port_ops->reclaim)(); 334 336 } 335 337 } … … 355 357 /* Add legacy devices. */ 356 358 kbd_add_legacy_devs(); 359 360 /* Add kbdev device */ 361 kbd_add_dev(NULL, &kbdev_ctl); 357 362 358 363 /* Initialize (reset) layout. */ -
uspace/srv/hid/kbd/include/kbd_ctl.h
r4f3f9659 rf2f99ae 50 50 extern kbd_ctl_ops_t apple_ctl; 51 51 extern kbd_ctl_ops_t gxe_fb_ctl; 52 extern kbd_ctl_ops_t kbdev_ctl; 52 53 extern kbd_ctl_ops_t pc_ctl; 53 54 extern kbd_ctl_ops_t stty_ctl;
Note:
See TracChangeset
for help on using the changeset viewer.