Skip to content
Permalink
Browse files

Merge pull request #915 from rsn8887/vita

PSP2: Add Playstation Vita support
  • Loading branch information...
sev- committed Mar 4, 2017
2 parents 72962ae + 7098852 commit 547e5846a144b820981c45cf3f76c77075971197
Showing with 2,049 additions and 15 deletions.
  1. +5 −0 .gitignore
  2. +323 −0 backends/events/psp2sdl/psp2sdl-events.cpp
  3. +39 −0 backends/events/psp2sdl/psp2sdl-events.h
  4. +6 −1 backends/fs/posix/posix-fs.cpp
  5. +241 −0 backends/fs/psp2/psp2-dirent.cpp
  6. +59 −0 backends/fs/psp2/psp2-dirent.h
  7. +45 −0 backends/fs/psp2/psp2-fs-factory.cpp
  8. +41 −0 backends/fs/psp2/psp2-fs-factory.h
  9. +7 −0 backends/graphics/graphics.h
  10. +522 −0 backends/graphics/psp2sdl/psp2sdl-graphics.cpp
  11. +55 −0 backends/graphics/psp2sdl/psp2sdl-graphics.h
  12. +64 −5 backends/graphics/surfacesdl/surfacesdl-graphics.cpp
  13. +8 −1 backends/graphics/surfacesdl/surfacesdl-graphics.h
  14. +1 −1 backends/mixer/sdl/sdl-mixer.cpp
  15. +12 −0 backends/modular-backend.cpp
  16. +3 −0 backends/modular-backend.h
  17. +9 −0 backends/module.mk
  18. +7 −0 backends/platform/sdl/module.mk
  19. +1 −1 backends/platform/sdl/posix/posix-main.cpp
  20. +66 −0 backends/platform/sdl/psp2/psp2-main.cpp
  21. +143 −0 backends/platform/sdl/psp2/psp2.cpp
  22. +52 −0 backends/platform/sdl/psp2/psp2.h
  23. +26 −0 backends/platform/sdl/psp2/psp2.mk
  24. +34 −1 common/system.h
  25. +76 −5 configure
  26. BIN dists/psp2/bg.png
  27. BIN dists/psp2/icon0.png
  28. +64 −0 dists/psp2/readme-psp2.md
  29. BIN dists/psp2/startup.png
  30. +11 −0 dists/psp2/template.xml
  31. +49 −0 gui/options.cpp
  32. +8 −0 gui/options.h
  33. +20 −0 gui/themes/default.inc
  34. BIN gui/themes/scummclassic.zip
  35. +13 −0 gui/themes/scummclassic/classic_layout.stx
  36. +13 −0 gui/themes/scummclassic/classic_layout_lowres.stx
  37. BIN gui/themes/scummmodern.zip
  38. +13 −0 gui/themes/scummmodern/scummmodern_layout.stx
  39. +13 −0 gui/themes/scummmodern/scummmodern_layout_lowres.stx
@@ -208,5 +208,10 @@ dists/msvc*/**
out/
scummvm.xcodeproj

#Ignore PSP2 files
psp2pkg/
*.velf
*.vpk

#Ignore gmon.out created by gprof
gmon.out
@@ -0,0 +1,323 @@
/* 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(PSP2)

#include <psp2/kernel/processmgr.h>
#include "backends/platform/sdl/psp2/psp2.h"
#include "backends/events/psp2sdl/psp2sdl-events.h"
#include "backends/platform/sdl/sdl.h"
#include "engines/engine.h"

#include "common/util.h"
#include "common/events.h"
#include "common/config-manager.h"

#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..)
sceKernelPowerTick(SCE_KERNEL_POWER_TICK_DISABLE_AUTO_SUSPEND);
sceKernelPowerTick(SCE_KERNEL_POWER_TICK_DISABLE_OLED_OFF);
}

#endif
@@ -0,0 +1,39 @@
/* 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.
*
*/

#if !defined(DISABLE_DEFAULT_EVENTMANAGER)
#define BACKEND_EVENTS_PSP2_H

#include "backends/events/sdl/sdl-events.h"

/**
* SDL Events manager for the PSP2.
*/
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);
};

#endif /* BACKEND_EVENTS_PSP2_H */
@@ -20,7 +20,7 @@
*
*/

#if defined(POSIX) || defined(PLAYSTATION3)
#if defined(POSIX) || defined(PLAYSTATION3) || defined(PSP2)

// Re-enable some forbidden symbols to avoid clashes with stat.h and unistd.h.
// Also with clock() in sys/time.h in some Mac OS X SDKs.
@@ -36,7 +36,12 @@

#include <sys/param.h>
#include <sys/stat.h>
#ifdef PSP2
#include "backends/fs/psp2/psp2-dirent.h"
#define mkdir sceIoMkdir
#else
#include <dirent.h>
#endif
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>

0 comments on commit 547e584

Please sign in to comment.
You can’t perform that action at this time.