diff options
-rw-r--r-- | TODO | 21 | ||||
-rw-r--r-- | doc/hid-help.pd | 390 | ||||
-rw-r--r-- | doc/joystick-help.pd | 119 | ||||
-rw-r--r-- | doc/mouse-help.pd | 79 | ||||
-rw-r--r-- | hid_darwin.c | 115 | ||||
-rw-r--r-- | joystick.pd | 62 |
6 files changed, 569 insertions, 217 deletions
@@ -85,12 +85,26 @@ void hid_post(const char *format, const char *); ============================================================================== = if device is closed and obj is started, open device and start +============================================================================== += catalog Linux device behavior + +- more data needed to make the proper [hid] output for MacOS X + +- catalog hatswitch behavior + +- catalog axis directions: right/down positive? left/up negative? ============================================================================== = event name changes - make key/button Type btn rather than key (undecided on this one) +============================================================================== += make [macosxevent] + +- so much info is lost in the translation to a common event scheme that it + would be quite handy to have a [macosxevent] object. This would give + access to the entire range of devices supported by HID Manager. ============================================================================== = device 0 gets events for all available devices @@ -137,3 +151,10 @@ This is probably only a problem on relative axes. - On Darwin/MacOSX, I think that the HIDGetEvent() loop will have to be 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). diff --git a/doc/hid-help.pd b/doc/hid-help.pd index a3e0b00..cc52481 100644 --- a/doc/hid-help.pd +++ b/doc/hid-help.pd @@ -1,25 +1,24 @@ -#N canvas 148 25 912 632 10; -#X msg 430 325 rel rel_x 0 1.63404e+09; -#X obj 430 304 prepend set; -#X obj 169 458 route rel_x rel_y; -#X floatatom 169 478 5 0 0 0 - - -; -#X floatatom 226 478 5 0 0 0 - - -; +#N canvas 307 79 928 648 10; +#X msg 455 295 abs abs_y 114 1.23605e+09; +#X obj 455 274 prepend set; +#X floatatom 37 484 5 0 0 0 - - -; +#X floatatom 89 484 5 0 0 0 - - -; #X msg 148 77 start; #X msg 174 96 stop; -#X floatatom 521 385 12 0 0 1 time - -; -#X obj 428 365 unpack s s f f; +#X floatatom 548 354 12 0 0 1 time - -; +#X obj 455 335 unpack s s f f; #X msg 239 37 open 0; #X msg 246 55 open 1; #X msg 253 73 open 2; #X msg 259 91 open 3; #X msg 265 109 open 4; -#X floatatom 226 439 7 0 0 0 - - -; -#X floatatom 284 439 7 0 0 0 - - -; +#X floatatom 84 439 7 0 0 0 - - -; +#X floatatom 138 439 7 0 0 0 - - -; #X obj 86 81 tgl 35 0 empty empty empty 0 -6 0 8 -24198 -1 -1 25 25 ; -#X floatatom 490 402 12 0 0 1 value - -; -#X symbolatom 459 419 10 0 0 1 event_code - -; -#X symbolatom 428 438 15 0 0 1 event_type - -; +#X floatatom 517 370 12 0 0 1 value - -; +#X symbolatom 486 386 15 0 0 1 event_code - -; +#X symbolatom 455 402 15 0 0 1 event_type - -; #X obj 17 271 bng 35 250 50 0 empty empty event_received 38 18 1 9 -262144 -1 -1; #X obj 2 2 cnv 15 900 20 empty empty [hid] 2 11 1 18 -233017 -66577 @@ -42,9 +41,9 @@ #X obj 63 241 spigot; #X obj 109 241 tgl 17 0 empty empty console_print 19 9 1 9 -262131 -1 -1 0 1; -#X floatatom 309 383 5 0 0 1 ev_syn - -; -#X obj 282 382 +; -#X msg 282 362 1; +#X floatatom 289 383 5 0 0 1 ev_syn - -; +#X obj 262 382 +; +#X msg 262 362 1; #X msg 336 136 close; #X msg 336 113 refresh; #X text 397 111 refresh device list; @@ -53,10 +52,9 @@ #X text 49 588 (C) Copyright 2004 Hans-Christoph Steiner <hans@at.or.at> ; #X text 266 602 released under the GNU GPL; -#X text 472 589 $Revision: 1.11 $$Date: 2004-11-15 05:17:45 $; +#X text 472 589 $Revision: 1.12 $$Date: 2004-11-16 01:35:35 $; #X text 473 602 $Author: eighthave $; -#X obj 226 418 route abs_x abs_y abs_z; -#X floatatom 342 439 7 0 0 0 - - -; +#X floatatom 192 439 7 0 0 0 - - -; #X msg 398 180 poll 20; #X msg 336 180 poll 2; #X text 332 159 start polling and set the poll delay in ms; @@ -65,75 +63,309 @@ #X text 371 56 !!! This software is very much alpha \, so any aspect of it could change without notice !!!; #X obj 248 225 hid 1; -#X obj 113 330 route key rel abs syn; -#X obj 73 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1 +#X obj 93 330 route key rel abs syn; +#X obj 9 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1 ; -#X obj 113 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 -1; -#X obj 154 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 -1; -#X obj 195 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 49 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1 +; +#X obj 90 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1 +; +#X obj 131 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 236 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 172 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 277 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 213 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 317 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 253 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 358 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 294 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 399 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 335 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; #X msg 270 129 open 5; -#X obj 73 504 route btn_0 btn_1 btn_2 btn_3 btn_4 btn_5 btn_6 btn_7 +#X obj 9 504 route btn_0 btn_1 btn_2 btn_3 btn_4 btn_5 btn_6 btn_7 btn_8 btn_9; -#X obj 440 537 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 376 537 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 +/usr/include/linux/input.h.); +#X obj 11 9 cnv 15 580 30 empty empty Event_Codes 20 12 1 14 -225271 +-66577 0; +#X text 32 118 EVENT CODE; +#X text 162 118 #define; +#X text 232 118 number; +#X text 32 133 -----------------------------------; +#X text 32 148 X Axis; +#X text 32 163 Y Axis; +#X text 32 178 Z Axis; +#X text 32 193 Horizontal Wheel; +#X text 32 208 Dial; +#X text 32 223 Wheel; +#X text 32 238 Misc; +#X text 162 148 REL_X; +#X text 162 163 REL_Y; +#X text 162 178 REL_Z; +#X text 162 193 REL_HWHEEL; +#X text 162 208 REL_DIAL; +#X text 162 223 REL_WHEEL; +#X text 162 238 REL_MISC; +#X text 247 148 0; +#X text 247 163 1; +#X text 247 178 2; +#X text 247 193 6; +#X text 247 208 7; +#X text 247 223 8; +#X text 247 238 9; +#X text 307 118 EVENT CODE; +#X text 457 118 #define; +#X text 547 118 number; +#X text 307 148 Absolute X; +#X text 307 163 Absolute Y; +#X text 307 178 Absolute Z; +#X text 307 193 RX; +#X text 307 208 RY; +#X text 307 223 RZ; +#X text 307 238 Throttle; +#X text 307 253 Rudder; +#X text 307 268 Wheel; +#X text 307 283 Gas Pedal; +#X text 307 298 Brake Pedal; +#X text 307 313 Hat Switch 0 X-axis; +#X text 307 328 Hat Switch 0 Y-axis; +#X text 307 343 Hat Switch 1 X-axis; +#X text 307 358 Hat Switch 1 Y-axis; +#X text 307 373 Hat Switch 2 X-axis; +#X text 307 388 Hat Switch 2 Y-axis; +#X text 307 403 Hat Switch 3 X-axis; +#X text 307 418 Hat Switch 3 Y-axis; +#X text 307 433 Pressure; +#X text 307 448 Distance; +#X text 307 463 Tilt X-Axis; +#X text 307 478 Tilt Y-Axis; +#X text 307 493 Misc; +#X text 457 148 ABS_X; +#X text 457 163 ABS_Y; +#X text 457 178 ABS_Z; +#X text 457 193 ABS_RX; +#X text 457 208 ABS_RY; +#X text 457 223 ABS_RZ; +#X text 457 238 ABS_THROTTLE; +#X text 457 253 ABS_RUDDER; +#X text 457 268 ABS_WHEEL; +#X text 457 283 ABS_GAS; +#X text 457 298 ABS_BRAKE; +#X text 457 313 ABS_HAT0X; +#X text 457 328 ABS_HAT0Y; +#X text 457 343 ABS_HAT1X; +#X text 457 358 ABS_HAT1Y; +#X text 457 373 ABS_HAT2X; +#X text 457 388 ABS_HAT2Y; +#X text 457 403 ABS_HAT3X; +#X text 457 418 ABS_HAT3Y; +#X text 457 433 ABS_PRESSURE; +#X text 457 448 ABS_DISTANCE; +#X text 457 463 ABS_TILT_X; +#X text 457 478 ABS_TILT_Y; +#X text 457 493 ABS_MISC; +#X text 563 148 0; +#X text 563 163 1; +#X text 563 178 2; +#X text 563 193 3; +#X text 563 208 4; +#X text 563 223 5; +#X text 563 238 6; +#X text 563 253 7; +#X text 563 268 8; +#X text 563 283 9; +#X text 563 298 10; +#X text 563 313 16; +#X text 563 328 17; +#X text 563 343 18; +#X text 563 358 19; +#X text 563 373 20; +#X text 563 388 21; +#X text 563 403 22; +#X text 563 418 23; +#X text 563 433 24; +#X text 563 448 25; +#X text 563 463 26; +#X text 563 478 27; +#X text 563 493 28; +#X obj 30 89 cnv 15 250 25 empty empty Relative_Axes 20 12 1 12 -241660 +-66577 0; +#X obj 308 89 cnv 15 280 25 empty empty Absolute_Axes 20 12 1 12 -241660 +-66577 0; +#X text 307 133 ----------------------------------------; +#X text 32 285 EVENT CODE; +#X text 138 285 #define; +#X text 232 285 number; +#X text 32 300 -----------------------------------; +#X obj 30 256 cnv 15 250 25 empty empty Joystick_Buttons 20 12 1 12 +-241660 -66577 0; +#X text 138 315 BTN_TRIGGER; +#X text 32 315 Trigger; +#X text 32 330 Thumb; +#X text 32 345 Thumb 2; +#X text 32 360 Top; +#X text 32 375 Top 2; +#X text 32 390 Pinkie; +#X text 32 405 Base 1; +#X text 138 404 BTN_BASE; +#X text 138 330 BTN_THUMB; +#X text 138 345 BTN_THUMB2; +#X text 138 360 BTN_TOP; +#X text 138 375 BTN_TOP2; +#X text 138 390 BTN_PINKIE; +#X text 245 315 288; +#X text 245 330 289; +#X text 245 345 290; +#X text 245 360 291; +#X text 245 375 292; +#X text 245 390 293; +#X text 245 405 294; +#X text 245 419 295; +#X text 245 434 296; +#X text 245 448 297; +#X text 138 418 BTN_BASE2; +#X text 138 433 BTN_BASE3; +#X text 138 447 BTN_BASE4; +#X text 32 419 Base 2; +#X text 32 434 Base 3; +#X text 32 448 Base 4; +#X text 32 463 Base 5; +#X text 32 477 Base 6; +#X text 138 462 BTN_BASE5; +#X text 138 476 BTN_BASE6; +#X text 245 463 298; +#X text 245 477 299; +#X restore 744 419 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.); +#X text 61 90 EVENT TYPE; +#X text 61 135 Keys and Buttons; +#X text 61 150 Relative Axes; +#X text 61 165 Absolute Axes; +#X text 61 180 Misc Events; +#X text 61 195 LED Event; +#X text 61 210 Sounds; +#X text 61 225 Autorepeat Values; +#X text 61 240 Force Feedback; +#X text 230 90 #define; +#X text 230 135 EV_KEY; +#X text 230 150 EV_REL; +#X text 230 165 EV_ABS; +#X text 230 180 EV_MSC; +#X text 230 195 EV_LED; +#X text 230 210 EV_SND; +#X text 230 225 EV_REP; +#X text 230 240 EV_FF; +#X text 315 90 number; +#X text 331 120 0; +#X text 331 135 1; +#X text 331 150 2; +#X text 331 165 3; +#X text 331 180 4; +#X text 331 195 17; +#X text 331 210 18; +#X text 331 225 20; +#X text 331 240 21; +#X obj 11 9 cnv 15 400 30 empty empty Event_Types 20 12 1 14 -262131 +-66577 0; +#X text 230 120 EV_SYN; +#X text 61 270 Force Feedback Status; +#X text 61 120 Syncronization Events; +#X text 230 270 EV_FF_STATUS; +#X text 331 270 23; +#X text 61 105 -------------------------------------------; +#X text 331 255 22; +#X text 230 255 EV_PWR; +#X text 61 255 Power Events (for UPS); +#X restore 744 399 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 744 439 pd Event_Values; +#X obj 37 464 route rel_x rel_y rel_z; +#X floatatom 141 484 5 0 0 0 - - -; +#X obj 84 418 route abs_x abs_y abs_z abs_rx abs_ry abs_rz; +#X floatatom 246 439 7 0 0 0 - - -; +#X floatatom 300 439 7 0 0 0 - - -; +#X floatatom 354 439 7 0 0 0 - - -; +#X obj 408 437 route abs_hat0x abs_hat0y abs_hat1x abs_hat1y; +#X floatatom 408 459 7 0 0 0 - - -; +#X obj 408 475 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X floatatom 485 459 7 0 0 0 - - -; +#X obj 485 475 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X floatatom 563 459 7 0 0 0 - - -; +#X obj 563 475 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X floatatom 640 459 7 0 0 0 - - -; +#X obj 640 475 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; #X connect 1 0 0 0; -#X connect 2 0 3 0; -#X connect 2 1 4 0; -#X connect 5 0 59 0; -#X connect 6 0 59 0; -#X connect 8 0 19 0; -#X connect 8 1 18 0; -#X connect 8 2 17 0; -#X connect 8 3 7 0; -#X connect 9 0 59 0; -#X connect 10 0 59 0; -#X connect 11 0 59 0; -#X connect 12 0 59 0; -#X connect 13 0 59 0; -#X connect 16 0 59 0; -#X connect 37 0 36 0; -#X connect 37 0 20 0; -#X connect 38 0 37 1; -#X connect 39 0 40 1; +#X connect 4 0 57 0; +#X connect 5 0 57 0; +#X connect 7 0 18 0; +#X connect 7 1 17 0; +#X connect 7 2 16 0; +#X connect 7 3 6 0; +#X connect 8 0 57 0; +#X connect 9 0 57 0; +#X connect 10 0 57 0; +#X connect 11 0 57 0; +#X connect 12 0 57 0; +#X connect 15 0 57 0; +#X connect 36 0 35 0; +#X connect 36 0 19 0; +#X connect 37 0 36 1; +#X connect 38 0 39 1; +#X connect 39 0 38 0; #X connect 40 0 39 0; -#X connect 41 0 40 0; -#X connect 42 0 59 0; -#X connect 43 0 59 0; -#X connect 51 0 14 0; -#X connect 51 1 15 0; -#X connect 51 2 52 0; -#X connect 53 0 59 0; -#X connect 54 0 59 0; -#X connect 57 0 59 0; -#X connect 59 0 37 0; -#X connect 59 0 1 0; -#X connect 59 0 8 0; -#X connect 59 0 60 0; -#X connect 60 0 71 0; -#X connect 60 1 2 0; -#X connect 60 2 51 0; -#X connect 60 3 41 0; -#X connect 70 0 59 0; -#X connect 71 0 61 0; -#X connect 71 1 62 0; -#X connect 71 2 63 0; -#X connect 71 3 64 0; -#X connect 71 4 65 0; -#X connect 71 5 66 0; -#X connect 71 6 67 0; -#X connect 71 7 68 0; -#X connect 71 8 69 0; -#X connect 71 9 72 0; +#X connect 41 0 57 0; +#X connect 42 0 57 0; +#X connect 51 0 57 0; +#X connect 52 0 57 0; +#X connect 55 0 57 0; +#X connect 57 0 36 0; +#X connect 57 0 1 0; +#X connect 57 0 7 0; +#X connect 57 0 58 0; +#X connect 58 0 69 0; +#X connect 58 1 74 0; +#X connect 58 2 76 0; +#X connect 58 3 40 0; +#X connect 68 0 57 0; +#X connect 69 0 59 0; +#X connect 69 1 60 0; +#X connect 69 2 61 0; +#X connect 69 3 62 0; +#X connect 69 4 63 0; +#X connect 69 5 64 0; +#X connect 69 6 65 0; +#X connect 69 7 66 0; +#X connect 69 8 67 0; +#X connect 69 9 70 0; +#X connect 74 0 2 0; +#X connect 74 1 3 0; +#X connect 74 2 75 0; +#X connect 76 0 13 0; +#X connect 76 1 14 0; +#X connect 76 2 50 0; +#X connect 76 3 77 0; +#X connect 76 4 78 0; +#X connect 76 5 79 0; +#X connect 76 6 80 0; +#X connect 80 0 81 0; +#X connect 80 1 83 0; +#X connect 80 2 85 0; +#X connect 80 3 87 0; +#X connect 81 0 82 0; +#X connect 83 0 84 0; +#X connect 85 0 86 0; +#X connect 87 0 88 0; diff --git a/doc/joystick-help.pd b/doc/joystick-help.pd index 9d8ef20..99fc0b4 100644 --- a/doc/joystick-help.pd +++ b/doc/joystick-help.pd @@ -1,72 +1,75 @@ -#N canvas 96 237 669 433 10; -#X obj 168 41 tgl 25 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0 1 +#N canvas 405 245 666 459 10; +#X obj 168 91 tgl 25 0 empty empty empty 0 -6 0 8 -225271 -1 -1 1 1 ; -#X floatatom 63 184 7 0 0 3 Y-axis - -; -#X floatatom 9 184 7 0 0 3 X-axis - -; -#X obj 219 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X floatatom 63 234 7 0 0 3 Y-axis - -; +#X floatatom 9 234 7 0 0 3 X-axis - -; +#X obj 212 324 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 264 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 252 324 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 309 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 293 324 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 355 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 334 324 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X floatatom 123 184 7 0 0 3 twist - -; -#X floatatom 182 184 5 0 0 0 - - -; -#X obj 219 271 route btn_1 btn_2 btn_3 btn_4 btn_5 btn_6 btn_7 btn_8 -btn_9; -#X obj 400 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X floatatom 123 234 7 0 0 3 twist - -; +#X floatatom 182 234 5 0 0 3 throttle - -; +#X obj 375 324 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 445 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 416 324 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 491 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 456 324 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 536 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 497 324 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 168 104 joystick 3; -#X obj 581 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 168 154 joystick 3; +#X obj 538 324 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 627 294 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 579 324 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X symbolatom 441 178 6 0 0 1 code - -; -#X floatatom 569 178 5 0 0 1 value - -; -#X obj 441 151 unpack symbol float; -#X text 512 194 buttons; +#X symbolatom 412 242 6 0 0 1 code - -; +#X floatatom 540 242 5 0 0 1 value - -; +#X obj 412 215 unpack symbol float; +#X text 483 258 buttons; #X obj 2 2 cnv 15 650 20 empty empty [joystick] 2 11 1 18 -233017 -66577 0; -#X msg 215 43 open 1; -#X text 1 382 (C) Copyright 2004 Hans-Christoph Steiner <hans@at.or.at> +#X msg 215 93 open 1; +#X text 1 412 (C) Copyright 2004 Hans-Christoph Steiner <hans@at.or.at> ; -#X text 218 396 released under the GNU GPL; -#X text 414 396 $Author: eighthave $; -#X text 414 383 $Revision: 1.3 $; -#X obj 526 350 all_about_hid; -#X text 417 351 For more info:; -#X floatatom 225 184 5 0 0 0 - - -; -#X floatatom 268 184 5 0 0 0 - - -; -#X msg 220 62 open 3; -#X msg 225 81 open 4; -#X connect 0 0 14 0; -#X connect 9 0 3 0; -#X connect 9 1 4 0; -#X connect 9 2 5 0; -#X connect 9 3 6 0; -#X connect 9 4 10 0; -#X connect 9 5 11 0; -#X connect 9 6 12 0; -#X connect 9 7 13 0; -#X connect 9 8 15 0; -#X connect 9 9 16 0; -#X connect 14 0 2 0; -#X connect 14 1 1 0; -#X connect 14 2 7 0; -#X connect 14 3 8 0; -#X connect 14 4 29 0; -#X connect 14 5 30 0; -#X connect 14 6 19 0; -#X connect 14 6 9 0; -#X connect 19 0 17 0; -#X connect 19 1 18 0; -#X connect 22 0 14 0; -#X connect 31 0 14 0; -#X connect 32 0 14 0; +#X text 218 426 released under the GNU GPL; +#X text 414 426 $Author: eighthave $; +#X text 414 413 $Revision: 1.4 $; +#X obj 519 372 all_about_hid; +#X text 410 373 For more info:; +#X floatatom 245 234 5 0 0 3 hat0X - -; +#X floatatom 288 234 5 0 0 3 hat0Y - -; +#X msg 220 112 open 3; +#X msg 225 131 open 4; +#X text 8 36 Use a joystick device with Pd. This object auto-calibrates +the output of axis data. Move each element of the device across its +full range to calibrate it.; +#X obj 212 291 route btn_0 btn_1 btn_2 btn_3 btn_4 btn_5 btn_6 btn_7 +btn_8 btn_9; +#X connect 0 0 13 0; +#X connect 13 0 2 0; +#X connect 13 1 1 0; +#X connect 13 2 7 0; +#X connect 13 3 8 0; +#X connect 13 4 28 0; +#X connect 13 5 29 0; +#X connect 13 6 18 0; +#X connect 13 6 33 0; +#X connect 18 0 16 0; +#X connect 18 1 17 0; +#X connect 21 0 13 0; +#X connect 30 0 13 0; +#X connect 31 0 13 0; +#X connect 33 0 3 0; +#X connect 33 1 4 0; +#X connect 33 2 5 0; +#X connect 33 3 6 0; +#X connect 33 4 9 0; +#X connect 33 5 10 0; +#X connect 33 6 11 0; +#X connect 33 7 12 0; +#X connect 33 8 14 0; +#X connect 33 9 15 0; diff --git a/doc/mouse-help.pd b/doc/mouse-help.pd index db4eda7..922c08b 100644 --- a/doc/mouse-help.pd +++ b/doc/mouse-help.pd @@ -1,20 +1,20 @@ -#N canvas 354 179 662 416 10; -#X symbolatom 211 218 6 0 0 1 code - -; -#X obj 130 56 tgl 25 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0 1 -; -#X floatatom 339 218 5 0 0 1 value - -; -#X floatatom 140 218 5 0 0 3 wheel - -; -#X floatatom 85 218 7 0 0 3 Y - -; -#X floatatom 31 218 7 0 0 3 X - -; -#X obj 193 285 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#N canvas 53 201 666 460 10; +#X symbolatom 211 268 6 0 0 1 code - -; +#X obj 130 106 tgl 25 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0 +1; +#X floatatom 339 268 5 0 0 1 value - -; +#X floatatom 140 268 5 0 0 3 wheel - -; +#X floatatom 85 268 7 0 0 3 Y - -; +#X floatatom 31 268 7 0 0 3 X - -; +#X obj 193 335 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 238 284 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 238 334 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 283 284 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 283 334 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X msg 175 43 open 0; -#X msg 180 62 open 1; -#X msg 185 81 open 2; +#X msg 175 93 open 0; +#X msg 180 112 open 1; +#X msg 185 131 open 2; #N canvas 462 248 632 542 mouse-noise 0; #X obj 100 25 inlet; #X obj 210 294 noise~; @@ -45,41 +45,44 @@ #X connect 10 1 5 0; #X connect 11 1 13 1; #X connect 13 0 4 1; -#X restore 425 136 pd mouse-noise 1; -#X msg 536 68 open 0; -#X msg 541 87 open 1; -#X msg 546 106 open 2; -#X obj 425 69 tgl 25 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0 1 -; -#X text 308 45 turn this on to make some noise with the mouse; -#X obj 130 111 mouse 1; -#X obj 211 191 unpack symbol float; -#X text 282 234 buttons; -#X obj 329 284 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X restore 425 186 pd mouse-noise 1; +#X msg 536 118 open 0; +#X msg 541 137 open 1; +#X msg 546 156 open 2; +#X obj 425 119 tgl 25 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0 +1; +#X text 308 95 turn this on to make some noise with the mouse; +#X obj 130 161 mouse 1; +#X obj 211 241 unpack symbol float; +#X text 282 284 buttons; +#X obj 329 334 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 374 284 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 374 334 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 419 284 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 419 334 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 465 284 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 465 334 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 510 284 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 510 334 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; #X obj 2 2 cnv 15 650 20 empty empty [mouse] 2 11 1 18 -233017 -66577 0; -#X obj 555 284 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 555 334 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X text 1 372 (C) Copyright 2004 Hans-Christoph Steiner <hans@at.or.at> +#X text 11 422 (C) Copyright 2004 Hans-Christoph Steiner <hans@at.or.at> ; -#X text 218 386 released under the GNU GPL; -#X text 414 386 $Author: eighthave $; -#X text 414 373 $Revision: 1.5 $; -#X obj 526 340 all_about_hid; -#X text 417 341 For more info:; -#X obj 601 284 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X text 228 436 released under the GNU GPL; +#X text 424 436 $Author: eighthave $; +#X text 424 423 $Revision: 1.6 $; +#X obj 526 382 all_about_hid; +#X text 417 383 For more info:; +#X obj 601 334 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 193 264 route btn_0 btn_1 btn_2 btn_3 btn_4 btn_5 btn_6 btn_7 +#X obj 193 314 route btn_0 btn_1 btn_2 btn_3 btn_4 btn_5 btn_6 btn_7 btn_8; +#X text 12 36 Use a mouse device with Pd. This object auto-calibrates +the output of axis data. Move the device around as fast as possible +in each axis to calibrate it.; #X connect 1 0 18 0; #X connect 9 0 18 0; #X connect 10 0 18 0; diff --git a/hid_darwin.c b/hid_darwin.c index 8e904ea..f87fb37 100644 --- a/hid_darwin.c +++ b/hid_darwin.c @@ -111,6 +111,8 @@ void convertDarwinElementToLinuxTypeCode(pRecElement element, char *linux_type, case kHIDUsage_GD_Rz: convertAxis(element, linux_type, linux_code, "rz"); break; case kHIDUsage_GD_Wheel: sprintf(linux_type,"rel");sprintf(linux_code,"rel_wheel");break; + case kHIDUsage_GD_Slider: + sprintf(linux_type,"abs");sprintf(linux_code,"abs_throttle");break; } break; case kHIDPage_Button: @@ -121,6 +123,19 @@ void convertDarwinElementToLinuxTypeCode(pRecElement element, char *linux_type, } } +/* + * Linux input events report hatswitches as absolute axes with -1, 0, 1 as + * possible values. MacOS X HID Manager reports hatswitches as a specific + * hatswitch type with each direction represented by a unique number. This + * function converts the unique number to the Linux style axes. + */ +void hid_convert_hatswitch_values(IOHIDEventStruct event, char *linux_type, char *linux_code) +{ + /* + * hmm, not sure how to implement this cleanly yet, so I left the code + * inline in hid_get_events(). + */ +} /* ============================================================================== */ /* DARWIN-SPECIFIC SUPPORT FUNCTIONS */ @@ -178,11 +193,22 @@ t_int hid_build_element_list(t_hid *x) post("-----------------------------------------------------------"); for(i=0; i<numElements; i++) { - convertDarwinElementToLinuxTypeCode(pCurrentHIDElement,type,code); HIDGetTypeName((IOHIDElementType) pCurrentHIDElement->type, type_name); - HIDGetUsageName(pCurrentHIDElement->usagePage, pCurrentHIDElement->usage, usage_name); - post(" %s\t%s\t%s, %s",type,code,type_name,usage_name); - + HIDGetUsageName(pCurrentHIDElement->usagePage, + pCurrentHIDElement->usage, usage_name); + + /* some events need more processing than others */ + switch(pCurrentHIDElement->usage) + { + case kHIDUsage_GD_Hatswitch: + post(" %s\t%s\t%s, %s","abs","abs_hat0x",type_name,usage_name); + post(" %s\t%s\t%s, %s","abs","abs_hat0y",type_name,usage_name); + break; + default: + convertDarwinElementToLinuxTypeCode(pCurrentHIDElement,type,code); + post(" %s\t%s\t%s, %s",type,code,type_name,usage_name); + } + pCurrentHIDElement = HIDGetNextDeviceElement (pCurrentHIDElement, kHIDElementTypeInput); } post(""); @@ -190,6 +216,8 @@ t_int hid_build_element_list(t_hid *x) return (0); } + + /* ============================================================================== */ /* Pd [hid] FUNCTIONS */ /* ============================================================================== */ @@ -235,11 +263,72 @@ t_int hid_get_events(t_hid *x) (long) pCurrentHIDElement->cookie, event_output_string); ); //end DEBUG - convertDarwinElementToLinuxTypeCode(pCurrentHIDElement,type,code); + /* some events need more processing than others */ + switch(pCurrentHIDElement->usage) + { + case kHIDUsage_GD_Hatswitch: + sprintf(type,"abs"); + switch (value) + { +/* + * MacOS X represents this as one event, while [hid] represents it as two + * distinct axes. So the conversion requires an added hid_output_event(). + */ + case 0: + sprintf(code,"abs_hat0y");value = 1; + hid_output_event(x,type,code,(t_float)value,(t_float)(event.timestamp).lo); + sprintf(code,"abs_hat0x");value = 0; + break; + case 1: + sprintf(code,"abs_hat0y");value = 1; + hid_output_event(x,type,code,(t_float)value,(t_float)(event.timestamp).lo); + sprintf(code,"abs_hat0x");value = 1; + break; + case 2: + sprintf(code,"abs_hat0y");value = 0; + hid_output_event(x,type,code,(t_float)value,(t_float)(event.timestamp).lo); + sprintf(code,"abs_hat0x");value = 1; + break; + case 3: + sprintf(code,"abs_hat0y");value = -1; + hid_output_event(x,type,code,(t_float)value,(t_float)(event.timestamp).lo); + sprintf(code,"abs_hat0x");value = 1; + break; + case 4: + sprintf(code,"abs_hat0y");value = -1; + hid_output_event(x,type,code,(t_float)value,(t_float)(event.timestamp).lo); + sprintf(code,"abs_hat0x");value = 0; + break; + case 5: + sprintf(code,"abs_hat0y");value = -1; + hid_output_event(x,type,code,(t_float)value,(t_float)(event.timestamp).lo); + sprintf(code,"abs_hat0x");value = -1; + break; + case 6: + sprintf(code,"abs_hat0y");value = 0; + hid_output_event(x,type,code,(t_float)value,(t_float)(event.timestamp).lo); + sprintf(code,"abs_hat0x");value = -1; + break; + case 7: + sprintf(code,"abs_hat0y");value = 1; + hid_output_event(x,type,code,(t_float)value,(t_float)(event.timestamp).lo); + sprintf(code,"abs_hat0x");value = -1; + break; + case 8: + sprintf(code,"abs_hat0y");value = 0; + hid_output_event(x,type,code,(t_float)value,(t_float)(event.timestamp).lo); + sprintf(code,"abs_hat0x");value = 0; + break; + } + hid_output_event(x,type,code,(t_float)value,(t_float)(event.timestamp).lo); + break; + default: + convertDarwinElementToLinuxTypeCode(pCurrentHIDElement,type,code); + hid_output_event(x,type,code,(t_float)value,(t_float)(event.timestamp).lo); + } + // DEBUG(post("type: %s code: %s event name: %s",type,code,event_output_string);); - // TODO: convert this to a common time format, i.e. Linux struct timeval - hid_output_event(x,type,code,(t_float)value,(t_float)(event.timestamp).lo); ++event_counter; } @@ -336,6 +425,7 @@ t_int hid_build_device_list(t_hid *x) char cstrDeviceName [256]; + post(""); /* display device list in console */ for(i=0; i < numdevs; i++) { @@ -346,13 +436,12 @@ t_int hid_build_device_list(t_hid *x) HIDGetUsageName (pCurrentHIDDevice->usagePage, pCurrentHIDDevice->usage, cstrDeviceName); - post(" vendorID: %d productID: %d locID: %d", - pCurrentHIDDevice->vendorID, - pCurrentHIDDevice->productID, - pCurrentHIDDevice->locID); - - // TODO: display all of the element types/codes for each device + DEBUG(post(" vendorID: %d productID: %d locID: %d", + pCurrentHIDDevice->vendorID, + pCurrentHIDDevice->productID, + pCurrentHIDDevice->locID);); } + post(""); return (0); } diff --git a/joystick.pd b/joystick.pd index c1432c8..77e5c83 100644 --- a/joystick.pd +++ b/joystick.pd @@ -1,49 +1,53 @@ -#N canvas 368 109 807 595 10; +#N canvas 368 109 823 611 10; #X msg 96 64 start; #X msg 105 83 stop; #X obj 77 30 inlet; #X obj 207 160 print UNKNOWN_JOYSTICK_EVENT_TYPE; -#X obj 218 286 print UNKNOWN_JOYSTICK_EVENT_CODE; +#X obj 430 289 print UNKNOWN_JOYSTICK_EVENT_CODE; #X obj 38 508 outlet; -#X obj 180 327 outlet; -#X obj 201 307 outlet; +#X obj 300 342 outlet; +#X obj 366 317 outlet; #X text 52 244 codes (0=X 1=Y 6=throttle 7=rudder \, 16=hat0X \, 17=hat0Y) ; #X obj 411 417 outlet; #X obj 77 107 hid \$1; -#X obj 38 489 autoscale -1 1; -#X obj 68 468 outlet; -#X obj 68 449 autoscale -1 1; -#X obj 99 428 outlet; -#X obj 99 409 autoscale -1 1; -#X obj 130 388 outlet; -#X obj 130 369 autoscale -1 1; +#X obj 103 468 outlet; +#X obj 169 428 outlet; +#X obj 235 387 outlet; #X obj 221 91 print RAW; #X obj 79 139 route abs key; #X text 401 433 button code/value list; -#X obj 38 264 route abs_x abs_y abs_z 16 17 6; #X text 91 509 X-axis; -#X text 117 468 Y-axis; -#X text 152 430 twist; +#X text 152 468 Y-axis; +#X text 222 430 twist; #X text 11 552 (C) Copyright 2004 Hans-Christoph Steiner <hans@at.or.at> ; #X text 228 566 released under the GNU GPL; #X text 424 566 $Author: eighthave $; -#X text 424 553 $Revision: 1.2 $$Date: 2004-11-14 22:29:43 $; +#X text 424 553 $Revision: 1.3 $$Date: 2004-11-16 01:35:35 $; +#X obj 38 489 autoscale -1 1; +#X obj 103 449 autoscale -1 1; +#X obj 169 409 autoscale -1 1; +#X obj 235 368 autoscale -1 1; +#X obj 38 264 route abs_x abs_y abs_rz abs_throttle abs_hat0x abs_hat0y +; +#X text 287 388 throttle/slider; +#X text 346 343 hat0x; +#X text 416 319 hat0y; #X connect 0 0 10 0; #X connect 1 0 10 0; #X connect 2 0 10 0; -#X connect 10 0 19 0; -#X connect 11 0 5 0; -#X connect 13 0 12 0; -#X connect 15 0 14 0; -#X connect 17 0 16 0; -#X connect 19 0 21 0; -#X connect 19 1 9 0; -#X connect 19 2 3 0; -#X connect 21 0 11 0; -#X connect 21 1 13 0; -#X connect 21 2 15 0; -#X connect 21 3 17 0; -#X connect 21 4 6 0; -#X connect 21 5 7 0; +#X connect 10 0 15 0; +#X connect 15 0 28 0; +#X connect 15 1 9 0; +#X connect 15 2 3 0; +#X connect 24 0 5 0; +#X connect 25 0 11 0; +#X connect 26 0 12 0; +#X connect 27 0 13 0; +#X connect 28 0 24 0; +#X connect 28 1 25 0; +#X connect 28 2 26 0; +#X connect 28 3 27 0; +#X connect 28 4 6 0; +#X connect 28 5 7 0; |