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