Skip to content

Commit

Permalink
fix: joystick bug
Browse files Browse the repository at this point in the history
  • Loading branch information
nytamin committed Apr 7, 2021
1 parent df7d9b6 commit 84d2150
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/xkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,14 @@ export class XKeys extends EventEmitter {
})
newAnalogStates.joystick.forEach((newValue, index) => {
const oldValue = this._analogStates.joystick[index]
if (oldValue.x !== newValue.x || oldValue.y !== newValue.y || oldValue.z !== newValue.z) {
if (!oldValue) {
const emitValue: JoystickValueEmit = {
...newValue,
// Calculate deltaZ, since that is not trivial to do:
deltaZ: 0,
}
this.emit('joystick', index, emitValue, eventMetadata)
} else if (oldValue.x !== newValue.x || oldValue.y !== newValue.y || oldValue.z !== newValue.z) {
const emitValue: JoystickValueEmit = {
...newValue,
// Calculate deltaZ, since that is not trivial to do:
Expand Down

0 comments on commit 84d2150

Please sign in to comment.