From: Kaj-Michael Lang Date: Fri, 7 Mar 2008 12:57:44 +0000 (+0200) Subject: Add functions to handle headphone button presses on tablets. Untested. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7a3a9b5fbd759fda968845bc615f86b66f2fa3ee;p=mapper Add functions to handle headphone button presses on tablets. Untested. --- diff --git a/src/cb.c b/src/cb.c index 345114e..17dc91f 100644 --- a/src/cb.c +++ b/src/cb.c @@ -1321,3 +1321,25 @@ if (!p) { poi_edit_dialog(ACTION_EDIT_POI, p); return TRUE; } + +/***/ + +gboolean +headphone_button_cb(gpointer data) +{ +gint hb_action=0; +switch (hb_action) { +case 1: +#if 0 + /* XXX: Add code to add generic POI */ + hildon_banner_show_information(_window, NULL, _("POI Added")); +#endif +break; +case 0: +default: + path_insert_mark_text(&_track, g_strdup("Mark")); + hildon_banner_show_information(_window, NULL, _("Mark added")); +break; +} +return FALSE; +} diff --git a/src/cb.h b/src/cb.h index 8a2ebaa..0c1aeba 100644 --- a/src/cb.h +++ b/src/cb.h @@ -109,4 +109,7 @@ gboolean cmenu_cb_poi_edit_poi(GtkAction * action); gboolean cmenu_cb_poi_add_route(GtkAction * action); gboolean cmenu_cb_poi_add_way(GtkAction * action); +/* Special button callbacks */ +gboolean headphone_button_cb(gpointer data); + #endif diff --git a/src/mapper.c b/src/mapper.c index b84a8c9..409c460 100644 --- a/src/mapper.c +++ b/src/mapper.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #ifdef WITH_GST @@ -49,6 +50,10 @@ #include #include +#ifdef WITH_HAL +#include +#endif + #ifdef WITH_HILDON_DBUS_BT #include #endif @@ -115,6 +120,10 @@ guint mis=MAPPER_INIT_START; static GtkWidget *init_progress; static GtkWidget *init_dialog; +#ifdef WITH_HAL +LibHalContext *ctx; +#endif + /** * Initialize arrays */ @@ -240,6 +249,39 @@ if (!_osso) { return 0; } +#ifdef WITH_HAL +static void +hal_condition_cb(LibHalContext *ctx, const char *udi, const char *name, const char *detail) +{ +g_debug("HAL: [%s]->[%s:%s]", udi, name, detail); +if (strcmp(name, "ButtonPressed")==0 && strcmp(detail, "phone")==0) + g_idle_add_full(G_PRIORITY_HIGH_IDLE, headphone_button_cb, NULL,NULL); +} + +static gboolean +mapper_hal_init(void) +{ +DBusError error; + +dbus_error_init(&error); + +ctx=libhal_ctx_new(); +g_assert(ctx); + +g_assert(dbus_conn); +libhal_ctx_set_dbus_connection(ctx, dbus_conn); +g_debug("HAL: init"); +if (!libhal_ctx_init(ctx, &error)) + return FALSE; + +g_debug("HAL: setting cb"); +libhal_ctx_set_device_condition(ctx, hal_condition_cb); +libhal_device_add_property_watch(ctx, "/org/freedesktop/Hal/devices/platform_retu_headset_logicaldev_input",NULL); + +return TRUE; +} +#endif + static gint mapper_osso_cb_init(void) { @@ -355,14 +397,17 @@ switch (mis) { /* Initialize D-Bus system connection. */ if (NULL == (dbus_conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &error))) { g_printerr("Failed to open connection to D-Bus: %s.\n", error->message); - popup_error(_window, "Failed to connect to D-Bus."); + popup_error(NULL, "Failed to connect to D-Bus."); error = NULL; } /* XXX: Move this */ - #ifdef WITH_OSSO +#ifdef WITH_OSSO osso_hw_set_event_cb(_osso, NULL, osso_cb_hw_state, NULL); - #endif +#endif +#ifdef WITH_HAL + mapper_hal_init(); +#endif mis=MAPPER_INIT_UI; p=0.9;