Debian Codegraph @

src/core/util_hid.h

raw symbols SCIP
1 /*----------------------------------------------------------------------------
2 ChucK Strongly-timed Audio Programming Language
3 Compiler, Virtual Machine, and Synthesis Engine
4
5 Copyright (c) 2003 Ge Wang and Perry R. Cook. All rights reserved.
6 http://chuck.stanford.edu/
7 http://chuck.cs.princeton.edu/
8
9 This program is free software; you can redistribute it and/or modify
10 it under the dual-license terms of EITHER the MIT License OR the GNU
11 General Public License (the latter as published by the Free Software
12 Foundation; either version 2 of the License or, at your option, any
13 later version).
14
15 This program is distributed in the hope that it will be useful and/or
16 interesting, but WITHOUT ANY WARRANTY; without even the implied warranty
17 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 MIT Licence and/or the GNU General Public License for details.
19
20 You should have received a copy of the MIT License and the GNU General
21 Public License (GPL) along with this program; a copy of the GPL can also
22 be obtained by writing to the Free Software Foundation, Inc., 59 Temple
23 Place, Suite 330, Boston, MA 02111-1307 U.S.A.
24 -----------------------------------------------------------------------------*/
25
26 //-----------------------------------------------------------------------------
27 // file: util_hid.h
28 // desc: header file for joystick/mouse/keyboard support
29 //
30 // author: Spencer Salazar ([email protected])
31 // date: spring 2006
32 //-----------------------------------------------------------------------------
33 #ifndef __UTIL_HID_H__
34 #define __UTIL_HID_H__
35
36 #include "chuck_def.h"
37
38
39 //-----------------------------------------------------------------------------
40 // definitions
41 //-----------------------------------------------------------------------------
42 struct HidMsg
43 {
44 t_CKINT device_type; // device type
45 t_CKINT device_num; // device number
46 t_CKINT type; // message type
47 t_CKINT eid; // element id
48 #ifdef _WIN64 // REFACTOR-2017
49 long idata[4]; // int data (code using this expects a "long" rather than a "t_CKINT")
50 #else
51 t_CKINT idata[4]; // int data
52 #endif
53 t_CKFLOAT fdata[4]; // float data
54
55 #ifdef __cplusplus
56 HidMsg()
57 { this->clear(); }
58
59 void clear()
60 {
61 memset( this, 0, sizeof(HidMsg) );
62 }
63 #endif
64 };
65
66
67 /* device types */
68 extern const t_CKUINT CK_HID_DEV_NONE;
69 extern const t_CKUINT CK_HID_DEV_JOYSTICK;
70 extern const t_CKUINT CK_HID_DEV_MOUSE;
71 extern const t_CKUINT CK_HID_DEV_KEYBOARD;
72 extern const t_CKUINT CK_HID_DEV_WIIREMOTE;
73 extern const t_CKUINT CK_HID_DEV_TILTSENSOR;
74 extern const t_CKUINT CK_HID_DEV_TABLET;
75 extern const t_CKUINT CK_HID_DEV_MULTITOUCH;
76 extern const t_CKUINT CK_HID_DEV_COUNT;
77
78 /* message types */
79 extern const t_CKUINT CK_HID_JOYSTICK_AXIS;
80 extern const t_CKUINT CK_HID_BUTTON_DOWN;
81 extern const t_CKUINT CK_HID_BUTTON_UP;
82 extern const t_CKUINT CK_HID_JOYSTICK_HAT;
83 extern const t_CKUINT CK_HID_JOYSTICK_BALL;
84 extern const t_CKUINT CK_HID_MOUSE_MOTION;
85 extern const t_CKUINT CK_HID_MOUSE_WHEEL;
86 extern const t_CKUINT CK_HID_DEVICE_CONNECTED;
87 extern const t_CKUINT CK_HID_DEVICE_DISCONNECTED;
88 extern const t_CKUINT CK_HID_ACCELEROMETER;
89 extern const t_CKUINT CK_HID_WIIREMOTE_IR;
90 extern const t_CKUINT CK_HID_LED;
91 extern const t_CKUINT CK_HID_FORCE_FEEDBACK;
92 extern const t_CKUINT CK_HID_SPEAKER;
93 extern const t_CKUINT CK_HID_TABLET_PRESSURE;
94 extern const t_CKUINT CK_HID_TABLET_MOTION;
95 extern const t_CKUINT CK_HID_TABLET_ROTATION;
96 extern const t_CKUINT CK_HID_MULTITOUCH_TOUCH;
97 extern const t_CKUINT CK_HID_MSG_COUNT;
98
99 /* keys */
100
101 /* extension API */
102
103 enum HidResult
104 {
105 HID_GENERALERROR = -1,
106 HID_NOERROR = 0,
107 };
108
109 struct _Chuck_Hid_Driver
110 {
111 void ( *init )();
112 void ( *quit )();
113 void ( *poll )();
114 void ( *probe )();
115 int ( *count )();
116 int ( *count_elements )( int, int );
117 int ( *open )( int );
118 int ( *open_async )( int );
119 int ( *close )( int );
120 int ( *send )( int, const HidMsg * );
121 int ( *read )( int, int, int, HidMsg * );
122 const char * ( *name )( int );
123 const char * driver_name;
124 };
125 typedef struct _Chuck_Hid_Driver Chuck_Hid_Driver;
126
127 /* functions */
128 extern void Hid_init();
129 extern void Hid_poll();
130 extern void Hid_quit();
131
132 extern void Joystick_init();
133 extern void Joystick_poll();
134 extern void Joystick_quit();
135 extern void Joystick_probe();
136 extern int Joystick_count();
137 extern int Joystick_count_elements( int js, int type );
138 extern int Joystick_open( int js );
139 extern int Joystick_open_async( int js );
140 extern int Joystick_open( const char * name );
141 extern int Joystick_close( int js );
142 extern int Joystick_send( int js, const HidMsg * msg );
143 extern const char * Joystick_name( int js );
144
145 extern int Joystick_axes( int js );
146 extern int Joystick_buttons( int js );
147 extern int Joystick_hats( int js );
148
149 extern void Mouse_init();
150 extern void Mouse_poll();
151 extern void Mouse_quit();
152 extern void Mouse_probe();
153 extern int Mouse_count();
154 extern int Mouse_count_elements( int js, int type );
155 extern int Mouse_open( int m );
156 extern int Mouse_open( const char * name );
157 extern int Mouse_close( int m );
158 extern int Mouse_send( int m, const HidMsg * msg );
159 extern const char * Mouse_name( int m );
160 extern int Mouse_buttons( int m );
161 extern int Mouse_start_cursor_track();
162 extern int Mouse_stop_cursor_track();
163
164 extern void Keyboard_init();
165 extern void Keyboard_poll();
166 extern void Keyboard_quit();
167 extern void Keyboard_probe();
168 extern int Keyboard_count();
169 extern int Keyboard_count_elements( int js, int type );
170 extern int Keyboard_open( int kb );
171 extern int Keyboard_open( const char * name );
172 extern int Keyboard_close( int kb );
173 extern int Keyboard_send( int kb, const HidMsg * msg );
174 extern const char * Keyboard_name( int kb );
175
176 extern void WiiRemote_init();
177 extern void WiiRemote_poll();
178 extern void WiiRemote_quit();
179 extern void WiiRemote_probe();
180 extern int WiiRemote_count();
181 extern int WiiRemote_open( int wr );
182 extern int WiiRemote_open( const char * name );
183 extern int WiiRemote_close( int wr );
184 extern int WiiRemote_send( int wr, const HidMsg * msg );
185 extern const char * WiiRemote_name( int wr );
186
187 extern void TiltSensor_init();
188 extern void TiltSensor_quit();
189 extern void TiltSensor_probe();
190 extern int TiltSensor_count();
191 extern int TiltSensor_open( int ts );
192 extern int TiltSensor_close( int ts );
193 extern int TiltSensor_read( int ts, int type, int num, HidMsg * msg );
194 extern const char * TiltSensor_name( int ts );
195 // ge: SMS multi-thread poll rate
196 t_CKINT TiltSensor_setPollRate( t_CKINT usec );
197 t_CKINT TiltSensor_getPollRate( );
198
199 extern void MultiTouchDevice_init();
200 extern void MultiTouchDevice_quit();
201 extern void MultiTouchDevice_probe();
202 extern int MultiTouchDevice_count();
203 extern int MultiTouchDevice_open( int ts );
204 extern int MultiTouchDevice_close( int ts );
205 extern const char * MultiTouchDevice_name( int ts );
206
207 extern void Tablet_init();
208 extern void Tablet_quit();
209 extern void Tablet_probe();
210 extern int Tablet_count();
211 extern int Tablet_open( int ts );
212 extern int Tablet_close( int ts );
213 extern const char * Tablet_name( int ts );
214
215
216 // get normalized [0,1] mouse cursor position
217 t_CKVEC2 ck_get_mouse_xy_normalize();
218 // get absolute mouse cursor position
219 t_CKVEC2 ck_get_mouse_xy_absolute();
220
221
222
223
224 #endif