Interface - Keyboard Input Broken
I've been messing around with the Interface version of desmume, and I've run into an issue with keyboard input not being handled properly. Less than half of the controls were actually registering, and most of those were triggering the wrong actions.
I started looking into the code, and I think I tracked the main issue down to this memcpy, which is copying from a u32[] to a u16[]. My best guess is that this was introduced with commit 101fa1e, where the keyboard_cfg array was left as a u16[] despite everything else related being changed to u32[]. Simply changing this type and the type of lookup_key() in my local build fixed most of the issue.
However, there was still an issue with having Right Shift as Select, because this case prevents a SDLK_RSHIFT press from considered as an input to the game. Removing the break from this case seems to resolve this issue, but might have other consequences I'm unaware of.
I do not have the means to test if there are similar issues for joypad input, though a brief look at the code makes me think there shouldn't be.
I should also mention I have been working on Windows 10 and WSL2 (testing in both), but I can't see any reason why that would cause this; it doesn't seem like a platform-dependent issue. Similarly, I was testing whether input worked using a Pokemon Platinum ROM, which I also don't think should have had an effect on the behaviour.
- shift key handling like that is usually meant to implement hotkeys. Just fix it so that it creates the input events, too. If shift-based hotkeys and game input bound to shift conflict, then that's the fault of whoever picked shift key to be game input
- why does "interface" version of desmume even have anything to do with KEYS? the interface version is meant to be controlled by another program. if the method of "control" is sending keys, then change the default bindings so they don't conflict -- the actual keys used shouldnt matter as long as there's some way for the other program to unambiguously communicate the intended actions without bugs
For the first, I think that's what I've done by removing the break from that case, so that makes sense.
For the second, I want to read out memory values from the emulated game while it is otherwise used by a player (mostly) as normal, which means they should be able to use the normal keyboard inputs to control it. Unless I'm missing something, this reading of memory is only possible with the interface version.
- you should be doing this with lua scripts instead
- you can achieve the same thing in principle by modifying desmume to create a shared memory object for the arm9 memory (MAIN_MEM on MMU_struct). I'd accept a PR that did that.. maybe. Maybe it would be better to create shared memory for the entire MMU_struct. It should probably be #ifdef'd
- you might could do it by scripting "cheat engine" too, I dont know for sure if it's scriptable. in this case it would be best if you had desmume print the address range of each interesting resource when the game boots, which is a PR we'd certainly accept
That's fair enough, I'll look into using lua scripts then.
Having a look at what else uses ctrlssdl.h I think the main issue I found (with the mismatched types) might affect the posix CLI frontend as well? Since it uses load_default_config, which is where the weird memcpy is, so that might be worth looking into?
seems like you know what's wrong with the memcpy, please make a PR
Have made a PR: #539
i guess this got fixed huh