Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up --- Bug Reports --- Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: SOLUTION: Use one PC to start games on two or more PC's (for twin cabs etc)  (Read 3721 times)

0 Members and 1 Guest are viewing this topic.

Pstylz

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15
  • Last login:Today at 10:17:18 am
  • 4Player Arcade Racer - WIP
Hi everyone,

I thought I would share my solution to use one PC to start a game on two (or more) PC's simultaneously - the use case for this is where one master cabinet "PLAYER 1" selects the game and starts that game on 2 PC's (in my case - my twin racing cabs).

    Eliminates the need to use a frontend on each cab
    Eliminates the need for the same game to be manually started on each cab at the same time
    Stops the initial "network sync" errors with some games if they are not both started at the same time
    Eliminates confusion for players

I am using the following to achieve this:
    LaunchBox (BigBox)
    AHK - AutoHotKey
    EXE Slideshow - this was used to make an animated "<<< Select Game on P1" screen for the PLAYER 2 cab

How it works:
    There is an AHK script that runs in the background on the PLAYER 2 cab looking for a "game" script in the folder C:\AHK to run. When no game is selected from PLAYER 1 the script keeps looping.
    While PLAYER 2 cab is waiting for a game selection from PLAYER 1 cab, an animated EXE slideshow is running on PLAYER 2 cab
    When PLAYER 1 selects a game, a "game" script is copied to folder C:\AHK on the PLAYER 2 cab
    The looping script on PLAYER 2 cab finds that a "game" script is in folder C:\AHK.  It starts the game on PLAYER 2 cab, deletes the script from C:\AHK so the looping script can continue looking for game changes from PLAYER 1 cab

An extra:
    When the ESCAPE key/exit button is pressed on the PLAYER 1 cab it will send a script to the PLAYER 2 cab to exit the current playing game and open the EXE Slideshow on the PLAYER 2 cab and wait for a game selection from the PLAYER 1 cab

AN EXAMPLE: DAYTONA USA SELECTED ON PLAYER 1 CAB
Code: [Select]
#SingleInstance force

;---- COPY DAYTONA USA GAME.AHK TO PLAYER 2 CAB ----;
;---- NOTE= Y:\AHK IS THE NETWORKED DRIVE ON PLAYER 2 CAB (C:\AHK) ----;
FileCopy, C:\AHK\FilesToCopyToP2\Daytona USA\GAME.ahk, Y:\AHK

;---- START DAYTONA USA ON PLAYER 1 CAB ----;
Run, C:\AHK\Links\2P\Daytona USA.lnk, , Max

;---- WHEN ESC IS PRESSED ON PLAYER 1, CLOSE ALL GAMES ON PLAYER 1 AND SEND A CLOSE ALL GAMES SCRIPT TO PLAYER 2 ----;
ESC::
FileCopy, C:\AHK\Escape\GAME.ahk, Y:\AHK
Send !F4::
Process, Close, TeknoParrotUi.exe
Process, Close, sdaemon.exe
Process, Close, supermodel.exe
Process, Close, Daytona.exe
Process, Close, emulator_multicpu.EXE
Process, Close, parrotloader.exe
Process, Close, OpenParrotLoader64.exe
Process, Close, ParrotLoader64.exe
Process, Close, BudgieLoader.exe
Process, Close, Wmn5r.exe
Process, Close, Rally.exe
Process, Close, MK_AGP3_FINAL.exe
ExitAPP
return

PLAYER 2 - LOOKING FOR GAME LOOP SCRIPT:
Code: [Select]
;---- LOOK FOR GAME SCRIPT TO EXECUTE GAME ----;
IfExist, C:\AHK\GAME.ahk

Run GAME.ahk

Loop

Sleep, 2000
Reload

AN EXAMPLE: DAYTONA USA GAME SCRIPT THAT IS SENT TO PLAYER 2 CAB WHEN A GAME IS SELECTED ON PLAYER 1
Code: [Select]
#SingleInstance force

