[mupen64plus-input-sdl] 123/196: Imported Upstream version 1.99.5+31+a5814ef06e8f

Sven Eckelmann ecsv-guest at moszumanska.debian.org
Thu Nov 26 06:00:29 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 67f327a9c10583cc6fe54d57188f8692174f913a
Author: Sven Eckelmann <sven at narfation.org>
Date:   Fri Feb 8 09:26:59 2013 +0100

    Imported Upstream version 1.99.5+31+a5814ef06e8f
---
 data/InputAutoCfg.ini  | 31 ++++++++++++++++++--
 projects/unix/Makefile | 76 +++++++++++++++++++++++++++++++++-----------------
 src/config.c           |  4 +--
 src/plugin.c           | 40 +++++++++++++++++++-------
 src/plugin.h           | 43 ++++++++++++++++++++++++++--
 5 files changed, 152 insertions(+), 42 deletions(-)

diff --git a/data/InputAutoCfg.ini b/data/InputAutoCfg.ini
index c8ea417..90fff89 100644
--- a/data/InputAutoCfg.ini
+++ b/data/InputAutoCfg.ini
@@ -276,7 +276,34 @@ Rumblepak switch =
 X Axis = axis(0-,0+)
 Y Axis = axis(1-,1+)
 
+; X-box controllers and compatible clones
+[Logitech Chillstream Controller]
+plugged = True
+plugin = 2
+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(7)
+Z Trig = axis(2+)
+B Button = button(2)
+A Button = button(0)
+C Button R = axis(3+)
+C Button L = axis(3-)
+C Button D = axis(4+)
+C Button U = axis(4-)
+R Trig = button(5)
+L Trig = button(4)
+Mempak switch = button(6)
+Rumblepak switch = button(8)
+X Axis = axis(0-,0+)
+Y Axis = axis(1-,1+)
+
 [Logitech Cordless Rumblepad 2]
+[Logitech Cordless RumblePad 2]
 [Logitech RumblePad 2 USB]
 [Logitech Dual Action]
 plugged = True
@@ -410,6 +437,7 @@ X Axis = axis(0-,0+)
 [Win32: XBOX 360 For Windows]
 [Xbox 360 Wireless Receiver]
 [OSX: Wireless 360 Controller]
+[OSX: Controller]
 [Linux: Xbox Gamepad (userspace driver)]
 plugged = True
 plugin = 2
@@ -679,7 +707,7 @@ C Button L = axis(2-)
 C Button D = axis(3+)
 C Button U = axis(3-)
 R Trig = axis(4+)
-L Trig = axis(5-)
+L Trig = axis(5+)
 Mempak switch =
 Rumblepak switch =
 X Axis = axis(0-,0+)
@@ -738,7 +766,6 @@ 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
diff --git a/projects/unix/Makefile b/projects/unix/Makefile
index daa3bc8..e10e58f 100644
--- a/projects/unix/Makefile
+++ b/projects/unix/Makefile
@@ -21,7 +21,7 @@
 # Makefile for SDL Input plugin in Mupen64plus
 
 # detect operating system
-UNAME = $(shell uname -s)
+UNAME ?= $(shell uname -s)
 OS := NONE
 ifeq ("$(UNAME)","Linux")
   OS = LINUX
@@ -59,6 +59,12 @@ ifneq ("$(filter GNU/kFreeBSD kfreebsd,$(UNAME))","")
   SO_EXTENSION = so
   SHARED = -shared
 endif
+ifeq ("$(patsubst MINGW%,MINGW,$(UNAME))","MINGW")
+  OS = MINGW
+  SO_EXTENSION = dll
+  SHARED = -shared
+  PIC = 0
+endif
 ifeq ("$(OS)","NONE")
   $(error OS type "$(UNAME)" not supported.  Please file bug report at 'http://code.google.com/p/mupen64plus/issues')
 endif
@@ -110,9 +116,13 @@ endif
 
 # base CFLAGS, LDLIBS, and LDFLAGS
 OPTFLAGS ?= -O3
-CFLAGS += $(OPTFLAGS) -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src
+WARNFLAGS ?= -Wall
+CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -ffast-math -fno-strict-aliasing -fvisibility=hidden -I../../src
 LDFLAGS += $(SHARED)
 
