SDL: Move the keyboard mouse to a subclass of SdlEventSource

And deprecate it. The new Virtual Mouse system is expected to replace
it.
This commit is contained in:
Bastien Bouclet 2020-03-02 20:24:42 +01:00
parent 2d87c21c2b
commit d94c7c3bcc
18 changed files with 480 additions and 377 deletions

View file

@ -23,9 +23,9 @@
#ifndef BACKENDS_EVENTS_SDL_DINGUX_H
#define BACKENDS_EVENTS_SDL_DINGUX_H
#include "backends/events/sdl/sdl-events.h"
#include "backends/events/sdl/legacy-sdl-events.h"
class DINGUXSdlEventSource : public SdlEventSource {
class DINGUXSdlEventSource : public LegacySdlEventSource {
protected:
bool remapKey(SDL_Event &ev, Common::Event &event);
};

View file

@ -23,13 +23,13 @@
#if !defined(BACKEND_EVENTS_GPH_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER)
#define BACKEND_EVENTS_GPH_H
#include "backends/events/sdl/sdl-events.h"
#include "backends/events/sdl/legacy-sdl-events.h"
/*
* SDL Events manager for GPH devices.
*/
class GPHEventSource : public SdlEventSource {
class GPHEventSource : public LegacySdlEventSource {
public:
GPHEventSource();

View file

@ -82,10 +82,6 @@ bool OPEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
else
event.type = Common::EVENT_LBUTTONDOWN; /* For normal mice etc. */
// update KbdMouse
_km.x = ev.button.x * MULTIPLIER;
_km.y = ev.button.y * MULTIPLIER;
return processMouseEvent(event, ev.button.x, ev.button.y);
}
@ -113,9 +109,6 @@ bool OPEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
return false;
processMouseEvent(event, ev.button.x, ev.button.y);
// update KbdMouse
_km.x = ev.button.x * MULTIPLIER;
_km.y = ev.button.y * MULTIPLIER;
return true;
}
@ -130,18 +123,18 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
switch (ev.key.keysym.sym) {
case SDLK_LEFT:
event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP;
processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);
processMouseEvent(event, _mouseY, _mouseY);
return true;
break;
case SDLK_RIGHT:
event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP;
processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);
processMouseEvent(event, _mouseX, _mouseY);
return true;
break;
#if defined(SDL_BUTTON_MIDDLE)
case SDLK_UP:
event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_MBUTTONDOWN : Common::EVENT_MBUTTONUP;
processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);
processMouseEvent(event, _mouseX, _mouseY);
return true;
break;
#endif
@ -154,12 +147,12 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
switch (ev.key.keysym.sym) {
case SDLK_HOME:
event.type = Common::EVENT_LBUTTONDOWN;
processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);
processMouseEvent(event, _mouseX, _mouseY);
return true;
break;
case SDLK_END:
event.type = Common::EVENT_RBUTTONDOWN;
processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);
processMouseEvent(event, _mouseX, _mouseY);
return true;
break;
case SDLK_PAGEDOWN:
@ -192,12 +185,12 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
switch (ev.key.keysym.sym) {
case SDLK_HOME:
event.type = Common::EVENT_LBUTTONUP;
processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);
processMouseEvent(event, _mouseX, _mouseY);
return true;
break;
case SDLK_END:
event.type = Common::EVENT_RBUTTONUP;
processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER);
processMouseEvent(event, _mouseX, _mouseY);
return true;
break;
case SDLK_PAGEDOWN:

View file

