Changes in uspace/drv/usbmouse/mouse.c [3ef91c88:4a4c8bcf] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbmouse/mouse.c
r3ef91c88 r4a4c8bcf 34 34 * Actual handling of USB mouse protocol. 35 35 */ 36 #include "mouse.h" 36 37 37 #include <usb/debug.h> 38 38 #include <errno.h> 39 39 #include <str_error.h> 40 40 #include <ipc/mouse.h> 41 #include <async.h> 42 #include "mouse.h" 41 43 42 44 /** Mouse polling callback. 43 45 * 44 * @param dev Device that is being polled.46 * @param dev Device that is being polled. 45 47 * @param buffer Data buffer. 46 * @param buffer_size Buffer size in bytes. 47 * @param arg Custom argument - points to usb_mouse_t. 48 * @param size Buffer size in bytes. 49 * @param arg Pointer to usb_mouse_t. 50 * 48 51 * @return Always true. 52 * 49 53 */ 50 bool usb_mouse_polling_callback(usb_device_t *dev, 51 uint8_t *buffer, size_t buffer_size, void *arg)54 bool usb_mouse_polling_callback(usb_device_t *dev, uint8_t *buffer, 55 size_t size, void *arg) 52 56 { 53 57 usb_mouse_t *mouse = (usb_mouse_t *) arg; 54 58 55 59 usb_log_debug2("got buffer: %s.\n", 56 usb_debug_str_buffer(buffer, buffer_size, 0));57 60 usb_debug_str_buffer(buffer, size, 0)); 61 58 62 uint8_t butt = buffer[0]; 59 63 char str_buttons[4] = { … … 63 67 0 64 68 }; 65 69 66 70 int shift_x = ((int) buffer[1]) - 127; 67 71 int shift_y = ((int) buffer[2]) - 127; 68 72 int wheel = ((int) buffer[3]) - 127; 69 70 if (buffer[1] == 0) {73 74 if (buffer[1] == 0) 71 75 shift_x = 0; 72 }73 if (buffer[2] == 0) {76 77 if (buffer[2] == 0) 74 78 shift_y = 0; 75 }76 if (buffer[3] == 0) {79 80 if (buffer[3] == 0) 77 81 wheel = 0; 78 } 79 80 if (mouse->console_phone >= 0) { 82 83 if (mouse->console_sess) { 81 84 if ((shift_x != 0) || (shift_y != 0)) { 82 /* FIXME: guessed for QEMU */ 83 async_req_2_0(mouse->console_phone, 84 MEVENT_MOVE, 85 - shift_x / 10, - shift_y / 10); 85 // FIXME: guessed for QEMU 86 87 async_exch_t *exch = async_exchange_begin(mouse->console_sess); 88 async_req_2_0(exch, MEVENT_MOVE, -shift_x / 10, -shift_y / 10); 89 async_exchange_end(exch); 86 90 } 87 91 if (butt) { 88 /* FIXME: proper button clicking. */ 89 async_req_2_0(mouse->console_phone, 90 MEVENT_BUTTON, 1, 1); 91 async_req_2_0(mouse->console_phone, 92 MEVENT_BUTTON, 1, 0); 92 // FIXME: proper button clicking 93 94 async_exch_t *exch = async_exchange_begin(mouse->console_sess); 95 async_req_2_0(exch, MEVENT_BUTTON, 1, 1); 96 async_req_2_0(exch, MEVENT_BUTTON, 1, 0); 97 async_exchange_end(exch); 93 98 } 94 99 } 95 100 96 101 usb_log_debug("buttons=%s dX=%+3d dY=%+3d wheel=%+3d\n", 97 102 str_buttons, shift_x, shift_y, wheel); 98 103 99 104 /* Guess. */ 100 105 async_usleep(1000); 101 106 102 107 return true; 103 108 } … … 105 110 /** Callback when polling is terminated. 106 111 * 107 * @param dev Device where the polling terminated.112 * @param dev Device where the polling terminated. 108 113 * @param recurring_errors Whether the polling was terminated due to 109 * recurring errors. 110 * @param arg Custom argument - points to usb_mouse_t. 114 * recurring errors. 115 * @param arg Pointer to usb_mouse_t. 116 * 111 117 */ 112 void usb_mouse_polling_ended_callback(usb_device_t *dev, 113 bool recurring_errors,void *arg)118 void usb_mouse_polling_ended_callback(usb_device_t *dev, bool recurring_errors, 119 void *arg) 114 120 { 115 121 usb_mouse_t *mouse = (usb_mouse_t *) arg; 116 117 async_hangup(mouse->console_ phone);118 mouse->console_ phone = -1;119 122 123 async_hangup(mouse->console_sess); 124 mouse->console_sess = NULL; 125 120 126 usb_device_destroy(dev); 121 127 }
Note:
See TracChangeset
for help on using the changeset viewer.