Author Topic: Joystick button to choose and launch a random game?  (Read 3732 times)

wrybread

  • Sr. Member
  • ****
  • Posts: 100
    • View Profile
Joystick button to choose and launch a random game?
« 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.
« Last Edit: September 24, 2020, 04:02:16 PM by wrybread »

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Joystick button to choose and launch a random game?
« Reply #1 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.

wrybread

  • Sr. Member
  • ****
  • Posts: 100
    • View Profile
Re: Joystick button to choose and launch a random game?
« Reply #2 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.
« Last Edit: September 26, 2020, 12:09:00 PM by wrybread »

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Joystick button to choose and launch a random game?
« Reply #3 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.

wrybread

  • Sr. Member
  • ****
  • Posts: 100
    • View Profile
Re: Joystick button to choose and launch a random game?
« Reply #4 on: September 26, 2020, 11:08:14 PM »
Would a plug-in let me send those two signals with a single button press?


rand0m

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
Re: Joystick button to choose and launch a random game?
« Reply #5 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" );

wrybread

  • Sr. Member
  • ****
  • Posts: 100
    • View Profile
Re: Joystick button to choose and launch a random game?
« Reply #6 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