From f8900583e5c604f0eef6a3df04d86817dd0d8964 Mon Sep 17 00:00:00 2001 From: Ozkan Sezer Date: Tue, 23 Nov 2021 17:04:40 +0300 Subject: [PATCH] removed windows winmm joystick driver --- CMakeLists.txt | 8 +- VisualC/SDL/SDL.vcxproj | 1 - VisualC/SDL/SDL.vcxproj.filters | 3 - configure | 4 - configure.ac | 2 - include/SDL_config.h.cmake | 1 - include/SDL_config.h.in | 3 +- src/joystick/windows/SDL_mmjoystick.c | 515 -------------------------- 8 files changed, 4 insertions(+), 533 deletions(-) delete mode 100644 src/joystick/windows/SDL_mmjoystick.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 00f16d124..725ed3362 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1715,11 +1715,12 @@ elseif(WINDOWS) endif() if(SDL_JOYSTICK) + file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/windows/*.c) + set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES}) + if(NOT WINDOWS_STORE) set(SDL_JOYSTICK_RAWINPUT 1) endif() - file(GLOB JOYSTICK_SOURCES ${SDL2_SOURCE_DIR}/src/joystick/windows/*.c) - set(SOURCE_FILES ${SOURCE_FILES} ${JOYSTICK_SOURCES}) if(HAVE_DINPUT_H) set(SDL_JOYSTICK_DINPUT 1) list(APPEND EXTRA_LIBS dinput8) @@ -1731,9 +1732,6 @@ elseif(WINDOWS) set(SDL_JOYSTICK_WGI 1) endif() endif() - if(NOT HAVE_DINPUT_H AND NOT HAVE_XINPUT_H) - set(SDL_JOYSTICK_WINMM 1) - endif() set(HAVE_SDL_JOYSTICK TRUE) if(SDL_HAPTIC) diff --git a/VisualC/SDL/SDL.vcxproj b/VisualC/SDL/SDL.vcxproj index becaead56..0e9062b56 100644 --- a/VisualC/SDL/SDL.vcxproj +++ b/VisualC/SDL/SDL.vcxproj @@ -490,7 +490,6 @@ - diff --git a/VisualC/SDL/SDL.vcxproj.filters b/VisualC/SDL/SDL.vcxproj.filters index d317135ac..da002cd3c 100644 --- a/VisualC/SDL/SDL.vcxproj.filters +++ b/VisualC/SDL/SDL.vcxproj.filters @@ -1063,9 +1063,6 @@ joystick\windows - - joystick\windows - joystick\windows diff --git a/configure b/configure index 5c688cc11..21f1568e6 100755 --- a/configure +++ b/configure @@ -25398,10 +25398,6 @@ $as_echo "#define SDL_JOYSTICK_DINPUT 1" >>confdefs.h EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8" fi - else - -$as_echo "#define SDL_JOYSTICK_WINMM 1" >>confdefs.h - fi SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c" have_joystick=yes diff --git a/configure.ac b/configure.ac index 7e4b92c72..f5a6ead99 100644 --- a/configure.ac +++ b/configure.ac @@ -3915,8 +3915,6 @@ case "$host" in AC_DEFINE(SDL_JOYSTICK_DINPUT, 1, [ ]) EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ldinput8 -ldxguid -ldxerr8" fi - else - AC_DEFINE(SDL_JOYSTICK_WINMM, 1, [ ]) fi SOURCES="$SOURCES $srcdir/src/joystick/windows/*.c" have_joystick=yes diff --git a/include/SDL_config.h.cmake b/include/SDL_config.h.cmake index d5daa3fc0..46b404ee1 100644 --- a/include/SDL_config.h.cmake +++ b/include/SDL_config.h.cmake @@ -328,7 +328,6 @@ #cmakedefine SDL_JOYSTICK_IOKIT @SDL_JOYSTICK_IOKIT@ #cmakedefine SDL_JOYSTICK_MFI @SDL_JOYSTICK_MFI@ #cmakedefine SDL_JOYSTICK_LINUX @SDL_JOYSTICK_LINUX@ -#cmakedefine SDL_JOYSTICK_WINMM @SDL_JOYSTICK_WINMM@ #cmakedefine SDL_JOYSTICK_OS2 @SDL_JOYSTICK_OS2@ #cmakedefine SDL_JOYSTICK_USBHID @SDL_JOYSTICK_USBHID@ #cmakedefine SDL_HAVE_MACHINE_JOYSTICK_H @SDL_HAVE_MACHINE_JOYSTICK_H@ diff --git a/include/SDL_config.h.in b/include/SDL_config.h.in index 1005d5da6..ddab098d1 100644 --- a/include/SDL_config.h.in +++ b/include/SDL_config.h.in @@ -33,7 +33,7 @@ /* Make sure that this isn't included by Visual C++ */ #ifdef _MSC_VER -#error You should run hg revert SDL_config.h +#error You should run git checkout -f include/SDL_config.h #endif /* C language features */ @@ -316,7 +316,6 @@ #undef SDL_JOYSTICK_MFI #undef SDL_JOYSTICK_LINUX #undef SDL_JOYSTICK_ANDROID -#undef SDL_JOYSTICK_WINMM #undef SDL_JOYSTICK_OS2 #undef SDL_JOYSTICK_USBHID #undef SDL_HAVE_MACHINE_JOYSTICK_H diff --git a/src/joystick/windows/SDL_mmjoystick.c b/src/joystick/windows/SDL_mmjoystick.c deleted file mode 100644 index d288af02f..000000000 --- a/src/joystick/windows/SDL_mmjoystick.c +++ /dev/null @@ -1,515 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2021 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "../../SDL_internal.h" - -#ifdef SDL_JOYSTICK_WINMM - -/* Win32 MultiMedia Joystick driver, contributed by Andrei de A. Formiga */ - -#include "../../core/windows/SDL_windows.h" -#include -#include - -#include "SDL_events.h" -#include "SDL_joystick.h" -#include "../SDL_sysjoystick.h" -#include "../SDL_joystick_c.h" - -#ifdef REGSTR_VAL_JOYOEMNAME -#undef REGSTR_VAL_JOYOEMNAME -#endif -#define REGSTR_VAL_JOYOEMNAME "OEMName" - -#define MAX_JOYSTICKS 16 -#define MAX_AXES 6 /* each joystick can have up to 6 axes */ -#define MAX_BUTTONS 32 /* and 32 buttons */ -#define JOY_BUTTON_FLAG(n) (1<instance_id = device_index; - joystick->hwdata = - (struct joystick_hwdata *) SDL_malloc(sizeof(*joystick->hwdata)); - if (joystick->hwdata == NULL) { - return SDL_OutOfMemory(); - } - SDL_memset(joystick->hwdata, 0, sizeof(*joystick->hwdata)); - - /* set hardware data */ - joystick->hwdata->id = SYS_JoystickID[index]; - for (i = 0; i < MAX_AXES; ++i) { - if ((i < 2) || (SYS_Joystick[index].wCaps & caps_flags[i - 2])) { - joystick->hwdata->transaxis[i].offset = SDL_JOYSTICK_AXIS_MIN - axis_min[i]; - joystick->hwdata->transaxis[i].scale = - (float) (SDL_JOYSTICK_AXIS_MAX - SDL_JOYSTICK_AXIS_MIN) / (axis_max[i] - axis_min[i]); - } else { - joystick->hwdata->transaxis[i].offset = 0; - joystick->hwdata->transaxis[i].scale = 1.0; /* Just in case */ - } - } - - /* fill nbuttons, naxes, and nhats fields */ - joystick->nbuttons = SYS_Joystick[index].wNumButtons; - joystick->naxes = SYS_Joystick[index].wNumAxes; - if (SYS_Joystick[index].wCaps & JOYCAPS_HASPOV) { - joystick->nhats = 1; - } else { - joystick->nhats = 0; - } - return (0); -} - -static Uint8 -TranslatePOV(DWORD value) -{ - Uint8 pos; - - pos = SDL_HAT_CENTERED; - if (value != JOY_POVCENTERED) { - if ((value > JOY_POVLEFT) || (value < JOY_POVRIGHT)) { - pos |= SDL_HAT_UP; - } - if ((value > JOY_POVFORWARD) && (value < JOY_POVBACKWARD)) { - pos |= SDL_HAT_RIGHT; - } - if ((value > JOY_POVRIGHT) && (value < JOY_POVLEFT)) { - pos |= SDL_HAT_DOWN; - } - if (value > JOY_POVBACKWARD) { - pos |= SDL_HAT_LEFT; - } - } - return (pos); -} - -static int -WINMM_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) -{ - return SDL_Unsupported(); -} - -static int -WINMM_JoystickRumbleTriggers(SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble) -{ - return SDL_Unsupported(); -} - -static Uint32 WINMM_JoystickGetCapabilities(SDL_Joystick *joystick) -{ - return 0; -} - -static int -WINMM_JoystickSetLED(SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue) -{ - return SDL_Unsupported(); -} - -static int -WINMM_JoystickSendEffect(SDL_Joystick *joystick, const void *data, int size) -{ - return SDL_Unsupported(); -} - -static int WINMM_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enabled) -{ - return SDL_Unsupported(); -} - -/* Function to update the state of a joystick - called as a device poll. - * This function shouldn't update the joystick structure directly, - * but instead should call SDL_PrivateJoystick*() to deliver events - * and update joystick device state. - */ -static void -WINMM_JoystickUpdate(SDL_Joystick *joystick) -{ - MMRESULT result; - int i; - DWORD flags[MAX_AXES] = { JOY_RETURNX, JOY_RETURNY, JOY_RETURNZ, - JOY_RETURNR, JOY_RETURNU, JOY_RETURNV - }; - DWORD pos[MAX_AXES]; - struct _transaxis *transaxis; - int value; - JOYINFOEX joyinfo; - - joyinfo.dwSize = sizeof(joyinfo); - joyinfo.dwFlags = JOY_RETURNALL | JOY_RETURNPOVCTS; - if (!joystick->hats) { - joyinfo.dwFlags &= ~(JOY_RETURNPOV | JOY_RETURNPOVCTS); - } - result = joyGetPosEx(joystick->hwdata->id, &joyinfo); - if (result != JOYERR_NOERROR) { - SetMMerror("joyGetPosEx", result); - return; - } - - /* joystick motion events */ - pos[0] = joyinfo.dwXpos; - pos[1] = joyinfo.dwYpos; - pos[2] = joyinfo.dwZpos; - pos[3] = joyinfo.dwRpos; - pos[4] = joyinfo.dwUpos; - pos[5] = joyinfo.dwVpos; - - transaxis = joystick->hwdata->transaxis; - for (i = 0; i < joystick->naxes; i++) { - if (joyinfo.dwFlags & flags[i]) { - value = (int) (((float) pos[i] + transaxis[i].offset) * transaxis[i].scale); - SDL_PrivateJoystickAxis(joystick, (Uint8) i, (Sint16) value); - } - } - - /* joystick button events */ - if (joyinfo.dwFlags & JOY_RETURNBUTTONS) { - for (i = 0; i < joystick->nbuttons; ++i) { - if (joyinfo.dwButtons & JOY_BUTTON_FLAG(i)) { - SDL_PrivateJoystickButton(joystick, (Uint8) i, SDL_PRESSED); - } else { - SDL_PrivateJoystickButton(joystick, (Uint8) i, SDL_RELEASED); - } - } - } - - /* joystick hat events */ - if (joyinfo.dwFlags & JOY_RETURNPOV) { - SDL_PrivateJoystickHat(joystick, 0, TranslatePOV(joyinfo.dwPOV)); - } -} - -/* Function to close a joystick after use */ -static void -WINMM_JoystickClose(SDL_Joystick *joystick) -{ - SDL_free(joystick->hwdata); -} - -/* Function to perform any system-specific joystick related cleanup */ -static void -WINMM_JoystickQuit(void) -{ - int i; - for (i = 0; i < MAX_JOYSTICKS; i++) { - SDL_free(SYS_JoystickName[i]); - SYS_JoystickName[i] = NULL; - } -} - -static SDL_bool -WINMM_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out) -{ - return SDL_FALSE; -} - - -/* implementation functions */ -void -SetMMerror(char *function, int code) -{ - static char *error; - static char errbuf[1024]; - - errbuf[0] = 0; - switch (code) { - case MMSYSERR_NODRIVER: - error = "Joystick driver not present"; - break; - - case MMSYSERR_INVALPARAM: - case JOYERR_PARMS: - error = "Invalid parameter(s)"; - break; - - case MMSYSERR_BADDEVICEID: - error = "Bad device ID"; - break; - - case JOYERR_UNPLUGGED: - error = "Joystick not attached"; - break; - - case JOYERR_NOCANDO: - error = "Can't capture joystick input"; - break; - - default: - SDL_snprintf(errbuf, SDL_arraysize(errbuf), - "%s: Unknown Multimedia system error: 0x%x", - function, code); - break; - } - - if (!errbuf[0]) { - SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: %s", function, - error); - } - SDL_SetError("%s", errbuf); -} - -SDL_JoystickDriver SDL_WINMM_JoystickDriver = -{ - WINMM_JoystickInit, - WINMM_NumJoysticks, - WINMM_JoystickDetect, - WINMM_JoystickGetDeviceName, - WINMM_JoystickGetDevicePlayerIndex, - WINMM_JoystickSetDevicePlayerIndex, - WINMM_JoystickGetDeviceGUID, - WINMM_JoystickGetDeviceInstanceID, - WINMM_JoystickOpen, - WINMM_JoystickRumble, - WINMM_JoystickRumbleTriggers, - WINMM_JoystickGetCapabilities, - WINMM_JoystickSetLED, - WINMM_JoystickSendEffect, - WINMM_JoystickSetSensorsEnabled, - WINMM_JoystickUpdate, - WINMM_JoystickClose, - WINMM_JoystickQuit, - WINMM_JoystickGetGamepadMapping -}; - -#endif /* SDL_JOYSTICK_WINMM */ - -/* vi: set ts=4 sw=4 expandtab: */