Added 'isAnalog' functionality to avoid that gamepads on full left/right
steering will delay steering because of time-full-steer. Added some virtual destructors.
This commit is contained in:
parent
4986deebd6
commit
e2d17bcf88
@ -75,6 +75,8 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
virtual ~DeviceConfig() {}
|
||||||
|
|
||||||
static DeviceConfig* create(const XMLNode *config);
|
static DeviceConfig* create(const XMLNode *config);
|
||||||
irr::core::stringw toString();
|
irr::core::stringw toString();
|
||||||
bool hasBindingFor(const int buttonID) const;
|
bool hasBindingFor(const int buttonID) const;
|
||||||
@ -97,6 +99,11 @@ public:
|
|||||||
|
|
||||||
virtual void save(std::ofstream& stream);
|
virtual void save(std::ofstream& stream);
|
||||||
virtual bool load(const XMLNode *config);
|
virtual bool load(const XMLNode *config);
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
/** Returns true if this device has analog axis, so that steering values
|
||||||
|
* will not be affected by time-full-steer delays. */
|
||||||
|
virtual bool isAnalog() const { return false;}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Should only be called for gamepads, which has its own implementation.
|
/** Should only be called for gamepads, which has its own implementation.
|
||||||
* of this function. */
|
* of this function. */
|
||||||
|
@ -45,7 +45,8 @@ GamepadConfig::GamepadConfig( const std::string &name,
|
|||||||
|
|
||||||
GamepadConfig::GamepadConfig() : DeviceConfig()
|
GamepadConfig::GamepadConfig() : DeviceConfig()
|
||||||
{
|
{
|
||||||
m_deadzone = 2000;
|
m_deadzone = 2000;
|
||||||
|
m_is_analog = true;
|
||||||
setDefaultBinds();
|
setDefaultBinds();
|
||||||
} // GamepadConfig
|
} // GamepadConfig
|
||||||
|
|
||||||
@ -57,6 +58,7 @@ GamepadConfig::GamepadConfig() : DeviceConfig()
|
|||||||
bool GamepadConfig::load(const XMLNode *config)
|
bool GamepadConfig::load(const XMLNode *config)
|
||||||
{
|
{
|
||||||
config->get("deadzone", &m_deadzone);
|
config->get("deadzone", &m_deadzone);
|
||||||
|
config->get("analog", &m_is_analog);
|
||||||
bool ok = DeviceConfig::load(config);
|
bool ok = DeviceConfig::load(config);
|
||||||
|
|
||||||
if(getName()=="")
|
if(getName()=="")
|
||||||
@ -77,7 +79,8 @@ bool GamepadConfig::load(const XMLNode *config)
|
|||||||
void GamepadConfig::save (std::ofstream& stream)
|
void GamepadConfig::save (std::ofstream& stream)
|
||||||
{
|
{
|
||||||
stream << "<gamepad name =\"" << getName()
|
stream << "<gamepad name =\"" << getName()
|
||||||
<<"\" deadzone=\""<<m_deadzone << "\"\n";
|
<< "\" deadzone=\"" << m_deadzone
|
||||||
|
<< "\" analog=\"" << m_is_analog<<"\"\n";
|
||||||
stream << " ";
|
stream << " ";
|
||||||
DeviceConfig::save(stream);
|
DeviceConfig::save(stream);
|
||||||
stream << "</gamepad>\n\n";
|
stream << "</gamepad>\n\n";
|
||||||
|
@ -46,16 +46,21 @@ private:
|
|||||||
/** Deadzone of this gamepad. */
|
/** Deadzone of this gamepad. */
|
||||||
int m_deadzone;
|
int m_deadzone;
|
||||||
|
|
||||||
|
/** If this device has analog axis, steering etc. must be set immediately
|
||||||
|
* from the input values, not having a delayed time (time-full-steer). */
|
||||||
|
bool m_is_analog;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
irr::core::stringw toString ();
|
GamepadConfig ();
|
||||||
|
GamepadConfig(const std::string &name,
|
||||||
|
const int axis_count=0,
|
||||||
|
const int button_ount=0);
|
||||||
|
virtual ~GamepadConfig() {}
|
||||||
|
|
||||||
|
irr::core::stringw toString();
|
||||||
|
|
||||||
virtual void save(std::ofstream& stream);
|
virtual void save(std::ofstream& stream);
|
||||||
void setDefaultBinds ();
|
void setDefaultBinds ();
|
||||||
GamepadConfig ();
|
|
||||||
GamepadConfig (const std::string &name,
|
|
||||||
const int axis_count=0,
|
|
||||||
const int button_ount=0);
|
|
||||||
virtual bool load(const XMLNode *config) OVERRIDE;
|
virtual bool load(const XMLNode *config) OVERRIDE;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@ -69,10 +74,10 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Returns the number of axis of this configufation. */
|
/** Returns the number of axis of this configufation. */
|
||||||
virtual int getNumberOfAxes() const OVERRIDE { return m_axis_count; }
|
virtual int getNumberOfAxes() const OVERRIDE { return m_axis_count; }
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Sets the number of axis this device has. */
|
/** Sets the number of axis this device has. */
|
||||||
void setNumberOfAxis(int count) { m_axis_count = count; }
|
void setNumberOfAxis(int count) { m_axis_count = count; }
|
||||||
// ~GamepadConfig();
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
/** Return deadzone of this configuration. */
|
/** Return deadzone of this configuration. */
|
||||||
|
@ -161,6 +161,17 @@ bool GamePadDevice::processAndMapInput(Input::InputType type, const int id,
|
|||||||
{
|
{
|
||||||
if (!m_configuration->isEnabled()) return false;
|
if (!m_configuration->isEnabled()) return false;
|
||||||
|
|
||||||
|
// A digital input value is 32767 or -32768 (which then triggers
|
||||||
|
// time-full-steer to be used to adjust actual steering values.
|
||||||
|
// To prevent this delay for analog gamesticks, make sure that
|
||||||
|
// 32767/-32768 are never used.
|
||||||
|
if(m_configuration->isAnalog())
|
||||||
|
{
|
||||||
|
if(*value==32767)
|
||||||
|
*value = 32766;
|
||||||
|
else if(*value==-32768)
|
||||||
|
*value = -32767;
|
||||||
|
}
|
||||||
bool success = false;
|
bool success = false;
|
||||||
if(m_prev_axis_directions == NULL) return false; // device not open
|
if(m_prev_axis_directions == NULL) return false; // device not open
|
||||||
|
|
||||||
|
@ -36,10 +36,12 @@ class KeyboardConfig : public DeviceConfig
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
KeyboardConfig();
|
||||||
|
virtual ~KeyboardConfig() {}
|
||||||
|
|
||||||
void setDefaultBinds ();
|
void setDefaultBinds ();
|
||||||
virtual void save(std::ofstream& stream);
|
virtual void save(std::ofstream& stream);
|
||||||
|
|
||||||
KeyboardConfig ();
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
virtual bool isGamePad() const { return false; }
|
virtual bool isGamePad() const { return false; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user