]> err.no Git - mapper/commitdiff
Add functions to handle headphone button presses on tablets. Untested.
authorKaj-Michael Lang <milang@onion.tal.org>
Fri, 7 Mar 2008 12:57:44 +0000 (14:57 +0200)
committerKaj-Michael Lang <milang@onion.tal.org>
Fri, 7 Mar 2008 12:57:44 +0000 (14:57 +0200)
src/cb.c
src/cb.h
src/mapper.c

index 345114ebb5fb51e8010431e60b15b563a2fe982a..17dc91fc838a56a03c0bb6dce6827760d483ce1a 100644 (file)
--- 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;
+} 
index 8a2ebaaed22f79c82dd70e7f7438ed424907c035..0c1aeba0c5f58593b9ba23616fa7bbe25382c8cb 100644 (file)
--- 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
index b84a8c90dcde9c19d72df5975eb55fc4ae2b242a..409c4608a4396542a0f9a83c2b4628ac6544a1e0 100644 (file)
@@ -32,6 +32,7 @@
 #include <math.h>
 #include <errno.h>
 #include <sys/wait.h>
+#include <glib.h>
 #include <glib/gstdio.h>
 #include <glib/gi18n.h>
 #ifdef WITH_GST
 #include <libintl.h>
 #include <locale.h>
 
+#ifdef WITH_HAL
+#include <libhal.h>
+#endif
+
 #ifdef WITH_HILDON_DBUS_BT
 #include <bt-dbus.h>
 #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;