Ignore:
File:
1 edited

Legend:

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

    r4a4c8bcf r79ae36dd  
    4040#include <ipc/mouse.h>
    4141#include <async.h>
     42#include <async_obsolete.h>
    4243#include "mouse.h"
    4344
    4445/** Mouse polling callback.
    4546 *
    46  * @param dev    Device that is being polled.
     47 * @param dev Device that is being polled.
    4748 * @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.
    5151 * @return Always true.
    52  *
    5352 */
    54 bool usb_mouse_polling_callback(usb_device_t *dev, uint8_t *buffer,
    55     size_t size, void *arg)
     53bool usb_mouse_polling_callback(usb_device_t *dev,
     54    uint8_t *buffer, size_t buffer_size, void *arg)
    5655{
    5756        usb_mouse_t *mouse = (usb_mouse_t *) arg;
    58        
     57
    5958        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
    6261        uint8_t butt = buffer[0];
    6362        char str_buttons[4] = {
     
    6766                0
    6867        };
    69        
     68
    7069        int shift_x = ((int) buffer[1]) - 127;
    7170        int shift_y = ((int) buffer[2]) - 127;
    7271        int wheel = ((int) buffer[3]) - 127;
    73        
    74         if (buffer[1] == 0)
     72
     73        if (buffer[1] == 0) {
    7574                shift_x = 0;
    76        
    77         if (buffer[2] == 0)
     75        }
     76        if (buffer[2] == 0) {
    7877                shift_y = 0;
    79        
    80         if (buffer[3] == 0)
     78        }
     79        if (buffer[3] == 0) {
    8180                wheel = 0;
    82        
    83         if (mouse->console_sess) {
     81        }
     82
     83        if (mouse->console_phone >= 0) {
    8484                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);
    9089                }
    9190                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);
    9896                }
    9997        }
    100        
     98
    10199        usb_log_debug("buttons=%s  dX=%+3d  dY=%+3d  wheel=%+3d\n",
    102100            str_buttons, shift_x, shift_y, wheel);
    103        
     101
    104102        /* Guess. */
    105103        async_usleep(1000);
    106        
     104
    107105        return true;
    108106}
     
    110108/** Callback when polling is terminated.
    111109 *
    112  * @param dev              Device where the polling terminated.
     110 * @param dev Device where the polling terminated.
    113111 * @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.
    117114 */
    118 void usb_mouse_polling_ended_callback(usb_device_t *dev, bool recurring_errors,
    119     void *arg)
     115void usb_mouse_polling_ended_callback(usb_device_t *dev,
     116    bool recurring_errors, void *arg)
    120117{
    121118        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
    126123        usb_device_destroy(dev);
    127124}
Note: See TracChangeset for help on using the changeset viewer.