diff options
Diffstat (limited to 'backends')
-rw-r--r-- | backends/events/ps3sdl/ps3sdl-events.cpp | 138 | ||||
-rw-r--r-- | backends/events/ps3sdl/ps3sdl-events.h | 2 | ||||
-rw-r--r-- | backends/events/psp2sdl/psp2sdl-events.cpp | 277 | ||||
-rw-r--r-- | backends/events/psp2sdl/psp2sdl-events.h | 3 | ||||
-rw-r--r-- | backends/events/sdl/sdl-events.cpp | 309 | ||||
-rw-r--r-- | backends/events/sdl/sdl-events.h | 32 | ||||
-rw-r--r-- | backends/events/symbiansdl/symbiansdl-events.cpp | 36 | ||||
-rw-r--r-- | backends/events/symbiansdl/symbiansdl-events.h | 2 | ||||
-rw-r--r-- | backends/platform/psp/display_manager.cpp | 29 | ||||
-rw-r--r-- | backends/platform/psp/display_manager.h | 3 | ||||
-rw-r--r-- | backends/platform/sdl/psp2/psp2.cpp | 14 | ||||
-rw-r--r-- | backends/platform/sdl/sdl.cpp | 20 | ||||
-rw-r--r-- | backends/platform/symbian/README | 2 | ||||
-rw-r--r-- | backends/platform/symbian/src/SymbianOS.cpp | 7 | ||||
-rw-r--r-- | backends/platform/symbian/src/SymbianOS.h | 1 |
15 files changed, 371 insertions, 504 deletions
diff --git a/backends/events/ps3sdl/ps3sdl-events.cpp b/backends/events/ps3sdl/ps3sdl-events.cpp index 01cdc2f0f6..2aa2adbac6 100644 --- a/backends/events/ps3sdl/ps3sdl-events.cpp +++ b/backends/events/ps3sdl/ps3sdl-events.cpp @@ -31,128 +31,34 @@ #include "common/util.h" #include "common/events.h" -enum { - BTN_LEFT = 0, - BTN_DOWN = 1, - BTN_RIGHT = 2, - BTN_UP = 3, - - BTN_START = 4, - BTN_R3 = 5, - BTN_L3 = 6, - BTN_SELECT = 7, - - BTN_SQUARE = 8, - BTN_CROSS = 9, - BTN_CIRCLE = 10, - BTN_TRIANGLE = 11, - - BTN_R1 = 12, - BTN_L1 = 13, - BTN_R2 = 14, - BTN_L2 = 15 -}; - -bool PS3SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { - - event.kbd.flags = 0; - - switch (ev.jbutton.button) { - case BTN_CROSS: // Left mouse button - event.type = Common::EVENT_LBUTTONDOWN; - processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); - break; - case BTN_CIRCLE: // Right mouse button - event.type = Common::EVENT_RBUTTONDOWN; - processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); - break; - case BTN_TRIANGLE: // Game menu - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = Common::KEYCODE_F5; - event.kbd.ascii = mapKey(SDLK_F5, (SDLMod) ev.key.keysym.mod, 0); - break; - case BTN_SELECT: // Virtual keyboard -#ifdef ENABLE_VKEYBD - event.type = Common::EVENT_VIRTUAL_KEYBOARD; -#endif - break; - case BTN_SQUARE: // Escape - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = Common::KEYCODE_ESCAPE; - event.kbd.ascii = mapKey(SDLK_ESCAPE, (SDLMod) ev.key.keysym.mod, 0); - break; - case BTN_L1: // Predictive input dialog - event.type = Common::EVENT_PREDICTIVE_DIALOG; - break; - case BTN_START: // ScummVM in game menu - event.type = Common::EVENT_MAINMENU; - break; - } - return true; -} - -bool PS3SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { - - event.kbd.flags = 0; - - switch (ev.jbutton.button) { - case BTN_CROSS: // Left mouse button - event.type = Common::EVENT_LBUTTONUP; - processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); - break; - case BTN_CIRCLE: // Right mouse button - event.type = Common::EVENT_RBUTTONUP; - processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); - break; - case BTN_TRIANGLE: // Game menu - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_F5; - event.kbd.ascii = mapKey(SDLK_F5, (SDLMod) ev.key.keysym.mod, 0); - break; - case BTN_SELECT: // Virtual keyboard - // Handled in key down - break; - case BTN_SQUARE: // Escape - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_ESCAPE; - event.kbd.ascii = mapKey(SDLK_ESCAPE, (SDLMod) ev.key.keysym.mod, 0); - break; - } - return true; -} - /** * The XMB (PS3 in game menu) needs the screen buffers to be constantly flip while open. * This pauses execution and keeps redrawing the screen until the XMB is closed. */ void PS3SdlEventSource::preprocessEvents(SDL_Event *event) { - if (event->type == SDL_WINDOWEVENT) { - if (event->window.event == SDL_WINDOWEVENT_LEAVE) { - // XMB opened - if (g_engine) - g_engine->pauseEngine(true); - - for (;;) { - if (!SDL_PollEvent(event)) { - // Locking the screen forces a full redraw - Graphics::Surface* screen = g_system->lockScreen(); - if (screen) { - g_system->unlockScreen(); - g_system->updateScreen(); - } - SDL_Delay(10); - continue; - } - if (event->type == SDL_QUIT) - return; - if (event->type != SDL_WINDOWEVENT) - continue; - if (event->window.event == SDL_WINDOWEVENT_ENTER) { - // XMB closed - if (g_engine) - g_engine->pauseEngine(false); - return; + if (event->type == SDL_APP_DIDENTERBACKGROUND) { + // XMB opened + if (g_engine) + g_engine->pauseEngine(true); + + for (;;) { + if (!SDL_PollEvent(event)) { + // Locking the screen forces a full redraw + Graphics::Surface* screen = g_system->lockScreen(); + if (screen) { + g_system->unlockScreen(); + g_system->updateScreen(); } + SDL_Delay(10); + continue; + } + if (event->type == SDL_QUIT) + return; + if (event->type == SDL_APP_DIDENTERFOREGROUND) { + // XMB closed + if (g_engine) + g_engine->pauseEngine(false); + return; } } } diff --git a/backends/events/ps3sdl/ps3sdl-events.h b/backends/events/ps3sdl/ps3sdl-events.h index d28ce7fcf8..340af49102 100644 --- a/backends/events/ps3sdl/ps3sdl-events.h +++ b/backends/events/ps3sdl/ps3sdl-events.h @@ -31,8 +31,6 @@ class PS3SdlEventSource : public SdlEventSource { protected: void preprocessEvents(SDL_Event *event); - bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event); - bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event); }; #endif /* BACKEND_EVENTS_PS3_H */ diff --git a/backends/events/psp2sdl/psp2sdl-events.cpp b/backends/events/psp2sdl/psp2sdl-events.cpp index e58e49d9a8..4ea528b00f 100644 --- a/backends/events/psp2sdl/psp2sdl-events.cpp +++ b/backends/events/psp2sdl/psp2sdl-events.cpp @@ -36,283 +36,6 @@ #include "math.h" -#define JOY_DEADZONE 2000 -#define JOY_ANALOG -#define JOY_XAXIS 0 -#define JOY_YAXIS 1 -#define JOY_XAXISR 2 -#define JOY_YAXISR 3 - -enum { - BTN_LEFT = 7, - BTN_DOWN = 6, - BTN_RIGHT = 9, - BTN_UP = 8, - - BTN_START = 11, - BTN_SELECT = 10, - - BTN_SQUARE = 3, - BTN_CROSS = 2, - BTN_CIRCLE = 1, - BTN_TRIANGLE = 0, - - BTN_R1 = 5, - BTN_L1 = 4 -}; - -bool PSP2EventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { - - event.kbd.flags = 0; - - switch (ev.jbutton.button) { -// Dpad - case BTN_LEFT: // Left (+R_trigger: Up+Left) - if (!_km.modifier) { - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = Common::KEYCODE_KP4; - event.kbd.ascii = mapKey(SDLK_KP4, (SDLMod) ev.key.keysym.mod, 0); - } else { - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = Common::KEYCODE_KP7; - event.kbd.ascii = mapKey(SDLK_KP7, (SDLMod) ev.key.keysym.mod, 0); - } - break; - case BTN_RIGHT: // Right (+R_trigger: Down+Right) - if (!_km.modifier) { - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = Common::KEYCODE_KP6; - event.kbd.ascii = mapKey(SDLK_KP6, (SDLMod) ev.key.keysym.mod, 0); - } else { - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = Common::KEYCODE_KP3; - event.kbd.ascii = mapKey(SDLK_KP3, (SDLMod) ev.key.keysym.mod, 0); - } - break; - case BTN_UP: // Up (+R_trigger: Up+Right) - if (!_km.modifier) { - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = Common::KEYCODE_KP8; - event.kbd.ascii = mapKey(SDLK_KP8, (SDLMod) ev.key.keysym.mod, 0); - } else { - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = Common::KEYCODE_KP9; - event.kbd.ascii = mapKey(SDLK_KP9, (SDLMod) ev.key.keysym.mod, 0); - } - break; - case BTN_DOWN: // Down (+R_trigger: Down+Left) - if (!_km.modifier) { - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = Common::KEYCODE_KP2; - event.kbd.ascii = mapKey(SDLK_KP2, (SDLMod) ev.key.keysym.mod, 0); - } else { - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = Common::KEYCODE_KP1; - event.kbd.ascii = mapKey(SDLK_KP1, (SDLMod) ev.key.keysym.mod, 0); - } - break; -// Buttons - case BTN_CROSS: // Left mouse button - event.type = Common::EVENT_LBUTTONDOWN; - processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); - break; - case BTN_CIRCLE: // Right mouse button - event.type = Common::EVENT_RBUTTONDOWN; - processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); - break; - case BTN_TRIANGLE: // Escape (+R_trigger: Return) - if (!_km.modifier) { - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = Common::KEYCODE_ESCAPE; - event.kbd.ascii = mapKey(SDLK_ESCAPE, (SDLMod) ev.key.keysym.mod, 0); - } else { - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = Common::KEYCODE_RETURN; - event.kbd.ascii = mapKey(SDLK_RETURN, (SDLMod) ev.key.keysym.mod, 0); - } - break; - case BTN_SQUARE: // Period (+R_trigger: Space) - if (!_km.modifier) { - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = Common::KEYCODE_PERIOD; - event.kbd.ascii = mapKey(SDLK_PERIOD, (SDLMod) ev.key.keysym.mod, 0); - } else { - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = Common::KEYCODE_SPACE; - event.kbd.ascii = mapKey(SDLK_SPACE, (SDLMod) ev.key.keysym.mod, 0); - } - break; - case BTN_L1: // Game menu - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = Common::KEYCODE_F5; - event.kbd.ascii = mapKey(SDLK_F5, (SDLMod) ev.key.keysym.mod, 0); - break; - case BTN_R1: // Modifier + Shift - _km.modifier=true; // slow mouse - event.type = Common::EVENT_KEYDOWN; - event.kbd.keycode = Common::KEYCODE_INVALID; - event.kbd.ascii = 0; - event.kbd.flags = Common::KBD_SHIFT; - break; - case BTN_START: // ScummVM in game menu - event.type = Common::EVENT_MAINMENU; - break; - case BTN_SELECT: // Virtual keyboard (+R_trigger: Predictive Input Dialog) - if (!_km.modifier) { -#ifdef ENABLE_VKEYBD - event.type = Common::EVENT_VIRTUAL_KEYBOARD; -#endif - } else { - event.type = Common::EVENT_PREDICTIVE_DIALOG; - } - break; - } - return true; -} - -bool PSP2EventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { - - event.kbd.flags = 0; - - switch (ev.jbutton.button) { -// Dpad - case BTN_LEFT: // Left (+R_trigger: Up+Left) - if (!_km.modifier) { - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_KP4; - event.kbd.ascii = mapKey(SDLK_KP4, (SDLMod) ev.key.keysym.mod, 0); - } else { - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_KP7; - event.kbd.ascii = mapKey(SDLK_KP7, (SDLMod) ev.key.keysym.mod, 0); - } - break; - case BTN_RIGHT: // Right (+R_trigger: Down+Right) - if (!_km.modifier) { - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_KP6; - event.kbd.ascii = mapKey(SDLK_KP6, (SDLMod) ev.key.keysym.mod, 0); - } else { - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_KP3; - event.kbd.ascii = mapKey(SDLK_KP3, (SDLMod) ev.key.keysym.mod, 0); - } - break; - case BTN_UP: // Up (+R_trigger: Up+Right) - if (!_km.modifier) { - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_KP8; - event.kbd.ascii = mapKey(SDLK_KP8, (SDLMod) ev.key.keysym.mod, 0); - } else { - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_KP9; - event.kbd.ascii = mapKey(SDLK_KP9, (SDLMod) ev.key.keysym.mod, 0); - } - break; - case BTN_DOWN: // Down (+R_trigger: Down+Left) - if (!_km.modifier) { - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_KP2; - event.kbd.ascii = mapKey(SDLK_KP2, (SDLMod) ev.key.keysym.mod, 0); - } else { - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_KP1; - event.kbd.ascii = mapKey(SDLK_KP1, (SDLMod) ev.key.keysym.mod, 0); - } - break; -// Buttons - case BTN_CROSS: // Left mouse button - event.type = Common::EVENT_LBUTTONUP; - processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); - break; - case BTN_CIRCLE: // Right mouse button - event.type = Common::EVENT_RBUTTONUP; - processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); - break; - case BTN_TRIANGLE: // Escape (+R_trigger: Return) - if (!_km.modifier) { - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_ESCAPE; - event.kbd.ascii = mapKey(SDLK_ESCAPE, (SDLMod) ev.key.keysym.mod, 0); - } else { - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_RETURN; - event.kbd.ascii = mapKey(SDLK_RETURN, (SDLMod) ev.key.keysym.mod, 0); - } - break; - case BTN_SQUARE: // Period (+R_trigger: Space) - if (!_km.modifier) { - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_PERIOD; - event.kbd.ascii = mapKey(SDLK_PERIOD, (SDLMod) ev.key.keysym.mod, 0); - } else { - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_SPACE; - event.kbd.ascii = mapKey(SDLK_SPACE, (SDLMod) ev.key.keysym.mod, 0); - } - break; - case BTN_L1: // Game menu - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_F5; - event.kbd.ascii = mapKey(SDLK_F5, (SDLMod) ev.key.keysym.mod, 0); - break; - case BTN_R1: // Modifier + SHIFT Key - _km.modifier = false; // slow mouse - event.type = Common::EVENT_KEYUP; - event.kbd.keycode = Common::KEYCODE_INVALID; - event.kbd.ascii = 0; - event.kbd.flags = 0; - break; - case BTN_START: // ScummVM in game menu - // Handled in key down - break; - case BTN_SELECT: // Virtual keyboard (+R_trigger: Predictive Input Dialog) - // Handled in key down - break; - } - return true; -} - -bool PSP2EventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) { - - int axis = ev.jaxis.value; - - // conversion factor between keyboard mouse and joy axis value - int vel_to_axis = (1500 / MULTIPLIER); - - if (ev.jaxis.axis == JOY_XAXIS) { - _km.joy_x = axis; - } else if (ev.jaxis.axis == JOY_YAXIS) { - axis = -axis; - _km.joy_y = -axis; - } - - // radial and scaled deadzone - - float analogX = (float)_km.joy_x; - float analogY = (float)_km.joy_y; - float deadZone = (float)JOY_DEADZONE; - if (g_system->hasFeature(OSystem::kFeatureJoystickDeadzone)) - deadZone = (float)ConfMan.getInt("joystick_deadzone") * 1000.0f; - float scalingFactor = 1.0f; - float magnitude = 0.0f; - - magnitude = sqrt(analogX * analogX + analogY * analogY); - - if (magnitude >= deadZone) { - _km.x_down_count = 0; - _km.y_down_count = 0; - scalingFactor = 1.0f / magnitude * (magnitude - deadZone) / (32769.0f - deadZone); - _km.x_vel = (int16)(analogX * scalingFactor * 32768.0f / (float) vel_to_axis); - _km.y_vel = (int16)(analogY * scalingFactor * 32768.0f / (float) vel_to_axis); - } else { - _km.x_vel = 0; - _km.y_vel = 0; - } - - return false; -} - void PSP2EventSource::preprocessEvents(SDL_Event *event) { // prevent suspend (scummvm games contains a lot of cutscenes..) diff --git a/backends/events/psp2sdl/psp2sdl-events.h b/backends/events/psp2sdl/psp2sdl-events.h index 001312e1d5..5593e8a504 100644 --- a/backends/events/psp2sdl/psp2sdl-events.h +++ b/backends/events/psp2sdl/psp2sdl-events.h @@ -30,9 +30,6 @@ */ class PSP2EventSource : public SdlEventSource { protected: - bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event); - bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event); - bool handleJoyAxisMotion(SDL_Event &ev, Common::Event &event); void preprocessEvents(SDL_Event *event); }; diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index 48854437ad..a3dee67f22 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -30,17 +30,8 @@ #include "common/config-manager.h" #include "common/textconsole.h" -#ifdef JOY_ANALOG -#include "math.h" -#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_DEADZONE 3200 - -#ifndef __SYMBIAN32__ // Symbian wants dialog joystick i.e cursor for movement/selection - #define JOY_ANALOG -#endif // #define JOY_INVERT_Y #define JOY_XAXIS 0 @@ -77,7 +68,7 @@ static uint32 convUTF8ToUTF32(const char *src) { SdlEventSource::SdlEventSource() : EventSource(), _scrollLock(false), _joystick(0), _lastScreenID(0), _graphicsManager(0), _queuedFakeMouseMove(false) #if SDL_VERSION_ATLEAST(2, 0, 0) - , _queuedFakeKeyUp(false), _fakeKeyUp() + , _queuedFakeKeyUp(false), _fakeKeyUp(), _controller(nullptr) #endif { // Reset mouse state @@ -90,25 +81,18 @@ SdlEventSource::SdlEventSource() error("Could not initialize SDL: %s", SDL_GetError()); } - // Enable joystick - if (SDL_NumJoysticks() > joystick_num) { - _joystick = SDL_JoystickOpen(joystick_num); - debug("Using joystick: %s", #if SDL_VERSION_ATLEAST(2, 0, 0) - SDL_JoystickName(_joystick) -#else - SDL_JoystickName(joystick_num) -#endif - ); - } else { - warning("Invalid joystick: %d", joystick_num); + if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) == -1) { + error("Could not initialize SDL: %s", SDL_GetError()); } +#endif + + openJoystick(joystick_num); } } SdlEventSource::~SdlEventSource() { - if (_joystick) - SDL_JoystickClose(_joystick); + closeJoystick(); } int SdlEventSource::mapKey(SDLKey sdlKey, SDLMod mod, Uint16 unicode) { @@ -534,12 +518,6 @@ bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) { return handleMouseButtonDown(ev, event); case SDL_MOUSEBUTTONUP: return handleMouseButtonUp(ev, event); - case SDL_JOYBUTTONDOWN: - return handleJoyButtonDown(ev, event); - case SDL_JOYBUTTONUP: - return handleJoyButtonUp(ev, event); - case SDL_JOYAXISMOTION: - return handleJoyAxisMotion(ev, event); #if SDL_VERSION_ATLEAST(2, 0, 0) case SDL_MOUSEWHEEL: { @@ -607,6 +585,12 @@ bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) { default: return false; } + + case SDL_JOYDEVICEADDED: + return handleJoystickAdded(ev.jdevice); + + case SDL_JOYDEVICEREMOVED: + return handleJoystickRemoved(ev.jdevice); #else case SDL_VIDEOEXPOSE: if (_graphicsManager) @@ -623,6 +607,30 @@ bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) { } + if (_joystick) { + switch (ev.type) { + case SDL_JOYBUTTONDOWN: + return handleJoyButtonDown(ev, event); + case SDL_JOYBUTTONUP: + return handleJoyButtonUp(ev, event); + case SDL_JOYAXISMOTION: + return handleJoyAxisMotion(ev, event); + } + } + +#if SDL_VERSION_ATLEAST(2, 0, 0) + if (_controller) { + switch (ev.type) { + case SDL_CONTROLLERBUTTONDOWN: + return handleControllerButton(ev, event, false); + case SDL_CONTROLLERBUTTONUP: + return handleControllerButton(ev, event, true); + case SDL_CONTROLLERAXISMOTION: + return handleControllerAxisMotion(ev, event); + } + } +#endif + return false; } @@ -797,6 +805,42 @@ bool SdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { return processMouseEvent(event, ev.button.x, ev.button.y); } +void SdlEventSource::openJoystick(int joystickIndex) { + if (SDL_NumJoysticks() > joystickIndex) { +#if SDL_VERSION_ATLEAST(2, 0, 0) + if (SDL_IsGameController(joystickIndex)) { + _controller = SDL_GameControllerOpen(joystickIndex); + debug("Using game controller: %s", SDL_GameControllerName(_controller)); + } else +#endif + { + _joystick = SDL_JoystickOpen(joystickIndex); + debug("Using joystick: %s", +#if SDL_VERSION_ATLEAST(2, 0, 0) + SDL_JoystickName(_joystick) +#else + SDL_JoystickName(joystickIndex) +#endif + ); + } + } else { + warning("Invalid joystick: %d", joystickIndex); + } +} + +void SdlEventSource::closeJoystick() { +#if SDL_VERSION_ATLEAST(2, 0, 0) + if (_controller) { + SDL_GameControllerClose(_controller); + _controller = nullptr; + } +#endif + if (_joystick) { + SDL_JoystickClose(_joystick); + _joystick = nullptr; + } +} + bool SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { if (ev.jbutton.button == JOY_BUT_LMOUSE) { event.type = Common::EVENT_LBUTTONDOWN; @@ -860,71 +904,184 @@ bool SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { } bool SdlEventSource::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); + } - int axis = ev.jaxis.value; -#ifdef JOY_ANALOG - // conversion factor between keyboard mouse and joy axis value - int vel_to_axis = (1500 / MULTIPLIER); + return false; +} + +#if SDL_VERSION_ATLEAST(2, 0, 0) +bool SdlEventSource::handleJoystickAdded(const SDL_JoyDeviceEvent &device) { + debug(5, "SdlEventSource: Received joystick added event for index '%d'", device.which); + + int joystick_num = ConfMan.getInt("joystick_num"); + if (joystick_num == device.which) { + debug(5, "SdlEventSource: Newly added joystick with index '%d' matches 'joysticky_num', trying to use it", device.which); + + closeJoystick(); + openJoystick(joystick_num); + } + + return false; +} + +bool SdlEventSource::handleJoystickRemoved(const SDL_JoyDeviceEvent &device) { + debug(5, "SdlEventSource: Received joystick removed event for instance id '%d'", device.which); + + SDL_Joystick *joystick; + if (_controller) { + joystick = SDL_GameControllerGetJoystick(_controller); + } else { + joystick = _joystick; + } + + if (!joystick) { + return false; + } + + if (SDL_JoystickInstanceID(joystick) == device.which) { + debug(5, "SdlEventSource: Newly removed joystick with instance id '%d' matches currently used joystick, closing current joystick", device.which); + + closeJoystick(); + } + + return false; +} + +bool SdlEventSource::handleControllerButton(const SDL_Event &ev, Common::Event &event, bool buttonUp) { + using namespace Common; + + struct ControllerEventMapping { + EventType normalType; + KeyState normalKeystate; + EventType modifierType; + KeyState modifierKeystate; + }; + + static const ControllerEventMapping mapping[] = { + // SDL_CONTROLLER_BUTTON_A: Left mouse button + { EVENT_LBUTTONDOWN, KeyState(), EVENT_LBUTTONDOWN, KeyState() }, + // SDL_CONTROLLER_BUTTON_B: Right mouse button + { EVENT_RBUTTONDOWN, KeyState(), EVENT_RBUTTONDOWN, KeyState() }, + // SDL_CONTROLLER_BUTTON_X: Period (+R_trigger: Space) + { EVENT_KEYDOWN, KeyState(KEYCODE_PERIOD, '.'), EVENT_KEYDOWN, KeyState(KEYCODE_SPACE, ASCII_SPACE) }, + // SDL_CONTROLLER_BUTTON_Y: Escape (+R_trigger: Return) + { EVENT_KEYDOWN, KeyState(KEYCODE_ESCAPE, ASCII_ESCAPE), EVENT_KEYDOWN, KeyState(KEYCODE_RETURN, ASCII_RETURN) }, + // SDL_CONTROLLER_BUTTON_BACK: Virtual keyboard (+R_trigger: Predictive Input Dialog) +#ifdef ENABLE_VKEYBD + { EVENT_VIRTUAL_KEYBOARD, KeyState(), EVENT_PREDICTIVE_DIALOG, KeyState() }, #else - if (axis > JOY_DEADZONE) { - axis -= JOY_DEADZONE; - } else if (axis < -JOY_DEADZONE) { - axis += JOY_DEADZONE; - } else - axis = 0; + { EVENT_INVALID, KeyState(), EVENT_PREDICTIVE_DIALOG, KeyState() }, #endif + // SDL_CONTROLLER_BUTTON_GUIDE: Unmapped + { EVENT_INVALID, KeyState(), EVENT_INVALID, KeyState() }, + // SDL_CONTROLLER_BUTTON_START: ScummVM in game menu + { EVENT_MAINMENU, KeyState(), EVENT_MAINMENU, KeyState() }, + // SDL_CONTROLLER_BUTTON_LEFTSTICK: Unmapped + { EVENT_INVALID, KeyState(), EVENT_INVALID, KeyState() }, + // SDL_CONTROLLER_BUTTON_RIGHTSTICK: Unmapped + { EVENT_INVALID, KeyState(), EVENT_INVALID, KeyState() }, + // SDL_CONTROLLER_BUTTON_LEFTSHOULDER: Game menu + { EVENT_KEYDOWN, KeyState(KEYCODE_F5, ASCII_F5), EVENT_KEYDOWN, KeyState(KEYCODE_F5, ASCII_F5) }, + // SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: Modifier + Shift + { EVENT_KEYDOWN, KeyState(KEYCODE_INVALID, 0, KBD_SHIFT), EVENT_KEYDOWN, KeyState(KEYCODE_INVALID, 0, 0) }, + // SDL_CONTROLLER_BUTTON_DPAD_UP: Up (+R_trigger: Up+Right) + { EVENT_KEYDOWN, KeyState(KEYCODE_KP8, 0), EVENT_KEYDOWN, KeyState(KEYCODE_KP9, 0) }, + // SDL_CONTROLLER_BUTTON_DPAD_DOWN: Down (+R_trigger: Down+Left) + { EVENT_KEYDOWN, KeyState(KEYCODE_KP2, 0), EVENT_KEYDOWN, KeyState(KEYCODE_KP1, 0) }, + // SDL_CONTROLLER_BUTTON_DPAD_LEFT: Left (+R_trigger: Up+Left) + { EVENT_KEYDOWN, KeyState(KEYCODE_KP4, 0), EVENT_KEYDOWN, KeyState(KEYCODE_KP7, 0) }, + // SDL_CONTROLLER_BUTTON_DPAD_RIGHT: Right (+R_trigger: Down+Right) + { EVENT_KEYDOWN, KeyState(KEYCODE_KP6, 0), EVENT_KEYDOWN, KeyState(KEYCODE_KP3, 0) } + }; + + if (ev.cbutton.button > SDL_CONTROLLER_BUTTON_DPAD_RIGHT) { + warning("Unknown SDL controller button: '%d'", ev.cbutton.button); + return false; + } - if (ev.jaxis.axis == JOY_XAXIS) { -#ifdef JOY_ANALOG - _km.joy_x = axis; -#else - if (axis != 0) { - _km.x_vel = (axis > 0) ? 1 * MULTIPLIER:-1 * MULTIPLIER; - _km.x_down_count = 1; + if (!_km.modifier) { + event.type = mapping[ev.cbutton.button].normalType; + event.kbd = mapping[ev.cbutton.button].normalKeystate; + } else { + event.type = mapping[ev.cbutton.button].modifierType; + event.kbd = mapping[ev.cbutton.button].modifierKeystate; + } + + // Setting the mouse speed modifier after filling the event structure above + // ensures that the shift key events are correctly handled + if (ev.cbutton.button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) { + // Right shoulder is the modifier button that makes the mouse go slower + // and allows access to an extended layout while pressed. + _km.modifier = !buttonUp; + } + + if (event.type == EVENT_LBUTTONDOWN || event.type == EVENT_RBUTTONDOWN) { + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); + } + + if (buttonUp) { + // The event mapping table is for button down events. If we received a button up event, + // transform the event type to the corresponding up type. + if (event.type == EVENT_KEYDOWN) { + event.type = EVENT_KEYUP; + } else if (event.type == EVENT_LBUTTONDOWN) { + event.type = EVENT_LBUTTONUP; + } else if (event.type == EVENT_RBUTTONDOWN) { + event.type = EVENT_RBUTTONUP; } else { - _km.x_vel = 0; - _km.x_down_count = 0; + // Handled in key down + event.type = EVENT_INVALID; } + } + + return event.type != EVENT_INVALID; +} + +bool SdlEventSource::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 false; +} #endif - } else if (ev.jaxis.axis == JOY_YAXIS) { -#ifndef JOY_INVERT_Y - axis = -axis; -#endif -#ifdef JOY_ANALOG - _km.joy_y = -axis; -#else - if (axis != 0) { - _km.y_vel = (-axis > 0) ? 1 * MULTIPLIER: -1 * MULTIPLIER; - _km.y_down_count = 1; - } else { - _km.y_vel = 0; - _km.y_down_count = 0; - } + +bool SdlEventSource::handleAxisToMouseMotion(int16 xAxis, int16 yAxis) { +#ifdef JOY_INVERT_Y + yAxis = -yAxis; #endif - } -#ifdef JOY_ANALOG - // radial and scaled analog joystick deadzone - float analogX = (float)_km.joy_x; - float analogY = (float)_km.joy_y; - float deadZone = (float)JOY_DEADZONE; - if (g_system->hasFeature(OSystem::kFeatureJoystickDeadzone)) - deadZone = (float)ConfMan.getInt("joystick_deadzone") * 1000.0f; - float scalingFactor = 1.0f; - float magnitude = 0.0f; - - magnitude = sqrt(analogX * analogX + analogY * analogY); + + // 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; - scalingFactor = 1.0f / magnitude * (magnitude - deadZone) / (32769.0f - deadZone); + 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; } -#endif return false; } diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h index 5fd3cb7ea5..f5bbfeb15c 100644 --- a/backends/events/sdl/sdl-events.h +++ b/backends/events/sdl/sdl-events.h @@ -80,6 +80,11 @@ protected: /** Joystick */ SDL_Joystick *_joystick; +#if SDL_VERSION_ATLEAST(2, 0, 0) + /** Game controller */ + SDL_GameController *_controller; +#endif + /** Last screen id for checking if it was modified */ int _lastScreenID; @@ -89,6 +94,21 @@ protected: SdlGraphicsManager *_graphicsManager; /** + * Open the SDL joystick with the specified index + * + * After this function completes successfully, SDL sends events for the device. + * + * If the joystick is also a SDL game controller, open it as a controller + * so an extended button mapping can be used. + */ + void openJoystick(int joystickIndex); + + /** + * Close the currently open joystick if any + */ + void closeJoystick(); + + /** * Pre process an event before it is dispatched. */ virtual void preprocessEvents(SDL_Event *event) {} @@ -117,9 +137,21 @@ protected: virtual bool handleJoyAxisMotion(SDL_Event &ev, Common::Event &event); virtual bool handleKbdMouse(Common::Event &event); +#if SDL_VERSION_ATLEAST(2, 0, 0) + virtual bool handleJoystickAdded(const SDL_JoyDeviceEvent &event); + virtual bool handleJoystickRemoved(const SDL_JoyDeviceEvent &device); + virtual bool handleControllerButton(const SDL_Event &ev, Common::Event &event, bool buttonUp); + virtual bool handleControllerAxisMotion(const SDL_Event &ev, Common::Event &event); +#endif + //@} /** + * Update the virtual mouse according to a joystick or game controller axis position change + */ + virtual bool handleAxisToMouseMotion(int16 xAxis, int16 yAxis); + + /** * Assigns the mouse coords to the mouse event. Furthermore notify the * graphics manager about the position change. */ diff --git a/backends/events/symbiansdl/symbiansdl-events.cpp b/backends/events/symbiansdl/symbiansdl-events.cpp index 4649f9f90a..0ae5824681 100644 --- a/backends/events/symbiansdl/symbiansdl-events.cpp +++ b/backends/events/symbiansdl/symbiansdl-events.cpp @@ -31,6 +31,8 @@ #include <bautils.h> +#define JOY_DEADZONE 3200 + SymbianSdlEventSource::zoneDesc SymbianSdlEventSource::_zones[TOTAL_ZONES] = { { 0, 0, 320, 145 }, { 0, 145, 150, 55 }, @@ -200,4 +202,38 @@ bool SymbianSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { return false; } +bool SymbianSdlEventSource::handleAxisToMouseMotion(int16 xAxis, int16 yAxis) { + // Symbian wants dialog joystick i.e cursor for movement/selection + + if (xAxis > JOY_DEADZONE) { + xAxis -= JOY_DEADZONE; + } else if (xAxis < -JOY_DEADZONE) { + xAxis += JOY_DEADZONE; + } else + xAxis = 0; + if (yAxis > JOY_DEADZONE) { + yAxis -= JOY_DEADZONE; + } else if (yAxis < -JOY_DEADZONE) { + yAxis += JOY_DEADZONE; + } else + yAxis = 0; + + if (xAxis != 0) { + _km.x_vel = (xAxis > 0) ? 1 * MULTIPLIER:-1 * MULTIPLIER; + _km.x_down_count = 1; + } else { + _km.x_vel = 0; + _km.x_down_count = 0; + } + if (yAxis != 0) { + _km.y_vel = (yAxis > 0) ? 1 * MULTIPLIER: -1 * MULTIPLIER; + _km.y_down_count = 1; + } else { + _km.y_vel = 0; + _km.y_down_count = 0; + } + + return false; +} + #endif diff --git a/backends/events/symbiansdl/symbiansdl-events.h b/backends/events/symbiansdl/symbiansdl-events.h index 2664bc267d..0393e398f0 100644 --- a/backends/events/symbiansdl/symbiansdl-events.h +++ b/backends/events/symbiansdl/symbiansdl-events.h @@ -50,6 +50,8 @@ protected: static zoneDesc _zones[TOTAL_ZONES]; virtual bool remapKey(SDL_Event &ev, Common::Event &event); + + virtual bool handleAxisToMouseMotion(int16 xAxis, int16 yAxis); }; #endif diff --git a/backends/platform/psp/display_manager.cpp b/backends/platform/psp/display_manager.cpp index 2e995c809e..f8be51e4e9 100644 --- a/backends/platform/psp/display_manager.cpp +++ b/backends/platform/psp/display_manager.cpp @@ -55,7 +55,8 @@ uint32 __attribute__((aligned(16))) MasterGuRenderer::_displayList[2048]; const OSystem::GraphicsMode DisplayManager::_supportedModes[] = { { "Original Resolution", "Original Resolution", ORIGINAL_RESOLUTION }, { "Keep Aspect Ratio", "Keep Aspect Ratio", KEEP_ASPECT_RATIO }, - { "Full Screen", "Full Screen", STRETCHED_FULL_SCREEN }, + { "4:3 Aspect Ratio", "4:3 Aspect Ratio", ASPECT_RATIO_CORRECTION }, + { "Stretched Full Screen", "Stretched Full Screen", STRETCHED_FULL_SCREEN }, {0, 0, 0} }; @@ -358,23 +359,35 @@ void DisplayManager::calculateScaleParams() { switch (_graphicsMode) { case ORIGINAL_RESOLUTION: // check if we can fit the original resolution inside the screen - if ((_displayParams.screenSource.width < PSP_SCREEN_WIDTH) && - (_displayParams.screenSource.height < PSP_SCREEN_HEIGHT)) { + if ((_displayParams.screenSource.width <= PSP_SCREEN_WIDTH) && + (_displayParams.screenSource.height <= PSP_SCREEN_HEIGHT)) { _displayParams.screenOutput.width = _displayParams.screenSource.width; _displayParams.screenOutput.height = _displayParams.screenSource.height; - } else { // revert to stretch to fit - _displayParams.screenOutput.width = PSP_SCREEN_WIDTH; - _displayParams.screenOutput.height = PSP_SCREEN_HEIGHT; + break; } - break; + // else revert to keep aspect ratio case KEEP_ASPECT_RATIO: { // maximize the height while keeping aspect ratio float aspectRatio = (float)_displayParams.screenSource.width / (float)_displayParams.screenSource.height; _displayParams.screenOutput.height = PSP_SCREEN_HEIGHT; // always full height _displayParams.screenOutput.width = (uint32)(PSP_SCREEN_HEIGHT * aspectRatio); - if (_displayParams.screenOutput.width > PSP_SCREEN_WIDTH) // we can't have wider than the screen + if (_displayParams.screenOutput.width > PSP_SCREEN_WIDTH) { // shrink if wider than screen + _displayParams.screenOutput.height = (uint32) (((float) PSP_SCREEN_HEIGHT * (float) PSP_SCREEN_WIDTH) / (float) _displayParams.screenOutput.width); + _displayParams.screenOutput.width = PSP_SCREEN_WIDTH; + } + } + break; + case ASPECT_RATIO_CORRECTION: { // maximize the height while forcing 4:3 aspect ratio + float aspectRatio = 4.0f / 3.0f; + + _displayParams.screenOutput.height = PSP_SCREEN_HEIGHT; // always full height + _displayParams.screenOutput.width = (uint32)(PSP_SCREEN_HEIGHT * aspectRatio); + + if (_displayParams.screenOutput.width > PSP_SCREEN_WIDTH) { // // shrink if wider than screen + _displayParams.screenOutput.height = (uint32) (((float) PSP_SCREEN_HEIGHT * (float) PSP_SCREEN_WIDTH) / (float) _displayParams.screenOutput.width); _displayParams.screenOutput.width = PSP_SCREEN_WIDTH; + } } break; case STRETCHED_FULL_SCREEN: // we simply stretch to the whole screen diff --git a/backends/platform/psp/display_manager.h b/backends/platform/psp/display_manager.h index b1b748a68c..ba11963f8c 100644 --- a/backends/platform/psp/display_manager.h +++ b/backends/platform/psp/display_manager.h @@ -106,6 +106,7 @@ public: enum GraphicsModeID { ///> Possible output formats onscreen ORIGINAL_RESOLUTION, KEEP_ASPECT_RATIO, + ASPECT_RATIO_CORRECTION, STRETCHED_FULL_SCREEN }; DisplayManager() : _screen(0), _cursor(0), _overlay(0), _keyboard(0), @@ -118,7 +119,7 @@ public: bool setGraphicsMode(int mode); bool setGraphicsMode(const char *name); int getGraphicsMode() const { return _graphicsMode; } - uint32 getDefaultGraphicsMode() const { return STRETCHED_FULL_SCREEN; } + uint32 getDefaultGraphicsMode() const { return KEEP_ASPECT_RATIO; } const OSystem::GraphicsMode* getSupportedGraphicsModes() const { return _supportedModes; } // Setters for pointers diff --git a/backends/platform/sdl/psp2/psp2.cpp b/backends/platform/sdl/psp2/psp2.cpp index 94b06e6d23..12154ba7d0 100644 --- a/backends/platform/sdl/psp2/psp2.cpp +++ b/backends/platform/sdl/psp2/psp2.cpp @@ -94,12 +94,6 @@ void OSystem_PSP2::initBackend() { if (!ConfMan.hasKey("filtering")) { ConfMan.setBool("filtering", true); } - if (!ConfMan.hasKey("kbdmouse_speed")) { - ConfMan.setInt("kbdmouse_speed", 3); - } - if (!ConfMan.hasKey("joystick_deadzone")) { - ConfMan.setInt("joystick_deadzone", 2); - } if (!ConfMan.hasKey("shader")) { ConfMan.setInt("shader", 2); } @@ -108,6 +102,14 @@ void OSystem_PSP2::initBackend() { if (_savefileManager == 0) _savefileManager = new DefaultSaveFileManager("ux0:data/scummvm/saves"); + // Controller mappings for Vita, various names have been used in various SDL versions + SDL_GameControllerAddMapping("50535669746120436f6e74726f6c6c65,PSVita Controller,y:b0,b:b1,a:b2,x:b3,leftshoulder:b4,rightshoulder:b5,dpdown:b6,dpleft:b7,dpup:b8,dpright:b9,back:b10,start:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,"); + SDL_GameControllerAddMapping("50535669746120636f6e74726f6c6c65,PSVita controller,y:b0,b:b1,a:b2,x:b3,leftshoulder:b4,rightshoulder:b5,dpdown:b6,dpleft:b7,dpup:b8,dpright:b9,back:b10,start:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,"); + SDL_GameControllerAddMapping("50535669746120636f6e74726f6c6c65,PSVita controller 2,y:b0,b:b1,a:b2,x:b3,leftshoulder:b4,rightshoulder:b5,dpdown:b6,dpleft:b7,dpup:b8,dpright:b9,back:b10,start:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,"); + SDL_GameControllerAddMapping("50535669746120636f6e74726f6c6c65,PSVita controller 3,y:b0,b:b1,a:b2,x:b3,leftshoulder:b4,rightshoulder:b5,dpdown:b6,dpleft:b7,dpup:b8,dpright:b9,back:b10,start:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,"); + SDL_GameControllerAddMapping("50535669746120636f6e74726f6c6c65,PSVita controller 4,y:b0,b:b1,a:b2,x:b3,leftshoulder:b4,rightshoulder:b5,dpdown:b6,dpleft:b7,dpup:b8,dpright:b9,back:b10,start:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,"); + SDL_GameControllerAddMapping("505356697461206275696c74696e206a,PSVita builtin joypad,y:b0,b:b1,a:b2,x:b3,leftshoulder:b4,rightshoulder:b5,dpdown:b6,dpleft:b7,dpup:b8,dpright:b9,back:b10,start:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,"); + // Event source if (_eventSource == 0) _eventSource = new PSP2EventSource(); diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index f6ab180897..3082a69ebf 100644 --- a/backends/platform/sdl/sdl.cpp +++ b/backends/platform/sdl/sdl.cpp @@ -90,6 +90,8 @@ OSystem_SDL::OSystem_SDL() _eventSource(0), _window(0) { + ConfMan.registerDefault("kbdmouse_speed", 3); + ConfMan.registerDefault("joystick_deadzone", 3); } OSystem_SDL::~OSystem_SDL() { @@ -180,10 +182,10 @@ bool OSystem_SDL::hasFeature(Feature f) { #if SDL_VERSION_ATLEAST(2, 0, 0) if (f == kFeatureClipboardSupport) return true; #endif -#ifdef JOY_ANALOG - if (f == kFeatureJoystickDeadzone) return true; -#endif - if (f == kFeatureKbdMouseSpeed) return true; + if (f == kFeatureJoystickDeadzone || f == kFeatureKbdMouseSpeed) { + bool joystickSupportEnabled = ConfMan.getInt("joystick_num") >= 0; + return joystickSupportEnabled; + } return ModularBackend::hasFeature(f); } @@ -289,16 +291,6 @@ void OSystem_SDL::initBackend() { _inited = true; - if (!ConfMan.hasKey("kbdmouse_speed")) { - ConfMan.registerDefault("kbdmouse_speed", 3); - ConfMan.setInt("kbdmouse_speed", 3); - } -#ifdef JOY_ANALOG - if (!ConfMan.hasKey("joystick_deadzone")) { - ConfMan.registerDefault("joystick_deadzone", 3); - ConfMan.setInt("joystick_deadzone", 3); - } -#endif ModularBackend::initBackend(); // We have to initialize the graphics manager before the event manager diff --git a/backends/platform/symbian/README b/backends/platform/symbian/README index cdff5f9787..867a683f41 100644 --- a/backends/platform/symbian/README +++ b/backends/platform/symbian/README @@ -1,7 +1,7 @@ ScummVM - ScummVM ported to EPOC/SymbianOS - Copyright (C) 2008-2017 ScummVM Team + Copyright (C) 2008-2018 ScummVM Team Copyright (C) 2013-2013 Fedor Strizhniou aka zanac Copyright (C) 2003-2013 Lars 'AnotherGuest' Persson Copyright (C) 2002-2008 Jurgen 'SumthinWicked' Braam diff --git a/backends/platform/symbian/src/SymbianOS.cpp b/backends/platform/symbian/src/SymbianOS.cpp index 4d417b5a66..87e1c09a63 100644 --- a/backends/platform/symbian/src/SymbianOS.cpp +++ b/backends/platform/symbian/src/SymbianOS.cpp @@ -173,6 +173,13 @@ Common::String OSystem_SDL_Symbian::getDefaultConfigFileName() { return configFile; } +bool OSystem_SDL_Symbian::hasFeature(Feature f) { + if (f == kFeatureJoystickDeadzone) return false; + + return OSystem_SDL::hasFeature(f); +} + + RFs& OSystem_SDL_Symbian::FsSession() { return *_RFs; } diff --git a/backends/platform/symbian/src/SymbianOS.h b/backends/platform/symbian/src/SymbianOS.h index 617540941d..fea1ebc0b2 100644 --- a/backends/platform/symbian/src/SymbianOS.h +++ b/backends/platform/symbian/src/SymbianOS.h @@ -39,6 +39,7 @@ public: virtual void engineDone(); virtual bool setGraphicsMode(const char *name); virtual Common::String getDefaultConfigFileName(); + virtual bool hasFeature(Feature f); /** * Returns reference to File session |