From e9839c31e21a457642c7583afc23218cb405640c Mon Sep 17 00:00:00 2001 From: Pawel Kolodziejski Date: Sat, 3 Oct 2020 17:13:54 +0200 Subject: [PATCH] BACKENDS: Drop native game joystick support in replacement for emulated from core events backend. --- .../events/riscossdl/riscossdl-events.cpp | 2 +- backends/events/riscossdl/riscossdl-events.h | 6 +- backends/events/sdl/resvm-sdl-events.cpp | 467 ------------------ backends/events/sdl/resvm-sdl-events.h | 85 ---- backends/events/sdl/sdl-events.h | 1 - .../openglsdl/openglsdl-graphics3d.cpp | 6 +- backends/graphics3d/sdl/sdl-graphics3d.cpp | 2 +- .../surfacesdl/surfacesdl-graphics3d.cpp | 8 +- backends/keymapper/keymap.cpp | 6 - backends/keymapper/keymapper.cpp | 6 - backends/module.mk | 1 - backends/platform/android/android.h | 1 - backends/platform/android/events.cpp | 71 --- backends/platform/sdl/sdl.cpp | 3 +- engines/engine.h | 9 +- engines/grim/grim.cpp | 3 +- 16 files changed, 9 insertions(+), 668 deletions(-) delete mode 100644 backends/events/sdl/resvm-sdl-events.cpp delete mode 100644 backends/events/sdl/resvm-sdl-events.h diff --git a/backends/events/riscossdl/riscossdl-events.cpp b/backends/events/riscossdl/riscossdl-events.cpp index 0215d74b0ac..201bca94bc6 100644 --- a/backends/events/riscossdl/riscossdl-events.cpp +++ b/backends/events/riscossdl/riscossdl-events.cpp @@ -32,7 +32,7 @@ #include RISCOSSdlEventSource::RISCOSSdlEventSource() - : ResVmSdlEventSource() { // ResidualVM: was SdlEventSource + : SdlEventSource() { int messages[2]; messages[0] = 3; // Message_DataLoad messages[1] = 0; diff --git a/backends/events/riscossdl/riscossdl-events.h b/backends/events/riscossdl/riscossdl-events.h index d54f96b0fde..028c34d5c03 100644 --- a/backends/events/riscossdl/riscossdl-events.h +++ b/backends/events/riscossdl/riscossdl-events.h @@ -23,14 +23,12 @@ #if !defined(BACKEND_EVENTS_RISCOS_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER) #define BACKEND_EVENTS_RISCOS_H -// ResidualVM: -// #include "backends/events/sdl/sdl-events.h" -#include "backends/events/sdl/resvm-sdl-events.h" +#include "backends/events/sdl/sdl-events.h" /** * SDL Events manager for RISC OS. */ -class RISCOSSdlEventSource : public ResVmSdlEventSource { // ResidualVM: was SdlEventSource +class RISCOSSdlEventSource : public SdlEventSource { public: RISCOSSdlEventSource(); protected: diff --git a/backends/events/sdl/resvm-sdl-events.cpp b/backends/events/sdl/resvm-sdl-events.cpp deleted file mode 100644 index 4be6d649c57..00000000000 --- a/backends/events/sdl/resvm-sdl-events.cpp +++ /dev/null @@ -1,467 +0,0 @@ -/* ResidualVM - A 3D game interpreter - * - * ResidualVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * 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 - * of the License, 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "common/scummsys.h" - -#if defined(SDL_BACKEND) - -#include "backends/events/sdl/resvm-sdl-events.h" -#include "backends/graphics3d/sdl/sdl-graphics3d.h" -#include "engines/engine.h" -#include "gui/gui-manager.h" -#include "common/config-manager.h" - -#if defined(ENABLE_VKEYBD) && SDL_VERSION_ATLEAST(2, 0, 0) -#define CONTROLLER_BUT_VKEYBOARD SDL_CONTROLLER_BUTTON_BACK -#endif - -// FIXME move joystick defines out and replace with confile file options -// we should really allow users to map any key to a joystick button - -// #define JOY_INVERT_Y -#define JOY_XAXIS 0 -#define JOY_YAXIS 1 -// buttons -#define JOY_BUT_LMOUSE 0 -#define JOY_BUT_RMOUSE 2 -#define JOY_BUT_ESCAPE 3 -#define JOY_BUT_PERIOD 1 -#define JOY_BUT_SPACE 4 -#define JOY_BUT_F5 5 -#ifdef ENABLE_VKEYBD -#define JOY_BUT_VKEYBOARD 7 -#endif - -ResVmSdlEventSource::ResVmSdlEventSource() { - // Reset mouse state - memset(&_km, 0, sizeof(_km)); - - ConfMan.registerDefault("kbdmouse_speed", 3); - ConfMan.registerDefault("joystick_deadzone", 3); -} - -bool ResVmSdlEventSource::processMouseEvent(Common::Event &event, int x, int y, int relx, int rely) { - event.relMouse.x = relx; - event.relMouse.y = rely; - - return SdlEventSource::processMouseEvent(event, x, y); -} - -bool ResVmSdlEventSource::pollEvent(Common::Event &event) { - bool state = SdlEventSource::pollEvent(event); - - // Handle mouse control via analog joystick and keyboard - if (!state && handleKbdMouse(event)) { - return true; - } - - return state; -} - -bool ResVmSdlEventSource::handleMouseMotion(SDL_Event &ev, Common::Event &event) { - // update KbdMouse - _km.x = ev.motion.x * MULTIPLIER; - _km.y = ev.motion.y * MULTIPLIER; - - return SdlEventSource::handleMouseMotion(ev, event); -} - -bool ResVmSdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) { - // update KbdMouse - _km.x = ev.motion.x * MULTIPLIER; - _km.y = ev.motion.y * MULTIPLIER; - - return SdlEventSource::handleMouseButtonDown(ev, event); -} - -bool ResVmSdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { - // update KbdMouse - _km.x = ev.motion.x * MULTIPLIER; - _km.y = ev.motion.y * MULTIPLIER; - - return SdlEventSource::handleMouseButtonUp(ev, event); -} - -bool ResVmSdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { - if (shouldGenerateMouseEvents()) { - if (ev.jbutton.button == JOY_BUT_LMOUSE) { - event.type = Common::EVENT_LBUTTONDOWN; - return processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); - } else if (ev.jbutton.button == JOY_BUT_RMOUSE) { - event.type = Common::EVENT_RBUTTONDOWN; - return processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); - } - } - - return SdlEventSource::handleJoyButtonDown(ev, event); -} - -bool ResVmSdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { - if (shouldGenerateMouseEvents()) { - if (ev.jbutton.button == JOY_BUT_LMOUSE) { - event.type = Common::EVENT_LBUTTONUP; - return processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); - } else if (ev.jbutton.button == JOY_BUT_RMOUSE) { - event.type = Common::EVENT_RBUTTONUP; - return processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); - } - } - - return SdlEventSource::handleJoyButtonUp(ev, event); -} - -bool ResVmSdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) { - if (shouldGenerateMouseEvents()) { - if (ev.jaxis.axis == JOY_XAXIS) { - _km.joy_x = ev.jaxis.value; - return handleAxisToMouseMotion(_km.joy_x, _km.joy_y); - } else if (ev.jaxis.axis == JOY_YAXIS) { - _km.joy_y = ev.jaxis.value; - return handleAxisToMouseMotion(_km.joy_x, _km.joy_y); - } - } - - return SdlEventSource::handleJoyAxisMotion(ev, event); -} - -#if SDL_VERSION_ATLEAST(2, 0, 0) - -static int mapSDLControllerButtonToResVM(Uint8 sdlButton) { - Common::JoystickButton resvmButtons[] = { - Common::JOYSTICK_BUTTON_A, - Common::JOYSTICK_BUTTON_B, - Common::JOYSTICK_BUTTON_X, - Common::JOYSTICK_BUTTON_Y, - Common::JOYSTICK_BUTTON_BACK, - Common::JOYSTICK_BUTTON_GUIDE, - Common::JOYSTICK_BUTTON_START, - Common::JOYSTICK_BUTTON_LEFT_STICK, - Common::JOYSTICK_BUTTON_RIGHT_STICK, - Common::JOYSTICK_BUTTON_LEFT_SHOULDER, - Common::JOYSTICK_BUTTON_RIGHT_SHOULDER, - Common::JOYSTICK_BUTTON_DPAD_UP, - Common::JOYSTICK_BUTTON_DPAD_DOWN, - Common::JOYSTICK_BUTTON_DPAD_LEFT, - Common::JOYSTICK_BUTTON_DPAD_RIGHT, - }; - - if (sdlButton >= ARRAYSIZE(resvmButtons)) { - return -1; - } - - return resvmButtons[sdlButton]; -} - -bool ResVmSdlEventSource::handleControllerButton(const SDL_Event &ev, Common::Event &event, bool buttonUp) { - if (shouldGenerateMouseEvents()) { -#if SDL_VERSION_ATLEAST(2, 0, 0) - if (event.joystick.button == Common::JOYSTICK_BUTTON_RIGHT_SHOULDER) { - // Right shoulder is the modifier button that makes the mouse go slower. - _km.modifier = !buttonUp; - } -#endif - return SdlEventSource::handleControllerButton(ev, event, buttonUp); - } else { -#ifdef ENABLE_VKEYBD - // Trigger virtual keyboard on long press of more than 1 second of configured button - const uint32 vkeybdTime = 1000; - static uint32 vkeybdThen = 0; - - if (ev.cbutton.button == CONTROLLER_BUT_VKEYBOARD) { - if (!buttonUp) { - vkeybdThen = g_system->getMillis(); - } else if ((vkeybdThen > 0) && (g_system->getMillis() - vkeybdThen >= vkeybdTime)) { - vkeybdThen = 0; - event.type = Common::EVENT_VIRTUAL_KEYBOARD; - return true; - } - } -#endif - int button = mapSDLControllerButtonToResVM(ev.cbutton.button); - if (button == -1) { - return false; - } - - event.type = buttonUp ? Common::EVENT_JOYBUTTON_UP : Common::EVENT_JOYBUTTON_DOWN; - event.joystick.button = button; - return true; - } -} - -bool ResVmSdlEventSource::handleControllerAxisMotion(const SDL_Event &ev, Common::Event &event) { - if (shouldGenerateMouseEvents()) { - if (ev.caxis.axis == SDL_CONTROLLER_AXIS_LEFTX) { - _km.joy_x = ev.caxis.value; - return handleAxisToMouseMotion(_km.joy_x, _km.joy_y); - } else if (ev.caxis.axis == SDL_CONTROLLER_AXIS_LEFTY) { - _km.joy_y = ev.caxis.value; - return handleAxisToMouseMotion(_km.joy_x, _km.joy_y); - } - return SdlEventSource::handleControllerAxisMotion(ev, event); - } else { - // Indicates if L2/R2 are currently pushed or not - static bool l2Pushed = false, r2Pushed = false; - // Simulate buttons from left and right triggers (needed for EMI) - if (ev.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERLEFT) { - bool pushed = (ev.caxis.value > 0); - if (l2Pushed == pushed) - return false; - event.type = (pushed) ? Common::EVENT_JOYBUTTON_DOWN : Common::EVENT_JOYBUTTON_UP; - event.joystick.button = Common::JOYSTICK_BUTTON_LEFT_TRIGGER; - l2Pushed = pushed; - return true; - } else if (ev.caxis.axis == SDL_CONTROLLER_AXIS_TRIGGERRIGHT) { - bool pushed = (ev.caxis.value > 0); - if (r2Pushed == pushed) - return false; - event.type = (pushed) ? Common::EVENT_JOYBUTTON_DOWN : Common::EVENT_JOYBUTTON_UP; - event.joystick.button = Common::JOYSTICK_BUTTON_RIGHT_TRIGGER; - r2Pushed = pushed; - return true; - } else { - event.type = Common::EVENT_JOYAXIS_MOTION; - event.joystick.axis = ev.caxis.axis; - event.joystick.position = ev.caxis.value; - return true; - } - } -} -#endif - -bool ResVmSdlEventSource::shouldGenerateMouseEvents() { - // Engine doesn't support joystick -> emulate mouse events - if (g_engine && !g_engine->hasFeature(Engine::kSupportsJoystick)) { - return true; - } - - // Even if engine supports joystick, emulate mouse events if in GUI or in virtual keyboard - if (g_gui.isActive() || g_engine->isPaused()) { - return true; - } - - return false; -} - -bool ResVmSdlEventSource::handleKbdMouse(Common::Event &event) { - // The ResidualVM version of this method handles relative mouse - // movement, as required by Myst III. - - int32 oldKmX = _km.x; - int32 oldKmY = _km.y; - - updateKbdMouse(); - - if (!dynamic_cast(_graphicsManager)) - return false; - - if (_km.x != oldKmX || _km.y != oldKmY) { - SdlGraphics3dManager *graphicsManager = dynamic_cast(_graphicsManager); - - int32 relX = _km.x - oldKmX; - int32 relY = _km.y - oldKmY; - - if (graphicsManager) { - if (graphicsManager->isMouseLocked()) { - _km.x = oldKmX; - _km.y = oldKmY; - } else { - // warpMouseInWindow causes SDL to generate mouse events. Don't use it when the mouse is locked - // to avoid inconsistent events that would cause crazy camera movement in Myst III. - graphicsManager->getWindow()->warpMouseInWindow((Uint16)(_km.x / MULTIPLIER), (Uint16)(_km.y / MULTIPLIER)); - } - } - - event.type = Common::EVENT_MOUSEMOVE; - return processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER, relX / MULTIPLIER, relY / MULTIPLIER); - } - - return false; -} - -bool ResVmSdlEventSource::handleAxisToMouseMotion(int16 xAxis, int16 yAxis) { -#ifdef JOY_INVERT_Y - yAxis = -yAxis; -#endif - - // conversion factor between keyboard mouse and joy axis value - int vel_to_axis = (1500 / MULTIPLIER); - - // radial and scaled deadzone - - float analogX = (float)xAxis; - float analogY = (float)yAxis; - float deadZone = (float)ConfMan.getInt("joystick_deadzone") * 1000.0f; - - float magnitude = sqrt(analogX * analogX + analogY * analogY); - - if (magnitude >= deadZone) { - _km.x_down_count = 0; - _km.y_down_count = 0; - float scalingFactor = 1.0f / magnitude * (magnitude - deadZone) / (32769.0f - deadZone); - _km.x_vel = (int16)(analogX * scalingFactor * 32768.0f / vel_to_axis); - _km.y_vel = (int16)(analogY * scalingFactor * 32768.0f / vel_to_axis); - } else { - _km.x_vel = 0; - _km.y_vel = 0; - } - - return false; -} - -void ResVmSdlEventSource::resetKeyboardEmulation(int16 x_max, int16 y_max) { - _km.x_max = x_max; - _km.y_max = y_max; - _km.delay_time = 12; - _km.last_time = 0; - _km.modifier = false; - _km.joy_x = 0; - _km.joy_y = 0; -} - -void ResVmSdlEventSource::updateKbdMouse() { - uint32 curTime = g_system->getMillis(true); - if (curTime < _km.last_time + _km.delay_time) { - return; - } - - _km.last_time = curTime; - if (_km.x_down_count == 1) { - _km.x_down_time = curTime; - _km.x_down_count = 2; - } - if (_km.y_down_count == 1) { - _km.y_down_time = curTime; - _km.y_down_count = 2; - } - - if (_km.x_vel || _km.y_vel) { - if (_km.x_down_count) { - if (curTime > _km.x_down_time + 300) { - if (_km.x_vel > 0) - _km.x_vel += MULTIPLIER; - else - _km.x_vel -= MULTIPLIER; - } else if (curTime > _km.x_down_time + 200) { - if (_km.x_vel > 0) - _km.x_vel = 5 * MULTIPLIER; - else - _km.x_vel = -5 * MULTIPLIER; - } - } - if (_km.y_down_count) { - if (curTime > _km.y_down_time + 300) { - if (_km.y_vel > 0) - _km.y_vel += MULTIPLIER; - else - _km.y_vel -= MULTIPLIER; - } else if (curTime > _km.y_down_time + 200) { - if (_km.y_vel > 0) - _km.y_vel = 5 * MULTIPLIER; - else - _km.y_vel = -5 * MULTIPLIER; - } - } - - int16 speedFactor = computeJoystickMouseSpeedFactor(); - - // - The modifier key makes the mouse movement slower - // - The extra factor "delay/speedFactor" ensures velocities - // are independent of the kbdMouse update rate - // - all velocities were originally chosen - // at a delay of 25, so that is the reference used here - // - note: operator order is important to avoid overflow - if (_km.modifier) { - _km.x += ((_km.x_vel / 10) * ((int16)_km.delay_time)) / speedFactor; - _km.y += ((_km.y_vel / 10) * ((int16)_km.delay_time)) / speedFactor; - } else { - _km.x += (_km.x_vel * ((int16)_km.delay_time)) / speedFactor; - _km.y += (_km.y_vel * ((int16)_km.delay_time)) / speedFactor; - } - - if (_km.x < 0) { - _km.x = 0; - _km.x_vel = -1 * MULTIPLIER; - _km.x_down_count = 1; - } else if (_km.x > _km.x_max * MULTIPLIER) { - _km.x = _km.x_max * MULTIPLIER; - _km.x_vel = 1 * MULTIPLIER; - _km.x_down_count = 1; - } - - if (_km.y < 0) { - _km.y = 0; - _km.y_vel = -1 * MULTIPLIER; - _km.y_down_count = 1; - } else if (_km.y > _km.y_max * MULTIPLIER) { - _km.y = _km.y_max * MULTIPLIER; - _km.y_vel = 1 * MULTIPLIER; - _km.y_down_count = 1; - } - } -} - -int16 ResVmSdlEventSource::computeJoystickMouseSpeedFactor() const { - int16 speedFactor; - - switch (ConfMan.getInt("kbdmouse_speed")) { - // 0.25 keyboard pointer speed - case 0: - speedFactor = 100; - break; - // 0.5 speed - case 1: - speedFactor = 50; - break; - // 0.75 speed - case 2: - speedFactor = 33; - break; - // 1.0 speed - case 3: - speedFactor = 25; - break; - // 1.25 speed - case 4: - speedFactor = 20; - break; - // 1.5 speed - case 5: - speedFactor = 17; - break; - // 1.75 speed - case 6: - speedFactor = 14; - break; - // 2.0 speed - case 7: - speedFactor = 12; - break; - default: - speedFactor = 25; - } - - // Scale the mouse cursor speed with the display size so moving across - // the screen takes a reasonable amount of time at higher resolutions. - return speedFactor * 480 / _km.y_max; -} - -#endif diff --git a/backends/events/sdl/resvm-sdl-events.h b/backends/events/sdl/resvm-sdl-events.h deleted file mode 100644 index 40620e74583..00000000000 --- a/backends/events/sdl/resvm-sdl-events.h +++ /dev/null @@ -1,85 +0,0 @@ -/* ResidualVM - A 3D game interpreter - * - * ResidualVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * 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 - * of the License, 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#ifndef BACKEND_EVENTS_RESVM_SDL -#define BACKEND_EVENTS_RESVM_SDL - -#include "backends/events/sdl/sdl-events.h" - -// multiplier used to increase resolution for keyboard/joystick mouse -#define MULTIPLIER 16 - -/** - * Custom event source for ResidualVM with true joystick support. - */ -class ResVmSdlEventSource : public SdlEventSource { -public: - ResVmSdlEventSource(); - - /** - * Resets keyboard emulation after a video screen change - */ - void resetKeyboardEmulation(int16 x_max, int16 y_max); - -protected: - struct KbdMouse { - int32 x, y; - int16 x_vel, y_vel, x_max, y_max, x_down_count, y_down_count, joy_x, joy_y; - uint32 last_time, delay_time, x_down_time, y_down_time; - bool modifier; - }; - KbdMouse _km; - - bool pollEvent(Common::Event &event) override; - void updateKbdMouse(); - - bool handleMouseMotion(SDL_Event &ev, Common::Event &event) override; - bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event) override; - bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event) override; - - bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event) override; - bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event) override; - bool handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) override; - bool handleKbdMouse(Common::Event &event); - - bool processMouseEvent(Common::Event &event, int x, int y, int relx = 0, int rely = 0) override; - - /** - * Update the virtual mouse according to a joystick or game controller axis position change - */ - virtual bool handleAxisToMouseMotion(int16 xAxis, int16 yAxis); - - /** - * Compute the virtual mouse movement speed factor according to the 'kbdmouse_speed' setting. - * The speed factor is scaled with the display size. - */ - int16 computeJoystickMouseSpeedFactor() const; - -#if SDL_VERSION_ATLEAST(2, 0, 0) - bool handleControllerButton(const SDL_Event &ev, Common::Event &event, bool buttonUp) override; - bool handleControllerAxisMotion(const SDL_Event &ev, Common::Event &event) override; -#endif - - bool shouldGenerateMouseEvents(); -}; - -#endif diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h index 0b2d89c1dab..4b841ebe96e 100644 --- a/backends/events/sdl/sdl-events.h +++ b/backends/events/sdl/sdl-events.h @@ -25,7 +25,6 @@ #include "backends/platform/sdl/sdl-sys.h" #include "backends/graphics/sdl/sdl-graphics.h" -#include "backends/graphics3d/sdl/sdl-graphics3d.h" #include "common/events.h" diff --git a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp index 0aab595e26e..3b77e10116c 100644 --- a/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp +++ b/backends/graphics3d/openglsdl/openglsdl-graphics3d.cpp @@ -26,7 +26,7 @@ #include "backends/graphics3d/openglsdl/openglsdl-graphics3d.h" -#include "backends/events/sdl/resvm-sdl-events.h" +#include "backends/events/sdl/sdl-events.h" #include "common/config-manager.h" #include "common/file.h" #include "engines/engine.h" @@ -296,8 +296,6 @@ void OpenGLSdlGraphics3dManager::createOrUpdateScreen() { _screenChangeCount++; - dynamic_cast(_eventSource)->resetKeyboardEmulation(obtainedWidth - 1, obtainedHeight - 1); - #if !defined(AMIGAOS) if (renderToFrameBuffer) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); @@ -353,8 +351,6 @@ void OpenGLSdlGraphics3dManager::notifyResize(const int width, const int height) _overlayBackground = nullptr; _screenChangeCount++; - - dynamic_cast(_eventSource)->resetKeyboardEmulation(newWidth - 1, newHeight- 1); #endif } diff --git a/backends/graphics3d/sdl/sdl-graphics3d.cpp b/backends/graphics3d/sdl/sdl-graphics3d.cpp index 2b2a072b29d..cadbce88767 100644 --- a/backends/graphics3d/sdl/sdl-graphics3d.cpp +++ b/backends/graphics3d/sdl/sdl-graphics3d.cpp @@ -22,8 +22,8 @@ #include "backends/graphics/sdl/sdl-graphics.h" #include "backends/graphics3d/sdl/sdl-graphics3d.h" +#include "backends/events/sdl/sdl-events.h" #include "backends/platform/sdl/sdl-sys.h" -#include "backends/events/sdl/resvm-sdl-events.h" #include "backends/platform/sdl/sdl.h" #include "backends/keymapper/action.h" #include "backends/keymapper/keymap.h" diff --git a/backends/graphics3d/surfacesdl/surfacesdl-graphics3d.cpp b/backends/graphics3d/surfacesdl/surfacesdl-graphics3d.cpp index 3f0c71dac17..10f45cdb8d8 100644 --- a/backends/graphics3d/surfacesdl/surfacesdl-graphics3d.cpp +++ b/backends/graphics3d/surfacesdl/surfacesdl-graphics3d.cpp @@ -25,7 +25,7 @@ #if defined(SDL_BACKEND) #include "backends/graphics3d/surfacesdl/surfacesdl-graphics3d.h" -#include "backends/events/sdl/resvm-sdl-events.h" +#include "backends/events/sdl/sdl-events.h" #include "common/config-manager.h" #include "common/file.h" #include "engines/engine.h" @@ -234,8 +234,6 @@ void SurfaceSdlGraphics3dManager::createOrUpdateScreen() { _screenFormat = _overlayFormat; _screenChangeCount++; - - dynamic_cast(_eventSource)->resetKeyboardEmulation(_gameRect.getWidth() - 1, _gameRect.getHeight() - 1); } Graphics::PixelBuffer SurfaceSdlGraphics3dManager::getScreenPixelBuffer() { @@ -342,8 +340,6 @@ void SurfaceSdlGraphics3dManager::showOverlay() { _overlayVisible = true; clearOverlay(); - - dynamic_cast(_eventSource)->resetKeyboardEmulation(getOverlayWidth() - 1, getOverlayHeight() - 1); } void SurfaceSdlGraphics3dManager::hideOverlay() { @@ -353,8 +349,6 @@ void SurfaceSdlGraphics3dManager::hideOverlay() { _overlayVisible = false; clearOverlay(); - - dynamic_cast(_eventSource)->resetKeyboardEmulation(_gameRect.getWidth() - 1, _gameRect.getHeight() - 1); } void SurfaceSdlGraphics3dManager::grabOverlay(void *buf, int pitch) const { diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp index f66d5d3e3fa..665d5aafdef 100644 --- a/backends/keymapper/keymap.cpp +++ b/backends/keymapper/keymap.cpp @@ -136,12 +136,6 @@ const Action *Keymap::findAction(const char *id) const { } Keymap::KeymapMatch Keymap::getMappedActions(const Event &event, ActionArray &actions) const { - // ResidualVM specific START - if (event.type == EVENT_JOYAXIS_MOTION) { - return kKeymapMatchNone; - } - // ResidualVM specific END - switch (event.type) { case EVENT_KEYDOWN: case EVENT_KEYUP: { diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index 7ac7ce27804..1be29220d83 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -244,12 +244,6 @@ Keymap::KeymapMatch Keymapper::getMappedActions(const Event &event, Keymap::Acti } Keymapper::IncomingEventType Keymapper::convertToIncomingEventType(const Event &ev) const { - // ResidualVM specific START - if (ev.type == EVENT_JOYAXIS_MOTION) { - return kIncomingEventIgnored; - } - // ResidualVM specific END - if (ev.type == EVENT_CUSTOM_BACKEND_HARDWARE || ev.type == EVENT_WHEELDOWN || ev.type == EVENT_WHEELUP) { diff --git a/backends/module.mk b/backends/module.mk index f9fbb1fafe6..4a089587439 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -134,7 +134,6 @@ ifdef SDL_BACKEND MODULE_OBJS += \ events/sdl/legacy-sdl-events.o \ events/sdl/sdl-events.o \ - events/sdl/resvm-sdl-events.o \ graphics/sdl/sdl-graphics.o \ graphics/surfacesdl/surfacesdl-graphics.o \ graphics3d/sdl/sdl-graphics3d.o \ diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h index 65f808a1007..72eec1f68c3 100644 --- a/backends/platform/android/android.h +++ b/backends/platform/android/android.h @@ -141,7 +141,6 @@ public: public: void pushEvent(int type, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6); - bool shouldGenerateMouseEvents(); private: Common::Queue _event_queue; diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp index d143e34edef..eb7fa9e7b3d 100644 --- a/backends/platform/android/events.cpp +++ b/backends/platform/android/events.cpp @@ -286,38 +286,6 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, case JKEYCODE_DPAD_DOWN: case JKEYCODE_DPAD_LEFT: case JKEYCODE_DPAD_RIGHT: - if (!shouldGenerateMouseEvents()) { - switch (arg1) { - case JACTION_DOWN: - e.type = Common::EVENT_KEYDOWN; - break; - case JACTION_UP: - e.type = Common::EVENT_KEYUP; - break; - default: - LOGE("unhandled jaction on dpad key: %d", arg1); - return; - } - - switch (arg2) { - case JKEYCODE_DPAD_UP: - e.kbd.keycode = Common::KEYCODE_UP; - break; - case JKEYCODE_DPAD_DOWN: - e.kbd.keycode = Common::KEYCODE_DOWN; - break; - case JKEYCODE_DPAD_LEFT: - e.kbd.keycode = Common::KEYCODE_LEFT; - break; - case JKEYCODE_DPAD_RIGHT: - e.kbd.keycode = Common::KEYCODE_RIGHT; - break; - } - - pushEvent(e); - return; - } - if (arg1 != JACTION_DOWN) return; @@ -380,9 +348,6 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, break; case JE_SCROLL: - if (!shouldGenerateMouseEvents()) - return; - e.type = Common::EVENT_MOUSEMOVE; if (_touchpad_mode) { @@ -411,15 +376,6 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, return; } - // ResidualVM specific code start - if (!shouldGenerateMouseEvents()) { - Common::Event ev; - ev.kbd.keycode = Common::KEYCODE_RETURN; - pushKeyPressEvent(ev); - return; - } - // ResidualVM specific code end - e.type = Common::EVENT_MOUSEMOVE; if (_touchpad_mode) { @@ -464,14 +420,6 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, return; case JE_DOUBLE_TAP: - // ResidualVM specific code start - if (!shouldGenerateMouseEvents()) { - Common::Event ev; - ev.kbd.keycode = Common::KEYCODE_u; - pushKeyPressEvent(ev); - } - // ResidualVM specific code end - e.type = Common::EVENT_MOUSEMOVE; if (_touchpad_mode) { @@ -526,10 +474,6 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, case JE_TOUCH: case JE_MULTI: - if (!shouldGenerateMouseEvents()) { - _touchControls.update(arg1, arg2, arg3, arg4); - return; - } switch (arg2) { case JACTION_POINTER_DOWN: if (arg1 > _fingersDown) @@ -738,21 +682,6 @@ bool OSystem_Android::pollEvent(Common::Event &event) { return true; } -bool OSystem_Android::shouldGenerateMouseEvents() { - // Engine doesn't support joystick -> emulate mouse events - // TODO: Provide dedicated feature for handling touchscreen events - if (g_engine && !g_engine->hasFeature(Engine::kSupportsJoystick)) { - return true; - } - - // Even if engine supports joystick, emulate mouse events if in GUI or in virtual keyboard - if (g_gui.isActive() || g_engine->isPaused()) { - return true; - } - - return false; -} - void OSystem_Android::pushEvent(const Common::Event &event) { _event_queue_lock->lock(); _event_queue.push(event); diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index a07e617b782..ab3fbf0fdef 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -44,7 +44,6 @@ #endif #include "backends/events/default/default-events.h" -#include "backends/events/sdl/resvm-sdl-events.h" // ResidualVM #include "backends/events/sdl/legacy-sdl-events.h" #include "backends/keymapper/hardware-input.h" #include "backends/mutex/sdl/sdl-mutex.h" @@ -227,7 +226,7 @@ void OSystem_SDL::initBackend() { // Create the default event source, in case a custom backend // manager didn't provide one yet. if (!_eventSource) - _eventSource = new ResVmSdlEventSource(); // ResidualVm: was SdlEventSource + _eventSource = new SdlEventSource(); #if !SDL_VERSION_ATLEAST(2, 0, 0) // SDL 1 does not generate its own keyboard repeat events. diff --git a/engines/engine.h b/engines/engine.h index 64439638a38..dd0a81d5b7c 100644 --- a/engines/engine.h +++ b/engines/engine.h @@ -206,14 +206,7 @@ public: * The engine will need to read the actual resolution used by the * backend using OSystem::getWidth and OSystem::getHeight. */ - kSupportsArbitraryResolutions, // ResidualVM specific - - /** - * Engine must receive joystick events because the game uses them. - * For engines which have not this feature, joystick events are converted - * to mouse events. - */ - kSupportsJoystick // ResidualVM specific + kSupportsArbitraryResolutions // ResidualVM specific }; diff --git a/engines/grim/grim.cpp b/engines/grim/grim.cpp index 87dc4176c39..35596420c70 100644 --- a/engines/grim/grim.cpp +++ b/engines/grim/grim.cpp @@ -1384,8 +1384,7 @@ void GrimEngine::clearEventQueue() { bool GrimEngine::hasFeature(EngineFeature f) const { return (f == kSupportsReturnToLauncher) || - (f == kSupportsLoadingDuringRuntime) || - (f == kSupportsJoystick); + (f == kSupportsLoadingDuringRuntime); } void GrimEngine::pauseEngineIntern(bool pause) {