Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbmouse/mouse.c

    r4a4c8bcf r3ef91c88  
    3434 * Actual handling of USB mouse protocol.
    3535 */
    36 
     36#include "mouse.h"
    3737#include <usb/debug.h>
    3838#include <errno.h>
    3939#include <str_error.h>
    4040#include <ipc/mouse.h>
    41 #include <async.h>
    42 #include "mouse.h"
    4341
    4442/** Mouse polling callback.
    4543 *
    46  * @param dev    Device that is being polled.
     44 * @param dev Device that is being polled.
    4745 * @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.
    5148 * @return Always true.
    52  *
    5349 */
    54 bool usb_mouse_polling_callback(usb_device_t *dev, uint8_t *buffer,
    55     size_t size, void *arg)
     50bool usb_mouse_polling_callback(usb_device_t *dev,
     51    uint8_t *buffer, size_t buffer_size, void *arg)
    5652{
    5753        usb_mouse_t *mouse = (usb_mouse_t *) arg;
    58        
     54
    5955        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
    6258        uint8_t butt = buffer[0];
    6359        char str_buttons[4] = {
     
    6763                0
    6864        };
    69        
     65
    7066        int shift_x = ((int) buffer[1]) - 127;
    7167        int shift_y = ((int) buffer[2]) - 127;
    7268        int wheel = ((int) buffer[3]) - 127;
    73        
    74         if (buffer[1] == 0)
     69
     70        if (buffer[1] == 0) {
    7571                shift_x = 0;
    76        
    77         if (buffer[2] == 0)
     72        }
     73        if (buffer[2] == 0) {
    7874                shift_y = 0;
    79        
    80         if (buffer[3] == 0)
     75        }
     76        if (buffer[3] == 0) {
    8177                wheel = 0;
    82        
    83         if (mouse->console_sess) {
     78        }
     79
     80        if (mouse->console_phone >= 0) {
    8481                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);
    9086                }
    9187                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);
    9893                }
    9994        }
    100        
     95
    10196        usb_log_debug("buttons=%s  dX=%+3d  dY=%+3d  wheel=%+3d\n",
    10297            str_buttons, shift_x, shift_y, wheel);
    103        
     98
    10499        /* Guess. */
    105100        async_usleep(1000);
    106        
     101
    107102        return true;
    108103}
     
    110105/** Callback when polling is terminated.
    111106 *
    112  * @param dev              Device where the polling terminated.
     107 * @param dev Device where the polling terminated.
    113108 * @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.
    117111 */
    118 void usb_mouse_polling_ended_callback(usb_device_t *dev, bool recurring_errors,
    119     void *arg)
     112void usb_mouse_polling_ended_callback(usb_device_t *dev,
     113    bool recurring_errors, void *arg)
    120114{
    121115        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
    126120        usb_device_destroy(dev);
    127121}
Note: See TracChangeset for help on using the changeset viewer.