+# default configuration programs
+SDL_CONFIG = $(CROSS_COMPILE)sdl-config
+
 # 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)
@@ -143,12 +153,24 @@ ifeq ($(OS), LINUX)
   LDLIBS += -ldl
 endif
 ifeq ($(OS), OSX)
+  # Select the proper SDK
+  # Also, SDKs are stored in a different location since XCode 4.3
+  OSX_SDK ?= $(shell sw_vers -productVersion | cut -f1 -f2 -d .)
+  OSX_XCODEMAJ = $(shell xcodebuild -version | grep '[0-9]*\.[0-9]*' | cut -f2 -d ' ' | cut -f1 -d .)
+  OSX_XCODEMIN = $(shell xcodebuild -version | grep '[0-9]*\.[0-9]*' | cut -f2 -d ' ' | cut -f2 -d .)
+  OSX_XCODEGE43 = $(shell echo "`expr $(OSX_XCODEMAJ) \>= 4``expr $(OSX_XCODEMIN) \>= 3`")
+  ifeq ($(OSX_XCODEGE43), 11)
+    OSX_SYSROOT := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
+  else
+    OSX_SYSROOT := /Developer/SDKs
+  endif
+
   ifeq ($(CPU), X86)
     ifeq ($(ARCH_DETECTED), 64BITS)
-      CFLAGS += -arch x86_64 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
+      CFLAGS += -arch x86_64 -mmacosx-version-min=$(OSX_SDK) -isysroot $(OSX_SYSROOT)/MacOSX$(OSX_SDK).sdk
       LDLIBS += -ldl
     else
-      CFLAGS += -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=10.5 -isysroot /Developer/SDKs/MacOSX10.5.sdk
+      CFLAGS += -mmmx -msse -fomit-frame-pointer -arch i686 -mmacosx-version-min=$(OSX_SDK) -isysroot $(OSX_SYSROOT)/MacOSX$(OSX_SDK).sdk
       LDFLAGS += -arch i686
       LDLIBS += -ldl -read_only_relocs suppress
     endif
@@ -156,18 +178,11 @@ ifeq ($(OS), OSX)
 endif
 
 # test for presence of SDL
-ifeq ($(shell which sdl-config 2>/dev/null),)
+ifeq ($(shell which $(SDL_CONFIG) 2>/dev/null),)
   $(error No SDL development libraries found!)
 endif
-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
-    LDLIBS += -L/usr/local/lib -lSDL -Wl,-framework,Cocoa
-else
-    CFLAGS  += $(shell sdl-config --cflags)
-    LDLIBS += $(shell sdl-config --libs)
-endif
+CFLAGS  += $(shell $(SDL_CONFIG) --cflags)
+LDLIBS += $(shell $(SDL_CONFIG) --libs)
 
 # set mupen64plus core API header path
 ifneq ("$(APIDIR)","")
@@ -200,8 +215,8 @@ endif
 endif
 
 # set base program pointers and flags
-CC       ?= gcc
-CXX      ?= g++
+CC        = $(CROSS_COMPILE)gcc
+CXX       = $(CROSS_COMPILE)g++
 RM       ?= rm -f
 INSTALL  ?= install
 MKDIR ?= mkdir -p
@@ -213,7 +228,9 @@ ifeq ($(DEBUG),1)
   CFLAGS += -g
   INSTALL_STRIP_FLAG ?= 
 else
-  INSTALL_STRIP_FLAG ?= -s
+  ifneq ($(OS),OSX)
+    INSTALL_STRIP_FLAG ?= -s
+  endif
 endif
 ifeq ($(PLUGINDBG), 1)
   CFLAGS += -D_DEBUG
@@ -234,26 +251,27 @@ ifeq ($(PLUGINDIR),)
 endif
 
 SRCDIR = ../../src
-OBJDIR = _obj
+OBJDIR = _obj$(POSTFIX)
 
 # list of source files to compile
 SOURCE = \
 	$(SRCDIR)/plugin.c \
 	$(SRCDIR)/autoconfig.c \
