mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Make joysticks dead zone configurable (bug #5502)
This commit is contained in:
parent
c94d6336b5
commit
230e06dec7
9 changed files with 37 additions and 6 deletions
|
@ -34,6 +34,7 @@
|
|||
Bug #5485: Intimidate doesn't increase disposition on marginal wins
|
||||
Bug #5490: Hits to carried left slot aren't redistributed if there's no shield equipped
|
||||
Bug #5499: Faction advance is available when requirements not met
|
||||
Bug #5502: Dead zone for analogue stick movement is too small
|
||||
Feature #390: 3rd person look "over the shoulder"
|
||||
Feature #2386: Distant Statics in the form of Object Paging
|
||||
Feature #5297: Add a search function to the "Datafiles" tab of the OpenMW launcher
|
||||
|
|
|
@ -226,6 +226,11 @@ namespace MWInput
|
|||
}
|
||||
}
|
||||
|
||||
void BindingsManager::setJoystickDeadZone(float deadZone)
|
||||
{
|
||||
mInputBinder->setJoystickDeadZone(deadZone);
|
||||
}
|
||||
|
||||
float BindingsManager::getActionValue (int id) const
|
||||
{
|
||||
return mInputBinder->getChannel(id)->getValue();
|
||||
|
|
|
@ -36,6 +36,8 @@ namespace MWInput
|
|||
|
||||
void setPlayerControlsEnabled(bool enabled);
|
||||
|
||||
void setJoystickDeadZone(float deadZone);
|
||||
|
||||
bool isLeftOrRightButton(int action, bool joystick) const;
|
||||
|
||||
bool actionIsActive(int id) const;
|
||||
|
|
|
@ -72,6 +72,10 @@ namespace MWInput
|
|||
float uiScale = Settings::Manager::getFloat("scaling factor", "GUI");
|
||||
if (uiScale != 0.f)
|
||||
mInvUiScalingFactor = 1.f / uiScale;
|
||||
|
||||
float deadZoneRadius = Settings::Manager::getFloat("joystick dead zone", "Input");
|
||||
deadZoneRadius = std::min(std::max(deadZoneRadius, 0.0f), 0.5f);
|
||||
mBindingsManager->setJoystickDeadZone(deadZoneRadius);
|
||||
}
|
||||
|
||||
void ControllerManager::processChangedSettings(const Settings::CategorySettingVector& changed)
|
||||
|
|
|
@ -135,6 +135,18 @@ camera sensitivity setting.
|
|||
|
||||
This setting can only be configured by editing the settings configuration file.
|
||||
|
||||
joystick dead zone
|
||||
------------------
|
||||
|
||||
:Type: floating point
|
||||
:Range: 0.0 to 0.5
|
||||
:Default: 0.1
|
||||
|
||||
This setting controls the radius of dead zone (where an input is discarded) for joystick axes.
|
||||
Note that third-party software can provide its own dead zones. In this case OpenmW-specific setting dead zone can be disabled (0.0).
|
||||
|
||||
This setting can only be configured by editing the settings configuration file.
|
||||
|
||||
enable gyroscope
|
||||
----------------
|
||||
|
||||
|
|
1
extern/oics/ICSInputControlSystem.cpp
vendored
1
extern/oics/ICSInputControlSystem.cpp
vendored
|
@ -34,6 +34,7 @@ namespace ICS
|
|||
, DetectingBindingListener* detectingBindingListener
|
||||
, InputControlSystemLog* log, size_t channelCount)
|
||||
: mFileName(file)
|
||||
, mDeadZone(0.1f)
|
||||
, mLog(log)
|
||||
, mDetectingBindingListener(detectingBindingListener)
|
||||
, mDetectingBindingControl(NULL)
|
||||
|
|
4
extern/oics/ICSInputControlSystem.h
vendored
4
extern/oics/ICSInputControlSystem.h
vendored
|
@ -79,6 +79,8 @@ namespace ICS
|
|||
void setDetectingBindingListener(DetectingBindingListener* detectingBindingListener){ mDetectingBindingListener = detectingBindingListener; };
|
||||
DetectingBindingListener* getDetectingBindingListener(){ return mDetectingBindingListener; };
|
||||
|
||||
void setJoystickDeadZone(float deadZone){ mDeadZone = deadZone; };
|
||||
|
||||
// in seconds
|
||||
void update(float timeSinceLastFrame);
|
||||
|
||||
|
@ -180,6 +182,8 @@ namespace ICS
|
|||
|
||||
std::string mFileName;
|
||||
|
||||
float mDeadZone;
|
||||
|
||||
typedef std::map<SDL_Scancode, ControlKeyBinderItem> ControlsKeyBinderMapType; // <Scancode, [direction, control]>
|
||||
typedef std::map<int, ControlAxisBinderItem> ControlsAxisBinderMapType; // <axis, [direction, control]>
|
||||
typedef std::map<int, ControlButtonBinderItem> ControlsButtonBinderMapType; // <button, [direction, control]>
|
||||
|
|
|
@ -28,7 +28,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#define SDL_JOY_AXIS_MIN -32768
|
||||
#define SDL_JOY_AXIS_MAX 32767
|
||||
#define DEADZONE 0.1f
|
||||
|
||||
namespace ICS
|
||||
{
|
||||
|
@ -263,13 +262,13 @@ namespace ICS
|
|||
|
||||
float axisRange = SDL_JOY_AXIS_MAX - SDL_JOY_AXIS_MIN;
|
||||
float valDisplaced = (float)(evt.value - SDL_JOY_AXIS_MIN);
|
||||
float percent = valDisplaced / axisRange * (1+DEADZONE*2) - DEADZONE; //Assures all values, 0 through 1, are seen
|
||||
if(percent > .5-DEADZONE && percent < .5+DEADZONE) //close enough to center
|
||||
float percent = valDisplaced / axisRange * (1+mDeadZone*2) - mDeadZone; //Assures all values, 0 through 1, are seen
|
||||
if(percent > .5-mDeadZone && percent < .5+mDeadZone) //close enough to center
|
||||
percent = .5;
|
||||
else if(percent > .5)
|
||||
percent -= DEADZONE;
|
||||
percent -= mDeadZone;
|
||||
else
|
||||
percent += DEADZONE;
|
||||
percent += mDeadZone;
|
||||
|
||||
if(joystickBinderItem.direction == Control::INCREASE)
|
||||
{
|
||||
|
|
|
@ -421,6 +421,9 @@ enable controller = true
|
|||
# Emulated gamepad cursor sensitivity.
|
||||
gamepad cursor speed = 1.0
|
||||
|
||||
# Set dead zone for joysticks (gamepad or on-screen ones)
|
||||
joystick dead zone = 0.1
|
||||
|
||||
# Enable gyroscope support.
|
||||
enable gyroscope = false
|
||||
|
||||
|
|
Loading…
Reference in a new issue