From 742e122ef16d2538803a3d40596ca9bd4b3f2112 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 15 Nov 2004 04:05:39 +0000 Subject: converted button codes to a numbered scheme; added [buttongate] svn path=/trunk/externals/hcs/hid/; revision=2275 --- TODO | 12 +---- buttongate.pd | 27 ++++++++++ doc/buttongate-help.pd | 24 +++++++++ doc/hid-help.pd | 98 ++++++++++++++++++++++------------ doc/joystick-help.pd | 16 +++--- doc/mouse-help.pd | 47 +++++++++-------- hid.h | 3 +- hid_darwin.c | 22 ++++---- hid_linux.c | 139 +++++++++++++++++++++++++++++++++++++++++-------- 9 files changed, 278 insertions(+), 110 deletions(-) create mode 100644 buttongate.pd create mode 100644 doc/buttongate-help.pd diff --git a/TODO b/TODO index d51c069..ae6e39f 100644 --- a/TODO +++ b/TODO @@ -76,13 +76,6 @@ Darwin - are [start( and [stop( needed? is 0/1 enough? -============================================================================== -= ditch x_devname in hid_linux.c - -- use sprintf(arg,"/dev/input/event%d",x_ddevice_number); instead - - - ============================================================================== = consistent console output @@ -96,14 +89,13 @@ void hid_post(const char *format, const char *); ============================================================================== = event name changes -- make key/button Type ev_btn rather than ev_key +- make key/button Type btn rather than key (undecided on this one) -- perhaps remove the "ev_" prefix on event Types for efficiency and clarity ============================================================================== = mapping object ideas -- [mousefilter]-like object to easily control things with a button + ______________________________________________________________________________ ------------------------------------------------------------------------------ diff --git a/buttongate.pd b/buttongate.pd new file mode 100644 index 0000000..aed6454 --- /dev/null +++ b/buttongate.pd @@ -0,0 +1,27 @@ +#N canvas 367 43 501 384 10; +#X obj 224 82 hid \$1; +#X obj 224 24 inlet; +#X obj 224 107 route key; +#X obj 224 137 route \$2; +#X obj 104 26 inlet; +#X obj 104 245 outlet; +#X obj 104 214 spigot; +#X text 9 278 (C) Copyright 2004 Hans-Christoph Steiner +; +#X text 226 292 released under the GNU GPL; +#X text 16 329 $Author: eighthave $; +#X text 16 346 $Date: 2004-11-15 04:05:39 $; +#X text 16 312 $Revision: 1.1 $; +#X obj 319 21 loadbang; +#X msg 319 42 1; +#X obj 224 170 unpack f f; +#X text 5 6 [buttongate]; +#X connect 0 0 2 0; +#X connect 1 0 0 0; +#X connect 2 0 3 0; +#X connect 3 0 14 0; +#X connect 4 0 6 0; +#X connect 6 0 5 0; +#X connect 12 0 13 0; +#X connect 13 0 0 0; +#X connect 14 0 6 1; diff --git a/doc/buttongate-help.pd b/doc/buttongate-help.pd new file mode 100644 index 0000000..e990139 --- /dev/null +++ b/doc/buttongate-help.pd @@ -0,0 +1,24 @@ +#N canvas 11 255 460 423 10; +#X obj 5 2 cnv 15 450 20 empty empty buttongate] 2 11 1 18 -233017 +-66577 0; +#X obj 98 306 bng 25 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X obj 98 149 loadbang; +#X msg 98 169 1; +#X obj 98 197 metro 150; +#X text 27 380 (C) Copyright 2004 Hans-Christoph Steiner +; +#X text 244 394 released under the GNU GPL; +#X obj 327 332 all_about_hid; +#X text 218 333 For more info:; +#X text 17 38 [buttongate] is a simple gate controlled by a HID button. +You must specify the device and the button which controls the gate. +The left inlet takes the data to be gated. The right inlet is for sending +optional control messages to the HID.; +#X obj 98 242 buttongate 0 btn_0; +#X text 18 119 The first button on the first device controls this gate: +; +#X connect 2 0 3 0; +#X connect 3 0 4 0; +#X connect 4 0 10 0; +#X connect 10 0 1 0; diff --git a/doc/hid-help.pd b/doc/hid-help.pd index 8e43b8b..4692b04 100644 --- a/doc/hid-help.pd +++ b/doc/hid-help.pd @@ -1,5 +1,5 @@ -#N canvas 267 62 963 686 10; -#X msg 430 325 rel rel_x 0 3.31743e+09; +#N canvas 148 25 908 628 10; +#X msg 430 325 rel rel_y -6 1.10049e+09; #X obj 430 304 prepend set; #X obj 149 473 route rel_x rel_y; #X floatatom 149 493 5 0 0 0 - - -; @@ -15,7 +15,7 @@ #X msg 265 129 open 4; #X floatatom 206 454 7 0 0 0 - - -; #X floatatom 264 454 7 0 0 0 - - -; -#X obj 86 81 tgl 35 0 empty empty empty 0 -6 0 8 -24198 -1 -1 0 25 +#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 - -; @@ -48,15 +48,12 @@ #X msg 336 136 close; #X msg 336 113 refresh; #X text 397 111 refresh device list; -#X obj 94 524 unpack s f f; -#X obj 133 542 tgl 25 0 empty empty any_button 27 13 1 9 -195568 -1 --1 0 1; -#X obj 746 556 all_about_hid; -#X text 637 557 For more info:; +#X obj 717 512 all_about_hid; +#X text 608 513 For more info:; #X text 49 588 (C) Copyright 2004 Hans-Christoph Steiner ; #X text 266 602 released under the GNU GPL; -#X text 472 589 $Revision: 1.9 $$Date: 2004-11-14 22:29:43 $; +#X text 472 589 $Revision: 1.10 $$Date: 2004-11-15 04:05:39 $; #X text 473 602 $Author: eighthave $; #X obj 206 433 route abs_x abs_y abs_z; #X floatatom 322 454 7 0 0 0 - - -; @@ -69,41 +66,74 @@ of it could change without notice !!!; #X obj 248 225 hid 1; #X obj 93 345 route key rel abs syn; +#X obj 53 552 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1 +; +#X obj 93 552 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1 +; +#X obj 134 552 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +1; +#X obj 175 552 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +1; +#X obj 216 552 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +1; +#X obj 257 552 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +1; +#X obj 297 552 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +1; +#X obj 338 552 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +1; +#X obj 379 552 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +1; +#X msg 270 149 open 5; +#X obj 53 519 route btn_0 btn_1 btn_2 btn_3 btn_4 btn_5 btn_6 btn_7 +btn_8 btn_9; +#X obj 420 552 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +1; #X connect 1 0 0 0; #X connect 2 0 3 0; #X connect 2 1 4 0; -#X connect 5 0 61 0; -#X connect 6 0 61 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 61 0; -#X connect 10 0 61 0; -#X connect 11 0 61 0; -#X connect 12 0 61 0; -#X connect 13 0 61 0; -#X connect 16 0 61 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 40 0 39 0; #X connect 41 0 40 0; -#X connect 42 0 61 0; -#X connect 43 0 61 0; -#X connect 45 1 46 0; -#X connect 53 0 14 0; -#X connect 53 1 15 0; -#X connect 53 2 54 0; -#X connect 55 0 61 0; -#X connect 56 0 61 0; -#X connect 59 0 61 0; -#X connect 61 0 37 0; -#X connect 61 0 1 0; -#X connect 61 0 8 0; -#X connect 61 0 62 0; -#X connect 62 0 45 0; -#X connect 62 1 2 0; -#X connect 62 2 53 0; -#X connect 62 3 41 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; diff --git a/doc/joystick-help.pd b/doc/joystick-help.pd index 9013a0b..9d8ef20 100644 --- a/doc/joystick-help.pd +++ b/doc/joystick-help.pd @@ -1,5 +1,5 @@ #N canvas 96 237 669 433 10; -#X obj 168 41 tgl 25 0 empty empty empty 0 -6 0 8 -225271 -1 -1 1 1 +#X obj 168 41 tgl 25 0 empty empty empty 0 -6 0 8 -225271 -1 -1 0 1 ; #X floatatom 63 184 7 0 0 3 Y-axis - -; #X floatatom 9 184 7 0 0 3 X-axis - -; @@ -35,17 +35,17 @@ btn_9; #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 msg 220 62 open 2; -#X msg 225 81 open 3; #X text 1 382 (C) Copyright 2004 Hans-Christoph Steiner ; #X text 218 396 released under the GNU GPL; #X text 414 396 $Author: eighthave $; -#X text 414 383 $Revision: 1.2 $; +#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; @@ -61,12 +61,12 @@ btn_9; #X connect 14 1 1 0; #X connect 14 2 7 0; #X connect 14 3 8 0; -#X connect 14 4 31 0; -#X connect 14 5 32 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 23 0 14 0; -#X connect 24 0 14 0; +#X connect 31 0 14 0; +#X connect 32 0 14 0; diff --git a/doc/mouse-help.pd b/doc/mouse-help.pd index 3bac550..db4eda7 100644 --- a/doc/mouse-help.pd +++ b/doc/mouse-help.pd @@ -6,11 +6,11 @@ #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 287 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 193 285 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 238 287 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 238 284 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 284 287 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 283 284 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; @@ -55,29 +55,31 @@ #X obj 130 111 mouse 1; #X obj 211 191 unpack symbol float; #X text 282 234 buttons; -#X obj 193 264 route btn_1 btn_2 btn_3 btn_4 btn_5 btn_6 btn_7 btn_8 -; -#X obj 330 287 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 329 284 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 376 287 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 374 284 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 421 287 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 419 284 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 467 287 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 465 284 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 1; -#X obj 513 287 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 510 284 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 559 287 tgl 25 0 empty empty empty 0 -6 0 8 -195568 -1 -1 0 +#X obj 555 284 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 ; #X text 218 386 released under the GNU GPL; #X text 414 386 $Author: eighthave $; -#X text 414 373 $Revision: 1.4 $; +#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 +1; +#X obj 193 264 route btn_0 btn_1 btn_2 btn_3 btn_4 btn_5 btn_6 btn_7 +btn_8; #X connect 1 0 18 0; #X connect 9 0 18 0; #X connect 10 0 18 0; @@ -90,15 +92,16 @@ #X connect 18 1 4 0; #X connect 18 2 3 0; #X connect 18 3 19 0; -#X connect 18 3 21 0; +#X connect 18 3 35 0; #X connect 19 0 0 0; #X connect 19 1 2 0; -#X connect 21 0 6 0; -#X connect 21 1 7 0; -#X connect 21 2 8 0; -#X connect 21 3 22 0; -#X connect 21 4 23 0; -#X connect 21 5 24 0; -#X connect 21 6 25 0; -#X connect 21 7 26 0; -#X connect 21 8 28 0; +#X connect 35 0 6 0; +#X connect 35 1 7 0; +#X connect 35 2 8 0; +#X connect 35 3 21 0; +#X connect 35 4 22 0; +#X connect 35 5 23 0; +#X connect 35 6 24 0; +#X connect 35 7 25 0; +#X connect 35 8 27 0; +#X connect 35 9 34 0; diff --git a/hid.h b/hid.h index cc8fd32..7db864b 100644 --- a/hid.h +++ b/hid.h @@ -14,7 +14,7 @@ #define HID_MAJOR_VERSION 0 #define HID_MINOR_VERSION 1 -static char *version = "$Revision: 1.9 $"; +static char *version = "$Revision: 1.10 $"; /*------------------------------------------------------------------------------ * CLASS DEF @@ -25,7 +25,6 @@ typedef struct _hid { t_object x_obj; t_int x_fd; - t_symbol *x_devname; t_int x_device_number; t_clock *x_clock; t_int x_delay; diff --git a/hid_darwin.c b/hid_darwin.c index 003515d..b257b2f 100644 --- a/hid_darwin.c +++ b/hid_darwin.c @@ -72,17 +72,17 @@ char *convertEventsFromDarwinToLinux(pRecElement element); *============================================================================== */ -void convertAxis(pRecElement element, char *linux_type, char *linux_code, char axis) +void convertAxis(pRecElement element, char *linux_type, char *linux_code, char *axis) { if (element->relative) { sprintf(linux_type,"rel"); - sprintf(linux_code,"rel_%c",axis); + sprintf(linux_code,"rel_%s",axis); } else { sprintf(linux_type,"abs"); - sprintf(linux_code,"abs_%c",axis); + sprintf(linux_code,"abs_%s",axis); } } @@ -103,12 +103,12 @@ void convertDarwinElementToLinuxTypeCode(pRecElement element, char *linux_type, case kHIDPage_GenericDesktop: switch (element->usage) { - case kHIDUsage_GD_X: convertAxis(element, linux_type, linux_code, 'x'); break; - case kHIDUsage_GD_Y: convertAxis(element, linux_type, linux_code, 'y'); break; - case kHIDUsage_GD_Z: convertAxis(element, linux_type, linux_code, 'z'); break; - case kHIDUsage_GD_Rx: convertAxis(element, linux_type, linux_code, 'x'); break; - case kHIDUsage_GD_Ry: convertAxis(element, linux_type, linux_code, 'y'); break; - case kHIDUsage_GD_Rz: convertAxis(element, linux_type, linux_code, 'z'); break; + case kHIDUsage_GD_X: convertAxis(element, linux_type, linux_code, "x"); break; + case kHIDUsage_GD_Y: convertAxis(element, linux_type, linux_code, "y"); break; + case kHIDUsage_GD_Z: convertAxis(element, linux_type, linux_code, "z"); break; + case kHIDUsage_GD_Rx: convertAxis(element, linux_type, linux_code, "rx"); break; + case kHIDUsage_GD_Ry: convertAxis(element, linux_type, linux_code, "ry"); break; + 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; } @@ -172,7 +172,7 @@ t_int hid_build_element_list(t_hid *x) DEBUG(post("[hid] found %d elements:",numElements);); - post("-----------------------------------------------------------"); + post(""); post(" TYPE\t\tCODE\tEVENT NAME"); post("-----------------------------------------------------------"); for(i=0; i= 0x100) + { + if(linux_code < BTN_MOUSE) + sprintf(hid_code,"btn_%d",linux_code - BTN_MISC); /* numbered buttons */ + else if(linux_code < BTN_JOYSTICK) + sprintf(hid_code,"btn_%d",linux_code - BTN_MOUSE); /* mouse buttons */ + else if(linux_code < BTN_GAMEPAD) + sprintf(hid_code,"btn_%d",linux_code - BTN_JOYSTICK); /* joystick buttons */ + else if(linux_code < BTN_DIGI) + sprintf(hid_code,"btn_%d",linux_code - BTN_GAMEPAD); /* gamepad buttons */ + else if(linux_code < BTN_WHEEL) + sprintf(hid_code,"btn_%d",linux_code - BTN_DIGI); /* tablet buttons */ + else if(linux_code < KEY_OK) + sprintf(hid_code,"btn_%d",linux_code - BTN_WHEEL); /* wheel buttons */ + } +} + +/* ============================================================================== */ +/* Pd [hid] FUNCTIONS */ +/* ============================================================================== */ + t_int hid_get_events(t_hid *x) { DEBUG(post("hid_get_events");); @@ -60,7 +120,16 @@ t_int hid_get_events(t_hid *x) /* type */ SETSYMBOL(event_data, gensym(ev[hid_input_event.type])); /* code */ - SETSYMBOL(event_data + 1, gensym(event_names[hid_input_event.type][hid_input_event.code])); + if (hid_input_event.type == EV_KEY) + { + char hid_code[7]; + hid_convert_linux_buttons_to_numbers(hid_input_event.code,hid_code); + SETSYMBOL(event_data + 1, + gensym(hid_code)); + } + else + SETSYMBOL(event_data + 1, + gensym(event_names[hid_input_event.type][hid_input_event.code])); /* value */ SETFLOAT(event_data + 2, (t_float)hid_input_event.value); /* time */ @@ -81,29 +150,28 @@ t_int hid_open_device(t_hid *x, t_int device_number) { DEBUG(post("hid_open_device");); - char arg[20]; + char device_name[20]; struct input_event hid_input_event; unsigned long bitmask[EV_MAX][NBITS(KEY_MAX)]; char devicename[256] = "Unknown"; t_int event_type, event_code; - char *event_typeName = ""; + char *event_type_name = ""; /* counts for various event types */ t_int synCount,keyCount,relCount,absCount,mscCount,ledCount,sndCount,repCount,ffCount,pwrCount,ff_statusCount; x->x_fd = -1; x->x_device_number = device_number; - sprintf(arg,"/dev/input/event%d",x->x_device_number); - x->x_devname = gensym(arg); + sprintf(device_name,"/dev/input/event%d",x->x_device_number); - if (x->x_devname) + if (device_name) { /* open the device read-only, non-exclusive */ - x->x_fd = open(x->x_devname->s_name, O_RDONLY | O_NONBLOCK); + x->x_fd = open(device_name, O_RDONLY | O_NONBLOCK); /* test if device open */ if (x->x_fd < 0 ) { - error("[hid] open %s failed",x->x_devname->s_name); + error("[hid] open %s failed",device_name); x->x_fd = -1; return 1; } @@ -117,7 +185,7 @@ t_int hid_open_device(t_hid *x, t_int device_number) /* get name of device */ ioctl(x->x_fd, EVIOCGNAME(sizeof(devicename)), devicename); post ("\nConfiguring device %d as %s (%s)", - x->x_device_number,devicename,x->x_devname->s_name); + x->x_device_number,devicename,device_name); /* get bitmask representing supported events (axes, keys, etc.) */ memset(bitmask, 0, sizeof(bitmask)); @@ -136,23 +204,27 @@ t_int hid_open_device(t_hid *x, t_int device_number) /* make pretty names for event types */ switch(event_type) { - case EV_SYN: event_typeName = "Synchronization"; break; - case EV_KEY: event_typeName = "Keys/Buttons"; break; - case EV_REL: event_typeName = "Relative Axes"; break; - case EV_ABS: event_typeName = "Absolute Axes"; break; - case EV_MSC: event_typeName = "Miscellaneous"; break; - case EV_LED: event_typeName = "LEDs"; break; - case EV_SND: event_typeName = "System Sounds"; break; - case EV_REP: event_typeName = "Autorepeat Values"; break; - case EV_FF: event_typeName = "Force Feedback"; break; - case EV_PWR: event_typeName = "Power"; break; - case EV_FF_STATUS: event_typeName = "Force Feedback Status"; break; + case EV_SYN: event_type_name = "Synchronization"; break; + case EV_KEY: event_type_name = "Keys/Buttons"; break; + case EV_REL: event_type_name = "Relative Axis"; break; + case EV_ABS: event_type_name = "Absolute Axis"; break; + case EV_MSC: event_type_name = "Miscellaneous"; break; + case EV_LED: event_type_name = "LEDs"; break; + case EV_SND: event_type_name = "System Sounds"; break; + case EV_REP: event_type_name = "Autorepeat Values"; break; + case EV_FF: event_type_name = "Force Feedback"; break; + case EV_PWR: event_type_name = "Power"; break; + case EV_FF_STATUS: event_type_name = "Force Feedback Status"; break; } - post(" %s (%s/type %d) ", event_typeName, ev[event_type] ? ev[event_type] : "?", event_type); +// post(" %s (%s) ", event_type_name, ev[event_type] ? ev[event_type] : "?", event_type); /* get bitmask representing supported button types */ ioctl(x->x_fd, EVIOCGBIT(event_type, KEY_MAX), bitmask[event_type]); + post(""); + post(" TYPE\t\tCODE\tEVENT NAME"); + post("-----------------------------------------------------------"); + /* cycle through all possible event codes (axes, keys, etc.) * testing to see which are supported */ @@ -160,9 +232,22 @@ t_int hid_open_device(t_hid *x, t_int device_number) { if (test_bit(event_code, bitmask[event_type])) { - post(" %s (%d)", event_names[event_type] ? (event_names[event_type][event_code] ? event_names[event_type][event_code] : "?") : "?", event_code); + if ((event_type == EV_KEY) && (event_code >= BTN_MISC) && (event_code < KEY_OK) ) + { + char hid_code[7]; + hid_convert_linux_buttons_to_numbers(event_code,hid_code); + post(" %s\t\t%s\t%s", + ev[event_type] ? ev[event_type] : "?", + hid_code, + event_names[event_type] ? (event_names[event_type][event_code] ? event_names[event_type][event_code] : "?") : "?"); + } + else + post(" %s\t\t%s\t%s", + ev[event_type] ? ev[event_type] : "?", + event_names[event_type] ? (event_names[event_type][event_code] ? event_names[event_type][event_code] : "?") : "?", + event_type_name); /* post(" Event code %d (%s)", event_code, names[event_type] ? (names[event_type][event_code] ? names[event_type][event_code] : "?") : "?"); */ - + switch(event_type) { /* * the API changed at some point... EV_SYN seems to be the new name @@ -227,9 +312,17 @@ t_int hid_build_device_list(t_hid *x) * the device list. Once the device name can be other things in addition * the current t_float, then this will probably need to be changed. */ + + hid_list_devices(); + return (0); } +void hid_platform_specific_free(t_hid *x) +{ + /* nothing to be done here on GNU/Linux */ +} + #endif /* #ifdef __linux__ */ -- cgit v1.2.1