aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2004-11-27 19:29:34 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2004-11-27 19:29:34 +0000
commitbd04f45dbb9df98d1f3e9cf4c1d080a43af3cb0e (patch)
treefb13e55fda6d8b4bbfac3de20895bb70c5e04d28
parenta425a8aca3765a29750b2786277ad4f50f29d893 (diff)
quick kludge to add more event types for MacOS X, including a test version of keyboard support
svn path=/trunk/externals/hcs/hid/; revision=2324
-rw-r--r--TODO16
-rw-r--r--doc/keyboard-help.pd110
-rw-r--r--doc/mouse-help.pd156
-rw-r--r--hid_darwin.c19
-rw-r--r--hid_rel2abs.pd24
-rw-r--r--keyboard.pd12
-rw-r--r--mouse.pd20
7 files changed, 280 insertions, 77 deletions
diff --git a/TODO b/TODO
index b8c8d1f..ad767b8 100644
--- a/TODO
+++ b/TODO
@@ -160,3 +160,19 @@ 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, mouse axis data is limited by the screen dimensions
+
+- the axes data stops outputting when the mouse pointer reaches the edge of
+ the screen. Hopefully the HID Manager API will allow raw mouse data
+ access. It must since its used with games.
+
+_________________________________________________________________________________________
+- BUG: on MacOS X, two keyboard key codes are reported as hatswitches
+
+ abs abs_hat0x Button Input, Keyboard Usage 0x39
+ abs abs_hat0y Button Input, Keyboard Usage 0x39
+
+I am pretty sure this is just a display problem, but it might not be.
diff --git a/doc/keyboard-help.pd b/doc/keyboard-help.pd
new file mode 100644
index 0000000..90a45b4
--- /dev/null
+++ b/doc/keyboard-help.pd
@@ -0,0 +1,110 @@
+#N canvas 109 184 569 474 10;
+#X obj 168 91 tgl 25 0 empty empty empty 0 -6 0 8 -225271 -1 -1 1 1
+;
+#X obj 11 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1
+;
+#X symbolatom 168 222 12 0 0 0 code - -;
+#X floatatom 296 222 5 0 0 1 value - -;
+#X obj 168 195 unpack symbol float;
+#X text 239 238 buttons;
+#X obj 2 2 cnv 15 550 20 empty empty [keyboard] 2 11 1 18 -233017 -66577
+0;
+#X msg 215 93 open 1;
+#X text 1 432 (C) Copyright 2004 Hans-Christoph Steiner <hans@at.or.at>
+;
+#X text 218 446 released under the GNU GPL;
+#X text 414 446 $Author: eighthave $;
+#X text 414 433 $Revision: 1.1 $;
+#X obj 348 402 all_about_hid;
+#X text 239 403 For more info:;
+#X msg 220 112 open 3;
+#X msg 225 131 open 5;
+#X obj 168 154 keyboard 0;
+#X obj 32 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1
+;
+#X obj 53 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1
+;
+#X obj 74 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1
+;
+#X obj 95 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1
+;
+#X obj 116 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 137 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 158 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 179 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 200 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 221 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 242 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 263 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 284 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 305 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 326 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 347 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 368 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 389 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 1
+1;
+#X obj 410 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 431 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 452 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 473 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X obj 494 369 tgl 20 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
+1;
+#X text 117 270 Most keyboards can detect multiple keys at the same
+time. You can test yours by pressing and holding keys and counting
+how many "X"s are shown below;
+#X text 8 36 Use a keyboard device with Pd. This object gives you raw
+access to the keyboard events. Pd does not need to have focus in order
+get the key events. No matter which application has focus \, this object
+will get keyboard events.;
+#X obj 75 315 route key_4 key_5 key_6 key_7 key_8 key_9 key_10 key_11
+key_12 key_13 key_14 key_15 key_16 key_17 key_18 key_19 key_20 key_21
+key_22 key_23 key_24 key_25 key_26 key_27;
+#X connect 0 0 16 0;
+#X connect 4 0 2 0;
+#X connect 4 1 3 0;
+#X connect 7 0 16 0;
+#X connect 14 0 16 0;
+#X connect 15 0 16 0;
+#X connect 16 0 4 0;
+#X connect 16 0 42 0;
+#X connect 42 0 1 0;
+#X connect 42 1 17 0;
+#X connect 42 2 18 0;
+#X connect 42 3 19 0;
+#X connect 42 4 20 0;
+#X connect 42 5 21 0;
+#X connect 42 6 22 0;
+#X connect 42 7 23 0;
+#X connect 42 8 24 0;
+#X connect 42 9 25 0;
+#X connect 42 10 26 0;
+#X connect 42 11 27 0;
+#X connect 42 12 28 0;
+#X connect 42 13 29 0;
+#X connect 42 14 30 0;
+#X connect 42 15 31 0;
+#X connect 42 16 32 0;
+#X connect 42 17 33 0;
+#X connect 42 18 34 0;
+#X connect 42 19 35 0;
+#X connect 42 20 36 0;
+#X connect 42 21 37 0;
+#X connect 42 22 38 0;
+#X connect 42 23 39 0;
diff --git a/doc/mouse-help.pd b/doc/mouse-help.pd
index 0f53ddc..7084893 100644
--- a/doc/mouse-help.pd
+++ b/doc/mouse-help.pd
@@ -1,6 +1,6 @@
-#N canvas 53 201 666 460 10;
+#N canvas 470 274 674 468 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 1
+#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 - -;
@@ -12,44 +12,78 @@
1;
#X obj 283 334 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0
1;
-#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 msg 175 83 open 0;
+#X msg 180 102 open 1;
+#X msg 185 121 open 2;
+#N canvas 289 90 660 570 mouse-noise 0;
#X obj 100 25 inlet;
#X obj 210 294 noise~;
-#X obj 155 293 osc~;
-#X obj 155 266 * 4000;
+#X obj 155 316 osc~;
#X obj 113 367 *~;
#X msg 162 103 \; pd dsp 1;
-#X obj 103 418 dac~;
+#X obj 110 510 dac~;
#X obj 338 61 inlet;
#X text 400 62 open msgs;
-#X obj 143 173 mouse \$1;
+#X obj 138 169 mouse \$1;
#X obj 101 78 t f b;
-#X obj 194 196 unpack s f;
-#X text 270 197 get button value only;
+#X text 328 192 get button value only;
#X obj 210 320 *~;
-#X connect 0 0 10 0;
-#X connect 1 0 13 0;
-#X connect 2 0 4 1;
-#X connect 3 0 2 0;
-#X connect 4 0 6 0;
-#X connect 4 0 6 1;
-#X connect 7 0 9 0;
-#X connect 9 0 4 0;
-#X connect 9 1 3 0;
-#X connect 9 3 11 0;
-#X connect 10 0 4 0;
-#X connect 10 0 9 0;
-#X connect 10 1 5 0;
-#X connect 11 1 13 1;
-#X connect 13 0 4 1;
+#X obj 499 330 notescale 40 90;
+#X obj 317 242 / 2;
+#X obj 113 458 pan;
+#X obj 289 439 line;
+#X msg 289 416 \$1 20;
+#X obj 313 328 +;
+#X obj 359 328 f;
+#X msg 343 297 0;
+#X msg 141 131 close;
+#X obj 155 223 hid_rel2abs 0 100;
+#X obj 155 243 - 100;
+#X obj 155 262 abs;
+#X obj 189 192 unpack symbol float;
+#X obj 110 315 line~;
+#X msg 110 292 \$1 3;
+#X obj 155 297 * 20;
+#X obj 326 349 min 20;
+#X obj 326 368 max 0;
+#X obj 296 301 int;
+#X obj 326 389 / 20;
+#X connect 0 0 9 0;
+#X connect 1 0 11 0;
+#X connect 2 0 3 1;
+#X connect 3 0 14 0;
+#X connect 6 0 8 0;
+#X connect 8 0 26 0;
+#X connect 8 1 21 0;
+#X connect 8 2 30 0;
+#X connect 8 3 24 0;
+#X connect 9 0 8 0;
+#X connect 9 1 4 0;
+#X connect 11 0 3 1;
+#X connect 13 0 11 1;
+#X connect 14 0 5 0;
+#X connect 14 1 5 1;
+#X connect 15 0 14 1;
+#X connect 16 0 15 0;
+#X connect 17 0 28 0;
+#X connect 18 0 17 1;
+#X connect 19 0 18 1;
+#X connect 19 0 17 1;
+#X connect 20 0 8 0;
+#X connect 21 0 22 0;
+#X connect 22 0 23 0;
+#X connect 23 0 27 0;
+#X connect 24 1 13 0;
+#X connect 25 0 3 0;
+#X connect 26 0 25 0;
+#X connect 27 0 2 0;
+#X connect 28 0 29 0;
+#X connect 29 0 18 0;
+#X connect 29 0 31 0;
+#X connect 30 0 17 0;
+#X connect 31 0 16 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
+#X obj 425 119 tgl 25 0 empty empty empty 0 -6 0 8 -225271 -1 -1 1
1;
#X text 308 95 turn this on to make some noise with the mouse;
#X obj 211 241 unpack symbol float;
@@ -72,7 +106,7 @@
;
#X text 228 436 released under the GNU GPL;
#X text 424 436 $Author: eighthave $;
-#X text 424 423 $Revision: 1.7 $;
+#X text 424 423 $Revision: 1.8 $;
#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
@@ -82,30 +116,36 @@ 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 obj 130 161 mouse 0;
#X text 13 111 turn on polling:;
-#X connect 1 0 36 0;
-#X connect 9 0 36 0;
-#X connect 10 0 36 0;
-#X connect 11 0 36 0;
-#X connect 13 0 12 1;
-#X connect 14 0 12 1;
-#X connect 15 0 12 1;
-#X connect 16 0 12 0;
-#X connect 18 0 0 0;
-#X connect 18 1 2 0;
-#X connect 34 0 6 0;
-#X connect 34 1 7 0;
-#X connect 34 2 8 0;
-#X connect 34 3 20 0;
-#X connect 34 4 21 0;
-#X connect 34 5 22 0;
-#X connect 34 6 23 0;
-#X connect 34 7 24 0;
-#X connect 34 8 26 0;
-#X connect 34 9 33 0;
-#X connect 36 0 5 0;
-#X connect 36 1 4 0;
-#X connect 36 2 3 0;
-#X connect 36 3 18 0;
-#X connect 36 3 34 0;
+#X msg 533 163 open \$1;
+#X obj 516 140 hradio 15 1 1 8 empty empty choose_a_device 0 -6 1 9
+-262144 -1 -1 2;
+#X floatatom 516 165 1 0 0 0 - - -;
+#X msg 180 146 refresh;
+#X obj 130 171 mouse 0;
+#X connect 1 0 38 0;
+#X connect 9 0 38 0;
+#X connect 10 0 38 0;
+#X connect 11 0 38 0;
+#X connect 13 0 12 0;
+#X connect 15 0 0 0;
+#X connect 15 1 2 0;
+#X connect 31 0 6 0;
+#X connect 31 1 7 0;
+#X connect 31 2 8 0;
+#X connect 31 3 17 0;
+#X connect 31 4 18 0;
+#X connect 31 5 19 0;
+#X connect 31 6 20 0;
+#X connect 31 7 21 0;
+#X connect 31 8 23 0;
+#X connect 31 9 30 0;
+#X connect 34 0 12 1;
+#X connect 35 0 36 0;
+#X connect 35 0 34 0;
+#X connect 37 0 38 0;
+#X connect 38 0 5 0;
+#X connect 38 1 4 0;
+#X connect 38 2 3 0;
+#X connect 38 3 15 0;
+#X connect 38 3 31 0;
diff --git a/hid_darwin.c b/hid_darwin.c
index f87fb37..6b19be3 100644
--- a/hid_darwin.c
+++ b/hid_darwin.c
@@ -115,11 +115,30 @@ void convertDarwinElementToLinuxTypeCode(pRecElement element, char *linux_type,
sprintf(linux_type,"abs");sprintf(linux_code,"abs_throttle");break;
}
break;
+ case kHIDPage_KeyboardOrKeypad:
+ sprintf(linux_type, "key");
+ /* temporary kludge until I feel like writing the translation table */
+ sprintf(linux_code, "key_%ld", element->usage);
+ break;
case kHIDPage_Button:
sprintf(linux_type, "key");
/* HID Manager button numbers start at 1, [hid] start at 0 */
sprintf(linux_code, "btn_%ld", element->usage - 1);
break;
+ case kHIDPage_LEDs:
+ /* temporary kludge until I feel like writing the translation table */
+ sprintf(linux_type, "led");
+ sprintf(linux_code, "led_%ld", element->usage - 1);
+ break;
+ case kHIDPage_PID:
+ /* temporary kludge until I feel like writing the translation table */
+ sprintf(linux_type, "ff");
+ sprintf(linux_code, "ff_%ld", element->usage - 1);
+ break;
+ default:
+ /* temporary kludge until I feel like writing the translation table */
+ sprintf(linux_type, "not_implemented");
+ sprintf(linux_code, "notimp_%ld", element->usage - 1);
}
}
diff --git a/hid_rel2abs.pd b/hid_rel2abs.pd
index f7358ca..b244a50 100644
--- a/hid_rel2abs.pd
+++ b/hid_rel2abs.pd
@@ -1,17 +1,25 @@
-#N canvas 0 22 458 308 10;
+#N canvas 0 22 466 316 10;
#X obj 137 20 inlet;
-#X obj 222 267 outlet;
+#X obj 221 272 outlet;
#X floatatom 221 81 5 0 0 0 - - -;
#X obj 137 81 route reset;
#X obj 221 174 +;
-#X obj 251 174 f;
-#X msg 137 126 0;
+#X obj 281 174 f;
+#X obj 232 195 min \$2;
+#X obj 232 214 max \$1;
+#X obj 260 137 f \$1;
+#X obj 215 26 loadbang;
+#X msg 215 45 reset;
#X connect 0 0 3 0;
-#X connect 3 0 6 0;
+#X connect 3 0 8 0;
#X connect 3 1 2 0;
#X connect 3 1 4 0;
-#X connect 4 0 5 0;
#X connect 4 0 1 0;
+#X connect 4 0 6 0;
#X connect 5 0 4 1;
-#X connect 6 0 4 1;
-#X connect 6 0 5 1;
+#X connect 6 0 7 0;
+#X connect 7 0 5 0;
+#X connect 8 0 4 1;
+#X connect 8 0 5 0;
+#X connect 9 0 10 0;
+#X connect 10 0 3 0;
diff --git a/keyboard.pd b/keyboard.pd
new file mode 100644
index 0000000..decbe2d
--- /dev/null
+++ b/keyboard.pd
@@ -0,0 +1,12 @@
+#N canvas 0 22 470 320 10;
+#X msg 96 64 start;
+#X msg 105 83 stop;
+#X obj 77 30 inlet;
+#X obj 77 107 hid \$1;
+#X obj 77 139 route key;
+#X obj 77 273 outlet;
+#X connect 0 0 3 0;
+#X connect 1 0 3 0;
+#X connect 2 0 3 0;
+#X connect 3 0 4 0;
+#X connect 4 0 5 0;
diff --git a/mouse.pd b/mouse.pd
index a981cb5..8a83b6d 100644
--- a/mouse.pd
+++ b/mouse.pd
@@ -1,4 +1,4 @@
-#N canvas 305 189 713 458 10;
+#N canvas 305 189 717 462 10;
#X obj 125 38 inlet;
#X obj 5 346 outlet;
#X obj 110 346 outlet;
@@ -16,7 +16,6 @@
#X obj 187 37 loadbang;
#X obj 5 283 autoscale -1 1;
#X obj 110 283 autoscale -1 1;
-#X obj 220 284 autoscale -1 1;
#X obj 67 233 route rel_x rel_y rel_wheel;
#X obj 271 258 print MOUSE_UNIMPLEMENTED_EVENT;
#X text 343 139 this is for once this feature is implemented;
@@ -27,8 +26,8 @@
;
#X text 218 436 released under the GNU GPL;
#X text 414 436 $Author: eighthave $;
-#X text 414 423 $Revision: 1.3 $;
-#X connect 0 0 21 0;
+#X text 414 423 $Revision: 1.4 $;
+#X connect 0 0 20 0;
#X connect 6 0 5 0;
#X connect 7 0 6 0;
#X connect 8 0 7 0;
@@ -36,10 +35,9 @@
#X connect 14 0 13 0;
#X connect 15 0 1 0;
#X connect 16 0 2 0;
-#X connect 17 0 3 0;
-#X connect 18 0 15 0;
-#X connect 18 1 16 0;
-#X connect 18 2 17 0;
-#X connect 21 0 22 0;
-#X connect 22 0 18 0;
-#X connect 22 1 4 0;
+#X connect 17 0 15 0;
+#X connect 17 1 16 0;
+#X connect 17 2 3 0;
+#X connect 20 0 21 0;
+#X connect 21 0 17 0;
+#X connect 21 1 4 0;