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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since c4c6025 was c4c6025, checked in by Jiri Svoboda <jiri@…>, 8 years ago

Add C API for serial port control.

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