Skip to content

Commit e815de8

Browse files
committed
Renamed project to DCS-Input-Command-Injector, Saved Game folder changed to "InputCommands/"
1 parent 581363d commit e815de8

File tree

7 files changed

+49
-44
lines changed

7 files changed

+49
-44
lines changed

DCS-Keybind-Injector-Quaggles/DCS-Keybind-Injector-Quaggles/Scripts/Input/Data.lua renamed to DCS-Input-Command-Injector-Quaggles/DCS-Input-Command-Injector-Quaggles/Scripts/Input/Data.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ end
8282
into the "loadDeviceProfileFromFile" function below the line:
8383
status, result = pcall(f)
8484
]]--
85-
local quagglesLogName = 'Quaggles.KeybindInjector'
85+
local quagglesLogName = 'Quaggles.InputCommandInjector'
8686
local quagglesLoggingEnabled = false
87-
local function QuagglesKeybindInjector(filename, folder, env, result)
87+
local function QuagglesInputCommandInjector(filename, folder, env, result)
8888
-- Returns true if string starts with supplied string
8989
local function StartsWith(String,Start)
9090
return string.sub(String,1,string.len(Start))==Start
@@ -95,7 +95,7 @@ local function QuagglesKeybindInjector(filename, folder, env, result)
9595
local targetPrefix = "./Mods/aircraft/"
9696
if StartsWith(filename, targetPrefix) and StartsWith(folder, targetPrefix) then
9797
-- Transform path to user folder
98-
local newFileName = filename:gsub(targetPrefix, lfs.writedir():gsub('\\','/').."QuagglesKeybindInjector/")
98+
local newFileName = filename:gsub(targetPrefix, lfs.writedir():gsub('\\','/').."InputCommands/")
9999
if quagglesLoggingEnabled then log.write(quagglesLogName, log.INFO, '--Translated path: '..newFileName) end
100100

101101
-- If the user has put a file there continue
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Modifies the DCS control scripts to allow merging of user configured input commands from "Saved Games/DCS/" without modifying the original source files: https://github.com/Quaggles/dcs-input-command-injector/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.2

DCS-Keybind-Injector-Quaggles/README.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

DCS-Keybind-Injector-Quaggles/VERSION.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

Inject.lua

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
into the "loadDeviceProfileFromFile" function below the line:
66
status, result = pcall(f)
77
]]--
8-
local quagglesLogName = 'Quaggles.KeybindInjector'
8+
local quagglesLogName = 'Quaggles.InputCommandInjector'
99
local quagglesLoggingEnabled = false
10-
local function QuagglesKeybindInjector(filename, folder, env, result)
10+
local function QuagglesInputCommandInjector(filename, folder, env, result)
1111
-- Returns true if string starts with supplied string
1212
local function StartsWith(String,Start)
1313
return string.sub(String,1,string.len(Start))==Start
@@ -18,25 +18,30 @@ local function QuagglesKeybindInjector(filename, folder, env, result)
1818
local targetPrefix = "./Mods/aircraft/"
1919
if StartsWith(filename, targetPrefix) and StartsWith(folder, targetPrefix) then
2020
-- Transform path to user folder
21-
local newFileName = filename:gsub(targetPrefix, lfs.writedir():gsub('\\','/').."QuagglesKeybindInjector/")
21+
local newFileName = filename:gsub(targetPrefix, lfs.writedir():gsub('\\','/').."InputCommands/")
2222
if quagglesLoggingEnabled then log.write(quagglesLogName, log.INFO, '--Translated path: '..newFileName) end
2323

2424
-- If the user has put a file there continue
2525
if lfs.attributes(newFileName) then
2626
if quagglesLoggingEnabled then log.write(quagglesLogName, log.INFO, '----Found merge at: '..newFileName) end
2727
--Configure file to run in same environment as the default command entry file
28-
local f = loadfile(newFileName)
29-
setfenv(f, env)
30-
local statusInj, resultInj
31-
statusInj, resultInj = pcall(f)
32-
33-
-- Merge resulting tables
34-
if statusInj then
35-
if resultInj.keyCommands then env.join(result.keyCommands, resultInj.keyCommands) end
36-
if resultInj.axisCommands then env.join(result.axisCommands, resultInj.axisCommands) end
37-
if quagglesLoggingEnabled then log.write(quagglesLogName, log.INFO, '------Merge successful') end
28+
local f, err = loadfile(newFileName)
29+
if err ~= nil then
30+
log.write(quagglesLogName, log.ERROR, '------Failure loading: '..tostring(newFileName).." Error: "..tostring(err))
31+
return
3832
else
39-
if quagglesLoggingEnabled then log.write(quagglesLogName, log.INFO, '------Merge failed: '..tostring(statusInj)) end
33+
setfenv(f, env)
34+
local statusInj, resultInj
35+
statusInj, resultInj = pcall(f)
36+
37+
-- Merge resulting tables
38+
if statusInj then
39+
if resultInj.keyCommands then env.join(result.keyCommands, resultInj.keyCommands) end
40+
if resultInj.axisCommands then env.join(result.axisCommands, resultInj.axisCommands) end
41+
if quagglesLoggingEnabled then log.write(quagglesLogName, log.INFO, '------Merge successful') end
42+
else
43+
if quagglesLoggingEnabled then log.write(quagglesLogName, log.INFO, '------Merge failed: '..tostring(statusInj)) end
44+
end
4045
end
4146
end
4247
end