;---- CLOSE ALL POTENTIAL RUNNING GAMES ----;
Process, Close, TeknoParrotUi.exe
Process, Close, sdaemon.exe
Process, Close, supermodel.exe
Process, Close, Daytona.exe
Process, Close, emulator_multicpu.EXE
Process, Close, parrotloader.exe
Process, Close, OpenParrotLoader64.exe
Process, Close, ParrotLoader64.exe
Process, Close, BudgieLoader.exe
Process, Close, Wmn5r.exe
Process, Close, Rally.exe
Process, Close, MK_AGP3_FINAL.exe

;---- START DAYTONA USA ON PLAYER 2 CAB----;
Run, C:\AHK\Links\2P\Daytona USA.lnk, , Max

;---- DELETE GAME SCRIPT FROM LOOP SEARCH FOLDER ----;
FileDelete, C:\AHK\GAME.ahk

;---- IF ESC IS DETECTED CLOSE ALL POTENTIAL RUNNING GAMES ----;
ESC::
Process, Close, TeknoParrotUi.exe
Process, Close, sdaemon.exe
Process, Close, supermodel.exe
Process, Close, Daytona.exe
Process, Close, emulator_multicpu.EXE
Process, Close, parrotloader.exe
Process, Close, OpenParrotLoader64.exe
Process, Close, ParrotLoader64.exe
Process, Close, BudgieLoader.exe
Process, Close, Wmn5r.exe
Process, Close, Rally.exe
Process, Close, MK_AGP3_FINAL.exe

;---- CHECK IF EXE SLIDESHOW IS RUNNING ----;
Process, Exist, Player 2 - Waiting Screen 0.4.exe
If Not ErrorLevel ; errorlevel will = 0 if process doesn't exist
Run, C:\AHK\Player 2 - Waiting Screen 0.4.exe, , Max

ExitAPP
return

This is a pretty easy way to sync the execution of a game on multiple PC's - there's probably better ways, but hope this helps.
One draw back, is that you need to create a few scripts for every game you want to run on your cabs, this includes when you add new games. 
Because this process is only required for my racing cabs and it only has a select few games, its easy to manage and isn't an issue for me.

If anyone would like further explanation please let me know.

nugarp

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 249
  • Last login:August 04, 2022, 09:33:10 am
  • I want to build my own arcade controls!
Never did I ever imagine AHK would be used to replace socket functionality. Neat trick you have there - thanks for sharing.

If you code at all or are curious, take a look at nodejs and the socket.io library. You won't need to keep polling. It's super user friendly.

Sent from my SM-G950U using Tapatalk


Empo

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 34
  • Last login:August 03, 2022, 05:06:43 pm
  • I want to build my own arcade flux capacitors!!
Sorry for dragging up an old thread. But this is a question i have been wondering about as i want this function in my setup. Very nice use of AHK to obtain this function i must say.

But in my digging regarding this i found the PsExec: https://docs.microsoft.com/en-us/sysinternals/downloads/psexec

PsExec i think would be a better solution, anyone tried this ? (i already start my games in the twin driver setup using bat. files)

Pstylz

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15
  • Last login:Today at 10:17:18 am
  • 4Player Arcade Racer - WIP
Never did I ever imagine AHK would be used to replace socket functionality. Neat trick you have there - thanks for sharing.

If you code at all or are curious, take a look at nodejs and the socket.io library. You won't need to keep polling. It's super user friendly.

Sent from my SM-G950U using Tapatalk

Thanks for the feedback.  :cheers:
Thank you for the suggestion but unfortunately I'm not skilled enough to code (very well) - I'm just a good "tinker-er" haha.
And fortunately the polling on P2 machine barely has any impact on system resources.

Pstylz

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15
  • Last login:Today at 10:17:18 am
  • 4Player Arcade Racer - WIP
Sorry for dragging up an old thread. But this is a question i have been wondering about as i want this function in my setup. Very nice use of AHK to obtain this function i must say.

But in my digging regarding this i found the PsExec: https://docs.microsoft.com/en-us/sysinternals/downloads/psexec

PsExec i think would be a better solution, anyone tried this ? (i already start my games in the twin driver setup using bat. files)

