source: mainline/uspace/srv/hid/isdv4_tablet/isdv4.h

Last change on this file was 5b0cf63, checked in by Jiri Svoboda <jiri@…>, 7 years ago

A round of cstyle fixing (i.e. run make ccheck-fix).

  • 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,
77 PRESS,
78 RELEASE,
79 PROXIMITY_IN,
80 PROXIMITY_OUT,
81 MOVE
82} isdv4_event_type_t;
83
84typedef enum {
85 STYLUS_TIP,
86 STYLUS_ERASER,
87 TOUCH
88} isdv4_source_type_t;
89
90struct isdv4_event {
91 isdv4_event_type_t type;
92 isdv4_source_type_t source;
93 unsigned int x;
94 unsigned int y;
95 unsigned int pressure;
96 unsigned int button;
97};
98
99extern errno_t isdv4_init(isdv4_state_t *, async_sess_t *, isdv4_event_fn);
100extern errno_t isdv4_init_tablet(isdv4_state_t *);
101extern errno_t isdv4_read_events(isdv4_state_t *state);
102extern void isdv4_fini(isdv4_state_t *);
103
104#endif
Note: See TracBrowser for help on using the repository browser.