README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
# DCS Keybind Injector by Quaggles
1+
# DCS Input Command Injector by Quaggles
22

33
![image](https://user-images.githubusercontent.com/8382945/113183515-75dbfb00-9297-11eb-965a-492fd9789c26.png)
44

55
## Summary
66

7-
A mod that allows you to configure custom keybind entries inside your `Saved Games/DCS/` folder instead of inside your game folder, when DCS is run these entries are merged in with the default aircraft entries. This method avoids having to manually merge your control changes into each aircrafts default controls when DCS updates.
7+
A mod that allows you to configure custom input commands inside your `Saved Games/DCS/` folder instead of inside your game folder, when DCS is run these commands are merged in with the default aircraft commands. This method avoids having to manually merge your command changes into each aircrafts default commands when DCS updates.
88

99
## The goal of this mod
1010

11-
Commonly in DCS users with unique input systems will need to create custom keybinds to allow them to use certain aircraft functions with their HOTAS. Some examples are:
11+
Commonly in DCS users with unique input systems will need to create custom input command to allow them to use certain aircraft functions with their HOTAS. Some examples are:
1212

1313
* Configuring 3 way switches on a Thrustmaster Warthog HOTAS to control switches the module developer never intended to be controlled by a 3 way switch
1414
* Configuring actions that only trigger a cockpit switch while a button is held, for example using the trigger safety on a VKB Gunfighter Pro to turn on Master Arm while it's flipped down and then turn off Master Arm when flipped up
15-
* Adding keybinds that the developer forgot, for example the Ka-50 has no individual "Gear Up" and Gear Down" binds, only a gear toggle
15+
* Adding control entries that the developer forgot, for example the Ka-50 has no individual "Gear Up" and Gear Down" commands, only a gear toggle
1616

17-
In my case, on my Saitek X-55 Throttle there is an airbrake slider switch that when engaged registers as a single button being held down, when the slider is disengaged the button is released. In DCS by default few aircraft support this type of input so a custom input is needed, in my case for the F/A-18C:
17+
In my case, on my Saitek X-55 Throttle there is an airbrake slider switch that when engaged registers as a single button being held down, when the slider is disengaged the button is released. In DCS by default few aircraft support this type of input so a custom input command is needed, in my case for the F/A-18C:
1818

1919
```lua
2020
{down = hotas_commands.THROTTLE_SPEED_BRAKE, up = hotas_commands.THROTTLE_SPEED_BRAKE, cockpit_device_id = devices.HOTAS, value_down = -1.0, value_up = 1.0, name = 'Speed Brake Hold', category = {'Quaggles Custom'}},
2121
```
2222

23-
Until now the solution was to find the control definition file `DCSWorld\Mods\aircraft\FA-18C\Input\FA-18C\joystick\default.lua` and insert your command somewhere inside of it, if you weren't using a mod manager then every time the game was updated your change would be erased and you'd need reinsert your commands into the files for every aircraft you changed.
23+
Until now the solution was to find the control definition file `DCSWorld\Mods\aircraft\FA-18C\Input\FA-18C\joystick\default.lua` and insert your custom command somewhere inside of it, if you weren't using a mod manager then every time the game was updated your change would be erased and you'd need reinsert your commands into the files for every aircraft you changed.
2424

25-
If you were using a mod manager such as OVGME if you reapplied your mod after an update and the developers had changed the control binds things could break as things could conflict.
25+
If you were using a mod manager such as OVGME if you reapplied your mod after an update and the developers had changed the input commands things could break and conflict.
2626

27-
With this mod you should just need to re-enable it after every update with OVGME and your custom control binds are safe with no need no change anything.
27+
With this mod you should just need to re-enable it after every update with OVGME and your custom commands are safe with no need no change anything.
2828

2929
## Installation
3030

31-
1. Go to the [latest release](https://github.com/Quaggles/dcs-keybind-injector/releases/latest)
32-
2. Download `DCS-Keybind-Injector-Quaggles.zip`
31+
1. Go to the [latest release](https://github.com/Quaggles/dcs-input-command-injector/releases/latest)
32+
2. Download `DCS-Input-Command-Injector-Quaggles.zip`
3333

3434
### [OVGME (Recommended)](https://wiki.hoggitworld.com/view/OVGME)
3535
3. Drop the zip file in your mod directory
@@ -38,22 +38,22 @@ With this mod you should just need to re-enable it after every update with OVGME
3838

3939
### Manual
4040
3. Extract the zip
41-
4. Find the `DCS-Keybind-Injector-Quaggles/Scripts` folder
41+
4. Find the `DCS-Input-Command-Injector-Quaggles/Scripts` folder
4242
5. Move it into your `DCSWorld/` folder
4343
6. Windows Explorer will ask you if you want to replace `Data.lua`, say yes
4444
7. Repeat this process every DCS update, if you use OVGME you can just reenable the mod and it handles this for you
4545

4646
## Configuration
4747

48-
New commands are configured in the `Saved Games\DCS\QuagglesKeybindInjector` directory, lets go through how to configure a hold action for the speedbrake on the F/A-18C Hornet.
48+
New commands are configured in the `Saved Games\DCS\InputCommands` directory, lets go through how to configure a hold command for the speedbrake on the F/A-18C Hornet.
4949

5050
### Setting the folder structure
5151

52-
For the F/A-18C the default input files are located in `DCSWorld\Mods\aircraft\FA-18C\Input\FA-18C`, inside this directory are folders with the generic names of your input devices, these can include `joystick`, `keyboard`, `mouse`, `trackir` and `headtracker`. Each generic input folder contains `default.lua` which is the default set of keybinds the developer has configured, this is an important reference when making your own commands. It also contains many lua files for automatic binding of common hardware like the Thrustmaster Warthog HOTAS but these can be ignored.
52+
For the F/A-18C the default input files are located in `DCSWorld\Mods\aircraft\FA-18C\Input\FA-18C`, inside this directory are folders with the generic names of your input devices, these can include `joystick`, `keyboard`, `mouse`, `trackir` and `headtracker`. Each generic input folder contains `default.lua` which is the default set of commands the developer has configured, this is an important reference when making your own commands. It also contains many lua files for automatic binding of common hardware like the Thrustmaster Warthog HOTAS but these can be ignored (`*.diff.lua`).
5353

54-
The DCS input folder structure needs be duplicated so that the folders relative to `DCSWorld\Mods\aircraft` are placed in `Saved Games\DCS\QuagglesKeybindInjector`. The folder structure needs to match <b>EXACTLY</b> for each generic input device you want to add commands to. In my F/A-18C Speedbrake Hold example that means I will create the structure `Saved Games\DCS\QuagglesKeybindInjector\FA-18C\Input\FA-18C\joystick\`, for an F-14B in the RIO seat I would create `Saved Games\DCS\QuagglesKeybindInjector\F14\Input\F-14B-RIO\joystick`.
54+
The DCS input folder structure needs be duplicated so that the folders relative to `DCSWorld\Mods\aircraft` are placed in `Saved Games\DCS\InputCommands`. The folder structure needs to match <b>EXACTLY</b> for each generic input device you want to add commands to. In my F/A-18C Speedbrake Hold example that means I will create the structure `Saved Games\DCS\InputCommands\FA-18C\Input\FA-18C\joystick\`, for an F-14B in the RIO seat I would create `Saved Games\DCS\InputCommands\F14\Input\F-14B-RIO\joystick`.
5555

56-
<b>IMPORTANT:</b> For some aircraft the 1st and 3rd folders have different names, for example `F14\Input\F-14B-Pilot` make sure this structure is followed correctly or your inputs won't be found
56+
<b>IMPORTANT:</b> For some aircraft the 1st and 3rd folders have different names, for example `F14\Input\F-14B-Pilot` make sure this structure is followed correctly or your inputs won't be found.
5757

5858
An example of the folder structure for some aircraft I have configured:
5959

@@ -63,7 +63,7 @@ An example of the folder structure for some aircraft I have configured:
6363

6464
![image](https://user-images.githubusercontent.com/8382945/113173913-37414300-928d-11eb-91ad-6e09b6f64a8b.png)
6565

66-
Inside the generic input folder `Saved Games\DCS\QuagglesKeybindInjector\FA-18C\Input\FA-18C\joystick\` etc we will create a lua script called `default.lua`, paste in the following text, it contains the Speedbrake Hold example and some commented out templates for the general structure of commands
66+
Inside the generic input folder `Saved Games\DCS\InputCommands\FA-18C\Input\FA-18C\joystick\` we will create a lua script called `default.lua`, paste in the following text, it contains the Speedbrake Hold example and some commented out templates for the general structure of commands
6767

6868
```lua
6969
return {
@@ -80,19 +80,19 @@ return {
8080
}
8181
```
8282

83-
To work out what to put in these templates reference the developer provided default keybinds file, for the F/A-18C that is in `DCSWorld\Mods\aircraft\FA-18C\Input\FA-18C\joystick\default.lua`
83+
To work out what to put in these templates reference the developer provided default input command file, for the F/A-18C that is in `DCSWorld\Mods\aircraft\FA-18C\Input\FA-18C\joystick\default.lua`
8484

8585
I'd recommend setting a unique category name for your custom commands so that they are easy to find in the menu.
8686

87-
## Extras
8887
### Hardlinking
89-
If you want to have a set of commands bindable to both your HOTAS and your keyboard consider [hardlinking](https://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html) your `default.lua` from your `joystick` folder to your `keyboard` folder.
88+
If you want to have a set of custom commands for both your HOTAS and your keyboard consider [hardlinking](https://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html) your `default.lua` from your `joystick` folder to your `keyboard` folder.
9089

91-
By hardlinking both files look like they are in different directories to Windows and DCS but they actually refer to the same file on the disk meaning if you modify one you automatically modify the other
90+
By hardlinking both files look like they are in different directories to Windows and DCS but they actually refer to the same file on the disk meaning if you modify one you automatically modify the other.
91+
92+
## Examples
9293

9394
### Request AWACS Nearest Bandit
9495
Allows binding request bogey dope to your HOTAS, not every aircraft has this by default in DCS
95-
9696
```lua
9797
{down = iCommandAWACSBanditBearing, name='Request AWACS Nearest Bandit', category = 'Quaggles Custom'},
9898
```
@@ -120,13 +120,13 @@ Note: May get broken by Heatblur at any time and could be considered unscrupulou
120120
```
121121

122122
# FAQ
123-
## My new control bindings aren't showing up ingame
123+
## My new input commands aren't showing up ingame
124124
First look at `Saved Games\DCS\Logs\dcs.log` at the bottom is likely an error telling you what went wrong in your code, for finding syntax errors in lua I would recommend Visual Studio Code with the vscode-lua extension, it should highlight them all in red for you making it easy to find that missing comma 😄
125125

126-
If you have no errors open the mod version of `Scripts\Input\Data.lua` and find the line `local quagglesLoggingEnabled = false` and set it to `true` you will get outputs in the `Saved Games\DCS\Logs\dcs.log` file as the script tries to handle every lua control file, it will tell you the path to the file it is trying to find in your Saved Games folder so you can ensure your folder structure is correct. Remember `../` in a path means get the parent directory.
126+
If you have no errors open the mod version of `Scripts\Input\Data.lua` and find the line `local quagglesLoggingEnabled = false` and set it to `true` you will get outputs in the `Saved Games\DCS\Logs\dcs.log` file as the script tries to handle every lua control file, it will tell you the path to the files it is trying to find in your Saved Games folder so you can ensure your folder structure is correct. Remember `../` in a path means get the parent directory.
127127

128128
## HELP MY CONTROLS MENU IS BLANK/MISSING
129-
Don't worry, this doesn't mean you've lost all your keybinds, it means there was an error somewhere in the code loading the keybinds, usually my injector catches any errors in the `default.lua` and reports them `Saved Games\DCS\Logs\dcs.log`. If you see nothing there it could mean that DCS has been updated and changed the format of the `Scripts/Input/Data.lua` file the mod changes, simple uninstall the mod and the game should work as normal, then wait for an updated version of the mod.
129+
Don't worry, this doesn't mean you've lost all your binds, it means there was an error somewhere in the code loading the commands, usually my injector catches any errors in the `default.lua` and reports them `Saved Games\DCS\Logs\dcs.log`. If you see nothing there it could mean that DCS has been updated and changed the format of the `Scripts/Input/Data.lua` file the mod changes, simple uninstall the mod and the game should work as normal, then wait for an updated version of the mod.
130130

131131
## Disclaimer
132-
I am not responsible for any corrupted keybinds when you use this mod, I've personally never had an issue with this method but I recommend <b>always</b> keeping backups of your keybinds (`Saved Games\DCS\Config\Input`) if you value them.
132+
I am not responsible for any corrupted binds when you use this mod, I've personally never had an issue with this method but I recommend <b>always</b> keeping backups of your binds (`Saved Games\DCS\Config\Input`) if you value them.

0 commit comments

Comments
 (0)