3#include <Phidget22/phidget22.h>
7#include <ossia/detail/hash.hpp>
12struct phidget_handle_t
15 phidget_handle_t(PhidgetHandle h)
20 int32_t get_serial()
const
23 Phidget_getDeviceSerialNumber(phid, &sn);
27 operator PhidgetHandle()
const {
return phid; }
29 phidget_handle_t get_parent()
const
32 Phidget_getParent(phid, &par);
35 auto get_device_class()
const
37 Phidget_DeviceClass dc;
38 Phidget_getDeviceClass(phid, &dc);
41 auto get_channel()
const
44 Phidget_getChannel(phid, &dc);
47 auto get_channel_class()
const
49 Phidget_ChannelClass dc;
50 Phidget_getChannelClass(phid, &dc);
53 auto get_channel_subclass()
const
55 Phidget_ChannelSubclass dc;
56 Phidget_getChannelSubclass(phid, &dc);
59 auto get_device_id()
const
62 Phidget_getDeviceID(phid, &dc);
65 auto get_hub_port()
const
68 Phidget_getHubPort(phid, &dc);
71 auto get_hub_port_count()
const
74 Phidget_getHubPortCount(phid, &dc);
77 bool is_attached()
const
80 Phidget_getAttached(phid, &dc);
83 bool is_hub_port_device()
const
86 Phidget_getIsHubPortDevice(phid, &dc);
89 bool is_channel()
const
92 Phidget_getIsChannel(phid, &dc);
96 std::string get_device_classname() {
return phidget_name(get_device_class()); }
97 std::string get_channel_classname() {
return phidget_name(get_channel_class()); }
98 std::string get_channel_subclassname() {
return phidget_name(get_channel_subclass()); }
99 std::string get_device_id_name() {
return phidget_id(get_device_id()); }
101 const char* phidget_id(Phidget_DeviceID cls)
106 return "PHIDID_NOTHING";
107 case PHIDID_INTERFACEKIT_4_8_8:
108 return "PHIDID_INTERFACEKIT_4_8_8";
110 return "PHIDID_1000";
112 return "PHIDID_1001";
114 return "PHIDID_1002";
116 return "PHIDID_1008";
117 case PHIDID_1010_1013_1018_1019:
118 return "PHIDID_1010_1013_1018_1019";
120 return "PHIDID_1011";
122 return "PHIDID_1012";
124 return "PHIDID_1014";
126 return "PHIDID_1015";
128 return "PHIDID_1016";
130 return "PHIDID_1017";
132 return "PHIDID_1023";
134 return "PHIDID_1024";
136 return "PHIDID_1030";
138 return "PHIDID_1031";
140 return "PHIDID_1032";
142 return "PHIDID_1040";
144 return "PHIDID_1041";
146 return "PHIDID_1042";
148 return "PHIDID_1043";
150 return "PHIDID_1044";
152 return "PHIDID_1045";
154 return "PHIDID_1046";
156 return "PHIDID_1047";
158 return "PHIDID_1048";
160 return "PHIDID_1049";
162 return "PHIDID_1051";
164 return "PHIDID_1052";
166 return "PHIDID_1053";
168 return "PHIDID_1054";
170 return "PHIDID_1055";
172 return "PHIDID_1056";
174 return "PHIDID_1057";
176 return "PHIDID_1058";
178 return "PHIDID_1059";
180 return "PHIDID_1060";
182 return "PHIDID_1061";
184 return "PHIDID_1062";
186 return "PHIDID_1063";
188 return "PHIDID_1064";
190 return "PHIDID_1065";
192 return "PHIDID_1066";
194 return "PHIDID_1067";
195 case PHIDID_1202_1203:
196 return "PHIDID_1202_1203";
198 return "PHIDID_1204";
199 case PHIDID_1215__1218:
200 return "PHIDID_1215__1218";
201 case PHIDID_1219__1222:
202 return "PHIDID_1219__1222";
204 return "PHIDID_ADP1000";
206 return "PHIDID_ADP1001";
208 return "PHIDID_DAQ1000";
210 return "PHIDID_DAQ1200";
212 return "PHIDID_DAQ1300";
214 return "PHIDID_DAQ1301";
216 return "PHIDID_DAQ1400";
218 return "PHIDID_DAQ1500";
220 return "PHIDID_DCC1000";
222 return "PHIDID_DST1000";
224 return "PHIDID_DST1200";
226 return "PHIDID_ENC1000";
228 return "PHIDID_HIN1000";
230 return "PHIDID_HIN1001";
232 return "PHIDID_HIN1100";
234 return "PHIDID_HUB0000";
236 return "PHIDID_HUB0001";
238 return "PHIDID_HUB0002";
240 return "PHIDID_HUB0004";
242 return "PHIDID_HUB0005";
244 return "PHIDID_HUM1000";
246 return "PHIDID_LCD1100";
248 return "PHIDID_LED1000";
250 return "PHIDID_LUX1000";
252 return "PHIDID_MOT1100";
254 return "PHIDID_MOT1101";
256 return "PHIDID_OUT1000";
258 return "PHIDID_OUT1001";
260 return "PHIDID_OUT1002";
262 return "PHIDID_OUT1100";
264 return "PHIDID_PRE1000";
266 return "PHIDID_RCC1000";
268 return "PHIDID_REL1000";
270 return "PHIDID_REL1100";
272 return "PHIDID_REL1101";
274 return "PHIDID_SAF1000";
276 return "PHIDID_SND1000";
278 return "PHIDID_STC1000";
280 return "PHIDID_TMP1000";
282 return "PHIDID_TMP1100";
284 return "PHIDID_TMP1101";
286 return "PHIDID_TMP1200";
288 return "PHIDID_TMP1300";
290 return "PHIDID_VCP1000";
292 return "PHIDID_VCP1001";
294 return "PHIDID_VCP1002";
295 case PHIDID_DIGITALINPUT_PORT:
296 return "PHIDID_DIGITALINPUT_PORT";
297 case PHIDID_DIGITALOUTPUT_PORT:
298 return "PHIDID_DIGITALOUTPUT_PORT";
299 case PHIDID_VOLTAGEINPUT_PORT:
300 return "PHIDID_VOLTAGEINPUT_PORT";
301 case PHIDID_VOLTAGERATIOINPUT_PORT:
302 return "PHIDID_VOLTAGERATIOINPUT_PORT";
303 case PHIDID_GENERICUSB:
304 return "PHIDID_GENERICUSB";
305 case PHIDID_GENERICVINT:
306 return "PHIDID_GENERICVINT";
307 case PHIDID_FIRMWARE_UPGRADE_USB:
308 return "PHIDID_FIRMWARE_UPGRADE_USB";
309 case PHIDID_FIRMWARE_UPGRADE_STM32F0:
310 return "PHIDID_FIRMWARE_UPGRADE_STM32F0";
311 case PHIDID_FIRMWARE_UPGRADE_STM8S:
312 return "PHIDID_FIRMWARE_UPGRADE_STM8S";
313 case PHIDID_FIRMWARE_UPGRADE_SPI:
314 return "PHIDID_FIRMWARE_UPGRADE_SPI";
316 return "PHIDID_VCP1100";
318 return "PHIDID_DCC1100";
320 return "PHIDID_HIN1101";
322 return "PHIDID_DCC1001";
323 case PHIDID_DICTIONARY:
324 return "PHIDID_DICTIONARY";
326 return "PHIDID_STC1001";
327 case PHIDID_USBSWITCH:
328 return "PHIDID_USBSWITCH";
333 const char* phidget_name(Phidget_DeviceClass cls)
337 case PHIDCLASS_ACCELEROMETER:
338 return "ACCELEROMETER";
339 case PHIDCLASS_ADVANCEDSERVO:
340 return "ADVANCEDSERVO";
341 case PHIDCLASS_ANALOG:
343 case PHIDCLASS_BRIDGE:
345 case PHIDCLASS_ENCODER:
347 case PHIDCLASS_FREQUENCYCOUNTER:
348 return "FREQUENCYCOUNTER";
353 case PHIDCLASS_INTERFACEKIT:
354 return "INTERFACEKIT";
359 case PHIDCLASS_MESHDONGLE:
361 case PHIDCLASS_MOTORCONTROL:
362 return "MOTORCONTROL";
363 case PHIDCLASS_PHSENSOR:
367 case PHIDCLASS_SERVO:
369 case PHIDCLASS_SPATIAL:
371 case PHIDCLASS_STEPPER:
373 case PHIDCLASS_TEMPERATURESENSOR:
374 return "TEMPERATURESENSOR";
375 case PHIDCLASS_TEXTLCD:
379 case PHIDCLASS_GENERIC:
381 case PHIDCLASS_FIRMWAREUPGRADE:
382 return "FIRMWAREUPGRADE";
383 case PHIDCLASS_DICTIONARY:
385 case PHIDCLASS_NOTHING:
391 const char* phidget_name(Phidget_ChannelClass cls)
395 case PHIDCHCLASS_NOTHING:
397 case PHIDCHCLASS_ACCELEROMETER:
398 return "ACCELEROMETER";
399 case PHIDCHCLASS_CURRENTINPUT:
400 return "CURRENTINPUT";
401 case PHIDCHCLASS_DATAADAPTER:
402 return "DATAADAPTER";
403 case PHIDCHCLASS_DCMOTOR:
405 case PHIDCHCLASS_DIGITALINPUT:
406 return "DIGITALINPUT";
407 case PHIDCHCLASS_DIGITALOUTPUT:
408 return "DIGITALOUTPUT";
409 case PHIDCHCLASS_DISTANCESENSOR:
410 return "DISTANCESENSOR";
411 case PHIDCHCLASS_ENCODER:
413 case PHIDCHCLASS_FREQUENCYCOUNTER:
414 return "FREQUENCYCOUNTER";
415 case PHIDCHCLASS_GPS:
417 case PHIDCHCLASS_LCD:
419 case PHIDCHCLASS_GYROSCOPE:
421 case PHIDCHCLASS_HUB:
423 case PHIDCHCLASS_CAPACITIVETOUCH:
424 return "CAPACITIVETOUCH";
425 case PHIDCHCLASS_HUMIDITYSENSOR:
426 return "HUMIDITYSENSOR";
429 case PHIDCHCLASS_LIGHTSENSOR:
430 return "LIGHTSENSOR";
431 case PHIDCHCLASS_MAGNETOMETER:
432 return "MAGNETOMETER";
433 case PHIDCHCLASS_MESHDONGLE:
435 case PHIDCHCLASS_PHSENSOR:
437 case PHIDCHCLASS_POWERGUARD:
439 case PHIDCHCLASS_PRESSURESENSOR:
440 return "PRESSURESENSOR";
441 case PHIDCHCLASS_RCSERVO:
443 case PHIDCHCLASS_RESISTANCEINPUT:
444 return "RESISTANCEINPUT";
445 case PHIDCHCLASS_RFID:
447 case PHIDCHCLASS_SOUNDSENSOR:
448 return "SOUNDSENSOR";
449 case PHIDCHCLASS_SPATIAL:
451 case PHIDCHCLASS_STEPPER:
453 case PHIDCHCLASS_TEMPERATURESENSOR:
454 return "TEMPERATURESENSOR";
455 case PHIDCHCLASS_VOLTAGEINPUT:
456 return "VOLTAGEINPUT";
457 case PHIDCHCLASS_VOLTAGEOUTPUT:
458 return "VOLTAGEOUTPUT";
459 case PHIDCHCLASS_VOLTAGERATIOINPUT:
460 return "VOLTAGERATIOINPUT";
461 case PHIDCHCLASS_FIRMWAREUPGRADE:
462 return "FIRMWAREUPGRADE";
463 case PHIDCHCLASS_GENERIC:
465 case PHIDCHCLASS_MOTORPOSITIONCONTROLLER:
466 return "MOTORPOSITIONCONTROLLER";
467 case PHIDCHCLASS_BLDCMOTOR:
469 case PHIDCHCLASS_DICTIONARY:
475 const char* phidget_name(Phidget_ChannelSubclass cls)
479 case PHIDCHSUBCLASS_NONE:
481 case PHIDCHSUBCLASS_DIGITALOUTPUT_DUTY_CYCLE:
482 return "DIGITALOUTPUT_DUTY_CYCLE";
483 case PHIDCHSUBCLASS_DIGITALOUTPUT_LED_DRIVER:
484 return "DIGITALOUTPUT_LED_DRIVER";
485 case PHIDCHSUBCLASS_TEMPERATURESENSOR_RTD:
486 return "TEMPERATURESENSOR_RTD";
487 case PHIDCHSUBCLASS_TEMPERATURESENSOR_THERMOCOUPLE:
488 return "TEMPERATURESENSOR_THERMOCOUPLE";
489 case PHIDCHSUBCLASS_VOLTAGEINPUT_SENSOR_PORT:
490 return "VOLTAGEINPUT_SENSOR_PORT";
491 case PHIDCHSUBCLASS_VOLTAGERATIOINPUT_SENSOR_PORT:
492 return "VOLTAGERATIOINPUT_SENSOR_PORT";
493 case PHIDCHSUBCLASS_VOLTAGERATIOINPUT_BRIDGE:
494 return "VOLTAGERATIOINPUT_BRIDGE";
495 case PHIDCHSUBCLASS_LCD_GRAPHIC:
496 return "LCD_GRAPHIC";
497 case PHIDCHSUBCLASS_LCD_TEXT:
499 case PHIDCHSUBCLASS_ENCODER_MODE_SETTABLE:
500 return "ENCODER_MODE_SETTABLE";
508 phidget_id() =
default;
509 phidget_id(ossia::phidget_handle_t);
515inline bool operator==(phidget_id lhs, phidget_id rhs)
517 return lhs.serialNumber == rhs.serialNumber && lhs.hubPort == rhs.hubPort
518 && lhs.channel == rhs.channel && lhs.isHubPort == rhs.isHubPort;
525class hash<
ossia::phidget_id>
528 std::size_t operator()(
const ossia::phidget_id&
id)
531 ossia::hash_combine(s,
id.serialNumber);
532 ossia::hash_combine(s,
id.hubPort);
533 ossia::hash_combine(s,
id.channel);
534 ossia::hash_combine(s,
id.isHubPort);