Changeset ae303ad in mainline
- Timestamp:
- 2017-11-21T18:15:12Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a0e09ef
- Parents:
- 6283cefb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/hid/usbhid/mouse/mousedev.c
r6283cefb rae303ad 147 147 } 148 148 149 static int get_mouse_axis_move_value(uint8_t rid, usb_hid_report_t *report,149 static const usb_hid_report_field_t *get_mouse_axis_move_field(uint8_t rid, usb_hid_report_t *report, 150 150 int32_t usage) 151 151 { 152 int result = 0;153 154 152 usb_hid_report_path_t *path = usb_hid_report_path(); 155 153 usb_hid_report_path_append_item(path, USB_HIDUT_PAGE_GENERIC_DESKTOP, … … 158 156 usb_hid_report_path_set_report_id(path, rid); 159 157 160 usb_hid_report_field_t *field = usb_hid_report_get_sibling(158 const usb_hid_report_field_t *field = usb_hid_report_get_sibling( 161 159 report, NULL, path, USB_HID_PATH_COMPARE_END, 162 160 USB_HID_REPORT_TYPE_INPUT); 163 161 164 if (field != NULL) {165 result = field->value;166 }167 168 162 usb_hid_report_path_free(path); 169 163 170 return result;164 return field; 171 165 } 172 166 … … 181 175 } 182 176 183 const int shift_x = get_mouse_axis_move_value(hid_dev->report_id, 184 &hid_dev->report, USB_HIDUT_USAGE_GENERIC_DESKTOP_X); 185 const int shift_y = get_mouse_axis_move_value(hid_dev->report_id, 186 &hid_dev->report, USB_HIDUT_USAGE_GENERIC_DESKTOP_Y); 187 const int wheel = get_mouse_axis_move_value(hid_dev->report_id, 188 &hid_dev->report, USB_HIDUT_USAGE_GENERIC_DESKTOP_WHEEL); 189 190 if (shift_x || shift_y || wheel) { 177 const usb_hid_report_field_t *move_x = get_mouse_axis_move_field( 178 hid_dev->report_id, &hid_dev->report, 179 USB_HIDUT_USAGE_GENERIC_DESKTOP_X); 180 const usb_hid_report_field_t *move_y = get_mouse_axis_move_field( 181 hid_dev->report_id, &hid_dev->report, 182 USB_HIDUT_USAGE_GENERIC_DESKTOP_Y); 183 const usb_hid_report_field_t *wheel= get_mouse_axis_move_field( 184 hid_dev->report_id, &hid_dev->report, 185 USB_HIDUT_USAGE_GENERIC_DESKTOP_WHEEL); 186 187 bool absolute_x = move_x && !USB_HID_ITEM_FLAG_RELATIVE(move_x->item_flags); 188 bool absolute_y = move_y && !USB_HID_ITEM_FLAG_RELATIVE(move_y->item_flags); 189 190 /* Tablet shall always report both X and Y */ 191 if (absolute_x != absolute_y) { 192 usb_log_error(NAME " cannot handle mix of absolute and relative mouse move."); 193 return true; 194 } 195 196 int shift_x = move_x ? move_x->value : 0; 197 int shift_y = move_y ? move_y->value : 0; 198 int shift_z = wheel ? wheel->value : 0; 199 200 if (absolute_x && absolute_y) { 201 async_exch_t *exch = 202 async_exchange_begin(mouse_dev->mouse_sess); 203 if (exch != NULL) { 204 async_msg_4(exch, MOUSEEV_ABS_MOVE_EVENT, 205 shift_x, shift_y, move_x->logical_maximum, move_y->logical_maximum); 206 async_exchange_end(exch); 207 } 208 209 // Even if we move the mouse absolutely, we need to resolve wheel 210 shift_x = shift_y = 0; 211 } 212 213 214 if (shift_x || shift_y || shift_z) { 191 215 async_exch_t *exch = 192 216 async_exchange_begin(mouse_dev->mouse_sess); 193 217 if (exch != NULL) { 194 218 async_msg_3(exch, MOUSEEV_MOVE_EVENT, 195 shift_x, shift_y, wheel);219 shift_x, shift_y, shift_z); 196 220 async_exchange_end(exch); 197 221 }
Note:
See TracChangeset
for help on using the changeset viewer.