Skip to content
Browse files

svn import #55318

  • Loading branch information...
1 parent e68bc32 commit 459a4d4a9fd1ce31db8fa79afd10cc4729b82396 @lousyphreak committed
Showing with 7,730 additions and 539 deletions.
  1. +7 −0 AUTHORS
  2. +1 −1 COPYRIGHT
  3. +2 −2 Makefile.common
  4. +17 −1 NEWS
  5. +9 −1 README
  6. +148 −0 backends/audiocd/audiocd.h
  7. +21 −35 sound/audiocd.cpp → backends/audiocd/default/default-audiocd.cpp
  8. +62 −0 backends/audiocd/default/default-audiocd.h
  9. +138 −0 backends/audiocd/sdl/sdl-audiocd.cpp
  10. +53 −0 backends/audiocd/sdl/sdl-audiocd.h
  11. +22 −1 backends/base-backend.cpp
  12. +11 −1 backends/base-backend.h
  13. +3 −1 backends/events/default/default-events.cpp
  14. +7 −57 backends/{platform/dingux/dingux-events.cpp → events/dinguxsdl/dinguxsdl-events.cpp}
  15. +36 −0 backends/events/dinguxsdl/dinguxsdl-events.h
  16. +472 −0 backends/events/gp2xsdl/gp2xsdl-events.cpp
  17. +59 −0 backends/events/gp2xsdl/gp2xsdl-events.h
  18. +34 −39 backends/{platform/linuxmoto/linuxmoto-events.cpp → events/linuxmotosdl/linuxmotosdl-events.cpp}
  19. +40 −0 backends/events/linuxmotosdl/linuxmotosdl-events.h
  20. +9 −8 backends/{platform/samsungtv/events.cpp → events/samsungtvsdl/samsungtvsdl-events.cpp}
  21. +39 −0 backends/events/samsungtvsdl/samsungtvsdl-events.h
  22. +79 −84 backends/{platform/sdl/events.cpp → events/sdl/sdl-events.cpp}
  23. +135 −0 backends/events/sdl/sdl-events.h
  24. +201 −0 backends/events/symbiansdl/symbiansdl-events.cpp
  25. +59 −0 backends/events/symbiansdl/symbiansdl-events.h
  26. +5 −2 backends/fs/ds/ds-fs-factory.cpp
  27. +1 −4 backends/fs/ds/ds-fs-factory.h
  28. +33 −55 backends/fs/ds/ds-fs.cpp
  29. +9 −7 backends/fs/ds/ds-fs.h
  30. +1 −1 backends/fs/n64/romfsstream.cpp
  31. +2 −2 backends/fs/ps2/ps2-fs-factory.cpp
  32. +2 −2 backends/fs/psp/psp-fs-factory.cpp
  33. +4 −3 backends/fs/psp/psp-fs.cpp
  34. +1 −1 backends/fs/wii/wii-fs-factory.cpp
  35. +3 −3 backends/fs/windows/windows-fs-factory.cpp
  36. +91 −26 backends/{platform/dingux/dingux-graphics.cpp → graphics/dinguxsdl/dinguxsdl-graphics.cpp}
  37. +66 −0 backends/graphics/dinguxsdl/dinguxsdl-graphics.h
  38. +183 −0 backends/graphics/gp2xsdl/gp2xsdl-graphics.cpp
  39. +49 −0 backends/graphics/gp2xsdl/gp2xsdl-graphics.h
  40. +91 −0 backends/graphics/graphics.h
  41. +52 −21 ...nds/{platform/linuxmoto/linuxmoto-graphics.cpp → graphics/linuxmotosdl/linuxmotosdl-graphics.cpp}
  42. +52 −0 backends/graphics/linuxmotosdl/linuxmotosdl-graphics.h
  43. +88 −0 backends/graphics/null/null-graphics.h
  44. +72 −0 backends/graphics/opengl/glerrorcheck.cpp
  45. +38 −0 backends/graphics/opengl/glerrorcheck.h
  46. +195 −0 backends/graphics/opengl/gltexture.cpp
  47. +112 −0 backends/graphics/opengl/gltexture.h
  48. +1,307 −0 backends/graphics/opengl/opengl-graphics.cpp
  49. +294 −0 backends/graphics/opengl/opengl-graphics.h
  50. +684 −0 backends/graphics/openglsdl/openglsdl-graphics.cpp
  51. +119 −0 backends/graphics/openglsdl/openglsdl-graphics.h
  52. +361 −94 backends/{platform/sdl/graphics.cpp → graphics/sdl/sdl-graphics.cpp}
  53. +326 −0 backends/graphics/sdl/sdl-graphics.h
  54. +83 −0 backends/graphics/symbiansdl/symbiansdl-graphics.cpp
  55. +45 −0 backends/graphics/symbiansdl/symbiansdl-graphics.h
  56. +4 −4 backends/keymapper/remap-dialog.cpp
  57. +108 −0 backends/log/log.cpp
  58. +132 −0 backends/log/log.h
  59. +5 −3 backends/midi/coreaudio.cpp
  60. +5 −3 backends/midi/coremidi.cpp
  61. +5 −3 backends/midi/dmedia.cpp
  62. +3 −3 backends/midi/seq.cpp
  63. +5 −3 backends/midi/stmidi.cpp
  64. +2 −2 backends/midi/timidity.cpp
  65. +5 −3 backends/midi/windows.cpp
  66. +129 −0 backends/mixer/doublebuffersdl/doublebuffersdl-mixer.cpp
  67. +69 −0 backends/mixer/doublebuffersdl/doublebuffersdl-mixer.h
  68. +143 −0 backends/mixer/sdl/sdl-mixer.cpp
  69. +100 −0 backends/mixer/sdl/sdl-mixer.h
  70. +78 −0 backends/mixer/symbiansdl/symbiansdl-mixer.cpp
  71. +47 −0 backends/mixer/symbiansdl/symbiansdl-mixer.h
  72. +278 −0 backends/modular-backend.cpp
  73. +178 −0 backends/modular-backend.h
  74. +25 −0 backends/module.mk
  75. +46 −0 backends/mutex/mutex.h
  76. +42 −0 backends/mutex/null/null-mutex.h
  77. +50 −0 backends/mutex/sdl/sdl-mutex.cpp
  78. +43 −0 backends/mutex/sdl/sdl-mutex.h
  79. +0 −2 backends/platform/android/README.build
  80. +19 −1 backends/platform/android/android.cpp
  81. +2 −2 backends/platform/android/video.cpp
  82. +2 −2 backends/platform/android/video.h
  83. +6 −4 backends/platform/dc/Makefile
  84. +15 −0 backends/platform/dc/check_plugin_symbols
  85. +25 −16 backends/platform/dc/dc.h
  86. +102 −7 backends/platform/dc/dcmain.cpp
  87. +2 −1 backends/platform/dc/dreamcast.mk
  88. +6 −0 backends/platform/dc/plugin_head.S
  89. +2 −2 backends/platform/dc/vmsave.cpp
  90. +14 −26 backends/platform/dingux/dingux.cpp
