Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: 8bitsdeep on March 28, 2020, 09:10:57 PM

Title: Signal handling removing key repeat
Post by: 8bitsdeep on March 28, 2020, 09:10:57 PM
Normally when you hold down an arrow key, the key repeat triggers and AM will quickly start scrolling through your list. However, my current theme scrolls sideways instead of vertically, so I handled the signals accordingly in the script to keep things intuitive for the user without having to remap controls specifically for my theme. But doing this stops key repeat from working.

Code: [Select]
fe.add_signal_handler( this, "on_signal" );
function on_signal( sig ) {
    if(sig == "left"){
        fe.list.index--;
        return true;
    }
    else if(sig == "right"){
        fe.list.index++;
        return true;
    }
    else return false;
}

Is there a way to fix this or perhaps a better way to handle a horizontal scroll input?
Title: Re: Signal handling removing key repeat
Post by: jedione on March 29, 2020, 08:03:16 AM
here you are. my friend

should work good.

Code: [Select]
function on_signal( sig )
{
switch ( sig )
{


case "up":
fe.signal( "" );
 
return true;


case "down":
fe.signal( "" );

return true


case "left":
fe.signal( "prev_game" );

return true;


case "right":
fe.signal( "next_game" );

return true;

case "select":
default:

}

return false;
}

fe.add_signal_handler(this, "on_signal");
Title: Re: Signal handling removing key repeat
Post by: 8bitsdeep on March 29, 2020, 12:00:37 PM
Perfect, thank you!