-	$(SRCDIR)/config.c \
-	$(SRCDIR)/osal_dynamiclib_unix.c
+	$(SRCDIR)/config.c
+
+ifeq ($(OS),MINGW)
+SOURCE += $(SRCDIR)/osal_dynamiclib_win32.c
+else
+SOURCE += $(SRCDIR)/osal_dynamiclib_unix.c
+endif
 
 # 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) $(OBJDIRS))
 
-# build dependency files
-CFLAGS += -MD
--include $(OBJECTS:.o=.d)
-
 # build targets
-TARGET = mupen64plus-input-sdl.$(SO_EXTENSION)
+TARGET = mupen64plus-input-sdl$(POSTFIX).$(SO_EXTENSION)
 
 targets:
 	@echo "Mupen64Plus-input-sdl makefile. "
@@ -267,7 +285,9 @@ targets:
 	@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 "    WARNFLAGS=flag == compiler warning levels (default: -Wall)"
 	@echo "    PIC=(1|0)     == Force enable/disable of position independent code"
+	@echo "    POSTFIX=name  == String added to the name of the the build (default: '')"
 	@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)"
@@ -293,10 +313,14 @@ uninstall:
 	$(RM) "$(DESTDIR)$(SHAREDIR)/InputAutoCfg.ini"
 
 clean:
-	$(RM) -r ./_obj $(TARGET)
+	$(RM) -r $(OBJDIR) $(TARGET)
 
 rebuild: clean all
 
+# build dependency files
+CFLAGS += -MD
+-include $(OBJECTS:.o=.d)
+
 ifeq ($(LTO), 1)
   CFLAGS += -flto
   LDFLAGS += -fuse-linker-plugin $(CFLAGS)
