Trigger key press Virtual keyboard button?

Issue #29 resolved
Former user created an issue

Here code I found in source (file: fceux-1dca6bb7.js) registerKeyEventCallback

->HEAP32[JSEvents.keyEvent + 156 >> 2] = e.keyCode

How can I trigger key press (like vitural keyboard button)?

Thank you.

Comments (7)

  1. Valtteri Heikkilä repo owner

    Do you intend to trigger joypad button presses (and perhaps other peripherals like Zapper)?

    There’s no js API function (to WebAssembly/C++ code) to do this right now. The API is defined in SConstruct file. Look for exportsList:

      exportsList = [
        'main',
        'FCEM_OnSaveGameInterval',
        'FCEM_SetController',
        'FCEM_BindKey',
        'FCEM_BindGamepad',
        'FCEM_SilenceSound'
      ]
    

  2. Tuấn Ngô

    Thanks for responded.

    I wanna trigger with virtual pad for smart phone on screen, I try callback events key for instead but not good. 🙂

    Has this project ended and can continue?

  3. Matthew Walker

    FYI - you can simulate a keypress through the window:

    window.dispatchEvent(new KeyboardEvent('keydown',{'keyCode':13}));
    

    I’ve confirmed that this indeed does work on mobile devices.

  4. Valtteri Heikkilä repo owner

    Update, I’ve added functions setControllerBits() and triggerZapper() in em-fceux. Use these in your app to set the controllers/Zapper based on whatever input method you use, virtual gamepad etc. (See API.md for all the API functions.)

  5. Log in to comment