[mupen64plus-input-sdl] 64/196: Imported Upstream version 1.99.5~hg20110828

Sven Eckelmann ecsv-guest at moszumanska.debian.org
Thu Nov 26 06:00:17 UTC 2015


This is an automated email from the git hooks/post-receive script.

ecsv-guest pushed a commit to branch master
in repository mupen64plus-input-sdl.

commit 0f727bbd1cd86f62d6094c1f04a63602ad1d58bf
Author: Sven Eckelmann <sven at narfation.org>
Date:   Sun Aug 28 18:47:08 2011 +0200

    Imported Upstream version 1.99.5~hg20110828
---
 README                 |  33 ++++++-----
 data/InputAutoCfg.ini  | 109 +++++++++++++++++++++++++++++++++++-
 projects/unix/Makefile | 149 +++++++++++++++++++++++++++----------------------
 src/config.c           |  18 +++++-
 src/config.h           |   1 -
 src/osal_preproc.h     |   2 +-
 src/plugin.c           |  79 ++++++++++++++++++--------
 src/plugin.h           |   2 +
 src/version.h          |   6 +-
 9 files changed, 286 insertions(+), 113 deletions(-)

diff --git a/README b/README
index 5b0128e..35786f9 100644
--- a/README
+++ b/README
@@ -8,24 +8,37 @@
 
 ********Notes for supported joysticks for auto-configuration:
 
-1. Logitech Dual Action gamepad, Logitech Cordless Rumblepad 2:
+1. Jess Tech Rumble Pad (Saitek Rumble)
+The left D-pad is mapped to the D-pad; The joystick is mapped to the left joystick of the gamepad; the C buttons are mapped to the gampad's right joystick. Start button is mapped to start; the A-button is mapped to the lowest button on the gamepad's right front; the B-button to the left button (buttons marked 3 and 1 on my gamepad). The L and R buttons are mapped to the lower left and right rear triggers; the Z button is mapped to the left upper rear trigger. All other buttons are unused. 
+
+2. Logitech Dual Action gamepad, Logitech Cordless Rumblepad 2:
 The digital pad maps to the N64 d-pad.  The left analog stick maps to the N64 analog stick.
 The right analog stick maps to the C-buttons,  and the buttons 2 and 1 map to A and B.
 Button 4 is the Z trigger, and the top shoulder buttons map to the left and right N64 triggers.
 Button 10 is the start button.
 The bottom shoulder buttons select the memory pack or rumble pak.
 
-2. Microsoft X-Box 360 pad:
+3. Microsoft X-Box 360 pad:
 C button U (up) and C button R (right) are assigned to the Y and B buttons.
 All 4 C buttons are assigned to the U and V axis (including the already configured up and right C buttons).
 The Z button has been assigned to the left trigger and switching the rumble on and off can be done with the right trigger.
 Because there are no other buttons left I decided to use the button click behavior of the left joystick to switch Mempak on and off.
 
-3. N64 controller:
+4. N64 controller:
 All controls are mapped to their proper place on the N64 controller with an Adaptoid or custom hardware with Gamecon driver.
 Rumble and Memory packs can be selected with the 'r' and 'm' keys, respectively.
 
-4. SAITEK P880:
+5. Playstation 3 Controller:
+Left analog stick - analog stick
+Right analog stick - C-pad
+D-Pad - D-Pad
+Cross - A
+Square - B
+L1 / R1 - L / R
+L2 - Z
+Start - Start
+
+6. SAITEK P880:
 Notes:
 The gamepad doesnt have enough keys to real assign all buttons. The second 
 analog stick can be used as button by pushing him insight.
@@ -39,17 +52,7 @@ used for A and B and the second and third row was used for C-Buttons - except
 for the Button next to the A button which would be C-Down but got the Z 
 button.
 
-5. Playstation 3 Controller:
-Left analog stick - analog stick
-Right analog stick - C-pad
-D-Pad - D-Pad
-Cross - A
-Square - B
-L1 / R1 - L / R
-L2 - Z
-Start - Start
-
-6. Default Keyboard interface:
+7. Default Keyboard interface:
 Analog Pad is "Arrow Keys"
 C Up/Left/Down/Right are "I", "J", "K", "L"
 DPad Up/Left/Down/Right are "W", "A", "S", "D"
