Skip to content

Commit 7757c46

Browse files
committed
fix(analog-joystick): output inverted
currently we output -1 (GND) for top / left positions, while the physical part outputs -1 (GND) for bottom / right positions. So let's fix that!
1 parent 6ef9f22 commit 7757c46

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/analog-joystick-element.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export class AnalogJoystickElement extends LitElement {
173173
x="1"
174174
height="10"
175175
width="7"
176-
@mousedown=${() => this.mousedown(-1, 0)}
176+
@mousedown=${() => this.mousedown(1, 0)}
177177
@mouseup=${() => this.mouseup(true, false)}
178178
/>
179179
<path d="m 7.022,11.459 -3.202,2.497 3.202,2.497" />
@@ -184,7 +184,7 @@ export class AnalogJoystickElement extends LitElement {
184184
x="7.9"
185185
height="7"
186186
width="10"
187-
@mousedown=${() => this.mousedown(0, -1)}
187+
@mousedown=${() => this.mousedown(0, 1)}
188188
@mouseup=${() => this.mouseup(false, true)}
189189
/>
190190
<path d="m 16.615,7.095 -2.497,-3.202 -2.497,3.202" />
@@ -195,7 +195,7 @@ export class AnalogJoystickElement extends LitElement {
195195
x="18"
196196
height="10"
197197
width="7"
198-
@mousedown=${() => this.mousedown(1, 0)}
198+
@mousedown=${() => this.mousedown(-1, 0)}
199199
@mouseup=${() => this.mouseup(true, false)}
200200
/>
201201
<path d="m 19.980,16.101 3.202,-2.497 -3.202,-2.497" />
@@ -206,7 +206,7 @@ export class AnalogJoystickElement extends LitElement {
206206
x="7.9"
207207
height="7"
208208
width="10"
209-
@mousedown=${() => this.mousedown(0, 1)}
209+
@mousedown=${() => this.mousedown(0, -1)}
210210
@mouseup=${() => this.mouseup(false, true)}
211211
/>
212212
<path d="m 11.620,20.112 2.497,3.202 2.497,-3.202" />
@@ -233,19 +233,19 @@ export class AnalogJoystickElement extends LitElement {
233233
private keydown(e: KeyboardEvent) {
234234
switch (e.key) {
235235
case 'ArrowUp':
236-
this.yValue = -1;
236+
this.yValue = 1;
237237
this.valueChanged();
238238
break;
239239
case 'ArrowDown':
240-
this.yValue = 1;
240+
this.yValue = -1;
241241
this.valueChanged();
242242
break;
243243
case 'ArrowLeft':
244-
this.xValue = -1;
244+
this.xValue = 1;
245245
this.valueChanged();
246246
break;
247247
case 'ArrowRight':
248-
this.xValue = 1;
248+
this.xValue = -1;
249249
this.valueChanged();
250250
break;
251251
}

0 commit comments

Comments
 (0)