Skip to content

Commit

Permalink
Add Alternate Keyboard and Joypad launch key / button
Browse files Browse the repository at this point in the history
  • Loading branch information
joyrider3774 committed Nov 2, 2019
1 parent 9f0bdd5 commit 3315408
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ Specifies the key to be used for right selection (default right shift = 161)
### LAUNCHKEY
Specifies the key to be used to confirm the selection and launch the app, by default pinball fx3 (default return = 13)

### LAUNCHKEY2
Specifies an alternate key to be used to confirm the selection and launch the app, by default pinball fx3 (default space = 32)

### QUITKEY
Specifies the key to be used for quiting the launcher and returning to PinballX. Please make sure it's set to same key as PinballX's quit emulator key (default Q = 81)

Expand Down Expand Up @@ -136,6 +139,9 @@ joystick button to be used for a right selection (Default = 5 / RB Button on xbo
### LAUNCHBUTTON
joystick button to be used to confirm the selection and launch the game (Default = 0 / A Button on xbox 360 joypad)

### LAUNCHBUTTON2
Alternate joystick button to be used to confirm the selection and launch the game (Default = 1 / B Button on xbox 360 joypad)

### QUITBUTTON
joystick button to be used to quit the launcher (Default = 6 / back Button on xbox 360 joypad)

Expand Down
16 changes: 11 additions & 5 deletions Source/Launcher app/MainForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ TMainLauncherForm = class(TForm)
BitMapBuffer, BitmapRotated, BitMapScaled: TBitmap;
PngBackGround, PngSelection, PngNoSelection: TPngImage;
Path, LaunchParams, StartParams, Title: String;
LeftKey, RightKey, LaunchKey, QuitKey: Word;
LeftKey, RightKey, LaunchKey, LaunchKey2, QuitKey: Word;
ScaleM, ScaleD, SelectedButton, DoRotate, ScaleFontM, ScaleFontD,
PosLeft, PosTop: Integer;
FButtons: Array[1..NumButtonRows*NumButtonCols] of TButtonRec;
DontSaveIni, DontReadSteamPathReg, SmoothResizeDraw, UseJoypad,
ForceForeGroundWindowDone : Boolean;
JoyLaunchButton, JoyLeftButton, JoyQuitButton, JoyRightButton,
JoyLaunchButton, JoyLaunchButton2, JoyLeftButton, JoyQuitButton, JoyRightButton,
JoyLeftRightAxis: Integer;
JoyAxisDeadZone: Double;
JoyPovLeftMin, JoyPovLeftMax, JoyPovRightMin, JoyPovRightMax: Single;
Expand Down Expand Up @@ -193,6 +193,7 @@ procedure TMainLauncherForm.LoadIni;
LeftKey := IniFile.ReadInteger('SETTINGS','LEFTKEY', VK_LSHIFT);
RightKey := IniFile.ReadInteger('SETTINGS','RIGHTKEY', VK_RSHIFT);
LaunchKey := IniFile.ReadInteger('SETTINGS','LAUNCHKEY', VK_RETURN);
LaunchKey2 := IniFile.ReadInteger('SETTINGS','LAUNCHKEY2', VK_SPACE);
QuitKey := IniFile.ReadInteger('SETTINGS','QUITKEY', Ord('Q'));
StartParams := IniFile.ReadString('SETTINGS', 'STARTPARAMS', '-applaunch 442120');
Path := IniFile.ReadString('SETTINGS', 'PATH', '');
Expand All @@ -214,6 +215,7 @@ procedure TMainLauncherForm.LoadIni;
JoyLeftButton := IniFile.ReadInteger('JOYPAD', 'LEFTBUTTON', 4);
JoyRightButton := IniFile.ReadInteger('JOYPAD', 'RIGHTBUTTON', 5);
JoyLaunchButton := IniFile.ReadInteger('JOYPAD', 'LAUNCHBUTTON', 0);
JoyLaunchButton2 := IniFile.ReadInteger('JOYPAD', 'LAUNCHBUTTON2', 1);
JoyQuitButton := IniFile.ReadInteger('JOYPAD', 'QUITBUTTON', 6);
JoyLeftRightAxis := IniFile.ReadInteger('JOYPAD', 'LEFTRIGHTAXIS', 0);
JoyAxisDeadZone := IniFile.ReadFloat('JOYPAD', 'LEFTRIGHTAXISDEADZONE', 0.5);
Expand Down Expand Up @@ -288,6 +290,7 @@ procedure TMainLauncherForm.SaveIni;
IniFile.WriteInteger('SETTINGS','LEFTKEY', LeftKey);
IniFile.WriteInteger('SETTINGS','RIGHTKEY', RightKey);
IniFile.WriteInteger('SETTINGS','LAUNCHKEY', LaunchKey);
IniFile.WriteInteger('SETTINGS','LAUNCHKEY2', LaunchKey2);
IniFile.WriteInteger('SETTINGS','QUITKEY', QuitKey);
IniFile.WriteString('SETTINGS', 'STARTPARAMS', StartParams);
IniFile.WriteString('SETTINGS', 'PATH', Path);
Expand All @@ -310,6 +313,7 @@ procedure TMainLauncherForm.SaveIni;
IniFile.WriteInteger('JOYPAD', 'LEFTBUTTON', JoyLeftButton);
IniFile.WriteInteger('JOYPAD', 'RIGHTBUTTON', JoyRightButton);
IniFile.WriteInteger('JOYPAD', 'LAUNCHBUTTON', JoyLaunchButton);
IniFile.WriteInteger('JOYPAD', 'LAUNCHBUTTON2', JoyLaunchButton2);
IniFile.WriteInteger('JOYPAD', 'QUITBUTTON', JoyQuitButton);
IniFile.WriteInteger('JOYPAD', 'LEFTRIGHTAXIS', JoyLeftRightAxis);
IniFile.WriteFloat('JOYPAD', 'LEFTRIGHTAXISDEADZONE', JoyAxisDeadZone);
Expand Down Expand Up @@ -624,7 +628,7 @@ procedure TMainLauncherForm.FormKeyDown(Sender: TObject; var Key: Word;
if GetKeyState(VK_RMENU) < 0 then
RealKey := VK_RMENU;

if (RealKey = LaunchKey) then
if (RealKey = LaunchKey) or (RealKey = LaunchKey2) then
DoLaunch(FButtons[SelectedButton].Param);

if RealKey = LeftKey then
Expand Down Expand Up @@ -784,8 +788,10 @@ procedure TMainLauncherForm.JoyPadButtonDown(Sender: TNLDJoystick;
Repaint;
end;

if (JoyLaunchButton > -1) and (JoyLaunchButton < 32) then
if TJoyButton(JoyLaunchButton) in Buttons then
if ((JoyLaunchButton > -1) and (JoyLaunchButton < 32) and
(TJoyButton(JoyLaunchButton) in Buttons)) or
((JoyLaunchButton2 > -1) and (JoyLaunchButton2 < 32) and
(TJoyButton(JoyLaunchButton2) in Buttons)) then
DoLaunch(FButtons[SelectedButton].Param);

if (JoyQuitButton > -1) and (JoyQuitButton < 32) then
Expand Down

0 comments on commit 3315408

Please sign in to comment.