From 4baec1a214e95e35c86aaa0d27a2401c170cba41 Mon Sep 17 00:00:00 2001
From: Cecil Hugh Watson <knoppmyth@gmail.com>
Date: Mon, 3 May 2010 23:19:53 -0700
Subject: mythtv:Bumped to compile rc3.

---
 abs/core-testing/mythtv/stable-0.23/mythtv/PKGBUILD | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/abs/core-testing/mythtv/stable-0.23/mythtv/PKGBUILD b/abs/core-testing/mythtv/stable-0.23/mythtv/PKGBUILD
index c8eb95f..d213525 100755
--- a/abs/core-testing/mythtv/stable-0.23/mythtv/PKGBUILD
+++ b/abs/core-testing/mythtv/stable-0.23/mythtv/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=mythtv
 pkgver=0.23
-pkgrel=18
+pkgrel=19
 pkgdesc="A personal video recorder for Linux"
 url="http://www.mythtv.org"
 license="GPL"
-- 
cgit v0.12


From 7c6c7188458a3047b067c9442dec4ba373e9b91f Mon Sep 17 00:00:00 2001
From: Cecil Hugh Watson <knoppmyth@gmail.com>
Date: Mon, 3 May 2010 23:20:05 -0700
Subject: mythinstall:bumped to recompile.

---
 abs/core-testing/mythinstall/PKGBUILD | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/abs/core-testing/mythinstall/PKGBUILD b/abs/core-testing/mythinstall/PKGBUILD
index 1ec14f4..f7e8e58 100644
--- a/abs/core-testing/mythinstall/PKGBUILD
+++ b/abs/core-testing/mythinstall/PKGBUILD
@@ -1,7 +1,7 @@
 # Maintainer: Jams
 pkgname=mythinstall
 pkgver=2
-pkgrel=43
+pkgrel=44
 pkgdesc="LinHES installer/systemconfig GUI."
 arch=i686
 depends=()
-- 
cgit v0.12


From 37a96fd86c86ce3d081d8f333317bc9f46a9ebe0 Mon Sep 17 00:00:00 2001
From: Cecil Hugh Watson <knoppmyth@gmail.com>
Date: Mon, 3 May 2010 23:29:32 -0700
Subject: mythnetvision:bumped to ensure latest.

---
 abs/core-testing/mythtv/stable-0.23/mythnetvision/PKGBUILD | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/abs/core-testing/mythtv/stable-0.23/mythnetvision/PKGBUILD b/abs/core-testing/mythtv/stable-0.23/mythnetvision/PKGBUILD
index de0bc11..cd25452 100644
--- a/abs/core-testing/mythtv/stable-0.23/mythnetvision/PKGBUILD
+++ b/abs/core-testing/mythtv/stable-0.23/mythnetvision/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=mythnetvision
 pkgver=0.23
-pkgrel=4
+pkgrel=5
 pkgdesc="Internet video plugin for MythTV"
 url="http://www.mythtv.org"
 license="GPL"
-- 
cgit v0.12


From e49e4b1261f04d4df8077ca9699c6edfaddbc1a5 Mon Sep 17 00:00:00 2001
From: Cecil Hugh Watson <knoppmyth@gmail.com>
Date: Mon, 3 May 2010 23:29:54 -0700
Subject: myththemes:bumped to ensure latest (adds Childish theme).

---
 abs/core-testing/mythtv/stable-0.23/myththemes/PKGBUILD | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/abs/core-testing/mythtv/stable-0.23/myththemes/PKGBUILD b/abs/core-testing/mythtv/stable-0.23/myththemes/PKGBUILD
index 6ceba8b..371ce97 100755
--- a/abs/core-testing/mythtv/stable-0.23/myththemes/PKGBUILD
+++ b/abs/core-testing/mythtv/stable-0.23/myththemes/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=myththemes
 pkgver=0.23
-pkgrel=4
+pkgrel=5
 pkgdesc="Themes for MythTV"
 url="http://www.mythtv.org"
 license="GPL"
-- 
cgit v0.12


From 80935cb2b9bef89b51d7237273b54b667760f947 Mon Sep 17 00:00:00 2001
From: Cecil Hugh Watson <knoppmyth@gmail.com>
Date: Mon, 10 May 2010 16:21:12 -0700
Subject: mythtv:bumped to build 0.23 "release".

---
 abs/core-testing/mythtv/stable-0.23/mythtv/PKGBUILD | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/abs/core-testing/mythtv/stable-0.23/mythtv/PKGBUILD b/abs/core-testing/mythtv/stable-0.23/mythtv/PKGBUILD
