Jump to content
LaunchBox Community Forums

Load (4) RetroArch and Align on each corner for (4) game play?


whazzzzzup17

Recommended Posts

Anyone experienced with AutoHotkey and can load (4) separate instances of an emulator so I can play (4) players on the same game?

For example: Game Boy - Color Pokemon. It would be nice to run (4) separate emulators and play with (4) controllers. This works, but I can only do it manually by moving each window.

Link to comment
Share on other sites

Dude this would make a sweet game menu item plugin, launch multiple versions of an emulator so more than 1 person can play a game at a time.

Iv just found out by googling after iv read your post that ppsspp can play multiplayer adhoc games on the same pc. Could create a game menu plugin that launches 2 instances of ppsspp, if there is only 1 screen, split the screen. If 2 screens, 1 screen each instance of ppsspp. Controllers can be mapped per instance. Basically lan on the same pc. Would be a cool addition.

I only came here to comment on how cool this would be, Im working on other stuff and dont have the time to pursue something like  this. So yeah this is just a shit post, sorry about that. ha.

 

Link to comment
Share on other sites

2 hours ago, jayjay said:

Dude this would make a sweet game menu item plugin, launch multiple versions of an emulator so more than 1 person can play a game at a time.

Iv just found out by googling after iv read your post that ppsspp can play multiplayer adhoc games on the same pc. Could create a game menu plugin that launches 2 instances of ppsspp, if there is only 1 screen, split the screen. If 2 screens, 1 screen each instance of ppsspp. Controllers can be mapped per instance. Basically lan on the same pc. Would be a cool addition.

I only came here to comment on how cool this would be, Im working on other stuff and dont have the time to pursue something like  this. So yeah this is just a shit post, sorry about that. ha.

 

Exactly. I do the same thing with Pokemon on VisualBoyAdvance for my big screen TV. I just run the emulator 2-4 times and run the same ROM, or even other games. It's just a lot of manual work setting the windows to the right location. I have an AutoHotkey script that hides the taskbar and titlebar of each window, but it would be nice to auto align each window, whether its 2,4,6 or w/e. My kids can then play Pokemon at the same time but on their own version with their own controllers.

Link to comment
Share on other sites

This is as far as I got, I cant spend any more time on this.

Compile the script and set it up as an emulator in LB, name it 4 player retroarch or something, you'll still need to add the code to hide taskbar.

SetTitleMatchMode, 2

run, path to emulator %1%
run, path to emulator %1%
run, path to emulator %1%
run, path to emulator %1%

sleep, 3000 ;wait for all windows to open, longer sleep?

winCount = 0
height := (A_ScreenHeight/2)
width := (A_ScreenWidth/2)

WinGet, OutputVar, List , RetroArch ;replace retroarch with a word in the title window
	
Loop %OutputVar%
{
	Id:=OutputVar%A_Index%

	WinGetTitle, title, % "ahk_id " Id
	
	If (winCount == 3)
	{
		WinActivate, % "ahk_id " Id
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%
		WinMove, % "ahk_id " Id, , %width%, %height% , %width%, %height%	
		winCount++
	}
	
	If (winCount == 2)
	{
		WinActivate, % "ahk_id " Id
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%
		WinMove, % "ahk_id " Id, , %width%, 0 , %width%, %height%	
		winCount++
	}
	
	If (winCount == 1)
	{
		WinActivate, % "ahk_id " Id
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%
		WinMove, % "ahk_id " Id, , 0, %height% , %width%, %height%	
		winCount++
	}
	
	If (winCount == 0)
	{
		WinActivate, % "ahk_id " Id
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%		
		WinMove, % "ahk_id " Id, , 0, 0 , %width%, %height%
		winCount++
	}
}

If you wanted to get creative, you could have a screen pop up saying something like "each player press start" with a count down timer.  Then split the screen depending on how many people press start. Would be cool.

Edited by jayjay
Link to comment
Share on other sites

1 hour ago, jayjay said:

This is as far as I got, I cant spend any more time on this.

Compile the script and set it up as an emulator in LB, name it 4 player retroarch or something, you'll still need to add the code to hide taskbar.

If you wanted to get creative, you could have a screen pop up saying something like "each player press start" with a count down timer.  Then split the screen depending on how many people press start. Would be cool.

