Update multitouch device when settings are changed

This commit is contained in:
Deve 2016-12-20 23:05:26 +01:00
parent 082661db65
commit 53ee40af70
3 changed files with 29 additions and 8 deletions

View File

@ -44,11 +44,7 @@ MultitouchDevice::MultitouchDevice()
event.y = 0;
}
m_deadzone_center = UserConfigParams::m_multitouch_deadzone_center;
m_deadzone_center = std::min(std::max(m_deadzone_center, 0.0f), 0.5f);
m_deadzone_edge = UserConfigParams::m_multitouch_deadzone_edge;
m_deadzone_edge = std::min(std::max(m_deadzone_edge, 0.0f), 0.5f);
updateConfigParams();
} // MultitouchDevice
// ----------------------------------------------------------------------------
@ -225,6 +221,18 @@ void MultitouchDevice::updateDeviceState(unsigned int event_id)
}
} // updateDeviceState
// ----------------------------------------------------------------------------
/** Updates config parameters i.e. when they are modified in options
*/
void MultitouchDevice::updateConfigParams()
{
m_deadzone_center = UserConfigParams::m_multitouch_deadzone_center;
m_deadzone_center = std::min(std::max(m_deadzone_center, 0.0f), 0.5f);
m_deadzone_edge = UserConfigParams::m_multitouch_deadzone_edge;
m_deadzone_edge = std::min(std::max(m_deadzone_edge, 0.0f), 0.5f);
} // updateConfigParams
// ----------------------------------------------------------------------------
/** Helper function that returns a steering factor for steering button.
* \param value The axis value from 0 to 1.

View File

@ -107,6 +107,8 @@ public:
void updateDeviceState(unsigned int event_id);
void handleControls(MultitouchButton* button);
void updateConfigParams();
}; // MultitouchDevice

View File

@ -19,6 +19,9 @@
#include "config/user_config.hpp"
#include "guiengine/widgets/spinner_widget.hpp"
#include "input/device_manager.hpp"
#include "input/input_manager.hpp"
#include "input/multitouch_device.hpp"
#include "utils/translation.hpp"
#include <IGUIEnvironment.h>
@ -59,18 +62,26 @@ GUIEngine::EventPropagation MultitouchSettingsDialog::processEvent(
{
SpinnerWidget* scale = getWidget<SpinnerWidget>("scale");
assert(scale != NULL);
UserConfigParams::m_multitouch_scale = scale->getValue() / 100.0f;
UserConfigParams::m_multitouch_scale = (float)scale->getValue() / 100.0f;
SpinnerWidget* deadzone_edge = getWidget<SpinnerWidget>("deadzone_edge");
assert(deadzone_edge != NULL);
UserConfigParams::m_multitouch_deadzone_edge =
deadzone_edge->getValue() / 100.0f;
(float)deadzone_edge->getValue() / 100.0f;
SpinnerWidget* deadzone_center = getWidget<SpinnerWidget>("deadzone_center");
assert(deadzone_center != NULL);
UserConfigParams::m_multitouch_deadzone_center =
deadzone_center->getValue() / 100.0f;
(float)deadzone_center->getValue() / 100.0f;
MultitouchDevice* touch_device = input_manager->getDeviceManager()->
getMultitouchDevice();
if (touch_device != NULL)
{
touch_device->updateConfigParams();
}
user_config->saveConfig();
ModalDialog::dismiss();