diff --git a/data/InputAutoCfg.ini b/data/InputAutoCfg.ini
index f41d14b..4483d9f 100644
--- a/data/InputAutoCfg.ini
+++ b/data/InputAutoCfg.ini
@@ -125,6 +125,32 @@ Rumblepak switch = button(0)
 X Axis = axis(0-,0+)
 Y Axis = axis(1-,1+)
 
+; raphnet technologies USB converter (http://www.raphnet-tech.com/)
+[GC/N64_USB]
+plugged = True
+plugin = 2
+mouse = False
+AnalogDeadzone = 4096,4096
+AnalogPeak = 32768,32768
+DPad R = button(13)
+DPad L = button(12)
+DPad D = button(11)
+DPad U = button(10)
+Start = button(3)
+Z Trig = button(2)
+B Button = button(1)
+A Button = button(0)
+C Button R = button(7)
+C Button L = button(6)
+C Button D = button(5)
+C Button U = button(4)
+R Trig = button(9)
+L Trig = button(8)
+Mempak switch = 
+Rumblepak switch = 
+X Axis = axis(0-,0+)
+Y Axis = axis(1-,1+)
+
 [GreenAsia Inc. USB Joystick]
 plugged = True
 plugin = 2
@@ -175,6 +201,31 @@ Rumblepak switch =
 X Axis = axis(0-,0+)
 Y Axis = axis(1-,1+)
 
+[Jess Tech Colour Rumble Pad]
+plugged = True
+plugin = 1
+mouse = False
+AnalogDeadzone = 4096,4096
+AnalogPeak = 32768,32768
+DPad R = hat(0 Right)
+DPad L = hat(0 Left)
+DPad D = hat(0 Down)
+DPad U = hat(0 Up)
+Start = button(9)
+Z Trig = button(4)
+B Button = button(0)
+A Button = button(2)
+C Button R = axis(3+)
+C Button L = axis(3-)
+C Button D = axis(2+)
+C Button U = axis(2-)
+R Trig = button(7)
+L Trig = button(5)
+Mempak switch =
+Rumblepak switch =
+X Axis = axis(0-,0+)
+Y Axis = axis(1-,1+)
+
 [Logitech Cordless Rumblepad 2]
 [Logitech RumblePad 2 USB]
 [Logitech Dual Action]
@@ -525,8 +576,7 @@ Rumblepak switch =
 Y Axis = axis(1-,1+)
 X Axis = axis(0-,0+)
 
-[Sony PLAYSTATION(R)3 Controller]
-[OSX: PLAYSTATION(R)3 Controller]
+[PLAYSTATION(R)3 Controller]
 plugged = True
 plugin = 2
 mouse = False
@@ -629,6 +679,8 @@ Y Axis = axis(1-,1+)
 [BigBen XBMiniPad Controller]
 [Joytech Wireless Advanced Controller]
 [Chinese-made Xbox Controller]
+[Logitech Chillstream Controller]
+[Generic X-Box pad]
 plugged = True
 plugin = 2
 mouse = False
@@ -653,9 +705,60 @@ Rumblepak switch = button(2)
 X Axis = axis(0-,0+)
 Y Axis = axis(1-,1+)
 
-[HuiJia USB GamePad]
 [OSX: USB GamePad]
 ; this is a 2-port USB device.  The Right port is controller #1, the Left port is #2
+; this is the "MayFlash" adapter, aka HuiJia.  The OSX driver seems to have a
+; different button mapping
+plugged = True
+plugin = 2
+mouse = False
+AnalogDeadzone = 2500,2500
+AnalogPeak = 20000,20000
+DPad R = button(13)
+DPad L = button(15)
+DPad D = button(14)
+DPad U = button(12)
+Start = button(9)
+Z Trig = button(8)
+B Button = button(2)
+A Button = button(1)
+C Button R = axis(1-)
+C Button L = axis(1+)
+C Button D = axis(0+)
+C Button U = axis(0-)
+R Trig = button(7)
+L Trig = button(6)
+Mempak switch = key(109)
+Rumblepak switch = key(114)
+X Axis = axis(2-,2+)
+Y Axis = axis(3-,3+)
+__NextController:
+plugged = True
+plugin = 2
+mouse = False
+AnalogDeadzone = 2500,2500
+AnalogPeak = 20000,20000
+DPad R = button(29)
+DPad L = button(31)
+DPad D = button(30)
+DPad U = button(28)
+Start = button(25)
+Z Trig = button(24)
+B Button = button(18)
+A Button = button(17)
+C Button R = axis(5-)
+C Button L = axis(5+)
+C Button D = axis(4+)
+C Button U = axis(4-)
+R Trig = button(23)
+L Trig = button(22)
+Mempak switch = key(109)
+Rumblepak switch = key(114)
+X Axis = axis(6-,6+)
+Y Axis = axis(7-,7+)
+
+[HuiJia USB GamePad]
+; this is a 2-port USB device.  The Right port is controller #1, the Left port is #2
 plugged = True
 plugin = 2
 mouse = False
diff --git a/projects/unix/Makefile b/projects/unix/Makefile
index 0a0d7ab..64f4005 100644
--- a/projects/unix/Makefile
+++ b/projects/unix/Makefile
@@ -48,6 +48,12 @@ ifeq ("$(UNAME)","FreeBSD")
   SO_EXTENSION = so
   SHARED = -shared
 endif
+ifeq ("$(UNAME)","OpenBSD")
+  OS = FREEBSD
+  SO_EXTENSION = so
+  SHARED = -shared
+  $(warning OS type "$(UNAME)" not officially supported.')
+endif
 ifneq ("$(filter GNU/kFreeBSD kfreebsd,$(UNAME))","")
   OS = LINUX
   SO_EXTENSION = so
@@ -65,42 +71,55 @@ ifneq ("$(filter x86_64 amd64,$(HOST_CPU))","")
   CPU := X86
   ifeq ("$(BITS)", "32")
     ARCH_DETECTED := 64BITS_32
+    PIC ?= 0
   else
     ARCH_DETECTED := 64BITS
+    PIC ?= 1
   endif
 endif
 ifneq ("$(filter pentium i%86,$(HOST_CPU))","")
   CPU := X86
   ARCH_DETECTED := 32BITS
+  PIC ?= 0
+endif
+ifneq ("$(filter ppc powerpc,$(HOST_CPU))","")
+  CPU := PPC
+  ARCH_DETECTED := 32BITS
+  BIG_ENDIAN := 1
+  PIC ?= 1
+  $(warning Architecture "$(HOST_CPU)" not officially supported.')
+endif
+ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","")
+  CPU := PPC
+  ARCH_DETECTED := 64BITS
+  BIG_ENDIAN := 1
+  PIC ?= 1
+  $(warning Architecture "$(HOST_CPU)" not officially supported.')
 endif
-# PPC doesn't work yet
-#ifneq ("$(filter ppc powerpc,$(HOST_CPU))","")
-#  CPU := PPC
-#  ARCH_DETECTED := 32BITS
-#endif
-#ifneq ("$(filter ppc64 powerpc64,$(HOST_CPU))","")
-#  CPU := PPC
-#  ARCH_DETECTED := 64BITS
-#endif
 ifeq ("$(CPU)","NONE")
   $(error CPU type "$(HOST_CPU)" not supported.  Please file bug report at 'http://code.google.com/p/mupen64plus/issues')
 endif
 
-# base CFLAGS, LIBS, and LDFLAGS
-CFLAGS += -ffast-math -funroll-loops -fexpensive-optimizations -fno-strict-aliasing -fvisibility=hidden -I../../src
-ifneq ($(OS), FREEBSD)
-  CFLAGS += -pipe -O3
+# base CFLAGS, LDLIBS, and LDFLAGS
+OPTFLAGS ?= -O3
+CFLAGS += $(OPTFLAGS) -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src
+LDFLAGS += $(SHARED)
+
+# Since we are building a shared library, we must compile with -fPIC on some architectures
+# On 32-bit x86 systems we do not want to use -fPIC because we don't have to and it has a big performance penalty on this arch
+ifeq ($(PIC), 1)
+  CFLAGS += -fPIC
+  LDFLAGS += -fPIC
 endif
 
-# Since we are building a shared library, we must compile with -fPIC for x86_64 CPUs.
-# On 32-bit systems we do not want to use -fPIC because we don't have to and it has a big performance penalty on this arch
-ifeq ($(ARCH_DETECTED), 64BITS)
-  CFLAGS += -fpic -DPIC
+ifeq ($(BIG_ENDIAN), 1)
+  CFLAGS += -DM64P_BIG_ENDIAN
 endif
+
 # tweak flags for 32-bit build on 64-bit system
 ifeq ($(ARCH_DETECTED), 64BITS_32)
   CFLAGS += -m32
-  LDFLAGS += -m32 -m elf_i386
+  LDFLAGS += -m32 -Wl,-m,elf_i386
 endif
 
 # set special flags per-system
@@ -110,30 +129,20 @@ ifeq ($(OS), FREEBSD)
   endif
 endif
 ifeq ($(OS), LINUX)
-  ifeq ($(CPU), X86)
-    ifeq ($(ARCH_DETECTED), 64BITS)
-      CFLAGS += -march=athlon64
-      LDFLAGS += -ldl
-    else
-      CFLAGS += -mmmx -msse -march=i686 -mtune=pentium-m -fomit-frame-pointer
-      LDFLAGS += -ldl
-    endif
-  endif
+  LDLIBS += -ldl
 endif
 ifeq ($(OS), OSX)
   ifeq ($(CPU), X86)
     ifeq ($(ARCH_DETECTED), 64BITS)
       CFLAGS += -arch x86_64 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
-      LDFLAGS += -ldl
+      LDLIBS += -ldl
     else
       CFLAGS += -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
-      LDFLAGS += -arch i686 -ldl
+      LDFLAGS += -arch i686
+      LDLIBS += -ldl
     endif
   endif
 endif
-ifeq ($(CPU), PPC)
-  CFLAGS += -mcpu=powerpc
-endif
 
 # test for presence of SDL
 ifeq ($(shell which sdl-config 2>/dev/null),)
@@ -143,10 +152,10 @@ ifeq ("$(UNAME)","Darwin")
     CFLAGS  += $(shell sdl-config --cflags)
     # sdl-config on mac screws up when we're trying to build a library and not an executable
     # SDL 1.3 is supposed to fix that, if it's ever released
-    LDFLAGS += -L/usr/local/lib -lSDL -Wl,-framework,Cocoa
+    LDLIBS += -L/usr/local/lib -lSDL -Wl,-framework,Cocoa
 else
     CFLAGS  += $(shell sdl-config --cflags)
-    LDFLAGS += $(shell sdl-config --libs)
+    LDLIBS += $(shell sdl-config --libs)
 endif
 
 # set mupen64plus core API header path
@@ -171,21 +180,29 @@ else
   endif
 endif
 
-# set shell function names
-CC      ?= gcc
-CXX     ?= g++
-LD      ?= g++
-INSTALL ?= install
-ifeq ($(OS),OSX)
-  STRIP	?= strip -x 
-else
-  STRIP	?= strip -s
+# reduced compile output when running make without V=1
+ifneq ($(findstring $(MAKEFLAGS),s),s)
+ifndef V
+    Q_CC = @echo '    CC  '$@;
+    Q_LD = @echo '    LD  '$@;
 endif
+endif
+
+# set base program pointers and flags
+CC       ?= gcc
+CXX      ?= g++
+RM       ?= rm -f
+INSTALL  ?= install
+MKDIR ?= mkdir -p
+COMPILE.c = $(Q_CC)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c
+LINK.o = $(Q_LD)$(CC) $(LDFLAGS) $(TARGET_ARCH)
 
 # set special flags for given Makefile parameters
 ifeq ($(DEBUG),1)
   CFLAGS += -g
-  STRIP = true # disable binary strip
+  INSTALL_STRIP_FLAG ?= 
+else
+  INSTALL_STRIP_FLAG ?= -s
 endif
 ifeq ($(PLUGINDBG), 1)
   CFLAGS += -D_DEBUG
@@ -199,7 +216,10 @@ ifeq ($(SHAREDIR),)
   SHAREDIR := $(PREFIX)/share/mupen64plus
 endif
 ifeq ($(LIBDIR),)
-  LIBDIR := $(PREFIX)/lib/mupen64plus
+  LIBDIR := $(PREFIX)/lib
+endif
+ifeq ($(PLUGINDIR),)
+  PLUGINDIR := $(LIBDIR)/mupen64plus
 endif
 
 SRCDIR = ../../src
@@ -215,20 +235,12 @@ SOURCE = \
 # generate a list of object files build, make a temporary directory for them
 OBJECTS := $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(filter %.c, $(SOURCE)))
 OBJDIRS = $(dir $(OBJECTS))
-$(shell mkdir -p $(OBJDIRS))
+$(shell $(MKDIR) $(OBJDIRS))
 
 # build dependency files
 CFLAGS += -MD
 -include $(OBJECTS:.o=.d)
 
-# reduced compile output when running make without V=1
-ifneq ($(findstring $(MAKEFLAGS),s),s)
-ifndef V
-    Q_CC = @echo '    CC  '$@;
-    Q_LD = @echo '    LD  '$@;
-endif
-endif
-
 # build targets
 TARGET = mupen64plus-input-sdl.$(SO_EXTENSION)
 
@@ -243,38 +255,41 @@ targets:
 	@echo "  Options:"
 	@echo "    BITS=32       == build 32-bit binaries on 64-bit machine"
 	@echo "    APIDIR=path   == path to find Mupen64Plus Core headers"
+	@echo "    OPTFLAGS=flag == compiler optimization (default: -O3)"
+	@echo "    PIC=(1|0)     == Force enable/disable of position independent code"
 	@echo "  Install Options:"
 	@echo "    PREFIX=path   == install/uninstall prefix (default: /usr/local)"
 	@echo "    SHAREDIR=path == path to install shared data files (default: PREFIX/share/mupen64plus)"
-	@echo "    LIBDIR=path   == path to install plugin libraries (default: PREFIX/lib/mupen64plus)"
+	@echo "    LIBDIR=path   == library prefix (default: PREFIX/lib)"
+	@echo "    PLUGINDIR=path == path to install plugin libraries (default: LIBDIR/mupen64plus)"
 	@echo "    DESTDIR=path  == path to prepend to all installation paths (only for packagers)"
 	@echo "  Debugging Options:"
 	@echo "    DEBUG=1       == add debugging symbols"
 	@echo "    PLUGINDBG=1   == print extra debugging information while running"
+	@echo "    V=1           == show verbose compiler output"
 
 all: $(TARGET)
 
 install: $(TARGET)
-	$(INSTALL) -d -v "$(DESTDIR)$(LIBDIR)"
-	$(INSTALL) -m 0644 $(TARGET) "$(DESTDIR)$(LIBDIR)"
-	$(INSTALL) -d -v "$(DESTDIR)$(SHAREDIR)"
+	$(INSTALL) -d "$(DESTDIR)$(PLUGINDIR)"
+	$(INSTALL) -m 0644 $(INSTALL_STRIP_FLAG) $(TARGET) "$(DESTDIR)$(PLUGINDIR)"
+	$(INSTALL) -d "$(DESTDIR)$(SHAREDIR)"
 	$(INSTALL) -m 0644 "../../data/InputAutoCfg.ini" "$(DESTDIR)$(SHAREDIR)"
 
 uninstall:
-	rm -f "$(DESTDIR)$(LIBDIR)/$(TARGET)"
+	$(RM) "$(DESTDIR)$(PLUGINDIR)/$(TARGET)"
+	$(RM) "$(DESTDIR)$(SHAREDIR)/InputAutoCfg.ini"
 
 clean:
-	rm -rf ./_obj/* $(TARGET)
-	rmdir ./_obj
+	$(RM) -r ./_obj $(TARGET)
 
 rebuild: clean all
 
-# build rules
-$(TARGET): $(OBJECTS)
-	$(Q_LD)$(CC) $(SHARED) $^ $(LDFLAGS) -o $@
-	$(STRIP) $@
-
+# standard build rules
 $(OBJDIR)/%.o: $(SRCDIR)/%.c
-	$(Q_CC)$(CC) -o $@ $(CFLAGS) -c $<
+	$(COMPILE.c) -o $@ $<
 
+$(TARGET): $(OBJECTS)
+	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@
 
+.PHONY: all clean install uninstall targets
diff --git a/src/config.c b/src/config.c
index 583124c..fc7e873 100644
--- a/src/config.c
+++ b/src/config.c
@@ -21,6 +21,7 @@
 
 #include <SDL.h>
 
+#define M64P_PLUGIN_PROTOTYPES 1
 #include "m64p_types.h"
 #include "m64p_plugin.h"
 #include "m64p_config.h"
@@ -29,6 +30,8 @@
 #include "autoconfig.h"
 #include "plugin.h"
 
+#include "config.h"
+
 #define HAT_POS_NAME( hat )         \
        ((hat == SDL_HAT_UP) ? "Up" :        \
        ((hat == SDL_HAT_DOWN) ? "Down" :    \
@@ -94,6 +97,7 @@ static void clear_controller(int iCtrlIdx)
     }
     for( b = 0; b < 2; b++ )
     {
+        controller[iCtrlIdx].mouse_sens[b] = 2.0;
         controller[iCtrlIdx].axis_deadzone[b] = 4096;
         controller[iCtrlIdx].axis_peak[b] = 32768;
         controller[iCtrlIdx].axis[b].button_a = controller[iCtrlIdx].axis[b].button_b = -1;
@@ -168,6 +172,11 @@ static int load_controller_config(const char *SectionName, int i)
             break;
         /* then do the optional parameters */
         ConfigGetParameter(pConfig, "mouse", M64TYPE_BOOL, &controller[i].mouse, sizeof(int));
+        if (ConfigGetParameter(pConfig, "MouseSensitivity", M64TYPE_STRING, input_str, 256) == M64ERR_SUCCESS)
+        {
+            if (sscanf(input_str, "%f,%f", &controller[i].mouse_sens[0], &controller[i].mouse_sens[1]) != 2)
+                DebugMessage(M64MSG_WARNING, "parsing error in MouseSensitivity parameter for controller %i", i + 1);
+        }
         if (ConfigGetParameter(pConfig, "AnalogDeadzone", M64TYPE_STRING, input_str, 256) == M64ERR_SUCCESS)
         {
             if (sscanf(input_str, "%i,%i", &controller[i].axis_deadzone[0], &controller[i].axis_deadzone[1]) != 2)
@@ -252,7 +261,7 @@ static int load_controller_config(const char *SectionName, int i)
 }
 
 /* global functions */
-void save_controller_config(int iCtrlIdx)
+static void save_controller_config(int iCtrlIdx)
 {
     m64p_handle pConfig;
     char SectionName[32], Param[32], ParamString[128];
@@ -274,6 +283,8 @@ void save_controller_config(int iCtrlIdx)
     ConfigSetDefaultBool(pConfig, "mouse", controller[iCtrlIdx].mouse, "If True, then mouse buttons may be used with this controller");
     ConfigSetDefaultInt(pConfig, "device", controller[iCtrlIdx].device, "Specifies which joystick is bound to this controller: -2=Keyboard/mouse, -1=Auto config, 0 or more= SDL Joystick number");
 
+    sprintf(Param, "%.2f,%.2f", controller[iCtrlIdx].mouse_sens[0], controller[iCtrlIdx].mouse_sens[1]);
+    ConfigSetDefaultString(pConfig, "MouseSensitivity", Param, "Scaling factor for mouse movements.  For X, Y axes.");
     sprintf(Param, "%i,%i", controller[iCtrlIdx].axis_deadzone[0], controller[iCtrlIdx].axis_deadzone[1]);
     ConfigSetDefaultString(pConfig, "AnalogDeadzone", Param, "The minimum absolute value of the SDL analog joystick axis to move the N64 controller axis value from 0.  For X, Y axes.");
     sprintf(Param, "%i,%i", controller[iCtrlIdx].axis_peak[0], controller[iCtrlIdx].axis_peak[1]);
@@ -399,10 +410,11 @@ void load_configuration(int bPrintSummary)
         sprintf(SectionName, "Input-SDL-Control%i", i + 1);
         readOK = load_controller_config(SectionName, i);
 
-        JoyName = get_sdl_joystick_name(i);
         if (!readOK || controller[i].device == DEVICE_AUTO)
         {
             int ControllersFound = 0;
+            /* if auto / bad config, get joystick name based on SDL order */
+            JoyName = get_sdl_joystick_name(i);
             /* reset the controller configuration again and try to auto-configure */
             ControllersFound = auto_set_defaults(i, JoyName);
             if (ControllersFound > 0)
@@ -433,6 +445,8 @@ void load_configuration(int bPrintSummary)
         }
         else if (controller[i].device >= 0)
         {
+            /* if joystick found in cfg, take its SDL number from there */
+            JoyName = get_sdl_joystick_name(controller[i].device);
             /* valid joystick configuration was read; check if the specified joystick is available in SDL */
             if (JoyName == NULL)
             {
diff --git a/src/config.h b/src/config.h
index 9ab22b7..48c23f2 100644
--- a/src/config.h
+++ b/src/config.h
@@ -23,7 +23,6 @@
 #define __CONFIG_H__
 
 extern void load_configuration(int bPrintSummary);
-extern void save_controller_config(int iCtrlIdx);
 
 #endif /* __CONFIG_H__ */
 
diff --git a/src/osal_preproc.h b/src/osal_preproc.h
index 79e96a0..37c7dc4 100644
--- a/src/osal_preproc.h
+++ b/src/osal_preproc.h
@@ -30,4 +30,4 @@
   #define strcasecmp _stricmp
 #endif // WIN32
 
-#endif // OSAL_PREPROC_H
\ No newline at end of file
+#endif // OSAL_PREPROC_H
diff --git a/src/plugin.c b/src/plugin.c
index 0bdfcc9..cbdf054 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -1,7 +1,7 @@
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  *   Mupen64plus-input-sdl - plugin.c                                      *
  *   Mupen64Plus homepage: http://code.google.com/p/mupen64plus/           *
- *   Copyright (C) 2008-2009 Richard Goedeken                              *
+ *   Copyright (C) 2008-2011 Richard Goedeken                              *
  *   Copyright (C) 2008 Tillin9                                            *
  *   Copyright (C) 2002 Blight                                             *
  *                                                                         *
@@ -27,8 +27,10 @@
 
 #include <SDL.h>
 
+#define M64P_PLUGIN_PROTOTYPES 1
 #include "m64p_types.h"
 #include "m64p_plugin.h"
+#include "m64p_common.h"
 #include "m64p_config.h"
 
 #include "plugin.h"
@@ -135,7 +137,9 @@ static CONTROL temp_core_controlinfo[4];
 EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Context,
                                    void (*DebugCallback)(void *, int, const char *))
 {
-    int i;
+    ptr_CoreGetAPIVersions CoreAPIVersionFunc;
+    
+    int i, ConfigAPIVersion, DebugAPIVersion, VidextAPIVersion;
 
     if (l_PluginInit)
         return M64ERR_ALREADY_INIT;
@@ -144,6 +148,22 @@ EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Con
     l_DebugCallback = DebugCallback;
     l_DebugCallContext = Context;
 
+    /* attach and call the CoreGetAPIVersions function, check Config API version for compatibility */
+    CoreAPIVersionFunc = (ptr_CoreGetAPIVersions) osal_dynlib_getproc(CoreLibHandle, "CoreGetAPIVersions");
+    if (CoreAPIVersionFunc == NULL)
+    {
+        DebugMessage(M64MSG_ERROR, "Core emulator broken; no CoreAPIVersionFunc() function found.");
+        return M64ERR_INCOMPATIBLE;
+    }
+    
+    (*CoreAPIVersionFunc)(&ConfigAPIVersion, &DebugAPIVersion, &VidextAPIVersion, NULL);
+    if ((ConfigAPIVersion & 0xffff0000) != (CONFIG_API_VERSION & 0xffff0000))
+    {
+        DebugMessage(M64MSG_ERROR, "Emulator core Config API (v%i.%i.%i) incompatible with plugin (v%i.%i.%i)",
+                VERSION_PRINTF_SPLIT(ConfigAPIVersion), VERSION_PRINTF_SPLIT(CONFIG_API_VERSION));
+        return M64ERR_INCOMPATIBLE;
+    }
+
     /* Get the core config function pointers from the library handle */
     ConfigOpenSection = (ptr_ConfigOpenSection) osal_dynlib_getproc(CoreLibHandle, "ConfigOpenSection");
     ConfigDeleteSection = (ptr_ConfigDeleteSection) osal_dynlib_getproc(CoreLibHandle, "ConfigDeleteSection");
@@ -214,7 +234,7 @@ EXPORT m64p_error CALL PluginGetVersion(m64p_plugin_type *PluginType, int *Plugi
         *PluginVersion = PLUGIN_VERSION;
 
     if (APIVersion != NULL)
-        *APIVersion = PLUGIN_API_VERSION;
+        *APIVersion = INPUT_PLUGIN_API_VERSION;
     
     if (PluginNamePtr != NULL)
         *PluginNamePtr = PLUGIN_NAME;
@@ -428,6 +448,8 @@ EXPORT void CALL ControllerCommand(int Control, unsigned char *Command)
 *******************************************************************/
 EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
 {
+    static int mousex_residual = 0;
+    static int mousey_residual = 0;
     int b, axis_val;
     SDL_Event event;
     unsigned char mstate;
@@ -532,30 +554,43 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
             controller[Control].buttons.Value |= button_bits[b];
     }
 
-    if (controller[Control].mouse && SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON)
+    if (controller[Control].mouse)
     {
-        SDL_PumpEvents();
-        while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_EVENTMASK(SDL_MOUSEMOTION)) == 1)
+        if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON)
         {
-            if (event.motion.xrel)
+            SDL_PumpEvents();
+            while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_EVENTMASK(SDL_MOUSEMOTION)) == 1)
             {
-                axis_val = (event.motion.xrel * 10);
-                if (axis_val < -80)
-                    axis_val = -80;
-                else if (axis_val > 80)
-                    axis_val = 80;
-                controller[Control].buttons.X_AXIS = axis_val;
-            }
-            if (event.motion.yrel)
-            {
-                axis_val = (event.motion.yrel * 10);
-                if (axis_val < -80)
-                    axis_val = -80;
-                else if (axis_val > 80)
-                    axis_val = 80;
-                controller[Control].buttons.Y_AXIS = -axis_val;
+                if (event.motion.xrel)
+                {
+                    mousex_residual += (int) (event.motion.xrel * controller[Control].mouse_sens[0]);
+                }
+                if (event.motion.yrel)
+                {
+                    mousey_residual += (int) (event.motion.yrel * controller[Control].mouse_sens[1]);
+                }
             }
         }
+        else
+        {
+            mousex_residual = 0;
+            mousey_residual = 0;
+        }
+        axis_val = mousex_residual;
+        if (axis_val < -80)
+            axis_val = -80;
+        else if (axis_val > 80)
+            axis_val = 80;
+        controller[Control].buttons.X_AXIS = axis_val;
+        axis_val = mousey_residual;
+        if (axis_val < -80)
+            axis_val = -80;
+        else if (axis_val > 80)
+            axis_val = 80;
+        controller[Control].buttons.Y_AXIS = -axis_val;
+        /* the mouse x/y values decay exponentially */
+        mousex_residual = (mousex_residual * 224) / 256;
+        mousey_residual = (mousey_residual * 224) / 256;
     }
 
 #ifdef _DEBUG
diff --git a/src/plugin.h b/src/plugin.h
index e64aa0d..7ddabc7 100644
--- a/src/plugin.h
+++ b/src/plugin.h
@@ -26,6 +26,7 @@
 
 #include <SDL.h>
 
+#define M64P_PLUGIN_PROTOTYPES 1
 #include "m64p_plugin.h"
 #include "m64p_config.h"
 
@@ -99,6 +100,7 @@ typedef struct
     int           event_joystick;   // the /dev/input/eventX device for force feeback
     int           axis_deadzone[2]; // minimum absolute value before analog movement is recognized
     int           axis_peak[2];     // highest analog value returned by SDL, used for scaling
+    float         mouse_sens[2];    // mouse sensitivity
 } SController;
 
 /* global data definitions */
diff --git a/src/version.h b/src/version.h
index c26deec..506e961 100644
--- a/src/version.h
+++ b/src/version.h
@@ -1,7 +1,7 @@
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  *   Mupen64plus-input-sdl - version.h                                     *
  *   Mupen64Plus homepage: http://code.google.com/p/mupen64plus/           *
- *   Copyright (C) 2009 Richard Goedeken                                   *
+ *   Copyright (C) 2009-2011 Richard Goedeken                              *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
  *   it under the terms of the GNU General Public License as published by  *
@@ -27,7 +27,9 @@
 #define VERSION_H
 
 #define PLUGIN_NAME    "Mupen64Plus SDL Input Plugin"
-#define PLUGIN_VERSION 0x016304
+#define PLUGIN_VERSION           0x016304
+#define INPUT_PLUGIN_API_VERSION 0x020000
+#define CONFIG_API_VERSION       0x020000
 
 #define VERSION_PRINTF_SPLIT(x) (((x) >> 16) & 0xffff), (((x) >> 8) & 0xff), ((x) & 0xff)
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/mupen64plus-input-sdl.git



More information about the Pkg-games-commits mailing list