Add a possibility to disable touch steering in options.

It may be useful if someone wants to play with external keyboard.
The multitouch_mode parameter will be also used to choose between steering with buttons and using accelerometer.
This commit is contained in:
Deve 2017-01-25 21:46:07 +01:00
parent 9ede4d2185
commit 49a77a8f48
7 changed files with 52 additions and 30 deletions

View File

@ -9,6 +9,16 @@
<spacer height="15" width="10"/>
<div width="75%" height="fit" layout="horizontal-row" >
<label proportion="1" height="100%" text_align="right" I18N="In the multitouch settings screen" text="Device enabled"/>
<div proportion="1" height="fit" layout="horizontal-row" >
<spacer width="40" height="100%" />
<checkbox id="buttons_enabled" width="40" height="40"/>
</div>
</div>
<spacer height="15" width="10"/>
<div width="75%" height="fit" layout="horizontal-row" >
<label proportion="1" height="100%" text_align="right" I18N="In the multitouch settings screen" text="Buttons scale"/>
<div proportion="1" height="fit" layout="horizontal-row" >

View File

@ -408,6 +408,11 @@ namespace UserConfigParams
PARAM_DEFAULT( BoolUserConfigParam(false, "multitouch_enabled",
&m_multitouch_group,
"Enable multitouch support.") );
PARAM_PREFIX IntUserConfigParam m_multitouch_mode
PARAM_DEFAULT( IntUserConfigParam(1, "multitouch_mode",
&m_multitouch_group,
"Steering mode: 0 = off, 1 = buttons, 2 = accelerometer") );
PARAM_PREFIX FloatUserConfigParam m_multitouch_deadzone_center
PARAM_DEFAULT( FloatUserConfigParam(0.1f, "multitouch_deadzone_center",

View File

@ -1129,30 +1129,26 @@ EventPropagation InputManager::input(const SEvent& event)
// Simulate touch event on non-android devices
#if !defined(ANDROID)
if (UserConfigParams::m_multitouch_enabled == true &&
(type == EMIE_LMOUSE_PRESSED_DOWN || type == EMIE_LMOUSE_LEFT_UP ||
type == EMIE_MOUSE_MOVED))
MultitouchDevice* device = m_device_manager->getMultitouchDevice();
if (device != NULL && (type == EMIE_LMOUSE_PRESSED_DOWN ||
type == EMIE_LMOUSE_LEFT_UP || type == EMIE_MOUSE_MOVED))
{
MultitouchDevice* device = m_device_manager->getMultitouchDevice();
device->m_events[0].id = 0;
device->m_events[0].x = event.MouseInput.X;
device->m_events[0].y = event.MouseInput.Y;
if (device != NULL)
if (type == EMIE_LMOUSE_PRESSED_DOWN)
{
device->m_events[0].id = 0;
device->m_events[0].x = event.MouseInput.X;
device->m_events[0].y = event.MouseInput.Y;
if (type == EMIE_LMOUSE_PRESSED_DOWN)
{
device->m_events[0].touched = true;
}
else if (type == EMIE_LMOUSE_LEFT_UP)
{
device->m_events[0].touched = false;
}
m_device_manager->updateMultitouchDevice();
device->updateDeviceState(0);
device->m_events[0].touched = true;
}
else if (type == EMIE_LMOUSE_LEFT_UP)
{
device->m_events[0].touched = false;
}
m_device_manager->updateMultitouchDevice();
device->updateDeviceState(0);
}
#endif

View File

@ -18,6 +18,7 @@
#include "states_screens/dialogs/multitouch_settings_dialog.hpp"
#include "config/user_config.hpp"
#include "guiengine/widgets/check_box_widget.hpp"
#include "guiengine/widgets/spinner_widget.hpp"
#include "input/device_manager.hpp"
#include "input/input_manager.hpp"
@ -73,10 +74,14 @@ GUIEngine::EventPropagation MultitouchSettingsDialog::processEvent(
assert(deadzone_center != NULL);
UserConfigParams::m_multitouch_deadzone_center =
(float)deadzone_center->getValue() / 100.0f;
CheckBoxWidget* buttons_en = getWidget<CheckBoxWidget>("buttons_enabled");
assert(buttons_en != NULL);
UserConfigParams::m_multitouch_mode = buttons_en->getState() ? 1 : 0;
MultitouchDevice* touch_device = input_manager->getDeviceManager()->
getMultitouchDevice();
if (touch_device != NULL)
{
touch_device->updateConfigParams();
@ -92,6 +97,7 @@ GUIEngine::EventPropagation MultitouchSettingsDialog::processEvent(
UserConfigParams::m_multitouch_scale.revertToDefaults();
UserConfigParams::m_multitouch_deadzone_edge.revertToDefaults();
UserConfigParams::m_multitouch_deadzone_center.revertToDefaults();
UserConfigParams::m_multitouch_mode.revertToDefaults();
updateValues();
@ -118,6 +124,10 @@ void MultitouchSettingsDialog::updateValues()
assert(deadzone_center != NULL);
deadzone_center->setValue(
(int)(UserConfigParams::m_multitouch_deadzone_center * 100.0f));
CheckBoxWidget* buttons_en = getWidget<CheckBoxWidget>("buttons_enabled");
assert(buttons_en != NULL);
buttons_en->setState(UserConfigParams::m_multitouch_mode);
}
// -----------------------------------------------------------------------------

View File

@ -85,7 +85,7 @@ RaceGUI::RaceGUI()
const float top_margin = 3.5f * m_font_height;
// Check if we have enough space for minimap when touch steering is enabled
if (UserConfigParams::m_multitouch_enabled)
if (m_multitouch_gui != NULL)
{
const float map_bottom = (float)(m_multitouch_gui->getMinimapBottom());
@ -115,7 +115,7 @@ RaceGUI::RaceGUI()
{
m_map_left = irr_driver->getActualScreenSize().Width - m_map_width;
}
else if (UserConfigParams::m_multitouch_enabled)
else if (m_multitouch_gui != NULL)
{
m_map_left = (int)((irr_driver->getActualScreenSize().Width -
m_map_width) * 0.95f);
@ -248,7 +248,7 @@ void RaceGUI::renderPlayerView(const Camera *camera, float dt)
drawPowerupIcons(kart, viewport, scaling);
if (!UserConfigParams::m_multitouch_enabled)
if (m_multitouch_gui == NULL)
{
drawSpeedEnergyRank(kart, viewport, scaling, dt);
}

View File

@ -102,7 +102,8 @@ RaceGUIBase::RaceGUIBase()
m_referee = NULL;
m_multitouch_gui = NULL;
if (UserConfigParams::m_multitouch_enabled &&
if (UserConfigParams::m_multitouch_enabled &&
UserConfigParams::m_multitouch_mode != 0 &&
race_manager->getNumLocalPlayers() == 1)
{
m_multitouch_gui = new RaceGUIMultitouch(this);
@ -721,7 +722,7 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin)
{
y_icons_limit = irr_driver->getActualScreenSize().Height - ICON_WIDTH;
}
else if (UserConfigParams::m_multitouch_enabled)
else if (m_multitouch_gui != NULL)
{
y_icons_limit = irr_driver->getActualScreenSize().Height / 2;
}

View File

@ -84,7 +84,7 @@ RaceGUIOverworld::RaceGUIOverworld()
const float map_size = 250.0f;
// Check if we have enough space for minimap when touch steering is enabled
if (UserConfigParams::m_multitouch_enabled)
if (m_multitouch_gui != NULL)
{
const float map_bottom = (float)(m_multitouch_gui->getMinimapBottom());
@ -115,7 +115,7 @@ RaceGUIOverworld::RaceGUIOverworld()
{
m_map_left = irr_driver->getActualScreenSize().Width - m_map_width;
}
else if (UserConfigParams::m_multitouch_enabled)
else if (m_multitouch_gui != NULL)
{
m_map_left = (int)((irr_driver->getActualScreenSize().Width -
m_map_width) * 0.9f);
@ -190,7 +190,7 @@ void RaceGUIOverworld::renderGlobal(float dt)
if(!world->isRacePhase()) return;
if (!m_enabled) return;
if (!UserConfigParams::m_multitouch_enabled)
if (m_multitouch_gui == NULL)
{
drawTrophyPoints();
}
@ -351,7 +351,7 @@ void RaceGUIOverworld::drawGlobalMiniMap()
if(draw_at.getX()>right_most) right_most = draw_at.getX();
}
if (UserConfigParams::m_multitouch_enabled)
if (m_multitouch_gui != NULL)
{
m_map_left += m_map_width - (int)right_most;
}