JME Controller Config

In my never-ending quest to get gamepads functioning perfectly in my jMonkey game, I ended up creating a couple of utilities based on TestJoypad to make the task easier, as well as to crowdsource the work of getting all gamepads operation to the users. Considering that I find them fairly useful, I decided to extract them from my game and publish them as a standalone library on GitHub for anyone to use.

The library contains two application states of interest. The JoystickPreviewScreen state will display the controllers currently connected to the computer (and update it as controllers are connected and disconnected on properly configured applications), as well as the values of all their inputs. This is essentially a GUI-based, user-friendly enhancement to the original TestJoypad example that, in my opinion, makes debugging joysticks a lot easier.

Once you have an idea what is going on, you can then make changes. Version 1.1 introduces the CalibrateInputScreen state. This screen will show a series of prompts that will guide users through the process of creating a controller remapping properties file compatible with JoystickCompatibilityMappings. Once finished, it spits a configuration file to the location you specify (appending to any previous data if the file exists). You can then load up that configuration file in conjunction with the one that comes with jme3-core upon the next application run.

One of the main ideas behind this project was to utilize as few dependencies as possible. It does rely on slf4j for logging, but most of you will have that anyway. It also relies on the files in the Interface/Joystick folder of jme3-testdata. These can easily be copied over into your own resources folder in the same location. This doesn’t need any GUI libraries, so you can continue using whichever one you want (if any). All you need to do is attach the app states as needed and you are good to go.

I also included examples of how to implement the classes in the :desktop and :android subprojects in the GitHub project. These are fully-fledged projects that can run. If all you want is a standalone utility for development purposes, you can easily download the source and build them.

11 Likes

I made a few changes in the master branch of this project. I’m probably going to hold off of an actual release file, since many of the changes make heavy use of bleeding-edge jmonkey features I’ve been developing. Nevertheless, I do consider the master branch to be stable enough for production in 3.3 projects, should anyone care to build the library themselves.

Some highlights:

  • The remapper should handle trigger axes much better, even if the default value is not 0.
  • When remapping, users can now choose to disable any buttons that were not mapped. This should reduce the clutter of buttons that jmonkey doesn’t use (most often duplicate buttons).
  • The vertical axes of the joysticks should now reflect the actual input values better. There is still the issue of some gamepads sending inverted input, but that should hopefully be fixed in a later jmonkey update.
  • The default value shown for axes is now “0.0” rather than “-1.0.”
4 Likes

This looks like a very interesting addition, I did some related work with GitHub - Pesegato/BigBanana: Mouseless (bananaful?) navigation for jme3 applications

1 Like

After a bit of a hiatus from here to focus on personal life, I’ve decided to go back and update some of my older projects. As such, I am pleased to say that the controller config is now updated for use with jMonkey version 3.4.0. Version 1.2 is now available for download on the github page, and will hopefully be updated in the store shortly.

I am also investigating the possibility of releasing it on Maven Central.

Changelog:

  • Adds support for jMonkeyEngine 3.4.
  • Adds the CalibrateInputScreen state. Attaching it will provide a series of prompts that will walk the user through creating a controller remapping file. See README.md for more details.
  • Dynamically changes the GUI slightly when on touchscreen devices.
  • Restructures the project. The standalone example desktop build can be found in the :desktop submodule.
  • Adds an build for LWJGL 2. It can be found in the :desktopLegacy submodule. Outside of a dependency change, it is identical.
  • Adds a build for Android. It can be found in the :android module.
  • Adds a GUIUtils class to the library. This class contains a series of static methods and fields designed to help handle the GUI aspects of the program. It is primarily used internally, but the methods are free to use for your own purposes as well.
  • Adds the ability to change the colors of the buttons by changing the values of the color fields in GUIUtils.
  • Makes the buttons look nicer.
2 Likes