Jump to content

All my products and services are free. All my costs are met by donations I receive from my users. If you enjoy using any of my products, please donate to support me. Thank you for your support. Tom Speirs

Patreon

[RESOLVED] Support for Pinball FX2


Loadedweapon

Recommended Posts

Update on vertically flipping the DMD image for use in p2k cabinets:

Swapped out the separate screen-capture-recorder device for ffmpeg's built-in gdigrab device. Performs as well as screen-capture-recorder for what I need desktop capture for. Now one distribution does it all. No need for Java or for registry entries, so it is a simpler solution.

Compared to the previous script, I'm just swapping out the line - run, ffmpeg... instruction.

You would still need a way to precisely size the capture area. As every cabinet configuration is different, you would need AutoHotkey to execute a modified script. The AutoHotkey distribution includes AutoIt3 Window Spy which might help with the process of fine-tuning size and location of the playback window.

#NoEnv
#SingleInstance force
#WinActivateForce
SetTitleMatchMode 3
DetectHiddenWindows On
RegRead, SteamDirPath, HKCU, Software\Valve\Steam, SteamPath
Run, "%SteamDirPath%\Steam.exe" -applaunch 226980,,UseErrorLevel
Process, wait, Pinball FX2.exe
Table = %1% ;Variable from PinballX
Sleep, 11000
Send {Enter Down}, Send {Enter Up}
Sleep, 20
Send {Enter Down}, Send {Enter Up}
Sleep, 500
;Starting position on launch is Zen-Football
Send {Up Down}, Send {Up Up}
Sleep, 20
Loop, 4
{
Send {Left Down}, Send {Left Up}
Sleep, 20
}
array1 := ["TheWalkingDead", "SW-HS", "SW-D", "SW-ANH", "SW-MOTF", "Zen-SWROTJ", "Zen-SWSA"]
array2 := ["Zen-SWDV", "Zen-SWESB", "Zen-SWCW", "Zen-SWBF", "Zen-Football", "Guardians", "Deadpool"]
array3 := ["Zen-DStrange", "Zen-CaptAmer", "Zen-FFour", "Zen-Civil", "Zen-Avengers", "Zen-FearItself", "Zen-InfinityGauntlet"]
array4 := ["Zen-Hulk", "Zen-Thor", "Zen-MoonKnight", "Zen-GhostRider", "Zen-XMen", "Zen-Blade", "Zen-IronMan"]
array5 := ["Zen-SpiderMan", "Zen-Wolverine", "PlantsVsZombies", "Zen-MSplosion", "Zen-EarthD", "Zen-Mars", "Zen-Excal"]
array6 := ["Zen-Para", "Zen-Epic", "Zen-Secrets", "Zen-Biolab", "Zen-Pasha", "Zen-Rome", "Zen-Shaman"]
array7 := ["Zen-Tesla", "Zen-ElDorado", "Zen-V12", "Zen_Sorc", "locked", "locked", "locked"]
arrayf := ["Zen-Football-ZenFC", "Zen-Football-ArsFC", "Zen-Football-LivFC", "Zen-Football-FCBar", "Zen-Football-RealM", "Zen-Football-ACMil", "Zen-Football-ASRom", "Zen-Football-Juven"]
row_index := 0
col_index := 0
table_found := 0
selected_table = %table%
current_table = "locked"
l_table = "locked"
l_row_index := 0
l_col_index := 0
f_table = "locked"
f_row_index := 0
f_col_index := 0
Loop, 7
{
main_loop = %A_Index%
Loop, 7
{
current_table = % array%main_loop%[A_Index]
IfInString, selected_table, %current_table%
{
col_index := A_Index - 1
row_index := main_loop - 1
table_found = 1
;MsgBox, Found table: %current_table% Selected: %selected_table% row: %row_index% col: %col_index%
break
}
}
if( table_found = 1 )
break
}
if( table_found == 1 )
{
; Move past main menus
;Sleep, 11000
;Send {Enter Down}, Send {Enter Up}
;Sleep, 20
;Send {Enter Down}, Send {Enter Up}
;Sleep, 500
; Move down the number of rows
Loop, %row_index%
{
Send {Down Down}, Send {Down Up}
Sleep, 20
}
; Move over the number of columns
Loop, %col_index%
{
Send {Right Down}, Send {Right Up}
Sleep, 20
}
; Select the table
Send {Enter Down}, Send {Enter Up}
Sleep, 1000
if (row_index=1 AND col_index=4) ; Super League Football Sub-menu
{
Send {Up Down}, Send {Up Up}
Sleep, 20
Send {Enter Down}, Send {Enter Up}
Sleep, 500
FileReadLine, last_f_table, %A_WorkingDir%\FX2LastFootballPlayed.txt, 1
Loop % arrayf.MaxIndex()
{
l_table = % arrayf[A_Index]
if( "X" l_table = "X" last_f_table )
{
l_col_index := Mod((A_Index - 1), 3)
l_row_index := Floor((A_Index - 1) / 3)
break
}
}
; Return cursor to position 1
; Move up the number of rows
Loop, %l_row_index%
{
Send {Up Down}, Send {Up Up}
Sleep, 20
}
; Move over the number of columns
Loop, %l_col_index%
{
Send {Left Down}, Send {Left Up}
Sleep, 20
}
Loop % arrayf.MaxIndex()
{
f_table = % arrayf[A_Index]
if( "X" f_table = "X" selected_table )
{
f_col_index := Mod((A_Index - 1), 3)
f_row_index := Floor((A_Index - 1) / 3)
break
}
}
; Move down the number of rows
Loop, %f_row_index%
{
Send {Down Down}, Send {Down Up}
Sleep, 20
}
; Move over the number of columns
Loop, %f_col_index%
{
Send {Right Down}, Send {Right Up}
Sleep, 20
}
Send {Enter Down}, Send {Enter Up}
Sleep, 1000
Send {Down Down}, Send {Down Up}
Sleep, 20
Send {Enter Down}, Send {Enter Up}
FileDelete, %A_WorkingDir%\FX2LastFootballPlayed.txt
FileAppend, %selected_table%, %A_WorkingDir%\FX2LastFootballPlayed.txt
}
else ; All other tables - launch single player
{
Send {Enter Down}, Send {Enter Up}
}
}
; Mirror and flip DMD for P2k
run, ffmpeg -rtbufsize 1500M -f gdigrab -framerate 120 -offset_x 3853 -offset_y 0 -video_size 732x212 -i desktop -vf "vflip" -vcodec mpeg4 -qscale:v 1 -f mpegts -threads 8 udp://localhost:1234,,Hide UseErrorLevel
Sleep, 1000
run, ffplay -an -sn -i -fflags nobuffer udp://localhost:1234?listen,,Hide UseErrorLevel
checkprocessagain:
Process, wait, ffplay.exe, 5.5
NewPID = %ErrorLevel% ; Save the value immediately since ErrorLevel is often changed.
if NewPID = 0
goto checkprocessagain
Process, wait, %NewPID%
Sleep, 2000
IfWinExist udp://localhost:1234?listen
{
WinMove, , , 3848, 197
}
; draw a black border to hide the window borders for the mirror
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, Color, 000000
WinSet, Region, 0-0 762-0 762-235 0-235 0-0 14-21 744-21 744-230 14-230 14-21
Gui, Show, W762 H235 X3840 Y205 NoActivate
; cover an artifact
Gui 2: +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, 2:Color, 000000
WinSet, Region, 0-0 W15 H40
Gui, 2:Show, W15 H40 X3840 Y190 NoActivate
; remove borders from DMD adapted from ozon - https://gist.github.com/ozon/2c3b98161329b583b4a5 Thanks
WinActivate, ahk_class PxWindowClass
IfWinExist Pinball FX2 DotMatrix
{
WinSet, Style, -0xC00000 ; hide title bar
WinSet, Style, -0x800000 ; hide thin-line border
WinSet, Style, -0x400000 ; hide dialog frame
WinSet, Style, -0x40000 ; hide thickframe/sizebox
}
WinActivate, Pinball FX2
WinWaitActive, Pinball FX2
Sleep, 1000
Send {Enter Down}, Send {Enter Up} ;Resume
process, WaitClose, Pinball FX2.exe
Run, taskkill /IM ffplay.exe,,UseErrorLevel
Run, taskkill /IM ffmpeg.exe /F,,UseErrorLevel
ExitApp

