Merge branch 'one_handed_controls' into 'master'

Draft: Add accessibility options to lua controls, including one handed controls and hold-free swinging

See merge request OpenMW/openmw!4736
This commit is contained in:
Skyhasacat 2025-08-02 08:46:24 +00:00
commit b8fbe84dad
3 changed files with 34 additions and 7 deletions

View File

@ -17,6 +17,14 @@ smoothControllerMovement: "Smooth Controller Movement"
smoothControllerMovementDescription: | smoothControllerMovementDescription: |
Enables smooth controller stick movement. This makes the transition from walking to running less abrupt. Enables smooth controller stick movement. This makes the transition from walking to running less abrupt.
oneHandedControls: "One Handed Controls"
oneHandedControlsDescription: |
Changes the controls so the normal A and D controls will instead move the camera left and right.
automaticWeaponHit: "Automatic Weapon Hit"
automaticWeaponHitDescription: |
Will cause the weapon swing to be held for a moment and swing automatically, so holding the key isn't necessary.
TogglePOV_name: "Toggle POV" TogglePOV_name: "Toggle POV"
TogglePOV_description: "Toggle between first and third person view. Hold to enter preview mode." TogglePOV_description: "Toggle between first and third person view. Hold to enter preview mode."

View File

@ -84,7 +84,7 @@ local movementControlsOverridden = false
local autoMove = false local autoMove = false
local attemptToJump = false local attemptToJump = false
local function processMovement() local function processMovement(dt)
local movement = input.getRangeActionValue('MoveForward') - input.getRangeActionValue('MoveBackward') local movement = input.getRangeActionValue('MoveForward') - input.getRangeActionValue('MoveBackward')
local sideMovement = input.getRangeActionValue('MoveRight') - input.getRangeActionValue('MoveLeft') local sideMovement = input.getRangeActionValue('MoveRight') - input.getRangeActionValue('MoveLeft')
local run = input.getBooleanActionValue('Run') ~= settings:get('alwaysRun') local run = input.getBooleanActionValue('Run') ~= settings:get('alwaysRun')
@ -94,9 +94,15 @@ local function processMovement()
elseif autoMove then elseif autoMove then
movement = 1 movement = 1
end end
local turnSpeed = 4--to be replaced with setting
if settings:get("oneHandedControls") then
if sideMovement ~= 0 then
self.controls.yawChange = (sideMovement * dt) * turnSpeed
end
else
self.controls.sideMovement = sideMovement
end
self.controls.movement = movement self.controls.movement = movement
self.controls.sideMovement = sideMovement
self.controls.run = run self.controls.run = run
self.controls.jump = attemptToJump self.controls.jump = attemptToJump
@ -167,13 +173,23 @@ local startUse = false
input.registerActionHandler('Use', async:callback(function(value) input.registerActionHandler('Use', async:callback(function(value)
if value and combatAllowed() then startUse = true end if value and combatAllowed() then startUse = true end
end)) end))
local function processAttacking() local swingStart = 0
local swingLength = 0.3
local function processAttacking(dt)
-- for spell-casting, set controls.use to true for exactly one frame -- for spell-casting, set controls.use to true for exactly one frame
-- otherwise spell casting is attempted every frame while Use is true -- otherwise spell casting is attempted every frame while Use is true
if Actor.getStance(self) == Actor.STANCE.Spell then if Actor.getStance(self) == Actor.STANCE.Spell then
self.controls.use = startUse and 1 or 0 self.controls.use = startUse and 1 or 0
elseif Actor.getStance(self) == Actor.STANCE.Weapon and input.getBooleanActionValue('Use') then elseif Actor.getStance(self) == Actor.STANCE.Weapon and input.getBooleanActionValue('Use') then
self.controls.use = 1 self.controls.use = 1
if settings:get("automaticWeaponHit") then
swingStart = swingLength
end
end
if swingStart > 0 and Actor.getStance(self) == Actor.STANCE.Weapon then
swingStart = swingStart - dt
self.controls.use = 1
else else
self.controls.use = 0 self.controls.use = 0
end end
@ -216,16 +232,16 @@ input.registerTriggerHandler('QuickKeysMenu', async:callback(function()
end end
end)) end))
local function onFrame(_) local function onFrame(dt)
if movementAllowed() then if movementAllowed() then
processMovement() processMovement(dt)
elseif not movementControlsOverridden then elseif not movementControlsOverridden then
self.controls.movement = 0 self.controls.movement = 0
self.controls.sideMovement = 0 self.controls.sideMovement = 0
self.controls.jump = false self.controls.jump = false
end end
if combatAllowed() then if combatAllowed() then
processAttacking() processAttacking(dt)
end end
attemptToJump = false attemptToJump = false
end end

View File

@ -35,6 +35,9 @@ I.Settings.registerGroup({
boolSetting('alwaysRun', false), boolSetting('alwaysRun', false),
boolSetting('toggleSneak', false), -- TODO: consider removing this setting when we have the advanced binding UI boolSetting('toggleSneak', false), -- TODO: consider removing this setting when we have the advanced binding UI
boolSetting('smoothControllerMovement', true), boolSetting('smoothControllerMovement', true),
--should probably be in an accessibility section
boolSetting('oneHandedControls', false),
boolSetting('automaticWeaponHit', false),
}, },
}) })