Changes in uspace/drv/bus/usb/usbhid/mouse/mousedev.c [56fd7cf:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhid/mouse/mousedev.c
r56fd7cf r9d58539 35 35 */ 36 36 37 /* XXX Fix this */38 #define _DDF_DATA_IMPLANT39 40 37 #include <usb/debug.h> 41 38 #include <usb/classes/classes.h> … … 57 54 #define NAME "mouse" 58 55 59 static void default_connection_handler(ddf_fun_t *, ipc_callid_t, ipc_call_t *); 60 61 static ddf_dev_ops_t ops = { .default_handler = default_connection_handler }; 62 56 /*----------------------------------------------------------------------------*/ 63 57 64 58 const usb_endpoint_description_t usb_hid_mouse_poll_endpoint_description = { … … 77 71 static const uint8_t IDLE_RATE = 0; 78 72 79 73 /*----------------------------------------------------------------------------*/ 80 74 static const uint8_t USB_MOUSE_BOOT_REPORT_DESCRIPTOR[] = { 81 75 0x05, 0x01, // USAGE_PAGE (Generic Desktop) … … 107 101 }; 108 102 109 103 /*----------------------------------------------------------------------------*/ 110 104 111 105 /** Default handler for IPC methods not handled by DDF. … … 118 112 ipc_callid_t icallid, ipc_call_t *icall) 119 113 { 120 usb_mouse_t *mouse_dev = ddf_fun_data_get(fun);114 usb_mouse_t *mouse_dev = fun->driver_data; 121 115 122 116 if (mouse_dev == NULL) { … … 126 120 } 127 121 128 usb_log_debug("%s: fun->name: %s\n", __FUNCTION__, ddf_fun_get_name(fun));122 usb_log_debug("%s: fun->name: %s\n", __FUNCTION__, fun->name); 129 123 usb_log_debug("%s: mouse_sess: %p\n", 130 124 __FUNCTION__, mouse_dev->mouse_sess); … … 136 130 mouse_dev->mouse_sess = sess; 137 131 usb_log_debug("Console session to %s set ok (%p).\n", 138 ddf_fun_get_name(fun), sess);132 fun->name, sess); 139 133 async_answer_0(icallid, EOK); 140 134 } else { 141 135 usb_log_error("Console session to %s already set.\n", 142 ddf_fun_get_name(fun));136 fun->name); 143 137 async_answer_0(icallid, ELIMIT); 144 138 async_hangup(sess); … … 149 143 } 150 144 } 151 145 /*----------------------------------------------------------------------------*/ 152 146 static int get_mouse_axis_move_value(uint8_t rid, usb_hid_report_t *report, 153 147 int32_t usage) … … 227 221 assert(index < mouse_dev->buttons_count); 228 222 229 if (mouse_dev->buttons[index] != field->value) {223 if (mouse_dev->buttons[index] == 0 && field->value != 0) { 230 224 async_exch_t *exch = 231 225 async_exchange_begin(mouse_dev->mouse_sess); 232 226 if (exch != NULL) { 233 227 async_req_2_0(exch, MOUSEEV_BUTTON_EVENT, 234 field->usage, (field->value != 0) ? 1 : 0); 228 field->usage, 1); 229 async_exchange_end(exch); 230 mouse_dev->buttons[index] = field->value; 231 } 232 233 } else if (mouse_dev->buttons[index] != 0 && field->value == 0) { 234 async_exch_t *exch = 235 async_exchange_begin(mouse_dev->mouse_sess); 236 if (exch != NULL) { 237 async_req_2_0(exch, MOUSEEV_BUTTON_EVENT, 238 field->usage, 0); 235 239 async_exchange_end(exch); 236 240 mouse_dev->buttons[index] = field->value; … … 248 252 return true; 249 253 } 250 254 /*----------------------------------------------------------------------------*/ 251 255 #define FUN_UNBIND_DESTROY(fun) \ 252 256 if (fun) { \ 253 257 if (ddf_fun_unbind((fun)) == EOK) { \ 258 (fun)->driver_data = NULL; \ 254 259 ddf_fun_destroy((fun)); \ 255 260 } else { \ 256 261 usb_log_error("Could not unbind function `%s', it " \ 257 "will not be destroyed.\n", ddf_fun_get_name(fun)); \262 "will not be destroyed.\n", (fun)->name); \ 258 263 } \ 259 264 } else (void)0 260 265 /*----------------------------------------------------------------------------*/ 261 266 static int usb_mouse_create_function(usb_hid_dev_t *hid_dev, usb_mouse_t *mouse) 262 267 { … … 274 279 } 275 280 276 ddf_fun_set_ops(fun, &ops);277 ddf_fun_data_implant(fun, mouse);281 fun->ops = &mouse->ops; 282 fun->driver_data = mouse; 278 283 279 284 int rc = ddf_fun_bind(fun); 280 285 if (rc != EOK) { 281 286 usb_log_error("Could not bind DDF function `%s': %s.\n", 282 ddf_fun_get_name(fun), str_error(rc)); 287 fun->name, str_error(rc)); 288 fun->driver_data = NULL; 283 289 ddf_fun_destroy(fun); 284 290 return rc; … … 286 292 287 293 usb_log_debug("Adding DDF function `%s' to category %s...\n", 288 ddf_fun_get_name(fun), HID_MOUSE_CATEGORY);294 fun->name, HID_MOUSE_CATEGORY); 289 295 rc = ddf_fun_add_to_category(fun, HID_MOUSE_CATEGORY); 290 296 if (rc != EOK) { … … 296 302 } 297 303 mouse->mouse_fun = fun; 304 298 305 return EOK; 299 306 } … … 338 345 return highest_button; 339 346 } 340 347 /*----------------------------------------------------------------------------*/ 341 348 int usb_mouse_init(usb_hid_dev_t *hid_dev, void **data) 342 349 { … … 372 379 } 373 380 381 // set handler for incoming calls 382 mouse_dev->ops.default_handler = default_connection_handler; 383 374 384 // TODO: how to know if the device supports the request??? 375 385 usbhid_req_set_idle(&hid_dev->usb_dev->ctrl_pipe, … … 388 398 return EOK; 389 399 } 390 400 /*----------------------------------------------------------------------------*/ 391 401 bool usb_mouse_polling_callback(usb_hid_dev_t *hid_dev, void *data) 392 402 { … … 401 411 return usb_mouse_process_report(hid_dev, mouse_dev); 402 412 } 403 413 /*----------------------------------------------------------------------------*/ 404 414 void usb_mouse_deinit(usb_hid_dev_t *hid_dev, void *data) 405 415 { … … 420 430 421 431 free(mouse_dev->buttons); 422 } 423 432 free(mouse_dev); 433 } 434 /*----------------------------------------------------------------------------*/ 424 435 int usb_mouse_set_boot_protocol(usb_hid_dev_t *hid_dev) 425 436 {
Note:
See TracChangeset
for help on using the changeset viewer.