Link to comment
Share on other sites

Hey I'm using that nuke launcher,It works great except it doesn't exit from steam when you exit a table. When you try to load another table it says you already have steam running ,can't start pinballfx2. I need a script that kills the bootstrapper process or exe of steam. I tried task kill and other apps but no luck.any help would be greatly appreciated.

Jay

Link to comment
Share on other sites

Hey I'm using that nuke launcher,It works great except it doesn't exit from steam when you exit a table. When you try to load another table it says you already have steam running ,can't start pinballfx2. I need a script that kills the bootstrapper process or exe of steam. I tried task kill and other apps but no luck.any help would be greatly appreciated.

Jay

Since you are using Nuke Launcher have you posted this in the Nuke Launcher thread?

Link to comment
Share on other sites

Well it's not a nuke launcher problem it is a steam/ pinballfx problem. It does the same thing outside of pinballx and nuke launcher.

I was just seeing if anybody has ran into this problem. I noticed a few people in this thread had complained of steam not closing after exit. After doing some research it seems to be a steam bug. I was just wondering if anybody might know a fix for it.

Link to comment
Share on other sites

For those who don't know what NukeLauncher is,it's a Pinball FX2 launcher that automated the table selection with a bunch of other features.

Here is a link to the main post about NukeLuncher

http://www.gameex.info/forums/topic/15201-app-nukelauncher-is-now-available-to-all-pinball-fx2-launcher/