Thanks for the help!

I'm posting more in case someone jumps in or you have more time.

I did find an error; if you modify the run commands to (2) instead of (4) emulators, it doesn't split the screen. Instead of 1 on the left and 1 on the right, they're both on the left.

As for some code on my side to hide the taskbar, this may help.

CapsLock & t:: HideShowTaskbar(hide := !hide)	 ; Toggle taskbar show/hide
	HideShowTaskbar(action) {
	   static ABM_SETSTATE := 0xA, ABS_AUTOHIDE := 0x1, ABS_ALWAYSONTOP := 0x2
	   VarSetCapacity(APPBARDATA, size := 2*A_PtrSize + 2*4 + 16 + A_PtrSize, 0)
	   NumPut(size, APPBARDATA), NumPut(WinExist("ahk_class Shell_TrayWnd"), APPBARDATA, A_PtrSize)
	   NumPut(action ? ABS_AUTOHIDE : ABS_ALWAYSONTOP, APPBARDATA, size - A_PtrSize)
	   DllCall("Shell32\SHAppBarMessage", UInt, ABM_SETSTATE, Ptr, &APPBARDATA)
	}
	toggle :=0
return

 

Link to comment
Share on other sites

Yeah I only coded it with 4 players in mind, would need a way to tell how many players are playing or how many windows are open and adjust accordingly.

If I ever finish my current plugin this is something i'll prob pursue if no one else does. I have a few ideas. Like being able to select and launch multiple games in BB or realigning the windows when a player drops out. Dont know how well it would work though. AHK and window commands can be a pain.

  • Like 1
Link to comment
Share on other sites

2 minutes ago, jayjay said:

Yeah I only coded it with 4 players in mind, would need a way to tell how many players are playing or how many windows are open and adjust accordingly.

If I ever finish my current plugin this is something i'll prob pursue if no one else does. I have a few ideas. Like being able to select and launch multiple games in BB or realigning the windows when a player drops out. Dont know how well it would work though. AHK and window commands can be a pain.

I'm working on it now, but I'm not as experienced so I doubt I'll get far. The (4) is fine, but I it would be nice to have (2) if needed. Or even better, it would be nice to have the user selected how man from 2-6?

I also don't know how to incorporate the selection of ROM's. Hopefully the ROM location wont have to be put directly into the AutoHotkey file. We can already drag and drop within the emulator.

 

SetTitleMatchMode, 2

run, E:\arcade\emulation\VBA\VisualBoyAdvance.exe %1%
run, E:\arcade\emulation\VBA\VisualBoyAdvance.exe %1%
run, E:\arcade\emulation\VBA\VisualBoyAdvance.exe %1%
run, E:\arcade\emulation\VBA\VisualBoyAdvance.exe %1%

sleep, 1000 ;wait for all windows to open, longer sleep?

winCount = 0
height := (A_ScreenHeight/2)
width := (A_ScreenWidth/2)

WinGet, OutputVar, List , VisualBoyAdvance ;replace retroarch with a word in the title window
	
Loop %OutputVar%
{
	Id:=OutputVar%A_Index%

	WinGetTitle, title, % "ahk_id " Id
	
	If (winCount == 3)
	{
		WinActivate, % "ahk_id " Id
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%
		WinMove, % "ahk_id " Id, , %width%, %height% , %width%, %height%	
		winCount++
	}
	
	If (winCount == 2)
	{
		WinActivate, % "ahk_id " Id
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%
		WinMove, % "ahk_id " Id, , %width%, 0 , %width%, %height%	
		winCount++
	}
	
	If (winCount == 1)
	{
		WinActivate, % "ahk_id " Id
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%
		WinMove, % "ahk_id " Id, , 0, %height% , %width%, %height%	
		winCount++
	}
	
	If (winCount == 0)
	{
		WinActivate, % "ahk_id " Id
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%		
		WinMove, % "ahk_id " Id, , 0, 0 , %width%, %height%
		winCount++
	}

}

