Skip to content

Commit

Permalink
Fixed recognition of input controls passed from the command line.
Browse files Browse the repository at this point in the history
  • Loading branch information
punesemu committed Feb 17, 2024
1 parent b464c23 commit be0c260
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/core/jstick.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,13 @@ void js_jdev_update(_js *js, BYTE enable_decode, BYTE port_index) {
js->jdev = &jstick.jdd.devices[i];
js->inited = TRUE;
if (enable_decode) {
memcpy(p->input[JOYSTICK], JSJDEV->stdctrl, js_jdev_sizeof_stdctrl());
for (size_t btn = 0; btn < MAX_STD_PAD_BUTTONS ; btn++) {
if (js->stdctrl_from_cmdline[btn]) {
JSJDEV->stdctrl[btn] = js->stdctrl_from_cmdline[btn];
js->stdctrl_from_cmdline[btn] = 0;
}
p->input[JOYSTICK][btn] = JSJDEV->stdctrl[btn];
}
js->input_decode_event = pf->input_decode_event;
}
break;
Expand Down
1 change: 1 addition & 0 deletions src/core/jstick.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ typedef struct _js {
BYTE inited;
thread_mutex_t lock;
_input_guid guid;
DBWORD stdctrl_from_cmdline[MAX_STD_PAD_BUTTONS];
void *jdev;
BYTE (*input_decode_event)(BYTE mode, BYTE autorepeat, DBWORD event, BYTE type, _port *prt);
} _js;
Expand Down
1 change: 1 addition & 0 deletions src/core/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ int main(int argc, char **argv) {
memset(&chrrom, 0x00, sizeof(chrrom));
memset(&wram, 0x00, sizeof(wram));
memset(&miscrom, 0x00, sizeof(miscrom));
memset(&jsp, 0x00, sizeof(jsp));

info.number_of_nes = 1;

Expand Down
2 changes: 1 addition & 1 deletion src/gui/cmd_line.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ BYTE cmd_line_parse(int argc, uTCHAR **argv) {
port[range[r].port].input[KEYBOARD][i - range[r].start] =
settings_inp_wr_port((void *)&value, i, KEYBOARD);
} else if (type == "j") {
port[range[r].port].input[JOYSTICK][i - range[r].start] =
jsp[range[r].port].stdctrl_from_cmdline[i - range[r].start] =
settings_inp_wr_port((void *)&value, i, JOYSTICK);
}
}
Expand Down

0 comments on commit be0c260

Please sign in to comment.