diff options
author | Holger Behrens <holger.behrens@windriver.com> | 2015-02-16 16:30:02 +0100 |
---|---|---|
committer | Holger Behrens <holger.behrens@windriver.com> | 2015-02-16 16:30:02 +0100 |
commit | 9149c5580a75016dd268b692069b1306f495bbfe (patch) | |
tree | be0361170257701c1e8427f19c0a24d01af6aa51 | |
parent | c53d1b89db42140296f89d07ea15dbdffa8cbb26 (diff) | |
download | genivi-demo-platform-hmi-9149c5580a75016dd268b692069b1306f495bbfe.tar.gz |
genivi-demo-platform-hmi: uprev to version 0.4
Signed-off-by: Holger Behrens <holger.behrens@windriver.com>
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | genivi-demo-platform-hmi.bb | 2 | ||||
-rw-r--r-- | include/gdp-hmi-apps.h | 12 | ||||
-rw-r--r-- | include/gdp-hmi-surfaces.h | 60 | ||||
-rw-r--r-- | src/gdp-dbus-service.cpp | 73 | ||||
-rw-r--r-- | src/gdp-hmi-controller.cpp | 156 |
6 files changed, 184 insertions, 121 deletions
diff --git a/configure.ac b/configure.ac index 17e2faf..f0c7ba2 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ # 09.Feb.2015, Holger Behrens, add support for dbus/dbus-c++/glib AC_PREREQ([2.69]) -AC_INIT([genivi-demo-platform-hmi], [0.2], +AC_INIT([genivi-demo-platform-hmi], [0.4], [http://bugs.genivi.org/], [genivi-demo-platform-hmi], [http://projects.genivi.org/genivi-demo-platform/]) diff --git a/genivi-demo-platform-hmi.bb b/genivi-demo-platform-hmi.bb index d5d05e3..78a746f 100644 --- a/genivi-demo-platform-hmi.bb +++ b/genivi-demo-platform-hmi.bb @@ -17,4 +17,4 @@ inherit externalsrc EXTERNALSRC = "/home/holger/Projects/GDP/stash.wrs.com/genivi-demo-platform-hmi" # make sure this matches the version given in configure.ac -PV = "0.3" +PV = "0.4" diff --git a/include/gdp-hmi-apps.h b/include/gdp-hmi-apps.h index 1618650..373f135 100644 --- a/include/gdp-hmi-apps.h +++ b/include/gdp-hmi-apps.h @@ -12,44 +12,54 @@ * For further information see http://www.genivi.org/. * * List of changes: - * 11.Feb.2014, Holger Behrens, written + * 11.Feb.2015, Holger Behrens, written + * 16.Feb.2015, Holger Behrens, added generic identifier */ #ifndef GDP_HMI_APP_H #define GDP_HMI_APP_H +#define GDP_PANEL 0 #define GDP_PANEL_SURFACE_ID 0 #define GDP_PANEL_LAYER_ID 0 #define GDP_PANEL_UNIT "gdp-hmi-panel.service" +#define GDP_LAUNCHER 1 #define GDP_LAUNCHER_SURFACE_ID 1 #define GDP_LAUNCHER_LAYER_ID 100 #define GDP_LAUNCHER_UNIT "gdp-hmi-launcher.service" +#define GDP_BACKGROUND 2 #define GDP_BACKGROUND_SURFACE_ID 2 #define GDP_BACKGROUND_LAYER_ID 200 #define GDP_BACKGROUND_UNIT "gdp-hmi-background.service" +#define QML_EXAMPLE 3 #define QML_EXAMPLE_SURFACE_ID 3 #define QML_EXAMPLE_LAYER_ID 300 #define QML_EXAMPLE_UNIT "qml-example.service" +#define AM_DEMO 4 #define AM_DEMO_SURFACE_ID 20 #define AM_DEMO_LAYER_ID 300 #define AM_DEMO_UNIT "AudioManager_PoC.service" +#define BROWSER_POC 5 #define BROWSER_POC_SURFACE_ID 30 #define BROWSER_POC_LAYER_ID 400 #define BROWSER_POC_UNIT "browser.service" +#define FSA 6 #define FSA_SURFACE_ID 40 #define FSA_LAYER_ID 500 #define FSA_UNIT "fsa.service" +#define MOCK_NAVIGATION 7 #define MOCK_NAVIGATION_SURFACE_ID 10 #define MOCK_NAVIGATION_LAYER_ID 600 #define MOCK_NAVIGATION_UNIT "EGLWLMockNavigation.service" +#define INPUT_EVENT_EXAMPLE 8 #define INPUT_EVENT_EXAMPLE_SURFACE_ID 5100 #define INPUT_EVENT_EXAMPLE_LAYER_ID 700 #define INPUT_EVENT_EXAMPLE_UNIT "EGLWLInputEventExample.service" diff --git a/include/gdp-hmi-surfaces.h b/include/gdp-hmi-surfaces.h index 11f3e50..797b564 100644 --- a/include/gdp-hmi-surfaces.h +++ b/include/gdp-hmi-surfaces.h @@ -13,6 +13,7 @@ * * List of changes: * 11.Feb.2014, Holger Behrens, written + * 16.Feb.2015, Holger Behrens, cleanup */ #ifndef GDP_HMI_SURFACES_H @@ -24,67 +25,14 @@ #include "gdp-hmi-apps.h" struct gdp_surface_context { + t_ilm_bool visible; t_ilm_bool created; const t_ilm_uint id_surface; const t_ilm_uint id_layer; const std::string unit; }; -static struct gdp_surface_context gdp_surfaces[] = { - { - ILM_FALSE, - GDP_PANEL_SURFACE_ID, - GDP_PANEL_LAYER_ID, - GDP_PANEL_UNIT - }, - { - ILM_FALSE, - GDP_LAUNCHER_SURFACE_ID, - GDP_LAUNCHER_LAYER_ID, - GDP_LAUNCHER_UNIT - }, - { - ILM_FALSE, - GDP_BACKGROUND_SURFACE_ID, - GDP_BACKGROUND_LAYER_ID, - GDP_BACKGROUND_UNIT - }, - { - ILM_FALSE, - QML_EXAMPLE_SURFACE_ID, - QML_EXAMPLE_LAYER_ID, - QML_EXAMPLE_UNIT - }, - { - ILM_FALSE, - AM_DEMO_SURFACE_ID, - AM_DEMO_LAYER_ID, - AM_DEMO_UNIT - }, - { - ILM_FALSE, - BROWSER_POC_SURFACE_ID, - BROWSER_POC_LAYER_ID, - BROWSER_POC_UNIT - }, - { - ILM_FALSE, - FSA_SURFACE_ID, - FSA_LAYER_ID, - FSA_UNIT - }, - { - ILM_FALSE, - MOCK_NAVIGATION_SURFACE_ID, - MOCK_NAVIGATION_LAYER_ID, - MOCK_NAVIGATION_UNIT - }, - { - ILM_FALSE, - INPUT_EVENT_EXAMPLE_SURFACE_ID, - INPUT_EVENT_EXAMPLE_LAYER_ID, - INPUT_EVENT_EXAMPLE_UNIT - }, -}; +extern struct gdp_surface_context gdp_surfaces[]; +extern const int gdp_surfaces_num; #endif // GDP_HMI_SURFACES_H
\ No newline at end of file diff --git a/src/gdp-dbus-service.cpp b/src/gdp-dbus-service.cpp index 89222ba..7cda7c6 100644 --- a/src/gdp-dbus-service.cpp +++ b/src/gdp-dbus-service.cpp @@ -12,7 +12,8 @@ * For further information see http://www.genivi.org/. * * List of changes: - * 10.Feb.2014, Holger Behrens, written + * 10.Feb.2015, Holger Behrens, written + * 16.Feb.2015, Holger Behrens, complete focus handling of already running app */ /*! \file gdp-dbus-service.cpp @@ -31,53 +32,53 @@ #include "gdp-dbus-service.h" #include "gdp-dbus-systemd.h" -extern SystemdService *gSystemdSession; // systemd on session bus (d-bus) -extern SystemdService *gSystemd; // systemd on system bus (d-bus) +extern SystemdService *gSystemdSession; // systemd on session bus (d-bus) +extern SystemdService *gSystemd; // systemd on system bus (d-bus) HmiService::HmiService(DBus::Connection &connection) : DBus::ObjectAdaptor(connection, GDP_DBUS_SERVICE_PATH) { sd_journal_print(LOG_INFO, "HmiService - constructor (path= %s)\n", - GDP_DBUS_SERVICE_PATH); + GDP_DBUS_SERVICE_PATH); } int64_t HmiService::GetId() { sd_journal_print(LOG_DEBUG, "HmiService::GetId() - %d\n", getpid()); - return getpid(); + return getpid(); } std::string HmiService::Show(const std::string &unit) { - if (0 == unit.compare(0, 15, "poweroff.target")) { - sd_journal_print(LOG_DEBUG, "HmiService::Show() - %s (match)\n", - unit.c_str()); - std::string path = gSystemd->StartUnit(unit, "replace"); - } else { - sd_journal_print(LOG_DEBUG, "HmiService::Show() - %s\n", - unit.c_str()); - for (int count = 0; - count < sizeof gdp_surfaces / sizeof gdp_surfaces[0]; count++) { - if (0 == unit.compare(gdp_surfaces[count].unit)) { - if (ILM_TRUE == gdp_surfaces[count].created) { - // FIXME - // bring gdp_surfaces[count].id_surface to front - sd_journal_print(LOG_DEBUG, - "HmiService::Show() - %s surface (%d) exists.\n", - unit.c_str(), gdp_surfaces[count].id_surface); - } else { - // request systemd to start the unit - std::string path = gSystemdSession->StartUnit(unit, "replace"); - sd_journal_print(LOG_DEBUG, - "systemd(session)::StartUnit() - %s\n", path.c_str()); - } - break; // for-loop - } - else { - sd_journal_print(LOG_DEBUG, "DEBUG: compare \"%s\" with \"%s\"", - unit.c_str(), gdp_surfaces[count].unit.c_str()); - } - } // for-loop - } - return "Show unit \"" + unit + "\"!"; + if (0 == unit.compare(0, 15, "poweroff.target")) { + sd_journal_print(LOG_DEBUG, "HmiService::Show() - %s (match)\n", + unit.c_str()); + std::string path = gSystemd->StartUnit(unit, "replace"); + } else { + sd_journal_print(LOG_DEBUG, "HmiService::Show() - %s\n", + unit.c_str()); + for (int count = 0; count < gdp_surfaces_num; count++) { + if (0 == unit.compare(gdp_surfaces[count].unit)) { + if (ILM_TRUE == gdp_surfaces[count].created) { + extern void surface_control(const int index); + // bring gdp_surfaces[count].id_surface to front + surface_control(count); + sd_journal_print(LOG_DEBUG, + "HmiService::Show() - %s surface (%d) exists.\n", + unit.c_str(), gdp_surfaces[count].id_surface); + } else { + // request systemd to start the unit + std::string path = gSystemdSession->StartUnit(unit, "replace"); + sd_journal_print(LOG_DEBUG, + "systemd(session)::StartUnit() - %s\n", path.c_str()); + } + break; // for-loop + } + else { + sd_journal_print(LOG_DEBUG, "DEBUG: compare \"%s\" with \"%s\"", + unit.c_str(), gdp_surfaces[count].unit.c_str()); + } + } // for-loop + } + return "Show unit \"" + unit + "\"!"; } diff --git a/src/gdp-hmi-controller.cpp b/src/gdp-hmi-controller.cpp index b9597c9..8212d11 100644 --- a/src/gdp-hmi-controller.cpp +++ b/src/gdp-hmi-controller.cpp @@ -17,6 +17,7 @@ * introduced SIGUSR signal handling, pidfile * 09.Feb.2015, Holger Behrens, convert main loop into a glib main loop * 10.Feb.2015, Holger Behrens, added interface to systemd (via dbus-c++) + * 16.Feb.2015, Holger Behrens, correct gdp_surfaces[] usage */ /*! \file gdp-hmi-controller.cpp @@ -72,6 +73,73 @@ DBus::Glib::BusDispatcher dispatcher; // dbus-c++ bus dispatcher (glib) SystemdService *gSystemdSession; // systemd on session bus (d-bus) SystemdService *gSystemd; // systemd on system bus (d-bus) +// database of well known surface and layer IDs as well as unit names +struct gdp_surface_context gdp_surfaces[] = { + { // 0 - GDP_PANEL + ILM_FALSE, + ILM_FALSE, + GDP_PANEL_SURFACE_ID, + GDP_PANEL_LAYER_ID, + GDP_PANEL_UNIT + }, + { // 1 - GDP_LAUNCHER + ILM_FALSE, + ILM_FALSE, + GDP_LAUNCHER_SURFACE_ID, + GDP_LAUNCHER_LAYER_ID, + GDP_LAUNCHER_UNIT + }, + { // 2 - GDP_BACKGROUND + ILM_FALSE, + ILM_FALSE, + GDP_BACKGROUND_SURFACE_ID, + GDP_BACKGROUND_LAYER_ID, + GDP_BACKGROUND_UNIT + }, + { // 3 - QML_EXAMPLE + ILM_FALSE, + ILM_FALSE, + QML_EXAMPLE_SURFACE_ID, + QML_EXAMPLE_LAYER_ID, + QML_EXAMPLE_UNIT + }, + { // 4 - AM_DEMO + ILM_FALSE, + ILM_FALSE, + AM_DEMO_SURFACE_ID, + AM_DEMO_LAYER_ID, + AM_DEMO_UNIT + }, + { // 5 - BROWSER_POC + ILM_FALSE, + ILM_FALSE, + BROWSER_POC_SURFACE_ID, + BROWSER_POC_LAYER_ID, + BROWSER_POC_UNIT + }, + { // 6 - FSA + ILM_FALSE, + ILM_FALSE, + FSA_SURFACE_ID, + FSA_LAYER_ID, + FSA_UNIT + }, + { // 7 - MOCK_NAVIGATION + ILM_FALSE, + ILM_FALSE, + MOCK_NAVIGATION_SURFACE_ID, + MOCK_NAVIGATION_LAYER_ID, + MOCK_NAVIGATION_UNIT + }, + { // 8 - INPUT_EVENT_EXAMPLE + ILM_FALSE, + ILM_FALSE, + INPUT_EVENT_EXAMPLE_SURFACE_ID, + INPUT_EVENT_EXAMPLE_LAYER_ID, + INPUT_EVENT_EXAMPLE_UNIT + }, +}; +const int gdp_surfaces_num = sizeof gdp_surfaces / sizeof gdp_surfaces[0]; /** * \brief creates a PID file @@ -154,7 +222,7 @@ static void layer_create(void) sd_journal_print(LOG_DEBUG, "Debug: Screen ID[%u] = %d\n", i, pIDs[i]); } - screenID = 0; // always use screen with the ID 0 + screenID = 0; // FIXME: always use screen with the ID 0 // (limitation of ivi-shell at time of this writing) } sd_journal_print(LOG_INFO, @@ -222,6 +290,34 @@ static void layer_create(void) } /** + * \brief mark surface as visible + * + * This function does mark the surface \p surfaceNum visible and all the + * other surfaces available invisible. + * + * \param surfaceNum The GDP surface number to mark as visible. + */ +static void surface_mark_visible(const int surfaceNum) +{ + // handling special case of panel + if (GDP_PANEL == surfaceNum) + return; + + for (int count = 0; count < gdp_surfaces_num; count++) { + if (count == surfaceNum) { + gdp_surfaces[count].visible = ILM_TRUE; + } else { + gdp_surfaces[count].visible = ILM_FALSE; + } + } + + // exception handling (panel is visible too, if !launcher surface) + if (GDP_LAUNCHER != surfaceNum) { + gdp_surfaces[GDP_PANEL].visible = ILM_TRUE; + } +} + +/** * \brief show the launcher surface * * This function does control the launcher surface given by \p gdp_surface. @@ -270,12 +366,13 @@ static void launcher_show(const struct gdp_surface_context gdp_surface) layerIdArray, 1); callResult = ilm_commitChanges(); + surface_mark_visible(GDP_LAUNCHER); } /** * \brief control the IVI surface * - * This function does control the surface \p gdp_surface. + * This function does control the surface \p index. * Currently the surface is added to its assigned layer, * the layer together with the layer holding the 'panel' * are brought into view on the screen and assigned input focus. @@ -292,24 +389,25 @@ static void launcher_show(const struct gdp_surface_context gdp_surface) * 10 | EGL Mock Navigation * 5100 | EGL Input Example * - * \param gdp_surfaces The GDP surface/layer context to be controlled. + * \param index The index into the gdp_surfaces[] database. */ -static void surface_control(struct gdp_surface_context gdp_surface) +void surface_control(const int index) { + const struct gdp_surface_context gdp_surface = gdp_surfaces[index]; ilmErrorTypes callResult = ILM_FAILED; t_ilm_surface surfaceIdArray[] = {GDP_BACKGROUND_SURFACE_ID}; t_ilm_layer layerIdArray[] = {GDP_BACKGROUND_LAYER_ID, GDP_PANEL_LAYER_ID}; - sd_journal_print(LOG_DEBUG, "surface_control" + sd_journal_print(LOG_DEBUG, "surface_control - index = %d" "(surface = %u, layer = %u)\n", - gdp_surface.id_surface, gdp_surface.id_layer); + index, gdp_surface.id_surface, gdp_surface.id_layer); surfaceIdArray[0] = gdp_surface.id_surface; layerIdArray[0] = gdp_surface.id_layer; switch(gdp_surface.id_surface) { - case GDP_PANEL_SURFACE_ID: // Panel + case GDP_PANEL_SURFACE_ID: // Panel callResult = ilm_surfaceSetDestinationRectangle( gdp_surface.id_surface, 0, 0, screenWidth, panelHeight); callResult = ilm_surfaceSetVisibility( @@ -335,24 +433,25 @@ static void surface_control(struct gdp_surface_context gdp_surface) ILM_TRUE); callResult = ilm_commitChanges(); break; - case GDP_LAUNCHER_SURFACE_ID: // GDP HMI / Launcher + case GDP_LAUNCHER_SURFACE_ID: // GDP HMI / Launcher launcher_show(gdp_surface); break; - case GDP_BACKGROUND_SURFACE_ID: // Background / Logo + case GDP_BACKGROUND_SURFACE_ID: // Background / Logo // fall-through - case QML_EXAMPLE_SURFACE_ID: // QML Example + case QML_EXAMPLE_SURFACE_ID: // QML Example // fall-through - case AM_DEMO_SURFACE_ID: // AudioManager PoC/Demo + case AM_DEMO_SURFACE_ID: // Audio Manager Demo // fall-through - case BROWSER_POC_SURFACE_ID: // Browser PoC + case BROWSER_POC_SURFACE_ID: // Browser PoC // fall-through - case FSA_SURFACE_ID: // FSA PoC + case FSA_SURFACE_ID: // FSA PoC // fall-through - case MOCK_NAVIGATION_SURFACE_ID: // EGL Mock Navigation + case MOCK_NAVIGATION_SURFACE_ID: // EGL Mock Navigation // fall-through case INPUT_EVENT_EXAMPLE_SURFACE_ID: // EGL Input Example callResult = ilm_surfaceSetDestinationRectangle( - gdp_surface.id_surface, 0, 0, screenWidth, screenHeight - panelHeight); + gdp_surface.id_surface, 0, 0, screenWidth, + screenHeight - panelHeight); callResult = ilm_surfaceSetVisibility( gdp_surface.id_surface, ILM_TRUE); callResult = ilm_surfaceSetOpacity( @@ -380,6 +479,7 @@ static void surface_control(struct gdp_surface_context gdp_surface) layerIdArray, 2); callResult = ilm_commitChanges(); + surface_mark_visible(index); break; default: sd_journal_print(LOG_DEBUG, @@ -406,8 +506,7 @@ static void surfaces_appear_check(t_ilm_int length, t_ilm_surface* pArray) // check for appearance for (int i = 0; i < length; i++) { // check out list of expected surface IDs 'gdp_surfaces' - for (int count = 0; - count < sizeof gdp_surfaces / sizeof gdp_surfaces[0]; count++) { + for (int count = 0; count < gdp_surfaces_num; count++) { if (pArray[i] == gdp_surfaces[count].id_surface) { // check if surface is already known if (ILM_TRUE == gdp_surfaces[count].created) @@ -418,7 +517,7 @@ static void surfaces_appear_check(t_ilm_int length, t_ilm_surface* pArray) "Debug: new surface id: %i (for layer: %i)\n", gdp_surfaces[count].id_surface, gdp_surfaces[count].id_layer); - surface_control(gdp_surfaces[count]); + surface_control(count); } } // inner for-loop } // outer for-loop @@ -439,8 +538,7 @@ static void surfaces_disappear_check(t_ilm_int length, t_ilm_surface* pArray) return; // check for disappearance - for (int count = 0; - count < sizeof gdp_surfaces / sizeof gdp_surfaces[0]; count++) { + for (int count = 0; count < gdp_surfaces_num; count++) { t_ilm_bool found = ILM_FALSE; for (int i = 0; i < length; i++) { @@ -456,6 +554,12 @@ static void surfaces_disappear_check(t_ilm_int length, t_ilm_surface* pArray) "Debug: surface id: %i disappeared (from layer: %i)\n", gdp_surfaces[count].id_surface, gdp_surfaces[count].id_layer); + // in case this surface was currently in sight + if (ILM_TRUE == gdp_surfaces[count].visible) { + // show the background instead + gdp_surfaces[count].visible = ILM_FALSE; + surface_control(GDP_BACKGROUND); + } } } // outer for-loop } @@ -524,15 +628,15 @@ static void sig_handler(int signo) g_main_loop_quit(gMainLoop); // stop the main loop in main() break; case SIGUSR1: - if (ILM_TRUE == gdp_surfaces[1].created) { - launcher_show(gdp_surfaces[1]); + if (ILM_TRUE == gdp_surfaces[GDP_LAUNCHER].created) { + launcher_show(gdp_surfaces[GDP_LAUNCHER]); } sd_journal_print(LOG_DEBUG, "Debug: show launcher (%s)\n", - (ILM_TRUE == gdp_surfaces[1].created) ? "true" : "false"); + (ILM_TRUE == gdp_surfaces[GDP_LAUNCHER].created) ? "true" : "false"); break; case SIGUSR2: - if (ILM_TRUE == gdp_surfaces[2].created) { - surface_control(gdp_surfaces[2]); + if (ILM_TRUE == gdp_surfaces[GDP_BACKGROUND].created) { + surface_control(GDP_BACKGROUND); } sd_journal_print(LOG_DEBUG, "Debug: show background\n"); break; @@ -633,7 +737,7 @@ int main(int argc, char * const* argv) * controller (us), to power off, which application (systemd unit) to * launch or give focus and bring to front/into view. * - * The 'home' button activation is signaled via USR1. + * The 'home' button activation is currently signaled via SIGUSR1. */ DBus::default_dispatcher = &dispatcher; |