Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Add Instant Joystick Support Using The Winsoft Controller Library In Delphi on Windows

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.

Winsoft Controller Installation

Installed in less than a minute!

Steps:

  1. Go to https://www.winsoft.sk/controller.htm for the download link.
  2. Download the trial version.
  3. Install Controller.exe
  4. 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.
  5. If you want to add Winsoft’s DirectX path controller, go to Language > Delphi > Library >
Adding X Box Controller Library Path to Delphis Library Path

Setting up the XBOX Controller

Prior to starting, go to Control Panel > Devices and Printers.

  1. Right-click on the joystick icon.
  2. Go to Game controller settings.
  3. Ensure status is OK.

If the status is not OK, please install the XBOX redistributable framework 4.0 and DirectX 9.0 run-time.

Ensure your XBox 360 Controller is correctly recognized by Windows

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).

Adding Joystick Controller support is as easy as drag and drop from Component Palette to FireMonkey Form

I then add code to get button press data from Controller.Buttons and respond to btUp as a Key-Up event.

[crayon-676880fddf2d2126028279/]

Loading and Saving Controller Settings

Adding Joystick Controller Support

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.

[crayon-676880fddf2da749870013/]

In order to save controller setting, I save the ControllerIndex.

[crayon-676880fddf2dc306400227/]

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.

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.

Exit mobile version