index d213525..0af81c7 100755
--- a/abs/core-testing/mythtv/stable-0.23/mythtv/PKGBUILD
+++ b/abs/core-testing/mythtv/stable-0.23/mythtv/PKGBUILD
@@ -1,6 +1,6 @@
 pkgname=mythtv
 pkgver=0.23
-pkgrel=19
+pkgrel=20
 pkgdesc="A personal video recorder for Linux"
 url="http://www.mythtv.org"
 license="GPL"
-- 
cgit v0.12


From 9fb9454e24c794fa8294dec0c50dbede1d38dd07 Mon Sep 17 00:00:00 2001
From: Cecil Hugh Watson <knoppmyth@gmail.com>
Date: Mon, 10 May 2010 16:21:31 -0700
Subject: v4l-dvb:bumped for newer modules.

---
 abs/core-testing/v4l-dvb/PKGBUILD | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/abs/core-testing/v4l-dvb/PKGBUILD b/abs/core-testing/v4l-dvb/PKGBUILD
index 8cd0ef8..02fc881 100644
--- a/abs/core-testing/v4l-dvb/PKGBUILD
+++ b/abs/core-testing/v4l-dvb/PKGBUILD
@@ -4,7 +4,7 @@
 pkgname=v4l-dvb
 _kernver=2.6.28-LinHES
 pkgver=1
-pkgrel=14
+pkgrel=16
 pkgdesc="V4L-DVB drivers from mercurial"
 arch=('i686' 'x86_64')
 license=('GPL2')
@@ -16,10 +16,13 @@ source=('http://linuxtv.org/hg/v4l-dvb/archive/tip.tar.gz' 'hdpvr.diff')
 
 build() {
   cd $startdir/src/v4l-dvb*/
-  patch -p1 < ../hdpvr.diff
+#  patch -p1 < ../hdpvr.diff
   make KERNDIR=/lib/modules/$_kernver/build \
   DESTDIR=$startdir/pkg KERNELRELEASE=$_kernver all || return 1
   make KERNDIR=/lib/modules/$_kernver/build \
   DESTDIR=$startdir/pkg KERNELRELEASE=$_kernver install || return 1
   rm -fr $startdir/pkg/lib/modules/$_kernver/modules*
 }
+
+md5sums=('7387b0d3fa4a43f225a17bf7a4672558'
+         'd50c96211d23fba48ebc4c5e2d1e6102')
-- 
cgit v0.12


From 1587de87b062dffdafe3b63bbd329c1eb1f91df9 Mon Sep 17 00:00:00 2001
From: Cecil Hugh Watson <knoppmyth@gmail.com>
Date: Mon, 10 May 2010 16:21:51 -0700
Subject: asciidoc:initial inclusion

---
 abs/extra-testing/asciidoc/ChangeLog | 10 ++++++++++
 abs/extra-testing/asciidoc/PKGBUILD  | 30 ++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
 create mode 100644 abs/extra-testing/asciidoc/ChangeLog
 create mode 100644 abs/extra-testing/asciidoc/PKGBUILD

diff --git a/abs/extra-testing/asciidoc/ChangeLog b/abs/extra-testing/asciidoc/ChangeLog
new file mode 100644
index 0000000..e9e5156
--- /dev/null
+++ b/abs/extra-testing/asciidoc/ChangeLog
@@ -0,0 +1,10 @@
+
+2009-11-07  Chris Brannon <cmbrannon79@gmail.com>
+
+	* Fixed optdepends, converted to arch=('any').
+
+
+2008-07-06  Douglas Soares de Andrade  <douglas@archlinux.org>
+
+	* Updated for x86_64 - 8.2.7
+
diff --git a/abs/extra-testing/asciidoc/PKGBUILD b/abs/extra-testing/asciidoc/PKGBUILD
new file mode 100644
index 0000000..2a73a22
--- /dev/null
+++ b/abs/extra-testing/asciidoc/PKGBUILD
@@ -0,0 +1,30 @@
+# Maintainer: Daniel J Griffiths <ghost1227@archlinux.us>
+# Contributor: Chris Brannon <cmbrannon79@gmail.com>
+# Contributor: Geoffroy Carrier <geoffroy@archlinux.org>
+# Contributor: Dan McGee <dan@archlinux.org>
+# Contributor: Jaroslaw Rosiek <philosoph@interia.pl>
+# Contributor: Darwin Bautista <djclue917@gmail.com>
+
+pkgname=asciidoc
+pkgver=8.5.3
+pkgrel=2
+pkgdesc="Text document format for short documents, articles, books and UNIX man pages"
+arch=('any')
+url="http://www.methods.co.nz/asciidoc/"
+license=('GPL')
+depends=('python' 'libxslt' 'docbook-xsl')
+optdepends=('lilypond: music-filter'
+	    'imagemagick: music-filter (used in conjunction with lilypond)'
+	    'source-highlight: source-highlight-filter'
+	    'fop: pdf generation'
+	    'lynx: text generation'
+	    'w3m: text generation (alternative to lynx)')
+source=(http://downloads.sourceforge.net/asciidoc/asciidoc-${pkgver}.tar.gz)
+
+build() {
+  cd ${srcdir}/${pkgname}-${pkgver}
+  ./configure --prefix=/usr --sysconfdir=/etc || return 1
+  make install DESTDIR="${pkgdir}" || return 1
+  install -Dm644 asciidocapi.py ${pkgdir}/usr/lib/python2.6/site-packages/asciidocapi.py
+}
+md5sums=('7377872275c2a575151655b19ac6dd3e')
-- 
cgit v0.12


From 67d9a0569866a6fd5e6b8df6c4600916e6e4ae5b Mon Sep 17 00:00:00 2001
From: Cecil Hugh Watson <knoppmyth@gmail.com>
Date: Mon, 10 May 2010 16:22:04 -0700
Subject: evtest:initial inclusion

---
 abs/extra-testing/evtest/PKGBUILD    | 24 ++++++++++++++++++++++++
 abs/extra-testing/evtest/evtest.diff | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)
 create mode 100644 abs/extra-testing/evtest/PKGBUILD
 create mode 100644 abs/extra-testing/evtest/evtest.diff