Sorry, we could not display the entire diff because too many files (1,238) changed.
View
7 AUTHORS
@@ -357,10 +357,17 @@ Other contributions
Hungarian:
Alex Bevilacqua
+ George Kormendi
Italian:
Matteo Angelino
+ Norwegian (Bokmaal):
+ Einar Johan T. Somaae
+
+ Brazilian Portuguese:
+ ScummBR Team
+
Russian:
Eugene Sandulenko
View
2 COPYRIGHT
@@ -1,5 +1,5 @@
ScummVM
-Copyright (C) 2001-2010 by the following:
+Copyright (C) 2001-2011 by the following:
If you have contributed to this project then you deserve to be on this
list. Contact us (see: AUTHORS) and we'll add you.
View
4 Makefile.common
@@ -2,7 +2,7 @@
# a list of common object files etc.
#
# $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/Makefile.common $
-# $Id: Makefile.common 54052 2010-11-03 22:57:42Z wjpalenstijn $
+# $Id: Makefile.common 54169 2010-11-09 20:48:23Z sev $
######################################################################
# The default build target: just build the scummvm executable
@@ -23,10 +23,10 @@ MODULES := test tools base $(MODULES)
# After the game specific modules follow the shared modules
MODULES += \
gui \
- sound \
backends \
engines \
graphics \
+ sound \
common \
po
View
18 NEWS
@@ -5,6 +5,9 @@ For a more comprehensive changelog for the latest experimental SVN code, see:
- Added support for Backyard Baseball.
- Added support for Backyard Baseball 2001.
+ General
+ - Added Norwegian (Bokmaal) translation.
+
Drascula:
- Added German and French subtitles in the Von Braun cutscene (#3069981:
no subtitles in scene with "von Braun").
@@ -15,11 +18,24 @@ For a more comprehensive changelog for the latest experimental SVN code, see:
SCUMM:
- Improved support for FM-TOWNS versions of games.
+
+ PSP:
+ - Added image viewer
+
+1.2.1 (2010-12-19)
+ General
+ - Add Hungarian translation.
+ - Add Brazilian Portuguese translation.
+
+ Cruise:
+ - Fixed a problem with Raoul appearing when examining the Book
-1.2.1 (2010-??-??)
Groovie:
- Fixed a regression that made the Russian version of T7G crash.
+ Lure:
+ - Fixed several NPC movement bugs
+
1.2.0 (2010-10-15)
New Games:
- Added support for Fascination.
View
10 README
@@ -1,5 +1,5 @@
ScummVM README
-Last updated: $Date: 2010-11-05 11:53:37 +0100 (Fr, 05 Nov 2010) $
+Last updated: $Date: 2010-11-26 13:37:24 +0100 (Fr, 26 Nov 2010) $
------------------------------------------------------------------------
For more information, compatibility lists, details on donating, the latest
@@ -2004,6 +2004,14 @@ Flight of the Amazon Queen adds the following non-standard keywords:
music_mute bool If true, music is muted
sfx_mute bool If true, sound effects are muted
+King's Quest VI Windows adds the following non-standard keywords:
+
+ windows_cursors bool If true, the original unscaled black and white
+ Windows cursors are used instead of the DOS
+ ones. If false, the DOS cursors are used in the
+ Windows version, upscaled to match the rest of
+ the upscaled graphics
+
Simon the Sorcerer 1 and 2 add the following non-standard keywords:
music_mute bool If true, music is muted
View
148 backends/audiocd/audiocd.h
@@ -0,0 +1,148 @@
+/* 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.
+ *
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/audiocd/audiocd.h $
+ * $Id: audiocd.h 54147 2010-11-08 22:53:36Z fingolfin $
+ *
+ */
+
+#ifndef BACKENDS_AUDIOCD_ABSTRACT_H
+#define BACKENDS_AUDIOCD_ABSTRACT_H
+
+#include "common/scummsys.h"
+#include "common/noncopyable.h"
+
+/**
+* Abstract Audio CD manager class. Subclasses implement the actual
+* functionality.
+*/
+class AudioCDManager : Common::NonCopyable {
+public:
+ virtual ~AudioCDManager() {}
+
+ /**
+ * A structure containing the current playback information
+ */
+ struct Status {
+ bool playing;
+ int track;
+ int start;
+ int duration;
+ int numLoops;
+ int volume;
+ int balance;
+ };
+
+ /**
+ * @name Emulated playback functions
+ * Engines should call these functions. Not all platforms
+ * support cd playback, and these functions should try to
+ * emulate it.
+ */
+ //@{
+
+ /**
+ * Start audio CD playback
+ * @param track the track to play.
+ * @param num_loops how often playback should be repeated (-1 = infinitely often).
+ * @param start_frame the frame at which playback should start (75 frames = 1 second).
+ * @param duration the number of frames to play.
+ * @param only_emulate determines if the track should be emulated only
+ */
+ virtual void play(int track, int numLoops, int startFrame, int duration, bool only_emulate = false) = 0;
+
+ /**
+ * Get if audio is being played.
+ * @return true if CD or emulated audio is playing
+ */
+ virtual bool isPlaying() const = 0;
+
+ /**
+ * Set the audio volume
+ */
+ virtual void setVolume(byte volume) = 0;
+
+ /**
+ * Set the speakers balance
+ */
+ virtual void setBalance(int8 balance) = 0;
+
+ /**
+ * Stop CD or emulated audio playback.
+ */
+ virtual void stop() = 0;
+
+ /**
+ * Update CD or emulated audio status.
+ */
+ virtual void update() = 0;
+
+ /**
+ * Get the playback status.
+ * @return a Status struct with playback data.
+ */
+ virtual Status getStatus() const = 0;
+
+ //@}
+
+
+ /**
+ * @name Real CD audio methods
+ * These functions should be called from the emulated
+ * ones if they can't emulate the audio playback.
+ */
+ //@{
+
+ /**
+ * Initialise the specified CD drive for audio playback.
+ * @param drive the drive id
+ * @return true if the CD drive was inited succesfully
+ */
+ virtual bool openCD(int drive) = 0;
+
+ /**
+ * Poll CD status.
+ * @return true if CD audio is playing
+ */
+ virtual bool pollCD() const = 0;
+
+ /**
+ * Start CD audio playback.
+ * @param track the track to play.
+ * @param num_loops how often playback should be repeated (-1 = infinitely often).
+ * @param start_frame the frame at which playback should start (75 frames = 1 second).
+ * @param duration the number of frames to play.
+ */
+ virtual void playCD(int track, int num_loops, int start_frame, int duration) = 0;
+
+ /**
+ * Stop CD audio playback.
+ */
+ virtual void stopCD() = 0;
+
+ /**
+ * Update CD audio status.
+ */
+ virtual void updateCD() = 0;
+
+ //@}
+};
+
+#endif
View
56 sound/audiocd.cpp → backends/audiocd/default/default-audiocd.cpp
@@ -18,38 +18,29 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/sound/audiocd.cpp $
- * $Id: audiocd.cpp 53160 2010-10-12 02:18:11Z jvprat $
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/audiocd/default/default-audiocd.cpp $
+ * $Id: default-audiocd.cpp 54147 2010-11-08 22:53:36Z fingolfin $
*
*/
-#include "sound/audiocd.h"
+#include "backends/audiocd/default/default-audiocd.h"
#include "sound/audiostream.h"
-#include "sound/decoders/mp3.h"
-#include "sound/decoders/vorbis.h"
-#include "sound/decoders/flac.h"
-#include "engines/engine.h"
-#include "common/util.h"
#include "common/system.h"
-DECLARE_SINGLETON(Audio::AudioCDManager)
-
-namespace Audio {
-
-AudioCDManager::AudioCDManager() {
+DefaultAudioCDManager::DefaultAudioCDManager() {
_cd.playing = false;
_cd.track = 0;
_cd.start = 0;
_cd.duration = 0;
_cd.numLoops = 0;
- _cd.volume = Mixer::kMaxChannelVolume;
+ _cd.volume = Audio::Mixer::kMaxChannelVolume;
_cd.balance = 0;
_mixer = g_system->getMixer();
_emulating = false;
assert(_mixer);
}
-void AudioCDManager::play(int track, int numLoops, int startFrame, int duration, bool only_emulate) {
+void DefaultAudioCDManager::play(int track, int numLoops, int startFrame, int duration, bool only_emulate) {
if (numLoops != 0 || startFrame != 0) {
_cd.track = track;
_cd.numLoops = numLoops;
@@ -65,14 +56,14 @@ void AudioCDManager::play(int track, int numLoops, int startFrame, int duration,
Audio::SeekableAudioStream *stream = 0;
for (int i = 0; !stream && i < 2; ++i)
- stream = SeekableAudioStream::openStreamFile(trackName[i]);
+ stream = Audio::SeekableAudioStream::openStreamFile(trackName[i]);
// Stop any currently playing emulated track
_mixer->stopHandle(_handle);
if (stream != 0) {
- Timestamp start = Timestamp(0, startFrame, 75);
- Timestamp end = duration ? Timestamp(0, startFrame + duration, 75) : stream->getLength();
+ Audio::Timestamp start = Audio::Timestamp(0, startFrame, 75);
+ Audio::Timestamp end = duration ? Audio::Timestamp(0, startFrame + duration, 75) : stream->getLength();
/*
FIXME: Seems numLoops == 0 and numLoops == 1 both indicate a single repetition,
@@ -80,39 +71,38 @@ void AudioCDManager::play(int track, int numLoops, int startFrame, int duration,
repetitions. Finally, -1 means infinitely many
*/
_emulating = true;
- _mixer->playStream(Mixer::kMusicSoundType, &_handle,
- makeLoopingAudioStream(stream, start, end, (numLoops < 1) ? numLoops + 1 : numLoops), -1, _cd.volume, _cd.balance);
-
+ _mixer->playStream(Audio::Mixer::kMusicSoundType, &_handle,
+ Audio::makeLoopingAudioStream(stream, start, end, (numLoops < 1) ? numLoops + 1 : numLoops), -1, _cd.volume, _cd.balance);
} else {
_emulating = false;
if (!only_emulate)
- g_system->playCD(track, numLoops, startFrame, duration);
+ playCD(track, numLoops, startFrame, duration);
}
}
}
-void AudioCDManager::stop() {
+void DefaultAudioCDManager::stop() {
if (_emulating) {
// Audio CD emulation
_mixer->stopHandle(_handle);
_emulating = false;
} else {
// Real Audio CD
- g_system->stopCD();
+ stopCD();
}
}
-bool AudioCDManager::isPlaying() const {
+bool DefaultAudioCDManager::isPlaying() const {
if (_emulating) {
// Audio CD emulation
return _mixer->isSoundHandleActive(_handle);
} else {
// Real Audio CD
- return g_system->pollCD();
+ return pollCD();
}
}
-void AudioCDManager::setVolume(byte volume) {
+void DefaultAudioCDManager::setVolume(byte volume) {
_cd.volume = volume;
if (_emulating) {
// Audio CD emulation
@@ -128,7 +118,7 @@ void AudioCDManager::setVolume(byte volume) {
}
}
-void AudioCDManager::setBalance(int8 balance) {
+void DefaultAudioCDManager::setBalance(int8 balance) {
_cd.balance = balance;
if (_emulating) {
// Audio CD emulation
@@ -144,7 +134,7 @@ void AudioCDManager::setBalance(int8 balance) {
}
}
-void AudioCDManager::updateCD() {
+void DefaultAudioCDManager::update() {
if (_emulating) {
// Check whether the audio track stopped playback
if (!_mixer->isSoundHandleActive(_handle)) {
@@ -156,16 +146,12 @@ void AudioCDManager::updateCD() {
_emulating = false;
}
} else {
- g_system->updateCD();
+ updateCD();
}
}
-AudioCDManager::Status AudioCDManager::getStatus() const {
- // TODO: This could be improved for "real" CD playback.
- // But to do that, we would have to extend the OSystem interface.
+DefaultAudioCDManager::Status DefaultAudioCDManager::getStatus() const {
Status info = _cd;
info.playing = isPlaying();
return info;
}
-
-} // End of namespace Audio
View
62 backends/audiocd/default/default-audiocd.h
@@ -0,0 +1,62 @@
+/* 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.
+ *
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/audiocd/default/default-audiocd.h $
+ * $Id: default-audiocd.h 54147 2010-11-08 22:53:36Z fingolfin $
+ *
+ */
+
+#ifndef BACKENDS_AUDIOCD_DEFAULT_H
+#define BACKENDS_AUDIOCD_DEFAULT_H
+
+#include "backends/audiocd/audiocd.h"
+#include "sound/mixer.h"
+
+/**
+ * The default audio cd manager. Implements emulation of audio cd playback.
+ */
+class DefaultAudioCDManager : public AudioCDManager {
+public:
+ DefaultAudioCDManager();
+ virtual ~DefaultAudioCDManager() {}
+
+ void play(int track, int numLoops, int startFrame, int duration, bool only_emulate = false);
+ void stop();
+ bool isPlaying() const;
+ void setVolume(byte volume);
+ void setBalance(int8 balance);
+ void update();
+ virtual Status getStatus() const; // Subclasses should override for better status results
+
+ virtual bool openCD(int drive) { return false; }
+ virtual void updateCD() {}
+ virtual bool pollCD() const { return false; }
+ virtual void playCD(int track, int num_loops, int start_frame, int duration) {}
+ virtual void stopCD() {}
+
+protected:
+ Audio::SoundHandle _handle;
+ bool _emulating;
+
+ Status _cd;
+ Audio::Mixer *_mixer;
+};
+
+#endif
View
138 backends/audiocd/sdl/sdl-audiocd.cpp
@@ -0,0 +1,138 @@
+/* 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.
+ *
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/audiocd/sdl/sdl-audiocd.cpp $
+ * $Id: sdl-audiocd.cpp 54575 2010-11-29 16:35:29Z fingolfin $
+ *
+ */
+
+#include "common/scummsys.h"
+
+#if defined(SDL_BACKEND)
+
+#include "backends/audiocd/sdl/sdl-audiocd.h"
+
+SdlAudioCDManager::SdlAudioCDManager()
+ :
+ _cdrom(0),
+ _cdTrack(0),
+ _cdNumLoops(0),
+ _cdStartFrame(0),
+ _cdDuration(0),
+ _cdEndTime(0),
+ _cdStopTime(0) {
+
+}
+
+SdlAudioCDManager::~SdlAudioCDManager() {
+ if (_cdrom) {
+ SDL_CDStop(_cdrom);
+ SDL_CDClose(_cdrom);
+ }
+}
+
+bool SdlAudioCDManager::openCD(int drive) {
+ if (SDL_InitSubSystem(SDL_INIT_CDROM) == -1)
+ _cdrom = NULL;
+ else {
+ _cdrom = SDL_CDOpen(drive);
+ // Did it open? Check if _cdrom is NULL
+ if (!_cdrom) {
+ warning("Couldn't open drive: %s", SDL_GetError());
+ } else {
+ _cdNumLoops = 0;
+ _cdStopTime = 0;
+ _cdEndTime = 0;
+ }
+ }
+
+ return (_cdrom != NULL);
+}
+
+void SdlAudioCDManager::stopCD() {
+ // Stop CD Audio in 1/10th of a second
+ _cdStopTime = SDL_GetTicks() + 100;
+ _cdNumLoops = 0;
+}
+
+void SdlAudioCDManager::playCD(int track, int num_loops, int start_frame, int duration) {
+ if (!num_loops && !start_frame)
+ return;
+
+ if (!_cdrom)
+ return;
+
+ if (duration > 0)
+ duration += 5;
+
+ _cdTrack = track;
+ _cdNumLoops = num_loops;
+ _cdStartFrame = start_frame;
+
+ SDL_CDStatus(_cdrom);
+ if (start_frame == 0 && duration == 0)
+ SDL_CDPlayTracks(_cdrom, track, 0, 1, 0);
+ else
+ SDL_CDPlayTracks(_cdrom, track, start_frame, 0, duration);
+ _cdDuration = duration;
+ _cdStopTime = 0;
+ _cdEndTime = SDL_GetTicks() + _cdrom->track[track].length * 1000 / CD_FPS;
+}
+
+bool SdlAudioCDManager::pollCD() const {
+ if (!_cdrom)
+ return false;
+
+ return (_cdNumLoops != 0 && (SDL_GetTicks() < _cdEndTime || SDL_CDStatus(_cdrom) == CD_PLAYING));
+}
+
+void SdlAudioCDManager::updateCD() {
+ if (!_cdrom)
+ return;
+
+ if (_cdStopTime != 0 && SDL_GetTicks() >= _cdStopTime) {
+ SDL_CDStop(_cdrom);
+ _cdNumLoops = 0;
+ _cdStopTime = 0;
+ return;
+ }
+
+ if (_cdNumLoops == 0 || SDL_GetTicks() < _cdEndTime)
+ return;
+
+ if (_cdNumLoops != 1 && SDL_CDStatus(_cdrom) != CD_STOPPED) {
+ // Wait another second for it to be done
+ _cdEndTime += 1000;
+ return;
+ }
+
+ if (_cdNumLoops > 0)
+ _cdNumLoops--;
+
+ if (_cdNumLoops != 0) {
+ if (_cdStartFrame == 0 && _cdDuration == 0)
+ SDL_CDPlayTracks(_cdrom, _cdTrack, 0, 1, 0);
+ else
+ SDL_CDPlayTracks(_cdrom, _cdTrack, _cdStartFrame, 0, _cdDuration);
+ _cdEndTime = SDL_GetTicks() + _cdrom->track[_cdTrack].length * 1000 / CD_FPS;
+ }
+}
+
+#endif
View
53 backends/audiocd/sdl/sdl-audiocd.h
@@ -0,0 +1,53 @@
+/* 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.
+ *
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/audiocd/sdl/sdl-audiocd.h $
+ * $Id: sdl-audiocd.h 54572 2010-11-29 16:16:50Z fingolfin $
+ *
+ */
+
+#ifndef BACKENDS_AUDIOCD_SDL_H
+#define BACKENDS_AUDIOCD_SDL_H
+
+#include "backends/audiocd/default/default-audiocd.h"
+
+#include "backends/platform/sdl/sdl-sys.h"
+
+/**
+ * The SDL audio cd manager. Implements real audio cd playback.
+ */
+class SdlAudioCDManager : public DefaultAudioCDManager {
+public:
+ SdlAudioCDManager();
+ virtual ~SdlAudioCDManager();
+
+protected:
+ virtual bool openCD(int drive);
+ virtual void updateCD();
+ virtual bool pollCD() const;
+ virtual void playCD(int track, int num_loops, int start_frame, int duration);
+ virtual void stopCD();
+
+ SDL_CD *_cdrom;
+ int _cdTrack, _cdNumLoops, _cdStartFrame, _cdDuration;
+ uint32 _cdEndTime, _cdStopTime;
+};
+
+#endif
View
23 backends/base-backend.cpp
@@ -19,12 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/base-backend.cpp $
- * $Id: base-backend.cpp 45778 2009-11-09 15:13:59Z wjpalenstijn $
+ * $Id: base-backend.cpp 54147 2010-11-08 22:53:36Z fingolfin $
*
*/
#include "backends/base-backend.h"
#include "backends/events/default/default-events.h"
+#include "backends/audiocd/default/default-audiocd.h"
#include "gui/message.h"
void BaseBackend::displayMessageOnOSD(const char *msg) {
@@ -71,6 +72,14 @@ void BaseBackend::fillScreen(uint32 col) {
#define DEFAULT_CONFIG_FILE "scummvm.ini"
#endif
+BaseBackend::BaseBackend() {
+ _audiocdManager = 0;
+}
+
+BaseBackend::~BaseBackend() {
+ delete _audiocdManager;
+}
+
Common::SeekableReadStream *BaseBackend::createConfigReadStream() {
Common::FSNode file(DEFAULT_CONFIG_FILE);
return file.createReadStream();
@@ -84,3 +93,15 @@ Common::WriteStream *BaseBackend::createConfigWriteStream() {
return file.createWriteStream();
#endif
}
+
+AudioCDManager *BaseBackend::getAudioCDManager() {
+ if (!_audiocdManager)
+ _audiocdManager = new DefaultAudioCDManager();
+ return _audiocdManager;
+}
+
+void BaseBackend::resetGraphicsScale() {
+ // As a hack, we use 0 here. Backends should override this method
+ // and provide their own.
+ setGraphicsMode(0);
+}
View
12 backends/base-backend.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/base-backend.h $
- * $Id: base-backend.h 42718 2009-07-25 00:59:03Z lordhoto $
+ * $Id: base-backend.h 54147 2010-11-08 22:53:36Z fingolfin $
*
*/
@@ -31,12 +31,22 @@
class BaseBackend : public OSystem, Common::EventSource {
public:
+ BaseBackend();
+ ~BaseBackend();
+
virtual Common::EventManager *getEventManager();
virtual void displayMessageOnOSD(const char *msg);
virtual void fillScreen(uint32 col);
virtual Common::SeekableReadStream *createConfigReadStream();
virtual Common::WriteStream *createConfigWriteStream();
+
+ virtual AudioCDManager *getAudioCDManager();
+
+ virtual void resetGraphicsScale();
+
+protected:
+ AudioCDManager *_audiocdManager;
};
View
4 backends/events/default/default-events.cpp
@@ -19,10 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/events/default/default-events.cpp $
- * $Id: default-events.cpp 52993 2010-10-03 14:59:36Z wjpalenstijn $
+ * $Id: default-events.cpp 54573 2010-11-29 16:18:43Z fingolfin $
*
*/
+#include "common/scummsys.h"
+
#if !defined(DISABLE_DEFAULT_EVENTMANAGER)
#include "common/system.h"
View
64 backends/platform/dingux/dingux-events.cpp → ...nds/events/dinguxsdl/dinguxsdl-events.cpp
@@ -18,16 +18,16 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/platform/dingux/dingux-events.cpp $
- * $Id: dingux-events.cpp 52894 2010-09-25 21:54:41Z hkz $
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/events/dinguxsdl/dinguxsdl-events.cpp $
+ * $Id: dinguxsdl-events.cpp 54584 2010-11-29 18:48:43Z lordhoto $
*
*/
-#include "backends/platform/dingux/dingux.h"
+#include "common/scummsys.h"
-#include "graphics/scaler/aspect.h" // for aspect2Real
+#if defined(DINGUX)
-#if defined (DINGUX)
+#include "backends/events/dinguxsdl/dinguxsdl-events.h"
#define PAD_UP SDLK_UP
#define PAD_DOWN SDLK_DOWN
@@ -42,24 +42,7 @@
#define TRIG_L SDLK_TAB
#define TRIG_R SDLK_BACKSPACE
-static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode) {
- if (key >= SDLK_F1 && key <= SDLK_F9) {
- return key - SDLK_F1 + Common::ASCII_F1;
- } else if (key >= SDLK_KP0 && key <= SDLK_KP9) {
- return key - SDLK_KP0 + '0';
- } else if (key >= SDLK_UP && key <= SDLK_PAGEDOWN) {
- return key;
- } else if (unicode) {
- return unicode;
- } else if (key >= 'a' && key <= 'z' && (mod & KMOD_SHIFT)) {
- return key & ~0x20;
- } else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) {
- return 0;
- }
- return key;
-}
-
-bool OSystem_SDL_Dingux::remapKey(SDL_Event &ev, Common::Event &event) {
+bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
if (ev.key.keysym.sym == PAD_UP) {
if (ev.type == SDL_KEYDOWN) {
_km.y_vel = -1;
@@ -179,37 +162,4 @@ bool OSystem_SDL_Dingux::remapKey(SDL_Event &ev, Common::Event &event) {
return false;
}
-void OSystem_SDL_Dingux::fillMouseEvent(Common::Event &event, int x, int y) {
- if (_videoMode.mode == GFX_HALF && !_overlayVisible) {
- event.mouse.x = x * 2;
- event.mouse.y = y * 2;
- } else {
- event.mouse.x = x;
- event.mouse.y = y;
- }
-
- // Update the "keyboard mouse" coords
- _km.x = x;
- _km.y = y;
-
- // Adjust for the screen scaling
- if (!_overlayVisible) {
- event.mouse.x /= _videoMode.scaleFactor;
- event.mouse.y /= _videoMode.scaleFactor;
- if (_videoMode.aspectRatioCorrection)
- event.mouse.y = aspect2Real(event.mouse.y);
- }
-}
-
-void OSystem_SDL_Dingux::warpMouse(int x, int y) {
- if (_mouseCurState.x != x || _mouseCurState.y != y) {
- if (_videoMode.mode == GFX_HALF && !_overlayVisible) {
- x = x / 2;
- y = y / 2;
- }
- }
- OSystem_SDL::warpMouse(x, y);
-}
-
-#endif
-
+#endif /* DINGUX */
View
36 backends/events/dinguxsdl/dinguxsdl-events.h
@@ -0,0 +1,36 @@
+/* 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.
+ *
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/events/dinguxsdl/dinguxsdl-events.h $
+ * $Id: dinguxsdl-events.h 54584 2010-11-29 18:48:43Z lordhoto $
+ *
+ */
+
+#ifndef BACKENDS_EVENTS_SDL_DINGUX_H
+#define BACKENDS_EVENTS_SDL_DINGUX_H
+
+#include "backends/events/sdl/sdl-events.h"
+
+class DINGUXSdlEventSource : public SdlEventSource {
+protected:
+ bool remapKey(SDL_Event &ev, Common::Event &event);
+};
+
+#endif /* BACKENDS_EVENTS_SDL_DINGUX_H */
View
472 backends/events/gp2xsdl/gp2xsdl-events.cpp
@@ -0,0 +1,472 @@
+/* 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.
+ *
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/events/gp2xsdl/gp2xsdl-events.cpp $
+ * $Id: gp2xsdl-events.cpp 54584 2010-11-29 18:48:43Z lordhoto $
+ *
+ */
+
+#include "common/scummsys.h"
+
+#if defined(GP2X) || defined(GP2XWIZ)
+
+#include "backends/events/gp2xsdl/gp2xsdl-events.h"
+#if defined(GP2X)
+#include "backends/platform/gp2x/gp2x-hw.h"
+#include "backends/graphics/gp2xsdl/gp2xsdl-graphics.h"
+#else
+#include "backends/platform/gp2xwiz/gp2xwiz-hw.h"
+#endif
+
+#include "backends/platform/sdl/sdl.h"
+
+// FIXME move joystick defines out and replace with confile file options
+// we should really allow users to map any key to a joystick button using the keymapper.
+#define JOY_DEADZONE 2200
+
+#define JOY_XAXIS 0
+#define JOY_YAXIS 1
+
+/* Quick default button states for modifiers. */
+int BUTTON_STATE_L = false;
+
+enum {
+ /* DPAD/Stick */
+ BUTTON_UP = 0,
+ BUTTON_UPLEFT = 1,
+ BUTTON_LEFT = 2,
+ BUTTON_DOWNLEFT = 3,
+ BUTTON_DOWN = 4,
+ BUTTON_DOWNRIGHT = 5,
+ BUTTON_RIGHT = 6,
+ BUTTON_UPRIGHT = 7,
+ /* Joystick Buttons */
+ BUTTON_MENU = 8, // Start on F100 GP2X
+ BUTTON_SELECT = 9,
+ BUTTON_L = 10,
+ BUTTON_R = 11,
+ BUTTON_A = 12,
+ BUTTON_B = 13,
+ BUTTON_X = 14,
+ BUTTON_Y = 15,
+ BUTTON_VOLUP = 16,
+ BUTTON_VOLDOWN = 17,
+ BUTTON_CLICK = 18
+};
+
+enum {
+ /* Unused Joystick Buttons on the GP2X */
+ BUTTON_HOME = 51,
+ BUTTON_HOLD = 52,
+ BUTTON_HELP = 53,
+ BUTTON_HELP2 = 54
+};
+
+enum {
+ /* Touchscreen TapMode */
+ TAPMODE_LEFT = 0,
+ TAPMODE_RIGHT = 1,
+ TAPMODE_HOVER = 2
+};
+
+GP2XSdlEventSource::GP2XSdlEventSource()
+ : _buttonStateL(false){
+
+}
+
+void GP2XSdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) {
+ event.kbd.flags = 0;
+
+ if (mod & KMOD_SHIFT)
+ event.kbd.flags |= Common::KBD_SHIFT;
+ if (mod & KMOD_ALT)
+ event.kbd.flags |= Common::KBD_ALT;
+ if (mod & KMOD_CTRL)
+ event.kbd.flags |= Common::KBD_CTRL;
+
+ // Sticky flags
+ if (mod & KMOD_NUM)
+ event.kbd.flags |= Common::KBD_NUM;
+ if (mod & KMOD_CAPS)
+ event.kbd.flags |= Common::KBD_CAPS;
+}
+
+void GP2XSdlEventSource::moveStick() {
+ bool stickBtn[32];
+
+ memcpy(stickBtn, _stickBtn, sizeof(stickBtn));
+
+ if ((stickBtn[0])||(stickBtn[2])||(stickBtn[4])||(stickBtn[6]))
+ stickBtn[1] = stickBtn[3] = stickBtn[5] = stickBtn[7] = 0;
+
+ if ((stickBtn[1])||(stickBtn[2])||(stickBtn[3])) {
+ if (_km.x_down_count!=2) {
+ _km.x_vel = -1;
+ _km.x_down_count = 1;
+ } else
+ _km.x_vel = -4;
+ } else if ((stickBtn[5])||(stickBtn[6])||(stickBtn[7])) {
+ if (_km.x_down_count!=2) {
+ _km.x_vel = 1;
+ _km.x_down_count = 1;
+ } else
+ _km.x_vel = 4;
+ } else {
+ _km.x_vel = 0;
+ _km.x_down_count = 0;
+ }
+
+ if ((stickBtn[0])||(stickBtn[1])||(stickBtn[7])) {
+ if (_km.y_down_count!=2) {
+ _km.y_vel = -1;
+ _km.y_down_count = 1;
+ } else
+ _km.y_vel = -4;
+ } else if ((stickBtn[3])||(stickBtn[4])||(stickBtn[5])) {
+ if (_km.y_down_count!=2) {
+ _km.y_vel = 1;
+ _km.y_down_count = 1;
+ } else
+ _km.y_vel = 4;
+ } else {
+ _km.y_vel = 0;
+ _km.y_down_count = 0;
+ }
+}
+
+/* GP2X Input mappings.
+Single Button
+
+Movement:
+
+GP2X_BUTTON_UP Cursor Up
+GP2X_BUTTON_DOWN Cursor Down
+GP2X_BUTTON_LEFT Cursor Left
+GP2X_BUTTON_RIGHT Cursor Right
+
+GP2X_BUTTON_UPLEFT Cursor Up Left
+GP2X_BUTTON_UPRIGHT Cursor Up Right
+GP2X_BUTTON_DOWNLEFT Cursor Down Left
+GP2X_BUTTON_DOWNRIGHT Cursor Down Right
+
+Button Emulation:
+
+GP2X_BUTTON_CLICK Left Mouse Click (GP2X only)
+GP2X_BUTTON_A . (Period)
+GP2X_BUTTON_B Left Mouse Click
+GP2X_BUTTON_Y Space Bar
+GP2X_BUTTON_X Right Mouse Click
+GP2X_BUTTON_L Combo Modifier (Left Trigger)
+GP2X_BUTTON_R Return (Right Trigger)
+GP2X_BUTTON_MENU F5 (Game Menu)
+GP2X_BUTTON_SELECT Escape
+GP2X_BUTTON_VOLUP /dev/mixer Global Volume Up
+GP2X_BUTTON_VOLDOWN /dev/mixer Global Volume Down
+
+Combos:
+
+GP2X_BUTTON_VOLUP & GP2X_BUTTON_VOLDOWN 0 (For Monkey 2 CP) or Virtual Keyboard if enabled
+GP2X_BUTTON_L & GP2X_BUTTON_SELECT Common::EVENT_QUIT (Calls Sync() to make sure SD is flushed)
+GP2X_BUTTON_L & GP2X_BUTTON_MENU Common::EVENT_MAINMENU (ScummVM Global Main Menu)
+GP2X_BUTTON_L & GP2X_BUTTON_A Common::EVENT_PREDICTIVE_DIALOG for predictive text entry box (AGI games)
+GP2X_BUTTON_L & GP2X_BUTTON_Y Toggles setZoomOnMouse() for larger then 320*240 games to scale to the point + raduis. (GP2X only)
+*/
+
+bool GP2XSdlEventSource::handleKeyDown(SDL_Event &ev, Common::Event &event) {
+ SDLModToOSystemKeyFlags(SDL_GetModState(), event);
+
+ if (remapKey(ev, event))
+ return true;
+
+ event.type = Common::EVENT_KEYDOWN;
+ event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
+ event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
+
+ return true;
+}
+
+bool GP2XSdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
+
+ _stickBtn[ev.jbutton.button] = 1;
+ event.kbd.flags = 0;
+
+ switch (ev.jbutton.button) {
+ case BUTTON_UP:
+ case BUTTON_UPLEFT:
+ case BUTTON_LEFT:
+ case BUTTON_DOWNLEFT:
+ case BUTTON_DOWN:
+ case BUTTON_DOWNRIGHT:
+ case BUTTON_RIGHT:
+ case BUTTON_UPRIGHT:
+ moveStick();
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+ break;
+ case BUTTON_B:
+ case BUTTON_CLICK:
+ if (BUTTON_STATE_L == true) {
+ ((GP2XSdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->toggleZoomOnMouse();
+ fillMouseEvent(event, _km.x, _km.y);
+ } else {
+ event.type = Common::EVENT_LBUTTONDOWN;
+ fillMouseEvent(event, _km.x, _km.y);
+ }
+ break;
+ case BUTTON_X:
+ event.type = Common::EVENT_RBUTTONDOWN;
+ fillMouseEvent(event, _km.x, _km.y);
+ break;
+ case BUTTON_L:
+ BUTTON_STATE_L = true;
+ break;
+ case BUTTON_R:
+ event.type = Common::EVENT_KEYDOWN;
+ if (BUTTON_STATE_L == true) {
+#ifdef ENABLE_VKEYBD
+ event.kbd.keycode = Common::KEYCODE_F7;
+ event.kbd.ascii = mapKey(SDLK_F7, ev.key.keysym.mod, 0);
+#else
+ event.kbd.keycode = Common::KEYCODE_0;
+ event.kbd.ascii = mapKey(SDLK_0, ev.key.keysym.mod, 0);
+#endif
+ } else {
+ event.kbd.keycode = Common::KEYCODE_RETURN;
+ event.kbd.ascii = mapKey(SDLK_RETURN, ev.key.keysym.mod, 0);
+ }
+ break;
+ case BUTTON_SELECT:
+ case BUTTON_HOME:
+ event.type = Common::EVENT_KEYDOWN;
+ if (BUTTON_STATE_L == true) {
+ event.type = Common::EVENT_QUIT;
+ } else {
+ event.kbd.keycode = Common::KEYCODE_ESCAPE;
+ event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
+ }
+ break;
+ case BUTTON_A:
+ event.type = Common::EVENT_KEYDOWN;
+ if (BUTTON_STATE_L == true) {
+ event.type = Common::EVENT_PREDICTIVE_DIALOG;
+ } else {
+ event.kbd.keycode = Common::KEYCODE_PERIOD;
+ event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
+ }
+ break;
+ case BUTTON_Y:
+ event.type = Common::EVENT_KEYDOWN;
+ if (BUTTON_STATE_L == true) {
+ GPH::ToggleTapMode();
+ if (GPH::tapmodeLevel == TAPMODE_LEFT) {
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Left Click");
+ } else if (GPH::tapmodeLevel == TAPMODE_RIGHT) {
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Right Click");
+ } else if (GPH::tapmodeLevel == TAPMODE_HOVER) {
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Hover (No Click)");
+ }
+ } else {
+ event.kbd.keycode = Common::KEYCODE_SPACE;
+ event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
+ }
+ break;
+ case BUTTON_MENU:
+ case BUTTON_HELP:
+ event.type = Common::EVENT_KEYDOWN;
+ if (BUTTON_STATE_L == true) {
+ event.type = Common::EVENT_MAINMENU;
+ } else {
+ event.kbd.keycode = Common::KEYCODE_F5;
+ event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
+ }
+ break;
+ case BUTTON_VOLUP:
+ GP2X_HW::mixerMoveVolume(2);
+ if (GP2X_HW::volumeLevel == 100) {
+ g_system->displayMessageOnOSD("Maximum Volume");
+ } else {
+ g_system->displayMessageOnOSD("Increasing Volume");
+ }
+ break;
+
+ case BUTTON_VOLDOWN:
+ GP2X_HW::mixerMoveVolume(1);
+ if (GP2X_HW::volumeLevel == 0) {
+ g_system->displayMessageOnOSD("Minimal Volume");
+ } else {
+ g_system->displayMessageOnOSD("Decreasing Volume");
+ }
+ break;
+ case BUTTON_HOLD:
+ event.type = Common::EVENT_QUIT;
+ break;
+ case BUTTON_HELP2:
+ GPH::ToggleTapMode();
+ if (GPH::tapmodeLevel == TAPMODE_LEFT) {
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Left Click");
+ } else if (GPH::tapmodeLevel == TAPMODE_RIGHT) {
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Right Click");
+ } else if (GPH::tapmodeLevel == TAPMODE_HOVER) {
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Hover (No Click)");
+ }
+ break;
+ }
+ return true;
+}
+
+bool GP2XSdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
+ _stickBtn[ev.jbutton.button] = 0;
+ event.kbd.flags = 0;
+
+ switch (ev.jbutton.button) {
+ case BUTTON_UP:
+ case BUTTON_UPLEFT:
+ case BUTTON_LEFT:
+ case BUTTON_DOWNLEFT:
+ case BUTTON_DOWN:
+ case BUTTON_DOWNRIGHT:
+ case BUTTON_RIGHT:
+ case BUTTON_UPRIGHT:
+ moveStick();
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+ break;
+ case BUTTON_B:
+ case BUTTON_CLICK:
+ if (BUTTON_STATE_L == true) {
+ break;
+ } else {
+ event.type = Common::EVENT_LBUTTONUP;
+ fillMouseEvent(event, _km.x, _km.y);
+ }
+ break;
+ case BUTTON_X:
+ event.type = Common::EVENT_RBUTTONUP;
+ fillMouseEvent(event, _km.x, _km.y);
+ break;
+ case BUTTON_L:
+ BUTTON_STATE_L = false;
+ break;
+ case BUTTON_SELECT:
+ case BUTTON_HOME:
+ event.type = Common::EVENT_KEYUP;
+ event.kbd.keycode = Common::KEYCODE_ESCAPE;
+ event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
+ break;
+ case BUTTON_A:
+ event.type = Common::EVENT_KEYUP;
+ event.kbd.keycode = Common::KEYCODE_PERIOD;
+ event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
+ break;
+ case BUTTON_Y:
+ event.type = Common::EVENT_KEYUP;
+ event.kbd.keycode = Common::KEYCODE_SPACE;
+ event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
+ break;
+ case BUTTON_MENU:
+ case BUTTON_HELP:
+ event.type = Common::EVENT_KEYUP;
+ if (BUTTON_STATE_L == true) {
+ event.type = Common::EVENT_MAINMENU;
+ } else {
+ event.kbd.keycode = Common::KEYCODE_F5;
+ event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
+ }
+ break;
+ case BUTTON_R:
+ event.type = Common::EVENT_KEYUP;
+ if (BUTTON_STATE_L == true) {
+#ifdef ENABLE_VKEYBD
+ event.kbd.keycode = Common::KEYCODE_F7;
+ event.kbd.ascii = mapKey(SDLK_F7, ev.key.keysym.mod, 0);
+#else
+ event.kbd.keycode = Common::KEYCODE_0;
+ event.kbd.ascii = mapKey(SDLK_0, ev.key.keysym.mod, 0);
+#endif
+ } else {
+ event.kbd.keycode = Common::KEYCODE_RETURN;
+ event.kbd.ascii = mapKey(SDLK_RETURN, ev.key.keysym.mod, 0);
+ }
+ break;
+ case BUTTON_VOLUP:
+ break;
+ case BUTTON_VOLDOWN:
+ break;
+ case BUTTON_HOLD:
+ break;
+ case BUTTON_HELP2:
+ break;
+ }
+ return true;
+}
+
+bool GP2XSdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
+ int axis = ev.jaxis.value;
+ if ( axis > JOY_DEADZONE) {
+ axis -= JOY_DEADZONE;
+ event.type = Common::EVENT_MOUSEMOVE;
+ } else if ( axis < -JOY_DEADZONE ) {
+ axis += JOY_DEADZONE;
+ event.type = Common::EVENT_MOUSEMOVE;
+ } else
+ axis = 0;
+
+ if ( ev.jaxis.axis == JOY_XAXIS) {
+#ifdef JOY_ANALOG
+ _km.x_vel = axis/2000;
+ _km.x_down_count = 0;
+#else
+ if (axis != 0) {
+ _km.x_vel = (axis > 0) ? 1:-1;
+ _km.x_down_count = 1;
+ } else {
+ _km.x_vel = 0;
+ _km.x_down_count = 0;
+ }
+#endif
+
+ } else if (ev.jaxis.axis == JOY_YAXIS) {
+#ifndef JOY_INVERT_Y
+ axis = -axis;
+#endif
+#ifdef JOY_ANALOG
+ _km.y_vel = -axis / 2000;
+ _km.y_down_count = 0;
+#else
+ if (axis != 0) {
+ _km.y_vel = (-axis > 0) ? 1: -1;
+ _km.y_down_count = 1;
+ } else {
+ _km.y_vel = 0;
+ _km.y_down_count = 0;
+ }
+#endif
+ }
+
+ fillMouseEvent(event, _km.x, _km.y);
+ return true;
+}
+
+bool GP2XSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
+ return false;
+}
+
+
+#endif
View
59 backends/events/gp2xsdl/gp2xsdl-events.h
@@ -0,0 +1,59 @@
+/* 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.
+ *
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/events/gp2xsdl/gp2xsdl-events.h $
+ * $Id: gp2xsdl-events.h 54584 2010-11-29 18:48:43Z lordhoto $
+ *
+ */
+
+#if !defined(BACKEND_EVENTS_SDL_GP2X_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER)
+#define BACKEND_EVENTS_SDL_GP2X_H
+
+#include "backends/events/sdl/sdl-events.h"
+
+/**
+ * SDL events manager for GP2X and GP2XWIZ
+ */
+class GP2XSdlEventSource : public SdlEventSource {
+public:
+ GP2XSdlEventSource();
+
+protected:
+ bool _stickBtn[32];
+
+ /** Button state for L button modifier */
+ bool _buttonStateL;
+
+ /**
+ * Handles the stick movement
+ */
+ void moveStick();
+
+ virtual bool handleKeyDown(SDL_Event &ev, Common::Event &event);
+ virtual bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event);
+ virtual bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event);
+ virtual bool handleJoyAxisMotion(SDL_Event &ev, Common::Event &event);
+
+ virtual void SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event);
+
+ virtual bool remapKey(SDL_Event &ev, Common::Event &event);
+};
+
+#endif
View
73 ...s/platform/linuxmoto/linuxmoto-events.cpp → ...ents/linuxmotosdl/linuxmotosdl-events.cpp
@@ -18,54 +18,47 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/platform/linuxmoto/linuxmoto-events.cpp $
- * $Id: linuxmoto-events.cpp 53160 2010-10-12 02:18:11Z jvprat $
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/events/linuxmotosdl/linuxmotosdl-events.cpp $
+ * $Id: linuxmotosdl-events.cpp 54584 2010-11-29 18:48:43Z lordhoto $
*
*/
-#include "backends/platform/linuxmoto/linuxmoto-sdl.h"
-#include "graphics/scaler/aspect.h" // for aspect2Real
-
-static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode) {
- if (key >= SDLK_F1 && key <= SDLK_F9) {
- return key - SDLK_F1 + Common::ASCII_F1;
- } else if (key >= SDLK_KP0 && key <= SDLK_KP9) {
- return key - SDLK_KP0 + '0';
- } else if (key >= SDLK_UP && key <= SDLK_PAGEDOWN) {
- return key;
- } else if (unicode) {
- return unicode;
- } else if (key >= 'a' && key <= 'z' && (mod & KMOD_SHIFT)) {
- return key & ~0x20;
- } else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) {
- return 0;
- }
- return key;
-}
+#include "common/scummsys.h"
-void OSystem_LINUXMOTO::fillMouseEvent(Common::Event &event, int x, int y) {
- if (_videoMode.mode == GFX_HALF && !_overlayVisible) {
- event.mouse.x = x*2;
- event.mouse.y = y*2;
- } else {
- event.mouse.x = x;
- event.mouse.y = y;
- }
+#if defined(LINUXMOTO)
- // Update the "keyboard mouse" coords
- _km.x = x;
- _km.y = y;
+#include "backends/events/linuxmotosdl/linuxmotosdl-events.h"
+#include "backends/platform/linuxmoto/linuxmoto-sdl.h"
- // Adjust for the screen scaling
- if (!_overlayVisible) {
- event.mouse.x /= _videoMode.scaleFactor;
- event.mouse.y /= _videoMode.scaleFactor;
- if (_videoMode.aspectRatioCorrection)
- event.mouse.y = aspect2Real(event.mouse.y);
+enum {
+ GFX_HALF = 12
+};
+
+void LinuxmotoSdlEventSource::preprocessEvents(SDL_Event *event) {
+ if (event->type == SDL_ACTIVEEVENT) {
+ if (event->active.state == SDL_APPINPUTFOCUS && !event->active.gain) {
+ ((OSystem_SDL* )g_system)->getMixerManager()->suspendAudio();
+ for (;;) {
+ if (!SDL_WaitEvent(event)) {
+ SDL_Delay(10);
+ continue;
+ }
+ if (event->type == SDL_QUIT)
+ return;
+ if (event->type != SDL_ACTIVEEVENT)
+ continue;
+ if (event->active.state == SDL_APPINPUTFOCUS && event->active.gain) {
+ ((OSystem_SDL* )g_system)->getMixerManager()->resumeAudio();
+ return;
+ }
+ }
+ }
}
}
-bool OSystem_LINUXMOTO::remapKey(SDL_Event &ev, Common::Event &event) {
+bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
+ if (false) {}
+
// Motorol A1200/E6/A1600 remapkey by Lubomyr
#ifdef MOTOEZX
// Quit on MOD+Camera Key on A1200
@@ -226,3 +219,5 @@ bool OSystem_LINUXMOTO::remapKey(SDL_Event &ev, Common::Event &event) {
return false;
}
+
+#endif
View
40 backends/events/linuxmotosdl/linuxmotosdl-events.h
@@ -0,0 +1,40 @@
+/* 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.
+ *
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/events/linuxmotosdl/linuxmotosdl-events.h $
+ * $Id: linuxmotosdl-events.h 54584 2010-11-29 18:48:43Z lordhoto $
+ *
+ */
+
+#if !defined(BACKEND_EVENTS_SDL_LINUXMOTO_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER)
+#define BACKEND_EVENTS_SDL_LINUXMOTO_H
+
+#include "backends/events/sdl/sdl-events.h"
+
+/**
+ * SDL events manager for LINUXMOTO
+ */
+class LinuxmotoSdlEventSource : public SdlEventSource {
+protected:
+ virtual void preprocessEvents(SDL_Event *event);
+ virtual bool remapKey(SDL_Event &ev, Common::Event &event);
+};
+
+#endif
View
17 backends/platform/samsungtv/events.cpp → ...ents/samsungtvsdl/samsungtvsdl-events.cpp
@@ -18,18 +18,18 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/platform/samsungtv/events.cpp $
- * $Id: events.cpp 48148 2010-02-27 17:02:58Z jvprat $
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/events/samsungtvsdl/samsungtvsdl-events.cpp $
+ * $Id: samsungtvsdl-events.cpp 54584 2010-11-29 18:48:43Z lordhoto $
*
*/
-#include "backends/platform/samsungtv/samsungtv.h"
-#include "common/util.h"
-#include "common/events.h"
+#include "common/scummsys.h"
-#if defined(SAMSUNGTV)
+#ifdef SAMSUNGTV
-bool OSystem_SDL_SamsungTV::remapKey(SDL_Event &ev, Common::Event &event) {
+#include "backends/events/samsungtvsdl/samsungtvsdl-events.h"
+
+bool SamsungTVSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
switch (ev.type) {
case SDL_KEYDOWN:{
if (ev.key.keysym.sym == SDLK_POWER) {
@@ -67,7 +67,8 @@ bool OSystem_SDL_SamsungTV::remapKey(SDL_Event &ev, Common::Event &event) {
}
}
- return false;
+ // Invoke parent implementation of this method
+ return SdlEventSource::remapKey(ev, event);
}
#endif
View
39 backends/events/samsungtvsdl/samsungtvsdl-events.h
@@ -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.
+ *
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/events/samsungtvsdl/samsungtvsdl-events.h $
+ * $Id: samsungtvsdl-events.h 54584 2010-11-29 18:48:43Z lordhoto $
+ *
+ */
+
+#if !defined(BACKEND_EVENTS_SDL_SAMSUNGTV_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER)
+#define BACKEND_EVENTS_SDL_SAMSUNGTV_H
+
+#include "backends/events/sdl/sdl-events.h"
+
+/**
+ * SDL events manager for Samsung TV
+ */
+class SamsungTVSdlEventSource : public SdlEventSource {
+protected:
+ virtual bool remapKey(SDL_Event &ev, Common::Event &event);
+};
+
+#endif
View
163 backends/platform/sdl/events.cpp → backends/events/sdl/sdl-events.cpp
@@ -18,15 +18,18 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
- * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/platform/sdl/events.cpp $
- * $Id: events.cpp 49902 2010-06-16 07:22:54Z tdhs $
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/events/sdl/sdl-events.cpp $
+ * $Id: sdl-events.cpp 54584 2010-11-29 18:48:43Z lordhoto $
*
*/
+#include "common/scummsys.h"
+
+#if defined(SDL_BACKEND)
+
+#include "backends/events/sdl/sdl-events.h"
#include "backends/platform/sdl/sdl.h"
-#include "common/util.h"
-#include "common/events.h"
-#include "graphics/scaler/aspect.h" // for aspect2Real
+#include "common/config-manager.h"
// FIXME move joystick defines out and replace with confile file options
// we should really allow users to map any key to a joystick button
@@ -47,10 +50,32 @@
#define JOY_BUT_SPACE 4
#define JOY_BUT_F5 5
+SdlEventSource::SdlEventSource()
+ : _scrollLock(false), _joystick(0), _lastScreenID(0), EventSource() {
+ // Reset mouse state
+ memset(&_km, 0, sizeof(_km));
+ int joystick_num = ConfMan.getInt("joystick_num");
+ if (joystick_num > -1) {
+ // Initialize SDL joystick subsystem
+ if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) {
+ error("Could not initialize SDL: %s", SDL_GetError());
+ }
+ // Enable joystick
+ if (SDL_NumJoysticks() > 0) {
+ printf("Using joystick: %s\n", SDL_JoystickName(0));
+ _joystick = SDL_JoystickOpen(joystick_num);
+ }
+ }
+}
-static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode) {
+SdlEventSource::~SdlEventSource() {
+ if (_joystick)
+ SDL_JoystickClose(_joystick);
+}
+
+int SdlEventSource::mapKey(SDLKey key, SDLMod mod, Uint16 unicode) {
if (key >= SDLK_F1 && key <= SDLK_F9) {
return key - SDLK_F1 + Common::ASCII_F1;
} else if (key >= SDLK_KP0 && key <= SDLK_KP9) {
@@ -67,25 +92,17 @@ static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode) {
return key;
}
-void OSystem_SDL::fillMouseEvent(Common::Event &event, int x, int y) {
+void SdlEventSource::fillMouseEvent(Common::Event &event, int x, int y) {
event.mouse.x = x;
event.mouse.y = y;
// Update the "keyboard mouse" coords
_km.x = x;
_km.y = y;
-
- // Adjust for the screen scaling
- if (!_overlayVisible) {
- event.mouse.x /= _videoMode.scaleFactor;
- event.mouse.y /= _videoMode.scaleFactor;
- if (_videoMode.aspectRatioCorrection)
- event.mouse.y = aspect2Real(event.mouse.y);
- }
}
-void OSystem_SDL::handleKbdMouse() {
- uint32 curTime = getMillis();
+void SdlEventSource::handleKbdMouse() {
+ uint32 curTime = g_system->getMillis();
if (curTime >= _km.last_time + _km.delay_time) {
_km.last_time = curTime;
if (_km.x_down_count == 1) {
@@ -153,7 +170,7 @@ void OSystem_SDL::handleKbdMouse() {
}
}
-static void SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) {
+void SdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) {
event.kbd.flags = 0;
@@ -178,19 +195,19 @@ static void SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) {
event.kbd.flags |= Common::KBD_CAPS;
}
-bool OSystem_SDL::pollEvent(Common::Event &event) {
- SDL_Event ev;
- ev.type = SDL_NOEVENT;
-
+bool SdlEventSource::pollEvent(Common::Event &event) {
handleKbdMouse();
- // If the screen mode changed, send an Common::EVENT_SCREEN_CHANGED
- if (_modeChanged) {
- _modeChanged = false;
+ // If the screen changed, send an Common::EVENT_SCREEN_CHANGED
+ int screenID = ((OSystem_SDL *)g_system)->getGraphicsManager()->getScreenChangeID();
+ if (screenID != _lastScreenID) {
+ _lastScreenID = screenID;
event.type = Common::EVENT_SCREEN_CHANGED;
return true;
}
+ SDL_Event ev;
+ ev.type = SDL_NOEVENT;
while (SDL_PollEvent(&ev)) {
preprocessEvents(&ev);
if (dispatchSDLEvent(ev, event))
@@ -199,7 +216,7 @@ bool OSystem_SDL::pollEvent(Common::Event &event) {
return false;
}
-bool OSystem_SDL::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
switch (ev.type) {
case SDL_KEYDOWN:
return handleKeyDown(ev, event);
@@ -219,8 +236,16 @@ bool OSystem_SDL::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
return handleJoyAxisMotion(ev, event);
case SDL_VIDEOEXPOSE:
- _forceFull = true;
- break;
+ // HACK: Send a fake event, handled by SdlGraphicsManager
+ event.type = (Common::EventType)OSystem_SDL::kSdlEventExpose;
+ return true;
+
+ case SDL_VIDEORESIZE:
+ // HACK: Send a fake event, handled by OpenGLSdlGraphicsManager
+ event.type = (Common::EventType)OSystem_SDL::kSdlEventResize;
+ event.mouse.x = ev.resize.w;
+ event.mouse.y = ev.resize.h;
+ return true;
case SDL_QUIT:
event.type = Common::EVENT_QUIT;
@@ -232,7 +257,7 @@ bool OSystem_SDL::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
}
-bool OSystem_SDL::handleKeyDown(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleKeyDown(SDL_Event &ev, Common::Event &event) {
SDLModToOSystemKeyFlags(SDL_GetModState(), event);
@@ -243,41 +268,6 @@ bool OSystem_SDL::handleKeyDown(SDL_Event &ev, Common::Event &event) {
if (_scrollLock)
event.kbd.flags |= Common::KBD_SCRL;
- // Alt-Return and Alt-Enter toggle full screen mode
- if (event.kbd.hasFlags(Common::KBD_ALT) && (ev.key.keysym.sym == SDLK_RETURN || ev.key.keysym.sym == SDLK_KP_ENTER)) {
- beginGFXTransaction();
- setFullscreenMode(!_videoMode.fullscreen);
- endGFXTransaction();
-#ifdef USE_OSD
- if (_videoMode.fullscreen)
- displayMessageOnOSD("Fullscreen mode");
- else
- displayMessageOnOSD("Windowed mode");
-#endif
-
- return false;
- }
-
- // Alt-S: Create a screenshot
- if (event.kbd.hasFlags(Common::KBD_ALT) && ev.key.keysym.sym == 's') {
- char filename[20];
-
- for (int n = 0;; n++) {
- SDL_RWops *file;
-
- sprintf(filename, "scummvm%05d.bmp", n);
- file = SDL_RWFromFile(filename, "r");
- if (!file)
- break;
- SDL_RWclose(file);
- }
- if (saveScreenshot(filename))
- printf("Saved '%s'\n", filename);
- else
- printf("Could not save screenshot!\n");
- return false;
- }
-
// Ctrl-m toggles mouse capture
if (event.kbd.hasFlags(Common::KBD_CTRL) && ev.key.keysym.sym == 'm') {
toggleMouseGrab();
@@ -309,12 +299,6 @@ bool OSystem_SDL::handleKeyDown(SDL_Event &ev, Common::Event &event) {
return true;
}
- // Ctrl-Alt-<key> will change the GFX mode
- if ((event.kbd.flags & (Common::KBD_CTRL|Common::KBD_ALT)) == (Common::KBD_CTRL|Common::KBD_ALT)) {
- if (handleScalerHotkeys(ev.key))
- return false;
- }
-
if (remapKey(ev, event))
return true;
@@ -325,7 +309,7 @@ bool OSystem_SDL::handleKeyDown(SDL_Event &ev, Common::Event &event) {
return true;
}
-bool OSystem_SDL::handleKeyUp(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleKeyUp(SDL_Event &ev, Common::Event &event) {
if (remapKey(ev, event))
return true;
@@ -340,22 +324,17 @@ bool OSystem_SDL::handleKeyUp(SDL_Event &ev, Common::Event &event) {
if (_scrollLock)
event.kbd.flags |= Common::KBD_SCRL;
- if (isScalerHotkey(event))
- // Swallow these key up events
- return false;
-
return true;
}
-bool OSystem_SDL::handleMouseMotion(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleMouseMotion(SDL_Event &ev, Common::Event &event) {
event.type = Common::EVENT_MOUSEMOVE;
fillMouseEvent(event, ev.motion.x, ev.motion.y);
- setMousePos(event.mouse.x, event.mouse.y);
return true;
}
-bool OSystem_SDL::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
if (ev.button.button == SDL_BUTTON_LEFT)
event.type = Common::EVENT_LBUTTONDOWN;
else if (ev.button.button == SDL_BUTTON_RIGHT)
@@ -378,7 +357,7 @@ bool OSystem_SDL::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
return true;
}
-bool OSystem_SDL::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
if (ev.button.button == SDL_BUTTON_LEFT)
event.type = Common::EVENT_LBUTTONUP;
else if (ev.button.button == SDL_BUTTON_RIGHT)
@@ -394,7 +373,7 @@ bool OSystem_SDL::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
return true;
}
-bool OSystem_SDL::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
if (ev.jbutton.button == JOY_BUT_LMOUSE) {
event.type = Common::EVENT_LBUTTONDOWN;
fillMouseEvent(event, _km.x, _km.y);
@@ -425,7 +404,7 @@ bool OSystem_SDL::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
return true;
}
-bool OSystem_SDL::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
if (ev.jbutton.button == JOY_BUT_LMOUSE) {
event.type = Common::EVENT_LBUTTONUP;
fillMouseEvent(event, _km.x, _km.y);
@@ -456,7 +435,7 @@ bool OSystem_SDL::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
return true;
}
-bool OSystem_SDL::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
int axis = ev.jaxis.value;
if ( axis > JOY_DEADZONE) {
axis -= JOY_DEADZONE;
@@ -469,7 +448,7 @@ bool OSystem_SDL::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
if ( ev.jaxis.axis == JOY_XAXIS) {
#ifdef JOY_ANALOG
- _km.x_vel = axis/2000;
+ _km.x_vel = axis / 2000;
_km.x_down_count = 0;
#else
if (axis != 0) {
@@ -504,7 +483,7 @@ bool OSystem_SDL::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
return true;
}
-bool OSystem_SDL::remapKey(SDL_Event &ev, Common::Event &event) {
+bool SdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
#ifdef LINUPY
// On Yopy map the End button to quit
if ((ev.key.keysym.sym == 293)) {
@@ -571,3 +550,19 @@ bool OSystem_SDL::remapKey(SDL_Event &ev, Common::Event &event) {
#endif
return false;
}
+
+void SdlEventSource::toggleMouseGrab() {
+ if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF)
+ SDL_WM_GrabInput(SDL_GRAB_ON);
+ else
+ SDL_WM_GrabInput(SDL_GRAB_OFF);
+}
+
+void SdlEventSource::resetKeyboadEmulation(int16 x_max, int16 y_max) {
+ _km.x_max = x_max;
+ _km.y_max = y_max;
+ _km.delay_time = 25;
+ _km.last_time = 0;
+}
+
+#endif
View
135 backends/events/sdl/sdl-events.h
@@ -0,0 +1,135 @@
+/* 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.
+ *
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/events/sdl/sdl-events.h $
+ * $Id: sdl-events.h 54584 2010-11-29 18:48:43Z lordhoto $
+ *
+ */
+
+#if !defined(BACKEND_EVENTS_SDL_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER)
+#define BACKEND_EVENTS_SDL_H
+
+#include "backends/events/default/default-events.h"
+
+#include "backends/platform/sdl/sdl-sys.h"
+
+
+/**
+ * The SDL event source.
+ */
+class SdlEventSource : public Common::EventSource {
+public:
+ SdlEventSource();
+ virtual ~SdlEventSource();
+
+ /**
+ * Gets and processes SDL events.
+ */
+ virtual bool pollEvent(Common::Event &event);
+
+ /**
+ * Resets keyboard emulation after a video screen change
+ */
+ virtual void resetKeyboadEmulation(int16 x_max, int16 y_max);
+
+ /**
+ * Toggles mouse input grab
+ */
+ virtual void toggleMouseGrab();
+
+protected:
+ /** @name Keyboard mouse emulation
+ * Disabled by fingolfin 2004-12-18.
+ * I am keeping the rest of the code in for now, since the joystick
+ * code (or rather, "hack") uses it, too.
+ */
+ //@{
+
+ struct KbdMouse {
+ int16 x, y, x_vel, y_vel, x_max, y_max, x_down_count, y_down_count;
+ uint32 last_time, delay_time, x_down_time, y_down_time;
+ };
+ KbdMouse _km;
+
+ //@}
+
+ /** Scroll lock state - since SDL doesn't track it */
+ bool _scrollLock;
+
+ /** Joystick */
+ SDL_Joystick *_joystick;
+
+ /** Last screen id for checking if it was modified */
+ int _lastScreenID;
+
+ /**
+ * Pre process an event before it is dispatched.
+ */
+ virtual void preprocessEvents(SDL_Event *event) {}
+
+ /**
+ * Dispatchs SDL events for each handler.
+ */
+ virtual bool dispatchSDLEvent(SDL_Event &ev, Common::Event &event);
+
+
+ /** @name Event Handlers
+ * Handlers for specific SDL events, called by SdlEventSource::dispatchSDLEvent().
+ * This way, if a managers inherits fromt this SDL events manager, it can
+ * change the behavior of only a single event, without having to override all
+ * of SdlEventSource::dispatchSDLEvent().
+ */
+ //@{
+
+ virtual bool handleKeyDown(SDL_Event &ev, Common::Event &event);
+ virtual bool handleKeyUp(SDL_Event &ev, Common::Event &event);
+ virtual bool handleMouseMotion(SDL_Event &ev, Common::Event &event);
+ virtual bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event);
+ virtual bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event);
+ virtual bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event);
+ virtual bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event);
+ virtual bool handleJoyAxisMotion(SDL_Event &ev, Common::Event &event);
+ virtual void handleKbdMouse();
+
+ //@}
+
+ /**
+ * Assigns the mouse coords to the mouse event
+ */
+ virtual void fillMouseEvent(Common::Event &event, int x, int y);
+
+ /**
+ * Remaps key events. This allows platforms to configure
+ * their custom keys.
+ */
+ virtual bool remapKey(SDL_Event &ev, Common::Event &event);
+
+ /**
+ * Maps the ASCII value of key
+ */
+ virtual int mapKey(SDLKey key, SDLMod mod, Uint16 unicode);
+
+ /**
+ * Configures the key modifiers flags status
+ */
+ virtual void SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event);
+};
+
+#endif
View
201 backends/events/symbiansdl/symbiansdl-events.cpp
@@ -0,0 +1,201 @@
+/* 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.
+ *
+ * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/backends/events/symbiansdl/symbiansdl-events.cpp $
+ * $Id: symbiansdl-events.cpp 54584 2010-11-29 18:48:43Z lordhoto $
+ *
+ */
+