Winsoft’s Controller is a XInput API controller SDK. XInput a universal joystick controller for Windows 7, 8, 10.
In the Windows platform, you can use other joysticks, such as PlayStation Dual-Shock Controller, Nintendo Switch Pro Controller and Steam Controller if you don’t have a XBOX joystick controller.
Table of Contents
Winsoft Controller Installation
Steps:
- Go to https://www.winsoft.sk/controller.htm for the download link.
- Download the trial version.
- Install Controller.exe
- Find Winsoft’s Controller installed in C:\Program Files (x86)\Winsoft\Controller\ and example in C:\Program Files (x86)\Winsoft\Controller\Examples\Delphi\Demo.dproj.
- If you want to add Winsoft’s DirectX path controller, go to Language > Delphi > Library >
Setting up the XBOX Controller
Prior to starting, go to Control Panel > Devices and Printers.
- Right-click on the joystick icon.
- Go to Game controller settings.
- Ensure status is OK.
If the status is not OK, please install the XBOX redistributable framework 4.0 and DirectX 9.0 run-time.
Quick Joystick Support
I have made changes to the Delphi Stater Kit game Alien Invasion.
I first drag and drop the TController from the (1) component palette to form (2).
I then add code to get button press data from Controller.Buttons and respond to btUp as a Key-Up event.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Buttons := GamepadFrame.Controller.Buttons; if (btLeft in Buttons) then begin Key := vkLeft; end else if (btRight in Buttons) then begin Key := vkRight; end else if (btUp in Buttons) or (btA in Buttons) or (btB in Buttons) or (btX in Buttons) or (btY in Buttons) then begin Key := vkUp; end else if (btStart in Buttons) then begin isPaused := not isPaused; Exit; end; |
Loading and Saving Controller Settings
In order to load Joystick controller settings, I load ControllerIndex. If the setting is more than 1 (i.e, 0 = (none), 1 = Device 0), I enable the Joystick Controller, or else, Joystick is disabled.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
// type TGameForm = class(TForm) //... ControllerIndex : Integer; end; procedure TGameForm.LoadSettings; var IniFile: TMemIniFile; begin IniFile := TMemIniFile.Create(SettingsFilePath + 'Settings.ini'); //... ControllerIndex := IniFile.ReadInteger('Settings', 'Controller', 0); if (ControllerIndex > 0) then begin GamepadFrame.Controller.Device := ControllerIndex - 1; GamepadFrame.Controller.Enabled; GamepadFrame.Timer.Enabled := true; end else begin GamepadFrame.Controller.Disable; GamepadFrame.Timer.Enabled := false; end; //... end; |
In order to save controller setting, I save the ControllerIndex.
1 2 3 4 5 6 7 8 9 10 |
procedure TGameForm.SaveSettings; var IniFile: TMemIniFile; begin IniFile := TMemIniFile.Create(SettingsFilePath + 'Settings.ini'); //... IniFile.WriteInteger('Settings', 'Controller', ControllerIndex); IniFile.UpdateFile; IniFile.Free; end; |
The GIT repository for the Alien Invasion modifications to work with Winsoft Controller is at https://github.com/PolywickStudio/DelphiAlienInvasion
Winsoft sells the full-version at their website.
- Works with: Delphi, C++Builder, FMX, VCL
- Works on: Windows 32-bit, Windows 64-bit
Conclusion: In less than 30 lines of code, I have demonstrated adding Joystick support to your game. WINSOFT saves game-development time.
Check out the full WINSOFT Controller for Delphi and C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition