-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathveikk.h
134 lines (113 loc) · 3.91 KB
/
veikk.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* Veikk S640 (and others) driver tablet -- still in production
* Heavily guided by the Wacom driver (drivers/hid/wacom*)
* @author Jonathan Lam <[email protected]>
*/
#ifndef VEIKK_H
#define VEIKK_H
#include <linux/hid.h>
#include <linux/input.h>
#include <linux/types.h>
#include <linux/usb.h>
#define VEIKK_VENDOR_ID 0x2FEB
#define VEIKK_DRIVER_VERSION "2.0"
#define VEIKK_DRIVER_DESC "USB VEIKK drawing tablet driver"
#define VEIKK_DRIVER_LICENSE "GPL"
#define VEIKK_PEN_REPORT 0x0001
#define VEIKK_STYLUS_REPORT 0x0002 // equivalent to pen report
// supported module parameter types
// TODO: currently not used; may remove in future; however, is used in the
// configuration tool
enum veikk_modparm {
VEIKK_MP_SCREEN_MAP,
VEIKK_MP_SCREEN_SIZE,
VEIKK_MP_PRESSURE_MAP,
VEIKK_MP_ORIENTATION
};
// generic struct for representing rectangular geometries (physical/mappings)
// currently only used for
struct veikk_rect {
s32 x, y;
u32 width, height;
};
// structure of module parameters (module parameters are just integer-serialized
// versions of these structs); used to easily deserialize module parameters,
// but easier and more consistent to represent everything with struct veikk_rect
// for general use
struct veikk_screen_size {
u16 width, height;
};
struct veikk_screen_map {
s16 x, y;
u16 width, height;
};
struct veikk_pressure_map {
s16 a0, a1, a2, a3;
};
enum veikk_orientation {
VEIKK_OR_DFL=0,
VEIKK_OR_CCW,
VEIKK_OR_FLIP,
VEIKK_OR_CW
};
// pen input report -- structure of input report from tablet
struct veikk_pen_report {
u8 report_id;
u8 buttons;
u16 x, y, pressure;
};
// device-specific properties; one created for every device. These
// characteristics should not be modified anywhere in the program; any
// modifiable properties (e.g., mapped characteristics) should be copied
// over to the device's struct veikk before modifying
struct veikk;
struct veikk_device_info {
// identifiers
const char *name;
const int prod_id;
// physical characteristics; acts as defaults for mapped characteristics
const int x_max, y_max, pressure_max;
// device-specific handlers
int (*alloc_input_devs)(struct veikk *veikk);
int (*setup_and_register_input_devs)(struct veikk *veikk);
int (*handle_raw_data)(struct veikk *veikk, u8 *data, int size,
unsigned int report_id);
int (*handle_modparm_change)(struct veikk *veikk);
};
// common properties for veikk devices
struct veikk {
// hardware details
struct hid_device *hdev;
// device-specific properties
const struct veikk_device_info *vdinfo;
// mapped digitizer characteristics; initialized with defaults from
// struct veikk_device_info
struct veikk_rect map_rect;
int pressure_map[4];
// these are used for orientation mapping
int x_map_axis, y_map_axis, x_map_dir, y_map_dir;
struct input_dev *pen_input;
struct list_head lh;
};
// from veikk_drv.c
extern struct list_head vdevs;
extern struct mutex vdevs_mutex;
int veikk_input_open(struct input_dev *dev);
void veikk_input_close(struct input_dev *dev);
// from veikk_vdev.c
extern const struct hid_device_id veikk_ids[];
// from veikk_modparms.c
extern struct veikk_rect veikk_screen_map;
extern struct veikk_rect veikk_screen_size;
extern enum veikk_orientation veikk_orientation;
extern struct veikk_pressure_map veikk_pressure_map;
// module parameter (configuration) helper
void veikk_configure_input_devs(struct veikk_rect ss,
struct veikk_rect sm,
enum veikk_orientation or,
struct veikk *veikk);
// calculate pressure map -- for use in raw_event handler
int veikk_map_pressure(s64 pres, s64 pres_max,
struct veikk_pressure_map *coef);
#endif