Changeset 854eddd6 in mainline for uspace/srv/hid/input/generic/input.c
- Timestamp:
- 2011-06-14T21:40:28Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 662da50, e3a46c2
- Parents:
- ecb692a2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/input/generic/input.c
recb692a2 r854eddd6 54 54 #include <io/keycode.h> 55 55 #include <devmap.h> 56 #include <input.h> 56 57 #include <kbd.h> 57 58 #include <kbd_port.h> 58 59 #include <kbd_ctl.h> 59 60 #include <layout.h> 61 #include <mouse.h> 60 62 61 63 // FIXME: remove this header … … 68 70 static void kbd_devs_reclaim(void); 69 71 72 static void input_event_key(int, unsigned int, unsigned, wchar_t); 73 70 74 int client_phone = -1; 71 75 72 76 /** List of keyboard devices */ 73 77 static link_t kbd_devs; 78 79 /** List of mouse devices */ 80 link_t mouse_devs; 74 81 75 82 bool irc_service = false; … … 166 173 167 174 ev.c = layout_parse_ev(kdev->active_layout, &ev); 168 169 async_obsolete_msg_4(client_phone, INPUT_EVENT, ev.type, ev.key, ev.mods, ev.c); 175 input_event_key(ev.type, ev.key, ev.mods, ev.c); 176 } 177 178 /** Key has been pressed or released. */ 179 static void input_event_key(int type, unsigned int key, unsigned mods, 180 wchar_t c) 181 { 182 async_obsolete_msg_4(client_phone, INPUT_EVENT_KEY, type, key, 183 mods, c); 184 } 185 186 /** Mouse pointer has moved. */ 187 void input_event_move(int dx, int dy) 188 { 189 async_obsolete_msg_2(client_phone, INPUT_EVENT_MOVE, dx, dy); 190 } 191 192 /** Mouse button has been pressed. */ 193 void input_event_button(int bnum, int press) 194 { 195 async_obsolete_msg_2(client_phone, INPUT_EVENT_BUTTON, bnum, press); 170 196 } 171 197 … … 221 247 kdev = calloc(1, sizeof(kbd_dev_t)); 222 248 if (kdev == NULL) { 223 printf(NAME ": Allocating keyboard device. Out of memory.\n"); 249 printf(NAME ": Error allocating keyboard device. " 250 "Out of memory.\n"); 224 251 return NULL; 225 252 } … … 374 401 } 375 402 376 /** Periodically check for new kbdev devices in /dev/class/keyboard. 403 /** Periodically check for new input devices. 404 * 405 * Looks under /dev/class/keyboard and /dev/class/mouse. 377 406 * 378 407 * @param arg Ignored … … 381 410 { 382 411 char *dev_path; 383 size_t id = 1; 412 size_t kbd_id = 1; 413 size_t mouse_id = 1; 384 414 int rc; 385 415 … … 387 417 async_usleep(DISCOVERY_POLL_INTERVAL); 388 418 389 rc = asprintf(&dev_path, "/dev/class/keyboard\\%zu", id); 419 /* 420 * Check for new keyboard device 421 */ 422 rc = asprintf(&dev_path, "/dev/class/keyboard\\%zu", kbd_id); 390 423 if (rc < 0) 391 424 continue; 392 425 393 426 if (kbd_add_kbdev(dev_path) == EOK) { 394 printf(NAME ": Connected k bdevdevice '%s'\n",427 printf(NAME ": Connected keyboard device '%s'\n", 395 428 dev_path); 396 429 397 430 /* XXX Handle device removal */ 398 ++ id;431 ++kbd_id; 399 432 } 400 433 401 434 free(dev_path); 435 436 /* 437 * Check for new mouse device 438 */ 439 rc = asprintf(&dev_path, "/dev/class/mouse\\%zu", mouse_id); 440 if (rc < 0) 441 continue; 442 443 if (mouse_add_dev(dev_path) == EOK) { 444 printf(NAME ": Connected mouse device '%s'\n", 445 dev_path); 446 447 /* XXX Handle device removal */ 448 ++mouse_id; 449 } 450 451 free(dev_path); 402 452 } 403 453 … … 406 456 407 457 /** Start a fibril for discovering new devices. */ 408 static void kbd_start_dev_discovery(void)458 static void input_start_dev_discovery(void) 409 459 { 410 460 fid_t fid; … … 427 477 428 478 list_initialize(&kbd_devs); 479 list_initialize(&mouse_devs); 429 480 430 481 if (((sysinfo_get_value("kbd.cir.fhc", &fhc) == EOK) && (fhc)) … … 437 488 } 438 489 439 /* Add legacy devices. */490 /* Add legacy keyboard devices. */ 440 491 kbd_add_legacy_devs(); 441 492 493 /* Add legacy (devmap-style) mouse device. */ 494 (void) mouse_add_dev("/dev/hid_in/mouse"); 442 495 443 496 /* Register driver */ … … 457 510 } 458 511 459 /* Start looking for new kbdevdevices */460 kbd_start_dev_discovery();512 /* Start looking for new input devices */ 513 input_start_dev_discovery(); 461 514 462 515 printf(NAME ": Accepting connections\n");
Note:
See TracChangeset
for help on using the changeset viewer.