source: mainline/uspace/srv/hid/isdv4_tablet/isdv4.h@ 5a6cc679

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 5a6cc679 was 5a6cc679, checked in by Jenda <jenda.jzqk73@…>, 8 years ago

Merge commit '50f19b7ee8e94570b5c63896736c4eb49cfa18db' into forwardport

Not all ints are converted to errno_t in xhci tree yet, however it compiles and works :)

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 * Copyright (c) 2012 Martin Sucha
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#ifndef ISDV4_H_
30#define ISDV4_H_
31
32#include <async.h>
33#include <io/chardev.h>
34
35typedef struct isdv4_event isdv4_event_t;
36
37typedef void (*isdv4_event_fn)(const isdv4_event_t *);
38
39typedef struct {
40 /* Stylus information */
41 unsigned int stylus_max_x;
42 unsigned int stylus_max_y;
43 unsigned int stylus_max_pressure;
44 unsigned int stylus_max_xtilt;
45 unsigned int stylus_max_ytilt;
46 bool stylus_tilt_supported;
47
48 /* Touch information */
49 unsigned int touch_type;
50 unsigned int touch_max_x;
51 unsigned int touch_max_y;
52
53 /* Event state */
54 bool stylus_in_proximity;
55 bool stylus_is_eraser;
56 bool tip_pressed; /* Reported as stylus button 1 */
57 bool button1_pressed; /* Reported as stylus button 2 */
58 bool button2_pressed; /* Reported as stylus button 3 */
59 bool finger1_pressed; /* Reported as touch button 1 */
60
61 /** Session with the serial device */
62 async_sess_t *sess;
63 /** Character device */
64 chardev_t *chardev;
65
66 /* Receive buffer state */
67 uint8_t *buf;
68 size_t buf_size;
69 size_t buf_end;
70
71 /** Callbacks */
72 isdv4_event_fn emit_event_fn;
73} isdv4_state_t;
74
75typedef enum {
76 UNKNOWN, PRESS, RELEASE, PROXIMITY_IN, PROXIMITY_OUT, MOVE
77} isdv4_event_type_t;
78
79typedef enum {
80 STYLUS_TIP, STYLUS_ERASER, TOUCH
81} isdv4_source_type_t;
82
83struct isdv4_event {
84 isdv4_event_type_t type;
85 isdv4_source_type_t source;
86 unsigned int x;
87 unsigned int y;
88 unsigned int pressure;
89 unsigned int button;
90};
91
92extern errno_t isdv4_init(isdv4_state_t *, async_sess_t *, isdv4_event_fn);
93extern errno_t isdv4_init_tablet(isdv4_state_t *);
94extern errno_t isdv4_read_events(isdv4_state_t *state);
95extern void isdv4_fini(isdv4_state_t *);
96
97#endif
Note: See TracBrowser for help on using the repository browser.