Commit 0aca2acc authored by phil's avatar phil
Browse files

some fixes

parent 0b4c8c1f
#N canvas 533 151 723 728 12;
#X obj 309 164 hid;
#X obj 283 256 print;
#X msg 382 31 list;
#X msg 383 71 list vendorid 1;
#X msg 382 196 list usage_page 1;
#X msg 383 220 list usage 2;
#X msg 383 244 list usage_page 1 usage 2;
#X msg 384 280 list joystick;
#X msg 385 304 list mouse;
#X msg 387 398 open mouse;
#X msg 392 462 close;
#X msg 394 580 poll 0;
#X msg 394 553 poll 10;
#X obj 395 511 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
#N canvas 533 151 941 735 12;
#X obj 434 89 hid;
#X msg 502 105 list;
#X msg 503 145 list vendorid 1;
#X msg 502 270 list usage_page 1;
#X msg 503 294 list usage 2;
#X msg 503 318 list usage_page 1 usage 2;
#X msg 504 354 list joystick;
#X msg 505 378 list mouse;
#X msg 507 499 open mouse;
#X msg 512 563 close;
#X msg 511 703 poll 0;
#X obj 512 634 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
-1 -1;
#X msg 384 95 list productid 2;
#X msg 384 120 list serial 0vsf-dfsd-sdg123;
#X msg 385 147 list vendorid 1 productid 2 serial 123-456;
#X msg 388 424 open joystick;
#X msg 385 355 open vendorid 1 productid 2 serial 123-345;
#X text 97 506 output all available output values;
#X msg 72 158 report_id;
#X msg 72 215 report_id \$1;
#X floatatom 72 192 5 0 0 0 - - -;
#X text 41 31 list all devices or search for particular criteria (any
#X msg 504 169 list productid 2;
#X msg 504 194 list serial 0vsf-dfsd-sdg123;
#X msg 505 221 list vendorid 1 productid 2 serial 123-456;
#X msg 508 525 open joystick;
#X msg 505 456 open vendorid 1 productid 2 serial 123-345;
#X text 512 601 output all available output values;
#X text 494 69 list all devices or search for particular criteria (any
combination possible);
#X text 21 552 automatically poll for values every N ms and turn off
#X text 504 656 automatically poll for values every N ms and turn off
with zero value;
#X text 47 354 open FIRST device matching criteria and close again..
#X text 505 432 open FIRST device matching criteria and close again..
;
#X text 355 643 USB HID PD external requires system libusb and hidapi
#X text 29 22 USB HID PD external requires system libusb and hidapi
compatibility https://github.com/tschiemer/hid-pd-external;
#X connect 0 0 1 0;
#X msg 511 676 poll 1;
#X floatatom 193 423 5 0 0 0 - - -;
#X floatatom 194 444 5 0 0 0 - - -;
#X floatatom 194 464 5 0 0 0 - - -;
#X floatatom 194 485 5 0 0 0 - - -;
#X floatatom 194 507 5 0 0 0 - - -;
#X obj 103 129 route device opened closed value;
#X obj 57 174 print device;
#X obj 157 218 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
1;
#X msg 158 175 1;
#X msg 214 175 0;
#X obj 170 255 route 1 9 5;
#X obj 192 297 print button;
#X text 25 384 Generic controls (1);
#X text 139 424 x (48);
#X text 139 446 y (49);
#X text 132 467 Rz (53);
#X text 104 486 Slider (54);
#X text 111 508 Wheel (56);
#X text 96 296 button (9);
#X obj 194 323 print gamepad;
#X text 90 320 gamepad (5);
#X floatatom 195 530 5 0 0 0 - - -;
#X obj 193 385 route 48 49 53 54 56 57;
#X text 75 532 Hat Switch (57);
#X obj 195 350 print other_user_page;
#X obj 272 502 print other_usage;
#X text 75 218 open ?;
#X connect 0 0 28 0;
#X connect 1 0 0 0;
#X connect 2 0 0 0;
#X connect 3 0 0 0;
#X connect 4 0 0 0;
......@@ -46,8 +71,21 @@ compatibility https://github.com/tschiemer/hid-pd-external;
#X connect 13 0 0 0;
#X connect 14 0 0 0;
#X connect 15 0 0 0;
#X connect 16 0 0 0;
#X connect 17 0 0 0;
#X connect 20 0 0 0;
#X connect 21 0 0 0;
#X connect 22 0 21 0;
#X connect 22 0 0 0;
#X connect 28 0 29 0;
#X connect 28 1 31 0;
#X connect 28 2 32 0;
#X connect 28 3 33 0;
#X connect 31 0 30 0;
#X connect 32 0 30 0;
#X connect 33 0 45 0;
#X connect 33 1 34 0;
#X connect 33 2 42 0;
#X connect 33 3 47 0;
#X connect 45 0 23 0;
#X connect 45 1 24 0;
#X connect 45 2 25 0;
#X connect 45 3 26 0;
#X connect 45 4 27 0;
#X connect 45 5 44 0;
#X connect 45 6 48 0;
......@@ -810,14 +810,19 @@ static int hid_read_report(hid_t * hid)
size_t r = hid_read_timeout(hid->handle, data, sizeof(data), hid->poll_ms ? hid->poll_ms : 0);
if (r > 0){
// post("got report!");
// post("got report! %d", r);
//
// for(int i = 0; i < r; i++){
// post("%02x", data[i]);
// }
//
// return r;
if (r != hid->report_size){
error("report size mismatch! expecting errors");
hid->poll_ms = 0;
}
// only act when data is different
else if (memcmp(data, hid->last_report, hid->report_size) != 0) {
else {//if (memcmp(data, hid->last_report, hid->report_size) != 0) {
// post("report changed");
// update last report
......@@ -828,21 +833,23 @@ static int hid_read_report(hid_t * hid)
} else {
for( size_t i = 0; i < hid->value_count; i++){
if (hid->last_values[i] != hid->tmp_values[i]){
if (hid->last_values[i] != hid->tmp_values[i])
{
// post("changed %d to %d", hid->report_items[i]->usage, hid->tmp_values[i]);
t_atom atoms[2];
SETFLOAT(atoms, hid->report_items[i]->usage);
SETFLOAT(atoms + 1, hid->tmp_values[i]);
t_atom atoms[3];
SETFLOAT(atoms, hid->report_items[i]->usage_page);
SETFLOAT(atoms + 1, hid->report_items[i]->usage);
SETFLOAT(atoms + 2, hid->tmp_values[i]);
outlet_anything(hid->out, gensym("value"), 2, atoms);
outlet_anything(hid->out, gensym("value"), 3, atoms);
}
}
int32_t * swap = hid->last_values;
hid->last_values = hid->tmp_values;
hid->tmp_values = swap;
// memcpy(hid->last_values, hid->tmp_values, hid->value_count * sizeof(int32_t));
// int32_t * swap = hid->last_values;
// hid->last_values = hid->tmp_values;
// hid->tmp_values = swap;
memcpy(hid->last_values, hid->tmp_values, hid->value_count * sizeof(int32_t));
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment