Changeset cf99c4c in mainline
- Timestamp:
- 2011-11-06T13:14:58Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 50f2095
- Parents:
- e04182d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhid/multimedia/multimedia.c
re04182d rcf99c4c 127 127 * sends also these keys to application (otherwise it cannot use those 128 128 * keys at all). 129 * 130 * @param hid_dev 131 * @param lgtch_dev132 * @param type Type of the event (press / release). Recognized values: 129 * 130 * @param hid_dev 131 * @param multim_dev 132 * @param type Type of the event (press / release). Recognized values: 133 133 * KEY_PRESS, KEY_RELEASE 134 134 * @param key Key code of the key according to HID Usage Tables. 135 135 */ 136 static void usb_multimedia_push_ev(usb_hid_dev_t *hid_dev, 136 static void usb_multimedia_push_ev(usb_hid_dev_t *hid_dev, 137 137 usb_multimedia_t *multim_dev, int type, unsigned int key) 138 138 { 139 assert(hid_dev != NULL);140 139 assert(multim_dev != NULL); 141 140 142 kbd_event_t ev;143 144 ev.type = type;145 ev.key = key;146 ev.mods = 0;147 ev.c = 0;141 const kbd_event_t ev = { 142 .type = type, 143 .key = key, 144 .mods = 0, 145 .c = 0, 146 }; 148 147 149 148 usb_log_debug2(NAME " Sending key %d to the console\n", ev.key); … … 164 163 { 165 164 if (hid_dev == NULL || hid_dev->usb_dev == NULL) { 166 return EINVAL; /*! @todo Other return code? */165 return EINVAL; 167 166 } 168 167 … … 199 198 } 200 199 201 usb_log_debug( "%sfunction created (handle: %" PRIun ").\n",202 NAME,fun->handle);200 usb_log_debug(NAME " function created (handle: %" PRIun ").\n", 201 fun->handle); 203 202 204 203 rc = ddf_fun_add_to_category(fun, "keyboard"); … … 222 221 void usb_multimedia_deinit(struct usb_hid_dev *hid_dev, void *data) 223 222 { 224 if (hid_dev == NULL) {225 return;226 }227 228 223 if (data != NULL) { 229 usb_multimedia_t *multim_dev = (usb_multimedia_t *)data; 230 // hangup session to the console 231 async_hangup(multim_dev->console_sess); 224 usb_multimedia_t *multim_dev = data; 225 /* Hangup session to the console */ 226 if (multim_dev->console_sess) 227 async_hangup(multim_dev->console_sess); 232 228 const int ret = ddf_fun_unbind(multim_dev->fun); 233 229 if (ret != EOK) { 234 usb_log_error("Failed to unbind multim function.\n"); 230 usb_log_error("Failed to unbind %s function.\n", 231 multim_dev->fun->name); 235 232 } else { 236 233 usb_log_debug2("%s unbound.\n", multim_dev->fun->name); 234 /* This frees multim_dev too as it was stored in 235 * fun->data */ 237 236 ddf_fun_destroy(multim_dev->fun); 238 237 } … … 249 248 } 250 249 251 usb_multimedia_t *multim_dev = (usb_multimedia_t *)data;250 usb_multimedia_t *multim_dev = data; 252 251 253 252 usb_hid_report_path_t *path = usb_hid_report_path(); 254 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_CONSUMER, 0); 253 int ret = 254 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_CONSUMER, 0); 255 if (ret != EOK) 256 return true; /* This might be a temporary failure. */ 255 257 256 258 usb_hid_report_path_set_report_id(path, hid_dev->report_id); … … 268 270 usb_log_debug(NAME " KEY VALUE(%X) USAGE(%X)\n", 269 271 field->value, field->usage); 270 unsigned int key =272 const unsigned key = 271 273 usb_multimedia_map_usage(field->usage); 272 const char *key_str = 274 const char *key_str = 273 275 usbhid_multimedia_usage_to_str(field->usage); 274 276 usb_log_info("Pressed key: %s\n", key_str); 275 usb_multimedia_push_ev(hid_dev, multim_dev, KEY_PRESS, 277 usb_multimedia_push_ev(hid_dev, multim_dev, KEY_PRESS, 276 278 key); 277 279 } … … 279 281 field = usb_hid_report_get_sibling( 280 282 &hid_dev->report, field, path, USB_HID_PATH_COMPARE_END 281 | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 283 | USB_HID_PATH_COMPARE_USAGE_PAGE_ONLY, 282 284 USB_HID_REPORT_TYPE_INPUT); 283 285 }
Note:
See TracChangeset
for help on using the changeset viewer.