Guest User

Untitled

a guest
Aug 2nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;----------------------------------------------------------------------------
  2. ; Key Mapping Software
  3. ; JoyToKey v5.1 and Xpadder 2012.01.19
  4. ; by brolly
  5. ; 1.0
  6. ;
  7. ; Notes:
  8. ; This will not work with JoyToKey v3 since it won't allow you to load profiles from directories other than the default one
  9. ; Make sure you activate the following preferences on JoyToKey:
  10. ; Start JoyToKey in a minimized mode
  11. ; Hide icon from taskbar when minimized
  12. ;
  13. ; The following entries should be added to the main Settings.ini file under the Hyperlaunch section:
  14. ; keymapper_enabled=true or false, defines if you want to use a keymapper by default (defaults to false)
  15. ; keymapper=joytokey or xpadder (defaults to empty)
  16. ; keymapper_path=path to the folder & file containing your mapping software exe, example C:\Hyperspin\Xpadder\Xpadder.exe
  17. ; keymapper_profiles_path=path where the profiles are stored (defaults to A_ScriptDir\Controller Profiles\)
  18. ; lastkeymapperprofile=this key is updated with the path for the last profile file used (Not used anymore)
  19. ;
  20. ; The following entries should be added to the main Settings.ini file under the Hyperlaunch section:
  21. ; keymapper_enabled=true or false, defines if you want to use a keymapper on this system (defaults to the setting defined on the main Settings.ini file)
  22. ;
  23. ; Profiles are loaded by the following order:
  24. ; 1. Game specific profile
  25. ; 2. System specific profile
  26. ; 3. Default profile
  27. ;
  28. ; The default profile (if exists) should be on keymapper_profiles_path and should be called Default.cfg or Default.xpadderprofile
  29. ; The system default profile (if exists) should be on keymapper_profiles_path\SystemName and should be called SystemName.cfg or SystemName.xpadderprofile
  30. ; Game Specific profiles (if exists) should be on keymapper_profiles_path\SystemName and should be called romName.cfg or romName.xpadderprofile
  31. ;----------------------------------------------------------------------------
  32.  
  33. ; DO NOT INCLUDE THESE IN HYPERLAUNCH:
  34. settingsFile=%A_ScriptDir%\Settings\Settings.ini
  35. iniFile := CheckFile(A_ScriptDir . "\Settings\" . systemName . ".ini")
  36.  
  37. ; Read keymapper settings from Settings.ini
  38. ; PUT WITH INIREADS AND RETSTR VAR IN HYPERLAUNCH
  39. ; IniRead, keymapperEnabled, %settingsFile%, HyperLaunch, keymapper_enabled, false ; NOT NEEDED, KEEP THIS PER SYSTEM ONLY FOR NOW, LESS CONFUSION AND NO ACCIDENTAL ENABLES
  40. IniRead, keymapperEnabled, %iniFile%, exe info, keymapper_enabled, false
  41. IniRead, keymapper, %settingsFile%, HyperLaunch, keymapper, %A_Space%
  42. IniRead, keymapperFullPath, %settingsFile%, HyperLaunch, keymapper_path, %A_Space%
  43. IniRead, keymapperProfilePath, %settingsFile%, HyperLaunch, keymapper_profiles_path, %A_ScriptDir%\Keymapper Profiles\ ; MIGHT HARDCODE THIS, WILL DISCUSS WITH BBB
  44. ;IniRead, lastkeymapperprofile, %settingsFile%, HyperLaunch, lastkeymapperprofile, %A_Space%
  45.  
  46. ; CHANGING HOW ITS CALLED FOR HYPERLAUNCH IMPLEMENTATION
  47. If (keymapperEnabled = "true"){
  48.         ;Add Global RunKeyMapper function to module if used
  49.         ; retStr .= "`n`nLoadKeyMapper(){`n}"
  50.         ; retStr .= "`n`nUnloadKeyMapper(){`n}"
  51.         RunKeyMapper()
  52.     }Else{
  53.         ;Still have to add a blank function so no error occurs.
  54.         retStr .= "`n`nLoadKeyMapper(){`n}"
  55.         retStr .= "`n`nUnloadKeyMapper(){`n}"
  56.     }
  57. ExitApp
  58.  
  59. RunKeyMapper() {
  60.     Global
  61.     SplitPath, keymapperFullPath, keymapperExe, keymapperPath, keymapperExt ; splitting pathname into variables
  62.     CheckFile(keymapperFullPath) ; WANT TO CHECK THIS FIRST, NO NEED TO CONTINUE IF USER HAS IT CONFIGURED WRONG
  63.     ; If (keymapperEnabled = "true") {
  64.    
  65.     ; Build profile
  66.     If (keymapper="xpadder") {
  67.         defaultProfile = %keymapperProfilePath%%systemName%\default.xpadderprofile
  68.         profile = %keymapperProfilePath%%systemName%\%romName%.xpadderprofile
  69.     } Else If (keymapper="joytokey") {
  70.         defaultProfile = %keymapperProfilePath%%systemName%\default.cfg
  71.         profile = %keymapperProfilePath%%systemName%\%romName%.cfg
  72.     }
  73.     If (FileExist(profile))
  74.         profileToUse=%profile%
  75.     Else If (FileExist(defaultProfile))
  76.         profileToUse=%defaultProfile%
  77.     Else
  78.         ScriptError("Keymapper support is enabled`, but could not find a default profile or one for this rom in " . keymapperProfilePath)
  79.  
  80.     ;If (lastkeymapperprofile != "%profilePath%%profileToUse%")
  81.  
  82.     ; Launch keymapper
  83.     If (keymapper="joytokey") {
  84.         Process, Close, %keymapperExe%
  85.         Process, WaitClose, %keymapperExe% ; Make sure it's actually closed before continuing
  86.         Run, %keymapperExe% "%profileToUse%", %keymapperPath% ;Run joytokey
  87.     } Else If (keymapper="xpadder")
  88.         Run, %keymapperExe% "%profileToUse%" /M, %keymapperPath% ;Run xpadder
  89.     ;IniWrite, %profilePath%%profileToUse%, %settingsFile%, HyperLaunch, lastkeymapperprofile
  90. }
  91.  
  92.  
  93. UnloadKeymapper() {
  94.         ;Unload keymapper software
  95.         If (keymapper="joytokey")
  96.             Process, Close, %keymapperExe%
  97.         Else If (keymapper="xpadder")
  98.             Run, "%keymapperExe%" /C, %keymapperPath%
  99.         ;IniWrite, %A_Space%, %settingsFile%, HyperLaunch, lastkeymapperprofile
  100. }
  101.  
  102. CloseProcess:
  103. Return
Add Comment
Please, Sign In to add comment