aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO54
-rw-r--r--doc/hid-help.pd302
-rw-r--r--hid.c28
-rw-r--r--hid.h24
-rw-r--r--hid_darwin.c35
5 files changed, 244 insertions, 199 deletions
diff --git a/TODO b/TODO
index 4cf35cf..27394fd 100644
--- a/TODO
+++ b/TODO
@@ -1,16 +1,24 @@
+______________________________________________________________________________
+- deal with hatswitches!!
+
+Because of the currnently implementation of the conversion of the MacOS X
+style event to the Linux style event, an event with a value of zero is output
+on the unchanged axis when the hatswitch is moved in along the X or Y axis (as
+opposed to diagonally). but this might be fixed...
- fix up hatswitch logic... hmmm
on Mac OS X, just make the next element in the array always be the Y axis of
the hatswitch, then when receiving a hatswitch event, output, increment,
then output again (yes, its a hack).
-- add device type to [info(
-HIDGetUsageName(pCurrentHIDDevice->usagePage, pCurrentHIDDevice->usage, cstrDeviceName);
-
-i.e. cstrDeviceName
+- what do standard hatswitches output on the various platforms? they should
+ probably always output like axes, but then the CUI will be screwed
+______________________________________________________________________________
+= fix key names on Mac OS X
+I think they are unimplemented... :-(
______________________________________________________________________________
= array lookups for symbols
@@ -57,16 +65,6 @@ ______________________________________________________________________________
- for relative axes, sum up all events and output one
http://lists.apple.com/archives/mac-games-dev/2005/Oct/msg00060.html
-- for absolute axes, just output latest value. if they are not in the queue,
- I can check them manually
-
-- buttons, output everything
-
-- is this at all necessary? How often do multiple events happen in one poll
- period? ANSWER: on Mac OS X, most hid_get_events() calls fetch multiple
- events for each mouse axis, so yes, its probably necessary
-
-
______________________________________________________________________________
= [poll 1( message set to exact delay based on block size
@@ -82,8 +80,13 @@ http://mud.5341.com/msg/8455.html
______________________________________________________________________________
-= make second inlet for poll # (for [human->pd])
+= make second inlet for specific status requests [human->pd])
+- [vendor(, [product(
+- [range(
+- [poll(
+- [name(
+- [type(
______________________________________________________________________________
= output device data on open
@@ -192,16 +195,11 @@ ______________________________________________________________________________
______________________________________________________________________________
-= function return values
-
-- most functions probably do not need return values
-
-
-______________________________________________________________________________
= check out using USB timestamp
-- use the USB timestamp to correctly space the output data (meh, probably
- unnecessary)
+- use the USB timestamp to correctly space the output data
+
+(meh, probably not useful)
@@ -216,7 +214,7 @@ ______________________________________________________________________________
______________________________________________________________________________
-- BUG: on Mac OS X, polling starts without hid_build_device_list()
+- BUG: on Mac OS X, polling starts without hid_build_device_list() or hid_open()
- when polling starts, hid_build_device_list() should be called before starting
@@ -250,14 +248,6 @@ This is probably only a problem on relative axes.
followed by one call to HIDGetElementValue()
-______________________________________________________________________________
-- BUG: hatswitches on MacOS X output an event without a change in value
-
-Because of the currnently implementation of the conversion of the MacOS X
-style event to the Linux style event, an event with a value of zero is output
-on the unchanged axis when the hatswitch is moved in along the X or Y axis (as
-opposed to diagonally).
-
______________________________________________________________________________
- BUG: on MacOS X, two keyboard key codes are reported as hatswitches
diff --git a/doc/hid-help.pd b/doc/hid-help.pd
index 304fcf9..e3eec37 100644
--- a/doc/hid-help.pd
+++ b/doc/hid-help.pd
@@ -1,45 +1,45 @@
-#N canvas 59 45 910 595 10;
-#X floatatom 27 454 5 0 0 0 - - -;
-#X floatatom 83 454 5 0 0 0 - - -;
-#X floatatom 63 410 6 0 0 0 - - -;
-#X obj 129 92 tgl 35 0 empty empty empty 0 -6 0 8 -24198 -1 -1 25 25
+#N canvas 59 45 913 587 10;
+#X floatatom 27 439 5 0 0 0 - - -;
+#X floatatom 83 439 5 0 0 0 - - -;
+#X floatatom 63 395 6 0 0 0 - - -;
+#X obj 129 77 tgl 35 0 empty empty empty 0 -6 0 8 -24198 -1 -1 25 25
;
-#X floatatom 571 355 12 0 0 1 value - -;
-#X symbolatom 531 371 15 0 0 1 event_code - -;
-#X symbolatom 492 387 15 0 0 1 event_type - -;
+#X floatatom 571 340 12 0 0 1 value - -;
+#X symbolatom 531 356 15 0 0 1 event_code - -;
+#X symbolatom 492 372 15 0 0 1 event_type - -;
#X obj 2 2 cnv 15 900 20 empty empty [hid] 2 11 1 18 -233017 -66577
0;
-#X text 274 347 outlet message format:;
-#X obj 772 114 ev-list;
-#X obj 772 165 ev_syn-list;
-#X obj 772 187 ev_key-list;
-#X obj 772 209 ev_rel-list;
-#X obj 772 231 ev_abs-list;
-#X obj 772 253 ev_msc-list;
-#X obj 772 275 ev_led-list;
-#X obj 772 297 ev_snd-list;
-#X obj 772 319 ev_rep-list;
-#X obj 772 341 ev_ff-list;
-#X obj 772 363 ev_ff_status-list;
-#X text 740 95 Event Types:;
-#X text 740 146 Event Codes:;
-#X floatatom 138 358 5 0 0 1 ev_syn - -;
-#X obj 111 357 +;
-#X msg 111 337 1;
-#X msg 402 117 close;
-#X msg 402 96 refresh;
-#X text 463 94 refresh device list;
-#X text 537 502 For more info:;
-#X text 266 572 released under the GNU GPL;
-#X text 472 559 $Revision: 1.24 $$Date: 2006-06-02 20:06:51 $;
-#X text 473 572 $Author: eighthave $;
-#X msg 436 216 poll 20;
-#X msg 374 216 poll 2;
-#X text 370 201 start polling and set the poll delay in ms;
-#X text 462 48 !!! This software is very much alpha \, so any aspect
+#X text 274 332 outlet message format:;
+#X obj 772 99 ev-list;
+#X obj 772 150 ev_syn-list;
+#X obj 772 172 ev_key-list;
+#X obj 772 194 ev_rel-list;
+#X obj 772 216 ev_abs-list;
+#X obj 772 238 ev_msc-list;
+#X obj 772 260 ev_led-list;
+#X obj 772 282 ev_snd-list;
+#X obj 772 304 ev_rep-list;
+#X obj 772 326 ev_ff-list;
+#X obj 772 348 ev_ff_status-list;
+#X text 740 80 Event Types:;
+#X text 740 131 Event Codes:;
+#X floatatom 138 343 5 0 0 1 ev_syn - -;
+#X obj 111 342 +;
+#X msg 111 322 1;
+#X msg 402 102 close;
+#X msg 402 81 refresh;
+#X text 463 79 refresh device list;
+#X text 537 487 For more info:;
+#X text 266 557 released under the GNU GPL;
+#X text 472 544 $Revision: 1.25 $$Date: 2006-06-02 21:32:53 $;
+#X text 473 557 $Author: eighthave $;
+#X msg 436 201 poll 20;
+#X msg 374 201 poll 2;
+#X text 370 186 start polling and set the poll delay in ms;
+#X text 462 33 !!! This software is very much alpha \, so any aspect
of it could change without notice !!!;
-#X obj 16 306 route key rel abs syn;
-#X obj 9 517 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1
+#X obj 16 291 route key rel abs syn;
+#X obj 9 502 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1
;
#N canvas 278 328 631 544 Event_Codes 0;
#X text 28 48 (For a complete listing of Linux Input Events \, see
@@ -193,7 +193,7 @@ of it could change without notice !!!;
#X text 138 476 BTN_BASE6;
#X text 245 463 298;
#X text 245 477 299;
-#X restore 774 429 pd Event_Codes;
+#X restore 774 414 pd Event_Codes;
#N canvas 50 289 469 317 Event_Types 0;
#X text 28 48 (For a complete listing of Linux Input Events \, see
/usr/include/linux/input.h.);
@@ -236,144 +236,153 @@ of it could change without notice !!!;
#X text 331 255 22;
#X text 230 255 EV_PWR;
#X text 61 255 Power Events (for UPS);
-#X restore 774 409 pd Event_Types;
+#X restore 774 394 pd Event_Types;
#N canvas 0 22 450 300 Event_Values 0;
#X text 28 48 (For a complete listing of Linux Input Events \, see
/usr/include/linux/input.h.);
#X obj 11 9 cnv 15 400 30 empty empty Event_Values 20 12 1 14 -261681
-66577 0;
-#X restore 774 449 pd Event_Values;
-#X floatatom 140 454 5 0 0 0 - - -;
-#X obj 421 409 route abs_hat0x abs_hat0y abs_hat1x abs_hat1y;
-#X floatatom 421 431 7 0 0 0 - - -;
-#X msg 402 138 print;
-#X obj 304 265 hid 0;
-#X text 465 118 close the device;
-#X text 465 139 print the device and element lists;
-#X text 9 227 Any non-zero value starts polling \,;
-#X text 8 240 0 stops the polling. If the number;
-#X text 9 253 is greater than 1 \, then the poll;
-#X text 9 266 delay is set to that number.;
-#X obj 27 434 route rel_x rel_y rel_z rel_wheel;
-#X floatatom 196 454 5 0 0 0 - - -;
-#X obj 492 336 unpack s s f;
-#X msg 258 125 open \$1;
-#X obj 258 107 hradio 15 1 0 8 empty empty empty 0 -6 0 8 -262144 -1
--1 0;
-#X floatatom 247 126 1 0 0 0 - - -;
-#X text 298 361 event_type event_code value;
-#X obj 63 389 route abs_x abs_y abs_z abs_rx abs_ry abs_rz abs_throttle
+#X restore 774 434 pd Event_Values;
+#X floatatom 140 439 5 0 0 0 - - -;
+#X obj 421 394 route abs_hat0x abs_hat0y abs_hat1x abs_hat1y;
+#X floatatom 421 416 7 0 0 0 - - -;
+#X msg 402 123 print;
+#X obj 304 250 hid 0;
+#X text 465 103 close the device;
+#X text 465 124 print the device and element lists;
+#X text 9 212 Any non-zero value starts polling \,;
+#X text 8 225 0 stops the polling. If the number;
+#X text 9 238 is greater than 1 \, then the poll;
+#X text 9 251 delay is set to that number.;
+#X obj 27 419 route rel_x rel_y rel_z rel_wheel;
+#X floatatom 196 439 5 0 0 0 - - -;
+#X obj 492 321 unpack s s f;
+#X msg 258 110 open \$1;
+#X obj 258 92 hradio 15 1 0 8 empty empty empty 0 -6 0 8 -262144 -1
+-1 2;
+#X floatatom 247 111 1 0 0 0 - - -;
+#X text 298 346 event_type event_code value;
+#X obj 63 374 route abs_x abs_y abs_z abs_rx abs_ry abs_rz abs_throttle
;
-#X obj 421 447 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+#X obj 421 432 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
-1;
-#X floatatom 498 431 7 0 0 0 - - -;
-#X obj 498 447 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+#X floatatom 498 416 7 0 0 0 - - -;
+#X obj 498 432 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
-#X floatatom 576 431 7 0 0 0 - - -;
-#X obj 576 447 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+#X floatatom 576 416 7 0 0 0 - - -;
+#X obj 576 432 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
-#X floatatom 653 431 7 0 0 0 - - -;
-#X obj 653 447 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+#X floatatom 653 416 7 0 0 0 - - -;
+#X obj 653 432 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
1;
-#X floatatom 113 410 6 0 0 0 - - -;
-#X floatatom 163 410 6 0 0 0 - - -;
-#X floatatom 213 410 6 0 0 0 - - -;
-#X floatatom 263 410 6 0 0 0 - - -;
-#X floatatom 313 410 6 0 0 0 - - -;
-#X floatatom 363 410 6 0 0 0 - - -;
-#X obj 39 517 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1
+#X floatatom 113 395 6 0 0 0 - - -;
+#X floatatom 163 395 6 0 0 0 - - -;
+#X floatatom 213 395 6 0 0 0 - - -;
+#X floatatom 263 395 6 0 0 0 - - -;
+#X floatatom 313 395 6 0 0 0 - - -;
+#X floatatom 363 395 6 0 0 0 - - -;
+#X obj 39 502 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1
;
-#X obj 69 517 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1
+#X obj 69 502 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1
;
-#X obj 99 517 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1
+#X obj 99 502 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1
;
-#X obj 129 517 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+#X obj 129 502 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
-#X obj 159 517 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+#X obj 159 502 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
-#X obj 189 517 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+#X obj 189 502 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
-#X obj 219 517 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+#X obj 219 502 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
-#X obj 249 517 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+#X obj 249 502 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
-#X obj 279 517 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+#X obj 279 502 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
-#X obj 309 517 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+#X obj 309 502 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
-#X obj 339 517 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+#X obj 339 502 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
-#X obj 369 517 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+#X obj 369 502 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
-#X obj 399 517 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+#X obj 399 502 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
-#X obj 9 475 route btn_0 btn_1 btn_2 btn_3 btn_4 btn_5 btn_6 btn_7
+#X obj 9 460 route btn_0 btn_1 btn_2 btn_3 btn_4 btn_5 btn_6 btn_7
btn_8 btn_9 btn_10 btn_11 btn_12 btn_13 btn_14 btn_15;
-#X obj 429 517 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+#X obj 429 502 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
-#X obj 459 517 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+#X obj 459 502 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
-#X obj 262 313 cyclone/prepend set;
-#X msg 37 166 debug \$1;
-#X obj 37 144 hradio 15 1 1 10 empty empty empty 0 -6 0 8 -262144 -1
--1 0;
-#X obj 646 501 pddp/pddp_open all_about_hid;
-#X msg 298 160 info;
-#N canvas 477 37 399 223 see 0;
-#N canvas 247 287 550 277 route 0;
-#X obj 53 13 inlet;
-#X obj 98 225 outlet;
-#X obj 45 225 outlet;
-#X obj 198 203 symbol;
-#X obj 198 225 outlet;
-#X obj 258 203 symbol;
-#X obj 258 225 outlet;
-#X obj 318 203 symbol;
-#X obj 318 225 outlet;
-#X obj 378 203 symbol;
-#X obj 378 225 outlet;
-#X obj 438 203 symbol;
-#X obj 438 225 outlet;
-#X obj 52 62 route open device poll product manufacturer transport
-vendorID productID;
-#X obj 148 224 outlet;
+#X obj 262 298 cyclone/prepend set;
+#X msg 37 151 debug \$1;
+#X obj 37 129 hradio 15 1 1 10 empty empty empty 0 -6 0 8 -262144 -1
+-1 5;
+#X obj 646 486 pddp/pddp_open all_about_hid;
+#X msg 298 145 info;
+#N canvas 477 37 411 235 see 0;
+#N canvas 108 318 543 264 route 0;
+#X obj 27 14 inlet;
+#X obj 72 226 outlet;
+#X obj 19 226 outlet;
+#X obj 172 226 outlet;
+#X obj 222 204 symbol;
+#X obj 222 226 outlet;
+#X obj 272 204 symbol;
+#X obj 272 226 outlet;
+#X obj 322 204 symbol;
+#X obj 322 226 outlet;
+#X obj 372 204 symbol;
+#X obj 372 226 outlet;
+#X obj 122 225 outlet;
+#X obj 26 63 route open device total poll product manufacturer transport
+type vendorID productID;
+#X obj 422 204 symbol;
+#X obj 422 226 outlet;
+#X obj 472 204 symbol;
+#X obj 472 226 outlet;
#X connect 0 0 13 0;
-#X connect 3 0 4 0;
-#X connect 5 0 6 0;
-#X connect 7 0 8 0;
-#X connect 9 0 10 0;
-#X connect 11 0 12 0;
+#X connect 4 0 5 0;
+#X connect 6 0 7 0;
+#X connect 8 0 9 0;
+#X connect 10 0 11 0;
#X connect 13 0 2 0;
#X connect 13 1 1 0;
-#X connect 13 2 14 0;
+#X connect 13 2 12 0;
#X connect 13 3 3 0;
-#X connect 13 4 5 0;
-#X connect 13 5 7 0;
-#X connect 13 6 9 0;
-#X connect 13 7 11 0;
+#X connect 13 4 4 0;
+#X connect 13 5 6 0;
+#X connect 13 6 8 0;
+#X connect 13 7 10 0;
+#X connect 13 8 14 0;
+#X connect 13 9 16 0;
+#X connect 14 0 15 0;
+#X connect 16 0 17 0;
#X restore 55 66 pd route info;
-#X obj 54 88 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1
-;
+#X obj 32 97 tgl 15 0 empty empty open 0 -6 0 8 -262144 -1 -1 1 1;
#X obj 61 23 inlet;
#X obj 74 44 print info;
#X symbolatom 255 94 0 0 0 0 productID - -;
#X symbolatom 255 113 0 0 0 0 vendorID - -;
-#X symbolatom 255 132 0 0 0 0 transport - -;
-#X symbolatom 255 152 0 0 0 0 manufacturer - -;
-#X symbolatom 137 173 0 0 0 0 product - -;
+#X symbolatom 255 152 0 0 0 0 transport - -;
+#X symbolatom 255 172 0 0 0 0 manufacturer - -;
+#X symbolatom 137 193 0 0 0 0 product - -;
#X floatatom 48 141 5 0 0 0 device - -;
#X floatatom 48 163 5 0 0 0 poll - -;
+#X symbolatom 255 132 0 0 0 0 type - -;
+#X floatatom 48 183 5 0 0 0 total - -;
#X connect 0 0 1 0;
#X connect 0 1 9 0;
#X connect 0 2 10 0;
-#X connect 0 3 8 0;
-#X connect 0 4 7 0;
-#X connect 0 5 6 0;
-#X connect 0 6 5 0;
-#X connect 0 7 4 0;
+#X connect 0 3 12 0;
+#X connect 0 4 8 0;
+#X connect 0 5 7 0;
+#X connect 0 6 6 0;
+#X connect 0 7 11 0;
+#X connect 0 8 5 0;
+#X connect 0 9 4 0;
#X connect 2 0 0 0;
#X connect 2 0 3 0;
-#X restore 418 286 pd see device info;
+#X restore 418 271 pd see device info;
#N canvas 0 22 380 450 open 0;
#X obj 77 61 hradio 15 1 0 8 empty empty empty 0 -6 0 8 -262144 -1
-1 0;
@@ -416,7 +425,7 @@ vendorID productID;
#X connect 14 0 5 0;
#X connect 16 0 5 0;
#X connect 17 0 5 0;
-#X restore 203 74 pd open by device type;
+#X restore 203 59 pd open by device type;
#N canvas 88 102 470 320 open 0;
#X text 217 82 Gravis/Destroyer Tiltpad;
#X msg 76 81 open 0x047D 0x4008;
@@ -430,8 +439,8 @@ IDs (it is not case sensitive):;
#X connect 1 0 4 0;
#X connect 2 0 4 0;
#X connect 7 0 4 0;
-#X restore 174 52 pd open by vendor/product ID;
-#N canvas 114 93 523 432 test 0;
+#X restore 174 37 pd open by vendor/product ID;
+#N canvas 114 93 527 436 test 0;
#X obj 122 5 inlet;
#X obj 66 64 route DESKTOP;
#X obj 65 118 route DESKTOP57;
@@ -440,19 +449,26 @@ IDs (it is not case sensitive):;
#X floatatom 73 172 5 0 0 0 - - -;
#X obj 126 175 spigot;
#X obj 124 216 print test;
-#X obj 167 152 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+#X obj 167 152 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1
1;
+#X obj 270 82 spigot;
+#X obj 268 123 print test;
+#X obj 311 59 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1
+;
#X connect 0 0 1 0;
+#X connect 0 0 8 0;
#X connect 1 0 2 0;
#X connect 2 0 3 0;
#X connect 2 0 4 0;
#X connect 2 0 5 0;
#X connect 5 0 6 0;
#X connect 7 0 5 1;
-#X restore 197 318 pd test;
-#X msg 504 216 poll 200;
-#X msg 261 332 abs abs_y 55;
-#X text 49 558 (C) Copyright 2004 Hans-Christoph Steiner <hans@at.or.at>
+#X connect 8 0 9 0;
+#X connect 10 0 8 1;
+#X restore 197 303 pd test;
+#X msg 504 201 poll 200;
+#X msg 261 317 key btn_0 0;
+#X text 49 543 (C) Copyright 2004 Hans-Christoph Steiner <hans@at.or.at>
;
#X connect 3 0 45 0;
#X connect 22 0 23 1;
diff --git a/hid.c b/hid.c
index 7ee4ee8..4b61bce 100644
--- a/hid.c
+++ b/hid.c
@@ -109,6 +109,30 @@ static void output_poll_time(t_hid *x)
output_status(x, gensym("poll"), x->x_delay);
}
+static void output_device_count(t_hid *x)
+{
+ output_status(x, gensym("total"), device_count);
+}
+
+static void output_element_ranges(t_hid *x)
+{
+ if( (x->x_device_number > -1) && (x->x_device_open) )
+ {
+ unsigned int i;
+ t_atom output_data[4];
+
+ for(i=0;i<element_count[x->x_device_number];++i)
+ {
+ SETSYMBOL(output_data, element[x->x_device_number][i]->type);
+ SETSYMBOL(output_data + 1, element[x->x_device_number][i]->name);
+ SETFLOAT(output_data + 2, element[x->x_device_number][i]->min);
+ SETFLOAT(output_data + 3, element[x->x_device_number][i]->max);
+ outlet_anything(x->x_status_outlet, gensym("range"), 4, output_data);
+ }
+ }
+}
+
+
static unsigned int name_to_usage(char *usage_name)
{ // output usagepage << 16 + usage
if(strcmp(usage_name,"pointer") == 0) return(0x00010001);
@@ -137,7 +161,7 @@ static short get_device_number_from_arguments(int argc, t_atom *argv)
{
first_argument = atom_getsymbolarg(0,argc,argv);
if(first_argument == &s_)
- { // single float arg means device
+ { // single float arg means device #
device_number = (short) atom_getfloatarg(0,argc,argv);
if(device_number < 0) device_number = -1;
debug_print(LOG_DEBUG,"[hid] setting device# to %d",device_number);
@@ -350,7 +374,9 @@ static void hid_info(t_hid *x)
{
output_open_status(x);
output_device_number(x);
+ output_device_count(x);
output_poll_time(x);
+ output_element_ranges(x);
hid_platform_specific_info(x);
}
diff --git a/hid.h b/hid.h
index bd31b88..23b65a4 100644
--- a/hid.h
+++ b/hid.h
@@ -15,7 +15,7 @@
#define HID_MAJOR_VERSION 0
#define HID_MINOR_VERSION 7
-/* static char *version = "$Revision: 1.24 $"; */
+/* static char *version = "$Revision: 1.25 $"; */
/*------------------------------------------------------------------------------
* GLOBAL DEFINES
@@ -40,38 +40,31 @@ typedef struct _hid
{
t_object x_obj;
t_int x_fd;
+ void *x_ff_device;
short x_device_number;
-// unsigned short vendor_id; // USB idVendor for current device
-// unsigned short product_id; // USB idProduct for current device
t_int x_has_ff;
- void *x_ff_device;
- t_clock *x_clock;
- t_int x_delay;
t_int x_started;
t_int x_device_open;
+ t_int x_delay;
+ t_clock *x_clock;
t_outlet *x_data_outlet;
t_outlet *x_status_outlet;
} t_hid;
-
/*------------------------------------------------------------------------------
* GLOBAL VARIABLES
*/
-/*
- * count the number of instances of this object so that certain free()
+/* count the number of instances of this object so that certain free()
* functions can be called only after the final instance is detroyed.
*/
t_int hid_instance_count;
extern unsigned short global_debug_level;
-/* next I need to make a data structure to hold the data to be output for this
- * poll. This should probably be an array for efficiency */
-
-
+/* built up when the elements of an open device are enumerated */
typedef struct _hid_element
{
#ifdef __linux__
@@ -83,11 +76,16 @@ typedef struct _hid_element
t_symbol *name; // Linux "code"; HID "usage"
unsigned char polled; // is it polled or queued? (maybe only on Mac OS X?)
unsigned char relative; // relative data gets output everytime
+ t_int min; // from device report
+ t_int max; // from device report
t_float instance; // usage page/usage instance # ([absolute throttle 2 163(
t_int value; // output the sum of events in a poll for relative axes
t_int previous_value; //only output on change on abs and buttons
} t_hid_element;
+/* mostly for status querying */
+unsigned short device_count;
+
/* store element structs to eliminate symbol table lookups, etc. */
t_hid_element *element[MAX_DEVICES][MAX_ELEMENTS];
/* number of active elements per device */
diff --git a/hid_darwin.c b/hid_darwin.c
index cfe3319..b03eaa7 100644
--- a/hid_darwin.c
+++ b/hid_darwin.c
@@ -60,7 +60,7 @@
* GLOBAL VARS
*======================================================================== */
-extern t_int hid_instance_count;
+extern t_int hid_instance_count; // in hid.h
/* store device pointers so I don't have to query them all the time */
pRecDevice device_pointer[MAX_DEVICES];
@@ -432,23 +432,24 @@ void hid_build_element_list(t_hid *x)
case kHIDUsage_GD_Wheel:
//case kHIDUsage_GD_Hatswitch: // hatswitches are more like buttons, so queue them
debug_print(LOG_INFO,"[hid] storing absolute axis to poll %s, %s (0x%04x 0x%04x)",
- type_name, usage_name, pCurrentHIDElement->usagePage, pCurrentHIDElement->usage);
+ type_name, usage_name,
+ pCurrentHIDElement->usagePage, pCurrentHIDElement->usage);
if(HIDDequeueElement(pCurrentHIDDevice,pCurrentHIDElement) != kIOReturnSuccess)
debug_print(LOG_ERR,"[hid] could not dequeue element");
new_element->polled = 1;
break;
- default:
- debug_print(LOG_CRIT,"[hid] SKIPPED %s, %s (0x%04x 0x%04x)x", type_name, usage_name,
- pCurrentHIDElement->usagePage, pCurrentHIDElement->usage);
}
}
else
{
- debug_print(LOG_INFO,"[hid] queuing element %s, %s (0x%04x 0x%04x)",type_name, usage_name,
+ debug_print(LOG_INFO,"[hid] queuing element %s, %s (0x%04x 0x%04x)",
+ type_name, usage_name,
pCurrentHIDElement->usagePage, pCurrentHIDElement->usage);
}
- post("\tlogical min %d max %d",pCurrentHIDElement->minReport,pCurrentHIDElement->maxReport);
-
+ new_element->min = pCurrentHIDElement->min;
+ new_element->max = pCurrentHIDElement->max;
+ debug_print(LOG_DEBUG,"\tlogical min %d max %d",
+ pCurrentHIDElement->min,pCurrentHIDElement->max);
element[x->x_device_number][element_count[x->x_device_number]] = new_element;
++element_count[x->x_device_number];
pCurrentHIDElement = HIDGetNextDeviceElement(pCurrentHIDElement, kHIDElementTypeInput);
@@ -519,6 +520,7 @@ void hid_print_device_list(t_hid *x)
{
char device_type_buffer[256];
t_int i, numdevs;
+ unsigned int j;
pRecDevice pCurrentHIDDevice = NULL;
if( HIDHaveDeviceList() )
@@ -536,6 +538,8 @@ void hid_print_device_list(t_hid *x)
pCurrentHIDDevice->version,pCurrentHIDDevice->locID);
HIDGetUsageName(pCurrentHIDDevice->usagePage, pCurrentHIDDevice->usage,
device_type_buffer);
+ for(j=0; j< strlen(device_type_buffer); ++j)
+ device_type_buffer[j] = tolower(device_type_buffer[j]);
post("\tdevice type: %s\tusage page: 0x%04x\tusage: 0x%04x",
device_type_buffer, pCurrentHIDDevice->usagePage,
pCurrentHIDDevice->usage);
@@ -551,9 +555,11 @@ void hid_print_device_list(t_hid *x)
void hid_platform_specific_info(t_hid *x)
{
+ unsigned int i;
pRecDevice pCurrentHIDDevice = NULL;
char vendor_id_string[7];
char product_id_string[7];
+ char device_type_buffer[256];
t_symbol *output_symbol;
t_atom *output_atom = getbytes(sizeof(t_atom));
@@ -571,7 +577,7 @@ void hid_platform_specific_info(t_hid *x)
SETSYMBOL(output_atom, gensym(pCurrentHIDDevice->manufacturer));
outlet_anything( x->x_status_outlet, gensym("manufacturer"),
1, output_atom);
- /* serial */
+ /* serial number */
if(pCurrentHIDDevice->serial != NULL)
{
output_symbol = gensym(pCurrentHIDDevice->serial);
@@ -598,6 +604,15 @@ void hid_platform_specific_info(t_hid *x)
SETSYMBOL(output_atom, gensym(product_id_string));
outlet_anything( x->x_status_outlet, gensym("productID"),
1, output_atom);
+ /* type */
+ HIDGetUsageName(pCurrentHIDDevice->usagePage,
+ pCurrentHIDDevice->usage,
+ device_type_buffer);
+ for(i=0; i< strlen(device_type_buffer); ++i)
+ device_type_buffer[i] = tolower(device_type_buffer[i]);
+ SETSYMBOL(output_atom, gensym(device_type_buffer));
+ outlet_anything( x->x_status_outlet, gensym("type"),
+ 1, output_atom);
}
}
freebytes(output_atom,sizeof(t_atom));
@@ -742,7 +757,7 @@ void hid_build_device_list(void)
device_pointer[device_number] = pCurrentHIDDevice;
pCurrentHIDDevice = HIDGetNextDevice(pCurrentHIDDevice);
}
-
+ device_count = (unsigned int) HIDCountDevices(); // set the global variable
debug_print(LOG_WARNING,"[hid] completed device list.");
}