Changeset e04182d in mainline
- Timestamp:
- 2011-11-05T23:32:45Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cf99c4c
- Parents:
- 9f583151
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhid/mouse/mousedev.c
r9f583151 re04182d 55 55 #define ARROWS_PER_SINGLE_WHEEL 3 56 56 57 #define NAME 57 #define NAME "mouse" 58 58 59 59 /*----------------------------------------------------------------------------*/ … … 123 123 ipc_callid_t icallid, ipc_call_t *icall) 124 124 { 125 usb_mouse_t *mouse_dev = (usb_mouse_t *)fun->driver_data;125 usb_mouse_t *mouse_dev = fun->driver_data; 126 126 127 127 if (mouse_dev == NULL) { 128 usb_log_debug("default_connection_handler: Missing " 129 "parameters.\n"); 128 usb_log_debug("%s: Missing parameters.\n", __FUNCTION__); 130 129 async_answer_0(icallid, EINVAL); 131 130 return; 132 131 } 133 132 134 usb_log_debug("default_connection_handler: fun->name: %s\n", 135 fun->name); 136 usb_log_debug("default_connection_handler: mouse_sess: %p, " 137 "wheel_sess: %p\n", mouse_dev->mouse_sess, mouse_dev->wheel_sess); 138 139 async_sess_t **sess_ptr = 140 (str_cmp(fun->name, HID_MOUSE_FUN_NAME) == 0) ? 133 usb_log_debug("%s: fun->name: %s\n", __FUNCTION__, fun->name); 134 usb_log_debug("%s: mouse_sess: %p, wheel_sess: %p\n", 135 __FUNCTION__, mouse_dev->mouse_sess, mouse_dev->wheel_sess); 136 137 async_sess_t **sess_ptr = (fun == mouse_dev->mouse_fun) ? 141 138 &mouse_dev->mouse_sess : &mouse_dev->wheel_sess; 142 139 … … 146 143 if (*sess_ptr == NULL) { 147 144 *sess_ptr = sess; 148 usb_log_debug("Console session to mouseset ok (%p).\n",149 sess);145 usb_log_debug("Console session to %s set ok (%p).\n", 146 fun->name, sess); 150 147 async_answer_0(icallid, EOK); 151 148 } else { 152 usb_log_ debug("default_connection_handler: Console "153 "session to mouse already set.\n");149 usb_log_error("Console session to %s already set.\n", 150 fun->name); 154 151 async_answer_0(icallid, ELIMIT); 155 152 } 156 153 } else { 157 usb_log_debug(" default_connection_handler: Invalid function.\n");154 usb_log_debug("%s: Invalid function.\n", __FUNCTION__); 158 155 async_answer_0(icallid, EINVAL); 159 156 } … … 170 167 mouse->mouse_sess = NULL; 171 168 mouse->wheel_sess = NULL; 169 mouse->buttons = NULL; 170 mouse->buttons_count = 0; 172 171 173 172 return mouse; … … 180 179 assert(mouse_dev != NULL); 181 180 182 // hangup session to the console 183 if (mouse_dev->mouse_sess != NULL) 184 async_hangup(mouse_dev->mouse_sess); 185 186 if (mouse_dev->wheel_sess != NULL) 187 async_hangup(mouse_dev->wheel_sess); 181 /* Hangup session to the console */ 182 if (mouse_dev->mouse_sess != NULL) { 183 const int ret = async_hangup(mouse_dev->mouse_sess); 184 if (ret != EOK) 185 usb_log_warning("Failed to hang up mouse session: " 186 "%p, %s.\n", mouse_dev->mouse_sess, str_error(ret)); 187 } 188 189 if (mouse_dev->wheel_sess != NULL) { 190 const int ret = async_hangup(mouse_dev->wheel_sess); 191 if (ret != EOK) 192 usb_log_warning("Failed to hang up wheel session: " 193 "%p, %s.\n", mouse_dev->wheel_sess, str_error(ret)); 194 } 195 188 196 int ret = ddf_fun_unbind(mouse_dev->mouse_fun); 189 197 if (ret != EOK) { … … 191 199 } else { 192 200 ddf_fun_destroy(mouse_dev->mouse_fun); 193 /* Prevent double free */201 /* Prevent double free, these two functions share driver data */ 194 202 mouse_dev->wheel_fun->driver_data = NULL; 195 203 } … … 201 209 ddf_fun_destroy(mouse_dev->wheel_fun); 202 210 } 211 203 212 } 204 213 … … 215 224 } 216 225 217 int count = ((wheel < 0) ? -wheel : wheel) * ARROWS_PER_SINGLE_WHEEL; 218 int i; 219 220 for (i = 0; i < count; i++) { 226 const unsigned count = 227 ((wheel < 0) ? -wheel : wheel) * ARROWS_PER_SINGLE_WHEEL; 228 for (unsigned i = 0; i < count; i++) { 221 229 /* Send arrow press and release. */ 222 230 usb_log_debug2("Sending key %d to the console\n", key);
Note:
See TracChangeset
for help on using the changeset viewer.