Changeset b670523 in mainline for uspace/drv/usbmouse/mouse.c


Ignore:
Timestamp:
2011-06-09T20:42:27Z (13 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9ec25a6
Parents:
503e4e3 (diff), 390d80d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline

File:
1 edited

Legend:

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

    r503e4e3 rb670523  
    4040#include <ipc/mouse.h>
    4141#include <async.h>
    42 #include <async_obsolete.h>
    4342#include "mouse.h"
    4443
    4544/** Mouse polling callback.
    4645 *
    47  * @param dev Device that is being polled.
     46 * @param dev    Device that is being polled.
    4847 * @param buffer Data buffer.
    49  * @param buffer_size Buffer size in bytes.
    50  * @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 *
    5151 * @return Always true.
     52 *
    5253 */
    53 bool usb_mouse_polling_callback(usb_device_t *dev,
    54     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)
    5556{
    5657        usb_mouse_t *mouse = (usb_mouse_t *) arg;
    57 
     58       
    5859        usb_log_debug2("got buffer: %s.\n",
    59             usb_debug_str_buffer(buffer, buffer_size, 0));
    60 
     60            usb_debug_str_buffer(buffer, size, 0));
     61       
    6162        uint8_t butt = buffer[0];
    6263        char str_buttons[4] = {
     
    6667                0
    6768        };
    68 
     69       
    6970        int shift_x = ((int) buffer[1]) - 127;
    7071        int shift_y = ((int) buffer[2]) - 127;
    7172        int wheel = ((int) buffer[3]) - 127;
    72 
    73         if (buffer[1] == 0) {
     73       
     74        if (buffer[1] == 0)
    7475                shift_x = 0;
    75         }
    76         if (buffer[2] == 0) {
     76       
     77        if (buffer[2] == 0)
    7778                shift_y = 0;
    78         }
    79         if (buffer[3] == 0) {
     79       
     80        if (buffer[3] == 0)
    8081                wheel = 0;
    81         }
    82 
    83         if (mouse->console_phone >= 0) {
     82       
     83        if (mouse->console_sess) {
    8484                if ((shift_x != 0) || (shift_y != 0)) {
    85                         /* FIXME: guessed for QEMU */
    86                         async_obsolete_req_2_0(mouse->console_phone,
    87                             MEVENT_MOVE,
    88                             - 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);
    8990                }
    9091                if (butt) {
    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);
     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);
    9698                }
    9799        }
    98 
     100       
    99101        usb_log_debug("buttons=%s  dX=%+3d  dY=%+3d  wheel=%+3d\n",
    100102            str_buttons, shift_x, shift_y, wheel);
    101 
     103       
    102104        /* Guess. */
    103105        async_usleep(1000);
    104 
     106       
    105107        return true;
    106108}
     
    108110/** Callback when polling is terminated.
    109111 *
    110  * @param dev Device where the polling terminated.
     112 * @param dev              Device where the polling terminated.
    111113 * @param recurring_errors Whether the polling was terminated due to
    112  *      recurring errors.
    113  * @param arg Custom argument - points to usb_mouse_t.
     114 *                         recurring errors.
     115 * @param arg              Pointer to usb_mouse_t.
     116 *
    114117 */
    115 void usb_mouse_polling_ended_callback(usb_device_t *dev,
    116     bool recurring_errors, void *arg)
     118void usb_mouse_polling_ended_callback(usb_device_t *dev, bool recurring_errors,
     119    void *arg)
    117120{
    118121        usb_mouse_t *mouse = (usb_mouse_t *) arg;
    119 
    120         async_obsolete_hangup(mouse->console_phone);
    121         mouse->console_phone = -1;
    122 
     122       
     123        async_hangup(mouse->console_sess);
     124        mouse->console_sess = NULL;
     125       
    123126        usb_device_destroy(dev);
    124127}
Note: See TracChangeset for help on using the changeset viewer.