Added MULTITOUCH_CONTROLS_... enum for m_multitouch_controls config option

This commit is contained in:
Sergii Pylypenko 2018-10-18 21:42:34 +03:00
parent 9f923fdfaa
commit 64e0c6312e
5 changed files with 25 additions and 17 deletions

View File

@ -352,6 +352,14 @@ enum GeometryLevel
GEOLEVEL_2 = 2 GEOLEVEL_2 = 2
}; };
enum MultitouchControls
{
MULTITOUCH_CONTROLS_UNDEFINED = 0,
MULTITOUCH_CONTROLS_STEERING_WHEEL = 1,
MULTITOUCH_CONTROLS_ACCELEROMETER = 2,
MULTITOUCH_CONTROLS_GYROSCOPE = 3,
};
/** Using X-macros for setting-possible values is not very pretty, but it's a /** Using X-macros for setting-possible values is not very pretty, but it's a
* no-maintenance case : * no-maintenance case :
* when you want to add a new parameter, just add one signle line below and * when you want to add a new parameter, just add one signle line below and

View File

@ -2083,7 +2083,7 @@ int main(int argc, char *argv[] )
} }
#ifdef ANDROID #ifdef ANDROID
if (UserConfigParams::m_multitouch_controls == 0) if (UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_UNDEFINED)
{ {
int32_t touch = AConfiguration_getTouchscreen( int32_t touch = AConfiguration_getTouchscreen(
global_android_app->config); global_android_app->config);

View File

@ -83,9 +83,9 @@ void InitAndroidDialog::beforeAddingWidgets()
Widget* accelerometer = &control_type->getChildren()[index]; Widget* accelerometer = &control_type->getChildren()[index];
accelerometer->setActive(false); accelerometer->setActive(false);
if (UserConfigParams::m_multitouch_controls == 2) if (UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_ACCELEROMETER)
{ {
UserConfigParams::m_multitouch_controls = 1; UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_STEERING_WHEEL;
} }
} }
@ -98,9 +98,9 @@ void InitAndroidDialog::beforeAddingWidgets()
Widget* gyroscope = &control_type->getChildren()[index]; Widget* gyroscope = &control_type->getChildren()[index];
gyroscope->setActive(false); gyroscope->setActive(false);
if (UserConfigParams::m_multitouch_controls == 3) if (UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_GYROSCOPE)
{ {
UserConfigParams::m_multitouch_controls = 1; UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_STEERING_WHEEL;
} }
} }
@ -127,15 +127,15 @@ GUIEngine::EventPropagation InitAndroidDialog::processEvent(
if (selected == "steering_wheel") if (selected == "steering_wheel")
{ {
UserConfigParams::m_multitouch_controls = 1; UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_STEERING_WHEEL;
} }
else if (selected == "accelerometer") else if (selected == "accelerometer")
{ {
UserConfigParams::m_multitouch_controls = 2; UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_ACCELEROMETER;
} }
else if (selected == "gyroscope") else if (selected == "gyroscope")
{ {
UserConfigParams::m_multitouch_controls = 3; UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_GYROSCOPE;
} }
user_config->saveConfig(); user_config->saveConfig();
@ -154,12 +154,12 @@ void InitAndroidDialog::updateValues()
RibbonWidget* control_type = getWidget<RibbonWidget>("control_type"); RibbonWidget* control_type = getWidget<RibbonWidget>("control_type");
assert(control_type != NULL); assert(control_type != NULL);
if (UserConfigParams::m_multitouch_controls == 2) if (UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_ACCELEROMETER)
{ {
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);
} }
else if (UserConfigParams::m_multitouch_controls == 3) 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);
@ -175,7 +175,7 @@ void InitAndroidDialog::updateValues()
bool InitAndroidDialog::onEscapePressed() bool InitAndroidDialog::onEscapePressed()
{ {
UserConfigParams::m_multitouch_controls = 1; UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_STEERING_WHEEL;
user_config->saveConfig(); user_config->saveConfig();
ModalDialog::dismiss(); ModalDialog::dismiss();
return true; return true;

View File

@ -119,16 +119,16 @@ GUIEngine::EventPropagation MultitouchSettingsDialog::processEvent(
CheckBoxWidget* gyroscope = getWidget<CheckBoxWidget>("gyroscope"); CheckBoxWidget* gyroscope = getWidget<CheckBoxWidget>("gyroscope");
assert(gyroscope != NULL); assert(gyroscope != NULL);
UserConfigParams::m_multitouch_controls = 1; UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_STEERING_WHEEL;
if (accelerometer->getState()) if (accelerometer->getState())
{ {
UserConfigParams::m_multitouch_controls = 2; UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_ACCELEROMETER;
} }
if (gyroscope->getState()) if (gyroscope->getState())
{ {
UserConfigParams::m_multitouch_controls = 3; UserConfigParams::m_multitouch_controls = MULTITOUCH_CONTROLS_GYROSCOPE;
} }
MultitouchDevice* touch_device = input_manager->getDeviceManager()-> MultitouchDevice* touch_device = input_manager->getDeviceManager()->
@ -224,11 +224,11 @@ void MultitouchSettingsDialog::updateValues()
CheckBoxWidget* accelerometer = getWidget<CheckBoxWidget>("accelerometer"); CheckBoxWidget* accelerometer = getWidget<CheckBoxWidget>("accelerometer");
assert(accelerometer != NULL); assert(accelerometer != NULL);
accelerometer->setState(UserConfigParams::m_multitouch_controls == 2); accelerometer->setState(UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_ACCELEROMETER);
CheckBoxWidget* gyroscope = getWidget<CheckBoxWidget>("gyroscope"); CheckBoxWidget* gyroscope = getWidget<CheckBoxWidget>("gyroscope");
assert(gyroscope != NULL); assert(gyroscope != NULL);
gyroscope->setState(UserConfigParams::m_multitouch_controls == 3); gyroscope->setState(UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_GYROSCOPE);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -116,7 +116,7 @@ void RaceGUIMultitouch::init()
if (m_device == NULL) if (m_device == NULL)
return; return;
if (UserConfigParams::m_multitouch_controls == 2) if (UserConfigParams::m_multitouch_controls == MULTITOUCH_CONTROLS_ACCELEROMETER)
{ {
m_device->activateAccelerometer(); m_device->activateAccelerometer();
} }