Changeset 1875a0c in mainline for uspace/srv/hid/input/proto/adb.c


Ignore:
Timestamp:
2011-06-21T19:10:20Z (13 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
022d9f67
Parents:
a9d85df
Message:

input server improvements

  • integrate legacy port mouse drivers (PS/2, ADB) into the input server (to be on par with the legacy keyboard drivers)
  • create generic port/protocol layers for the mouse in the input server
  • rename the "hid_in" namespace to "hid" namespace (hid_in/input was rather redundant)
  • rename the mouse event IPC messages to be more consistent with the keyboard event messages
  • rename input server ops structure members to be more generic (parse_scancode → parse)
  • cstyle changes (newlines, comments, printouts)
File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/input/proto/adb.c

    ra9d85df r1875a0c  
    11/*
    2  * Copyright (c) 2010 Jiri Svoboda
     2 * Copyright (c) 2011 Martin Decky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup mouse
    30  * @brief
     29/** @addtogroup mouse_proto
     30 * @ingroup input
    3131 * @{
    3232 */
    33 /** @file
     33/**
     34 * @file
     35 * @brief ADB protocol driver.
    3436 */
    3537
    36 #ifndef ADB_MOUSE_H_
    37 #define ADB_MOUSE_H_
     38#include <bool.h>
     39#include <mouse.h>
     40#include <mouse_port.h>
     41#include <mouse_proto.h>
    3842
    39 #include <sys/types.h>
     43static mouse_dev_t *mouse_dev;
     44static bool b1_pressed;
     45static bool b2_pressed;
    4046
    41 #define NAME       "adb_ms"
    42 #define NAMESPACE  "hid_in"
     47static int adb_proto_init(mouse_dev_t *mdev)
     48{
     49        mouse_dev = mdev;
     50        b1_pressed = false;
     51        b2_pressed = false;
     52       
     53        return 0;
     54}
    4355
    44 extern void mouse_handle_data(uint16_t);
     56/** Process mouse data */
     57static void adb_proto_parse(sysarg_t data)
     58{
     59        bool b1, b2;
     60        uint16_t udx, udy;
     61        int dx, dy;
     62       
     63        /* Extract fields. */
     64        b1 = ((data >> 15) & 1) == 0;
     65        udy = (data >> 8) & 0x7f;
     66        b2 = ((data >> 7) & 1) == 0;
     67        udx = data & 0x7f;
     68       
     69        /* Decode 7-bit two's complement signed values. */
     70        dx = (udx & 0x40) ? (udx - 0x80) : udx;
     71        dy = (udy & 0x40) ? (udy - 0x80) : udy;
     72       
     73        if (b1 != b1_pressed) {
     74                mouse_push_event_button(mouse_dev, 1, b1);
     75                b1_pressed = b1;
     76        }
     77       
     78        if (b2 != b2_pressed) {
     79                mouse_push_event_button(mouse_dev, 2, b2);
     80                b1_pressed = b1;
     81        }
     82       
     83        if (dx != 0 || dy != 0)
     84                mouse_push_event_move(mouse_dev, dx, dy);
     85}
    4586
    46 #endif
     87mouse_proto_ops_t adb_proto = {
     88        .parse = adb_proto_parse,
     89        .init = adb_proto_init
     90};
    4791
    4892/**
Note: See TracChangeset for help on using the changeset viewer.