You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
835 B
JavaScript
36 lines
835 B
JavaScript
class Config {
|
|
constructor(
|
|
simulator_class,
|
|
{ button_to_original_keycode, button_to_simulated_event_name }
|
|
) {
|
|
this.button_to_original_keycode = button_to_original_keycode;
|
|
this.button_to_simulated_event_name = button_to_simulated_event_name;
|
|
|
|
this.original_keycodes_to_button = {};
|
|
this.simulator_class = simulator_class;
|
|
|
|
for (let button in this.button_to_original_keycode) {
|
|
this.original_keycodes_to_button[
|
|
this.button_to_original_keycode[button]
|
|
] = button;
|
|
}
|
|
}
|
|
|
|
start(wiimote) {
|
|
this.simulator = new this.simulator_class();
|
|
wiimote.on("input", event => {
|
|
if (event.key_code == 0) {
|
|
return;
|
|
}
|
|
this.simulator.simulateEvent({
|
|
key_name: this.button_to_simulated_event_name[
|
|
event.button_name
|
|
],
|
|
direction: event.direction,
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
module.exports = Config;
|