Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Support for additional game controllers

A topic by xordspar0 created 86 days ago Views: 31 Replies: 2
Viewing posts 1 to 3
(+1)

SDL doesn’t recognize my controller natively, but SDL_GameControllerDB has it in its database. I unzipped the .love file and patched in support for the database. Then I dropped gamecontrollerdb.txt into the unpack directory, and my controller worked! My patch is below.

diff --git a/core/init.lua b/core/init.lua
index c7de670..cd22d73 100644
--- a/core/init.lua
+++ b/core/init.lua
@@ -40,6 +40,7 @@ end
 
 function api:load_globals()
 	-- prepares the global namespace ofc
+	love.joystick.loadGamepadMappings("gamecontrollerdb.txt")
 	input = require("libs.boipushy")() -- now with sequences??
 	class = require("libs.classic")
 	lume = require("libs.lume")

It would be great to have this supported by the game natively. This will cause an error if the file doesn’t exist, so a little more engineering would be required. Maybe the game could ship with the file included; LOVE would still automatically allow overriding/updating it by dropping a replacement into the user’s data directory. Or a simple file existence check would be fine.

(+1)

it would be good to have this in the pipeline! I appreciate you digging into this, and offering future support for players. I don't have a computer at this time, but once I do, I can look into integrating that natively for everybody. Thank you 

That will be great, thanks!

I’ve been chatting about loadGamepadMappings with some people on the SDL forums and I learned about the environment variable SDL_GAMECONTROLLERCONFIG_FILE. A user can set that variable instead of patching the game like I suggested above. This works for any LOVE or SDL game, super handy.

  1. Drop the SDL_GameControllerDB next to the .love file, then
  2. SDL_GAMECONTROLLERCONFIG_FILE=gamecontrollerdb.txt love 'Metanet Hunter G4 (v1.2).love'