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