No worries.  Hoped this helped or gave you further inspiration for other solutions.  :cheers:
I did attempt to use PsExec many moons ago, but found I had issues with it.... cant remember what now, but i think P2's controls failed to register when games were initiated with PSExec

Pstylz

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15
  • Last login:Today at 10:17:18 am
  • 4Player Arcade Racer - WIP
I've been working on a "cleaner" way to get BIGBOX/LAUNCHBOX to start up the selected game in preparation for my new project - 4 Player Arcade Racers cabinet(s)    8) >:D
In the OP above, you would need to duplicate and modify the same script for every game and compile.

I have now made a single "GameStart" script/executable that reads the "rom" title sent from BIGBOX to identify the game to start.
The GameStart script then creates an AHK file with the appropriate game title and saves it on the PLAYER 2 machine where the GAME LOOP SCRIPT running on PLAYER 2 will execute.
All that is required now is a ".lnk" of the game to be added into the "\\Arcade\AHK\Links\" folder on both player machines.
NOTE:  The game ".lnk" filename must match what is in BIGBOX   ;)


GAMESTART.EXE
Code: [Select]
#SingleInstance force

;---- EXTRACT COMMAND LINE ATTRIBUTES (GAME TITLE) FROM BIGBOX (LAUNCHBOX) ----;
GAME = %1% %2% %3% %4% %5%

;---- START LOCAL GAME (P1) ----;
Run, C:\Arcade\AHK\Links\%Game%.lnk, , Max

;---- DELETE EXISTING GAME.AHK FROM PLAYER 2 ----;
;---- NOTE -- THIS ENSURES THE "GAME START LOOP" FOLDER IS CLEAR ----;
FileDelete, C:\Arcade\AHK\Player2\Game Start Loop\GAME.ahk


;------------------------------------------------------------------------------------------;

;---- CREATE PLAYER 2 START GAME FILE AND THEN SEND TO PLAYER 2 ----;
;---- NOTE: "Y:\" DRIVE IS THE NETWORK DRIVE ON PLAYER 1 CAB OF PLAYER 2 CAB'S "C:\" DRIVE ----;
fileAppend,
(
#SingleInstance force

;---- CLOSE ANY RUNNING GAMES ON P2 BEFORE STARTING NEW GAME ----;
Process, Close, TeknoParrotUi.exe
Process, Close, sdaemon.exe
Process, Close, supermodel.exe
Process, Close, Daytona.exe
Process, Close, emulator_multicpu.EXE
Process, Close, parrotloader.exe
Process, Close, OpenParrotLoader64.exe
Process, Close, OpenParrotLoader.exe
Process, Close, ParrotLoader64.exe
Process, Close, BudgieLoader.exe
Process, Close, Wmn5r.exe
Process, Close, Rally.exe
Process, Close, MK_AGP3_FINAL.exe
Process, Close, racing.exe

;---- START GAME ON PLAYER 2 ----;
Run, C:\Arcade\AHK\Links\%GAME%.lnk, , Max

;---- DELETE GAME SCRIPT FROM GAME START LOOP SEARCH FOLDER ONCE GAME HAS STARTED ----;
FileDelete, C:\Arcade\AHK\Player2\Game Start Loop\GAME.ahk

;---- IF ESC IS PRESSED, CLOSE ALL RUNNING GAMES ON P2 ----;
;---- RUN "WAITING SCREEN" AFTER ALL GAMES CLOSED ON P2 ----;
ESC::
Process, Close, TeknoParrotUi.exe
Process, Close, sdaemon.exe
Process, Close, supermodel.exe
Process, Close, Daytona.exe
Process, Close, emulator_multicpu.EXE
Process, Close, parrotloader.exe
Process, Close, OpenParrotLoader64.exe
Process, Close, OpenParrotLoader.exe
Process, Close, ParrotLoader64.exe
Process, Close, BudgieLoader.exe
Process, Close, Wmn5r.exe
Process, Close, Rally.exe
Process, Close, MK_AGP3_FINAL.exe
Process, Close, racing.exe

;---- CHECK IF EXE "WAITING SCREEN" IS RUNNING ----;
Process, Exist, Player 2 - Waiting Screen 0.4.exe
If Not ErrorLevel ; errorlevel will = 0 if process doesn't exist
Run, C:\Arcade\AHK\Player2\Player 2 - Waiting Screen 0.4.exe, , Max

ExitAPP
return

), Y:\Arcade\AHK\Player2\Game Start Loop\GAME.ahk

