source: mainline/uspace/srv/hid/input/port/adb_mouse.c@ f1fae414

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since f1fae414 was 1875a0c, checked in by Martin Decky <martin@…>, 14 years ago

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)
  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 * Copyright (c) 2011 Martin Decky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup mouse_port
30 * @ingroup mouse
31 * @{
32 */
33/** @file
34 * @brief ADB mouse port driver.
35 */
36
37#include <ipc/adb.h>
38#include <async.h>
39#include <input.h>
40#include <mouse_port.h>
41#include <mouse.h>
42#include <errno.h>
43#include <devmap.h>
44
45static mouse_dev_t *mouse_dev;
46static async_sess_t *dev_sess;
47
48static void mouse_port_events(ipc_callid_t iid, ipc_call_t *icall, void *arg)
49{
50 /* Ignore parameters, the connection is already opened */
51 while (true) {
52 ipc_call_t call;
53 ipc_callid_t callid = async_get_call(&call);
54
55 int retval;
56
57 if (!IPC_GET_IMETHOD(call)) {
58 /* TODO: Handle hangup */
59 return;
60 }
61
62 switch (IPC_GET_IMETHOD(call)) {
63 case ADB_REG_NOTIF:
64 mouse_push_data(mouse_dev, IPC_GET_ARG1(call));
65 break;
66 default:
67 retval = ENOENT;
68 }
69
70 async_answer_0(callid, retval);
71 }
72}
73
74static int adb_port_init(mouse_dev_t *mdev)
75{
76 const char *dev = "adb/mouse";
77
78 mouse_dev = mdev;
79
80 devmap_handle_t handle;
81 int rc = devmap_device_get_handle(dev, &handle, 0);
82 if (rc != EOK)
83 return rc;
84
85 dev_sess = devmap_device_connect(EXCHANGE_ATOMIC, handle, 0);
86 if (dev_sess == NULL) {
87 printf("%s: Failed to connect to device\n", NAME);
88 return ENOENT;
89 }
90
91 async_exch_t *exch = async_exchange_begin(dev_sess);
92 if (exch == NULL) {
93 printf("%s: Failed starting exchange with device\n", NAME);
94 async_hangup(dev_sess);
95 return ENOMEM;
96 }
97
98 /* NB: The callback connection is slotted for removal */
99 rc = async_connect_to_me(exch, 0, 0, 0, mouse_port_events, NULL);
100 async_exchange_end(exch);
101 if (rc != EOK) {
102 printf("%s: Failed to create callback from device\n", NAME);
103 async_hangup(dev_sess);
104 return rc;
105 }
106
107 return EOK;
108}
109
110static void adb_port_yield(void)
111{
112}
113
114static void adb_port_reclaim(void)
115{
116}
117
118static void adb_port_write(uint8_t data)
119{
120}
121
122mouse_port_ops_t adb_mouse_port = {
123 .init = adb_port_init,
124 .yield = adb_port_yield,
125 .reclaim = adb_port_reclaim,
126 .write = adb_port_write
127};
128
129/**
130 * @}
131 */
Note: See TracBrowser for help on using the repository browser.