Link to comment
Share on other sites

  • 1 month later...

Thanks to your scripts Carney_Priest (and a little tailoring) I now have Piinball FX2 working a treat on my cab.

Many thanks for posting your efforts for other to use!

Shifters

PS Another day another Carney_Priest ahk script :rolleyes:

Thanks! But I too am transitioning to NukeLauncher. Still working on it, but I am having some success just running a stripped down version of my script that does the DMD mirroring that I need in parallel with NukeLauncher.

http://www.gameex.info/forums/topic/12837-support-for-pinball-fx2/page-12#entry132260

Link to comment
Share on other sites

Lag on flippers - if you have an NVidia card, you can go into the NVidia Control Panel, Manage 3D Settings and set up a custom profile for Pinball FX2 where Max Pre-rendered Frames is set to "1". That may help.

Selecting the right table - Yes, the auto-detect did not work for me either even though the names in my xml are identical to the pxp file names in the Steam folder. So, you have to define and maintain the list and order in the ini. Same thing that you have to do with the arrays in my script.

If the Sleep values in my script work they can be carried over to the Delay values in the ini.

What I like with NukeLauncher is that there is some form of multiplayer support and that it can automatically exit all the way out on Escape.

There are still some issues that I need to work out to get all of this working with my VirtuaPin Plunger Kit, but I can't lay my remaining issues at the feet of NukeLauncher. I have the same issues with my script.

Link to comment
Share on other sites

Oh, man! What a PITA FX2 is! There are at least eight different processes and probably more running on top of FX2 for me to do what I want.

I switched over to NukeLauncher. It's just too good not to. The Guessing Engine did not work for me even though I had changed my game names in the XML to be the same as the pxp file names used by Zen. No matter; I defined the names and order in the ini. Same thing I'd have to do with my script. Delay times in my script are proven for my system. I carried the times over to the ini. Works great!

I've stripped down my script to run in parallel with NukeLauncher to do the DMD mirroring for p2k cabinets. NukeLauncher has some built-in support but my configuration is pretty unique. I went with my own solution. This script is set up to Launch Before NukeLauncher in the PBX Settings ini for the Pinball FX2 system.

#NoEnv
#SingleInstance force
#WinActivateForce
SetTitleMatchMode 3
DetectHiddenWindows On
; To run with NukeLauncher
Sleep, 20000
; Mirror and flip DMD for P2k
run, ffmpeg -rtbufsize 1500M -f gdigrab -framerate 120 -offset_x 3853 -offset_y 0 -video_size 732x212 -i desktop -vf "vflip" -vcodec mpeg4 -qscale:v 1 -f mpegts -threads 8 udp://localhost:1234,,Hide UseErrorLevel
Sleep, 1000
run, ffplay -an -sn -i -fflags nobuffer udp://localhost:1234?listen,,Hide UseErrorLevel
checkprocessagain:
Process, wait, ffplay.exe, 5.5
NewPID = %ErrorLevel% ; Save the value immediately since ErrorLevel is often changed.
if NewPID = 0
goto checkprocessagain
Process, wait, %NewPID%
Sleep, 2000
IfWinExist udp://localhost:1234?listen
{
WinMove, , , 3848, 197
}
; draw a black border to hide the window borders for the mirror
Gui +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, Color, 000000
WinSet, Region, 0-0 762-0 762-235 0-235 0-0 14-21 744-21 744-230 14-230 14-21
Gui, Show, W762 H235 X3840 Y205 NoActivate
; cover an artifact
Gui 2: +LastFound +AlwaysOnTop -Caption +ToolWindow
Gui, 2:Color, 000000
WinSet, Region, 0-0 W15 H40
Gui, 2:Show, W15 H40 X3840 Y190 NoActivate
WinActivate, Pinball FX2
WinWaitActive, Pinball FX2
Sleep, 1000
Send {Enter Down}, Send {Enter Up} ;Resume
process, WaitClose, Pinball FX2.exe
Run, taskkill /IM ffplay.exe,,UseErrorLevel
Run, taskkill /IM ffmpeg.exe /F,,UseErrorLevel
ExitApp

