Hi everyone,

after having installed the debian distro. i noticed that there is no
right mouse button. so many "standard" applications aren't usable
because they depend on it(i tried to add an applet to my xfce panel..).
so i created a patch to the xorg tslib input driver. once installed you
can press the aux button on your openmoko and than tap on the screen and
i will be recognized as right button click. i attached the patch but i
hope that it will be included in the standard package so everyone have
not to compile is by them self.

 Sebastian Ohl
--- xf86-input-tslib-0.0.4.orig/debian/patches/02_leftbutton-emulation.diff
+++ xf86-input-tslib-0.0.4/debian/patches/02_leftbutton-emulation.diff
@@ -0,0 +1,105 @@
+--- xf86-input-tslib-0.0.4/src/tslib.c	2007-10-19 10:59:29.000000000 +0000
++++ xf86-input-tslib-0.0.4.2bnt/src/tslib.c	2008-08-16 13:38:06.000000000 +0000
+@@ -55,9 +55,12 @@
+ #include <xf86Module.h>
+ #endif
+ 
++/* openmoko second mouse button emulation */
++#include <dbus/dbus.h>
++
+ #define TSLIB_DEV_DEFAULT "/dev/event0"
+ 
+-#define MAXBUTTONS 1
++#define MAXBUTTONS 2
+ 
+ #define DEFAULT_HEIGHT		240
+ #define DEFAULT_WIDTH		320
+@@ -72,6 +75,8 @@
+ 	int rotate;
+ 	int height;
+ 	int width;
++    DBusConnection *dbus;
++	unsigned char secondbutton;
+ };
+ 
+ static const char *DEFAULTS[] = {
+@@ -168,7 +173,7 @@
+ 		priv->lastp = samp.pressure;
+ 
+ 		xf86PostButtonEvent(local->dev, TRUE,
+-			1, !!samp.pressure, 0, 2,
++			(priv->secondbutton?3:1), !!samp.pressure, 0, 2,
+ 			priv->lastx,
+ 			priv->lasty);
+ 	}
+@@ -274,6 +279,44 @@
+ }
+ 
+ /*
++ * button_switch_filter --
++ *
++ * called when a dbus event occured. used for detection of aux button preasure 
++ */
++static DBusHandlerResult
++button_switch_filter (DBusConnection *connection, DBusMessage *message, void *user_data)
++{
++	struct ts_priv *priv = (struct ts_priv *) (user_data);
++	/* A signal from the bus saying we are about to be disconnected */
++	if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) {
++		/* set to first button because getting stuck in the second is not so cool */
++		priv->secondbutton = 0;
++		/* We have handled this message, don't pass it on */
++		return DBUS_HANDLER_RESULT_HANDLED;
++	} 
++	/* A signal from the bus saying an input event occured */
++	else if (dbus_message_is_signal(message, "org.freesmartphone.Device.Input", "Event")) {
++		DBusError error;
++		const char *key;
++		const char *state;
++		dbus_error_init (&error);
++		if (dbus_message_get_args(message, &error, DBUS_TYPE_STRING, &key, DBUS_TYPE_STRING, &state, DBUS_TYPE_INVALID)) {
++			/* ErrorF("Input event received: %s=%s\n", key, state); */
++			if (strncmp(key,"AUX",3) == 0) {
++				// this is threadsafe because it is only a small basic type is set
++				priv->secondbutton = (strncmp(state,"pressed",7)==0) ||
++							(strncmp(state,"held",4)==0);
++			}
++		} else {
++			ErrorF("Input event received, but error getting message: %s\n", error.message);
++			dbus_error_free (&error);
++		}
++		return DBUS_HANDLER_RESULT_HANDLED;
++	}
++	return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
++}
++
++/*
+  * xf86TslibInit --
+  *
+  * called when the module subsection is found in XF86Config
+@@ -284,6 +327,7 @@
+ 	struct ts_priv *priv;
+ 	char *s;
+ 	InputInfoPtr pInfo;
++	DBusError dberror;
+ 
+ 	priv = xcalloc (1, sizeof (struct ts_priv));
+         if (!priv)
+@@ -361,6 +405,17 @@
+ 
+ 	pInfo->fd = ts_fd(priv->ts);
+ 
++	dbus_error_init (&dberror);
++	priv->dbus = dbus_bus_get (DBUS_BUS_SYSTEM, &dberror);
++	if (!priv->dbus) {
++		ErrorF("Failed to connect to the D-BUS daemon: %s", dberror.message);
++		dbus_error_free (&dberror);
++		return NULL; 
++	}
++	dbus_bus_add_match (priv->dbus, "interface='org.freesmartphone.Device.Input'", &dberror);
++	dbus_connection_add_filter (priv->dbus, button_switch_filter, priv, NULL);
++	priv->secondbutton = 0;
++		
+ 	/* Mark the device configured */
+ 	pInfo->flags |= XI86_CONFIGURED;
+ 
_______________________________________________
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community

Reply via email to