-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AH-64D: Add Power Lever controls for Idle/Off and Finger Lifts
Fixes #999 Also moves engine power lever to Left Console category. Finger lift and Idle/Off controls do not work for CP/G, which seems to be a module limitation.
- Loading branch information
1 parent
69b5647
commit 16ec5e1
Showing
7 changed files
with
196 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module("ICommand", package.seeall) | ||
|
||
--- @enum ICommand | ||
local ICommand = { | ||
left_engine_start = 311, | ||
right_engine_start = 312, | ||
left_engine_stop = 313, | ||
right_engine_stop = 314, | ||
} | ||
|
||
return ICommand |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
Scripts/DCS-BIOS/test/controls/InputOnlySetStatePushButtonTest.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
local ControlType = require("Scripts.DCS-BIOS.lib.modules.documentation.ControlType") | ||
local InputType = require("Scripts.DCS-BIOS.lib.modules.documentation.InputType") | ||
local MockDevice = require("Scripts.DCS-BIOS.test.controls.MockDevice") | ||
local Module = require("Scripts.DCS-BIOS.lib.modules.Module") | ||
|
||
local lu = require("Scripts.DCS-BIOS.test.ext.luaunit") | ||
|
||
--- @class TestInputOnlySetStatePushButton | ||
--- @field module Module | ||
TestInputOnlySetStatePushButton = {} | ||
local moduleName = "MyModule" | ||
local moduleAddress = 0x4200 | ||
|
||
function TestInputOnlySetStatePushButton:setUp() | ||
self.module = Module:new(moduleName, moduleAddress, {}) | ||
Input_Processor_Device = MockDevice:new(0) | ||
end | ||
|
||
local id = "MY_INPUT_ONLY_SET_STATE_PUSH_BUTTON" | ||
local device_id = 1 | ||
local command = 2 | ||
local category = "Input-Only Set State Push Buttons" | ||
local description = "This is an input-only set state push button" | ||
|
||
function TestInputOnlySetStatePushButton:testAddPushButton() | ||
local control = self.module:defineInputOnlySetStatePushButton(id, device_id, command, category, description) | ||
|
||
lu.assertEquals(control, self.module.documentation[category][id]) | ||
lu.assertEquals(control.control_type, ControlType.action) | ||
lu.assertEquals(control.category, category) | ||
lu.assertEquals(control.description, description) | ||
lu.assertEquals(control.identifier, id) | ||
lu.assertIsNil(control.api_variant) | ||
|
||
lu.assertEquals(#control.inputs, 1) | ||
|
||
local set_state_input = control.inputs[1] --[[@as SetStateInput]] | ||
lu.assertEquals(set_state_input.interface, InputType.set_state) | ||
lu.assertEquals(set_state_input.max_value, 1) | ||
|
||
lu.assertEquals(#control.outputs, 0) | ||
end | ||
|
||
function TestInputOnlySetStatePushButton:testInput0() | ||
self.module:defineInputOnlySetStatePushButton(id, device_id, command, category, description) | ||
local input_processor = self.module.inputProcessors[id] | ||
|
||
input_processor("0") | ||
|
||
lu.assertEquals(#Input_Processor_Device.clickable_actions, 1) | ||
local action_press = Input_Processor_Device.clickable_actions[1] | ||
lu.assertAlmostEquals(action_press[command], 0) | ||
end | ||
|
||
function TestInputOnlySetStatePushButton:testInput1() | ||
self.module:defineInputOnlySetStatePushButton(id, device_id, command, category, description) | ||
local input_processor = self.module.inputProcessors[id] | ||
|
||
input_processor("1") | ||
|
||
lu.assertEquals(#Input_Processor_Device.clickable_actions, 1) | ||
local action_press = Input_Processor_Device.clickable_actions[1] | ||
lu.assertAlmostEquals(action_press[command], 1) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
local ActionArgument = require("Scripts.DCS-BIOS.lib.modules.documentation.ActionArgument") | ||
local ControlType = require("Scripts.DCS-BIOS.lib.modules.documentation.ControlType") | ||
local ICommand = require("Scripts.DCS-BIOS.lib.modules.ICommand") | ||
local InputType = require("Scripts.DCS-BIOS.lib.modules.documentation.InputType") | ||
local MockDevice = require("Scripts.DCS-BIOS.test.controls.MockDevice") | ||
local Module = require("Scripts.DCS-BIOS.lib.modules.Module") | ||
|
||
local lu = require("Scripts.DCS-BIOS.test.ext.luaunit") | ||
|
||
--- @class TestLoSetCommand | ||
--- @field module Module | ||
TestLoSetCommand = {} | ||
local moduleName = "MyModule" | ||
local moduleAddress = 0x4200 | ||
|
||
function TestLoSetCommand:setUp() | ||
self.module = Module:new(moduleName, moduleAddress, {}) | ||
Input_Processor_Device = MockDevice:new(0) | ||
end | ||
|
||
local id = "MY_LO_SET_COMMAND" | ||
local iCommand = ICommand.left_engine_start | ||
local category = "LoSetCommands" | ||
local description = "This is a LoSetCommand" | ||
|
||
function TestLoSetCommand:testAddLoSetCommand() | ||
local control = self.module:defineLoSetCommand(id, iCommand, category, description) | ||
|
||
lu.assertEquals(control, self.module.documentation[category][id]) | ||
lu.assertEquals(control.control_type, ControlType.action) | ||
lu.assertEquals(control.category, category) | ||
lu.assertEquals(control.description, description) | ||
lu.assertEquals(control.identifier, id) | ||
lu.assertIsNil(control.api_variant) | ||
|
||
lu.assertEquals(#control.inputs, 1) | ||
|
||
local action_input = control.inputs[1] --[[@as ActionInput]] | ||
lu.assertEquals(action_input.interface, InputType.action) | ||
lu.assertEquals(action_input.argument, ActionArgument.toggle) | ||
|
||
lu.assertEquals(#control.outputs, 0) | ||
end | ||
|
||
function LoSetCommand(iCommand) | ||
lu.assertEquals(ICommand.left_engine_start, iCommand) | ||
end | ||
|
||
function TestLoSetCommand:testLoSetCommand() | ||
self.module:defineLoSetCommand(id, iCommand, category, description) | ||
local input_processor = self.module.inputProcessors[id] | ||
|
||
input_processor("TOGGLE") | ||
end |