xref: /haiku/headers/private/input/keyboard_mouse_driver.h (revision 9a6a20d4689307142a7ed26a1437ba47e244e73f)
1 /*
2  * Copyright 2002-2010, Haiku. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _KEYBOARD_MOUSE_DRIVER_H
6 #define _KEYBOARD_MOUSE_DRIVER_H
7 
8 
9 #include <SupportDefs.h>
10 #include <Drivers.h>
11 
12 
13 // FIXME: these should go in InterfaceDefs.h (in the same enum as B_F1_KEY), but the names would
14 // clash with names in the modifiers enum also defined there, so we would need to first rename the
15 // values in the modifiers enumeration.
16 #define KEY_ShiftL      0x4b
17 #define KEY_ShiftR      0x56
18 #define KEY_ControlL    0x5c
19 #define KEY_CmdL        0x5d
20 #define KEY_AltL        0x5d
21 #define KEY_CmdR        0x5f
22 #define KEY_AltR        0x5f
23 #define KEY_ControlR    0x60
24 #define KEY_OptL        0x66
25 #define KEY_WinL        0x66
26 #define KEY_OptR        0x67
27 #define KEY_WinR        0x67
28 #define KEY_Menu        0x68
29 #define KEY_SysRq       0x7e
30 #define KEY_Break       0x7f
31 
32 #define KB_DEFAULT_CONTROL_ALT_DEL_TIMEOUT 4000000
33 
34 enum {
35 	KB_READ = B_DEVICE_OP_CODES_END,
36 	KB_GET_KEYBOARD_ID,
37 	KB_SET_LEDS,
38 	KB_SET_KEY_REPEATING,
39 	KB_SET_KEY_NONREPEATING,
40 	KB_SET_KEY_REPEAT_RATE,
41 	KB_GET_KEY_REPEAT_RATE,
42 	KB_SET_KEY_REPEAT_DELAY,
43 	KB_GET_KEY_REPEAT_DELAY,
44 	KB_SET_CONTROL_ALT_DEL_TIMEOUT,
45 	KB_RESERVED_1,
46 	KB_CANCEL_CONTROL_ALT_DEL,
47 	KB_DELAY_CONTROL_ALT_DEL,
48 	KB_SET_DEBUG_READER,
49 
50 	MS_READ = B_DEVICE_OP_CODES_END + 100,
51 	MS_NUM_EVENTS,
52 	MS_GET_ACCEL,
53 	MS_SET_ACCEL,
54 	MS_GET_TYPE,
55 	MS_SET_TYPE,
56 	MS_GET_MAP,
57 	MS_SET_MAP,
58 	MS_GET_CLICKSPEED,
59 	MS_SET_CLICKSPEED,
60 	MS_NUM_SERIAL_MICE,
61 
62 	MS_IS_TOUCHPAD,
63 	MS_READ_TOUCHPAD,
64 
65 	IIC_WRITE = B_DEVICE_OP_CODES_END + 200,
66 	RESTART_SYSTEM,
67 	SHUTDOWN_SYSTEM
68 };
69 
70 
71 typedef struct {
72 	bigtime_t	timestamp;
73 	uint32		keycode;
74 	bool		is_keydown;
75 } raw_key_info;
76 
77 
78 typedef struct {
79 	bool		num_lock;
80 	bool		caps_lock;
81 	bool		scroll_lock;
82 } led_info;
83 
84 
85 typedef struct {
86 	int32		cookie;
87 	uint32		buttons;
88 	int32		xdelta;
89 	int32		ydelta;
90 	int32		clicks;
91 	int32		modifiers;
92 	bigtime_t	timestamp;
93 	int32		wheel_ydelta;
94 	int32		wheel_xdelta;
95 } mouse_movement;
96 
97 
98 #define B_TIP_SWITCH			0x01
99 #define B_SECONDARY_TIP_SWITCH	0x02
100 #define B_BARREL_SWITCH			0x04
101 #define B_ERASER				0x08
102 #define B_TABLET_PICK			0x0F
103 
104 
105 typedef struct {
106 	uint32		buttons;
107 	uint32		switches;
108 	float		xpos;
109 	float		ypos;
110 	bool		has_contact;
111 	float		pressure;
112 	int32		clicks;
113 	bigtime_t	timestamp;
114 	int32		wheel_ydelta;
115 	int32		wheel_xdelta;
116 	float		tilt_x;
117 	float		tilt_y;
118 } tablet_movement;
119 
120 
121 #define B_ONE_FINGER	0x01
122 #define B_TWO_FINGER	0x02
123 #define B_MULTI_FINGER	0x04
124 #define B_PEN			0x08
125 
126 
127 typedef struct {
128 	uint16		edgeMotionWidth;
129 
130 	uint16		width;
131 	uint16		areaStartX;
132 	uint16		areaEndX;
133 	uint16		areaStartY;
134 	uint16		areaEndY;
135 
136 	uint16		minPressure;
137 	// the value you reach when you hammer really hard on the touchpad
138 	uint16		realMaxPressure;
139 	uint16		maxPressure;
140 } touchpad_specs;
141 
142 
143 typedef struct {
144 	uint8		buttons;
145 	uint32		xPosition;
146 	uint32		yPosition;
147 	uint8		zPressure;
148 	uint8		fingers;
149 	bool		gesture;
150 	uint8		fingerWidth;
151 	int32		wheel_ydelta;
152 	int32		wheel_xdelta;
153 	int32		wheel_zdelta;
154 	int32		wheel_wdelta;
155 	// 1 - 4	normal width
156 	// 5 - 11	very wide finger or palm
157 	// 12		maximum reportable width; extreme wide contact
158 } touchpad_movement;
159 
160 
161 typedef struct {
162 	bigtime_t timeout;
163 	int32 event;
164 	union {
165 		touchpad_movement touchpad;
166 		mouse_movement mouse;
167 	} u;
168 } touchpad_read;
169 
170 
171 #endif	// _KB_MOUSE_DRIVER_H
172