PSP: rewrote input code and added an input mode
The old input code was getting too messy. A redesign made it easier to modify and add several modes and combos, including one for 1st person games which benefit from a different control scheme. A combo switches between the modes. I also added directional support while the virtual keyboard is visible, using the nub. This allows moving around in the text in some games, and moving the character while typing for others (e.g. AGI) svn-id: r53042
This commit is contained in:
parent
b15f51ad7b
commit
e47e474cff
8 changed files with 694 additions and 332 deletions
|
@ -3,79 +3,95 @@ ScummVM-PSP 1.3.0svn README
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
- Copy the relevant game datafiles to your memory stick (location
|
- Copy the relevant game datafiles to your memory stick (location doesn't matter).
|
||||||
doesn't matter).
|
- Install ScummVM like any other homebrew.
|
||||||
- Install ScummVM like any other homebrew
|
- Run ScummVM and use the launcher to add games and run them.
|
||||||
- Run ScummVM and use the launcher to add games and run them
|
|
||||||
|
|
||||||
|
|
||||||
Controls
|
Controls
|
||||||
========
|
========
|
||||||
|
|
||||||
Left trigger - ESC
|
|
||||||
Right trigger - Modifier key (see below for uses)
|
Right trigger - Modifier key (see below for uses)
|
||||||
|
Left trigger - ESC (Usually skips cutscenes. Depends on game)
|
||||||
Analog - Mouse movement
|
Analog - Mouse movement
|
||||||
Right trigger + Analog - Fine control mouse
|
Right trigger + Analog - Fine mouse movement
|
||||||
Directions - Arrow keys
|
D-Pad - Arrow keys (useful mostly in SCI and AGI games)
|
||||||
Directions + Right Trigger - Diagonal arrow keys
|
D-Pad + Right Trigger - Diagonal arrow keys (it's hard to input diagonals on some PSPs)
|
||||||
Triangle - Enter
|
Triangle - Enter (useful for some dialogs)
|
||||||
Cross - Mouse button 1
|
Cross - Left Mouse Button (usually the main button)
|
||||||
Circle - Mouse button 2
|
Circle - Right Mouse Button (secondary button in some games)
|
||||||
Square - '.' (skip dialogue in some games)
|
Square - '.' (skip dialogue in some games e.g. Scumm)
|
||||||
Start - F5 (Main Menu)
|
Right trigger + Square - Spacebar (useful in Gobli*ns and SCI games)
|
||||||
Right trigger + Start - Return-To-Launcher menu
|
Start - Global Menu. Allows you to 'Return To Launcher' to play another game
|
||||||
|
Right trigger + Start - F5 (Main Menu in some games)
|
||||||
|
Select - Show/Hide Virtual Keyboard. Hold down to move keyboard onscreen (with D-Pad).
|
||||||
|
|
||||||
Virtual Keyboard
|
Virtual Keyboard Mode
|
||||||
================
|
=====================
|
||||||
|
Start - Enter key. Also exits virtual keyboard mode
|
||||||
|
Select - Exit the virtual keyboard mode
|
||||||
|
Right trigger - Input letters: lowercase/uppercase (press to toggle)
|
||||||
|
Left trigger - Input numbers/symbols (press to toggle)
|
||||||
|
D-Pad - Select square of characters (up, down, left or right)
|
||||||
|
Buttons/Triggers - Choose a specific character in the square. The four center characters are chosen
|
||||||
|
by the button in the corresponding position. The 2 top characters are chosen by the
|
||||||
|
triggers.
|
||||||
|
Analog - Moves in a direction (left/right/up/down) (Useful to keep moving
|
||||||
|
while typing in AGI games among other things)
|
||||||
|
|
||||||
Select - Show/Hide Virtual Keyboard. Hold down to move keyboard onscreen.
|
1st Person Game Mode (Can be ignored by most users)
|
||||||
Start - Enter
|
====================
|
||||||
Right trigger - Switch to/between letter modes
|
This is a special mode built for 1st person games like Lands of Lore. If you don't have these games you can
|
||||||
Left trigger - Switch to/between numbers and symbols
|
safely ignore this mode. To enter or leave this mode, use the combo:
|
||||||
D-Pad - Select square of characters
|
|
||||||
Buttons/Triggers - Choose a specific character
|
|
||||||
|
|
||||||
|
Right Trigger + Left Trigger + Square
|
||||||
|
|
||||||
|
Some buttons have been switched around to make these games more playable:
|
||||||
|
Square - Is the modifier key instead of Right Trigger.
|
||||||
|
Left/Right Trigger - Strafe left/right
|
||||||
|
D-Pad Left/Right - Turn left/right
|
||||||
|
Square + D-Pad - F1/F2/F3/F4
|
||||||
|
Square + Start - Esc (shows game menu)
|
||||||
|
|
||||||
|
|
||||||
Notes
|
Notes
|
||||||
=====
|
=====
|
||||||
|
- Notice that you can switch between games! This is much faster than quitting
|
||||||
|
and having to start ScummVM all over again. Go to the global menu and choose 'Return To Launcher'.
|
||||||
|
(Some games may not have the Return To Launcher option available yet.)
|
||||||
|
|
||||||
- Plugin files are NOT interchangeable between versions! You must copy ALL the
|
- The PSP version of ScummVM uses the Media Engine to accelerate decoding of MP3 files. This means
|
||||||
plugin files that come with every version of scummvm. They sit in the /plugin
|
that if you have the choice of compressing using Ogg files or MP3 files, choose MP3 -- the game
|
||||||
|
will generally run faster.
|
||||||
|
|
||||||
|
- Plugin files are NOT interchangeable between ScummVM versions! You must copy ALL the
|
||||||
|
plugin files that come with every version of ScummVM. They sit in the /plugin
|
||||||
subdirectory. If you get a crash upon startup, try deleting all the existing
|
subdirectory. If you get a crash upon startup, try deleting all the existing
|
||||||
plugin files in the plugin directory and copying the new ones over again.
|
plugin files in the plugin directory and copying the new ones over again.
|
||||||
|
|
||||||
- While it's possible to compress certain game resources to reduce their size,
|
|
||||||
this can (and usually will) cause games (especially animation) to be choppy
|
|
||||||
sometimes, as it ofcourse needs extra CPU power to decode these files.
|
|
||||||
As such, it is recommended to play games in their original, uncompressed,
|
|
||||||
form whenever possible.
|
|
||||||
|
|
||||||
- This README may be outdated, for more up-to-date instructions and notes see
|
- This README may be outdated, for more up-to-date instructions and notes see
|
||||||
the PSP Port Wiki: http://wiki.scummvm.org/index.php/PlayStation_Portable
|
the PSP Port Wiki: http://wiki.scummvm.org/index.php/PlayStation_Portable
|
||||||
|
|
||||||
Frequently Asked Questions
|
Frequently Asked Questions
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
Q: Pressing select doesn't make the virtual keyboard show up on screen!
|
|
||||||
A: You need to make sure that the kbd.zip file is in the same directory as the scummvm executable.
|
|
||||||
|
|
||||||
Q: Scummvm crashes upon starting up!
|
Q: Scummvm crashes upon starting up!
|
||||||
A: See the first note above.
|
A: See the first note above.
|
||||||
|
|
||||||
|
Q: Pressing select doesn't make the virtual keyboard show up on screen!
|
||||||
|
A: You need to make sure that the kbd.zip file is in the same directory as the ScummVM executable.
|
||||||
|
|
||||||
Q: What do I need to run the games?
|
Q: What do I need to run the games?
|
||||||
A: A 1.00 or 1.50 firmware PSP (or an EBOOT loader on firmware 2.00 or
|
A: A PSP that can run homebrew and the necessary datafiles for the game you want to play.
|
||||||
higher), and the necessary datafiles for the game you want to play and
|
|
||||||
obviously this ScummVM port.
|
|
||||||
|
|
||||||
Q: Can I run game X with this?
|
Q: Can I run game X with this?
|
||||||
A: You can find the list of supported games on the compatibility page
|
A: You can find the list of supported games on the compatibility page
|
||||||
on http://www.scummvm.org.
|
at http://www.scummvm.org
|
||||||
Note that ScummVM is NOT a 'DOS (game) emulator', but written
|
Note that ScummVM is NOT an emulator. The supported games engines have been painstakingly rewritten.
|
||||||
specifically for certain games/engines.
|
It's not easy to add support for a game you want that currently isn't supported.
|
||||||
|
|
||||||
Q: My Monkey Island 1 doesn't have any music, what gives?
|
Q: My Monkey Island 1 doesn't have any music, what gives?
|
||||||
A: If your version of Monkey Island came on a CD then it has the music
|
A: If your version of Monkey Island came on a CD then it has the music
|
||||||
as CD Audio tracks. You need to rip those to MP3/Ogg and copy them
|
as CD Audio tracks. You need to rip those to MP3/Ogg (MP3 is preferred), naming them track1.mp3 track2.mp3
|
||||||
to the same directory as the game datafiles for music to work.
|
etc. and copy them to the same directory as the game datafiles for music to work.
|
||||||
|
|
||||||
Q: Game X crashes, or feature Y doesn't work. Can you fix this?
|
Q: Game X crashes, or feature Y doesn't work. Can you fix this?
|
||||||
A: Possibly.
|
A: Possibly.
|
||||||
|
@ -83,21 +99,23 @@ A: Possibly.
|
||||||
played them all start-to-finish on the PSP, so it's possible there
|
played them all start-to-finish on the PSP, so it's possible there
|
||||||
are bugs or issues that we're not aware of.
|
are bugs or issues that we're not aware of.
|
||||||
When you encounter such a bug, please use the "Bug Tracker" you find linked
|
When you encounter such a bug, please use the "Bug Tracker" you find linked
|
||||||
on the ScummVM website, and mention all relevant info (i.e. that you're
|
on the ScummVM website, and mention all relevant info i.e. that you're
|
||||||
using the PSP version, which ScummVM version it is, if the problem exists
|
using the PSP version, which ScummVM version it is, if the problem exists
|
||||||
in a recent PC SVN version, a detailed description of the problem,
|
in a recent PC version, a detailed description of the problem,
|
||||||
and if at all possible a nearby savegame), this will make it much easier
|
and if at all possible a nearby savegame. This will make it much easier
|
||||||
for us to reproduce (and hopefully fix) the problem.
|
for us to reproduce (and hopefully fix) the problem.
|
||||||
|
|
||||||
Building the source code
|
Building the source code
|
||||||
========================
|
========================
|
||||||
To build ScummVM for PSP you need:
|
To build ScummVM for PSP you need:
|
||||||
|
|
||||||
|
- ScummVM source code (svn co https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk)
|
||||||
|
|
||||||
- PSP toolchain (svn co svn://svn.pspdev.org/psp/trunk/psptoolchain)
|
- PSP toolchain (svn co svn://svn.pspdev.org/psp/trunk/psptoolchain)
|
||||||
|
|
||||||
- PSPSDK (svn co svn://svn.pspdev.org/psp/trunk/pspsdk)
|
- PSPSDK (svn co svn://svn.pspdev.org/psp/trunk/pspsdk)
|
||||||
Note: This usually gets installed by the PSP toolchain,
|
Note: This usually gets installed by the PSP toolchain,
|
||||||
so you don't have to do it manually.
|
so you don't have to do it manually.
|
||||||
|
|
||||||
- zlib (svn co svn://svn.pspdev.org/psp/trunk/zlib)
|
- zlib (svn co svn://svn.pspdev.org/psp/trunk/zlib)
|
||||||
|
|
||||||
|
@ -107,21 +125,15 @@ To build ScummVM for PSP you need:
|
||||||
|
|
||||||
- libTremor(*) (svn co svn://svn.pspdev.org/psp/trunk/libTremor)
|
- libTremor(*) (svn co svn://svn.pspdev.org/psp/trunk/libTremor)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(*) = optional
|
(*) = optional
|
||||||
|
|
||||||
When you've installed these libraries (read their README.PSP for instructions),
|
Once you've installed these libraries (read their README.PSP for instructions),
|
||||||
type "make" in the backends/platform/psp directory to build a 1.00 firmware
|
create a subdirectory in your ScummVM folder called 'builds/psp'. Then, in this folder, type
|
||||||
EBOOT.PBP, or "make kxploit" to build the 1.50/kxploit EBOOT.PBPs
|
'../../configure --host=psp --enable-plugins --default-dynamic'. If everything is installed
|
||||||
|
correctly, ScummVM will inform you as it finds the right components. Finally type 'make' to build.
|
||||||
You can control most of the build process (engines and libraries used) from
|
|
||||||
the Makefile.
|
|
||||||
|
|
||||||
|
|
||||||
Port Authors
|
Port Authors
|
||||||
============
|
============
|
||||||
|
|
||||||
Joost Peters (joostp@scummvm.org)
|
Joost Peters (joostp@scummvm.org)
|
||||||
Paolo Costabel (paoloc@pacbell.net)
|
Paolo Costabel (paoloc@pacbell.net)
|
||||||
Thomas Mayer (tommybear@internode.on.net)
|
Thomas Mayer (tommybear@internode.on.net)
|
||||||
|
|
|
@ -3,79 +3,95 @@ ScummVM-PSP @VERSION@ README
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
============
|
============
|
||||||
- Copy the relevant game datafiles to your memory stick (location
|
- Copy the relevant game datafiles to your memory stick (location doesn't matter).
|
||||||
doesn't matter).
|
- Install ScummVM like any other homebrew.
|
||||||
- Install ScummVM like any other homebrew
|
- Run ScummVM and use the launcher to add games and run them.
|
||||||
- Run ScummVM and use the launcher to add games and run them
|
|
||||||
|
|
||||||
|
|
||||||
Controls
|
Controls
|
||||||
========
|
========
|
||||||
|
|
||||||
Left trigger - ESC
|
|
||||||
Right trigger - Modifier key (see below for uses)
|
Right trigger - Modifier key (see below for uses)
|
||||||
|
Left trigger - ESC (Usually skips cutscenes. Depends on game)
|
||||||
Analog - Mouse movement
|
Analog - Mouse movement
|
||||||
Right trigger + Analog - Fine control mouse
|
Right trigger + Analog - Fine mouse movement
|
||||||
Directions - Arrow keys
|
D-Pad - Arrow keys (useful mostly in SCI and AGI games)
|
||||||
Directions + Right Trigger - Diagonal arrow keys
|
D-Pad + Right Trigger - Diagonal arrow keys (it's hard to input diagonals on some PSPs)
|
||||||
Triangle - Enter
|
Triangle - Enter (useful for some dialogs)
|
||||||
Cross - Mouse button 1
|
Cross - Left Mouse Button (usually the main button)
|
||||||
Circle - Mouse button 2
|
Circle - Right Mouse Button (secondary button in some games)
|
||||||
Square - '.' (skip dialogue in some games)
|
Square - '.' (skip dialogue in some games e.g. Scumm)
|
||||||
Start - F5 (Main Menu)
|
Right trigger + Square - Spacebar (useful in Gobli*ns and SCI games)
|
||||||
Right trigger + Start - Return-To-Launcher menu
|
Start - Global Menu. Allows you to 'Return To Launcher' to play another game
|
||||||
|
Right trigger + Start - F5 (Main Menu in some games)
|
||||||
|
Select - Show/Hide Virtual Keyboard. Hold down to move keyboard onscreen (with D-Pad).
|
||||||
|
|
||||||
Virtual Keyboard
|
Virtual Keyboard Mode
|
||||||
================
|
=====================
|
||||||
|
Start - Enter key. Also exits virtual keyboard mode
|
||||||
|
Select - Exit the virtual keyboard mode
|
||||||
|
Right trigger - Input letters: lowercase/uppercase (press to toggle)
|
||||||
|
Left trigger - Input numbers/symbols (press to toggle)
|
||||||
|
D-Pad - Select square of characters (up, down, left or right)
|
||||||
|
Buttons/Triggers - Choose a specific character in the square. The four center characters are chosen
|
||||||
|
by the button in the corresponding position. The 2 top characters are chosen by the
|
||||||
|
triggers.
|
||||||
|
Analog - Moves in a direction (left/right/up/down) (Useful to keep moving
|
||||||
|
while typing in AGI games among other things)
|
||||||
|
|
||||||
Select - Show/Hide Virtual Keyboard. Hold down to move keyboard onscreen.
|
1st Person Game Mode (Can be ignored by most users)
|
||||||
Start - Enter
|
====================
|
||||||
Right trigger - Switch to/between letter modes
|
This is a special mode built for 1st person games like Lands of Lore. If you don't have these games you can
|
||||||
Left trigger - Switch to/between numbers and symbols
|
safely ignore this mode. To enter or leave this mode, use the combo:
|
||||||
D-Pad - Select square of characters
|
|
||||||
Buttons/Triggers - Choose a specific character
|
|
||||||
|
|
||||||
|
Right Trigger + Left Trigger + Square
|
||||||
|
|
||||||
|
Some buttons have been switched around to make these games more playable:
|
||||||
|
Square - Is the modifier key instead of Right Trigger.
|
||||||
|
Left/Right Trigger - Strafe left/right
|
||||||
|
D-Pad Left/Right - Turn left/right
|
||||||
|
Square + D-Pad - F1/F2/F3/F4
|
||||||
|
Square + Start - Esc (shows game menu)
|
||||||
|
|
||||||
|
|
||||||
Notes
|
Notes
|
||||||
=====
|
=====
|
||||||
|
- Notice that you can switch between games! This is much faster than quitting
|
||||||
|
and having to start ScummVM all over again. Go to the global menu and choose 'Return To Launcher'.
|
||||||
|
(Some games may not have the Return To Launcher option available yet.)
|
||||||
|
|
||||||
- Plugin files are NOT interchangeable between versions! You must copy ALL the
|
- The PSP version of ScummVM uses the Media Engine to accelerate decoding of MP3 files. This means
|
||||||
plugin files that come with every version of scummvm. They sit in the /plugin
|
that if you have the choice of compressing using Ogg files or MP3 files, choose MP3 -- the game
|
||||||
|
will generally run faster.
|
||||||
|
|
||||||
|
- Plugin files are NOT interchangeable between ScummVM versions! You must copy ALL the
|
||||||
|
plugin files that come with every version of ScummVM. They sit in the /plugin
|
||||||
subdirectory. If you get a crash upon startup, try deleting all the existing
|
subdirectory. If you get a crash upon startup, try deleting all the existing
|
||||||
plugin files in the plugin directory and copying the new ones over again.
|
plugin files in the plugin directory and copying the new ones over again.
|
||||||
|
|
||||||
- While it's possible to compress certain game resources to reduce their size,
|
|
||||||
this can (and usually will) cause games (especially animation) to be choppy
|
|
||||||
sometimes, as it ofcourse needs extra CPU power to decode these files.
|
|
||||||
As such, it is recommended to play games in their original, uncompressed,
|
|
||||||
form whenever possible.
|
|
||||||
|
|
||||||
- This README may be outdated, for more up-to-date instructions and notes see
|
- This README may be outdated, for more up-to-date instructions and notes see
|
||||||
the PSP Port Wiki: http://wiki.scummvm.org/index.php/PlayStation_Portable
|
the PSP Port Wiki: http://wiki.scummvm.org/index.php/PlayStation_Portable
|
||||||
|
|
||||||
Frequently Asked Questions
|
Frequently Asked Questions
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
Q: Pressing select doesn't make the virtual keyboard show up on screen!
|
|
||||||
A: You need to make sure that the kbd.zip file is in the same directory as the scummvm executable.
|
|
||||||
|
|
||||||
Q: Scummvm crashes upon starting up!
|
Q: Scummvm crashes upon starting up!
|
||||||
A: See the first note above.
|
A: See the first note above.
|
||||||
|
|
||||||
|
Q: Pressing select doesn't make the virtual keyboard show up on screen!
|
||||||
|
A: You need to make sure that the kbd.zip file is in the same directory as the ScummVM executable.
|
||||||
|
|
||||||
Q: What do I need to run the games?
|
Q: What do I need to run the games?
|
||||||
A: A 1.00 or 1.50 firmware PSP (or an EBOOT loader on firmware 2.00 or
|
A: A PSP that can run homebrew and the necessary datafiles for the game you want to play.
|
||||||
higher), and the necessary datafiles for the game you want to play and
|
|
||||||
obviously this ScummVM port.
|
|
||||||
|
|
||||||
Q: Can I run game X with this?
|
Q: Can I run game X with this?
|
||||||
A: You can find the list of supported games on the compatibility page
|
A: You can find the list of supported games on the compatibility page
|
||||||
on http://www.scummvm.org.
|
at http://www.scummvm.org
|
||||||
Note that ScummVM is NOT a 'DOS (game) emulator', but written
|
Note that ScummVM is NOT an emulator. The supported games engines have been painstakingly rewritten.
|
||||||
specifically for certain games/engines.
|
It's not easy to add support for a game you want that currently isn't supported.
|
||||||
|
|
||||||
Q: My Monkey Island 1 doesn't have any music, what gives?
|
Q: My Monkey Island 1 doesn't have any music, what gives?
|
||||||
A: If your version of Monkey Island came on a CD then it has the music
|
A: If your version of Monkey Island came on a CD then it has the music
|
||||||
as CD Audio tracks. You need to rip those to MP3/Ogg and copy them
|
as CD Audio tracks. You need to rip those to MP3/Ogg (MP3 is preferred), naming them track1.mp3 track2.mp3
|
||||||
to the same directory as the game datafiles for music to work.
|
etc. and copy them to the same directory as the game datafiles for music to work.
|
||||||
|
|
||||||
Q: Game X crashes, or feature Y doesn't work. Can you fix this?
|
Q: Game X crashes, or feature Y doesn't work. Can you fix this?
|
||||||
A: Possibly.
|
A: Possibly.
|
||||||
|
@ -83,21 +99,23 @@ A: Possibly.
|
||||||
played them all start-to-finish on the PSP, so it's possible there
|
played them all start-to-finish on the PSP, so it's possible there
|
||||||
are bugs or issues that we're not aware of.
|
are bugs or issues that we're not aware of.
|
||||||
When you encounter such a bug, please use the "Bug Tracker" you find linked
|
When you encounter such a bug, please use the "Bug Tracker" you find linked
|
||||||
on the ScummVM website, and mention all relevant info (i.e. that you're
|
on the ScummVM website, and mention all relevant info i.e. that you're
|
||||||
using the PSP version, which ScummVM version it is, if the problem exists
|
using the PSP version, which ScummVM version it is, if the problem exists
|
||||||
in a recent PC SVN version, a detailed description of the problem,
|
in a recent PC version, a detailed description of the problem,
|
||||||
and if at all possible a nearby savegame), this will make it much easier
|
and if at all possible a nearby savegame. This will make it much easier
|
||||||
for us to reproduce (and hopefully fix) the problem.
|
for us to reproduce (and hopefully fix) the problem.
|
||||||
|
|
||||||
Building the source code
|
Building the source code
|
||||||
========================
|
========================
|
||||||
To build ScummVM for PSP you need:
|
To build ScummVM for PSP you need:
|
||||||
|
|
||||||
|
- ScummVM source code (svn co https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk)
|
||||||
|
|
||||||
- PSP toolchain (svn co svn://svn.pspdev.org/psp/trunk/psptoolchain)
|
- PSP toolchain (svn co svn://svn.pspdev.org/psp/trunk/psptoolchain)
|
||||||
|
|
||||||
- PSPSDK (svn co svn://svn.pspdev.org/psp/trunk/pspsdk)
|
- PSPSDK (svn co svn://svn.pspdev.org/psp/trunk/pspsdk)
|
||||||
Note: This usually gets installed by the PSP toolchain,
|
Note: This usually gets installed by the PSP toolchain,
|
||||||
so you don't have to do it manually.
|
so you don't have to do it manually.
|
||||||
|
|
||||||
- zlib (svn co svn://svn.pspdev.org/psp/trunk/zlib)
|
- zlib (svn co svn://svn.pspdev.org/psp/trunk/zlib)
|
||||||
|
|
||||||
|
@ -107,21 +125,15 @@ To build ScummVM for PSP you need:
|
||||||
|
|
||||||
- libTremor(*) (svn co svn://svn.pspdev.org/psp/trunk/libTremor)
|
- libTremor(*) (svn co svn://svn.pspdev.org/psp/trunk/libTremor)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(*) = optional
|
(*) = optional
|
||||||
|
|
||||||
When you've installed these libraries (read their README.PSP for instructions),
|
Once you've installed these libraries (read their README.PSP for instructions),
|
||||||
type "make" in the backends/platform/psp directory to build a 1.00 firmware
|
create a subdirectory in your ScummVM folder called 'builds/psp'. Then, in this folder, type
|
||||||
EBOOT.PBP, or "make kxploit" to build the 1.50/kxploit EBOOT.PBPs
|
'../../configure --host=psp --enable-plugins --default-dynamic'. If everything is installed
|
||||||
|
correctly, ScummVM will inform you as it finds the right components. Finally type 'make' to build.
|
||||||
You can control most of the build process (engines and libraries used) from
|
|
||||||
the Makefile.
|
|
||||||
|
|
||||||
|
|
||||||
Port Authors
|
Port Authors
|
||||||
============
|
============
|
||||||
|
|
||||||
Joost Peters (joostp@scummvm.org)
|
Joost Peters (joostp@scummvm.org)
|
||||||
Paolo Costabel (paoloc@pacbell.net)
|
Paolo Costabel (paoloc@pacbell.net)
|
||||||
Thomas Mayer (tommybear@internode.on.net)
|
Thomas Mayer (tommybear@internode.on.net)
|
||||||
|
|
|
@ -26,6 +26,8 @@
|
||||||
#ifndef MOUSE_H
|
#ifndef MOUSE_H
|
||||||
#define MOUSE_H
|
#define MOUSE_H
|
||||||
|
|
||||||
|
#include "backends/platform/psp/default_display_client.h"
|
||||||
|
|
||||||
class Cursor : public DefaultDisplayClient {
|
class Cursor : public DefaultDisplayClient {
|
||||||
private:
|
private:
|
||||||
int _hotspotX, _hotspotY;
|
int _hotspotX, _hotspotY;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include "graphics/surface.h"
|
#include "graphics/surface.h"
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
#include "backends/platform/psp/memory.h"
|
#include "backends/platform/psp/memory.h"
|
||||||
|
#include "backends/platform/psp/psppixelformat.h"
|
||||||
|
|
||||||
#define MAX_TEXTURE_SIZE 512
|
#define MAX_TEXTURE_SIZE 512
|
||||||
|
|
||||||
|
|
|
@ -23,238 +23,272 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Todo: handle events that should fire because of shift going off
|
#include <pspctrl.h>
|
||||||
// Solution: handle shift on a button-by-button basis, only allowing it when the button is up. Also a inputmap-wide button. At buttonup, shiftstate is inspected per button.
|
#include "gui/message.h"
|
||||||
|
#include "backends/platform/psp/input.h"
|
||||||
|
|
||||||
//#define __PSP_DEBUG_FUNCS__ /* Uncomment for debugging the stack */
|
//#define __PSP_DEBUG_FUNCS__ /* Uncomment for debugging the stack */
|
||||||
//#define __PSP_DEBUG_PRINT__ /* Uncomment for debug prints */
|
//#define __PSP_DEBUG_PRINT__ /* Uncomment for debug prints */
|
||||||
|
|
||||||
#include "backends/platform/psp/trace.h"
|
#include "backends/platform/psp/trace.h"
|
||||||
|
|
||||||
#include "backends/platform/psp/psppixelformat.h"
|
|
||||||
#include "backends/platform/psp/input.h"
|
|
||||||
|
|
||||||
// Defines for working with PSP buttons
|
// Defines for working with PSP buttons
|
||||||
#define CHANGED(x) (_buttonsChanged & (x))
|
#define DOWN(x) ((pad.Buttons & (x)) == (x))
|
||||||
#define PRESSED(x) ((_buttonsChanged & (x)) && (pad.Buttons & (x)))
|
|
||||||
#define UNPRESSED(x) ((_buttonsChanged & (x)) && !(pad.Buttons & (x)))
|
|
||||||
#define DOWN(x) (pad.Buttons & (x))
|
|
||||||
#define UP(x) (!(pad.Buttons & (x)))
|
#define UP(x) (!(pad.Buttons & (x)))
|
||||||
#define PSP_DPAD (PSP_CTRL_DOWN|PSP_CTRL_UP|PSP_CTRL_LEFT|PSP_CTRL_RIGHT)
|
#define PSP_DPAD (PSP_CTRL_DOWN|PSP_CTRL_UP|PSP_CTRL_LEFT|PSP_CTRL_RIGHT)
|
||||||
#define PSP_4BUTTONS (PSP_CTRL_CROSS | PSP_CTRL_CIRCLE | PSP_CTRL_TRIANGLE | PSP_CTRL_SQUARE)
|
#define PSP_4BUTTONS (PSP_CTRL_CROSS | PSP_CTRL_CIRCLE | PSP_CTRL_TRIANGLE | PSP_CTRL_SQUARE)
|
||||||
#define PSP_TRIGGERS (PSP_CTRL_LTRIGGER | PSP_CTRL_RTRIGGER)
|
#define PSP_TRIGGERS (PSP_CTRL_LTRIGGER | PSP_CTRL_RTRIGGER)
|
||||||
|
#define PSP_ALL_BUTTONS (PSP_DPAD | PSP_4BUTTONS | PSP_TRIGGERS | PSP_CTRL_START | PSP_CTRL_SELECT)
|
||||||
|
|
||||||
#define PAD_CHECK_TIME 53
|
#define PAD_CHECK_TIME 53
|
||||||
|
|
||||||
void InputHandler::init() {
|
Button::Button() {
|
||||||
sceCtrlSetSamplingCycle(0); // set sampling to vsync. n = n usecs
|
clear();
|
||||||
sceCtrlSetSamplingMode(1); // analog
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputHandler::getAllInputs(Common::Event &event) {
|
inline void Button::clear() {
|
||||||
DEBUG_ENTER_FUNC();
|
_key = Common::KEYCODE_INVALID;
|
||||||
|
_ascii = 0;
|
||||||
uint32 time = g_system->getMillis(); // may not be necessary with read
|
_flag = 0;
|
||||||
if (time - _lastPadCheckTime < PAD_CHECK_TIME) {
|
_pspEventDown.clear();
|
||||||
return false;
|
_pspEventUp.clear();
|
||||||
}
|
|
||||||
|
|
||||||
_lastPadCheckTime = time;
|
|
||||||
SceCtrlData pad;
|
|
||||||
|
|
||||||
sceCtrlPeekBufferPositive(&pad, 1); // Peek ignores sleep. Read sleeps thread
|
|
||||||
|
|
||||||
bool haveEvent;
|
|
||||||
|
|
||||||
memset(&event, 0, sizeof(event));
|
|
||||||
|
|
||||||
if (_keyboard->isVisible())
|
|
||||||
haveEvent = _keyboard->processInput(event, pad);
|
|
||||||
else
|
|
||||||
haveEvent = getEvent(event, pad);
|
|
||||||
|
|
||||||
if (haveEvent) {
|
|
||||||
PSP_DEBUG_PRINT("Have event[%s]\n", haveEvent ? "true" : "false");
|
|
||||||
PSP_DEBUG_PRINT("event.type[%d]\n", event.type);
|
|
||||||
}
|
|
||||||
|
|
||||||
return haveEvent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputHandler::getEvent(Common::Event &event, SceCtrlData &pad) {
|
inline bool Button::getEvent(Common::Event &event, PspEvent &pspEvent, bool down) {
|
||||||
DEBUG_ENTER_FUNC();
|
if (down) {
|
||||||
|
if (!_pspEventDown.isEmpty())
|
||||||
_buttonsChanged = pad.Buttons ^ _prevButtons;
|
pspEvent = _pspEventDown;
|
||||||
bool haveEvent = false;
|
} else { // up
|
||||||
|
if (!_pspEventUp.isEmpty())
|
||||||
// Collect events from different sources
|
pspEvent = _pspEventUp;
|
||||||
haveEvent = getDpadEvent(event, pad);
|
}
|
||||||
|
if (_key != Common::KEYCODE_INVALID) {
|
||||||
if (!haveEvent)
|
event.type = down ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP;
|
||||||
haveEvent = getButtonEvent(event, pad);
|
event.kbd.keycode = _key;
|
||||||
|
event.kbd.ascii = _ascii;
|
||||||
if (!haveEvent)
|
event.kbd.flags |= _flag;
|
||||||
haveEvent = getNubEvent(event, pad);
|
return true;
|
||||||
|
} else if (_flag) { // handle flag only events
|
||||||
_prevButtons = pad.Buttons;
|
event.type = down ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP;
|
||||||
|
event.kbd.flags |= down ? _flag : 0;
|
||||||
return haveEvent;
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputHandler::getDpadEvent(Common::Event &event, SceCtrlData &pad) {
|
void Button::setPspEvent(PspEventType typeDown, uint32 dataDown, PspEventType typeUp, uint32 dataUp) {
|
||||||
DEBUG_ENTER_FUNC();
|
_pspEventDown.type = typeDown;
|
||||||
|
_pspEventDown.data = dataDown;
|
||||||
|
_pspEventUp.type = typeUp;
|
||||||
|
_pspEventUp.data = dataUp;
|
||||||
|
}
|
||||||
|
|
||||||
int newDpadX = 0, newDpadY = 0;
|
// Translates bitfields to our constants
|
||||||
bool haveEvent = false;
|
// We put combined bitfields first to make sure we pick up diagonals
|
||||||
|
const uint32 ButtonPad::_buttonMap[] = {
|
||||||
|
PSP_CTRL_UP | PSP_CTRL_LEFT,
|
||||||
|
PSP_CTRL_UP | PSP_CTRL_RIGHT,
|
||||||
|
PSP_CTRL_DOWN | PSP_CTRL_RIGHT,
|
||||||
|
PSP_CTRL_DOWN | PSP_CTRL_LEFT,
|
||||||
|
PSP_CTRL_RIGHT, PSP_CTRL_DOWN, PSP_CTRL_LEFT, PSP_CTRL_UP,
|
||||||
|
PSP_CTRL_CROSS, PSP_CTRL_CIRCLE, PSP_CTRL_TRIANGLE, PSP_CTRL_SQUARE,
|
||||||
|
PSP_CTRL_LTRIGGER, PSP_CTRL_RTRIGGER, PSP_CTRL_START, PSP_CTRL_SELECT
|
||||||
|
};
|
||||||
|
|
||||||
if (DOWN(PSP_CTRL_UP)) {
|
ButtonPad::ButtonPad() : _prevButtonState(0), _shifted(UNSHIFTED), _padMode(PAD_MODE_NORMAL),
|
||||||
newDpadY++;
|
_comboMode(false) {
|
||||||
if (DOWN(PSP_CTRL_RTRIGGER)) // Shifting causes diagonals
|
for (int i = UNSHIFTED; i < SHIFTED_MODE_LAST; i++)
|
||||||
newDpadX++;
|
_buttonsChanged[i] = 0;
|
||||||
}
|
clearButtons();
|
||||||
if (DOWN(PSP_CTRL_RIGHT)) {
|
|
||||||
newDpadX++;
|
|
||||||
if (DOWN(PSP_CTRL_RTRIGGER))
|
|
||||||
newDpadY--;
|
|
||||||
}
|
|
||||||
if (DOWN(PSP_CTRL_DOWN)) {
|
|
||||||
newDpadY--;
|
|
||||||
if (DOWN(PSP_CTRL_RTRIGGER))
|
|
||||||
newDpadX--;
|
|
||||||
}
|
|
||||||
if (DOWN(PSP_CTRL_LEFT)) {
|
|
||||||
newDpadX--;
|
|
||||||
if (DOWN(PSP_CTRL_RTRIGGER))
|
|
||||||
newDpadY++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newDpadX != _dpadX || newDpadY != _dpadY) {
|
|
||||||
if (_dpadX == 0 && _dpadY == 0) { // We were in the middle so we pressed dpad
|
|
||||||
event.type = Common::EVENT_KEYDOWN;
|
|
||||||
event.kbd.keycode = translateDpad(newDpadX, newDpadY);
|
|
||||||
event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0'; // Get ascii
|
|
||||||
_dpadX = newDpadX;
|
|
||||||
_dpadY = newDpadY;
|
|
||||||
} else if (newDpadX == 0 && newDpadY == 0) {// We're now centered so we unpressed dpad
|
|
||||||
event.type = Common::EVENT_KEYUP;
|
|
||||||
event.kbd.keycode = translateDpad(_dpadX, _dpadY);
|
|
||||||
event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0';
|
|
||||||
_dpadX = newDpadX;
|
|
||||||
_dpadY = newDpadY;
|
|
||||||
} else { // we moved from one pressed dpad direction to another one
|
|
||||||
event.type = Common::EVENT_KEYUP; // first release the last dpad direction
|
|
||||||
event.kbd.keycode = translateDpad(_dpadX, _dpadY);
|
|
||||||
event.kbd.ascii = event.kbd.keycode - Common::KEYCODE_KP0 + '0';
|
|
||||||
_dpadX = 0; // so that we'll pick up a new dpad movement the next round
|
|
||||||
_dpadY = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
PSP_DEBUG_PRINT("Keypad event. DpadX[%d], DpadY[%d]\n", _dpadX, _dpadY);
|
|
||||||
haveEvent = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return haveEvent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Common::KeyCode InputHandler::translateDpad(int x, int y) {
|
void ButtonPad::clearButtons() {
|
||||||
DEBUG_ENTER_FUNC();
|
for (int i = BTN_UP_LEFT; i < BTN_LAST; i++) {
|
||||||
Common::KeyCode key;
|
_button[i][UNSHIFTED].clear();
|
||||||
|
_button[i][SHIFTED].clear();
|
||||||
if (x == -1) {
|
|
||||||
if (y == -1)
|
|
||||||
key = Common::KEYCODE_KP1;
|
|
||||||
else if (y == 0)
|
|
||||||
key = Common::KEYCODE_KP4;
|
|
||||||
else /* y == 1 */
|
|
||||||
key = Common::KEYCODE_KP7;
|
|
||||||
} else if (x == 0) {
|
|
||||||
if (y == -1)
|
|
||||||
key = Common::KEYCODE_KP2;
|
|
||||||
else /* y == 1 */
|
|
||||||
key = Common::KEYCODE_KP8;
|
|
||||||
} else {/* x == 1 */
|
|
||||||
if (y == -1)
|
|
||||||
key = Common::KEYCODE_KP3;
|
|
||||||
else if (y == 0)
|
|
||||||
key = Common::KEYCODE_KP6;
|
|
||||||
else /* y == 1 */
|
|
||||||
key = Common::KEYCODE_KP9;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ButtonPad::initButtons() {
|
||||||
|
switch (_padMode) {
|
||||||
|
case PAD_MODE_NORMAL:
|
||||||
|
initButtonsNormalMode();
|
||||||
|
break;
|
||||||
|
case PAD_MODE_LOL:
|
||||||
|
initButtonsLolMode();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool InputHandler::getButtonEvent(Common::Event &event, SceCtrlData &pad) {
|
void ButtonPad::initButtonsNormalMode() {
|
||||||
DEBUG_ENTER_FUNC();
|
DEBUG_ENTER_FUNC();
|
||||||
bool haveEvent = false;
|
PSP_DEBUG_PRINT("initializing buttons for normal mode\n");
|
||||||
|
clearButtons();
|
||||||
|
|
||||||
|
// Dpad
|
||||||
|
_button[BTN_UP_LEFT][UNSHIFTED].setKey(Common::KEYCODE_KP7, '7');
|
||||||
|
_button[BTN_LEFT][SHIFTED].setKey(Common::KEYCODE_KP7, '7'); // same as up_left
|
||||||
|
_button[BTN_UP][UNSHIFTED].setKey(Common::KEYCODE_KP8, '8');
|
||||||
|
_button[BTN_UP_RIGHT][UNSHIFTED].setKey(Common::KEYCODE_KP9, '9');
|
||||||
|
_button[BTN_UP][SHIFTED].setKey(Common::KEYCODE_KP9, '9'); // same as up_right
|
||||||
|
_button[BTN_LEFT][UNSHIFTED].setKey(Common::KEYCODE_KP4, '4');
|
||||||
|
_button[BTN_RIGHT][UNSHIFTED].setKey(Common::KEYCODE_KP6, '6');
|
||||||
|
_button[BTN_DOWN_LEFT][UNSHIFTED].setKey(Common::KEYCODE_KP1, '1');
|
||||||
|
_button[BTN_DOWN][SHIFTED].setKey(Common::KEYCODE_KP1, '1'); // same as down_left
|
||||||
|
_button[BTN_DOWN][UNSHIFTED].setKey(Common::KEYCODE_KP2, '2');
|
||||||
|
_button[BTN_DOWN_RIGHT][UNSHIFTED].setKey(Common::KEYCODE_KP3, '3');
|
||||||
|
_button[BTN_RIGHT][SHIFTED].setKey(Common::KEYCODE_KP3, '3'); // same as down_right
|
||||||
|
|
||||||
|
// Other buttons
|
||||||
|
_button[BTN_CROSS][UNSHIFTED].setPspEvent(PSP_EVENT_LBUTTON, true, PSP_EVENT_LBUTTON, false);
|
||||||
|
_button[BTN_CIRCLE][UNSHIFTED].setPspEvent(PSP_EVENT_RBUTTON, true, PSP_EVENT_RBUTTON, false);
|
||||||
|
_button[BTN_TRIANGLE][UNSHIFTED].setKey(Common::KEYCODE_RETURN, '\r');
|
||||||
|
_button[BTN_SQUARE][UNSHIFTED].setKey(Common::KEYCODE_PERIOD, '.');
|
||||||
|
_button[BTN_SQUARE][SHIFTED].setKey(Common::KEYCODE_SPACE, ' ');
|
||||||
|
_button[BTN_LTRIGGER][UNSHIFTED].setKey(Common::KEYCODE_ESCAPE, 27);
|
||||||
|
_button[BTN_RTRIGGER][SHIFTED].setPspEvent(PSP_EVENT_SHIFT, true, PSP_EVENT_SHIFT, false);
|
||||||
|
_button[BTN_RTRIGGER][UNSHIFTED].setPspEvent(PSP_EVENT_SHIFT, true, PSP_EVENT_SHIFT, false);
|
||||||
|
_button[BTN_RTRIGGER][SHIFTED].setKey(Common::KEYCODE_INVALID, 0, Common::KBD_SHIFT);
|
||||||
|
_button[BTN_RTRIGGER][UNSHIFTED].setKey(Common::KEYCODE_INVALID, 0, Common::KBD_SHIFT);
|
||||||
|
_button[BTN_START][SHIFTED].setKey(Common::KEYCODE_F5, Common::ASCII_F5);
|
||||||
|
_button[BTN_START][UNSHIFTED].setKey(Common::KEYCODE_F5, Common::ASCII_F5, Common::KBD_CTRL);
|
||||||
|
_button[BTN_SELECT][UNSHIFTED].setPspEvent(PSP_EVENT_SHOW_VIRTUAL_KB, true, PSP_EVENT_NONE, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (PRESSED(PSP_CTRL_SELECT))
|
void ButtonPad::initButtonsLolMode() {
|
||||||
_keyboard->setVisible(true);
|
DEBUG_ENTER_FUNC();
|
||||||
|
initButtonsNormalMode(); // set normal button configuration
|
||||||
|
PSP_DEBUG_PRINT("initializing buttons for LOL mode\n");
|
||||||
|
|
||||||
else if (CHANGED(PSP_4BUTTONS | PSP_TRIGGERS | PSP_CTRL_START)) {
|
// Square is our new shift button
|
||||||
if (CHANGED(PSP_CTRL_CROSS)) {
|
_button[BTN_SQUARE][UNSHIFTED].clear();
|
||||||
event.type = DOWN(PSP_CTRL_CROSS) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP;
|
_button[BTN_SQUARE][UNSHIFTED].setPspEvent(PSP_EVENT_SHIFT, true, PSP_EVENT_SHIFT, false);
|
||||||
event.mouse.x = _cursor->getX(); // Could this have to do with SCI enter problem?
|
_button[BTN_SQUARE][SHIFTED].clear();
|
||||||
event.mouse.y = _cursor->getY();
|
_button[BTN_SQUARE][SHIFTED].setPspEvent(PSP_EVENT_SHIFT, true, PSP_EVENT_SHIFT, false);
|
||||||
PSP_DEBUG_PRINT("%s\n", event.type == Common::EVENT_LBUTTONDOWN ? "LButtonDown" : "LButtonUp");
|
|
||||||
} else if (CHANGED(PSP_CTRL_CIRCLE)) {
|
// Dpad
|
||||||
event.type = DOWN(PSP_CTRL_CIRCLE) ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP;
|
_button[BTN_LEFT][UNSHIFTED].clear();
|
||||||
event.mouse.x = _cursor->getX();
|
_button[BTN_LEFT][UNSHIFTED].setKey(Common::KEYCODE_KP7, '7');
|
||||||
event.mouse.y = _cursor->getY();
|
_button[BTN_LEFT][SHIFTED].clear();
|
||||||
PSP_DEBUG_PRINT("%s\n", event.type == Common::EVENT_LBUTTONDOWN ? "RButtonDown" : "RButtonUp");
|
_button[BTN_LEFT][SHIFTED].setKey(Common::KEYCODE_F1, Common::ASCII_F1);
|
||||||
} else {
|
_button[BTN_UP][SHIFTED].clear();
|
||||||
//any of the other buttons.
|
_button[BTN_UP][SHIFTED].setKey(Common::KEYCODE_F2, Common::ASCII_F2);
|
||||||
event.type = _buttonsChanged & pad.Buttons ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP;
|
_button[BTN_RIGHT][UNSHIFTED].clear();
|
||||||
event.kbd.ascii = 0;
|
_button[BTN_RIGHT][UNSHIFTED].setKey(Common::KEYCODE_KP9, '9');
|
||||||
event.kbd.flags = 0;
|
_button[BTN_RIGHT][SHIFTED].clear();
|
||||||
|
_button[BTN_RIGHT][SHIFTED].setKey(Common::KEYCODE_F3, Common::ASCII_F3);
|
||||||
|
_button[BTN_DOWN][SHIFTED].clear();
|
||||||
|
_button[BTN_DOWN][SHIFTED].setKey(Common::KEYCODE_F4, Common::ASCII_F4);
|
||||||
|
|
||||||
if (CHANGED(PSP_CTRL_LTRIGGER)) {
|
// Buttons
|
||||||
event.kbd.keycode = Common::KEYCODE_ESCAPE;
|
_button[BTN_LTRIGGER][UNSHIFTED].clear();
|
||||||
event.kbd.ascii = 27;
|
_button[BTN_LTRIGGER][SHIFTED].clear();
|
||||||
} else if (CHANGED(PSP_CTRL_START)) {
|
_button[BTN_LTRIGGER][UNSHIFTED].setKey(Common::KEYCODE_KP4, '4'); // Triggers turn
|
||||||
event.kbd.keycode = Common::KEYCODE_F5;
|
_button[BTN_RTRIGGER][UNSHIFTED].clear();
|
||||||
event.kbd.ascii = Common::ASCII_F5;
|
_button[BTN_RTRIGGER][SHIFTED].clear();
|
||||||
if (DOWN(PSP_CTRL_RTRIGGER)) {
|
_button[BTN_RTRIGGER][UNSHIFTED].setKey(Common::KEYCODE_KP6, '6');
|
||||||
event.kbd.flags |= Common::KBD_CTRL; // Main menu to allow RTL
|
_button[BTN_START][SHIFTED].clear();
|
||||||
|
_button[BTN_START][SHIFTED].setKey(Common::KEYCODE_ESCAPE, 27);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ButtonPad::getEvent(Common::Event &event, PspEvent &pspEvent, SceCtrlData &pad) {
|
||||||
|
DEBUG_ENTER_FUNC();
|
||||||
|
|
||||||
|
//PSP_DEBUG_PRINT("buttons[%x]\n", pad.Buttons);
|
||||||
|
|
||||||
|
uint32 curButtonState = PSP_ALL_BUTTONS & pad.Buttons; // we only care about these
|
||||||
|
|
||||||
|
modifyButtonsForCombos(pad); // change buttons for combos
|
||||||
|
|
||||||
|
return getEventFromButtonState(event, pspEvent, curButtonState);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ButtonPad::getEventFromButtonState(Common::Event &event, PspEvent &pspEvent, uint32 buttonState) {
|
||||||
|
DEBUG_ENTER_FUNC();
|
||||||
|
_buttonsChanged[_shifted] |= buttonState ^ _prevButtonState; // add any buttons that changed
|
||||||
|
_prevButtonState = buttonState;
|
||||||
|
|
||||||
|
for (int shiftState = UNSHIFTED; shiftState < SHIFTED_MODE_LAST; shiftState++) {
|
||||||
|
if (_buttonsChanged[shiftState]) { // any button to address?
|
||||||
|
PSP_DEBUG_PRINT("found changed buttons\n");
|
||||||
|
ButtonType buttonType = BTN_LAST;
|
||||||
|
bool buttonDown = false; // normally we release a button (as in when we're in a different shiftmode)
|
||||||
|
|
||||||
|
for (int i = BTN_UP_LEFT; i < BTN_LAST; i++) {
|
||||||
|
uint32 buttonCode = _buttonMap[i];
|
||||||
|
if ((_buttonsChanged[shiftState] & buttonCode) == buttonCode) { // check for this changed button
|
||||||
|
buttonType = (ButtonType)i; // we know which button changed
|
||||||
|
_buttonsChanged[shiftState] &= ~buttonCode; // save the fact that we treated this button
|
||||||
|
if (shiftState == _shifted)
|
||||||
|
buttonDown = buttonState & buttonCode ? true : false; // pressed or released?
|
||||||
|
|
||||||
|
PSP_DEBUG_PRINT("button[%i] pressed\n", i);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if (CHANGED(PSP_CTRL_SQUARE)) {
|
|
||||||
event.kbd.keycode = Common::KEYCODE_PERIOD;
|
|
||||||
event.kbd.ascii = '.';
|
|
||||||
} else if (CHANGED(PSP_CTRL_TRIANGLE)) {
|
|
||||||
event.kbd.keycode = Common::KEYCODE_RETURN;
|
|
||||||
event.kbd.ascii = '\r';
|
|
||||||
} else if (DOWN(PSP_CTRL_RTRIGGER)) { // An event
|
|
||||||
event.kbd.flags |= Common::KBD_SHIFT;
|
|
||||||
}
|
}
|
||||||
PSP_DEBUG_PRINT("Ascii[%d]. Key %s.\n", event.kbd.ascii, event.type == Common::EVENT_KEYDOWN ? "down" : "up");
|
|
||||||
|
assert (buttonType < BTN_LAST);
|
||||||
|
bool haveEvent = _button[buttonType][shiftState].getEvent(event, pspEvent, buttonDown);
|
||||||
|
if (haveEvent)
|
||||||
|
PSP_DEBUG_PRINT("have event. key[%d] flag[%x] %s\n", event.kbd.ascii, event.kbd.flags, buttonDown ? "down" : "up");
|
||||||
|
return haveEvent;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
haveEvent = true;
|
|
||||||
}
|
return false;
|
||||||
|
|
||||||
return haveEvent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InputHandler::getNubEvent(Common::Event &event, SceCtrlData &pad) {
|
void ButtonPad::modifyButtonsForCombos(SceCtrlData &pad) {
|
||||||
|
if (DOWN(PSP_CTRL_RTRIGGER | PSP_CTRL_LTRIGGER)) {
|
||||||
|
if (!_comboMode) { // we're entering combo mode
|
||||||
|
PSP_DEBUG_PRINT("entering combo mode\n");
|
||||||
|
_button[BTN_SQUARE][UNSHIFTED].clear();
|
||||||
|
_button[BTN_SQUARE][SHIFTED].clear();
|
||||||
|
_button[BTN_DOWN][SHIFTED].clear();
|
||||||
|
_button[BTN_DOWN][UNSHIFTED].clear();
|
||||||
|
_button[BTN_UP][SHIFTED].clear();
|
||||||
|
_button[BTN_UP][UNSHIFTED].clear();
|
||||||
|
_button[BTN_SQUARE][UNSHIFTED].setPspEvent(PSP_EVENT_MODE_SWITCH, true, PSP_EVENT_NONE, true);
|
||||||
|
_button[BTN_SQUARE][SHIFTED].setPspEvent(PSP_EVENT_MODE_SWITCH, true, PSP_EVENT_NONE, true);
|
||||||
|
_button[BTN_DOWN][UNSHIFTED].setPspEvent(PSP_EVENT_CHANGE_SPEED, false, PSP_EVENT_NONE, true);
|
||||||
|
_button[BTN_DOWN][SHIFTED].setPspEvent(PSP_EVENT_CHANGE_SPEED, false, PSP_EVENT_NONE, true);
|
||||||
|
_button[BTN_UP][UNSHIFTED].setPspEvent(PSP_EVENT_CHANGE_SPEED, true, PSP_EVENT_NONE, true);
|
||||||
|
_button[BTN_UP][SHIFTED].setPspEvent(PSP_EVENT_CHANGE_SPEED, true, PSP_EVENT_NONE, true);
|
||||||
|
_comboMode = true;
|
||||||
|
}
|
||||||
|
} else { // no combo buttons are pressed now
|
||||||
|
if (_comboMode) { // we have been running in combo mode
|
||||||
|
initButtons(); // reset the button configuration
|
||||||
|
_comboMode = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Nub::getEvent(Common::Event &event, PspEvent &pspEvent, SceCtrlData &pad) {
|
||||||
DEBUG_ENTER_FUNC();
|
DEBUG_ENTER_FUNC();
|
||||||
|
|
||||||
bool haveEvent = false;
|
if (_dpadMode) { // Convert the nub to a D-Pad
|
||||||
|
uint32 buttonState;
|
||||||
|
translateToDpadState(pad.Lx, pad.Ly, buttonState);
|
||||||
|
return _buttonPad.getEventFromButtonState(event, pspEvent, buttonState);
|
||||||
|
}
|
||||||
|
|
||||||
int32 analogStepX = pad.Lx; // Goes up to 255.
|
int32 analogStepX = pad.Lx; // Goes up to 255.
|
||||||
int32 analogStepY = pad.Ly;
|
int32 analogStepY = pad.Ly;
|
||||||
|
|
||||||
int32 oldX = _cursor->getX();
|
|
||||||
int32 oldY = _cursor->getY();
|
|
||||||
|
|
||||||
analogStepX = modifyNubAxisMotion(analogStepX);
|
analogStepX = modifyNubAxisMotion(analogStepX);
|
||||||
analogStepY = modifyNubAxisMotion(analogStepY);
|
analogStepY = modifyNubAxisMotion(analogStepY);
|
||||||
|
|
||||||
|
int32 oldX = _cursor->getX();
|
||||||
|
int32 oldY = _cursor->getY();
|
||||||
|
|
||||||
if (analogStepX != 0 || analogStepY != 0) {
|
if (analogStepX != 0 || analogStepY != 0) {
|
||||||
|
|
||||||
PSP_DEBUG_PRINT("raw x[%d], y[%d]\n", analogStepX, analogStepY);
|
PSP_DEBUG_PRINT("raw x[%d], y[%d]\n", analogStepX, analogStepY);
|
||||||
|
|
||||||
// If no movement then this has no effect
|
// If no movement then this has no effect
|
||||||
if (DOWN(PSP_CTRL_RTRIGGER)) {
|
if (_shifted) {
|
||||||
// Fine control mode for analog
|
// Fine control mode for analog
|
||||||
if (analogStepX != 0) {
|
if (analogStepX != 0) {
|
||||||
if (analogStepX > 0)
|
if (analogStepX > 0)
|
||||||
|
@ -281,15 +315,29 @@ bool InputHandler::getNubEvent(Common::Event &event, SceCtrlData &pad) {
|
||||||
event.type = Common::EVENT_MOUSEMOVE;
|
event.type = Common::EVENT_MOUSEMOVE;
|
||||||
event.mouse.x = newX;
|
event.mouse.x = newX;
|
||||||
event.mouse.y = newY;
|
event.mouse.y = newY;
|
||||||
haveEvent = true;
|
|
||||||
|
|
||||||
PSP_DEBUG_PRINT("Nub event. X[%d], Y[%d]\n", newX, newY);
|
PSP_DEBUG_PRINT("Nub event. X[%d], Y[%d]\n", newX, newY);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return haveEvent;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int32 InputHandler::modifyNubAxisMotion(int32 input) {
|
void Nub::translateToDpadState(int dpadX, int dpadY, uint32 &buttonState) {
|
||||||
|
#define MIN_NUB_POSITION 70
|
||||||
|
buttonState = 0;
|
||||||
|
|
||||||
|
if (dpadX > 127 + MIN_NUB_POSITION)
|
||||||
|
buttonState |= PSP_CTRL_RIGHT;
|
||||||
|
else if (dpadX < 127 - MIN_NUB_POSITION)
|
||||||
|
buttonState |= PSP_CTRL_LEFT;
|
||||||
|
|
||||||
|
if (dpadY > 127 + MIN_NUB_POSITION)
|
||||||
|
buttonState |= PSP_CTRL_DOWN;
|
||||||
|
else if (dpadY < 127 - MIN_NUB_POSITION)
|
||||||
|
buttonState |= PSP_CTRL_UP;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int32 Nub::modifyNubAxisMotion(int32 input) {
|
||||||
DEBUG_ENTER_FUNC();
|
DEBUG_ENTER_FUNC();
|
||||||
const int MIN_NUB_MOTION = 30;
|
const int MIN_NUB_MOTION = 30;
|
||||||
|
|
||||||
|
@ -304,3 +352,160 @@ inline int32 InputHandler::modifyNubAxisMotion(int32 input) {
|
||||||
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool Nub::isButtonDown() {
|
||||||
|
if (_dpadMode) // only relevant in dpad mode
|
||||||
|
return _buttonPad.isButtonDown();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *InputHandler::_padModeText[] = {
|
||||||
|
"Normal Button Mode",
|
||||||
|
"1st Person RPG Button Mode"
|
||||||
|
};
|
||||||
|
|
||||||
|
void InputHandler::init() {
|
||||||
|
sceCtrlSetSamplingCycle(0); // set sampling to vsync. n = n usecs
|
||||||
|
sceCtrlSetSamplingMode(1); // analog
|
||||||
|
|
||||||
|
_buttonPad.initButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InputHandler::getAllInputs(Common::Event &event) {
|
||||||
|
DEBUG_ENTER_FUNC();
|
||||||
|
|
||||||
|
uint32 time = g_system->getMillis(); // may not be necessary with read
|
||||||
|
if (time - _lastPadCheckTime < PAD_CHECK_TIME) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_lastPadCheckTime = time;
|
||||||
|
SceCtrlData pad;
|
||||||
|
|
||||||
|
sceCtrlPeekBufferPositive(&pad, 1); // Peek doesn't sleep. Read sleeps the thread
|
||||||
|
|
||||||
|
bool haveEvent;
|
||||||
|
//memset(&event, 0, sizeof(event));
|
||||||
|
|
||||||
|
haveEvent = getEvent(event, pad);
|
||||||
|
|
||||||
|
if (haveEvent) {
|
||||||
|
PSP_DEBUG_PRINT("Have event[%s]. Type[%d]\n", haveEvent ? "true" : "false", event.type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return haveEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InputHandler::getEvent(Common::Event &event, SceCtrlData &pad) {
|
||||||
|
DEBUG_ENTER_FUNC();
|
||||||
|
|
||||||
|
PspEvent pspEvent;
|
||||||
|
bool haveEvent = false;
|
||||||
|
|
||||||
|
if (_keyboard->isVisible()) {
|
||||||
|
haveEvent = _keyboard->processInput(event, pspEvent, pad);
|
||||||
|
} else { // only process buttonpad if keyboard invisible
|
||||||
|
haveEvent = _buttonPad.getEvent(event, pspEvent, pad);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!haveEvent && pspEvent.isEmpty())
|
||||||
|
haveEvent = _nub.getEvent(event, pspEvent, pad);
|
||||||
|
|
||||||
|
// handle any pending PSP events
|
||||||
|
if (!haveEvent && pspEvent.isEmpty()) {
|
||||||
|
if (!_pendingPspEvent.isEmpty()) {
|
||||||
|
pspEvent = _pendingPspEvent;
|
||||||
|
_pendingPspEvent.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle any PSP events we might have
|
||||||
|
if (!pspEvent.isEmpty())
|
||||||
|
haveEvent |= handlePspEvent(event, pspEvent); // overrides any event we might have
|
||||||
|
|
||||||
|
return haveEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InputHandler::handlePspEvent(Common::Event &event, PspEvent &pspEvent) {
|
||||||
|
bool haveEvent = false;
|
||||||
|
|
||||||
|
PSP_DEBUG_PRINT("have pspEvent[%d] data[%d]\n", pspEvent.type, pspEvent.data);
|
||||||
|
|
||||||
|
switch (pspEvent.type) {
|
||||||
|
case PSP_EVENT_SHIFT:
|
||||||
|
handleShiftEvent((ShiftMode)pspEvent.data);
|
||||||
|
break;
|
||||||
|
case PSP_EVENT_SHOW_VIRTUAL_KB:
|
||||||
|
_keyboard->setVisible((bool)pspEvent.data);
|
||||||
|
if ((pspEvent.data && _keyboard->isVisible()) || !pspEvent.data) // don't change mode if keyboard didn't load
|
||||||
|
_nub.setDpadMode((bool)pspEvent.data); // set nub to keypad/regular mode
|
||||||
|
break;
|
||||||
|
case PSP_EVENT_LBUTTON:
|
||||||
|
haveEvent = true;
|
||||||
|
if (pspEvent.data) // down
|
||||||
|
handleMouseEvent(event, Common::EVENT_LBUTTONDOWN, "LButtonDown");
|
||||||
|
else
|
||||||
|
handleMouseEvent(event, Common::EVENT_LBUTTONUP, "LButtonUp");
|
||||||
|
break;
|
||||||
|
case PSP_EVENT_RBUTTON:
|
||||||
|
haveEvent = true;
|
||||||
|
if (pspEvent.data) // down
|
||||||
|
handleMouseEvent(event, Common::EVENT_RBUTTONDOWN, "RButtonDown");
|
||||||
|
else
|
||||||
|
handleMouseEvent(event, Common::EVENT_RBUTTONUP, "RButtonUp");
|
||||||
|
break;
|
||||||
|
case PSP_EVENT_MODE_SWITCH:
|
||||||
|
handleModeSwitchEvent();
|
||||||
|
break;
|
||||||
|
/*case PSP_EVENT_CHANGE_SPEED:
|
||||||
|
handleSpeedChange(pspEvent.data);
|
||||||
|
break;*/
|
||||||
|
default:
|
||||||
|
PSP_ERROR("Unhandled PSP Event[%d]\n", pspEvent.type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return haveEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputHandler::handleMouseEvent(Common::Event &event, Common::EventType type, const char *string) {
|
||||||
|
event.type = type;
|
||||||
|
event.mouse.x = _cursor->getX();
|
||||||
|
event.mouse.y = _cursor->getY();
|
||||||
|
PSP_DEBUG_PRINT("%s event, x[%d], y[%d]\n", string, event.mouse.x, event.mouse.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputHandler::handleShiftEvent(ShiftMode shifted) {
|
||||||
|
_buttonPad.setShifted(shifted);
|
||||||
|
_nub.setShifted(shifted);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputHandler::handleModeSwitchEvent() {
|
||||||
|
// check if we can't switch modes right now
|
||||||
|
if (_buttonPad.isButtonDown() || _nub.isButtonDown()) { // can't switch yet
|
||||||
|
PSP_DEBUG_PRINT("postponing mode switch event\n");
|
||||||
|
_pendingPspEvent.type = PSP_EVENT_MODE_SWITCH; // queue it to be done later
|
||||||
|
} else { // we can switch
|
||||||
|
PSP_DEBUG_PRINT("mode switch event\n");
|
||||||
|
_padMode = (PspPadMode)(_padMode + 1);
|
||||||
|
if (_padMode >= PAD_MODE_LAST)
|
||||||
|
_padMode = PAD_MODE_NORMAL;
|
||||||
|
|
||||||
|
GUI::TimedMessageDialog dialog(_padModeText[_padMode], 1500);
|
||||||
|
dialog.runModal();
|
||||||
|
|
||||||
|
_buttonPad.setPadMode(_padMode);
|
||||||
|
_buttonPad.initButtons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
void InputHandler::handleSpeedChange(bool up) {
|
||||||
|
char *dialogMsg;
|
||||||
|
|
||||||
|
if (up) {
|
||||||
|
dialogMsg = "
|
||||||
|
|
||||||
|
GUI::TimedMessageDialog dialog(_padModeText[_padMode], 1500);
|
||||||
|
dialog.runModal();
|
||||||
|
}*/
|
||||||
|
|
|
@ -28,36 +28,154 @@
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "common/events.h"
|
#include "common/events.h"
|
||||||
#include "backends/platform/psp/display_client.h"
|
|
||||||
#include "backends/platform/psp/default_display_client.h"
|
|
||||||
#include "backends/platform/psp/pspkeyboard.h"
|
#include "backends/platform/psp/pspkeyboard.h"
|
||||||
#include "backends/platform/psp/cursor.h"
|
#include "backends/platform/psp/cursor.h"
|
||||||
#include <pspctrl.h>
|
#include <pspctrl.h>
|
||||||
|
|
||||||
|
enum PspEventType {
|
||||||
|
PSP_EVENT_NONE = 0,
|
||||||
|
PSP_EVENT_SHIFT,
|
||||||
|
PSP_EVENT_SHOW_VIRTUAL_KB,
|
||||||
|
PSP_EVENT_LBUTTON,
|
||||||
|
PSP_EVENT_RBUTTON,
|
||||||
|
PSP_EVENT_MODE_SWITCH,
|
||||||
|
PSP_EVENT_CHANGE_SPEED,
|
||||||
|
PSP_EVENT_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct PspEvent {
|
||||||
|
PspEventType type;
|
||||||
|
uint32 data;
|
||||||
|
PspEvent() { clear(); }
|
||||||
|
void clear() {
|
||||||
|
type = PSP_EVENT_NONE;
|
||||||
|
data = 0;
|
||||||
|
}
|
||||||
|
bool isEmpty() { return type == PSP_EVENT_NONE; }
|
||||||
|
};
|
||||||
|
|
||||||
|
enum PspPadMode {
|
||||||
|
PAD_MODE_NORMAL,
|
||||||
|
PAD_MODE_LOL,
|
||||||
|
PAD_MODE_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ShiftMode {
|
||||||
|
UNSHIFTED = 0,
|
||||||
|
SHIFTED = 1,
|
||||||
|
SHIFTED_MODE_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class Button {
|
||||||
|
private:
|
||||||
|
Common::KeyCode _key;
|
||||||
|
uint32 _ascii;
|
||||||
|
uint32 _flag;
|
||||||
|
PspEvent _pspEventDown; // event when we press
|
||||||
|
PspEvent _pspEventUp; // event when we release
|
||||||
|
public:
|
||||||
|
Button();
|
||||||
|
void clear();
|
||||||
|
bool getEvent(Common::Event &event, PspEvent &pspEvent, bool buttonDown);
|
||||||
|
void setKey(Common::KeyCode key, uint32 ascii = 0, uint32 flag = 0) { _key = key; _ascii = ascii; _flag = flag; }
|
||||||
|
void setPspEvent(PspEventType typeDown, uint32 dataDown, PspEventType typeUp, uint32 dataUp);
|
||||||
|
};
|
||||||
|
|
||||||
|
class ButtonPad {
|
||||||
|
public:
|
||||||
|
enum ButtonType { // must match the buttonMap
|
||||||
|
BTN_UP_LEFT,
|
||||||
|
BTN_UP_RIGHT,
|
||||||
|
BTN_DOWN_RIGHT,
|
||||||
|
BTN_DOWN_LEFT,
|
||||||
|
BTN_RIGHT,
|
||||||
|
BTN_DOWN,
|
||||||
|
BTN_LEFT,
|
||||||
|
BTN_UP,
|
||||||
|
BTN_CROSS,
|
||||||
|
BTN_CIRCLE,
|
||||||
|
BTN_TRIANGLE,
|
||||||
|
BTN_SQUARE,
|
||||||
|
BTN_LTRIGGER,
|
||||||
|
BTN_RTRIGGER,
|
||||||
|
BTN_START,
|
||||||
|
BTN_SELECT,
|
||||||
|
BTN_LAST
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
Button _button[BTN_LAST][SHIFTED_MODE_LAST];
|
||||||
|
uint32 _buttonsChanged[SHIFTED_MODE_LAST]; // normal and shifted
|
||||||
|
uint32 _prevButtonState;
|
||||||
|
ShiftMode _shifted;
|
||||||
|
PspPadMode _padMode;
|
||||||
|
bool _comboMode; // are we in the middle of combos
|
||||||
|
static const uint32 _buttonMap[]; // maps the buttons to their values
|
||||||
|
|
||||||
|
void initButtonsNormalMode();
|
||||||
|
void initButtonsLolMode();
|
||||||
|
void modifyButtonsForCombos(SceCtrlData &pad);
|
||||||
|
void clearButtons();
|
||||||
|
|
||||||
|
public:
|
||||||
|
ButtonPad();
|
||||||
|
bool getEvent(Common::Event &event, PspEvent &pspEvent, SceCtrlData &pad);
|
||||||
|
bool getEventFromButtonState(Common::Event &event, PspEvent &pspEvent, uint32 buttonState);
|
||||||
|
void setShifted(ShiftMode shifted) { _shifted = shifted; }
|
||||||
|
void setPadMode(PspPadMode mode) { _padMode = mode; }
|
||||||
|
bool isButtonDown() { return _prevButtonState; }
|
||||||
|
void initButtons();
|
||||||
|
};
|
||||||
|
|
||||||
|
class Nub {
|
||||||
|
private:
|
||||||
|
Cursor *_cursor; // to enable changing/getting cursor position
|
||||||
|
|
||||||
|
ButtonPad _buttonPad; // private buttonpad for dpad mode
|
||||||
|
ShiftMode _shifted;
|
||||||
|
bool _dpadMode;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Nub() : _shifted(UNSHIFTED), _dpadMode(false) { _buttonPad.initButtons(); }
|
||||||
|
|
||||||
|
void setCursor(Cursor *cursor) { _cursor = cursor; }
|
||||||
|
void setDpadMode(bool active) { _dpadMode = active; }
|
||||||
|
void setShifted(ShiftMode shifted) { _shifted = shifted; }
|
||||||
|
bool isButtonDown();
|
||||||
|
|
||||||
|
bool getEvent(Common::Event &event, PspEvent &pspEvent, SceCtrlData &pad);
|
||||||
|
int32 modifyNubAxisMotion(int32 input);
|
||||||
|
void translateToDpadState(int dpadX, int dpadY, uint32 &buttonState); // convert nub data to dpad data
|
||||||
|
};
|
||||||
|
|
||||||
class InputHandler {
|
class InputHandler {
|
||||||
public:
|
public:
|
||||||
InputHandler() : _cursor(0), _keyboard(0), _prevButtons(0), _lastPadCheckTime(0), _buttonsChanged(0), _dpadX(0), _dpadY(0) {}
|
InputHandler() : _keyboard(0), _cursor(0), _padMode(PAD_MODE_NORMAL), _lastPadCheckTime(0) {}
|
||||||
|
|
||||||
void init();
|
|
||||||
bool getAllInputs(Common::Event &event);
|
|
||||||
void setKeyboard(PSPKeyboard *keyboard) { _keyboard = keyboard; }
|
void setKeyboard(PSPKeyboard *keyboard) { _keyboard = keyboard; }
|
||||||
void setCursor(Cursor *cursor) { _cursor = cursor; }
|
void setCursor(Cursor *cursor) { _cursor = cursor; _nub.setCursor(cursor); }
|
||||||
|
|
||||||
|
void init();
|
||||||
|
bool getAllInputs(Common::Event &event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Cursor *_cursor;
|
|
||||||
PSPKeyboard *_keyboard;
|
PSPKeyboard *_keyboard;
|
||||||
uint32 _prevButtons;
|
Cursor *_cursor;
|
||||||
|
|
||||||
|
Nub _nub;
|
||||||
|
ButtonPad _buttonPad;
|
||||||
|
|
||||||
|
PspPadMode _padMode; // whice mode we're in
|
||||||
|
PspEvent _pendingPspEvent; // an event that can't be handled yet
|
||||||
uint32 _lastPadCheckTime;
|
uint32 _lastPadCheckTime;
|
||||||
uint32 _buttonsChanged;
|
static const char *_padModeText[];
|
||||||
int32 _dpadX, _dpadY;
|
|
||||||
int32 _accelX, _accelY;
|
|
||||||
|
|
||||||
bool getEvent(Common::Event &event, SceCtrlData &pad);
|
bool getEvent(Common::Event &event, SceCtrlData &pad);
|
||||||
bool getDpadEvent(Common::Event &event, SceCtrlData &pad);
|
bool handlePspEvent(Common::Event &event, PspEvent &pspEvent);
|
||||||
bool getButtonEvent(Common::Event &event, SceCtrlData &pad);
|
void handleMouseEvent(Common::Event &event, Common::EventType type, const char *string);
|
||||||
bool getNubEvent(Common::Event &event, SceCtrlData &pad);
|
void handleShiftEvent(ShiftMode shifted);
|
||||||
int32 modifyNubAxisMotion(int32 input);
|
void handleModeSwitchEvent();
|
||||||
Common::KeyCode translateDpad(int x, int y);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* PSP_INPUT_H */
|
#endif /* PSP_INPUT_H */
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
//#define PSP_KB_SHELL /* Need a hack to properly load the keyboard from the PSP shell */
|
//#define PSP_KB_SHELL /* Need a hack to properly load the keyboard from the PSP shell */
|
||||||
|
|
||||||
#ifdef PSP_KB_SHELL
|
#ifdef PSP_KB_SHELL
|
||||||
#define PSP_KB_SHELL_PATH "ms0:/psp/game4xx/scummvm-solid/" /* path to kbd.zip */
|
#define PSP_KB_SHELL_PATH "ms0:/psp/game5xx/scummvm-solid/" /* path to kbd.zip */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
#include "backends/platform/psp/psppixelformat.h"
|
#include "backends/platform/psp/psppixelformat.h"
|
||||||
#include "backends/platform/psp/pspkeyboard.h"
|
#include "backends/platform/psp/pspkeyboard.h"
|
||||||
|
#include "backends/platform/psp/input.h"
|
||||||
#include "common/keyboard.h"
|
#include "common/keyboard.h"
|
||||||
#include "common/fs.h"
|
#include "common/fs.h"
|
||||||
#include "common/unzip.h"
|
#include "common/unzip.h"
|
||||||
|
@ -508,10 +509,11 @@ int PSPKeyboard::loadPngImage(Common::SeekableReadStream *file, Buffer &buffer,
|
||||||
* Uses the state machine.
|
* Uses the state machine.
|
||||||
* returns whether we have an event
|
* returns whether we have an event
|
||||||
*/
|
*/
|
||||||
bool PSPKeyboard::processInput(Common::Event &event, SceCtrlData &pad) {
|
bool PSPKeyboard::processInput(Common::Event &event, PspEvent &pspEvent, SceCtrlData &pad) {
|
||||||
DEBUG_ENTER_FUNC();
|
DEBUG_ENTER_FUNC();
|
||||||
|
|
||||||
bool haveEvent = false; // Whether we have an event for the event manager to process
|
bool haveEvent = false; // Whether we have an event for the event manager to process
|
||||||
|
bool havePspEvent = false;
|
||||||
event.kbd.flags = 0;
|
event.kbd.flags = 0;
|
||||||
|
|
||||||
_buttonsChanged = _prevButtons ^ pad.Buttons;
|
_buttonsChanged = _prevButtons ^ pad.Buttons;
|
||||||
|
@ -529,12 +531,12 @@ bool PSPKeyboard::processInput(Common::Event &event, SceCtrlData &pad) {
|
||||||
event.type = DOWN(PSP_CTRL_START) ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP;
|
event.type = DOWN(PSP_CTRL_START) ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP;
|
||||||
haveEvent = true;
|
haveEvent = true;
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
if (UP(PSP_CTRL_START))
|
if (UP(PSP_CTRL_START))
|
||||||
_state = kInvisible; // Make us invisible if unpressed
|
havePspEvent = true;
|
||||||
}
|
}
|
||||||
// Check for being in state of moving the keyboard onscreen or pressing select
|
// Check for being in state of moving the keyboard onscreen or pressing select
|
||||||
else if (_state == kMove)
|
else if (_state == kMove)
|
||||||
handleMoveState(pad);
|
havePspEvent = handleMoveState(pad);
|
||||||
else if (_state == kDefault)
|
else if (_state == kDefault)
|
||||||
haveEvent = handleDefaultState(event, pad);
|
haveEvent = handleDefaultState(event, pad);
|
||||||
else if (_state == kCornersSelected)
|
else if (_state == kCornersSelected)
|
||||||
|
@ -544,12 +546,16 @@ bool PSPKeyboard::processInput(Common::Event &event, SceCtrlData &pad) {
|
||||||
else if (_state == kLTriggerDown)
|
else if (_state == kLTriggerDown)
|
||||||
handleLTriggerDownState(pad); // Deal with trigger states
|
handleLTriggerDownState(pad); // Deal with trigger states
|
||||||
|
|
||||||
|
if (havePspEvent) {
|
||||||
|
pspEvent.type = PSP_EVENT_SHOW_VIRTUAL_KB; // tell the input handler we're off
|
||||||
|
pspEvent.data = false;
|
||||||
|
}
|
||||||
_prevButtons = pad.Buttons;
|
_prevButtons = pad.Buttons;
|
||||||
|
|
||||||
return haveEvent;
|
return haveEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PSPKeyboard::handleMoveState(SceCtrlData &pad) {
|
bool PSPKeyboard::handleMoveState(SceCtrlData &pad) {
|
||||||
DEBUG_ENTER_FUNC();
|
DEBUG_ENTER_FUNC();
|
||||||
if (UP(PSP_CTRL_SELECT)) {
|
if (UP(PSP_CTRL_SELECT)) {
|
||||||
// Toggle between visible and invisible
|
// Toggle between visible and invisible
|
||||||
|
@ -560,6 +566,9 @@ void PSPKeyboard::handleMoveState(SceCtrlData &pad) {
|
||||||
_state = kDefault;
|
_state = kDefault;
|
||||||
_moved = false; // reset moved flag
|
_moved = false; // reset moved flag
|
||||||
}
|
}
|
||||||
|
if (_state == kInvisible) {
|
||||||
|
return true; // we become invisible
|
||||||
|
}
|
||||||
} else if (DOWN(PSP_DPAD)) { // How we move the KB onscreen
|
} else if (DOWN(PSP_DPAD)) { // How we move the KB onscreen
|
||||||
_moved = true;
|
_moved = true;
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
|
@ -573,6 +582,7 @@ void PSPKeyboard::handleMoveState(SceCtrlData &pad) {
|
||||||
else /* DOWN(PSP_CTRL_RIGHT) */
|
else /* DOWN(PSP_CTRL_RIGHT) */
|
||||||
increaseKeyboardLocationX(5);
|
increaseKeyboardLocationX(5);
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PSPKeyboard::handleDefaultState(Common::Event &event, SceCtrlData &pad) {
|
bool PSPKeyboard::handleDefaultState(Common::Event &event, SceCtrlData &pad) {
|
||||||
|
|
|
@ -29,12 +29,15 @@
|
||||||
#include "common/events.h"
|
#include "common/events.h"
|
||||||
#include "common/stream.h"
|
#include "common/stream.h"
|
||||||
#include "backends/platform/psp/display_client.h"
|
#include "backends/platform/psp/display_client.h"
|
||||||
|
//#include "backends/platform/psp/input.h"
|
||||||
#include <pspctrl.h>
|
#include <pspctrl.h>
|
||||||
|
|
||||||
//number of modes
|
//number of modes
|
||||||
#define MODE_COUNT 4
|
#define MODE_COUNT 4
|
||||||
#define guiStringsSize 8 /* size of guistrings array */
|
#define guiStringsSize 8 /* size of guistrings array */
|
||||||
|
|
||||||
|
class PspEvent;
|
||||||
|
|
||||||
class PSPKeyboard : public DisplayClient {
|
class PSPKeyboard : public DisplayClient {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -58,10 +61,9 @@ public:
|
||||||
void setClean() { _dirty = false; }
|
void setClean() { _dirty = false; }
|
||||||
bool isVisible() const { return _state != kInvisible; } // Check if visible
|
bool isVisible() const { return _state != kInvisible; } // Check if visible
|
||||||
void setVisible(bool val);
|
void setVisible(bool val);
|
||||||
bool processInput(Common::Event &event, SceCtrlData &pad); // Process input
|
bool processInput(Common::Event &event, PspEvent &pspEvent, SceCtrlData &pad); // Process input
|
||||||
void moveTo(const int newX, const int newY); // Move keyboard
|
void moveTo(const int newX, const int newY); // Move keyboard
|
||||||
void render(); // Draw the keyboard onscreen
|
void render(); // Draw the keyboard onscreen
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum CursorDirections {
|
enum CursorDirections {
|
||||||
kUp = 0,
|
kUp = 0,
|
||||||
|
@ -82,7 +84,7 @@ private:
|
||||||
void increaseKeyboardLocationY(int amount);
|
void increaseKeyboardLocationY(int amount);
|
||||||
void convertCursorToXY(CursorDirections cur, int &x, int &y);
|
void convertCursorToXY(CursorDirections cur, int &x, int &y);
|
||||||
|
|
||||||
void handleMoveState(SceCtrlData &pad);
|
bool handleMoveState(SceCtrlData &pad);
|
||||||
bool handleDefaultState(Common::Event &event, SceCtrlData &pad);
|
bool handleDefaultState(Common::Event &event, SceCtrlData &pad);
|
||||||
bool handleCornersSelectedState(Common::Event &event, SceCtrlData &pad);
|
bool handleCornersSelectedState(Common::Event &event, SceCtrlData &pad);
|
||||||
bool getInputChoice(Common::Event &event, SceCtrlData &pad);
|
bool getInputChoice(Common::Event &event, SceCtrlData &pad);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue