23
23
#if defined(_USING_DYNAMIC_HID)
24
24
25
25
#define JOYSTICK_REPORT_ID_INDEX 7
26
- #define JOYSTICK_AXIS_MINIMUM - 32767
27
- #define JOYSTICK_AXIS_MAXIMUM 32767
28
- #define JOYSTICK_SIMULATOR_MINIMUM - 32767
29
- #define JOYSTICK_SIMULATOR_MAXIMUM 32767
26
+ #define JOYSTICK_AXIS_MINIMUM 0
27
+ #define JOYSTICK_AXIS_MAXIMUM 65535
28
+ #define JOYSTICK_SIMULATOR_MINIMUM 0
29
+ #define JOYSTICK_SIMULATOR_MAXIMUM 65535
30
30
31
31
#define JOYSTICK_INCLUDE_X_AXIS B00000001
32
32
#define JOYSTICK_INCLUDE_Y_AXIS B00000010
@@ -293,15 +293,16 @@ Joystick_::Joystick_(
293
293
tempHidReportDescriptor[hidReportDescriptorSize++] = 0x09 ;
294
294
tempHidReportDescriptor[hidReportDescriptorSize++] = 0x01 ;
295
295
296
- // LOGICAL_MINIMUM (-32767)
297
- tempHidReportDescriptor[hidReportDescriptorSize++] = 0x16 ;
298
- tempHidReportDescriptor[hidReportDescriptorSize++] = 0x01 ;
299
- tempHidReportDescriptor[hidReportDescriptorSize++] = 0x80 ;
296
+ // LOGICAL_MINIMUM (0)
297
+ tempHidReportDescriptor[hidReportDescriptorSize++] = 0x15 ;
298
+ tempHidReportDescriptor[hidReportDescriptorSize++] = 0x00 ;
300
299
301
- // LOGICAL_MAXIMUM (+32767)
302
- tempHidReportDescriptor[hidReportDescriptorSize++] = 0x26 ;
303
- tempHidReportDescriptor[hidReportDescriptorSize++] = 0xFF ;
304
- tempHidReportDescriptor[hidReportDescriptorSize++] = 0x7F ;
300
+ // LOGICAL_MAXIMUM (65535)
301
+ tempHidReportDescriptor[hidReportDescriptorSize++] = 0x27 ;
302
+ tempHidReportDescriptor[hidReportDescriptorSize++] = 0XFF ;
303
+ tempHidReportDescriptor[hidReportDescriptorSize++] = 0XFF ;
304
+ tempHidReportDescriptor[hidReportDescriptorSize++] = 0x00 ;
305
+ tempHidReportDescriptor[hidReportDescriptorSize++] = 0x00 ;
305
306
306
307
// REPORT_SIZE (16)
307
308
tempHidReportDescriptor[hidReportDescriptorSize++] = 0x75 ;
@@ -366,15 +367,16 @@ Joystick_::Joystick_(
366
367
tempHidReportDescriptor[hidReportDescriptorSize++] = 0x05 ;
367
368
tempHidReportDescriptor[hidReportDescriptorSize++] = 0x02 ;
368
369
369
- // LOGICAL_MINIMUM (-32767)
370
- tempHidReportDescriptor[hidReportDescriptorSize++] = 0x16 ;
371
- tempHidReportDescriptor[hidReportDescriptorSize++] = 0x01 ;
372
- tempHidReportDescriptor[hidReportDescriptorSize++] = 0x80 ;
370
+ // LOGICAL_MINIMUM (0)
371
+ tempHidReportDescriptor[hidReportDescriptorSize++] = 0x15 ;
372
+ tempHidReportDescriptor[hidReportDescriptorSize++] = 0x00 ;
373
373
374
- // LOGICAL_MAXIMUM (+32767)
375
- tempHidReportDescriptor[hidReportDescriptorSize++] = 0x26 ;
376
- tempHidReportDescriptor[hidReportDescriptorSize++] = 0xFF ;
377
- tempHidReportDescriptor[hidReportDescriptorSize++] = 0x7F ;
374
+ // LOGICAL_MAXIMUM (65535)
375
+ tempHidReportDescriptor[hidReportDescriptorSize++] = 0x27 ;
376
+ tempHidReportDescriptor[hidReportDescriptorSize++] = 0XFF ;
377
+ tempHidReportDescriptor[hidReportDescriptorSize++] = 0XFF ;
378
+ tempHidReportDescriptor[hidReportDescriptorSize++] = 0x00 ;
379
+ tempHidReportDescriptor[hidReportDescriptorSize++] = 0x00 ;
378
380
379
381
// REPORT_SIZE (16)
380
382
tempHidReportDescriptor[hidReportDescriptorSize++] = 0x75 ;
@@ -517,79 +519,79 @@ void Joystick_::releaseButton(uint8_t button)
517
519
if (_autoSendState) sendState ();
518
520
}
519
521
520
- void Joystick_::setXAxis (int16_t value)
522
+ void Joystick_::setXAxis (uint16_t value)
521
523
{
522
524
_xAxis = value;
523
525
if (_autoSendState) sendState ();
524
526
}
525
- void Joystick_::setYAxis (int16_t value)
527
+ void Joystick_::setYAxis (uint16_t value)
526
528
{
527
529
_yAxis = value;
528
530
if (_autoSendState) sendState ();
529
531
}
530
- void Joystick_::setZAxis (int16_t value)
532
+ void Joystick_::setZAxis (uint16_t value)
531
533
{
532
534
_zAxis = value;
533
535
if (_autoSendState) sendState ();
534
536
}
535
537
536
- void Joystick_::setRxAxis (int16_t value)
538
+ void Joystick_::setRxAxis (uint16_t value)
537
539
{
538
540
_xAxisRotation = value;
539
541
if (_autoSendState) sendState ();
540
542
}
541
- void Joystick_::setRyAxis (int16_t value)
543
+ void Joystick_::setRyAxis (uint16_t value)
542
544
{
543
545
_yAxisRotation = value;
544
546
if (_autoSendState) sendState ();
545
547
}
546
- void Joystick_::setRzAxis (int16_t value)
548
+ void Joystick_::setRzAxis (uint16_t value)
547
549
{
548
550
_zAxisRotation = value;
549
551
if (_autoSendState) sendState ();
550
552
}
551
553
552
- void Joystick_::setRudder (int16_t value)
554
+ void Joystick_::setRudder (uint16_t value)
553
555
{
554
556
_rudder = value;
555
557
if (_autoSendState) sendState ();
556
558
}
557
- void Joystick_::setThrottle (int16_t value)
559
+ void Joystick_::setThrottle (uint16_t value)
558
560
{
559
561
_throttle = value;
560
562
if (_autoSendState) sendState ();
561
563
}
562
- void Joystick_::setAccelerator (int16_t value)
564
+ void Joystick_::setAccelerator (uint16_t value)
563
565
{
564
566
_accelerator = value;
565
567
if (_autoSendState) sendState ();
566
568
}
567
- void Joystick_::setBrake (int16_t value)
569
+ void Joystick_::setBrake (uint16_t value)
568
570
{
569
571
_brake = value;
570
572
if (_autoSendState) sendState ();
571
573
}
572
- void Joystick_::setSteering (int16_t value)
574
+ void Joystick_::setSteering (uint16_t value)
573
575
{
574
576
_steering = value;
575
577
if (_autoSendState) sendState ();
576
578
}
577
579
578
- void Joystick_::setHatSwitch (int8_t hatSwitchIndex, int16_t value)
580
+ void Joystick_::setHatSwitch (int8_t hatSwitchIndex, uint16_t value)
579
581
{
580
582
if (hatSwitchIndex >= _hatSwitchCount) return ;
581
583
582
584
_hatSwitchValues[hatSwitchIndex] = value;
583
585
if (_autoSendState) sendState ();
584
586
}
585
587
586
- int Joystick_::buildAndSet16BitValue (bool includeValue, int16_t value, int16_t valueMinimum, int16_t valueMaximum, int16_t actualMinimum, int16_t actualMaximum, uint8_t dataLocation[])
588
+ int Joystick_::buildAndSet16BitValue (bool includeValue, uint16_t value, uint16_t valueMinimum, uint16_t valueMaximum, uint16_t actualMinimum, uint16_t actualMaximum, uint8_t dataLocation[])
587
589
{
588
- int16_t convertedValue;
590
+ uint16_t convertedValue;
589
591
uint8_t highByte;
590
592
uint8_t lowByte;
591
- int16_t realMinimum = min (valueMinimum, valueMaximum);
592
- int16_t realMaximum = max (valueMinimum, valueMaximum);
593
+ uint16_t realMinimum = min (valueMinimum, valueMaximum);
594
+ uint16_t realMaximum = max (valueMinimum, valueMaximum);
593
595
594
596
if (includeValue == false ) return 0 ;
595
597
@@ -616,12 +618,12 @@ int Joystick_::buildAndSet16BitValue(bool includeValue, int16_t value, int16_t v
616
618
return 2 ;
617
619
}
618
620
619
- int Joystick_::buildAndSetAxisValue (bool includeAxis, int16_t axisValue, int16_t axisMinimum, int16_t axisMaximum, uint8_t dataLocation[])
621
+ int Joystick_::buildAndSetAxisValue (bool includeAxis, uint16_t axisValue, uint16_t axisMinimum, uint16_t axisMaximum, uint8_t dataLocation[])
620
622
{
621
623
return buildAndSet16BitValue (includeAxis, axisValue, axisMinimum, axisMaximum, JOYSTICK_AXIS_MINIMUM, JOYSTICK_AXIS_MAXIMUM, dataLocation);
622
624
}
623
625
624
- int Joystick_::buildAndSetSimulationValue (bool includeValue, int16_t value, int16_t valueMinimum, int16_t valueMaximum, uint8_t dataLocation[])
626
+ int Joystick_::buildAndSetSimulationValue (bool includeValue, uint16_t value, uint16_t valueMinimum, uint16_t valueMaximum, uint8_t dataLocation[])
625
627
{
626
628
return buildAndSet16BitValue (includeValue, value, valueMinimum, valueMaximum, JOYSTICK_SIMULATOR_MINIMUM, JOYSTICK_SIMULATOR_MAXIMUM, dataLocation);
627
629
}
0 commit comments