Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: wrybread on September 24, 2020, 03:32:14 PM

Title: Joystick button to choose and launch a random game?
Post by: wrybread on September 24, 2020, 03:32:14 PM
I'm giving one of my cabinets some update love, and trying to set a button to choose and launch a random game.

When I last worked on this I saw that AM can choose a random game, but still requires the user to confirm the choice by pressing the "go" button.

Can anyone think of some clever way to map a button to choose and launch a game with a single press?

Ideally it would be a joystick button, since all my buttons use a joystick encoder.

I had a way to do this before using a Python script, and if all else fails I can use that, but it's a bit kludgey since it needs to close Attract Mode and then relaunch AM when the game ends.
Title: Re: Joystick button to choose and launch a random game?
Post by: keilmillerjr on September 26, 2020, 05:57:21 AM
Look at layouts.md. Create a plugin. Create a signal handler that polls for your input and issues random_game signal.
Title: Re: Joystick button to choose and launch a random game?
Post by: wrybread on September 26, 2020, 10:24:47 AM
The problem is that the random game signal chooses a game in AM (highlights it in the rom list) but doesn't actually start the game. Last I checked at least, hopefully I'm wrong.

That would be ok if the feature was just for me, but it's a bit complicated for newbies to my cabinet. Much much much cleaner to just press a button and have a random game start.

And I'm on Linux so can't use Auto Hot Key.
Title: Re: Joystick button to choose and launch a random game?
Post by: keilmillerjr on September 26, 2020, 07:42:59 PM
You don't need autohotkey. I'm on Linux too! :) Send random_game signal and then select signal. Try to work with a plug-in and post here. I'll help you along the way.
Title: Re: Joystick button to choose and launch a random game?
Post by: wrybread on September 26, 2020, 11:08:14 PM
Would a plug-in let me send those two signals with a single button press?

Title: Re: Joystick button to choose and launch a random game?
Post by: rand0m on November 02, 2020, 07:08:46 PM
try this >


Code: [Select]
function random_press(sig)
{
if (sig == "random_game")
{
fe.signal("random_game");
fe.signal("select");
    }
  return false;
}

fe.add_signal_handler( "random_press" );
Title: Re: Joystick button to choose and launch a random game?
Post by: wrybread on November 04, 2020, 03:51:28 PM
Thanks again rand0m. For anyone stumbling on this thread, I posted the working plugin here:

http://forum.attractmode.org/index.php?topic=3752.0