Skip to content

Commit

Permalink
allow user to add gamepad profiles without tempering w/ core (#1671)
Browse files Browse the repository at this point in the history
* allow user to add gamepad models without tempering w/ core

* more explicit var names
  • Loading branch information
p3r7 authored Apr 19, 2023
1 parent b37a2b1 commit 4230035
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lua/core/gamepad_model/index.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@

local models = {}

-- bundled w/ core
models['03000000830500006020000010010000'] = require 'gamepad_model/ibufalo_classic_usb'
models['030000005e0400008e02000014010000'] = require 'gamepad_model/xbox_360'

-- user-local
local user_conf_dir = _path.data .. "gamepads/"
if util.file_exists(user_conf_dir) then
local user_confs = util.scandir(user_conf_dir)
for _, conf_file in pairs(user_confs) do
if conf:sub(-#'.lua') == '.lua' then
local conf_file_sans_ext = conf_file:gsub("%.lua", "")
print("loading user gamepad conf: "..user_conf_dir..conf_file)
local module_path = user_conf_dir .. conf_file_sans_ext
local user_conf = require(module_path)
models[user_conf.guid] = user_conf
end
end
end

return models

0 comments on commit 4230035

Please sign in to comment.