aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrsn88872017-12-20 12:59:00 -0600
committerBastien Bouclet2017-12-26 21:11:05 +0100
commitdafadbc8c77fe89d0504ddfdef159e1c37491f81 (patch)
tree86980ecdfc36174b5594a990cb960d54b455058b
parent1522fc8e2f109229d9947158a1cd2ccc8c4642e1 (diff)
downloadscummvm-rg350-dafadbc8c77fe89d0504ddfdef159e1c37491f81.tar.gz
scummvm-rg350-dafadbc8c77fe89d0504ddfdef159e1c37491f81.tar.bz2
scummvm-rg350-dafadbc8c77fe89d0504ddfdef159e1c37491f81.zip
PSP2: Add controller config, remove joystick event handling
-rw-r--r--backends/events/psp2sdl/psp2sdl-events.cpp236
-rw-r--r--backends/events/psp2sdl/psp2sdl-events.h2
-rw-r--r--backends/platform/sdl/psp2/psp2.cpp8
3 files changed, 8 insertions, 238 deletions
diff --git a/backends/events/psp2sdl/psp2sdl-events.cpp b/backends/events/psp2sdl/psp2sdl-events.cpp
index ac3115a642..4ea528b00f 100644
--- a/backends/events/psp2sdl/psp2sdl-events.cpp
+++ b/backends/events/psp2sdl/psp2sdl-events.cpp
@@ -36,242 +36,6 @@
#include "math.h"
-#define JOY_DEADZONE 2000
-#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;
-}
-
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 e01a3b9ebc..5593e8a504 100644
--- a/backends/events/psp2sdl/psp2sdl-events.h
+++ b/backends/events/psp2sdl/psp2sdl-events.h
@@ -30,8 +30,6 @@
*/
class PSP2EventSource : public SdlEventSource {
protected:
- bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event);
- bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event);
void preprocessEvents(SDL_Event *event);
};
diff --git a/backends/platform/sdl/psp2/psp2.cpp b/backends/platform/sdl/psp2/psp2.cpp
index f323db72af..12154ba7d0 100644
--- a/backends/platform/sdl/psp2/psp2.cpp
+++ b/backends/platform/sdl/psp2/psp2.cpp
@@ -102,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();