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. My bare hosting costs are currently not met so please consider donating by either clicking this text or the Patreon link on the right.

Patreon

Using AlsoLaunch= to load custom JoyToKey configs and starting other apps using batch files


Recommended Posts

Posted

I have seen a lot of questions about JoyToKey and such and I thought I would share my approach.

I use a custom JoyToKey config for GameEx, MAME, PC games, vpinball, etc, (that's 1 config per) and have yet to ever mess with any custom key layouts in GameEx or any emulator.

I have a basic batch file I use for setting only the JoyToKey configurations and an more advanced batch method that starts JoyToKey, mounts ISOs, and starts other applications as needed. It's all based on the same initial setup and folder structures and it's fairly easy to maintain. I know there are other ways to do a lot of the same things within GameEx but I have found this to very flexible and the best method for my particular setup.

Note: I use the AlsoLaunch= to call the batch file, not LaunchBefore= I have found LaunchBefore to either hang or not allow the batch files to run to completion. Even though I may use the term Launch Before I'm referring to using the entry AlsoLaunch=

Basic method: The JoyToKey custom configuration loader

To avoid the First Configuration error or JoyToKey not loading the correct config file I have a separate folder for each game with it's own copy of JoyToKey, the JoyToKey.ini and the applicable config file.

e:\JoyToKey\vpin

e:\JoyToKey\xplane

e:\JoyToKey\GameEx

e:\JoyToKey\proj64

-- JoyToKey.exe

-- JoyToKey.ini

-- proj64.cfg

The JoyToKey.ini has been modified in each folder to reflect the config filename within the same folder, for example the JoyToKey.ini file within the proj64 folder:

[DirectInput]

AnalogDeadZone=1000

AnalogSaturation=10000

[LastStatus]

AllowMultipleRunning=0

StartIconified=1

WindowPositionTop=24

WindowPositionLeft=112

ListColumnWidthButton=75

ListColumnWidthKeyboard=163

ListColumnWidthAuto=42

FileName=proj64

You could actually leave the FileName=default and not change the cfg name but I like to be able to click on the taskbar icon and see what config file is loaded.

The config needs to be modified for each game configuration you want to use, using Proj64 as an example, run JoyToKey within the Proj64 folder, then the Proj64 emulator, then program the JoyToKey configuration. I don't bother changing key layouts within each individual emulator or game, I do it all within JoyToKey, this ensures control panel layout consistency across all games including save and load games. Note: You can change the configuration of JoyToKey if you load a game via GameEx but changes to the config file will be lost since JoyToKey is stopped via taskkill and not a proper exit of the program. To make sure you don't loose any configuration information I suggest launching JoyToKey then the emulator outside of GameEx and saving.

The Launch Before batch file : startup_proj64.bat

@echo off&cls&color 0b

set _j2k_home=proj64

:: -- [ location info ]--
set _j2k_drv=e
set _j2k_path=\JoyToKey
set _delay=2

:: -- [ JoyToKey Loader ]--

taskkill /F /IM JoyToKey.exe /T > nul
ping -n %_delay% 127.0.0.1 > nul
%_j2k_drv%:
chdir "%_j2k_drv %:%_j2k_path%\%_j2k_home%"
start "joytokey" "%_j2k_drv %:%_j2k_path%\%_j2k_home%\JoyToKey.exe"

:: --[end]--

It may look confusing at first, especially with the drive letter and paths separated, but this is done to allow you to change the only the _j2k_home= line and save it without having to modify anything else.

set _j2k_home=proj64

The name of the folder the JoyToKey configuration is located

set _j2k_drv=e

This is the drive letter of where the joytokey folders are located

set _j2k_path=\JoyToKey

The path without the drive letter or any quotes

set _delay=2

The batch file will kill joytokey if it's running before loading it with the new config, this allows for a adjustable pause before continuing.

Setting up this file for each game is easy, just change _home= to reflect the config folder you want to use, then save the batch file using the same name. If I need to make one for vpin; change line _home=vpin (same as the folder I created) then save the batch file as start_vpin.bat Then I put the batch file name into GameEx Emu entry VPinball AlsoLaunch=start_vpin.bat. That's it.

I also have one that I use called startup_GameEx.bat that I use when I startup GameEx under Launch on startup don't wait, and I reuse the same batch file on every emulator LaunchAfter=

Advanced Method: Loading JoyToKey, ISOs, LedWiz, and VPAuto Loader

Aside from using this method as a Launch Before solution I also use the same batch file as a way to launch other programs and games within GameEx via a Emulator entry called Sam's CMD Launcher and put all the batch files into one folder and target roms *.bat, similar to the DOSBox solution I've seen floating around. I'll explain this in more detail later.

I've built flexibility into this batch file that makes provisions for just about any startup scenario I need, loading JoyToKey, mount needed ISOs, etc, and LedWiz configurations. I use LedWiz to control lights within my buttons and change the colors based on emulator config loaded, the manufacture doesn't have a solution to do this yet but I figured out how to do this via batch files. I also change button light color based on Windows event log entries but that's outside of this write up, if interested let me know.

The basic method must be in place for this to work. It may look complex at first but its very easy to use once you understand what it's doing. I have tried to simplify this as much as possible by creating a script that allows quick configuration changes within the first couple of sections of the script and flagging actions using on and off triggers. In the example below I launch JoyToKey, mount an ISO, change the colors of my buttons, then start a game.

@echo off&cls&color 0b

:: -- [ game location information ]-
set _j2k_home=LegoStarwars
set _j2k_drv=e
set _j2k_path=\JoyToKey

set _loc_game_drv=c
set _loc_game=\Program Files\Giant\LEGO Star Wars Game
set _game_exe=LegoStarwars.exe
set _game_sw=
set _loc_iso=I:\My ISOs\LEGOStarWars.iso

::-- [ actions to perform ]-
set _delay=2
set _use_JoyToKey=on
set _use_Ledwiz=on
set _use_vpauto=off
set _use_daemon=on

::-- [app locations ]-
set _loc_GameEx=c:\Program Files\GameEx
set _loc_gamex_drv=c
set _ledwiz_path=E:\mame\apps\bat
set _loc_daemon=C:\Program Files\DAEMON Tools
set _loc_daemon_drv=c

:: -- [ DO NOT EDIT ANYTHING BELOW ]--


:_JoyToKey
if %_use_JoyToKey%==off goto _ledwiz
taskkill /F /IM JoyToKey.exe /T > nul
ping -n %_delay% 127.0.0.1 > nul
%_j2k_drv%:
chdir "%_j2k_drv %:%_j2k_path%\%_j2k_home%"
start "joytokey" "%_j2k_drv %:%_j2k_path%\%_j2k_home%\JoyToKey.exe"
goto _ledwiz


:_ledwiz
if %_use_Ledwiz%==off goto _vpauto
taskkill /F /IM -t Ledwiz.exe /T > nul
ping -n %_delay% 127.0.0.1 > nul
start "Ledwiz" "%_ledwiz_path%\Ledwiz.exe"
:: all green
echo LWZ-SBA:0,0,0,128,5 | clip
:: all green - blue 1,2,3 & 6
echo LWZ-SBA:136,136,0,128,5 | clip
goto _vpauto


:_vpauto
if %_use_vpauto%==off goto _daemon
taskkill /F /IM vpauto.exe /T > nul
%_loc_gamex_drv%
chdir "%_loc_GameEx%"
start "vpauto" vpauto.exe
goto _daemon


:_daemon
if %_use_daemon%==off goto _st_game
%_loc_daemon_drv%:
chdir "%_loc_daemon%"
daemon.exe -unmount 0
daemon.exe -mount 0,"%_loc_iso%"
ping -n %_delay% 127.0.0.1 > nul
goto _st_game


:_st_game
%_loc_game_drv%:
chdir "%_loc_game_drv%:%_loc_game%"

"%_game_exe%" "%_game_sw%"


:: -- [ cleanup

:_unmount
if %_use_daemon%==off goto _end
%_loc_daemon_drv%:
chdir "%_loc_daemon%"
daemon.exe -unmount 0
goto _end

:_end

To use it as a AlsoLaunch= batch file just blank out unneeded lines and adjust the actions. Using my Proj64 example;

:: -- [ game location information ]-

set _j2k_home=Proj64

set _j2k_drv=e

set _j2k_path=\JoyToKey

set _loc_game_drv=

set _loc_game=

set _game_exe=

set _game_sw=

set _loc_iso=

::-- [ actions to perform ]-

set _delay=2

set _use_JoyToKey=on

set _use_Ledwiz=on

set _use_vpauto=off

set _use_daemon=off

If you have a game or program that you need to launch and pass parameters just include them on the line set _game_sw=

example: set _game_sw=/fullscreen /usejoy

As I mentioned before I use an Emulator entry called Sam's CMD Launcher, to use this I just save all my batch files as example_name.cmd in E:\cmd and let GameEx pick it up.

[Emulator_27]

Enabled=True

DumbyValue=

STARTPAGENAME=Sam's CMD Launcher

TITLETEXT=Sam's CMD Launcher

StartPageLogo=

ROMFilter=*.cmd

RomsInFolders=False

RomPath=E:\cmd

SnapPath=E:\cmd\snap

TitlePath=

BoxPath=

CartPath=

WorkingPath=E:\cmd

MapKeys=True

WaitBeforeKeys=

SendKeys=

ReplaceDash=False

ReplaceUnder=True

Capitals=True

RemoveBrackets=False

ShowDesktop=True

Debug=False

MAPFile=

AlsoLaunch=

Command=""[ROMPath]\[RomFile]""

OLDatZip=

LaunchBefore=

LaunchAfter=C:\Program Files\bat\startup_GameEx.bat

configFile=

ExcludedFiles=

CustomBackground=

PlayMusic=True

PCGame=

DATABASE=

GamesIn7Zips=

I know this isn't a good solution for everybody but it might give ya'll some ideas on how to get things working for you.

Posted

Just a comment on your start_proj64.bat

i think you can pass parameters into the batch file - %1%, %2% etc...

Hence you could have a generic start.bat:

start.bat "proj64" 2

and :

set _j2k_home=%1%

set _delay=%2% etc...

or something like that???

Shaun

Posted
Just a comment on your start_proj64.bat

i think you can pass parameters into the batch file - %1%, %2% etc...

Hence you could have a generic start.bat:

start.bat "proj64" 2

and :

set _j2k_home=%1%

set _delay=%2% etc...

or something like that???

Shaun

Never occured to me. Thanks!

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