;------------------------------------------------------------------------------------------;


;---- WHEN ESC IS PRESSED ON PLAYER 1, CLOSE ALL GAMES ON PLAYER 1 AND SEND A CLOSE ALL GAMES SCRIPT TO PLAYER 2 ----;
;---- START BIGBOX.EXE ON PLAYER 1 IF DOESNT EXIST ----;
ESC::
FileCopy, C:\Arcade\AHK\Escape\GAME.ahk, Y:\Arcade\AHK\Player2\Game Start Loop\
Send !F4::
Process, Close, TeknoParrotUi.exe
Process, Close, sdaemon.exe
Process, Close, supermodel.exe
Process, Close, Daytona.exe
Process, Close, emulator_multicpu.EXE
Process, Close, parrotloader.exe
Process, Close, OpenParrotLoader64.exe
Process, Close, OpenParrotLoader.exe
Process, Close, ParrotLoader64.exe
Process, Close, BudgieLoader.exe
Process, Close, Wmn5r.exe
Process, Close, Rally.exe
Process, Close, MK_AGP3_FINAL.exe
Process, Close, racing.exe
Process, Exist, bigbox.exe
If Not ErrorLevel ; errorlevel will = 0 if process doesn't exist
Run, "C:\Arcade\LaunchBox\BigBox.exe", , Max
ExitAPP
return

return

PLAYER 2 - LOOKING FOR GAME LOOP SCRIPT:
Code: [Select]
;---- LOOK FOR GAME SCRIPT TO EXECUTE GAME ----;
IfExist, C:\AHK\GAME.ahk

Run GAME.ahk

Loop

Sleep, 2000
Reload

Fursphere

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1073
  • Last login:July 25, 2022, 10:58:26 am
If you have a frontend running on Cab #2 (BigBox) will the "looking for game" script launch the game in the foreground still? 

I sort of got PSExec running doing this, but if the front end was running on cab #2, it would launch in the background, and you'd have to alt-tab to it.   That seems to be the trickiest part of this whole thing, was getting the game running on the second cabinet without losing windows 'focus'.

I thought about approaching the launchbox/bigbox developers to make this sort of thing integrated, but I decided its such a niche case, it wouldn't be worth their time.  I mean, how many people have multiple emulation cabinets, and then out of that list, how many attempt to 'link' them.  :)

I built my current two two-player cabinets with this specifically in mind, the ability to play 4 player games.   For a brief moment, I considered a 3rd for those rare six player games, but I was already pushing my limits with two full side arcade cabinets, a virtual pinball cabinet and my wife's patience.   ;D

Fursphere

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1073
  • Last login:July 25, 2022, 10:58:26 am
All that is required now is a ".lnk" of the game to be added into the "\\Arcade\AHK\Links\" folder on both player machines.
NOTE:  The game ".lnk" filename must match what is in BIGBOX   ;)


Can you give an example of the LNK file you reference here?  Its contents? 
Are you putting the specific game startup command in this file?

For example:

Host Machine:
retroarch.exe -L cores/fbneo_libretro.dll -H romname    ??

Client Machine
retroarch.exe -L cores/fbneo_libretro.dll -C hostname romname   ??

Pstylz

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15
  • Last login:Today at 10:17:18 am
  • 4Player Arcade Racer - WIP
If you have a frontend running on Cab #2 (BigBox) will the "looking for game" script launch the game in the foreground still? 

I sort of got PSExec running doing this, but if the front end was running on cab #2, it would launch in the background, and you'd have to alt-tab to it.   That seems to be the trickiest part of this whole thing, was getting the game running on the second cabinet without losing windows 'focus'.

