Ignore:
File:
1 edited

Legend:

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

    r3ef91c88 r4a4c8bcf  
    3434 * Actual handling of USB mouse protocol.
    3535 */
    36 #include "mouse.h"
     36
    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"
    4143
    4244/** Mouse polling callback.
    4345 *
    44  * @param dev Device that is being polled.
     46 * @param dev    Device that is being polled.
    4547 * @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 *
    4851 * @return Always true.
     52 *
    4953 */
    50 bool usb_mouse_polling_callback(usb_device_t *dev,
    51     uint8_t *buffer, size_t buffer_size, void *arg)
     54bool usb_mouse_polling_callback(usb_device_t *dev, uint8_t *buffer,
     55    size_t size, void *arg)
    5256{
    5357        usb_mouse_t *mouse = (usb_mouse_t *) arg;
    54 
     58       
    5559        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       
    5862        uint8_t butt = buffer[0];
    5963        char str_buttons[4] = {
     
    6367                0
    6468        };
    65 
     69       
    6670        int shift_x = ((int) buffer[1]) - 127;
    6771        int shift_y = ((int) buffer[2]) - 127;
    6872        int wheel = ((int) buffer[3]) - 127;
    69 
    70         if (buffer[1] == 0) {
     73       
     74        if (buffer[1] == 0)
    7175                shift_x = 0;
    72         }
    73         if (buffer[2] == 0) {
     76       
     77        if (buffer[2] == 0)
    7478                shift_y = 0;
    75         }
    76         if (buffer[3] == 0) {
     79       
     80        if (buffer[3] == 0)
    7781                wheel = 0;
    78         }
    79 
    80         if (mouse->console_phone >= 0) {
     82       
     83        if (mouse->console_sess) {
    8184                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);
    8690                }
    8791                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);
    9398                }
    9499        }
    95 
     100       
    96101        usb_log_debug("buttons=%s  dX=%+3d  dY=%+3d  wheel=%+3d\n",
    97102            str_buttons, shift_x, shift_y, wheel);
    98 
     103       
    99104        /* Guess. */
    100105        async_usleep(1000);
    101 
     106       
    102107        return true;
    103108}
     
    105110/** Callback when polling is terminated.
    106111 *
    107  * @param dev Device where the polling terminated.
     112 * @param dev              Device where the polling terminated.
    108113 * @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 *
    111117 */
    112 void usb_mouse_polling_ended_callback(usb_device_t *dev,
    113     bool recurring_errors, void *arg)
     118void usb_mouse_polling_ended_callback(usb_device_t *dev, bool recurring_errors,
     119    void *arg)
    114120{
    115121        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       
    120126        usb_device_destroy(dev);
    121127}
Note: See TracChangeset for help on using the changeset viewer.