File mouseemu.defaults.patch of Package mouseemu

#! /bin/sh /usr/share/dpatch/dpatch-run
## 41_defaults.dpatch by  <gaudenz@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: change defaults to not emaulate mouse buttons for \!powerpc

@DPATCH@
---
 mouseemu.c |   39 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 3 deletions(-)

--- a/mouseemu.c
+++ b/mouseemu.c
@@ -24,11 +24,15 @@
 #include <signal.h>
 #include <wait.h>
 #include <sys/time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <linux/input.h>
 #include <linux/uinput.h>
 #include "mouseemu.h"
 #include "defkeys.h"
 
+static int use_defaults		= 0;
+
 static int b2_mod 		= BUTTON2MOD;
 static int b2_key 		= BUTTON2KEY;
 
@@ -534,10 +538,16 @@ void usage(FILE *stream, char *argv[]) {
 	                "Use decimal values. BTN_LEFT(272) is usable as "
 	                "B2_KEY or B3_KEY.\n\n");
 	fprintf(stream, "Default uinput device: " DEFAULT_UINPUT ".\n");
-	fprintf(stream, "Default keys:\n"
+	fprintf(stream, "Default keys:\n");
+	if (use_defaults)
+		fprintf(stream,
 	                "\tMiddle click : F10 (0 68)\n"
-	                "\tRight click	: F11 (0 87)\n"
-	                "\tScroll mod.	: Alt (56)\n"
+	                "\tRight click	: F11 (0 87)\n");
+	else
+		fprintf(stream,
+	                "\tMiddle click : none (0 0)\n"
+	                "\tRight click	: none (0 0)\n");
+	fprintf(stream, "\tScroll mod.	: Alt (56)\n"
 	                "\tDefault blocking time while typing: 300ms\n");
 
 	exit(0);
@@ -556,6 +566,29 @@ int main(int argc, char *argv[])
 
 	install_sighandler();
 
+#ifdef __powerpc__
+	use_defaults = 1;
+#else
+#if defined(__i386__) || defined(__amd64__)
+	{
+		FILE *dmidecode;
+		char line[1024];
+		dmidecode = popen("dmidecode -s system-manufacturer 2>/dev/null", "r");
+		if (dmidecode) {
+			if (fgets(line, 1024, dmidecode) && !strncmp(line, "Apple", 5))
+				use_defaults = 1;
+			pclose(dmidecode);
+		}
+	}
+#endif
+#endif
+	if (!use_defaults) {
+		b2_mod = 0;
+		b2_key = 0;
+		b3_mod = 0;
+		b3_key = 0;
+	}
+
 	uinputdev = DEFAULT_UINPUT;
 	if (argc > 1) {
 		int i = 0;