From 12723053b5ac10e2dc68f3d8abf507c07f0aa742 Mon Sep 17 00:00:00 2001 From: Garrett Brown Date: Tue, 11 Oct 2016 00:15:59 -0700 Subject: [PATCH] Remove SDL driver --- CMakeLists.txt | 17 ----- src/api/JoystickManager.cpp | 5 -- src/api/sdl/JoystickInterfaceSDL.cpp | 106 --------------------------- src/api/sdl/JoystickInterfaceSDL.h | 42 ----------- src/api/sdl/JoystickSDL.cpp | 99 ------------------------- src/api/sdl/JoystickSDL.h | 40 ---------- 6 files changed, 309 deletions(-) delete mode 100644 src/api/sdl/JoystickInterfaceSDL.cpp delete mode 100644 src/api/sdl/JoystickInterfaceSDL.h delete mode 100644 src/api/sdl/JoystickSDL.cpp delete mode 100644 src/api/sdl/JoystickSDL.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 863f50bc..87b32a8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,23 +83,6 @@ if("${CORE_SYSTEM_NAME}" STREQUAL "darwin" OR "${CORE_SYSTEM_NAME}" STREQUAL "os list(APPEND DEPLIBS ${COCOA_LIBRARY}) endif() -# --- SDL ---------------------------------------------------------------------- - -if(NOT "${CORE_SYSTEM_NAME}" STREQUAL "windows") - find_package(Sdl) - - if(SDL_FOUND) - include_directories(${SDL_INCLUDE_DIRS}) - - add_definitions(-DHAVE_SDL) - - list(APPEND JOYSTICK_SOURCES src/api/sdl/JoystickInterfaceSDL.cpp - src/api/sdl/JoystickSDL.cpp) - - list(APPEND DEPLIBS ${SDL_LIBRARIES}) - endif() -endif() - # --- Linux Joystick API ------------------------------------------------------- check_include_files(linux/joystick.h HAVE_LINUX_JOYSTICK_H) diff --git a/src/api/JoystickManager.cpp b/src/api/JoystickManager.cpp index 81bf014d..37c2033f 100644 --- a/src/api/JoystickManager.cpp +++ b/src/api/JoystickManager.cpp @@ -31,9 +31,6 @@ #if defined(HAVE_LINUX_JOYSTICK) #include "linux/JoystickInterfaceLinux.h" #endif -#if defined(HAVE_SDL) - #include "sdl/JoystickInterfaceSDL.h" -#endif #if defined(HAVE_COCOA) #include "cocoa/JoystickInterfaceCocoa.h" #endif @@ -118,8 +115,6 @@ bool CJoystickManager::Initialize(IScannerCallback* scanner) m_interfaces.push_back(new CJoystickInterfaceLinux); #elif defined(HAVE_UDEV) m_interfaces.push_back(new CJoystickInterfaceUdev); -#elif defined(HAVE_SDL) - m_interfaces.push_back(new CJoystickInterfaceSDL); #endif // OSX diff --git a/src/api/sdl/JoystickInterfaceSDL.cpp b/src/api/sdl/JoystickInterfaceSDL.cpp deleted file mode 100644 index d8b6961d..00000000 --- a/src/api/sdl/JoystickInterfaceSDL.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2014-2015 Garrett Brown - * Copyright (C) 2014-2015 Team XBMC - * - * 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 - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * . - * - */ - -#include "JoystickInterfaceSDL.h" -#include "JoystickSDL.h" -#include "api/JoystickTypes.h" -#include "log/Log.h" - -#include -#include - -using namespace JOYSTICK; - -const char* CJoystickInterfaceSDL::Name(void) const -{ - return INTERFACE_SDL; -} - -void CJoystickInterfaceSDL::Deinitialize(void) -{ - // Restart SDL joystick subsystem - SDL_QuitSubSystem(SDL_INIT_JOYSTICK); - if (SDL_WasInit(SDL_INIT_JOYSTICK) != 0) - esyslog("Stopping joystick SDL subsystem failed"); -} - -bool CJoystickInterfaceSDL::ScanForJoysticks(JoystickVector& joysticks) -{ - Deinitialize(); - - if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) != 0) - { - esyslog("(Re)start joystick subsystem failed : %s", SDL_GetError()); - return false; - } - - // Any joysticks connected? - if (SDL_NumJoysticks() > 0) - { - // Load joystick names and open all connected joysticks - for (int i = 0 ; i < SDL_NumJoysticks(); i++) - { - SDL_Joystick *joy = SDL_JoystickOpen(i); // joystick pointer is refcounted -#if defined(TARGET_DARWIN) - // On OS X, the 360 controllers are handled externally, since the SDL code is - // really buggy and doesn't handle disconnects. - if (std::string(SDL_JoystickName(i)).find("360") != std::string::npos) - { - isyslog("Ignoring joystick: %s", SDL_JoystickName(i)); - continue; - } -#endif - if (joy) - { - // Some (Microsoft) Keyboards are recognized as Joysticks by modern kernels - // Don't enumerate them - // https://bugs.launchpad.net/ubuntu/+source/linux/+bug/390959 - // NOTICE: Enabled Joystick: Microsoft Wired Keyboard 600 - // Details: Total Axis: 37 Total Hats: 0 Total Buttons: 57 - // NOTICE: Enabled Joystick: Microsoft Microsoft® 2.4GHz Transceiver v6.0 - // Details: Total Axis: 37 Total Hats: 0 Total Buttons: 57 - int num_axis = SDL_JoystickNumAxes(joy); - int num_buttons = SDL_JoystickNumButtons(joy); - if (num_axis > 20 && num_buttons > 50) - { - isyslog("Your Joystick seems to be a Keyboard, ignoring it: %s Axis: %d Buttons: %d", - SDL_JoystickNameForIndex(i), num_axis, num_buttons); - } - else - { - joysticks.push_back(JoystickPtr(new CJoystickSDL(SDL_JoystickNameForIndex(i), joy))); - - /* TODO - isyslog("Enabled Joystick: \"%s\" (SDL)", joystick.m_configuration.Name().c_str()); - isyslog("Details: Total Axes: %d Total Hats: %d Total Buttons: %d", - joystick.m_configuration.AxisIndexes().size(), - joystick.m_configuration.HatIndexes().size(), - joystick.m_configuration.ButtonIndexes().size());; - */ - } - } - } - } - - // Disable joystick events, since we'll be polling them - SDL_JoystickEventState(SDL_DISABLE); - - return true; -} diff --git a/src/api/sdl/JoystickInterfaceSDL.h b/src/api/sdl/JoystickInterfaceSDL.h deleted file mode 100644 index f8524e7f..00000000 --- a/src/api/sdl/JoystickInterfaceSDL.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2014-2015 Garrett Brown - * Copyright (C) 2014-2015 Team XBMC - * - * 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 - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * . - * - */ -#pragma once - -#include "api/IJoystickInterface.h" - -#include - -struct _SDL_Joystick; -typedef struct _SDL_Joystick SDL_Joystick; - -namespace JOYSTICK -{ - class CJoystickInterfaceSDL : public IJoystickInterface - { - public: - CJoystickInterfaceSDL(void); - virtual ~CJoystickInterfaceSDL(void) { Deinitialize(); } - - // implementation of IJoystickInterface - virtual const char* Name(void) const override; - virtual void Deinitialize(void) override; - virtual bool ScanForJoysticks(JoystickVector& joysticks) override; - }; -} diff --git a/src/api/sdl/JoystickSDL.cpp b/src/api/sdl/JoystickSDL.cpp deleted file mode 100644 index 7d2e4276..00000000 --- a/src/api/sdl/JoystickSDL.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2014-2015 Garrett Brown - * Copyright (C) 2014-2015 Team XBMC - * - * 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 - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * . - * - */ - -#include "JoystickSDL.h" -#include "JoystickInterfaceSDL.h" -#include "api/JoystickTypes.h" -#include "utils/CommonMacros.h" - -#include -#include - -#define MAX_AXISAMOUNT 32768 - -using namespace JOYSTICK; - -CJoystickSDL::CJoystickSDL(const std::string& strName, SDL_Joystick* pJoystick) - : CJoystick(INTERFACE_SDL), - m_pJoystick(pJoystick) -{ - SetName(strName); - SetButtonCount(SDL_JoystickNumButtons(m_pJoystick)); - SetHatCount(SDL_JoystickNumHats(m_pJoystick)); - SetAxisCount(SDL_JoystickNumAxes(m_pJoystick)); -} - -CJoystickSDL::~CJoystickSDL(void) -{ - SDL_JoystickClose(m_pJoystick); // joystick pointer is refcounted -} - -bool CJoystickSDL::ScanEvents(void) -{ - // Update the state of all opened joysticks - SDL_JoystickUpdate(); - - // Gamepad buttons - for (unsigned int b = 0; b < ButtonCount(); b++) - SetButtonValue(b, SDL_JoystickGetButton(m_pJoystick, b) ? JOYSTICK_STATE_BUTTON_PRESSED : - JOYSTICK_STATE_BUTTON_UNPRESSED); - - // Gamepad hats - for (unsigned int h = 0; h < HatCount(); h++) - { - switch (SDL_JoystickGetHat(m_pJoystick, h)) - { - case SDL_HAT_UP: - SetHatValue(h, JOYSTICK_STATE_HAT_UP); - break; - case SDL_HAT_RIGHT: - SetHatValue(h, JOYSTICK_STATE_HAT_RIGHT); - break; - case SDL_HAT_DOWN: - SetHatValue(h, JOYSTICK_STATE_HAT_DOWN); - break; - case SDL_HAT_LEFT: - SetHatValue(h, JOYSTICK_STATE_HAT_LEFT); - break; - case SDL_HAT_RIGHTUP: - SetHatValue(h, JOYSTICK_STATE_HAT_RIGHT_UP); - break; - case SDL_HAT_RIGHTDOWN: - SetHatValue(h, JOYSTICK_STATE_HAT_RIGHT_DOWN); - break; - case SDL_HAT_LEFTUP: - SetHatValue(h, JOYSTICK_STATE_HAT_LEFT_UP); - break; - case SDL_HAT_LEFTDOWN: - SetHatValue(h, JOYSTICK_STATE_HAT_LEFT_DOWN); - break; - case SDL_HAT_CENTERED: - default: - SetHatValue(h, JOYSTICK_STATE_HAT_UNPRESSED); - break; - } - } - - // Gamepad axes - for (unsigned int a = 0; a < AxisCount(); a++) - SetAxisValue(a, (long)SDL_JoystickGetAxis(m_pJoystick, a), MAX_AXISAMOUNT); - - return true; -} diff --git a/src/api/sdl/JoystickSDL.h b/src/api/sdl/JoystickSDL.h deleted file mode 100644 index 1d293c7b..00000000 --- a/src/api/sdl/JoystickSDL.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2014-2015 Garrett Brown - * Copyright (C) 2014-2015 Team XBMC - * - * 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 - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This Program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with XBMC; see the file COPYING. If not, see - * . - * - */ -#pragma once - -#include "api/Joystick.h" - -typedef struct _SDL_Joystick SDL_Joystick; - -namespace JOYSTICK -{ - class CJoystickSDL : public CJoystick - { - public: - CJoystickSDL(const std::string& strName, SDL_Joystick* pJoystick); - virtual ~CJoystickSDL(void); - - protected: - virtual bool ScanEvents(void) override; - - private: - SDL_Joystick* m_pJoystick; - }; -}