^t:: HideShowTaskbar(hide := !hide)	 ; Toggle taskbar show/hide
	HideShowTaskbar(action) {
	   static ABM_SETSTATE := 0xA, ABS_AUTOHIDE := 0x1, ABS_ALWAYSONTOP := 0x2
	   VarSetCapacity(APPBARDATA, size := 2*A_PtrSize + 2*4 + 16 + A_PtrSize, 0)
	   NumPut(size, APPBARDATA), NumPut(WinExist("ahk_class Shell_TrayWnd"), APPBARDATA, A_PtrSize)
	   NumPut(action ? ABS_AUTOHIDE : ABS_ALWAYSONTOP, APPBARDATA, size - A_PtrSize)
	   DllCall("Shell32\SHAppBarMessage", UInt, ABM_SETSTATE, Ptr, &APPBARDATA)
	}
	toggle :=0
return

 

Link to comment
Share on other sites

I'll explain like im talking to someone who doesnt know what they are doing, I mean no offence. Im just a bit crap at explaining things.

You need ahk installed to your pc.

Copy this into a txt file:

SetTitleMatchMode, 2

run, %A_ScriptDir%\VisualBoy.exe %1% ;change visualboy.exe to whatever the exe is
run, %A_ScriptDir%\VisualBoy.exe %1%
run, %A_ScriptDir%\VisualBoy.exe %1%
run, %A_ScriptDir%\VisualBoy.exe %1%

sleep, 3000 ;wait for all windows to open, longer sleep?

winCount = 0
height := (A_ScreenHeight/2)
width := (A_ScreenWidth/2)

WinGet, OutputVar, List , RetroArch ;Visual Boy Or Whatever
	
Loop %OutputVar%
{
	Id:=OutputVar%A_Index%

	WinGetTitle, title, % "ahk_id " Id
	
	If (winCount == 3)
	{
		WinActivate, % "ahk_id " Id
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%
		WinMove, % "ahk_id " Id, , %width%, %height% , %width%, %height%	
		winCount++
	}
	
	If (winCount == 2)
	{
		WinActivate, % "ahk_id " Id
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%
		WinMove, % "ahk_id " Id, , %width%, 0 , %width%, %height%	
		winCount++
	}
	
	If (winCount == 1)
	{
		WinActivate, % "ahk_id " Id
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%
		WinMove, % "ahk_id " Id, , 0, %height% , %width%, %height%	
		winCount++
	}
	
	If (winCount == 0)
	{
		WinActivate, % "ahk_id " Id
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%		
		WinMove, % "ahk_id " Id, , 0, 0 , %width%, %height%
		winCount++
	}
}

Save it and rename the file to VB.ahk or whatever, just make sure to change extension to ahk.

Move the file to the same directory as visualboy.exe

With ahk installed you can right click on VB.ahk and compile to create VB.exe

In LB set up a new emulator, set it up as if it was visual boy but give it a name that explains what it is.

and point the application path to the new VB.exe.

Right click on a game, launch with, your new VB.exe emulator.

 

You might have to disable the start up screen for the new emulator.

Link to comment
Share on other sites

21 minutes ago, jayjay said:

I'll explain like im talking to someone who doesnt know what they are doing, I mean no offence. Im just a bit crap at explaining things.

You need ahk installed to your pc.

I got all this man. I'm providing feedback on what you submitted and what I added

The one you just submitted, has a small typo. RetroArch should be changed to "Visualboy" or w/e

Here's what I have below, I am trying to adjust for if the user wants (2) emulators. I can get it to work manually. See below. The problem, is the WinCount, I think I need to create another WinCount and (2) IF statements seperatly if wincount is 1 or 2.

Also, on yours, if WinCount ==1 should be switched with If WinCount ==2 to work with (2) emulators where they open side by side, instead of top and bottom, in case the user doesn't want (4). The issue I'm stuck at is, your If statements are adding "winCount" and I don't know how to stop if only (2) emulators. I modified the screen height for == 0 and == 1 to make them work side by side on opening (2) emulators. I need to create a separate if, when the user wants (1) or (2) emulators instead of (3) or (4). And when they want (3) or (4) emulators, it needs to ignore the (2) IF's I just modified and use another version where the screen height isnt adjusted.

I also added a toggle to remove the taskbar. Not sure how to auto enable taskbar hide, but you can press CTRL + T manually

SetTitleMatchMode, 2