The mirroring behaves like my old script. Great!

I have a VirtuaPin Digital Plunger Kit v1. It's controller emulates a joystick. The issue was mapping the Exit table button and avoid conflicts with other emulators in my setup.

Everyone knows about x360ce. I was able to map Select, Auto Launch, L and R flipper, and X and Y axis for analog nudging. I can map Exit to Back, but NukeLauncher does not recognize this as an Exit command. And just killing the FX2 process does not work well for the DMD mirroring.

AntiMicro is a free, open source program to map keys to a gamepad. Sort of like XPadder, I imagine.

https://github.com/Ryochan7/antimicro

Sadly, there is little documentation on its command line instructions. I just couldn't figure out how to make it work that way, launching from within PBX. But all I need is a single profile to match a single button to a single key, Exit to Esc. The gui by default is set up to auto load the latest opened profile. There is an option to auto launch on Windows start up. I'd rather have this residing in memory only when I need it, but such is life.

PinballX uses the default keyboard input settings with Quit set to Esc. Now NukeLauncher recognizes an Exit button press as an 'Exit' and performs the "saveexit" operation perfectly, the DMD mirroring script kills ffmpeg and ffplay, and reverts back to PBX. Wonderful!

FP works out of the box exiting completely with Esc.

VP, on the other hand, brings up the Resume, Quit to Editor dialog. There's no way to change this in VP Preferences. I wrote a script called JoyExitMap to in turn map my Exit button (Joy8) to q for Quit just for VP. I have it launching on PBX startup:

#NoEnv
#SingleInstance force
#IfWinActive ahk_class VPPlayer
Joy8:: Send {q}
#IfWinActive
ExitApp

I had a little script that I ran on PBX shutdown that made sure the Windows cursor was on the main playfield instead of the DMD screen. It was always annoying having to move that cursor every time I shut down PBX. I added a line to kill JoyExitMap on PBX shutdown:

#NoEnv
Run, taskkill /IM JoyExitMap.exe,,UseErrorLevel
CoordMode, Mouse, Window
SendMode Input
MouseMove, 1644, 942
ExitApp

Took me days to figure out how to get all of this working together. I still need to do some tweaking of the analog nudge. The game nudges even when I'm not touching the machine. I haven't added a deadzone yet. Antideadzone is set in x360ce to 100%.
I tried enabling the analog plunger but right now it is registering a pull even when the plunger is at rest. I've read that this can be adjusted with DXTweak, but I haven't tried it yet. I'm pretty happy with having a digital launch button as I've been launching with a keyboard all this time.
Again, thanks to Tom and Jeff. It's the combination that rules Pinball FX2 for cabinets!

Edit:

Slight change to the little JoyExitMap script. It was causing a conflict that was shutting down tables as soon as they launch. This one works for me.

Link to comment
Share on other sites

Is your plunger set to use the right or left trigger? I first set it to the right analog joystick but It didn't work. I had to set the plunger to be the left analog trigger in x360ce and used xpadder to map esc like you did with the other program.

Link to comment
Share on other sites

Yeah, I relied heavily on your build diary at VPF to figure this out.

I tried right trigger. It works but needs tweaking. At rest the reading should be zero but the reading in the configuration software is not zero so it always tries to launch even if I'm not touching the plunger. I understand that the reading can be shifted with DXTweak but I just haven't gotten around to trying it. I haven't played all the tables extensively. Those that I have, I don't think that they benefit much from having an analog plunger. The skillshots seem to me to be more of a timing thing then a strength of a pull thing.

What is weird is that the left trigger always shows that it is engaged in the x360ce configuration utility whether or not I have something mapped to it or not. So I didn't even try it.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...