Changeset 70172dc4 in mainline for uspace/drv/bus/usb/usbhid/mouse/mousedev.c
- Timestamp:
- 2011-12-28T11:55:14Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3fac882d
- Parents:
- edb3cf2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhid/mouse/mousedev.c
redb3cf2 r70172dc4 52 52 #include "../usbhid.h" 53 53 54 /** Number of simulated arrow-key presses for singel wheel step. */55 #define ARROWS_PER_SINGLE_WHEEL 356 57 54 #define NAME "mouse" 58 55 … … 69 66 70 67 const char *HID_MOUSE_FUN_NAME = "mouse"; 71 const char *HID_MOUSE_WHEEL_FUN_NAME = "mouse-wheel";72 68 const char *HID_MOUSE_CATEGORY = "mouse"; 73 const char *HID_MOUSE_WHEEL_CATEGORY = "keyboard";74 69 75 70 /** Default idle rate for mouses. */ … … 126 121 127 122 usb_log_debug("%s: fun->name: %s\n", __FUNCTION__, fun->name); 128 usb_log_debug("%s: mouse_sess: %p, wheel_sess: %p\n", 129 __FUNCTION__, mouse_dev->mouse_sess, mouse_dev->wheel_sess); 130 131 async_sess_t **sess_ptr = (fun == mouse_dev->mouse_fun) ? 132 &mouse_dev->mouse_sess : &mouse_dev->wheel_sess; 123 usb_log_debug("%s: mouse_sess: %p\n", 124 __FUNCTION__, mouse_dev->mouse_sess); 133 125 134 126 async_sess_t *sess = 135 127 async_callback_receive_start(EXCHANGE_SERIALIZE, icall); 136 128 if (sess != NULL) { 137 if ( *sess_ptr== NULL) {138 *sess_ptr= sess;129 if (mouse_dev->mouse_sess == NULL) { 130 mouse_dev->mouse_sess = sess; 139 131 usb_log_debug("Console session to %s set ok (%p).\n", 140 132 fun->name, sess); … … 144 136 fun->name); 145 137 async_answer_0(icallid, ELIMIT); 138 async_hangup(sess); 146 139 } 147 140 } else { … … 150 143 } 151 144 } 152 153 /*----------------------------------------------------------------------------*/ 154 #if 0 155 static void usb_mouse_send_wheel(const usb_mouse_t *mouse_dev, int wheel) 156 { 157 unsigned int key = (wheel > 0) ? KC_UP : KC_DOWN; 158 159 if (mouse_dev->wheel_sess == NULL) { 160 usb_log_warning( 161 "Connection to console not ready, wheel roll discarded.\n"); 162 return; 163 } 164 165 const unsigned count = 166 ((wheel < 0) ? -wheel : wheel) * ARROWS_PER_SINGLE_WHEEL; 167 for (unsigned i = 0; i < count; i++) { 168 /* Send arrow press and release. */ 169 usb_log_debug2("Sending key %d to the console\n", key); 170 171 async_exch_t *exch = async_exchange_begin(mouse_dev->wheel_sess); 172 173 async_msg_4(exch, KBDEV_EVENT, KEY_PRESS, key, 0, 0); 174 async_msg_4(exch, KBDEV_EVENT, KEY_RELEASE, key, 0, 0); 175 176 async_exchange_end(exch); 177 } 178 } 179 #endif 180 /*----------------------------------------------------------------------------*/ 181 145 /*----------------------------------------------------------------------------*/ 182 146 static int get_mouse_axis_move_value(uint8_t rid, usb_hid_report_t *report, 183 147 int32_t usage) … … 203 167 return result; 204 168 } 205 169 /*----------------------------------------------------------------------------*/ 206 170 static bool usb_mouse_process_report(usb_hid_dev_t *hid_dev, 207 171 usb_mouse_t *mouse_dev) … … 230 194 } 231 195 } 232 #if 0 233 if (wheel != 0) 234 (void)usb_mouse_send_wheel(mouse_dev, wheel); 235 #endif 196 236 197 /* Buttons */ 237 198 usb_hid_report_path_t *path = usb_hid_report_path(); … … 342 303 mouse->mouse_fun = fun; 343 304 344 /*345 * Special function for acting as keyboard (wheel)346 */347 usb_log_debug("Creating DDF function %s...\n",348 HID_MOUSE_WHEEL_FUN_NAME);349 fun = ddf_fun_create(hid_dev->usb_dev->ddf_dev, fun_exposed,350 HID_MOUSE_WHEEL_FUN_NAME);351 if (fun == NULL) {352 usb_log_error("Could not create DDF function node `%s'.\n",353 HID_MOUSE_WHEEL_FUN_NAME);354 FUN_UNBIND_DESTROY(mouse->mouse_fun);355 mouse->mouse_fun = NULL;356 return ENOMEM;357 }358 359 /*360 * Store the initialized HID device and HID ops361 * to the DDF function.362 */363 fun->ops = &mouse->ops;364 fun->driver_data = mouse;365 366 rc = ddf_fun_bind(fun);367 if (rc != EOK) {368 usb_log_error("Could not bind DDF function `%s': %s.\n",369 fun->name, str_error(rc));370 FUN_UNBIND_DESTROY(mouse->mouse_fun);371 mouse->mouse_fun = NULL;372 373 fun->driver_data = NULL;374 ddf_fun_destroy(fun);375 return rc;376 }377 378 usb_log_debug("Adding DDF function to category %s...\n",379 HID_MOUSE_WHEEL_CATEGORY);380 rc = ddf_fun_add_to_category(fun, HID_MOUSE_WHEEL_CATEGORY);381 if (rc != EOK) {382 usb_log_error(383 "Could not add DDF function to category %s: %s.\n",384 HID_MOUSE_WHEEL_CATEGORY, str_error(rc));385 386 FUN_UNBIND_DESTROY(mouse->mouse_fun);387 mouse->mouse_fun = NULL;388 FUN_UNBIND_DESTROY(fun);389 return rc;390 }391 mouse->wheel_fun = fun;392 393 305 return EOK; 394 306 } 395 396 /*----------------------------------------------------------------------------*/ 397 307 /*----------------------------------------------------------------------------*/ 398 308 /** Get highest index of a button mentioned in given report. 399 309 * … … 517 427 } 518 428 519 if (mouse_dev->wheel_sess != NULL) {520 const int ret = async_hangup(mouse_dev->wheel_sess);521 if (ret != EOK)522 usb_log_warning("Failed to hang up wheel session: "523 "%p, %s.\n", mouse_dev->wheel_sess, str_error(ret));524 }525 526 429 FUN_UNBIND_DESTROY(mouse_dev->mouse_fun); 527 FUN_UNBIND_DESTROY(mouse_dev->wheel_fun);528 430 529 431 free(mouse_dev->buttons);
Note:
See TracChangeset
for help on using the changeset viewer.