Checkpoint

master
Kuba Orlik 5 years ago
parent 6cdfebca23
commit 36af27e260

2
.gitignore vendored

@ -1 +1,3 @@
node_modules node_modules
find-ffmax-bit

@ -23,11 +23,11 @@ class ClassicController extends WiiDevice {
ZR: 57, ZR: 57,
R: 55, R: 55,
ZL: 56, ZL: 56,
L: 54, L: 54
}); });
this.configs = { this.configs = {
"Xbox360 controller": new Config(XboxPadSimulator, { "Xbox360 controller - literal": new Config(XboxPadSimulator, {
button_to_original_keycode: this.buttons, button_to_original_keycode: this.buttons,
button_to_simulated_event_name: { button_to_simulated_event_name: {
A: "BTN_A", A: "BTN_A",
@ -44,8 +44,8 @@ class ClassicController extends WiiDevice {
R: "BTN_TR", R: "BTN_TR",
L: "BTN_TL", L: "BTN_TL",
ZL: "BTN_TL2", ZL: "BTN_TL2",
ZR: "BTN_TR2", ZR: "BTN_TR2"
}, }
}), }),
"Xbox360 controller - swap DPAD X/Y (starwhal)": new Config( "Xbox360 controller - swap DPAD X/Y (starwhal)": new Config(
XboxPadSimulator, XboxPadSimulator,
@ -66,8 +66,8 @@ class ClassicController extends WiiDevice {
R: "BTN_TR", R: "BTN_TR",
L: "BTN_TL", L: "BTN_TL",
ZL: "BTN_TL2", ZL: "BTN_TL2",
ZR: "BTN_TR2", ZR: "BTN_TR2"
}, }
} }
), ),
logger: new LoggerConfig(), logger: new LoggerConfig(),
@ -88,9 +88,9 @@ class ClassicController extends WiiDevice {
ZR: "KEY_Z", ZR: "KEY_Z",
R: "KEY_R", R: "KEY_R",
ZL: "KEY_Q", ZL: "KEY_Q",
L: "KEY_L", L: "KEY_L"
}, }
}), })
}; };
} }
} }

@ -58,7 +58,7 @@ class WiiDevice extends EventEmitter {
this.cat = spawn("cat", [this.handler_file]); this.cat = spawn("cat", [this.handler_file]);
this.stream = this.cat.stdout; this.stream = this.cat.stdout;
this.pressed_buttons_count = 0; this.pressed_buttons_count = 0;
this.stream.on("data", buf => { this.stream.on("data", (buf) => {
while (buf.length) { while (buf.length) {
let slice = buf.slice(0, WIIMOTE_EVENT_BYTESIZE); let slice = buf.slice(0, WIIMOTE_EVENT_BYTESIZE);
this.emit("input", new WiiDeviceEvent(slice, this)); this.emit("input", new WiiDeviceEvent(slice, this));
@ -82,7 +82,7 @@ class WiiDevice extends EventEmitter {
process.exit(13); process.exit(13);
} }
const stream = fs.createReadStream("any", { fd: handler_file_fd }); const stream = fs.createReadStream("any", { fd: handler_file_fd });
stream.on("data", buf => { stream.on("data", (buf) => {
while (buf.length) { while (buf.length) {
let slice = buf.slice(0, WIIMOTE_EVENT_BYTESIZE); let slice = buf.slice(0, WIIMOTE_EVENT_BYTESIZE);
this.emit("input", new WiiDeviceEvent(slice, this)); this.emit("input", new WiiDeviceEvent(slice, this));
@ -96,9 +96,11 @@ class WiiDevice extends EventEmitter {
} }
get_handler_file(handlers) { get_handler_file(handlers) {
return `/dev/input/${ const ret = `/dev/input/${
handlers.filter(handler => handler.startsWith("event"))[0] handlers.filter((handler) => handler.startsWith("event"))[0]
}`; }`;
console.log(ret);
return ret;
} }
setConfig(config_key) { setConfig(config_key) {

@ -42,16 +42,16 @@ class Wiimote extends WiiDevice {
"Xbox360 controller - Towerfall": new Config(XboxPadSimulator, { "Xbox360 controller - Towerfall": new Config(XboxPadSimulator, {
button_to_original_keycode: this.buttons, button_to_original_keycode: this.buttons,
button_to_simulated_event_name: { button_to_simulated_event_name: {
TWO: "BTN_A", TWO: "BTN_A", //jest dobrze - skok
ONE: "BTN_B", ONE: "BTN_B", // jest dobrze - strzał
B: "BTN_Y", B: "BTN_Y", // jest dobrze - dash
A: "BTN_TR", A: "BTN_TR", // jest dobrze - zmiana kolejności strzał
UP: "BTN_DPAD_LEFT", UP: "BTN_DPAD_LEFT", // jest dobrze
DOWN: "BTN_DPAD_RIGHT", DOWN: "BTN_DPAD_RIGHT", // jest dobrze
LEFT: "BTN_DPAD_DOWN", LEFT: "BTN_DPAD_DOWN", // jest dobrze
RIGHT: "BTN_DPAD_UP", RIGHT: "BTN_DPAD_UP", // jest dobrze
PLUS: "BTN_START", PLUS: "BTN_START", // jest dobrze
MINUS: "BTN_A", MINUS: "BTN_SELECT", // jest dobrze - eksplodowanie zdalnych strzał
HOME: "BTN_MODE" HOME: "BTN_MODE"
} }
}), }),

Loading…
Cancel
Save