diff --git a/abs/extra-testing/evtest/PKGBUILD b/abs/extra-testing/evtest/PKGBUILD
new file mode 100644
index 0000000..0952c5e
--- /dev/null
+++ b/abs/extra-testing/evtest/PKGBUILD
@@ -0,0 +1,24 @@
+# Contributor: Andrej Gelenberg <andrej.gelenberg@udo.edu>
+pkgname=evtest
+pkgver=1.25
+pkgrel=2
+pkgdesc="Simple tool for input event debugging."
+arch=('i686' 'x86_64')
+url="http://cgit.freedesktop.org/~whot/evtest/"
+license=('GPL')
+depends=(libxml2)
+makedepends=(xmlto asciidoc)
+optdepends=(libxslt)
+source=("http://cgit.freedesktop.org/~whot/evtest/snapshot/$pkgname-$pkgver.zip" "evtest.diff")
+
+build()
+{
+ cd $srcdir/$pkgname-$pkgver
+ patch -p1 < ../evtest.diff || return 1
+ autoreconf -iv
+ ./configure --prefix=/usr 
+ make || return 1
+ make DESTDIR=${startdir}/pkg install
+}
+md5sums=('1edddfcd366bb52490e08cbf1dbaeddf'
+         '1753bd5825ca7e5244a1a09029b8a47d')
diff --git a/abs/extra-testing/evtest/evtest.diff b/abs/extra-testing/evtest/evtest.diff
new file mode 100644
index 0000000..0dc7ba5
--- /dev/null
+++ b/abs/extra-testing/evtest/evtest.diff
@@ -0,0 +1,32 @@
+diff -ruaN evtest-1.25.orig/evtest-capture.c evtest-1.25/evtest-capture.c
+--- evtest-1.25.orig/evtest-capture.c	2009-12-02 22:24:44.000000000 +0000
++++ evtest-1.25/evtest-capture.c	2010-05-06 08:38:03.000000000 +0000
+@@ -560,16 +560,6 @@
+ 	[ABS_TOOL_WIDTH] = "ABS_TOOL_WIDTH",
+ 	[ABS_VOLUME] = "ABS_VOLUME",
+ 	[ABS_MISC] = "ABS_MISC",
+-	[ABS_MT_TOUCH_MAJOR] = "ABS_MT_TOUCH_MAJOR",
+-	[ABS_MT_TOUCH_MINOR] = "ABS_MT_TOUCH_MINOR",
+-	[ABS_MT_WIDTH_MAJOR] = "ABS_MT_WIDTH_MAJOR",
+-	[ABS_MT_WIDTH_MINOR] = "ABS_MT_WIDTH_MINOR",
+-	[ABS_MT_ORIENTATION] = "ABS_MT_ORIENTATION",
+-	[ABS_MT_POSITION_X] = "ABS_MT_POSITION_X",
+-	[ABS_MT_POSITION_Y] = "ABS_MT_POSITION_Y",
+-	[ABS_MT_TOOL_TYPE] = "ABS_MT_TOOL_TYPE",
+-	[ABS_MT_BLOB_ID] = "ABS_MT_BLOB_ID",
+-	[ABS_MT_TRACKING_ID] = "ABS_MT_TRACKING_ID",
+ };
+ 
+ const char *misc[MSC_MAX + 1] = {
+diff -ruaN evtest-1.25.orig/evtest.c evtest-1.25/evtest.c
+--- evtest-1.25.orig/evtest.c	2009-12-02 22:24:44.000000000 +0000
++++ evtest-1.25/evtest.c	2010-05-06 08:38:21.000000000 +0000
+@@ -192,7 +192,7 @@
+ 	[BTN_TOOL_MOUSE] = "ToolMouse",		[BTN_TOOL_LENS] = "ToolLens",
+ 	[BTN_TOUCH] = "Touch",			[BTN_STYLUS] = "Stylus",
+ 	[BTN_STYLUS2] = "Stylus2",		[BTN_TOOL_DOUBLETAP] = "Tool Doubletap",
+-	[BTN_TOOL_TRIPLETAP] = "Tool Tripletap", [BTN_TOOL_QUADTAP] = "Tool Quadtap",
++	[BTN_TOOL_TRIPLETAP] = "Tool Tripletap",
+ 	[BTN_GEAR_DOWN] = "WheelBtn",
+ 	[BTN_GEAR_UP] = "Gear up",		[KEY_OK] = "Ok",
+ 	[KEY_SELECT] = "Select",		[KEY_GOTO] = "Goto",
-- 
cgit v0.12


From 0840ae3ae3ae205d6fc6e7638292b45406a3b652 Mon Sep 17 00:00:00 2001
From: Cecil Hugh Watson <knoppmyth@gmail.com>
Date: Mon, 10 May 2010 16:22:25 -0700
Subject: sdlmame:patched with support for wiimotes as lightguns!

---
 abs/extra-testing/sdlmame/PKGBUILD               |  13 +-
 abs/extra-testing/sdlmame/mame-0137-wiimote.diff | 424 +++++++++++++++++++++++
 2 files changed, 432 insertions(+), 5 deletions(-)
 create mode 100644 abs/extra-testing/sdlmame/mame-0137-wiimote.diff

diff --git a/abs/extra-testing/sdlmame/PKGBUILD b/abs/extra-testing/sdlmame/PKGBUILD
index f59b7f2..2718a57 100644
--- a/abs/extra-testing/sdlmame/PKGBUILD
+++ b/abs/extra-testing/sdlmame/PKGBUILD
@@ -5,7 +5,7 @@
 pkgname=sdlmame
 pkgver=0.137
 _basever=0137
-pkgrel=2
+pkgrel=3
 pkgdesc="A port of the popular Multiple Arcade Machine Emulator using SDL with OpenGL support."
 url="http://mamedev.org/"
 license=('custom:MAME License')
@@ -21,10 +21,8 @@ source=("http://aarongiles.com/mirror/releases/mame0137s.zip"
 #	"http://mamedev.org/updates/0136u2_diff.zip"
 #	"http://mamedev.org/updates/0136u3_diff.zip"
 	"sdlmame.sh"
-	"extras.tar.gz")
-md5sums=('ce9e5359e882d5a8219821e39bd4f27a'
-         '3119ccfa1e970eba4467df31208adaf0'
-         '420b61240bf5ae11615ba7c6100ee00d')
+	"extras.tar.gz"
+	"mame-0137-wiimote.diff")
 
 build() {
   cd $srcdir/
@@ -35,6 +33,7 @@ build() {
 #    patch -p0 -E <0136u1.diff
 #    patch -p0 -E <0136u2.diff
 #    patch -p0 -E <0136u3.diff
+    patch -p1 < ../mame-0137-wiimote.diff || return 1
     sed -i 's/-Werror//' makefile || return 1
   fi
 
@@ -84,3 +83,7 @@ build() {
 
   find $pkgdir -type f -exec strip {} \;
 }
+md5sums=('ce9e5359e882d5a8219821e39bd4f27a'
+         '3119ccfa1e970eba4467df31208adaf0'
+         '420b61240bf5ae11615ba7c6100ee00d'
+         '07ba30c6054bf864f7c1300bfef03b81')
diff --git a/abs/extra-testing/sdlmame/mame-0137-wiimote.diff b/abs/extra-testing/sdlmame/mame-0137-wiimote.diff
new file mode 100644
index 0000000..8f29b8e
--- /dev/null
+++ b/abs/extra-testing/sdlmame/mame-0137-wiimote.diff
@@ -0,0 +1,424 @@
+diff -BNburp mame-org/makefile mame-wiimote/makefile
+diff -BNburp mame-org/src/osd/sdl/input.c mame-wiimote/src/osd/sdl/input.c
+--- mame-org/src/osd/sdl/input.c	2010-02-28 04:16:40.000000000 +0100
++++ mame-wiimote/src/osd/sdl/input.c	2010-05-07 13:53:59.000000000 +0200
+@@ -17,6 +17,12 @@
+ #include <ctype.h>
+ #include <stddef.h>
+ 
++// for xinput
++#include <X11/Xlib.h>
++#include <X11/extensions/XInput.h>
++#include <X11/Xutil.h>
++
++
+ // MAME headers
+ #include "emu.h"
+ #include "ui.h"
+@@ -53,6 +59,16 @@ enum
+ #define MAX_POV				4
+ #define MAX_DEVMAP_ENTRIES	16
+ 
++//For xinput
++#define INVALID_EVENT_TYPE	-1
++static int           motion_type = INVALID_EVENT_TYPE;
++static int           button_press_type = INVALID_EVENT_TYPE;
++static int           button_release_type = INVALID_EVENT_TYPE;
++static int           key_press_type = INVALID_EVENT_TYPE;
++static int           key_release_type = INVALID_EVENT_TYPE;
++static int           proximity_in_type = INVALID_EVENT_TYPE;
++static int           proximity_out_type = INVALID_EVENT_TYPE;
++
+ //============================================================
+ //  MACROS
+ //============================================================
+@@ -86,6 +102,16 @@ struct _mouse_state
+ 	INT32 buttons[MAX_BUTTONS];
+ };
+ 
++// state information for a lightgun
++typedef struct _lightgun_state lightgun_state;
++struct _lightgun_state
++{
++	INT32 lX, lY;
++	INT32 buttons[MAX_BUTTONS];
++	XID deviceid; //Xinput device id
++	INT32 maxx,maxy;
++	INT32 minx,miny;
++};
+ 
+ // state information for a joystick; DirectInput state must be first element
+ typedef struct _joystick_state joystick_state;
+@@ -115,6 +141,7 @@ struct _device_info
+ 		keyboard_state		keyboard;
+ 		mouse_state		mouse;
+ 		joystick_state		joystick;
++		lightgun_state		lightgun;
+ 	};
+ };
+ 
+@@ -164,10 +191,13 @@ struct _device_map_t
+ 
+ static device_map_t joy_map;
+ static device_map_t mouse_map;
++static device_map_t lightgun_map;
+ static device_map_t keyboard_map;
+ 
+ static int sixaxis_mode;
+ 
++Display *XDisplay;
++
+ 
+ //============================================================
+ //  PROTOTYPES
+@@ -671,6 +703,244 @@ static device_info *devmap_class_registe
+ 	return devinfo;
+ }
+ 
++//============================================================
++//  WiiMote lightgun stuff
++//============================================================
++
++//Copypasted from xinfo
++XDeviceInfo*
++find_device_info(Display	*display,
++		 char		*name,
++		 Bool		only_extended)
++{
++    XDeviceInfo	*devices;
++    XDeviceInfo *found = NULL;
++    int		loop;
++    int		num_devices;
++    int		len = strlen(name);
++    Bool	is_id = True;
++    XID		id=0;
++
++    for(loop=0; loop<len; loop++) {
++	if (!isdigit(name[loop])) {
++	    is_id = False;
++	    break;
++	}
++    }
++
++    if (is_id) {
++	id = atoi(name);
++    }
++
++    devices = XListInputDevices(display, &num_devices);
++
++    for(loop=0; loop<num_devices; loop++) {
++	if ((!only_extended || (devices[loop].use >= IsXExtensionDevice)) &&
++	    ((!is_id && strcmp(devices[loop].name, name) == 0) ||
++	     (is_id && devices[loop].id == id))) {
++	    if (found) {
++	        fprintf(stderr,
++	                "Warning: There are multiple devices named \"%s\".\n"
++	                "To ensure the correct one is selected, please use "
++	                "the device ID instead.\n\n", name);
++	    } else {
++		found = &devices[loop];
++	    }
++	}
++    }
++    return found;
++}
++
++//Copypasted from xinfo
++static int
++register_events(Display		*dpy,
++		XDeviceInfo	*info,
++		char		*dev_name,
++		Bool		handle_proximity)
++{
++    int			number = 0;	/* number of events registered */
++    XEventClass		event_list[7];
++    int			i;
++    XDevice		*device;
++    Window		root_win;
++    unsigned long	screen;
++    XInputClassInfo	*ip;
++
++    screen = DefaultScreen(dpy);
++    root_win = RootWindow(dpy, screen);
++
++    device = XOpenDevice(dpy, info->id);
++
++    if (!device) {
++	fprintf(stderr, "unable to open device %s\n", dev_name);
++	return 0;
++    }
++
++    if (device->num_classes > 0) {
++	for (ip = device->classes, i=0; i<info->num_classes; ip++, i++) {
++	    switch (ip->input_class) {
++	    case KeyClass:
++		DeviceKeyPress(device, key_press_type, event_list[number]); number++;
++		DeviceKeyRelease(device, key_release_type, event_list[number]); number++;
++		break;
++
++	    case ButtonClass:
++		DeviceButtonPress(device, button_press_type, event_list[number]); number++;
++		DeviceButtonRelease(device, button_release_type, event_list[number]); number++;
++		break;
++
++	    case ValuatorClass:
++		DeviceMotionNotify(device, motion_type, event_list[number]); number++;
++		fprintf(stderr, "Motion = %i\n",motion_type);
++		if (handle_proximity) {
++		    ProximityIn(device, proximity_in_type, event_list[number]); number++;
++		    ProximityOut(device, proximity_out_type, event_list[number]); number++;
++		}
++		break;
++
++	    default:
++		fprintf(stderr, "unknown class\n");
++		break;
++	    }
++	}
++
++	if (XSelectExtensionEvent(dpy, root_win, event_list, number)) {
++	    fprintf(stderr, "error selecting extended events\n");
++	    return 0;
++	}
++    }
++    return number;
++}
++
++
++
++static void sdlinput_register_lightguns(running_machine *machine)
++{
++	int index;
++	XExtensionVersion	*version;
++	
++	lightgun_enabled = options_get_bool(mame_options(), OPTION_LIGHTGUN);
++	devmap_init(machine, &lightgun_map, SDLOPTION_LIGHTGUNINDEX, 8, "Lightgun mapping");
++	
++	XDisplay = XOpenDisplay(NULL);
++
++	if (XDisplay == NULL) {
++	    fprintf(stderr, "Unable to connect to X server\n");
++	    return;
++	}
++
++	version = XGetExtensionVersion(XDisplay, INAME);
++
++	if (!version || (version == (XExtensionVersion*) NoSuchExtension)) {
++	    fprintf(stderr, "xinput extension not available!\n");
++	    return;
++	}
++
++
++	for (index=0; index<8; index++) {
++	    XDeviceInfo *info;
++	    if (strlen(lightgun_map.map[index].name)!=0) {
++		device_info *devinfo;
++		char *name=lightgun_map.map[index].name;
++		char defname[512];
++		devinfo = devmap_class_register(machine, &lightgun_map, index, &lightgun_list, DEVICE_CLASS_LIGHTGUN);
++		fprintf(stderr, "%i: %s\n",index, name);
++		info=find_device_info(XDisplay, name, 0);
++		if (!info) continue;
++
++		//Grab device info and translate to stuff mame can use
++		if (info->num_classes > 0) {
++		    XAnyClassPtr any = (XAnyClassPtr) (info->inputclassinfo);
++		    int i;
++		    for (i=0; i<info->num_classes; i++) {
++			int button;
++			XValuatorInfoPtr v;
++			XAxisInfoPtr a;
++			int j;
++			XButtonInfoPtr b;
++			switch (any->c_class) {
++			case ButtonClass:
++			    b = (XButtonInfoPtr) any;
++			    for (button = 0; button < b->num_buttons; button++)
++			    {
++				input_item_id itemid;
++				sprintf(defname, "B%d", button + 1);
++				itemid=(input_item_id) (ITEM_ID_BUTTON1+button);
++				input_device_item_add(devinfo->device, defname, &devinfo->lightgun.buttons[button], itemid, generic_button_get_state);
++			    }
++			    break;
++			case ValuatorClass:
++			    v = (XValuatorInfoPtr) any;
++			    a = (XAxisInfoPtr) ((char *) v + sizeof (XValuatorInfo));
++			    for (j=0; j<v->num_axes; j++, a++) {
++				if (j==0) {
++				    devinfo->lightgun.maxx=a->max_value;
++				    devinfo->lightgun.minx=a->min_value;
++				}
++				if (j==1) {
++				    devinfo->lightgun.maxy=a->max_value;
++				    devinfo->lightgun.miny=a->min_value;
++				}
++			    }
++			    break;
++			}
++		    any = (XAnyClassPtr) ((char *) any + any->length);
++		    }
++		}
++
++
++		sprintf(defname, "X %s", devinfo->name);
++		input_device_item_add(devinfo->device, defname, &devinfo->lightgun.lX, ITEM_ID_XAXIS, generic_axis_get_state);
++		sprintf(defname, "Y %s", devinfo->name);
++		input_device_item_add(devinfo->device, defname, &devinfo->lightgun.lY, ITEM_ID_YAXIS, generic_axis_get_state);
++
++
++		devinfo->lightgun.deviceid=info->id;
++		if (!info) {
++		    fprintf(stderr, "Can't find device %s!\n", lightgun_map.map[index].name);
++		} else {
++		    fprintf(stderr, "Device %i: Registered %i events.\n",(int)info->id, register_events(XDisplay, info, lightgun_map.map[index].name, 0));
++		}
++	    }
++	}
++	mame_printf_verbose("Lightgun: End initialization\n");
++}
++
++device_info *get_lightgun_info_for_deviceid(XID deviceid) {
++    device_info *devinfo;
++    int index;
++    //Find lightgun according to device id
++    for (index=0; ; index++) {
++	devinfo = generic_device_find_index(lightgun_list, index);
++	if (devinfo==NULL) break;
++	if (devinfo->lightgun.deviceid==deviceid) break;
++    }
++    return devinfo;
++}
++
++int normalize_absolute_axis(int raw, int rawmin, int rawmax)
++{
++	int center = (rawmax + rawmin) / 2;
++
++	// make sure we have valid data
++	if (rawmin >= rawmax)
++		return raw;
++
++	// above center
++	if (raw >= center)
++	{
++		int result = (long)(raw - center) * (long)INPUT_ABSOLUTE_MAX / (long)(rawmax - center);
++		return MIN(result, INPUT_ABSOLUTE_MAX);
++	}
++
++	// below center
++	else
++	{
++		int result = -((long)(center - raw) * (long)-INPUT_ABSOLUTE_MIN / (long)(center - rawmin));
++		return MAX(result, INPUT_ABSOLUTE_MIN);
++	}
++}
++
+ 
+ //============================================================
+ //  sdlinput_register_joysticks
+@@ -1115,6 +1385,9 @@ void sdlinput_init(running_machine *mach
+ 	// register the mice
+ 	sdlinput_register_mice(machine);
+ 
++	// register the lightguns
++	sdlinput_register_lightguns(machine);
++
+ 	if (machine->debug_flags & DEBUG_FLAG_OSD_ENABLED)
+ 	{
+ 		mame_printf_warning("Debug Build: Disabling input grab for -debug\n");
+@@ -1131,6 +1404,7 @@ void sdlinput_init(running_machine *mach
+ 	device_list_reset_devices(keyboard_list);
+ 	device_list_reset_devices(mouse_list);
+ 	device_list_reset_devices(joystick_list);
++	device_list_reset_devices(lightgun_list);
+ 
+ }
+ 
+@@ -1248,6 +1522,7 @@ void sdlinput_poll(running_machine *mach
+ 	device_info *devinfo;
+ 	SDL_Event event;
+ 	int index;
++	XEvent xevent;
+ 
+ 	// only for SDLMAME_EVENTS_IN_WORKER_THREAD
+ 	SDL_Event			loc_event_buf[MAX_BUF_EVENTS];
+@@ -1263,6 +1538,21 @@ void sdlinput_poll(running_machine *mach
+ 		devinfo->mouse.lY = 0;
+ 	}
+ 
++	//Get XInput events
++	while (XPending(XDisplay)!=0) {
++	    XNextEvent(XDisplay, &xevent);
++	    if (xevent.type==motion_type) {
++		XDeviceMotionEvent *motion = (XDeviceMotionEvent *) &xevent;
++		devinfo=get_lightgun_info_for_deviceid(motion->deviceid);
++		devinfo->lightgun.lX=normalize_absolute_axis(motion->axis_data[0], devinfo->lightgun.minx, devinfo->lightgun.maxx);
++		devinfo->lightgun.lY=normalize_absolute_axis(motion->axis_data[1], devinfo->lightgun.miny, devinfo->lightgun.maxy);
++	    } else if (xevent.type==button_press_type || xevent.type==button_release_type) {
++		XDeviceButtonEvent *button = (XDeviceButtonEvent *) &xevent;
++		devinfo=get_lightgun_info_for_deviceid(button->deviceid);
++		devinfo->lightgun.buttons[button->button]=(xevent.type==button_press_type)?0x80:0;
++	    }
++	}
++
+ 	if (SDLMAME_EVENTS_IN_WORKER_THREAD)
+ 	{
+ 		osd_lock_acquire(input_lock);
+diff -BNburp mame-org/src/osd/sdl/osdsdl.h mame-wiimote/src/osd/sdl/osdsdl.h
+--- mame-org/src/osd/sdl/osdsdl.h	2010-02-12 14:42:32.000000000 +0100
++++ mame-wiimote/src/osd/sdl/osdsdl.h	2010-05-07 08:53:34.000000000 +0200
+@@ -130,3 +130,4 @@ void sdlaudio_init(running_machine *mach
+ extern int sdl_num_processors;
+ 
+ #endif
++#define SDLOPTION_LIGHTGUNINDEX			"lightgun_index"  
+diff -BNburp mame-org/src/osd/sdl/sdlmain.c mame-wiimote/src/osd/sdl/sdlmain.c
+--- mame-org/src/osd/sdl/sdlmain.c	2010-02-13 12:19:16.000000000 +0100
++++ mame-wiimote/src/osd/sdl/sdlmain.c	2010-05-07 08:54:03.000000000 +0200
+@@ -190,6 +190,17 @@ static const options_entry mame_sdl_opti
+ 	{ SDLOPTION_JOYINDEX "8",                SDLOPTVAL_AUTO, 0,         "name of joystick mapped to joystick #8" },
+ 	{ SDLOPTION_SIXAXIS,			         "0",	 OPTION_BOOLEAN,    "Use special handling for PS3 Sixaxis controllers" },
+ 
++	{ NULL, 		                         NULL,   OPTION_HEADER,     "SDL LIGHTGUN MAPPING" },
++	{ SDLOPTION_LIGHTGUNINDEX "1",              SDLOPTVAL_AUTO, 0,         "name of lightgun mapped to lightgun #1" },
++	{ SDLOPTION_LIGHTGUNINDEX "2",              SDLOPTVAL_AUTO, 0,         "name of lightgun mapped to lightgun #2" },
++	{ SDLOPTION_LIGHTGUNINDEX "3",              SDLOPTVAL_AUTO, 0,         "name of lightgun mapped to lightgun #3" },
++	{ SDLOPTION_LIGHTGUNINDEX "4",              SDLOPTVAL_AUTO, 0,         "name of lightgun mapped to lightgun #4" },
++	{ SDLOPTION_LIGHTGUNINDEX "5",              SDLOPTVAL_AUTO, 0,         "name of lightgun mapped to lightgun #5" },
++	{ SDLOPTION_LIGHTGUNINDEX "6",              SDLOPTVAL_AUTO, 0,         "name of lightgun mapped to lightgun #6" },
++	{ SDLOPTION_LIGHTGUNINDEX "7",              SDLOPTVAL_AUTO, 0,         "name of lightgun mapped to lightgun #7" },
++	{ SDLOPTION_LIGHTGUNINDEX "8",              SDLOPTVAL_AUTO, 0,         "name of lightgun mapped to lightgun #8" },
++
++
+ #if (SDL_VERSION_ATLEAST(1,3,0))
+ 	{ NULL, 		                         NULL,   OPTION_HEADER,     "SDL MOUSE MAPPING" },
+ 	{ SDLOPTION_MOUSEINDEX "1",              SDLOPTVAL_AUTO, 0,         "name of mouse mapped to mouse #1" },
+diff -BNburp mame-org/src/osd/sdl/window.c mame-wiimote/src/osd/sdl/window.c
+--- mame-org/src/osd/sdl/window.c	2010-02-12 07:40:12.000000000 +0100
++++ mame-wiimote/src/osd/sdl/window.c	2010-05-07 08:54:54.000000000 +0200
+@@ -659,8 +659,17 @@ static void sdlwindow_update_cursor_stat
+ 	}
+ 
+ #else
++	//Hack for wii-lightguns: they stop working with a grabbed mouse; even a ShowCursor(SDL_DISABLE) already
++	//does this. To make the cursor disappear, we'll just set an empty cursor image.
++	unsigned char data[]={0,0,0,0,0,0,0,0};
++	SDL_Cursor *c;
++	c=SDL_CreateCursor(data, data, 8, 8, 0, 0);
++	SDL_SetCursor(c);
++
++
+ 	// do not do mouse capture if the debugger's enabled to avoid
+ 	// the possibility of losing control
++/*
+ 	if (!(machine->debug_flags & DEBUG_FLAG_OSD_ENABLED))
+ 	{
+ 		if ( window->fullscreen || sdlinput_should_hide_mouse(machine) )
+@@ -680,6 +689,7 @@ static void sdlwindow_update_cursor_stat
+ 			}
+ 		}
+ 	}
++*/
+ #endif
+ }
+ 
-- 
cgit v0.12