run, %A_ScriptDir%\VisualBoyAdvance.exe %1% ;change visualboy.exe to whatever the exe is
run, %A_ScriptDir%\VisualBoyAdvance.exe %1%
;run, %A_ScriptDir%\VisualBoyAdvance.exe %1%
;run, %A_ScriptDir%\VisualBoyAdvance.exe %1%

sleep, 1000 ;wait for all windows to open, longer sleep?

winCount = 0
height := (A_ScreenHeight/2)
width := (A_ScreenWidth/2)

WinGet, OutputVar, List , VisualBoyAdvance ;Visual Boy Or Whatever
	
Loop %OutputVar%
{
	Id:=OutputVar%A_Index%

	WinGetTitle, title, % "ahk_id " Id
	
	If (winCount == 3)
	{
		WinActivate, % "ahk_id " Id
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%
		WinMove, % "ahk_id " Id, , %width%, %height% , %width%, %height%	
		winCount++
	}
	
	If (winCount == 2)
	{
		WinActivate, % "ahk_id " Id
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%
		WinMove, % "ahk_id " Id, , 0, %height% , %width%, %height%	
		winCount++
	}
	
	If (winCount == 1)
	{
		height := (A_ScreenHeight)
		WinActivate, % "ahk_id " Id
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%
		WinMove, % "ahk_id " Id, , %width%, 0 , %width%, %height%	
		winCount++
	}
	

	If (winCount == 0)
	{
		height := (A_ScreenHeight)
		WinActivate, % "ahk_id " Id
		WinSet, Style, -0xC00000, %title%
		WinSet, Style, -0x40000, %title%		
		WinMove, % "ahk_id " Id, , 0, 0 , %width%, %height%
		winCount++
	}
}

^t:: HideShowTaskbar(hide := !hide)	 ; Toggle taskbar show/hide
	HideShowTaskbar(action) {
	   static ABM_SETSTATE := 0xA, ABS_AUTOHIDE := 0x1, ABS_ALWAYSONTOP := 0x2
	   VarSetCapacity(APPBARDATA, size := 2*A_PtrSize + 2*4 + 16 + A_PtrSize, 0)
	   NumPut(size, APPBARDATA), NumPut(WinExist("ahk_class Shell_TrayWnd"), APPBARDATA, A_PtrSize)
	   NumPut(action ? ABS_AUTOHIDE : ABS_ALWAYSONTOP, APPBARDATA, size - A_PtrSize)
	   DllCall("Shell32\SHAppBarMessage", UInt, ABM_SETSTATE, Ptr, &APPBARDATA)
	}
	toggle :=0
return

 

Edited by whazzzzzup17
Link to comment
Share on other sites

You need a way to know how many emulator instances are wanted before you hit the run emulator commands.

this

WinGet, OutputVar, List , VisualBoyAdvance

Gets the amount of visualboy windows that are open. 

this:

Loop %OutputVar%

loops through the windows.

the winCount variable is just to separate each window to apply the coordinates. at the moment it doesnt have any effect on the amount of windows the user wants.

If you just want 2 players then you can delete 2 run commands and 2 of the if statements in the loop and set up a new emulator in LB.

Or you could start the script off with a gui and have the players press buttons to register the amount of emulator instances wanted. This is to much work for me to go over. 

Link to comment
Share on other sites

Just now, jayjay said:

 

If you just want 2 players then you can delete 2 run commands and 2 of the if statements in the loop and set up a new emulator in LB.

Or you could start the script off with a gui and have the players press buttons to register the amount of emulator instances wanted. This is to much work for me to go over. 

Yes, got that. But for the first (2) instances I changed the window height so they're side by side when playing (2) emulators - see the top how I commented our instances 3 and 4.

With that said, if I do enable all (4) emulators from above, how do I ignore the screen height that I put in for the first (2) window instances.

Link to comment
Share on other sites

I'll play with it more and report back in the next day or so with some more progress.

To-Do's

  1. Adjust alignment for 2-6 emulators
  2. Allow user to select how many instances to run. 2-6
  3. Enable taskbar toggle to auto hide without pressing CTRL+T each time.
  4. Bind an button to close all emulators and renable taskbar.
  5. Selecting multiple games or selecting the same game multiple times.
  6. Re-align windows upon player removal.
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...