|
|
@ -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) {
|
|
|
|