Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: iOtero on May 29, 2019, 12:12:48 PM

Title: Key pressed
Post by: iOtero on May 29, 2019, 12:12:48 PM
What code should be used in a layout to simulate that a key has been pressed at the start of a layout?, for example, the right arrow key.

Thanks
Title: Re: Key pressed
Post by: iOtero on June 13, 2019, 02:24:27 AM
Nobody knows if it can be done or not?
Title: Re: Key pressed
Post by: zpaolo11x on June 13, 2019, 03:16:50 AM
I don't think you can simulate any "key" press, instead you can throw a signal, and since these signals include directions you can use something like

Code: [Select]
fe.signal ("right")

To simulate a right button press (or right joystick movement depending on your settings)

Here is an excerpt from https://github.com/mickelson/attract/blob/master/Layouts.md regading fe.signal:

#### `fe.signal()` ####

fe.signal( signal_str )

Signal that a particular frontend action should occur.

Parameters:

    signal_str - the action to signal for. Can be one of the following strings:
        "back"
        "up"
        "down"
        "left"
        "right"
        "select"
        "prev_game"
        "next_game"
        "prev_page"
        "next_page"
        "prev_display"
        "next_display"
        "displays_menu"
        "prev_filter"
        "next_filter"
        "filters_menu"
        "toggle_layout"
        "toggle_movie"
        "toggle_mute"
        "toggle_rotate_right"
        "toggle_flip"
        "toggle_rotate_left"
        "exit"
        "exit_to_desktop"
        "screenshot"
        "configure"
        "random_game"
        "replay_last_game"
        "add_favourite"
        "prev_favourite"
        "next_favourite"
        "add_tags"
        "screen_saver"
        "prev_letter"
        "next_letter"
        "intro"
        "custom1"
        "custom2"
        "custom3"
        "custom4"
        "custom5"
        "custom6"
        "reset_window"
        "reload"
Title: Re: Key pressed
Post by: iOtero on June 14, 2019, 06:52:39 AM
Thanks, zpaolo, its runs perfectly.  :D