I thought about approaching the launchbox/bigbox developers to make this sort of thing integrated, but I decided its such a niche case, it wouldn't be worth their time.  I mean, how many people have multiple emulation cabinets, and then out of that list, how many attempt to 'link' them.  :)

I built my current two two-player cabinets with this specifically in mind, the ability to play 4 player games.   For a brief moment, I considered a 3rd for those rare six player games, but I was already pushing my limits with two full side arcade cabinets, a virtual pinball cabinet and my wife's patience.   ;D

Hmmmm good question.
You could make the AHK script close BigBox on both machines when a game starts and when "ESCAPE" is pressed to exit a game it can restart BigBox on both machines.

If you wanted to run BIGBOX on both machines you could:
- run the "Looking for game" AHK script on both machines
- modify the GAMESTART script to work on Player 2 machine (changing some directory and drive references)
- modify the ESCAPE script to start BIGBOX on when exiting games for both machines

I'm happy to offer some assistance

Pstylz

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15
  • Last login:Today at 10:17:18 am
  • 4Player Arcade Racer - WIP
I built my current two two-player cabinets with this specifically in mind, the ability to play 4 player games.   For a brief moment, I considered a 3rd for those rare six player games, but I was already pushing my limits with two full side arcade cabinets, a virtual pinball cabinet and my wife's patience.   ;D

I've just started my 4P arcade racing cabinet for exactly that reason! 4 Player madness!!!!
I hear you regarding the wife's patience part haha

Pstylz

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 15
  • Last login:Today at 10:17:18 am
  • 4Player Arcade Racer - WIP
Can you give an example of the LNK file you reference here?  Its contents? 
Are you putting the specific game startup command in this file?

For example:

Host Machine:
retroarch.exe -L cores/fbneo_libretro.dll -H romname    ??

Client Machine
retroarch.exe -L cores/fbneo_libretro.dll -C hostname romname   ??

The LNK file is just a windows shortcut to start the game.
In my case, BIGBOX isn't set up with emulators. It just pushes the GAME TITLE to my GameStart script to execute.
Considering I only have a limited number of racing games for these machines, it's a manageable process.

Fursphere

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1073
  • Last login:July 25, 2022, 10:58:26 am
So I got this all working with BigBox.   

On the "Primary" cabinet, I setup a new Platform for FinalBurn Neo.   Then Setup a BATCH file (I'm an old school DOS guy...) to start RetroArch with all the required parameters and %game% argument passed from the command line.

The Batch file does two things:
-Dynamically create a batch file on the Secondary cabinet with the required parameters to launch Retroarch in CLIENT mode, then delete itself. 

-Launch RetroArch in HOST mode.
I used the basic AHK script you came up with to look for the game.bat file being created in the folder on the secondary machine, and launch it.   

This works perfectly.   Primary and Secondary both launch the game, and on the secondary it just launches right on top of BigBox, and BigBox goes dormant. 

I made the secondary FBNeo platform for two reasons:
-It has a unique romset from mame
-MAME is still a separate platform and launches games locally in 2 player mode.   FBNeo is setup strickly for 3+ player games.

The 'emulator' is just an FBNeo.bat file.    This exact concept could be used for other platforms w/ RetroArch (and various cores) to do netplay the same way.   

this is the batchfile if your curious.   I may re-write the thing using AHK, but this was just really quick.

Quote
del \\cab-b\d\ahk\game.bat
echo d: >> \\cab-b\d\ahk\game.bat
echo cd\ >> \\cab-b\d\ahk\game.bat
echo cd emulators >> \\cab-b\d\ahk\game.bat
echo cd retroarch >> \\cab-b\d\ahk\game.bat
echo start d:\emulators\retroarch\retroarch.exe -L cores/fbneo_libretro.dll -C cab-a %1 >> \\cab-b\d\ahk\game.bat
echo del d:\ahk\game.bat >> \\cab-b\d\ahk\game.bat
d:
cd\
cd emulators
cd retroarch
start retroarch.exe -L cores/fbneo_libretro.dll -H %1