Implement auto acceleration for steering wheel from mobile control
This commit is contained in:
parent
7f9f4dc182
commit
0e1732c45d
@ -2,7 +2,7 @@
|
|||||||
<stkgui>
|
<stkgui>
|
||||||
<div x="2%" y="2%" width="96%" height="96%" layout="vertical-row" >
|
<div x="2%" y="2%" width="96%" height="96%" layout="vertical-row" >
|
||||||
|
|
||||||
<box width="100%" height="80%" padding="10" layout="vertical-row">
|
<box width="100%" height="75%" padding="10" layout="vertical-row">
|
||||||
<bright width="100%" text="Select a type of control that you prefer" align="center" text_align="left" word_wrap="true"/>
|
<bright width="100%" text="Select a type of control that you prefer" align="center" text_align="left" word_wrap="true"/>
|
||||||
|
|
||||||
<spacer height="7%" width="10"/>
|
<spacer height="7%" width="10"/>
|
||||||
@ -16,12 +16,19 @@
|
|||||||
icon="gui/icons/android/steering_wheel.png" I18N="Control type" text="Steering wheel"/>
|
icon="gui/icons/android/steering_wheel.png" I18N="Control type" text="Steering wheel"/>
|
||||||
</ribbon>
|
</ribbon>
|
||||||
|
|
||||||
<spacer height="12%" width="10"/>
|
<spacer height="6%" width="10"/>
|
||||||
|
|
||||||
|
<div width="100%" height="16%" align="center" layout="horizontal-row">
|
||||||
|
<label align="center" text_align="left" text="Auto acceleration"/>
|
||||||
|
<spacer width="10"/>
|
||||||
|
<checkbox width="7%" height="100%" id="auto_acceleration"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<label width="100%" text="You can change it later in touch device settings." text_align="left" word_wrap="true"/>
|
<label width="100%" text="You can change it later in touch device settings." text_align="left" word_wrap="true"/>
|
||||||
|
|
||||||
</box>
|
</box>
|
||||||
|
|
||||||
<spacer height="7%" width="10"/>
|
<spacer height="6%" width="10"/>
|
||||||
|
|
||||||
<button id="close" text="Apply" align="center"/>
|
<button id="close" text="Apply" align="center"/>
|
||||||
|
|
||||||
|
@ -31,6 +31,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div width="75%" layout="horizontal-row" proportion="1">
|
||||||
|
<label proportion="1" align="center" text_align="right" I18N="In the multitouch settings screen" text="Auto acceleration"/>
|
||||||
|
<div proportion="1" align="center" height="fit" layout="horizontal-row" >
|
||||||
|
<spacer width="40" height="10" />
|
||||||
|
<checkbox id="auto_acceleration"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div width="75%" layout="horizontal-row" proportion="1">
|
<div width="75%" layout="horizontal-row" proportion="1">
|
||||||
<label proportion="1" align="center" text_align="right" I18N="In the multitouch settings screen" text="Accelerometer"/>
|
<label proportion="1" align="center" text_align="right" I18N="In the multitouch settings screen" text="Accelerometer"/>
|
||||||
<div proportion="1" align="center" height="fit" layout="horizontal-row" >
|
<div proportion="1" align="center" height="fit" layout="horizontal-row" >
|
||||||
|
@ -533,6 +533,11 @@ namespace UserConfigParams
|
|||||||
&m_multitouch_group,
|
&m_multitouch_group,
|
||||||
"Draw steering wheel on right side.") );
|
"Draw steering wheel on right side.") );
|
||||||
|
|
||||||
|
PARAM_PREFIX BoolUserConfigParam m_multitouch_auto_acceleration
|
||||||
|
PARAM_DEFAULT( BoolUserConfigParam(false, "multitouch_auto_acceleration",
|
||||||
|
&m_multitouch_group,
|
||||||
|
"Auto acceleration for multitouch controls.") );
|
||||||
|
|
||||||
PARAM_PREFIX IntUserConfigParam m_multitouch_controls
|
PARAM_PREFIX IntUserConfigParam m_multitouch_controls
|
||||||
PARAM_DEFAULT( IntUserConfigParam(0, "multitouch_controls",
|
PARAM_DEFAULT( IntUserConfigParam(0, "multitouch_controls",
|
||||||
&m_multitouch_group,
|
&m_multitouch_group,
|
||||||
|
@ -494,9 +494,11 @@ void MultitouchDevice::updateAxisY(float value)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_controller->action(PA_BRAKE, 0);
|
m_controller->action(PA_BRAKE, 0);
|
||||||
m_controller->action(PA_ACCEL, 0);
|
m_controller->action(PA_ACCEL,
|
||||||
|
UserConfigParams::m_multitouch_controls == 1 &&
|
||||||
|
UserConfigParams::m_multitouch_auto_acceleration ? Input::MAX_VALUE : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -105,8 +105,25 @@ void InitAndroidDialog::beforeAddingWidgets()
|
|||||||
GUIEngine::EventPropagation InitAndroidDialog::processEvent(
|
GUIEngine::EventPropagation InitAndroidDialog::processEvent(
|
||||||
const std::string& eventSource)
|
const std::string& eventSource)
|
||||||
{
|
{
|
||||||
if (eventSource == "close")
|
if (eventSource == "control_type")
|
||||||
{
|
{
|
||||||
|
RibbonWidget* control_type = getWidget<RibbonWidget>("control_type");
|
||||||
|
assert(control_type != NULL);
|
||||||
|
|
||||||
|
const std::string& selected = control_type->getSelectionIDString(
|
||||||
|
PLAYER_ID_GAME_MASTER);
|
||||||
|
if (selected == "steering_wheel")
|
||||||
|
{
|
||||||
|
getWidget<CheckBoxWidget>("auto_acceleration")->setActive(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getWidget<CheckBoxWidget>("auto_acceleration")->setState(false);
|
||||||
|
getWidget<CheckBoxWidget>("auto_acceleration")->setActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (eventSource == "close")
|
||||||
|
{
|
||||||
RibbonWidget* control_type = getWidget<RibbonWidget>("control_type");
|
RibbonWidget* control_type = getWidget<RibbonWidget>("control_type");
|
||||||
assert(control_type != NULL);
|
assert(control_type != NULL);
|
||||||
|
|
||||||
@ -121,14 +138,17 @@ GUIEngine::EventPropagation InitAndroidDialog::processEvent(
|
|||||||
if (selected == "steering_wheel")
|
if (selected == "steering_wheel")
|
||||||
{
|
{
|
||||||
UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_STEERING_WHEEL;
|
UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_STEERING_WHEEL;
|
||||||
|
UserConfigParams::m_multitouch_auto_acceleration = getWidget<CheckBoxWidget>("auto_acceleration")->getState();
|
||||||
}
|
}
|
||||||
else if (selected == "accelerometer")
|
else if (selected == "accelerometer")
|
||||||
{
|
{
|
||||||
UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_ACCELEROMETER;
|
UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_ACCELEROMETER;
|
||||||
|
UserConfigParams::m_multitouch_auto_acceleration = false;
|
||||||
}
|
}
|
||||||
else if (selected == "gyroscope")
|
else if (selected == "gyroscope")
|
||||||
{
|
{
|
||||||
UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_GYROSCOPE;
|
UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_GYROSCOPE;
|
||||||
|
UserConfigParams::m_multitouch_auto_acceleration = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
user_config->saveConfig();
|
user_config->saveConfig();
|
||||||
@ -151,17 +171,20 @@ void InitAndroidDialog::updateValues()
|
|||||||
{
|
{
|
||||||
int id = control_type->findItemNamed("accelerometer");
|
int id = control_type->findItemNamed("accelerometer");
|
||||||
control_type->setSelection(id, PLAYER_ID_GAME_MASTER);
|
control_type->setSelection(id, PLAYER_ID_GAME_MASTER);
|
||||||
|
getWidget<CheckBoxWidget>("auto_acceleration")->setActive(false);
|
||||||
}
|
}
|
||||||
else if (UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_GYROSCOPE)
|
else if (UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_GYROSCOPE)
|
||||||
{
|
{
|
||||||
int id = control_type->findItemNamed("gyroscope");
|
int id = control_type->findItemNamed("gyroscope");
|
||||||
control_type->setSelection(id, PLAYER_ID_GAME_MASTER);
|
control_type->setSelection(id, PLAYER_ID_GAME_MASTER);
|
||||||
|
getWidget<CheckBoxWidget>("auto_acceleration")->setActive(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int id = control_type->findItemNamed("steering_wheel");
|
int id = control_type->findItemNamed("steering_wheel");
|
||||||
control_type->setSelection(id, PLAYER_ID_GAME_MASTER);
|
control_type->setSelection(id, PLAYER_ID_GAME_MASTER);
|
||||||
}
|
}
|
||||||
|
getWidget<CheckBoxWidget>("auto_acceleration")->setState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -138,6 +138,9 @@ GUIEngine::EventPropagation MultitouchSettingsDialog::processEvent(
|
|||||||
UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_GYROSCOPE;
|
UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_GYROSCOPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_STEERING_WHEEL)
|
||||||
|
UserConfigParams::m_multitouch_auto_acceleration = getWidget<CheckBoxWidget>("auto_acceleration")->getState();
|
||||||
|
|
||||||
MultitouchDevice* touch_device = input_manager->getDeviceManager()->
|
MultitouchDevice* touch_device = input_manager->getDeviceManager()->
|
||||||
getMultitouchDevice();
|
getMultitouchDevice();
|
||||||
|
|
||||||
@ -183,12 +186,14 @@ GUIEngine::EventPropagation MultitouchSettingsDialog::processEvent(
|
|||||||
CheckBoxWidget* gyroscope = getWidget<CheckBoxWidget>("gyroscope");
|
CheckBoxWidget* gyroscope = getWidget<CheckBoxWidget>("gyroscope");
|
||||||
assert(gyroscope != NULL);
|
assert(gyroscope != NULL);
|
||||||
gyroscope->setState(false);
|
gyroscope->setState(false);
|
||||||
|
getWidget<CheckBoxWidget>("auto_acceleration")->setState(false);
|
||||||
}
|
}
|
||||||
else if (eventSource == "gyroscope")
|
else if (eventSource == "gyroscope")
|
||||||
{
|
{
|
||||||
CheckBoxWidget* accelerometer = getWidget<CheckBoxWidget>("accelerometer");
|
CheckBoxWidget* accelerometer = getWidget<CheckBoxWidget>("accelerometer");
|
||||||
assert(accelerometer != NULL);
|
assert(accelerometer != NULL);
|
||||||
accelerometer->setState(false);
|
accelerometer->setState(false);
|
||||||
|
getWidget<CheckBoxWidget>("auto_acceleration")->setState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return GUIEngine::EVENT_LET;
|
return GUIEngine::EVENT_LET;
|
||||||
@ -232,6 +237,11 @@ void MultitouchSettingsDialog::updateValues()
|
|||||||
CheckBoxWidget* gyroscope = getWidget<CheckBoxWidget>("gyroscope");
|
CheckBoxWidget* gyroscope = getWidget<CheckBoxWidget>("gyroscope");
|
||||||
assert(gyroscope != NULL);
|
assert(gyroscope != NULL);
|
||||||
gyroscope->setState(UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_GYROSCOPE);
|
gyroscope->setState(UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_GYROSCOPE);
|
||||||
|
|
||||||
|
if (UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_STEERING_WHEEL)
|
||||||
|
getWidget<CheckBoxWidget>("auto_acceleration")->setState(UserConfigParams::m_multitouch_auto_acceleration);
|
||||||
|
else
|
||||||
|
getWidget<CheckBoxWidget>("auto_acceleration")->setState(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user