Skip to content

Commit

Permalink
wasm: fix unspecified case for check_configuration_desc
Browse files Browse the repository at this point in the history
  • Loading branch information
toyoshim committed Nov 13, 2023
1 parent 14dd810 commit 9194d14
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
20 changes: 20 additions & 0 deletions us/iona_stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,26 @@ export class IONA {
this.exports.iona_poll();
}

state() {
const digitals = this.exports.iona_get_digital_states();
const buttons = [];
for (let bit = 0x0200; bit != 0; bit >>= 1) {
buttons.push((digitals & bit) != 0);
}
const analogs = [];
for (let i = 0; i < 6; ++i) {
analogs.push(this.exports.iona_get_analog_state(i));
}
return {
up: (digitals & 0x2000) != 0,
down: (digitals & 0x1000) != 0,
left: (digitals & 0x0800) != 0,
right: (digitals & 0x0400) != 0,
buttons: buttons,
analogs: analogs,
};
}

createPseudoDeviceDescriptor(pid, vid) {
const desc = new Uint8Array(18);
desc[0] = 0x12; // bLength
Expand Down
6 changes: 5 additions & 1 deletion us/wasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ iona_usb_host_check_configuration_desc(const uint8_t* desc) {
error();
return 0;
}
return usb_host->check_configuration_desc(0, desc);
uint8_t intf = usb_host->check_configuration_desc(0, desc);
if (intf == 255) {
intf = 0;
}
return intf;
}

EMSCRIPTEN_KEEPALIVE void iona_usb_host_check_hid_report_desc(
Expand Down

0 comments on commit 9194d14

Please sign in to comment.