Skip to content

Commit 1be7dd7

Browse files
committed
Fixed issue with Z axis example
1 parent aa55c1b commit 1be7dd7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

examples/JoystickTest/JoystickTest.ino

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// above.
99
// 2016-05-13 Updated to use new dynamic Joystick library
1010
// that can be customized.
11+
// 2022-03-29 Updated to work with version 2.1.0 of the
12+
// Joystick library.
1113
//------------------------------------------------------------
1214

1315
#include "Joystick.h"
@@ -105,18 +107,22 @@ void testXYAxis(unsigned int currentStep)
105107

106108
void testZAxis(unsigned int currentStep)
107109
{
110+
int z;
111+
108112
if (currentStep < 128)
109113
{
110-
Joystick.setZAxis(-currentStep);
114+
z = -currentStep;
111115
}
112116
else if (currentStep < 256 + 128)
113117
{
114-
Joystick.setZAxis(currentStep - 128 - 127);
118+
z = currentStep - 128 - 127;
115119
}
116120
else if (currentStep < 256 + 128 + 127)
117121
{
118-
Joystick.setZAxis(127 - (currentStep - 383));
122+
z = 127 - (currentStep - 383);
119123
}
124+
125+
Joystick.setZAxis(z);
120126
}
121127

122128
void testHatSwitch(unsigned int currentStep)

src/Joystick.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class Joystick_
109109

110110
protected:
111111
int buildAndSet16BitValue(bool includeValue, int32_t value, int32_t valueMinimum, int32_t valueMaximum, int32_t actualMinimum, int32_t actualMaximum, uint8_t dataLocation[]);
112-
int buildAndSetAxisValue(bool includeAxis, int32_t axisValue, int32_t axisMinimum, int32_t axisMaximum, uint8_t dataLocation[];
112+
int buildAndSetAxisValue(bool includeAxis, int32_t axisValue, int32_t axisMinimum, int32_t axisMaximum, uint8_t dataLocation[]);
113113
int buildAndSetSimulationValue(bool includeValue, uint16_t value, uint16_t valueMinimum, uint16_t valueMaximum, uint8_t dataLocation[]);
114114

115115
public:

0 commit comments

Comments
 (0)