Inital value for joysticks is 0.5

celladd
Digmaster 10 years ago
parent 073a2f0674
commit ad54e09593

@ -1120,11 +1120,13 @@ namespace MWInput
if (defaultKeyBindings.find(i) != defaultKeyBindings.end()
&& !mInputBinder->isKeyBound(defaultKeyBindings[i]))
{
control->setInitialValue(0.0f);
mInputBinder->addKeyBinding(control, defaultKeyBindings[i], ICS::Control::INCREASE);
}
else if (defaultMouseButtonBindings.find(i) != defaultMouseButtonBindings.end()
&& !mInputBinder->isMouseButtonBound(defaultMouseButtonBindings[i]))
{
control->setInitialValue(0.0f);
mInputBinder->addMouseButtonBinding (control, defaultMouseButtonBindings[i], ICS::Control::INCREASE);
}
}
@ -1167,7 +1169,11 @@ namespace MWInput
bool controlExists = mInputBinder->getChannel(i)->getControlsCount () != 0;
if (!controlExists)
{
control = new ICS::Control(boost::lexical_cast<std::string>(i), false, true, 0, ICS::ICS_MAX, ICS::ICS_MAX);
int inital;
if (defaultButtonBindings.find(i) != defaultButtonBindings.end())
inital = 0.0f;
else inital = 0.5f;
control = new ICS::Control(boost::lexical_cast<std::string>(i), false, true, inital, ICS::ICS_MAX, ICS::ICS_MAX);
mInputBinder->addControl(control);
control->attachChannel(mInputBinder->getChannel(i), ICS::Channel::DIRECT);
}
@ -1182,11 +1188,13 @@ namespace MWInput
if (defaultButtonBindings.find(i) != defaultButtonBindings.end())
{
control->setValue(0.5f);
control->setInitialValue(0.0f);
mInputBinder->addJoystickButtonBinding(control, defaultButtonBindings[i], ICS::Control::INCREASE);
}
else if (defaultAxisBindings.find(i) != defaultAxisBindings.end())
{
control->setValue(0.5f);
control->setInitialValue(0.5f);
mInputBinder->addJoystickAxisBinding(control, defaultAxisBindings[i], ICS::Control::INCREASE);
}
}
@ -1426,6 +1434,7 @@ namespace MWInput
return;
clearAllKeyBindings(control);
control->setInitialValue(0.0f);
ICS::DetectingBindingListener::keyBindingDetected (ICS, control, key, direction);
MWBase::Environment::get().getWindowManager ()->notifyInputActionBound ();
}
@ -1436,6 +1445,7 @@ namespace MWInput
if(!mDetectingKeyboard)
return;
clearAllKeyBindings(control);
control->setInitialValue(0.0f);
ICS::DetectingBindingListener::mouseButtonBindingDetected (ICS, control, button, direction);
MWBase::Environment::get().getWindowManager ()->notifyInputActionBound ();
}
@ -1451,6 +1461,7 @@ namespace MWInput
clearAllControllerBindings(control);
control->setValue(0.5f); //axis bindings must start at 0.5
control->setInitialValue(0.5f);
ICS::DetectingBindingListener::joystickAxisBindingDetected (ICS, control, axis, direction);
MWBase::Environment::get().getWindowManager ()->notifyInputActionBound ();
}
@ -1461,6 +1472,7 @@ namespace MWInput
if(mDetectingKeyboard)
return;
clearAllControllerBindings(control);
control->setInitialValue(0.0f);
ICS::DetectingBindingListener::joystickButtonBindingDetected (ICS, control, button, direction);
MWBase::Environment::get().getWindowManager ()->notifyInputActionBound ();
}

@ -34,7 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
namespace ICS
{
class DllExport Control
{
public:
@ -52,9 +52,10 @@ namespace ICS
void setValue(float value);
inline float getValue(){ return mValue; };
inline float getInitialValue(){ return mInitialValue; };
inline float getInitialValue(){ return mInitialValue; };
inline void setInitialValue(float i) {mInitialValue = i;};
void attachChannel(Channel* channel, Channel::ChannelDirection direction, float percentage = 1.0);
void attachChannel(Channel* channel, Channel::ChannelDirection direction, float percentage = 1.0);
std::list<Channel*> getAttachedChannels(){ return mAttachedChannels; };
inline float getStepSize(){ return mStepSize; };

@ -278,6 +278,7 @@ namespace ICS
/* Joystick Init */
//Load controller mappings
#if SDL_VERSION_ATLEAST(2,0,2)
int res = SDL_GameControllerAddMappingsFromFile("resources/gamecontrollerdb.txt");
if(res == -1)
{
@ -287,6 +288,7 @@ namespace ICS
{
ICS_LOG(std::string("Loaded ")+boost::lexical_cast<std::string>(res)+" Game controller bindings");
}
#endif
//Open all presently connected sticks
int numSticks = SDL_NumJoysticks();

Loading…
Cancel
Save