Skip to content

keypad_add_key not working with "easy way of running the emulator" #5

Description

When running the emulator in the window, I am not able to interact with it with the "keypad_add_key" and "keypad_rm_key", but the "touch_set_pos" seems to work as intended. When querying the keys (keypad_get()) it seems to be registering the "keypad_add_key" but the game does not seem to progress according to the keys I press. The script seems to work fine if it is headless (without the window it seems to register them) and it registers keys fine when pressing them on the keyboard during gameplay (in the window). Could you help?

from desmume.emulator import DeSmuME
from desmume.controls import keymask, Keys

emu = DeSmuME()
emu.open('D:\\Dropbox\\Speed Run\\DeSmuME 9.11\\Roms\\ROMs\\NA\\0561 - Harvest Moon DS (U)(Legacy).nds')

window = emu.create_sdl_window()

frame = 0
while not window.has_quit():

    frame += 1

    if frame == 405:
        emu.input.touch_set_pos(100, 100)

    if frame == 406:
        emu.input.touch_release()

    if frame == 405+150:
        emu.input.touch_set_pos(100, 100)

    if frame == 406+150:
        emu.input.touch_release()    

    if frame == 1500:
        a_keymask = keymask(Keys.KEY_A)
        emu.input.keypad_add_key(a_keymask)
        print("Press A")

    if frame == 1502:
        a_keymask = keymask(Keys.KEY_A)
        emu.input.keypad_rm_key(a_keymask)

    window.process_input()
    emu.cycle()
    window.draw()

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions