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