mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-21 12:23:51 +00:00
Merge pull request #2940 from akortunov/deadzone
Make joysticks dead zone configurable
This commit is contained in:
commit
c53516a4b7
9 changed files with 37 additions and 6 deletions
|
@ -34,6 +34,7 @@
|
||||||
Bug #5485: Intimidate doesn't increase disposition on marginal wins
|
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 #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 #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 #390: 3rd person look "over the shoulder"
|
||||||
Feature #2386: Distant Statics in the form of Object Paging
|
Feature #2386: Distant Statics in the form of Object Paging
|
||||||
Feature #5297: Add a search function to the "Datafiles" tab of the OpenMW launcher
|
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
|
float BindingsManager::getActionValue (int id) const
|
||||||
{
|
{
|
||||||
return mInputBinder->getChannel(id)->getValue();
|
return mInputBinder->getChannel(id)->getValue();
|
||||||
|
|
|
@ -36,6 +36,8 @@ namespace MWInput
|
||||||
|
|
||||||
void setPlayerControlsEnabled(bool enabled);
|
void setPlayerControlsEnabled(bool enabled);
|
||||||
|
|
||||||
|
void setJoystickDeadZone(float deadZone);
|
||||||
|
|
||||||
bool isLeftOrRightButton(int action, bool joystick) const;
|
bool isLeftOrRightButton(int action, bool joystick) const;
|
||||||
|
|
||||||
bool actionIsActive(int id) const;
|
bool actionIsActive(int id) const;
|
||||||
|
|
|
@ -72,6 +72,10 @@ namespace MWInput
|
||||||
float uiScale = Settings::Manager::getFloat("scaling factor", "GUI");
|
float uiScale = Settings::Manager::getFloat("scaling factor", "GUI");
|
||||||
if (uiScale != 0.f)
|
if (uiScale != 0.f)
|
||||||
mInvUiScalingFactor = 1.f / uiScale;
|
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)
|
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.
|
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
|
enable gyroscope
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
|
1
extern/oics/ICSInputControlSystem.cpp
vendored
1
extern/oics/ICSInputControlSystem.cpp
vendored
|
@ -34,6 +34,7 @@ namespace ICS
|
||||||
, DetectingBindingListener* detectingBindingListener
|
, DetectingBindingListener* detectingBindingListener
|
||||||
, InputControlSystemLog* log, size_t channelCount)
|
, InputControlSystemLog* log, size_t channelCount)
|
||||||
: mFileName(file)
|
: mFileName(file)
|
||||||
|
, mDeadZone(0.1f)
|
||||||
, mLog(log)
|
, mLog(log)
|
||||||
, mDetectingBindingListener(detectingBindingListener)
|
, mDetectingBindingListener(detectingBindingListener)
|
||||||
, mDetectingBindingControl(NULL)
|
, 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; };
|
void setDetectingBindingListener(DetectingBindingListener* detectingBindingListener){ mDetectingBindingListener = detectingBindingListener; };
|
||||||
DetectingBindingListener* getDetectingBindingListener(){ return mDetectingBindingListener; };
|
DetectingBindingListener* getDetectingBindingListener(){ return mDetectingBindingListener; };
|
||||||
|
|
||||||
|
void setJoystickDeadZone(float deadZone){ mDeadZone = deadZone; };
|
||||||
|
|
||||||
// in seconds
|
// in seconds
|
||||||
void update(float timeSinceLastFrame);
|
void update(float timeSinceLastFrame);
|
||||||
|
|
||||||
|
@ -180,6 +182,8 @@ namespace ICS
|
||||||
|
|
||||||
std::string mFileName;
|
std::string mFileName;
|
||||||
|
|
||||||
|
float mDeadZone;
|
||||||
|
|
||||||
typedef std::map<SDL_Scancode, ControlKeyBinderItem> ControlsKeyBinderMapType; // <Scancode, [direction, control]>
|
typedef std::map<SDL_Scancode, ControlKeyBinderItem> ControlsKeyBinderMapType; // <Scancode, [direction, control]>
|
||||||
typedef std::map<int, ControlAxisBinderItem> ControlsAxisBinderMapType; // <axis, [direction, control]>
|
typedef std::map<int, ControlAxisBinderItem> ControlsAxisBinderMapType; // <axis, [direction, control]>
|
||||||
typedef std::map<int, ControlButtonBinderItem> ControlsButtonBinderMapType; // <button, [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_MIN -32768
|
||||||
#define SDL_JOY_AXIS_MAX 32767
|
#define SDL_JOY_AXIS_MAX 32767
|
||||||
#define DEADZONE 0.1f
|
|
||||||
|
|
||||||
namespace ICS
|
namespace ICS
|
||||||
{
|
{
|
||||||
|
@ -263,13 +262,13 @@ namespace ICS
|
||||||
|
|
||||||
float axisRange = SDL_JOY_AXIS_MAX - SDL_JOY_AXIS_MIN;
|
float axisRange = SDL_JOY_AXIS_MAX - SDL_JOY_AXIS_MIN;
|
||||||
float valDisplaced = (float)(evt.value - 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
|
float percent = valDisplaced / axisRange * (1+mDeadZone*2) - mDeadZone; //Assures all values, 0 through 1, are seen
|
||||||
if(percent > .5-DEADZONE && percent < .5+DEADZONE) //close enough to center
|
if(percent > .5-mDeadZone && percent < .5+mDeadZone) //close enough to center
|
||||||
percent = .5;
|
percent = .5;
|
||||||
else if(percent > .5)
|
else if(percent > .5)
|
||||||
percent -= DEADZONE;
|
percent -= mDeadZone;
|
||||||
else
|
else
|
||||||
percent += DEADZONE;
|
percent += mDeadZone;
|
||||||
|
|
||||||
if(joystickBinderItem.direction == Control::INCREASE)
|
if(joystickBinderItem.direction == Control::INCREASE)
|
||||||
{
|
{
|
||||||
|
|
|
@ -418,6 +418,9 @@ enable controller = true
|
||||||
# Emulated gamepad cursor sensitivity.
|
# Emulated gamepad cursor sensitivity.
|
||||||
gamepad cursor speed = 1.0
|
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 support.
|
||||||
enable gyroscope = false
|
enable gyroscope = false
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue