Skip to content

Commit e6ed231

Browse files
fixing mapping
1 parent 49b9aba commit e6ed231

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

gamepad.js

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -230,24 +230,25 @@ export class Gamepad{
230230
this.render_live_view();
231231
}
232232
}
233-
if((Object.keys(this.gamepad_interface).every((key) => key in this.control_map && this.control_map[key].index !== -1))){
234-
const output = {}
235-
for(const control in this.control_map){
236-
const details = this.control_map[control];
237-
const raw_value = gamepad[details.type === 'axis' ? 'axes' : 'buttons'][details.index];
238-
if(details.type === 'axis'){
239-
const value = (raw_value - details.base);
240-
const value_clipped = Math.max(-1, Math.min(1, value));
241-
const value_inverted = details.invert ? -value_clipped : value_clipped;
242-
const value_transformed = this.expo_curve(value_inverted, this.expo_sliders[control].value);
243-
output[control] = value_transformed;
244-
this.callbacks[control](value_inverted);
245-
}
246-
else{
247-
output[control] = raw_value.pressed;
248-
this.callbacks[control](raw_value.pressed);
249-
}
233+
const output = {}
234+
for(const control in this.control_map){
235+
const details = this.control_map[control];
236+
if(details.index === -1) continue;
237+
const raw_value = gamepad[details.type === 'axis' ? 'axes' : 'buttons'][details.index];
238+
if(details.type === 'axis'){
239+
const value = (raw_value - details.base);
240+
const value_clipped = Math.max(-1, Math.min(1, value));
241+
const value_inverted = details.invert ? -value_clipped : value_clipped;
242+
const value_transformed = this.expo_curve(value_inverted, this.expo_sliders[control].value);
243+
output[control] = value_transformed;
244+
this.callbacks[control](value_inverted);
250245
}
246+
else{
247+
output[control] = raw_value.pressed;
248+
this.callbacks[control](raw_value.pressed);
249+
}
250+
}
251+
if((Object.keys(this.gamepad_interface).every((key) => key in output && this.control_map[key].index !== -1))){
251252
for(const listener of this.listeners){
252253
listener(output);
253254
}

0 commit comments

Comments
 (0)