diff --git a/src/config.c b/src/config.c
index 5545872..e777478 100644
--- a/src/config.c
+++ b/src/config.c
@@ -88,7 +88,7 @@ static void clear_controller(int iCtrlIdx)
     for( b = 0; b < 16; b++ )
     {
         controller[iCtrlIdx].button[b].button = -1;
-        controller[iCtrlIdx].button[b].key = SDLK_UNKNOWN;
+        controller[iCtrlIdx].button[b].key = SDL_SCANCODE_UNKNOWN;
         controller[iCtrlIdx].button[b].axis = -1;
         controller[iCtrlIdx].button[b].axis_deadzone = -1;
         controller[iCtrlIdx].button[b].hat = -1;
@@ -101,7 +101,7 @@ static void clear_controller(int iCtrlIdx)
         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;
-        controller[iCtrlIdx].axis[b].key_a = controller[iCtrlIdx].axis[b].key_b = SDLK_UNKNOWN;
+        controller[iCtrlIdx].axis[b].key_a = controller[iCtrlIdx].axis[b].key_b = SDL_SCANCODE_UNKNOWN;
         controller[iCtrlIdx].axis[b].axis_a = -1;
         controller[iCtrlIdx].axis[b].axis_dir_a = 1;
         controller[iCtrlIdx].axis[b].axis_b = -1;
diff --git a/src/plugin.c b/src/plugin.c
index e0bb9f1..2992290 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -106,7 +106,7 @@ static unsigned short button_bits[] = {
 
 static int romopen = 0;         // is a rom opened
 
-static unsigned char myKeyState[SDLK_LAST];
+static unsigned char myKeyState[SDL_NUM_SCANCODES];
 
 #ifdef __linux__
 static struct ff_effect ffeffect[3];
@@ -194,7 +194,7 @@ EXPORT m64p_error CALL PluginStartup(m64p_dynlib_handle CoreLibHandle, void *Con
 
     /* reset controllers */
     memset(controller, 0, sizeof(SController) * 4);
-    for (i = 0; i < SDLK_LAST; i++)
+    for (i = 0; i < SDL_NUM_SCANCODES; i++)
     {
         myKeyState[i] = 0;
     }
@@ -255,16 +255,16 @@ doSdlKeys(unsigned char* keystate)
     static int grabmouse = 1, grabtoggled = 0;
 
     axis_max_val = 80;
-    if (keystate[SDLK_RCTRL])
+    if (keystate[SDL_SCANCODE_RCTRL])
         axis_max_val -= 40;
-    if (keystate[SDLK_RSHIFT])
+    if (keystate[SDL_SCANCODE_RSHIFT])
         axis_max_val -= 20;
 
     for( c = 0; c < 4; c++ )
     {
         for( b = 0; b < 16; b++ )
         {
-            if( controller[c].button[b].key == SDLK_UNKNOWN || ((int) controller[c].button[b].key) < 0)
+            if( controller[c].button[b].key == SDL_SCANCODE_UNKNOWN || ((int) controller[c].button[b].key) < 0)
                 continue;
             if( keystate[controller[c].button[b].key] )
                 controller[c].buttons.Value |= button_bits[b];
@@ -278,10 +278,10 @@ doSdlKeys(unsigned char* keystate)
             else
                 axis_val = -controller[c].buttons.Y_AXIS;
 
-            if( controller[c].axis[b].key_a != SDLK_UNKNOWN && ((int) controller[c].axis[b].key_a) > 0)
+            if( controller[c].axis[b].key_a != SDL_SCANCODE_UNKNOWN && ((int) controller[c].axis[b].key_a) > 0)
                 if( keystate[controller[c].axis[b].key_a] )
                     axis_val = -axis_max_val;
-            if( controller[c].axis[b].key_b != SDLK_UNKNOWN && ((int) controller[c].axis[b].key_b) > 0)
+            if( controller[c].axis[b].key_b != SDL_SCANCODE_UNKNOWN && ((int) controller[c].axis[b].key_b) > 0)
                 if( keystate[controller[c].axis[b].key_b] )
                     axis_val = axis_max_val;
 
@@ -292,14 +292,18 @@ doSdlKeys(unsigned char* keystate)
         }
         if (controller[c].mouse)
         {
-            if (keystate[SDLK_LCTRL] && keystate[SDLK_LALT])
+            if (keystate[SDL_SCANCODE_LCTRL] && keystate[SDL_SCANCODE_LALT])
             {
                 if (!grabtoggled)
                 {
                     grabtoggled = 1;
                     grabmouse = !grabmouse;
                     // grab/ungrab mouse
+#if SDL_VERSION_ATLEAST(2,0,0)
+#warning SDL mouse grabbing not yet supported with SDL 2.0
+#else
                     SDL_WM_GrabInput( grabmouse ? SDL_GRAB_ON : SDL_GRAB_OFF );
+#endif
                     SDL_ShowCursor( grabmouse ? 0 : 1 );
                 }
             }
@@ -455,7 +459,7 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
     unsigned char mstate;
 
     // Handle keyboard input first
-    doSdlKeys(SDL_GetKeyState(NULL));
+    doSdlKeys(SDL_GetKeyboardState(NULL));
     doSdlKeys(myKeyState);
 
     // read joystick state
@@ -556,10 +560,17 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
 
     if (controller[Control].mouse)
     {
+#if SDL_VERSION_ATLEAST(2,0,0)
+#warning SDL mouse grabbing not yet supported with SDL 2.0
+#else
         if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON)
         {
             SDL_PumpEvents();
+#if SDL_VERSION_ATLEAST(1,3,0)
+            while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_MOUSEMOTION, SDL_MOUSEMOTION) == 1)
+#else
             while (SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_EVENTMASK(SDL_MOUSEMOTION)) == 1)
+#endif
             {
                 if (event.motion.xrel)
                 {
@@ -572,6 +583,7 @@ EXPORT void CALL GetKeys( int Control, BUTTONS *Keys )
             }
         }
         else
+#endif
         {
             mousex_residual = 0;
             mousey_residual = 0;
@@ -757,7 +769,7 @@ EXPORT void CALL InitiateControllers(CONTROL_INFO ControlInfo)
 
     // reset controllers
     memset( controller, 0, sizeof( SController ) * 4 );
-    for ( i = 0; i < SDLK_LAST; i++)
+    for ( i = 0; i < SDL_NUM_SCANCODES; i++)
     {
         myKeyState[i] = 0;
     }
@@ -823,7 +835,11 @@ EXPORT void CALL RomClosed(void)
     SDL_QuitSubSystem( SDL_INIT_JOYSTICK );
 
     // release/ungrab mouse
+#if SDL_VERSION_ATLEAST(2,0,0)
+#warning SDL mouse grabbing not yet supported with SDL 2.0
+#else
     SDL_WM_GrabInput( SDL_GRAB_OFF );
+#endif
     SDL_ShowCursor( 1 );
 
     romopen = 0;
@@ -862,11 +878,15 @@ EXPORT int CALL RomOpen(void)
     // grab mouse
     if (controller[0].mouse || controller[1].mouse || controller[2].mouse || controller[3].mouse)
     {
+#if SDL_VERSION_ATLEAST(2,0,0)
+#warning SDL mouse grabbing not yet supported with SDL 2.0
+#else
         SDL_ShowCursor( 0 );
         if (SDL_WM_GrabInput( SDL_GRAB_ON ) != SDL_GRAB_ON)
         {
             DebugMessage(M64MSG_WARNING, "Couldn't grab input! Mouse support won't work!");
         }
+#endif
     }
 
     romopen = 1;
diff --git a/src/plugin.h b/src/plugin.h
index 7ddabc7..882d422 100644
--- a/src/plugin.h
+++ b/src/plugin.h
@@ -25,6 +25,45 @@
 #define __PLUGIN_H__
 
 #include <SDL.h>
+#if ! SDL_VERSION_ATLEAST(1,3,0)
+
+#define SDL_GetKeyboardState SDL_GetKeyState
+#define SDL_SCANCODE_UNKNOWN SDLK_UNKNOWN
+#define SDL_NUM_SCANCODES SDLK_LAST
+#define SDL_SCANCODE_RCTRL SDLK_RCTRL
+#define SDL_SCANCODE_RSHIFT SDLK_RSHIFT
+#define SDL_SCANCODE_LCTRL SDLK_LCTRL
+#define SDL_SCANCODE_LALT SDLK_LALT
+#define SDL_Scancode SDLKey
+
+#endif
+
+#if SDL_VERSION_ATLEAST(2,0,0)
+
+static inline const char* _SDL_JoystickName(int device_index)
+{
+    SDL_Joystick *joystick;
+    const char *name;
+    static char JoyName[256];
+
+    joystick = SDL_JoystickOpen(device_index);
+    if (!joystick)
+        return NULL;
+
+    name = SDL_JoystickName(joystick);
+    if (name)
+    {
+        strncpy(JoyName, name, 255);
+        JoyName[255] = 0;
+    }
+    SDL_JoystickClose(joystick);
+
+    return JoyName;
+}
+
+#define SDL_JoystickName(device_index) _SDL_JoystickName(device_index)
+
+#endif
 
 #define M64P_PLUGIN_PROTOTYPES 1
 #include "m64p_plugin.h"
@@ -70,7 +109,7 @@ enum EButton
 typedef struct
 {
     int button;         // button index; -1 if notassigned
-    SDLKey key;         // sdl keysym; SDLK_UNKNOWN if not assigned
+    SDL_Scancode key;   // sdl keysym; SDL_SCANCODE_UNKNOWN if not assigned
     int axis, axis_dir; // aixs + direction (i.e. 0, 1 = X Axis +; 0, -1 = X Axis -); -1 if notassigned
     int axis_deadzone;  // -1 for default, or >= 0 for custom value
     int hat, hat_pos;   // hat + hat position; -1 if not assigned
@@ -80,7 +119,7 @@ typedef struct
 typedef struct
 {
     int button_a, button_b;         // up/down or left/right; -1 if not assigned
-    SDLKey key_a, key_b;            // up/down or left/right; SDLK_UNKNOWN if not assigned
+    SDL_Scancode key_a, key_b;      // up/down or left/right; SDL_SCANCODE_UNKNOWN if not assigned
     int axis_a, axis_b;             // axis index; -1 if not assigned
     int axis_dir_a, axis_dir_b;     // direction (1 = X+, 0, -1 = X-)
     int hat, hat_pos_a, hat_pos_b;  // hat + hat position up/down and left/right; -1 if not assigned

-- 
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