Currently, the emu_keypad_event function is called from the GUI thread, and it unsafely modifies internal data used by the emulator thread (not the least of which is by calling interrupt functions, which could cause any interrupt to be dropped, or worse, if a race condition occurs).
My current idea of a solution for this is to have the emu_keypad_event function only update the keymap arrays (which can be turned into arrays of atomics) and add an additional state to the cpu.abort atomic (which is capable of interrupting the CPU emulation), signaling the main emulation loop to safely process updates to the keymap ASAP.
Currently, the
emu_keypad_event
function is called from the GUI thread, and it unsafely modifies internal data used by the emulator thread (not the least of which is by calling interrupt functions, which could cause any interrupt to be dropped, or worse, if a race condition occurs).My current idea of a solution for this is to have the
emu_keypad_event
function only update the keymap arrays (which can be turned into arrays of atomics) and add an additional state to thecpu.abort
atomic (which is capable of interrupting the CPU emulation), signaling the main emulation loop to safely process updates to the keymap ASAP.