@ -103,8 +103,8 @@ void PSP2EventSource::preprocessFingerDown(SDL_Event *event) {
// id (for multitouch)
SDL_FingerID id = event->tfinger.fingerId;
int x = _km.x / MULTIPLIER;
int y = _km.y / MULTIPLIER;
int x = _mouseX;
int y = _mouseY;
if (port == 0 && !ConfMan.getBool("frontpanel_touchpad_mode")) {
convertTouchXYToGameXY(event->tfinger.x, event->tfinger.y, &x, &y);
@ -147,8 +147,8 @@ void PSP2EventSource::preprocessFingerUp(SDL_Event *event) {
}
}
int x = _km.x / MULTIPLIER;
int y = _km.y / MULTIPLIER;
int x = _mouseX;
int y = _mouseY;
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id == id) {
@ -219,8 +219,10 @@ void PSP2EventSource::preprocessFingerMotion(SDL_Event *event) {
}
if (numFingersDown >= 1) {
int x = _km.x / MULTIPLIER;
int y = _km.y / MULTIPLIER;
int x = _mouseX;
int y = _mouseY;
int xMax = _graphicsManager->getWindowWidth() - 1;
int yMax = _graphicsManager->getWindowHeight() - 1;
if (port == 0 && !ConfMan.getBool("frontpanel_touchpad_mode")) {
convertTouchXYToGameXY(event->tfinger.x, event->tfinger.y, &x, &y);
@ -267,23 +269,23 @@ void PSP2EventSource::preprocessFingerMotion(SDL_Event *event) {
// convert touch events to relative mouse pointer events
// track sub-pixel relative finger motion using the MULTIPLIER
_hiresDX += (event->tfinger.dx * 1.25 * speedFactor * _km.x_max * MULTIPLIER);
_hiresDY += (event->tfinger.dy * 1.25 * speedFactor * _km.y_max * MULTIPLIER);
_hiresDX += (event->tfinger.dx * 1.25 * speedFactor * xMax * MULTIPLIER);
_hiresDY += (event->tfinger.dy * 1.25 * speedFactor * yMax * MULTIPLIER);
int xRel = _hiresDX / MULTIPLIER;
int yRel = _hiresDY / MULTIPLIER;
x = (_km.x / MULTIPLIER) + xRel;
y = (_km.y / MULTIPLIER) + yRel;
x = _mouseX + xRel;
y = _mousey + yRel;
_hiresDX %= MULTIPLIER;
_hiresDY %= MULTIPLIER;
}
if (x > _km.x_max) {
x = _km.x_max;
if (x > xMax) {
x = xMax;
} else if (x < 0) {
x = 0;
}
if (y > _km.y_max) {
y = _km.y_max;
if (y > yMax) {
y = yMax;
} else if (y < 0) {
y = 0;
}
@ -311,8 +313,8 @@ void PSP2EventSource::preprocessFingerMotion(SDL_Event *event) {
if (numFingersDownLong >= 2) {
// starting drag, so push mouse down at current location (back)
// or location of "oldest" finger (front)
int mouseDownX = _km.x / MULTIPLIER;
int mouseDownY = _km.y / MULTIPLIER;
int mouseDownX = _mouseX;
int mouseDownY = _mousey;
if (port == 0 && !ConfMan.getBool("frontpanel_touchpad_mode")) {
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id == id) {
@ -372,8 +374,8 @@ void PSP2EventSource::preprocessFingerMotion(SDL_Event *event) {
}
void PSP2EventSource::convertTouchXYToGameXY(float touchX, float touchY, int *gameX, int *gameY) {
int screenH = _km.y_max;
int screenW = _km.x_max;
int screenH = _graphicsManager->getWindowHeight();
int screenW = _graphicsManager->getWindowWidth();
const int dispW = TOUCHSCREEN_WIDTH;
const int dispH = TOUCHSCREEN_HEIGHT;
@ -395,8 +397,8 @@ void PSP2EventSource::convertTouchXYToGameXY(float touchX, float touchY, int *ga
float dispTouchX = (touchX * (float)dispW);
float dispTouchY = (touchY * (float)dispH);
*gameX = CLIP((int)((dispTouchX - x) / sx), 0, (int)_km.x_max);
*gameY = CLIP((int)((dispTouchY - y) / sy), 0, (int)_km.y_max);
*gameX = CLIP((int)((dispTouchX - x) / sx), 0, screenW - 1);
*gameY = CLIP((int)((dispTouchY - y) / sy), 0, screenH - 1);
}
void PSP2EventSource::finishSimulatedMouseClicks() {
@ -414,8 +416,8 @@ void PSP2EventSource::finishSimulatedMouseClicks() {
SDL_Event ev;
ev.type = SDL_MOUSEBUTTONUP;
ev.button.button = simulatedButton;
ev.button.x = _km.x / MULTIPLIER;
ev.button.y = _km.y / MULTIPLIER;
ev.button.x = _mouseX;
ev.button.y = _mousey;
SDL_PushEvent(&ev);
_simulatedClickStartTime[port][i] = 0;

View file

@ -42,7 +42,8 @@ private:
MAX_TAP_TIME = 250, // taps longer than this will not result in mouse click events
MAX_TAP_MOTION_DISTANCE = 10, // max distance finger motion in Vita screen pixels to be considered a tap
SIMULATED_CLICK_DURATION = 50, // time in ms how long simulated mouse clicks should be
}; // track three fingers per panel
MULTIPLIER = 16 // multiplier for sub-pixel resolution
};
typedef struct {
int id; // -1: no touch

View file

@ -23,12 +23,12 @@
#if !defined(BACKEND_EVENTS_SDL_SAMSUNGTV_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER)
#define BACKEND_EVENTS_SDL_SAMSUNGTV_H
#include "backends/events/sdl/sdl-events.h"
#include "backends/events/sdl/legacy-sdl-events.h"
/**
* SDL events manager for Samsung TV
*/
class SamsungTVSdlEventSource : public SdlEventSource {
class SamsungTVSdlEventSource : public LegacySdlEventSource {
protected:
virtual bool remapKey(SDL_Event &ev, Common::Event &event);
};

View file

@ -0,0 +1,309 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM 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/legacy-sdl-events.h"
// #define JOY_INVERT_Y
#define JOY_XAXIS 0
#define JOY_YAXIS 1
LegacySdlEventSource::LegacySdlEventSource() {
// Reset mouse state
memset(&_km, 0, sizeof(_km));
}
void LegacySdlEventSource::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;
}
}
}
bool LegacySdlEventSource::handleKbdMouse(Common::Event &event) {
int32 oldKmX = _km.x;
int32 oldKmY = _km.y;
updateKbdMouse();
if (_km.x != oldKmX || _km.y != oldKmY) {
if (_graphicsManager) {
_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);
}
return false;
}
bool LegacySdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
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);
}
int16 LegacySdlEventSource::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;
}
bool LegacySdlEventSource::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 LegacySdlEventSource::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 LegacySdlEventSource::checkScreenChange() {
if (!_graphicsManager) {
return;
}
int newMaxX = _graphicsManager->getWindowWidth() - 1;
int newMaxY = _graphicsManager->getWindowHeight() - 1;
if (_km.x_max != newMaxX || _km.y_max != newMaxY) {
resetKeyboardEmulation(newMaxX, newMaxY);
}
}
bool LegacySdlEventSource::pollEvent(Common::Event &event) {
checkScreenChange();
bool handled = SdlEventSource::pollEvent(event);
if (handled) {
return true;
}
// Handle mouse control via analog joystick and keyboard
if (handleKbdMouse(event)) {
return true;
}
return false;
}
bool LegacySdlEventSource::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 LegacySdlEventSource::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 LegacySdlEventSource::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 LegacySdlEventSource::handleControllerButton(const SDL_Event &ev, Common::Event &event, bool buttonUp) {
if (event.joystick.button == Common::JOYSTICK_BUTTON_RIGHT_SHOULDER) {
// Right shoulder is the modifier button that makes the mouse go slower.
_km.modifier = !buttonUp;
}
return SdlEventSource::handleControllerButton(ev, event, buttonUp);
}
bool LegacySdlEventSource::handleControllerAxisMotion(const SDL_Event &ev, Common::Event &event) {
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);
}
#endif

View file

@ -0,0 +1,88 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM 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_SDL_LEGACY_H
#define BACKEND_EVENTS_SDL_LEGACY_H
#include "backends/events/sdl/sdl-events.h"
// multiplier used to increase resolution for keyboard/joystick mouse
#define MULTIPLIER 16
class LegacySdlEventSource : public SdlEventSource {
public:
LegacySdlEventSource();
bool pollEvent(Common::Event &event) override;
void checkScreenChange();
protected:
/** @name Keyboard mouse emulation
* Disabled by fingolfin 2004-12-18.
* I am keeping the rest of the code in for now, since the joystick
* code (or rather, "hack") uses it, too.
*/
//@{
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;
virtual void updateKbdMouse();
virtual bool handleKbdMouse(Common::Event &event);
//@}
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 handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) override;
#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
/**
* 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;
/**
* Resets keyboard emulation after a video screen change
*/
void resetKeyboardEmulation(int16 x_max, int16 y_max);
};
#endif

View file

@ -33,10 +33,6 @@
#include "engines/engine.h"
#include "gui/gui-manager.h"
// #define JOY_INVERT_Y
#define JOY_XAXIS 0
#define JOY_YAXIS 1
#if SDL_VERSION_ATLEAST(2, 0, 0)
#define GAMECONTROLLERDB_FILE "gamecontrollerdb.txt"
@ -87,14 +83,12 @@ void SdlEventSource::loadGameControllerMappingFile() {
#endif
SdlEventSource::SdlEventSource()
: EventSource(), _scrollLock(false), _joystick(0), _lastScreenID(0), _graphicsManager(0), _queuedFakeMouseMove(false), _lastHatPosition(SDL_HAT_CENTERED)
: EventSource(), _scrollLock(false), _joystick(0), _lastScreenID(0), _graphicsManager(0), _queuedFakeMouseMove(false),
_lastHatPosition(SDL_HAT_CENTERED), _mouseX(0), _mouseY(0)
#if SDL_VERSION_ATLEAST(2, 0, 0)
, _queuedFakeKeyUp(false), _fakeKeyUp(), _controller(nullptr)
#endif
{
// Reset mouse state
memset(&_km, 0, sizeof(_km));
int joystick_num = ConfMan.getInt("joystick_num");
if (joystick_num >= 0) {
// Initialize SDL joystick subsystem
@ -182,6 +176,9 @@ int SdlEventSource::mapKey(SDL_Keycode sdlKey, SDL_Keymod mod, Uint16 unicode) {
}
bool SdlEventSource::processMouseEvent(Common::Event &event, int x, int y) {
_mouseX = x;
_mouseY = y;
event.mouse.x = x;
event.mouse.y = y;
@ -192,151 +189,6 @@ bool SdlEventSource::processMouseEvent(Common::Event &event, int x, int y) {
return true;
}
void SdlEventSource::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;
}
}
}
bool SdlEventSource::handleKbdMouse(Common::Event &event) {
int32 oldKmX = _km.x;
int32 oldKmY = _km.y;
updateKbdMouse();
if (_km.x != oldKmX || _km.y != oldKmY) {
if (_graphicsManager) {
_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);
}
return false;
}
int16 SdlEventSource::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;
}
void SdlEventSource::SDLModToOSystemKeyFlags(SDL_Keymod mod, Common::Event &event) {
event.kbd.flags = 0;
@ -590,11 +442,6 @@ bool SdlEventSource::pollEvent(Common::Event &event) {
return true;
}
// Handle mouse control via analog joystick and keyboard
if (handleKbdMouse(event)) {
return true;
}
return false;
}
@ -616,11 +463,10 @@ bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
#if SDL_VERSION_ATLEAST(2, 0, 0)
case SDL_MOUSEWHEEL: {
Sint32 yDir = ev.wheel.y;
// HACK: It seems we want the mouse coordinates supplied
// with a mouse wheel event. However, SDL2 does not supply
// these, thus we use whatever we got last time. It seems
// these are always stored in _km.x, _km.y.
if (!processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER)) {
// We want the mouse coordinates supplied with a mouse wheel event.
// However, SDL2 does not supply these, thus we use whatever we got
// last time.
if (!processMouseEvent(event, _mouseX, _mouseY)) {
return false;
}
if (yDir < 0) {
@ -798,10 +644,6 @@ bool SdlEventSource::handleKeyUp(SDL_Event &ev, Common::Event &event) {
bool SdlEventSource::handleMouseMotion(SDL_Event &ev, Common::Event &event) {
event.type = Common::EVENT_MOUSEMOVE;
// update KbdMouse
_km.x = ev.motion.x * MULTIPLIER;
_km.y = ev.motion.y * MULTIPLIER;
return processMouseEvent(event, ev.motion.x, ev.motion.y);
}
@ -831,10 +673,6 @@ bool SdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event)
else
return false;
// update KbdMouse
_km.x = ev.button.x * MULTIPLIER;
_km.y = ev.button.y * MULTIPLIER;
return processMouseEvent(event, ev.button.x, ev.button.y);
}
@ -858,10 +696,6 @@ bool SdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
else
return false;
// update KbdMouse
_km.x = ev.button.x * MULTIPLIER;
_km.y = ev.button.y * MULTIPLIER;
return processMouseEvent(event, ev.button.x, ev.button.y);
}
@ -951,16 +785,6 @@ bool SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
}
bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
// TODO: Move hardcoded axis to mouse motion code to the keymapper
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);
}
event.type = Common::EVENT_JOYAXIS_MOTION;
event.joystick.axis = ev.jaxis.axis;
event.joystick.position = ev.jaxis.value;
@ -1071,25 +895,10 @@ bool SdlEventSource::handleControllerButton(const SDL_Event &ev, Common::Event &
event.type = buttonUp ? Common::EVENT_JOYBUTTON_UP : Common::EVENT_JOYBUTTON_DOWN;
event.joystick.button = button;
if (event.joystick.button == Common::JOYSTICK_BUTTON_RIGHT_SHOULDER) {
// Right shoulder is the modifier button that makes the mouse go slower.
_km.modifier = !buttonUp;
}
return true;
}
bool SdlEventSource::handleControllerAxisMotion(const SDL_Event &ev, Common::Event &event) {
// TODO: Move hardcoded axis to mouse motion code to the keymapper
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);
}
event.type = Common::EVENT_JOYAXIS_MOTION;
event.joystick.axis = ev.caxis.axis;
event.joystick.position = ev.caxis.value;
@ -1098,50 +907,10 @@ bool SdlEventSource::handleControllerAxisMotion(const SDL_Event &ev, Common::Eve
}
#endif
bool SdlEventSource::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;
}
bool SdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
return false;
}
void SdlEventSource::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 SdlEventSource::fakeWarpMouse(const int x, const int y) {
_queuedFakeMouseMove = true;
_fakeMouseMove.type = Common::EVENT_MOUSEMOVE;

View file

@ -28,9 +28,6 @@
#include "common/events.h"
// multiplier used to increase resolution for keyboard/joystick mouse
#define MULTIPLIER 16
// Type names which changed between SDL 1.2 and SDL 2.
#if !SDL_VERSION_ATLEAST(2, 0, 0)
typedef SDLKey SDL_Keycode;
@ -53,11 +50,6 @@ public:
*/
virtual bool pollEvent(Common::Event &event);
/**
* Resets keyboard emulation after a video screen change
*/
virtual void resetKeyboardEmulation(int16 x_max, int16 y_max);
/**
* Emulates a mouse movement that would normally be caused by a mouse warp
* of the system mouse.
@ -65,26 +57,12 @@ public:
void fakeWarpMouse(const int x, const int y);
protected:
/** @name Keyboard mouse emulation
* Disabled by fingolfin 2004-12-18.
* I am keeping the rest of the code in for now, since the joystick
* code (or rather, "hack") uses it, too.
*/
//@{
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;
//@}
/** Scroll lock state - since SDL doesn't track it */
bool _scrollLock;
int _mouseX;
int _mouseY;
/** Joystick */
SDL_Joystick *_joystick;
@ -151,8 +129,6 @@ protected:
virtual bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event);
virtual bool handleJoyAxisMotion(SDL_Event &ev, Common::Event &event);
virtual bool handleJoyHatMotion(SDL_Event &ev, Common::Event &event);
virtual void updateKbdMouse();
virtual bool handleKbdMouse(Common::Event &event);
#if SDL_VERSION_ATLEAST(2, 0, 0)
virtual bool handleJoystickAdded(const SDL_JoyDeviceEvent &event);
@ -164,17 +140,6 @@ protected:
//@}
/**
* 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;
/**
* Assigns the mouse coords to the mouse event. Furthermore notify the
* graphics manager about the position change.

View file

@ -97,8 +97,8 @@ void SwitchEventSource::preprocessFingerDown(SDL_Event *event) {
// id (for multitouch)
SDL_FingerID id = event->tfinger.fingerId;
int x = _km.x / MULTIPLIER;
int y = _km.y / MULTIPLIER;
int x = _mouseX;
int y = _mouseY;
if (port == 0 && !ConfMan.getBool("touchpad_mouse_mode")) {
convertTouchXYToGameXY(event->tfinger.x, event->tfinger.y, &x, &y);
@ -141,8 +141,8 @@ void SwitchEventSource::preprocessFingerUp(SDL_Event *event) {
}
}
int x = _km.x / MULTIPLIER;
int y = _km.y / MULTIPLIER;
int x = _mouseX;
int y = _mouseY;
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id == id) {
@ -213,8 +213,10 @@ void SwitchEventSource::preprocessFingerMotion(SDL_Event *event) {
}
if (numFingersDown >= 1) {
int x = _km.x / MULTIPLIER;
int y = _km.y / MULTIPLIER;
int x = _mouseX;
int y = _mouseY;
int xMax = _graphicsManager->getWindowWidth() - 1;
int yMax = _graphicsManager->getWindowHeight() - 1;
if (port == 0 && !ConfMan.getBool("touchpad_mouse_mode")) {
convertTouchXYToGameXY(event->tfinger.x, event->tfinger.y, &x, &y);
@ -253,14 +255,14 @@ void SwitchEventSource::preprocessFingerMotion(SDL_Event *event) {
// convert touch events to relative mouse pointer events
// Whenever an SDL_event involving the mouse is processed,
// _km.x/y are truncated from subpixel precision to regular pixel precision.
// Therefore, there's no need here to deal with subpixel precision in _km.x/y.
x = (_km.x / MULTIPLIER + (event->tfinger.dx * 1.25 * speedFactor * _km.x_max));
y = (_km.y / MULTIPLIER + (event->tfinger.dy * 1.25 * speedFactor * _km.y_max));
// _mouseX/Y are truncated from subpixel precision to regular pixel precision.
// Therefore, there's no need here to deal with subpixel precision in _mouseX/Y.
x = (_mouseX + (event->tfinger.dx * 1.25 * speedFactor * xMax));
y = (_mouseY + (event->tfinger.dy * 1.25 * speedFactor * yMax));
}
x = CLIP(x, 0, (int)_km.x_max);
y = CLIP(y, 0, (int)_km.y_max);
x = CLIP(x, 0, xMax);
y = CLIP(y, 0, yMax);
// update the current finger's coordinates so we can track it later
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
@ -285,8 +287,8 @@ void SwitchEventSource::preprocessFingerMotion(SDL_Event *event) {
if (numFingersDownLong >= 2) {
// starting drag, so push mouse down at current location (back)
// or location of "oldest" finger (front)
int mouseDownX = _km.x / MULTIPLIER;
int mouseDownY = _km.y / MULTIPLIER;
int mouseDownX = _mouseX;
int mouseDownY = _mouseY;
if (port == 0 && !ConfMan.getBool("touchpad_mouse_mode")) {
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id == id) {
@ -346,8 +348,8 @@ void SwitchEventSource::preprocessFingerMotion(SDL_Event *event) {
}
void SwitchEventSource::convertTouchXYToGameXY(float touchX, float touchY, int *gameX, int *gameY) {
int screenH = _km.y_max;
int screenW = _km.x_max;
int screenH = _graphicsManager->getWindowHeight();
int screenW = _graphicsManager->getWindowWidth();
const int dispW = TOUCHSCREEN_WIDTH;
const int dispH = TOUCHSCREEN_HEIGHT;
@ -369,8 +371,8 @@ void SwitchEventSource::convertTouchXYToGameXY(float touchX, float touchY, int *
float dispTouchX = (touchX * (float)dispW);
float dispTouchY = (touchY * (float)dispH);
*gameX = CLIP((int)((dispTouchX - x) / sx), 0, (int)_km.x_max);
*gameY = CLIP((int)((dispTouchY - y) / sy), 0, (int)_km.y_max);
*gameX = CLIP((int)((dispTouchX - x) / sx), 0, screenW);
*gameY = CLIP((int)((dispTouchY - y) / sy), 0, screenH);
}
void SwitchEventSource::finishSimulatedMouseClicks() {
@ -388,8 +390,8 @@ void SwitchEventSource::finishSimulatedMouseClicks() {
SDL_Event ev;
ev.type = SDL_MOUSEBUTTONUP;
ev.button.button = simulatedButton;
ev.button.x = _km.x / MULTIPLIER;
ev.button.y = _km.y / MULTIPLIER;
ev.button.x = _mouseX;
ev.button.y = _mouseY;
SDL_PushEvent(&ev);
_simulatedClickStartTime[port][i] = 0;

View file

@ -45,7 +45,8 @@ private:
MAX_TAP_TIME = 250, // taps longer than this will not result in mouse click events
MAX_TAP_MOTION_DISTANCE = 10, // max distance finger motion in Vita screen pixels to be considered a tap
SIMULATED_CLICK_DURATION = 50, // time in ms how long simulated mouse clicks should be
}; // track three fingers per panel
MULTIPLIER = 16 // multiplier for sub-pixel resolution
};
typedef struct {
int id; // -1: no touch

View file

@ -23,14 +23,14 @@
#if !defined(BACKEND_EVENTS_SYMBIAN_SDL_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER)
#define BACKEND_EVENTS_SYMBIAN_SDL_H
#include "backends/events/sdl/sdl-events.h"
#include "backends/events/sdl/legacy-sdl-events.h"
#define TOTAL_ZONES 3
/**
* SDL events manager for Symbian
*/
class SymbianSdlEventSource : public SdlEventSource {
class SymbianSdlEventSource : public LegacySdlEventSource {
public:
SymbianSdlEventSource();

View file

@ -150,9 +150,6 @@ bool WebOSSdlEventSource::handleMouseButtonDown(SDL_Event &ev,
_dragging = true;
event.type = Common::EVENT_LBUTTONDOWN;
processMouseEvent(event, _curX, _curY);
// update KbdMouse
_km.x = _curX * MULTIPLIER;
_km.y = _curY * MULTIPLIER;
}
// If we're not in trackpad mode, move the cursor to the tap
if (!_trackpadMode) {
@ -161,17 +158,11 @@ bool WebOSSdlEventSource::handleMouseButtonDown(SDL_Event &ev,
// If we're already clicking, hold it until after the move.
if (event.type == Common::EVENT_LBUTTONDOWN) {
processMouseEvent(event, _curX, _curY);
// update KbdMouse
_km.x = _curX * MULTIPLIER;
_km.y = _curY * MULTIPLIER;
g_system->getEventManager()->pushEvent(event);
}
// Move the mouse
event.type = Common::EVENT_MOUSEMOVE;
processMouseEvent(event, _curX, _curY);
// update KbdMouse
_km.x = _curX * MULTIPLIER;
_km.y = _curY * MULTIPLIER;
}
// Watch for a double-tap-triggered drag
_dragStartTime = g_system->getMillis();
@ -200,9 +191,6 @@ bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev,
if (ev.button.which == 0 && _dragging) {
event.type = Common::EVENT_LBUTTONUP;
processMouseEvent(event, _curX, _curY);
// update KbdMouse
_km.x = _curX * MULTIPLIER;
_km.y = _curY * MULTIPLIER;
_dragging = false;
} else {
// If it was the first finger and the click hasn't been
@ -211,9 +199,6 @@ bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev,
!_fingerDown[1] && !_fingerDown[2]) {
event.type = Common::EVENT_LBUTTONUP;
processMouseEvent(event, _curX, _curY);
// update KbdMouse
_km.x = _curX * MULTIPLIER;
_km.y = _curY * MULTIPLIER;
g_system->getEventManager()->pushEvent(event);
event.type = Common::EVENT_LBUTTONDOWN;
if (_queuedDragTime > 0)
@ -224,9 +209,6 @@ bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev,
// right mouse click.
event.type = Common::EVENT_RBUTTONDOWN;
processMouseEvent(event, _curX, _curY);
// update KbdMouse
_km.x = _curX * MULTIPLIER;
_km.y = _curY * MULTIPLIER;
_queuedRUpTime = g_system->getMillis() + QUEUED_RUP_DELAY;
} else if (ev.button.which == 2 &&
_fingerDown[0] && _fingerDown[1]) {
@ -235,9 +217,6 @@ bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev,
// as a right click.
event.type = Common::EVENT_MBUTTONUP;
processMouseEvent(event, _curX, _curY);
// update KbdMouse
_km.x = _curX * MULTIPLIER;
_km.y = _curY * MULTIPLIER;
g_system->getEventManager()->pushEvent(event);
event.type = Common::EVENT_MBUTTONDOWN;
_fingerDown[1] = false;
@ -284,9 +263,6 @@ bool WebOSSdlEventSource::handleMouseMotion(SDL_Event &ev,
}
event.type = Common::EVENT_MOUSEMOVE;
processMouseEvent(event, _curX, _curY);
// update KbdMouse
_km.x = _curX * MULTIPLIER;
_km.y = _curY * MULTIPLIER;
}
break;
case 1:
@ -431,18 +407,12 @@ bool WebOSSdlEventSource::pollEvent(Common::Event &event) {
} else if (_queuedRUpTime != 0 && curTime >= _queuedRUpTime) {
event.type = Common::EVENT_RBUTTONUP;
processMouseEvent(event, _curX, _curY);
// update KbdMouse
_km.x = _curX * MULTIPLIER;
_km.y = _curY * MULTIPLIER;
_queuedRUpTime = 0;
return true;
} else if (_queuedDragTime != 0 && curTime >= _queuedDragTime) {
event.type = Common::EVENT_LBUTTONDOWN;
_dragging = true;
processMouseEvent(event, _curX, _curY);
// update KbdMouse
_km.x = _curX * MULTIPLIER;
_km.y = _curY * MULTIPLIER;
_queuedDragTime = 0;
return true;
}

View file

@ -235,7 +235,6 @@ void SdlGraphicsManager::setSystemMousePosition(const int x, const int y) {
}
void SdlGraphicsManager::handleResizeImpl(const int width, const int height, const int xdpi, const int ydpi) {
_eventSource->resetKeyboardEmulation(width - 1, height - 1);
_forceRedraw = true;
}

View file

@ -86,6 +86,9 @@ public:
}
}
int getWindowWidth() const { return _windowWidth; }
int getWindowHeight() const { return _windowHeight; }
protected:
/**
* @returns whether or not the game screen must have aspect ratio correction

View file

@ -137,6 +137,7 @@ endif
# derive from the SDL backend, and they all need the following files.
ifdef SDL_BACKEND
MODULE_OBJS += \
events/sdl/legacy-sdl-events.o \
events/sdl/sdl-events.o \
graphics/sdl/sdl-graphics.o \
graphics/surfacesdl/surfacesdl-graphics.o \

View file

@ -40,7 +40,7 @@
#endif
#include "backends/events/default/default-events.h"
#include "backends/events/sdl/sdl-events.h"
#include "backends/events/sdl/legacy-sdl-events.h"
#include "backends/keymapper/hardware-input.h"
#include "backends/mutex/sdl/sdl-mutex.h"
#include "backends/timer/sdl/sdl-timer.h"
@ -203,7 +203,7 @@ void OSystem_SDL::initBackend() {
// Create the default event source, in case a custom backend
// manager didn't provide one yet.
if (_eventSource == 0)
_eventSource = new SdlEventSource();
_eventSource = new LegacySdlEventSource();
if (_eventManager == nullptr) {
DefaultEventManager *eventManager = new DefaultEventManager(_eventSource);