2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "steering_setup.h"
18 #include "gear-racing-controller.h"
20 #include "view_manager/view_manager.h"
21 #include "model/model_sensors.h"
22 #include "model/model_hw.h"
23 #include "model/model_car_connection.h"
27 static bool app_create(void *data)
29 _D("--------========================================================--------");
30 _D("--------========================================================--------");
31 _D("--------=============== APP %s %s ===============--------", __DATE__, __TIME__);
32 _D("--------========================================================--------");
33 _D("--------========================================================--------");
38 model_car_connection_init();
39 view_manager_initialize_ui();
45 app_control(app_control_h app_control, void *data)
48 int ret = app_control_get_app_id(app_control, &appid);
49 ASSERT_FUNCTION(ret != APP_CONTROL_ERROR_NONE);
51 char *config_file = NULL;
53 _D("APPID: %s", appid);
55 if (!strncmp(appid, "org.tizen.gear-racing-controller.bs", strlen(appid))) {
57 config_file = "config-azim-thr-dir-elev.ini";
58 } else if (!strncmp(appid, "org.tizen.gear-racing-controller.sb", strlen(appid))) {
60 config_file = "config-dir-elev-thr-azim.ini";
61 } else if (!strncmp(appid, "org.tizen.gear-racing-controller.ssa", strlen(appid))) {
63 config_file = "config-dir-thr-azim-elev.ini";
64 } else if (!strncmp(appid, "org.tizen.gear-racing-controller.sse", strlen(appid))) {
66 config_file = "config-dir-thr-elev-azim.ini";
69 config_file = "config-azim-thr-dir-elev.ini";
72 config_init(config_file);
79 model_car_connection_set_paused(true);
83 app_resume(void *data)
85 model_car_connection_set_paused(false);
89 app_terminate(void *data)
92 /* Release all resources. */
96 ui_app_lang_changed(app_event_info_h event_info, void *user_data)
98 /*APP_EVENT_LANGUAGE_CHANGED*/
103 ret = app_event_get_language(event_info, &language);
104 if (ret != APP_ERROR_NONE) {
105 dlog_print(DLOG_ERROR, LOG_TAG, "app_event_get_language() failed. Err = %d.", ret);
109 if (language != NULL) {
110 elm_language_set(language);
116 ui_app_orient_changed(app_event_info_h event_info, void *user_data)
118 /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
123 ui_app_region_changed(app_event_info_h event_info, void *user_data)
125 /*APP_EVENT_REGION_FORMAT_CHANGED*/
129 ui_app_low_battery(app_event_info_h event_info, void *user_data)
131 /*APP_EVENT_LOW_BATTERY*/
135 ui_app_low_memory(app_event_info_h event_info, void *user_data)
137 /*APP_EVENT_LOW_MEMORY*/
141 main(int argc, char *argv[])
145 ui_app_lifecycle_callback_s event_callback = {0,};
146 app_event_handler_h handlers[5] = {NULL, };
148 event_callback.create = app_create;
149 event_callback.terminate = app_terminate;
150 event_callback.pause = app_pause;
151 event_callback.resume = app_resume;
152 event_callback.app_control = app_control;
154 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, NULL);
155 ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, NULL);
156 ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, NULL);
157 ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, NULL);
158 ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, NULL);
160 ret = ui_app_main(argc, argv, &event_callback, NULL);
161 if (ret != APP_ERROR_NONE) {
162 dlog_print(DLOG_ERROR, LOG_TAG, "ui_app_main() is failed. err = %d", ret);