From dc649a13a7ed1721160140298aa4f1c9fd4b65d9 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Thu, 27 Oct 2011 14:16:22 +0200 Subject: ANDROID: Actually create the savegame directory. Not sure how this went missing from the commit. (cherry picked from commit fed26146a855fc79784c3df0ae3a1bf068fc2722) --- backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java | 1 + 1 file changed, 1 insertion(+) (limited to 'backends') diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java index 7c61520d43..fbd6513761 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java @@ -134,6 +134,7 @@ public class ScummVMActivity extends Activity { // world-readable and don't get deleted on uninstall. String savePath = Environment.getExternalStorageDirectory() + "/ScummVM/Saves/"; File saveDir = new File(savePath); + saveDir.mkdirs(); if (!saveDir.isDirectory()) { // If it doesn't work, resort to the internal app path. savePath = getDir("saves", MODE_WORLD_READABLE).getPath(); -- cgit v1.2.3 From a784aeb1874104810b7b06297c32723eda96df62 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Wed, 2 Nov 2011 01:22:57 +0100 Subject: BADA: Fix loop --- backends/timer/bada/timer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/timer/bada/timer.cpp b/backends/timer/bada/timer.cpp index 8f5620401f..faddacb3c3 100755 --- a/backends/timer/bada/timer.cpp +++ b/backends/timer/bada/timer.cpp @@ -76,7 +76,7 @@ BadaTimerManager::BadaTimerManager() { BadaTimerManager::~BadaTimerManager() { for (Common::List::iterator slot = _timers.begin(); - slot != _timers.end(); ++slot) { + slot != _timers.end(); ) { slot->Stop(); slot = _timers.erase(slot); } -- cgit v1.2.3 From 949b30dc36efd4c25822f83c6869179ea0f36dd2 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 9 Nov 2011 18:54:52 +0100 Subject: OPENGL: Always set the unpack alignment when refreshing the textures. This should hopefully make sure we are always having the correct alignment set up. This might fix bug #3435655 "OpenGL display corruption with various Sierra games Daily B.". --- backends/graphics/opengl/gltexture.h | 5 +++++ backends/graphics/opengl/opengl-graphics.cpp | 12 +++++------- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'backends') diff --git a/backends/graphics/opengl/gltexture.h b/backends/graphics/opengl/gltexture.h index 71f1eeb78f..d8c42eeb2d 100644 --- a/backends/graphics/opengl/gltexture.h +++ b/backends/graphics/opengl/gltexture.h @@ -102,6 +102,11 @@ public: */ GLuint getHeight() const { return _realHeight; } + /** + * Get the bytes per pixel. + */ + uint getBytesPerPixel() const { return _bytesPerPixel; } + /** * Set the texture filter. * @filter the filter type, GL_NEAREST or GL_LINEAR diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 8e01e76f16..5b1f7b4b28 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -1115,8 +1115,6 @@ void OpenGLGraphicsManager::loadTextures() { } #endif - uint gameScreenBPP = 0; - if (!_gameTexture) { byte bpp; GLenum intformat; @@ -1127,7 +1125,6 @@ void OpenGLGraphicsManager::loadTextures() { #else getGLPixelFormat(Graphics::PixelFormat::createFormatCLUT8(), bpp, intformat, format, type); #endif - gameScreenBPP = bpp; _gameTexture = new GLTexture(bpp, intformat, format, type); } else _gameTexture->refresh(); @@ -1186,10 +1183,11 @@ void OpenGLGraphicsManager::loadTextures() { // We need to setup a proper unpack alignment value here, else we will // get problems with the texture updates, in case the surface data is // not properly aligned. - // For now we use the gcd of the game screen format and 2, since 2 is - // the BPP value for the overlay and the OSD. - if (gameScreenBPP) - glPixelStorei(GL_UNPACK_ALIGNMENT, Common::gcd(gameScreenBPP, 2)); + // It is noteworthy this assumes the OSD uses the same BPP as the overlay + // and that the cursor works with any alignment setting. + int newAlignment = Common::gcd(_gameTexture->getBytesPerPixel(), _overlayTexture->getBytesPerPixel()); + assert(newAlignment == 1 || newAlignment == 2 || newAlignment == 4); + glPixelStorei(GL_UNPACK_ALIGNMENT, newAlignment); // We use a "pack" alignment (when reading from textures) to 4 here, // since the only place where we really use it is the BMP screenshot -- cgit v1.2.3 From 44b7f3aed52b1213995f9e19e4395f4350997b01 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 25 Oct 2011 21:18:42 +0200 Subject: ANDROID: Move from org.inodes.gus to org.scummvm. --- backends/platform/android/android.mk | 6 +- backends/platform/android/jni.cpp | 2 +- .../inodes/gus/scummvm/EditableSurfaceView.java | 61 --- .../org/inodes/gus/scummvm/PluginProvider.java | 53 --- .../android/org/inodes/gus/scummvm/ScummVM.java | 451 --------------------- .../org/inodes/gus/scummvm/ScummVMActivity.java | 224 ---------- .../org/inodes/gus/scummvm/ScummVMApplication.java | 30 -- .../org/inodes/gus/scummvm/ScummVMEvents.java | 231 ----------- .../android/org/inodes/gus/scummvm/Unpacker.java | 378 ----------------- .../org/scummvm/scummvm/EditableSurfaceView.java | 61 +++ .../org/scummvm/scummvm/PluginProvider.java | 53 +++ .../android/org/scummvm/scummvm/ScummVM.java | 451 +++++++++++++++++++++ .../org/scummvm/scummvm/ScummVMActivity.java | 224 ++++++++++ .../org/scummvm/scummvm/ScummVMApplication.java | 30 ++ .../android/org/scummvm/scummvm/ScummVMEvents.java | 231 +++++++++++ .../android/org/scummvm/scummvm/Unpacker.java | 378 +++++++++++++++++ 16 files changed, 1432 insertions(+), 1432 deletions(-) delete mode 100644 backends/platform/android/org/inodes/gus/scummvm/EditableSurfaceView.java delete mode 100644 backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java delete mode 100644 backends/platform/android/org/inodes/gus/scummvm/ScummVM.java delete mode 100644 backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java delete mode 100644 backends/platform/android/org/inodes/gus/scummvm/ScummVMApplication.java delete mode 100644 backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java delete mode 100644 backends/platform/android/org/inodes/gus/scummvm/Unpacker.java create mode 100644 backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java create mode 100644 backends/platform/android/org/scummvm/scummvm/PluginProvider.java create mode 100644 backends/platform/android/org/scummvm/scummvm/ScummVM.java create mode 100644 backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java create mode 100644 backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java create mode 100644 backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java create mode 100644 backends/platform/android/org/scummvm/scummvm/Unpacker.java (limited to 'backends') diff --git a/backends/platform/android/android.mk b/backends/platform/android/android.mk index 63d194fdc1..2e8fd62152 100644 --- a/backends/platform/android/android.mk +++ b/backends/platform/android/android.mk @@ -63,7 +63,7 @@ PATH_BUILD_CLASSES_PLUGIN_TOP = $(PATH_BUILD)/classes.plugin PATH_STAGE_PREFIX = build.stage PATH_STAGE_MAIN = $(PATH_STAGE_PREFIX).main -PATH_REL = org/inodes/gus/scummvm +PATH_REL = org/scummvm/scummvm PATH_SRC_TOP = $(srcdir)/backends/platform/android PATH_SRC = $(PATH_SRC_TOP)/$(PATH_REL) @@ -172,13 +172,13 @@ androidrelease: $(addprefix release/, $(APK_MAIN) $(APK_PLUGINS)) androidtestmain: $(APK_MAIN) $(ADB) install -r $(APK_MAIN) - $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.inodes.gus.scummvm/.Unpacker + $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.scummvm.scummvm/.Unpacker androidtest: $(APK_MAIN) $(APK_PLUGINS) @set -e; for apk in $^; do \ $(ADB) install -r $$apk; \ done - $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.inodes.gus.scummvm/.Unpacker + $(ADB) shell am start -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -n org.scummvm.scummvm/.Unpacker # used by buildbot! androiddistdebug: all diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp index b44a585528..a7ebb87651 100644 --- a/backends/platform/android/jni.cpp +++ b/backends/platform/android/jni.cpp @@ -125,7 +125,7 @@ jint JNI::onLoad(JavaVM *vm) { if (_vm->GetEnv((void **)&env, JNI_VERSION_1_2)) return JNI_ERR; - jclass cls = env->FindClass("org/inodes/gus/scummvm/ScummVM"); + jclass cls = env->FindClass("org/scummvm/scummvm/ScummVM"); if (cls == 0) return JNI_ERR; diff --git a/backends/platform/android/org/inodes/gus/scummvm/EditableSurfaceView.java b/backends/platform/android/org/inodes/gus/scummvm/EditableSurfaceView.java deleted file mode 100644 index 3aef14b851..0000000000 --- a/backends/platform/android/org/inodes/gus/scummvm/EditableSurfaceView.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.inodes.gus.scummvm; - -import android.content.Context; -import android.text.InputType; -import android.util.AttributeSet; -import android.view.SurfaceView; -import android.view.inputmethod.BaseInputConnection; -import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputConnection; -import android.view.inputmethod.InputMethodManager; - -public class EditableSurfaceView extends SurfaceView { - public EditableSurfaceView(Context context) { - super(context); - } - - public EditableSurfaceView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public EditableSurfaceView(Context context, AttributeSet attrs, - int defStyle) { - super(context, attrs, defStyle); - } - - @Override - public boolean onCheckIsTextEditor() { - return false; - } - - private class MyInputConnection extends BaseInputConnection { - public MyInputConnection() { - super(EditableSurfaceView.this, false); - } - - @Override - public boolean performEditorAction(int actionCode) { - if (actionCode == EditorInfo.IME_ACTION_DONE) { - InputMethodManager imm = (InputMethodManager) - getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(getWindowToken(), 0); - } - - // Sends enter key - return super.performEditorAction(actionCode); - } - } - - @Override - public InputConnection onCreateInputConnection(EditorInfo outAttrs) { - outAttrs.initialCapsMode = 0; - outAttrs.initialSelEnd = outAttrs.initialSelStart = -1; - outAttrs.inputType = (InputType.TYPE_CLASS_TEXT | - InputType.TYPE_TEXT_VARIATION_NORMAL | - InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE); - outAttrs.imeOptions = (EditorInfo.IME_ACTION_DONE | - EditorInfo.IME_FLAG_NO_EXTRACT_UI); - - return new MyInputConnection(); - } -} diff --git a/backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java b/backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java deleted file mode 100644 index d90b7b2c68..0000000000 --- a/backends/platform/android/org/inodes/gus/scummvm/PluginProvider.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.inodes.gus.scummvm; - -import android.content.BroadcastReceiver; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.pm.ActivityInfo; -import android.content.pm.PackageManager; -import android.net.Uri; -import android.os.Bundle; -import android.util.Log; - -import java.util.ArrayList; - -public class PluginProvider extends BroadcastReceiver { - private final static String LOG_TAG = "ScummVM"; - - public final static String META_UNPACK_LIB = - "org.inodes.gus.scummvm.meta.UNPACK_LIB"; - - public void onReceive(Context context, Intent intent) { - if (!intent.getAction().equals(ScummVMApplication.ACTION_PLUGIN_QUERY)) - return; - - Bundle extras = getResultExtras(true); - - final ActivityInfo info; - try { - info = context.getPackageManager() - .getReceiverInfo(new ComponentName(context, this.getClass()), - PackageManager.GET_META_DATA); - } catch (PackageManager.NameNotFoundException e) { - Log.e(LOG_TAG, "Error finding my own info?", e); - return; - } - - String mylib = info.metaData.getString(META_UNPACK_LIB); - if (mylib != null) { - ArrayList all_libs = - extras.getStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS); - all_libs.add(new Uri.Builder() - .scheme("plugin") - .authority(context.getPackageName()) - .path(mylib) - .toString()); - - extras.putStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS, - all_libs); - } - - setResultExtras(extras); - } -} diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java deleted file mode 100644 index 246a02c9be..0000000000 --- a/backends/platform/android/org/inodes/gus/scummvm/ScummVM.java +++ /dev/null @@ -1,451 +0,0 @@ -package org.inodes.gus.scummvm; - -import android.util.Log; -import android.content.res.AssetManager; -import android.view.SurfaceHolder; -import android.media.AudioFormat; -import android.media.AudioManager; -import android.media.AudioTrack; - -import javax.microedition.khronos.opengles.GL10; -import javax.microedition.khronos.egl.EGL10; -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.egl.EGLContext; -import javax.microedition.khronos.egl.EGLDisplay; -import javax.microedition.khronos.egl.EGLSurface; - -import java.io.File; -import java.util.LinkedHashMap; - -public abstract class ScummVM implements SurfaceHolder.Callback, Runnable { - final protected static String LOG_TAG = "ScummVM"; - final private AssetManager _asset_manager; - final private Object _sem_surface; - - private EGL10 _egl; - private EGLDisplay _egl_display = EGL10.EGL_NO_DISPLAY; - private EGLConfig _egl_config; - private EGLContext _egl_context = EGL10.EGL_NO_CONTEXT; - private EGLSurface _egl_surface = EGL10.EGL_NO_SURFACE; - - private SurfaceHolder _surface_holder; - private AudioTrack _audio_track; - private int _sample_rate = 0; - private int _buffer_size = 0; - - private String[] _args; - - final private native void create(AssetManager asset_manager, - EGL10 egl, EGLDisplay egl_display, - AudioTrack audio_track, - int sample_rate, int buffer_size); - final private native void destroy(); - final private native void setSurface(int width, int height); - final private native int main(String[] args); - - // pause the engine and all native threads - final public native void setPause(boolean pause); - final public native void enableZoning(boolean enable); - // Feed an event to ScummVM. Safe to call from other threads. - final public native void pushEvent(int type, int arg1, int arg2, int arg3, - int arg4, int arg5); - - // Callbacks from C++ peer instance - abstract protected void getDPI(float[] values); - abstract protected void displayMessageOnOSD(String msg); - abstract protected void setWindowCaption(String caption); - abstract protected String[] getPluginDirectories(); - abstract protected void showVirtualKeyboard(boolean enable); - abstract protected String[] getSysArchives(); - - public ScummVM(AssetManager asset_manager, SurfaceHolder holder) { - _asset_manager = asset_manager; - _sem_surface = new Object(); - - holder.addCallback(this); - } - - // SurfaceHolder callback - final public void surfaceCreated(SurfaceHolder holder) { - Log.d(LOG_TAG, "surfaceCreated"); - - // no need to do anything, surfaceChanged() will be called in any case - } - - // SurfaceHolder callback - final public void surfaceChanged(SurfaceHolder holder, int format, - int width, int height) { - // the orientation may reset on standby mode and the theme manager - // could assert when using a portrait resolution. so lets not do that. - if (height > width) { - Log.d(LOG_TAG, String.format("Ignoring surfaceChanged: %dx%d (%d)", - width, height, format)); - return; - } - - Log.d(LOG_TAG, String.format("surfaceChanged: %dx%d (%d)", - width, height, format)); - - synchronized(_sem_surface) { - _surface_holder = holder; - _sem_surface.notifyAll(); - } - - // store values for the native code - setSurface(width, height); - } - - // SurfaceHolder callback - final public void surfaceDestroyed(SurfaceHolder holder) { - Log.d(LOG_TAG, "surfaceDestroyed"); - - synchronized(_sem_surface) { - _surface_holder = null; - _sem_surface.notifyAll(); - } - - // clear values for the native code - setSurface(0, 0); - } - - final public void setArgs(String[] args) { - _args = args; - } - - final public void run() { - try { - initAudio(); - initEGL(); - - // wait for the surfaceChanged callback - synchronized(_sem_surface) { - while (_surface_holder == null) - _sem_surface.wait(); - } - } catch (Exception e) { - deinitEGL(); - deinitAudio(); - - throw new RuntimeException("Error preparing the ScummVM thread", e); - } - - create(_asset_manager, _egl, _egl_display, - _audio_track, _sample_rate, _buffer_size); - - int res = main(_args); - - destroy(); - - deinitEGL(); - deinitAudio(); - - // On exit, tear everything down for a fresh restart next time. - System.exit(res); - } - - final private void initEGL() throws Exception { - _egl = (EGL10)EGLContext.getEGL(); - _egl_display = _egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); - - int[] version = new int[2]; - _egl.eglInitialize(_egl_display, version); - - int[] num_config = new int[1]; - _egl.eglGetConfigs(_egl_display, null, 0, num_config); - - final int numConfigs = num_config[0]; - - if (numConfigs <= 0) - throw new IllegalArgumentException("No EGL configs"); - - EGLConfig[] configs = new EGLConfig[numConfigs]; - _egl.eglGetConfigs(_egl_display, configs, numConfigs, num_config); - - // Android's eglChooseConfig is busted in several versions and - // devices so we have to filter/rank the configs ourselves. - _egl_config = chooseEglConfig(configs); - - _egl_context = _egl.eglCreateContext(_egl_display, _egl_config, - EGL10.EGL_NO_CONTEXT, null); - - if (_egl_context == EGL10.EGL_NO_CONTEXT) - throw new Exception(String.format("Failed to create context: 0x%x", - _egl.eglGetError())); - } - - // Callback from C++ peer instance - final protected EGLSurface initSurface() throws Exception { - _egl_surface = _egl.eglCreateWindowSurface(_egl_display, _egl_config, - _surface_holder, null); - - if (_egl_surface == EGL10.EGL_NO_SURFACE) - throw new Exception(String.format( - "eglCreateWindowSurface failed: 0x%x", _egl.eglGetError())); - - _egl.eglMakeCurrent(_egl_display, _egl_surface, _egl_surface, - _egl_context); - - GL10 gl = (GL10)_egl_context.getGL(); - - Log.i(LOG_TAG, String.format("Using EGL %s (%s); GL %s/%s (%s)", - _egl.eglQueryString(_egl_display, EGL10.EGL_VERSION), - _egl.eglQueryString(_egl_display, EGL10.EGL_VENDOR), - gl.glGetString(GL10.GL_VERSION), - gl.glGetString(GL10.GL_RENDERER), - gl.glGetString(GL10.GL_VENDOR))); - - return _egl_surface; - } - - // Callback from C++ peer instance - final protected void deinitSurface() { - if (_egl_display != EGL10.EGL_NO_DISPLAY) { - _egl.eglMakeCurrent(_egl_display, EGL10.EGL_NO_SURFACE, - EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); - - if (_egl_surface != EGL10.EGL_NO_SURFACE) - _egl.eglDestroySurface(_egl_display, _egl_surface); - } - - _egl_surface = EGL10.EGL_NO_SURFACE; - } - - final private void deinitEGL() { - if (_egl_display != EGL10.EGL_NO_DISPLAY) { - _egl.eglMakeCurrent(_egl_display, EGL10.EGL_NO_SURFACE, - EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); - - if (_egl_surface != EGL10.EGL_NO_SURFACE) - _egl.eglDestroySurface(_egl_display, _egl_surface); - - if (_egl_context != EGL10.EGL_NO_CONTEXT) - _egl.eglDestroyContext(_egl_display, _egl_context); - - _egl.eglTerminate(_egl_display); - } - - _egl_surface = EGL10.EGL_NO_SURFACE; - _egl_context = EGL10.EGL_NO_CONTEXT; - _egl_config = null; - _egl_display = EGL10.EGL_NO_DISPLAY; - _egl = null; - } - - final private void initAudio() throws Exception { - _sample_rate = AudioTrack.getNativeOutputSampleRate( - AudioManager.STREAM_MUSIC); - _buffer_size = AudioTrack.getMinBufferSize(_sample_rate, - AudioFormat.CHANNEL_CONFIGURATION_STEREO, - AudioFormat.ENCODING_PCM_16BIT); - - // ~50ms - int buffer_size_want = (_sample_rate * 2 * 2 / 20) & ~1023; - - if (_buffer_size < buffer_size_want) { - Log.w(LOG_TAG, String.format( - "adjusting audio buffer size (was: %d)", _buffer_size)); - - _buffer_size = buffer_size_want; - } - - Log.i(LOG_TAG, String.format("Using %d bytes buffer for %dHz audio", - _buffer_size, _sample_rate)); - - _audio_track = new AudioTrack(AudioManager.STREAM_MUSIC, - _sample_rate, - AudioFormat.CHANNEL_CONFIGURATION_STEREO, - AudioFormat.ENCODING_PCM_16BIT, - _buffer_size, - AudioTrack.MODE_STREAM); - - if (_audio_track.getState() != AudioTrack.STATE_INITIALIZED) - throw new Exception( - String.format("Error initializing AudioTrack: %d", - _audio_track.getState())); - } - - final private void deinitAudio() { - if (_audio_track != null) - _audio_track.stop(); - - _audio_track = null; - _buffer_size = 0; - _sample_rate = 0; - } - - private static final int[] s_eglAttribs = { - EGL10.EGL_CONFIG_ID, - EGL10.EGL_BUFFER_SIZE, - EGL10.EGL_RED_SIZE, - EGL10.EGL_GREEN_SIZE, - EGL10.EGL_BLUE_SIZE, - EGL10.EGL_ALPHA_SIZE, - EGL10.EGL_CONFIG_CAVEAT, - EGL10.EGL_DEPTH_SIZE, - EGL10.EGL_LEVEL, - EGL10.EGL_MAX_PBUFFER_WIDTH, - EGL10.EGL_MAX_PBUFFER_HEIGHT, - EGL10.EGL_MAX_PBUFFER_PIXELS, - EGL10.EGL_NATIVE_RENDERABLE, - EGL10.EGL_NATIVE_VISUAL_ID, - EGL10.EGL_NATIVE_VISUAL_TYPE, - EGL10.EGL_SAMPLE_BUFFERS, - EGL10.EGL_SAMPLES, - EGL10.EGL_STENCIL_SIZE, - EGL10.EGL_SURFACE_TYPE, - EGL10.EGL_TRANSPARENT_TYPE, - EGL10.EGL_TRANSPARENT_RED_VALUE, - EGL10.EGL_TRANSPARENT_GREEN_VALUE, - EGL10.EGL_TRANSPARENT_BLUE_VALUE - }; - - final private class EglAttribs extends LinkedHashMap { - public EglAttribs(EGLConfig config) { - super(s_eglAttribs.length); - - int[] value = new int[1]; - - for (int i : s_eglAttribs) { - _egl.eglGetConfigAttrib(_egl_display, config, i, value); - - put(i, value[0]); - } - } - - private int weightBits(int attr, int size) { - final int value = get(attr); - - int score = 0; - - if (value == size || (size > 0 && value > size)) - score += 10; - - // penalize for wasted bits - score -= value - size; - - return score; - } - - public int weight() { - int score = 10000; - - if (get(EGL10.EGL_CONFIG_CAVEAT) != EGL10.EGL_NONE) - score -= 1000; - - // less MSAA is better - score -= get(EGL10.EGL_SAMPLES) * 100; - - // Must be at least 565, but then smaller is better - score += weightBits(EGL10.EGL_RED_SIZE, 5); - score += weightBits(EGL10.EGL_GREEN_SIZE, 6); - score += weightBits(EGL10.EGL_BLUE_SIZE, 5); - score += weightBits(EGL10.EGL_ALPHA_SIZE, 0); - score += weightBits(EGL10.EGL_DEPTH_SIZE, 0); - score += weightBits(EGL10.EGL_STENCIL_SIZE, 0); - - return score; - } - - public String toString() { - String s; - - if (get(EGL10.EGL_ALPHA_SIZE) > 0) - s = String.format("[%d] RGBA%d%d%d%d", - get(EGL10.EGL_CONFIG_ID), - get(EGL10.EGL_RED_SIZE), - get(EGL10.EGL_GREEN_SIZE), - get(EGL10.EGL_BLUE_SIZE), - get(EGL10.EGL_ALPHA_SIZE)); - else - s = String.format("[%d] RGB%d%d%d", - get(EGL10.EGL_CONFIG_ID), - get(EGL10.EGL_RED_SIZE), - get(EGL10.EGL_GREEN_SIZE), - get(EGL10.EGL_BLUE_SIZE)); - - if (get(EGL10.EGL_DEPTH_SIZE) > 0) - s += String.format(" D%d", get(EGL10.EGL_DEPTH_SIZE)); - - if (get(EGL10.EGL_STENCIL_SIZE) > 0) - s += String.format(" S%d", get(EGL10.EGL_STENCIL_SIZE)); - - if (get(EGL10.EGL_SAMPLES) > 0) - s += String.format(" MSAAx%d", get(EGL10.EGL_SAMPLES)); - - if ((get(EGL10.EGL_SURFACE_TYPE) & EGL10.EGL_WINDOW_BIT) > 0) - s += " W"; - if ((get(EGL10.EGL_SURFACE_TYPE) & EGL10.EGL_PBUFFER_BIT) > 0) - s += " P"; - if ((get(EGL10.EGL_SURFACE_TYPE) & EGL10.EGL_PIXMAP_BIT) > 0) - s += " X"; - - switch (get(EGL10.EGL_CONFIG_CAVEAT)) { - case EGL10.EGL_NONE: - break; - - case EGL10.EGL_SLOW_CONFIG: - s += " SLOW"; - break; - - case EGL10.EGL_NON_CONFORMANT_CONFIG: - s += " NON_CONFORMANT"; - - default: - s += String.format(" unknown CAVEAT 0x%x", - get(EGL10.EGL_CONFIG_CAVEAT)); - } - - return s; - } - }; - - final private EGLConfig chooseEglConfig(EGLConfig[] configs) { - EGLConfig res = configs[0]; - int bestScore = -1; - - Log.d(LOG_TAG, "EGL configs:"); - - for (EGLConfig config : configs) { - EglAttribs attr = new EglAttribs(config); - - // must have - if ((attr.get(EGL10.EGL_SURFACE_TYPE) & EGL10.EGL_WINDOW_BIT) == 0) - continue; - - int score = attr.weight(); - - Log.d(LOG_TAG, String.format("%s (%d)", attr.toString(), score)); - - if (score > bestScore) { - res = config; - bestScore = score; - } - } - - if (bestScore < 0) - Log.e(LOG_TAG, - "Unable to find an acceptable EGL config, expect badness."); - - Log.d(LOG_TAG, String.format("Chosen EGL config: %s", - new EglAttribs(res).toString())); - - return res; - } - - static { - // For grabbing with gdb... - final boolean sleep_for_debugger = false; - if (sleep_for_debugger) { - try { - Thread.sleep(20 * 1000); - } catch (InterruptedException e) { - } - } - - File cache_dir = ScummVMApplication.getLastCacheDir(); - String libname = System.mapLibraryName("scummvm"); - File libpath = new File(cache_dir, libname); - - System.load(libpath.getPath()); - } -} diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java deleted file mode 100644 index ce4e016322..0000000000 --- a/backends/platform/android/org/inodes/gus/scummvm/ScummVMActivity.java +++ /dev/null @@ -1,224 +0,0 @@ -package org.inodes.gus.scummvm; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.DialogInterface; -import android.media.AudioManager; -import android.os.Bundle; -import android.os.Environment; -import android.util.DisplayMetrics; -import android.util.Log; -import android.view.SurfaceView; -import android.view.SurfaceHolder; -import android.view.MotionEvent; -import android.view.inputmethod.InputMethodManager; -import android.widget.Toast; - -public class ScummVMActivity extends Activity { - - private class MyScummVM extends ScummVM { - private boolean usingSmallScreen() { - // Multiple screen sizes came in with Android 1.6. Have - // to use reflection in order to continue supporting 1.5 - // devices :( - DisplayMetrics metrics = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(metrics); - - try { - // This 'density' term is very confusing. - int DENSITY_LOW = metrics.getClass().getField("DENSITY_LOW").getInt(null); - int densityDpi = metrics.getClass().getField("densityDpi").getInt(metrics); - return densityDpi <= DENSITY_LOW; - } catch (Exception e) { - return false; - } - } - - public MyScummVM(SurfaceHolder holder) { - super(ScummVMActivity.this.getAssets(), holder); - - // Enable ScummVM zoning on 'small' screens. - // FIXME make this optional for the user - // disabled for now since it crops too much - //enableZoning(usingSmallScreen()); - } - - @Override - protected void getDPI(float[] values) { - DisplayMetrics metrics = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(metrics); - - values[0] = metrics.xdpi; - values[1] = metrics.ydpi; - } - - @Override - protected void displayMessageOnOSD(String msg) { - Log.i(LOG_TAG, "OSD: " + msg); - Toast.makeText(ScummVMActivity.this, msg, Toast.LENGTH_LONG).show(); - } - - @Override - protected void setWindowCaption(final String caption) { - runOnUiThread(new Runnable() { - public void run() { - setTitle(caption); - } - }); - } - - @Override - protected String[] getPluginDirectories() { - String[] dirs = new String[1]; - dirs[0] = ScummVMApplication.getLastCacheDir().getPath(); - return dirs; - } - - @Override - protected void showVirtualKeyboard(final boolean enable) { - runOnUiThread(new Runnable() { - public void run() { - showKeyboard(enable); - } - }); - } - - @Override - protected String[] getSysArchives() { - return new String[0]; - } - - } - - private MyScummVM _scummvm; - private ScummVMEvents _events; - private Thread _scummvm_thread; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setVolumeControlStream(AudioManager.STREAM_MUSIC); - - setContentView(R.layout.main); - takeKeyEvents(true); - - // This is a common enough error that we should warn about it - // explicitly. - if (!Environment.getExternalStorageDirectory().canRead()) { - new AlertDialog.Builder(this) - .setTitle(R.string.no_sdcard_title) - .setIcon(android.R.drawable.ic_dialog_alert) - .setMessage(R.string.no_sdcard) - .setNegativeButton(R.string.quit, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { - finish(); - } - }) - .show(); - - return; - } - - SurfaceView main_surface = (SurfaceView)findViewById(R.id.main_surface); - - main_surface.requestFocus(); - - getFilesDir().mkdirs(); - - // Start ScummVM - _scummvm = new MyScummVM(main_surface.getHolder()); - - _scummvm.setArgs(new String[] { - "ScummVM", - "--config=" + getFileStreamPath("scummvmrc").getPath(), - "--path=" + Environment.getExternalStorageDirectory().getPath(), - "--gui-theme=scummmodern", - "--savepath=" + getDir("saves", 0).getPath() - }); - - _events = new ScummVMEvents(this, _scummvm); - - main_surface.setOnKeyListener(_events); - main_surface.setOnTouchListener(_events); - - _scummvm_thread = new Thread(_scummvm, "ScummVM"); - _scummvm_thread.start(); - } - - @Override - public void onStart() { - Log.d(ScummVM.LOG_TAG, "onStart"); - - super.onStart(); - } - - @Override - public void onResume() { - Log.d(ScummVM.LOG_TAG, "onResume"); - - super.onResume(); - - if (_scummvm != null) - _scummvm.setPause(false); - } - - @Override - public void onPause() { - Log.d(ScummVM.LOG_TAG, "onPause"); - - super.onPause(); - - if (_scummvm != null) - _scummvm.setPause(true); - } - - @Override - public void onStop() { - Log.d(ScummVM.LOG_TAG, "onStop"); - - super.onStop(); - } - - @Override - public void onDestroy() { - Log.d(ScummVM.LOG_TAG, "onDestroy"); - - super.onDestroy(); - - if (_events != null) { - _events.sendQuitEvent(); - - try { - // 1s timeout - _scummvm_thread.join(1000); - } catch (InterruptedException e) { - Log.i(ScummVM.LOG_TAG, "Error while joining ScummVM thread", e); - } - - _scummvm = null; - } - } - - @Override - public boolean onTrackballEvent(MotionEvent e) { - if (_events != null) - return _events.onTrackballEvent(e); - - return false; - } - - private void showKeyboard(boolean show) { - SurfaceView main_surface = (SurfaceView)findViewById(R.id.main_surface); - InputMethodManager imm = (InputMethodManager) - getSystemService(INPUT_METHOD_SERVICE); - - if (show) - imm.showSoftInput(main_surface, InputMethodManager.SHOW_IMPLICIT); - else - imm.hideSoftInputFromWindow(main_surface.getWindowToken(), - InputMethodManager.HIDE_IMPLICIT_ONLY); - } -} diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVMApplication.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVMApplication.java deleted file mode 100644 index 8ab7d1a084..0000000000 --- a/backends/platform/android/org/inodes/gus/scummvm/ScummVMApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -package org.inodes.gus.scummvm; - -import android.app.Application; - -import java.io.File; - -public class ScummVMApplication extends Application { - public final static String ACTION_PLUGIN_QUERY = "org.inodes.gus.scummvm.action.PLUGIN_QUERY"; - public final static String EXTRA_UNPACK_LIBS = "org.inodes.gus.scummvm.extra.UNPACK_LIBS"; - - private static File _cache_dir; - - @Override - public void onCreate() { - super.onCreate(); - - // This is still on /data :( - _cache_dir = getCacheDir(); - // This is mounted noexec :( - //cache_dir = new File(Environment.getExternalStorageDirectory(), - // "/.ScummVM.tmp"); - // This is owned by download manager and requires special - // permissions to access :( - //cache_dir = Environment.getDownloadCacheDirectory(); - } - - public static File getLastCacheDir() { - return _cache_dir; - } -} diff --git a/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java b/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java deleted file mode 100644 index 175ff0b677..0000000000 --- a/backends/platform/android/org/inodes/gus/scummvm/ScummVMEvents.java +++ /dev/null @@ -1,231 +0,0 @@ -package org.inodes.gus.scummvm; - -import android.os.Handler; -import android.os.Message; -import android.util.Log; -import android.content.Context; -import android.view.KeyEvent; -import android.view.KeyCharacterMap; -import android.view.MotionEvent; -import android.view.View; -import android.view.ViewConfiguration; -import android.view.GestureDetector; -import android.view.inputmethod.InputMethodManager; - -public class ScummVMEvents implements - android.view.View.OnKeyListener, - android.view.View.OnTouchListener, - android.view.GestureDetector.OnGestureListener, - android.view.GestureDetector.OnDoubleTapListener { - - public static final int JE_SYS_KEY = 0; - public static final int JE_KEY = 1; - public static final int JE_DPAD = 2; - public static final int JE_DOWN = 3; - public static final int JE_SCROLL = 4; - public static final int JE_TAP = 5; - public static final int JE_DOUBLE_TAP = 6; - public static final int JE_MULTI = 7; - public static final int JE_BALL = 8; - public static final int JE_QUIT = 0x1000; - - final protected Context _context; - final protected ScummVM _scummvm; - final protected GestureDetector _gd; - final protected int _longPress; - - public ScummVMEvents(Context context, ScummVM scummvm) { - _context = context; - _scummvm = scummvm; - - _gd = new GestureDetector(context, this); - _gd.setOnDoubleTapListener(this); - _gd.setIsLongpressEnabled(false); - - _longPress = ViewConfiguration.getLongPressTimeout(); - } - - final public void sendQuitEvent() { - _scummvm.pushEvent(JE_QUIT, 0, 0, 0, 0, 0); - } - - public boolean onTrackballEvent(MotionEvent e) { - _scummvm.pushEvent(JE_BALL, e.getAction(), - (int)(e.getX() * e.getXPrecision() * 100), - (int)(e.getY() * e.getYPrecision() * 100), - 0, 0); - return true; - } - - final static int MSG_MENU_LONG_PRESS = 1; - - final private Handler keyHandler = new Handler() { - @Override - public void handleMessage(Message msg) { - if (msg.what == MSG_MENU_LONG_PRESS) { - InputMethodManager imm = (InputMethodManager) - _context.getSystemService(_context.INPUT_METHOD_SERVICE); - - if (imm != null) - imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); - } - } - }; - - // OnKeyListener - final public boolean onKey(View v, int keyCode, KeyEvent e) { - final int action = e.getAction(); - - if (e.isSystem()) { - // filter what we handle - switch (keyCode) { - case KeyEvent.KEYCODE_BACK: - case KeyEvent.KEYCODE_MENU: - case KeyEvent.KEYCODE_CAMERA: - case KeyEvent.KEYCODE_SEARCH: - break; - - default: - return false; - } - - // no repeats for system keys - if (e.getRepeatCount() > 0) - return false; - - // Have to reimplement hold-down-menu-brings-up-softkeybd - // ourselves, since we are otherwise hijacking the menu key :( - // See com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel() - // for the usual Android implementation of this feature. - if (keyCode == KeyEvent.KEYCODE_MENU) { - final boolean fired = - !keyHandler.hasMessages(MSG_MENU_LONG_PRESS); - - keyHandler.removeMessages(MSG_MENU_LONG_PRESS); - - if (action == KeyEvent.ACTION_DOWN) { - keyHandler.sendMessageDelayed(keyHandler.obtainMessage( - MSG_MENU_LONG_PRESS), _longPress); - return true; - } - - if (fired) - return true; - - // only send up events of the menu button to the native side - if (action != KeyEvent.ACTION_UP) - return true; - } - - _scummvm.pushEvent(JE_SYS_KEY, action, keyCode, 0, 0, 0); - - return true; - } - - // sequence of characters - if (action == KeyEvent.ACTION_MULTIPLE && - keyCode == KeyEvent.KEYCODE_UNKNOWN) { - final KeyCharacterMap m = KeyCharacterMap.load(e.getDeviceId()); - final KeyEvent[] es = m.getEvents(e.getCharacters().toCharArray()); - - if (es == null) - return true; - - for (KeyEvent s : es) { - _scummvm.pushEvent(JE_KEY, s.getAction(), s.getKeyCode(), - s.getUnicodeChar() & KeyCharacterMap.COMBINING_ACCENT_MASK, - s.getMetaState(), s.getRepeatCount()); - } - - return true; - } - - switch (keyCode) { - case KeyEvent.KEYCODE_DPAD_UP: - case KeyEvent.KEYCODE_DPAD_DOWN: - case KeyEvent.KEYCODE_DPAD_LEFT: - case KeyEvent.KEYCODE_DPAD_RIGHT: - case KeyEvent.KEYCODE_DPAD_CENTER: - _scummvm.pushEvent(JE_DPAD, action, keyCode, - (int)(e.getEventTime() - e.getDownTime()), - e.getRepeatCount(), 0); - return true; - } - - _scummvm.pushEvent(JE_KEY, action, keyCode, - e.getUnicodeChar() & KeyCharacterMap.COMBINING_ACCENT_MASK, - e.getMetaState(), e.getRepeatCount()); - - return true; - } - - // OnTouchListener - final public boolean onTouch(View v, MotionEvent e) { - final int action = e.getAction(); - - // constants from APIv5: - // (action & ACTION_POINTER_INDEX_MASK) >> ACTION_POINTER_INDEX_SHIFT - final int pointer = (action & 0xff00) >> 8; - - if (pointer > 0) { - _scummvm.pushEvent(JE_MULTI, pointer, action & 0xff, // ACTION_MASK - (int)e.getX(), (int)e.getY(), 0); - return true; - } - - return _gd.onTouchEvent(e); - } - - // OnGestureListener - final public boolean onDown(MotionEvent e) { - _scummvm.pushEvent(JE_DOWN, (int)e.getX(), (int)e.getY(), 0, 0, 0); - return true; - } - - final public boolean onFling(MotionEvent e1, MotionEvent e2, - float velocityX, float velocityY) { - //Log.d(ScummVM.LOG_TAG, String.format("onFling: %s -> %s (%.3f %.3f)", - // e1.toString(), e2.toString(), - // velocityX, velocityY)); - - return true; - } - - final public void onLongPress(MotionEvent e) { - // disabled, interferes with drag&drop - } - - final public boolean onScroll(MotionEvent e1, MotionEvent e2, - float distanceX, float distanceY) { - _scummvm.pushEvent(JE_SCROLL, (int)e1.getX(), (int)e1.getY(), - (int)e2.getX(), (int)e2.getY(), 0); - - return true; - } - - final public void onShowPress(MotionEvent e) { - } - - final public boolean onSingleTapUp(MotionEvent e) { - _scummvm.pushEvent(JE_TAP, (int)e.getX(), (int)e.getY(), - (int)(e.getEventTime() - e.getDownTime()), 0, 0); - - return true; - } - - // OnDoubleTapListener - final public boolean onDoubleTap(MotionEvent e) { - return true; - } - - final public boolean onDoubleTapEvent(MotionEvent e) { - _scummvm.pushEvent(JE_DOUBLE_TAP, (int)e.getX(), (int)e.getY(), - e.getAction(), 0, 0); - - return true; - } - - final public boolean onSingleTapConfirmed(MotionEvent e) { - return true; - } -} diff --git a/backends/platform/android/org/inodes/gus/scummvm/Unpacker.java b/backends/platform/android/org/inodes/gus/scummvm/Unpacker.java deleted file mode 100644 index 6cc7f8eadb..0000000000 --- a/backends/platform/android/org/inodes/gus/scummvm/Unpacker.java +++ /dev/null @@ -1,378 +0,0 @@ -package org.inodes.gus.scummvm; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.ActivityNotFoundException; -import android.content.BroadcastReceiver; -import android.content.ComponentName; -import android.content.Context; -import android.content.ContextWrapper; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.pm.ActivityInfo; -import android.content.pm.PackageManager; -import android.content.pm.ResolveInfo; -import android.net.Uri; -import android.os.AsyncTask; -import android.os.Bundle; -import android.util.Log; -import android.widget.ProgressBar; - -import java.io.IOException; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.zip.ZipFile; -import java.util.zip.ZipEntry; - -public class Unpacker extends Activity { - protected final static String LOG_TAG = "ScummVM"; - // TODO don't hardcode this - private final static boolean PLUGINS_ENABLED = false; - private final static String META_NEXT_ACTIVITY = - "org.inodes.gus.unpacker.nextActivity"; - private ProgressBar mProgress; - private File mUnpackDest; // location to unpack into - private AsyncTask mUnpacker; - private final static int REQUEST_MARKET = 1; - - // Android 3.1+ only - public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 32; - - private static class UnpackJob { - public ZipFile zipfile; - public Set paths; - - public UnpackJob(ZipFile zipfile, Set paths) { - this.zipfile = zipfile; - this.paths = paths; - } - - public long UnpackSize() { - long size = 0; - for (String path: paths) { - ZipEntry entry = zipfile.getEntry(path); - if (entry != null) size += entry.getSize(); - } - return size; - } - } - - private class UnpackTask extends AsyncTask { - @Override - protected void onProgressUpdate(Integer... progress) { - mProgress.setIndeterminate(false); - mProgress.setMax(progress[1]); - mProgress.setProgress(progress[0]); - mProgress.postInvalidate(); - } - - @Override - protected void onPostExecute(Void result) { - Bundle md = getMetaData(); - String nextActivity = md.getString(META_NEXT_ACTIVITY); - if (nextActivity != null) { - final ComponentName cn = - ComponentName.unflattenFromString(nextActivity); - if (cn != null) { - final Intent origIntent = getIntent(); - Intent intent = new Intent(); - intent.setComponent(cn); - if (origIntent.getExtras() != null) - intent.putExtras(origIntent.getExtras()); - intent.putExtra(Intent.EXTRA_INTENT, origIntent); - intent.setDataAndType(origIntent.getData(), - origIntent.getType()); - //intent.fillIn(getIntent(), 0); - intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); - Log.i(LOG_TAG, - "Starting next activity with intent " + intent); - startActivity(intent); - } else { - Log.w(LOG_TAG, - "Unable to extract a component name from " + nextActivity); - } - } - - finish(); - } - - @Override - protected Void doInBackground(String... all_libs) { - // This will contain all unpack jobs - Map unpack_jobs = - new HashMap(all_libs.length); - - // This will contain all unpack filenames (so we can - // detect stale files in the unpack directory) - Set all_files = new HashSet(all_libs.length); - - for (String lib: all_libs) { - final Uri uri = Uri.parse(lib); - final String pkg = uri.getAuthority(); - final String path = uri.getPath().substring(1); // skip first / - - all_files.add(new File(path).getName()); - - UnpackJob job = unpack_jobs.get(pkg); - if (job == null) { - try { - // getPackageResourcePath is hidden in Context, - // but exposed in ContextWrapper... - ContextWrapper context = - new ContextWrapper(createPackageContext(pkg, 0)); - ZipFile zipfile = - new ZipFile(context.getPackageResourcePath()); - job = new UnpackJob(zipfile, new HashSet(1)); - } catch (PackageManager.NameNotFoundException e) { - Log.e(LOG_TAG, "Package " + pkg + - " not found", e); - continue; - } catch (IOException e) { - // FIXME: show some sort of GUI error dialog - Log.e(LOG_TAG, - "Error opening ZIP for package " + pkg, e); - continue; - } - unpack_jobs.put(pkg, job); - } - job.paths.add(path); - } - - // Delete stale filenames from mUnpackDest - for (File file: mUnpackDest.listFiles()) { - if (!all_files.contains(file.getName())) { - Log.i(LOG_TAG, - "Deleting stale cached file " + file); - file.delete(); - } - } - - int total_size = 0; - for (UnpackJob job: unpack_jobs.values()) - total_size += job.UnpackSize(); - - publishProgress(0, total_size); - - mUnpackDest.mkdirs(); - - int progress = 0; - - for (UnpackJob job: unpack_jobs.values()) { - try { - ZipFile zipfile = job.zipfile; - for (String path: job.paths) { - ZipEntry zipentry = zipfile.getEntry(path); - if (zipentry == null) - throw new FileNotFoundException( - "Couldn't find " + path + " in zip"); - File dest = new File(mUnpackDest, new File(path).getName()); - if (dest.exists() && - dest.lastModified() == zipentry.getTime() && - dest.length() == zipentry.getSize()) { - // Already unpacked - progress += zipentry.getSize(); - } else { - if (dest.exists()) - Log.d(LOG_TAG, - "Replacing " + dest.getPath() + - " old.mtime=" + dest.lastModified() + - " new.mtime=" + zipentry.getTime() + - " old.size=" + dest.length() + - " new.size=" + zipentry.getSize()); - else - Log.i(LOG_TAG, - "Extracting " + zipentry.getName() + - " from " + zipfile.getName() + - " to " + dest.getPath()); - - long next_update = progress; - - InputStream in = zipfile.getInputStream(zipentry); - OutputStream out = new FileOutputStream(dest); - int len; - byte[] buffer = new byte[4096]; - while ((len = in.read(buffer)) != -1) { - out.write(buffer, 0, len); - progress += len; - if (progress >= next_update) { - publishProgress(progress, total_size); - // Arbitrary limit of 2% update steps - next_update += total_size / 50; - } - } - - in.close(); - out.close(); - dest.setLastModified(zipentry.getTime()); - } - publishProgress(progress, total_size); - } - - zipfile.close(); - } catch (IOException e) { - // FIXME: show some sort of GUI error dialog - Log.e(LOG_TAG, "Error unpacking plugin", e); - } - } - - if (progress != total_size) - Log.d(LOG_TAG, "Ended with progress " + progress + - " != total size " + total_size); - - setResult(RESULT_OK); - - return null; - } - } - - private class PluginBroadcastReciever extends BroadcastReceiver { - @Override - public void onReceive(Context context, Intent intent) { - if (!intent.getAction() - .equals(ScummVMApplication.ACTION_PLUGIN_QUERY)) { - Log.e(LOG_TAG, - "Received unexpected action " + intent.getAction()); - return; - } - - Bundle extras = getResultExtras(false); - if (extras == null) { - // Nothing for us to do. - Unpacker.this.setResult(RESULT_OK); - finish(); - } - - ArrayList unpack_libs = - extras.getStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS); - - if (unpack_libs != null && !unpack_libs.isEmpty()) { - final String[] libs = - unpack_libs.toArray(new String[unpack_libs.size()]); - mUnpacker = new UnpackTask().execute(libs); - } - } - } - - private void initPlugins() { - Bundle extras = new Bundle(1); - - ArrayList unpack_libs = new ArrayList(1); - // This is the common ScummVM code (not really a "plugin" as such) - unpack_libs.add(new Uri.Builder() - .scheme("plugin") - .authority(getPackageName()) - .path("mylib/armeabi/libscummvm.so") - .toString()); - extras.putStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS, - unpack_libs); - - Intent intent = new Intent(ScummVMApplication.ACTION_PLUGIN_QUERY); - // Android 3.1 defaults to FLAG_EXCLUDE_STOPPED_PACKAGES, and since - // none of our plugins will ever be running, that is not helpful - intent.setFlags(FLAG_INCLUDE_STOPPED_PACKAGES); - sendOrderedBroadcast(intent, Manifest.permission.SCUMMVM_PLUGIN, - new PluginBroadcastReciever(), - null, RESULT_OK, null, extras); - } - - @Override - public void onCreate(Bundle b) { - super.onCreate(b); - - mUnpackDest = ScummVMApplication.getLastCacheDir(); - - setContentView(R.layout.splash); - mProgress = (ProgressBar)findViewById(R.id.progress); - - setResult(RESULT_CANCELED); - - tryUnpack(); - } - - private void tryUnpack() { - Intent intent = new Intent(ScummVMApplication.ACTION_PLUGIN_QUERY); - List plugins = getPackageManager() - .queryBroadcastReceivers(intent, 0); - if (PLUGINS_ENABLED && plugins.isEmpty()) { - // No plugins installed - AlertDialog.Builder alert = new AlertDialog.Builder(this) - .setTitle(R.string.no_plugins_title) - .setMessage(R.string.no_plugins_found) - .setIcon(android.R.drawable.ic_dialog_alert) - .setOnCancelListener(new DialogInterface.OnCancelListener() { - public void onCancel(DialogInterface dialog) { - finish(); - } - }) - .setNegativeButton(R.string.quit, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - finish(); - } - }); - - final Uri uri = Uri.parse("market://search?q=ScummVM plugin"); - final Intent market_intent = new Intent(Intent.ACTION_VIEW, uri); - if (getPackageManager().resolveActivity(market_intent, 0) != null) { - alert.setPositiveButton(R.string.to_market, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int which) { - dialog.dismiss(); - try { - startActivityForResult(market_intent, - REQUEST_MARKET); - } catch (ActivityNotFoundException e) { - Log.e(LOG_TAG, - "Error starting market", e); - } - } - }); - } - - alert.show(); - - } else { - // Already have at least one plugin installed - initPlugins(); - } - } - - @Override - public void onStop() { - if (mUnpacker != null) - mUnpacker.cancel(true); - super.onStop(); - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, - Intent data) { - switch (requestCode) { - case REQUEST_MARKET: - if (resultCode != RESULT_OK) - Log.w(LOG_TAG, "Market returned " + resultCode); - tryUnpack(); - break; - } - } - - private Bundle getMetaData() { - try { - ActivityInfo ai = getPackageManager() - .getActivityInfo(getComponentName(), PackageManager.GET_META_DATA); - return ai.metaData; - } catch (PackageManager.NameNotFoundException e) { - Log.w(LOG_TAG, "Unable to find my own meta-data", e); - return new Bundle(); - } - } -} diff --git a/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java b/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java new file mode 100644 index 0000000000..b593fc6abf --- /dev/null +++ b/backends/platform/android/org/scummvm/scummvm/EditableSurfaceView.java @@ -0,0 +1,61 @@ +package org.scummvm.scummvm; + +import android.content.Context; +import android.text.InputType; +import android.util.AttributeSet; +import android.view.SurfaceView; +import android.view.inputmethod.BaseInputConnection; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputConnection; +import android.view.inputmethod.InputMethodManager; + +public class EditableSurfaceView extends SurfaceView { + public EditableSurfaceView(Context context) { + super(context); + } + + public EditableSurfaceView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public EditableSurfaceView(Context context, AttributeSet attrs, + int defStyle) { + super(context, attrs, defStyle); + } + + @Override + public boolean onCheckIsTextEditor() { + return false; + } + + private class MyInputConnection extends BaseInputConnection { + public MyInputConnection() { + super(EditableSurfaceView.this, false); + } + + @Override + public boolean performEditorAction(int actionCode) { + if (actionCode == EditorInfo.IME_ACTION_DONE) { + InputMethodManager imm = (InputMethodManager) + getContext().getSystemService(Context.INPUT_METHOD_SERVICE); + imm.hideSoftInputFromWindow(getWindowToken(), 0); + } + + // Sends enter key + return super.performEditorAction(actionCode); + } + } + + @Override + public InputConnection onCreateInputConnection(EditorInfo outAttrs) { + outAttrs.initialCapsMode = 0; + outAttrs.initialSelEnd = outAttrs.initialSelStart = -1; + outAttrs.inputType = (InputType.TYPE_CLASS_TEXT | + InputType.TYPE_TEXT_VARIATION_NORMAL | + InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE); + outAttrs.imeOptions = (EditorInfo.IME_ACTION_DONE | + EditorInfo.IME_FLAG_NO_EXTRACT_UI); + + return new MyInputConnection(); + } +} diff --git a/backends/platform/android/org/scummvm/scummvm/PluginProvider.java b/backends/platform/android/org/scummvm/scummvm/PluginProvider.java new file mode 100644 index 0000000000..0c43529f83 --- /dev/null +++ b/backends/platform/android/org/scummvm/scummvm/PluginProvider.java @@ -0,0 +1,53 @@ +package org.scummvm.scummvm; + +import android.content.BroadcastReceiver; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.content.pm.ActivityInfo; +import android.content.pm.PackageManager; +import android.net.Uri; +import android.os.Bundle; +import android.util.Log; + +import java.util.ArrayList; + +public class PluginProvider extends BroadcastReceiver { + private final static String LOG_TAG = "ScummVM"; + + public final static String META_UNPACK_LIB = + "org.scummvm.scummvm.meta.UNPACK_LIB"; + + public void onReceive(Context context, Intent intent) { + if (!intent.getAction().equals(ScummVMApplication.ACTION_PLUGIN_QUERY)) + return; + + Bundle extras = getResultExtras(true); + + final ActivityInfo info; + try { + info = context.getPackageManager() + .getReceiverInfo(new ComponentName(context, this.getClass()), + PackageManager.GET_META_DATA); + } catch (PackageManager.NameNotFoundException e) { + Log.e(LOG_TAG, "Error finding my own info?", e); + return; + } + + String mylib = info.metaData.getString(META_UNPACK_LIB); + if (mylib != null) { + ArrayList all_libs = + extras.getStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS); + all_libs.add(new Uri.Builder() + .scheme("plugin") + .authority(context.getPackageName()) + .path(mylib) + .toString()); + + extras.putStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS, + all_libs); + } + + setResultExtras(extras); + } +} diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVM.java b/backends/platform/android/org/scummvm/scummvm/ScummVM.java new file mode 100644 index 0000000000..3a25b54eeb --- /dev/null +++ b/backends/platform/android/org/scummvm/scummvm/ScummVM.java @@ -0,0 +1,451 @@ +package org.scummvm.scummvm; + +import android.util.Log; +import android.content.res.AssetManager; +import android.view.SurfaceHolder; +import android.media.AudioFormat; +import android.media.AudioManager; +import android.media.AudioTrack; + +import javax.microedition.khronos.opengles.GL10; +import javax.microedition.khronos.egl.EGL10; +import javax.microedition.khronos.egl.EGLConfig; +import javax.microedition.khronos.egl.EGLContext; +import javax.microedition.khronos.egl.EGLDisplay; +import javax.microedition.khronos.egl.EGLSurface; + +import java.io.File; +import java.util.LinkedHashMap; + +public abstract class ScummVM implements SurfaceHolder.Callback, Runnable { + final protected static String LOG_TAG = "ScummVM"; + final private AssetManager _asset_manager; + final private Object _sem_surface; + + private EGL10 _egl; + private EGLDisplay _egl_display = EGL10.EGL_NO_DISPLAY; + private EGLConfig _egl_config; + private EGLContext _egl_context = EGL10.EGL_NO_CONTEXT; + private EGLSurface _egl_surface = EGL10.EGL_NO_SURFACE; + + private SurfaceHolder _surface_holder; + private AudioTrack _audio_track; + private int _sample_rate = 0; + private int _buffer_size = 0; + + private String[] _args; + + final private native void create(AssetManager asset_manager, + EGL10 egl, EGLDisplay egl_display, + AudioTrack audio_track, + int sample_rate, int buffer_size); + final private native void destroy(); + final private native void setSurface(int width, int height); + final private native int main(String[] args); + + // pause the engine and all native threads + final public native void setPause(boolean pause); + final public native void enableZoning(boolean enable); + // Feed an event to ScummVM. Safe to call from other threads. + final public native void pushEvent(int type, int arg1, int arg2, int arg3, + int arg4, int arg5); + + // Callbacks from C++ peer instance + abstract protected void getDPI(float[] values); + abstract protected void displayMessageOnOSD(String msg); + abstract protected void setWindowCaption(String caption); + abstract protected String[] getPluginDirectories(); + abstract protected void showVirtualKeyboard(boolean enable); + abstract protected String[] getSysArchives(); + + public ScummVM(AssetManager asset_manager, SurfaceHolder holder) { + _asset_manager = asset_manager; + _sem_surface = new Object(); + + holder.addCallback(this); + } + + // SurfaceHolder callback + final public void surfaceCreated(SurfaceHolder holder) { + Log.d(LOG_TAG, "surfaceCreated"); + + // no need to do anything, surfaceChanged() will be called in any case + } + + // SurfaceHolder callback + final public void surfaceChanged(SurfaceHolder holder, int format, + int width, int height) { + // the orientation may reset on standby mode and the theme manager + // could assert when using a portrait resolution. so lets not do that. + if (height > width) { + Log.d(LOG_TAG, String.format("Ignoring surfaceChanged: %dx%d (%d)", + width, height, format)); + return; + } + + Log.d(LOG_TAG, String.format("surfaceChanged: %dx%d (%d)", + width, height, format)); + + synchronized(_sem_surface) { + _surface_holder = holder; + _sem_surface.notifyAll(); + } + + // store values for the native code + setSurface(width, height); + } + + // SurfaceHolder callback + final public void surfaceDestroyed(SurfaceHolder holder) { + Log.d(LOG_TAG, "surfaceDestroyed"); + + synchronized(_sem_surface) { + _surface_holder = null; + _sem_surface.notifyAll(); + } + + // clear values for the native code + setSurface(0, 0); + } + + final public void setArgs(String[] args) { + _args = args; + } + + final public void run() { + try { + initAudio(); + initEGL(); + + // wait for the surfaceChanged callback + synchronized(_sem_surface) { + while (_surface_holder == null) + _sem_surface.wait(); + } + } catch (Exception e) { + deinitEGL(); + deinitAudio(); + + throw new RuntimeException("Error preparing the ScummVM thread", e); + } + + create(_asset_manager, _egl, _egl_display, + _audio_track, _sample_rate, _buffer_size); + + int res = main(_args); + + destroy(); + + deinitEGL(); + deinitAudio(); + + // On exit, tear everything down for a fresh restart next time. + System.exit(res); + } + + final private void initEGL() throws Exception { + _egl = (EGL10)EGLContext.getEGL(); + _egl_display = _egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY); + + int[] version = new int[2]; + _egl.eglInitialize(_egl_display, version); + + int[] num_config = new int[1]; + _egl.eglGetConfigs(_egl_display, null, 0, num_config); + + final int numConfigs = num_config[0]; + + if (numConfigs <= 0) + throw new IllegalArgumentException("No EGL configs"); + + EGLConfig[] configs = new EGLConfig[numConfigs]; + _egl.eglGetConfigs(_egl_display, configs, numConfigs, num_config); + + // Android's eglChooseConfig is busted in several versions and + // devices so we have to filter/rank the configs ourselves. + _egl_config = chooseEglConfig(configs); + + _egl_context = _egl.eglCreateContext(_egl_display, _egl_config, + EGL10.EGL_NO_CONTEXT, null); + + if (_egl_context == EGL10.EGL_NO_CONTEXT) + throw new Exception(String.format("Failed to create context: 0x%x", + _egl.eglGetError())); + } + + // Callback from C++ peer instance + final protected EGLSurface initSurface() throws Exception { + _egl_surface = _egl.eglCreateWindowSurface(_egl_display, _egl_config, + _surface_holder, null); + + if (_egl_surface == EGL10.EGL_NO_SURFACE) + throw new Exception(String.format( + "eglCreateWindowSurface failed: 0x%x", _egl.eglGetError())); + + _egl.eglMakeCurrent(_egl_display, _egl_surface, _egl_surface, + _egl_context); + + GL10 gl = (GL10)_egl_context.getGL(); + + Log.i(LOG_TAG, String.format("Using EGL %s (%s); GL %s/%s (%s)", + _egl.eglQueryString(_egl_display, EGL10.EGL_VERSION), + _egl.eglQueryString(_egl_display, EGL10.EGL_VENDOR), + gl.glGetString(GL10.GL_VERSION), + gl.glGetString(GL10.GL_RENDERER), + gl.glGetString(GL10.GL_VENDOR))); + + return _egl_surface; + } + + // Callback from C++ peer instance + final protected void deinitSurface() { + if (_egl_display != EGL10.EGL_NO_DISPLAY) { + _egl.eglMakeCurrent(_egl_display, EGL10.EGL_NO_SURFACE, + EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); + + if (_egl_surface != EGL10.EGL_NO_SURFACE) + _egl.eglDestroySurface(_egl_display, _egl_surface); + } + + _egl_surface = EGL10.EGL_NO_SURFACE; + } + + final private void deinitEGL() { + if (_egl_display != EGL10.EGL_NO_DISPLAY) { + _egl.eglMakeCurrent(_egl_display, EGL10.EGL_NO_SURFACE, + EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT); + + if (_egl_surface != EGL10.EGL_NO_SURFACE) + _egl.eglDestroySurface(_egl_display, _egl_surface); + + if (_egl_context != EGL10.EGL_NO_CONTEXT) + _egl.eglDestroyContext(_egl_display, _egl_context); + + _egl.eglTerminate(_egl_display); + } + + _egl_surface = EGL10.EGL_NO_SURFACE; + _egl_context = EGL10.EGL_NO_CONTEXT; + _egl_config = null; + _egl_display = EGL10.EGL_NO_DISPLAY; + _egl = null; + } + + final private void initAudio() throws Exception { + _sample_rate = AudioTrack.getNativeOutputSampleRate( + AudioManager.STREAM_MUSIC); + _buffer_size = AudioTrack.getMinBufferSize(_sample_rate, + AudioFormat.CHANNEL_CONFIGURATION_STEREO, + AudioFormat.ENCODING_PCM_16BIT); + + // ~50ms + int buffer_size_want = (_sample_rate * 2 * 2 / 20) & ~1023; + + if (_buffer_size < buffer_size_want) { + Log.w(LOG_TAG, String.format( + "adjusting audio buffer size (was: %d)", _buffer_size)); + + _buffer_size = buffer_size_want; + } + + Log.i(LOG_TAG, String.format("Using %d bytes buffer for %dHz audio", + _buffer_size, _sample_rate)); + + _audio_track = new AudioTrack(AudioManager.STREAM_MUSIC, + _sample_rate, + AudioFormat.CHANNEL_CONFIGURATION_STEREO, + AudioFormat.ENCODING_PCM_16BIT, + _buffer_size, + AudioTrack.MODE_STREAM); + + if (_audio_track.getState() != AudioTrack.STATE_INITIALIZED) + throw new Exception( + String.format("Error initializing AudioTrack: %d", + _audio_track.getState())); + } + + final private void deinitAudio() { + if (_audio_track != null) + _audio_track.stop(); + + _audio_track = null; + _buffer_size = 0; + _sample_rate = 0; + } + + private static final int[] s_eglAttribs = { + EGL10.EGL_CONFIG_ID, + EGL10.EGL_BUFFER_SIZE, + EGL10.EGL_RED_SIZE, + EGL10.EGL_GREEN_SIZE, + EGL10.EGL_BLUE_SIZE, + EGL10.EGL_ALPHA_SIZE, + EGL10.EGL_CONFIG_CAVEAT, + EGL10.EGL_DEPTH_SIZE, + EGL10.EGL_LEVEL, + EGL10.EGL_MAX_PBUFFER_WIDTH, + EGL10.EGL_MAX_PBUFFER_HEIGHT, + EGL10.EGL_MAX_PBUFFER_PIXELS, + EGL10.EGL_NATIVE_RENDERABLE, + EGL10.EGL_NATIVE_VISUAL_ID, + EGL10.EGL_NATIVE_VISUAL_TYPE, + EGL10.EGL_SAMPLE_BUFFERS, + EGL10.EGL_SAMPLES, + EGL10.EGL_STENCIL_SIZE, + EGL10.EGL_SURFACE_TYPE, + EGL10.EGL_TRANSPARENT_TYPE, + EGL10.EGL_TRANSPARENT_RED_VALUE, + EGL10.EGL_TRANSPARENT_GREEN_VALUE, + EGL10.EGL_TRANSPARENT_BLUE_VALUE + }; + + final private class EglAttribs extends LinkedHashMap { + public EglAttribs(EGLConfig config) { + super(s_eglAttribs.length); + + int[] value = new int[1]; + + for (int i : s_eglAttribs) { + _egl.eglGetConfigAttrib(_egl_display, config, i, value); + + put(i, value[0]); + } + } + + private int weightBits(int attr, int size) { + final int value = get(attr); + + int score = 0; + + if (value == size || (size > 0 && value > size)) + score += 10; + + // penalize for wasted bits + score -= value - size; + + return score; + } + + public int weight() { + int score = 10000; + + if (get(EGL10.EGL_CONFIG_CAVEAT) != EGL10.EGL_NONE) + score -= 1000; + + // less MSAA is better + score -= get(EGL10.EGL_SAMPLES) * 100; + + // Must be at least 565, but then smaller is better + score += weightBits(EGL10.EGL_RED_SIZE, 5); + score += weightBits(EGL10.EGL_GREEN_SIZE, 6); + score += weightBits(EGL10.EGL_BLUE_SIZE, 5); + score += weightBits(EGL10.EGL_ALPHA_SIZE, 0); + score += weightBits(EGL10.EGL_DEPTH_SIZE, 0); + score += weightBits(EGL10.EGL_STENCIL_SIZE, 0); + + return score; + } + + public String toString() { + String s; + + if (get(EGL10.EGL_ALPHA_SIZE) > 0) + s = String.format("[%d] RGBA%d%d%d%d", + get(EGL10.EGL_CONFIG_ID), + get(EGL10.EGL_RED_SIZE), + get(EGL10.EGL_GREEN_SIZE), + get(EGL10.EGL_BLUE_SIZE), + get(EGL10.EGL_ALPHA_SIZE)); + else + s = String.format("[%d] RGB%d%d%d", + get(EGL10.EGL_CONFIG_ID), + get(EGL10.EGL_RED_SIZE), + get(EGL10.EGL_GREEN_SIZE), + get(EGL10.EGL_BLUE_SIZE)); + + if (get(EGL10.EGL_DEPTH_SIZE) > 0) + s += String.format(" D%d", get(EGL10.EGL_DEPTH_SIZE)); + + if (get(EGL10.EGL_STENCIL_SIZE) > 0) + s += String.format(" S%d", get(EGL10.EGL_STENCIL_SIZE)); + + if (get(EGL10.EGL_SAMPLES) > 0) + s += String.format(" MSAAx%d", get(EGL10.EGL_SAMPLES)); + + if ((get(EGL10.EGL_SURFACE_TYPE) & EGL10.EGL_WINDOW_BIT) > 0) + s += " W"; + if ((get(EGL10.EGL_SURFACE_TYPE) & EGL10.EGL_PBUFFER_BIT) > 0) + s += " P"; + if ((get(EGL10.EGL_SURFACE_TYPE) & EGL10.EGL_PIXMAP_BIT) > 0) + s += " X"; + + switch (get(EGL10.EGL_CONFIG_CAVEAT)) { + case EGL10.EGL_NONE: + break; + + case EGL10.EGL_SLOW_CONFIG: + s += " SLOW"; + break; + + case EGL10.EGL_NON_CONFORMANT_CONFIG: + s += " NON_CONFORMANT"; + + default: + s += String.format(" unknown CAVEAT 0x%x", + get(EGL10.EGL_CONFIG_CAVEAT)); + } + + return s; + } + }; + + final private EGLConfig chooseEglConfig(EGLConfig[] configs) { + EGLConfig res = configs[0]; + int bestScore = -1; + + Log.d(LOG_TAG, "EGL configs:"); + + for (EGLConfig config : configs) { + EglAttribs attr = new EglAttribs(config); + + // must have + if ((attr.get(EGL10.EGL_SURFACE_TYPE) & EGL10.EGL_WINDOW_BIT) == 0) + continue; + + int score = attr.weight(); + + Log.d(LOG_TAG, String.format("%s (%d)", attr.toString(), score)); + + if (score > bestScore) { + res = config; + bestScore = score; + } + } + + if (bestScore < 0) + Log.e(LOG_TAG, + "Unable to find an acceptable EGL config, expect badness."); + + Log.d(LOG_TAG, String.format("Chosen EGL config: %s", + new EglAttribs(res).toString())); + + return res; + } + + static { + // For grabbing with gdb... + final boolean sleep_for_debugger = false; + if (sleep_for_debugger) { + try { + Thread.sleep(20 * 1000); + } catch (InterruptedException e) { + } + } + + File cache_dir = ScummVMApplication.getLastCacheDir(); + String libname = System.mapLibraryName("scummvm"); + File libpath = new File(cache_dir, libname); + + System.load(libpath.getPath()); + } +} diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java new file mode 100644 index 0000000000..a41e843323 --- /dev/null +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java @@ -0,0 +1,224 @@ +package org.scummvm.scummvm; + +import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.media.AudioManager; +import android.os.Bundle; +import android.os.Environment; +import android.util.DisplayMetrics; +import android.util.Log; +import android.view.SurfaceView; +import android.view.SurfaceHolder; +import android.view.MotionEvent; +import android.view.inputmethod.InputMethodManager; +import android.widget.Toast; + +public class ScummVMActivity extends Activity { + + private class MyScummVM extends ScummVM { + private boolean usingSmallScreen() { + // Multiple screen sizes came in with Android 1.6. Have + // to use reflection in order to continue supporting 1.5 + // devices :( + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + + try { + // This 'density' term is very confusing. + int DENSITY_LOW = metrics.getClass().getField("DENSITY_LOW").getInt(null); + int densityDpi = metrics.getClass().getField("densityDpi").getInt(metrics); + return densityDpi <= DENSITY_LOW; + } catch (Exception e) { + return false; + } + } + + public MyScummVM(SurfaceHolder holder) { + super(ScummVMActivity.this.getAssets(), holder); + + // Enable ScummVM zoning on 'small' screens. + // FIXME make this optional for the user + // disabled for now since it crops too much + //enableZoning(usingSmallScreen()); + } + + @Override + protected void getDPI(float[] values) { + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + + values[0] = metrics.xdpi; + values[1] = metrics.ydpi; + } + + @Override + protected void displayMessageOnOSD(String msg) { + Log.i(LOG_TAG, "OSD: " + msg); + Toast.makeText(ScummVMActivity.this, msg, Toast.LENGTH_LONG).show(); + } + + @Override + protected void setWindowCaption(final String caption) { + runOnUiThread(new Runnable() { + public void run() { + setTitle(caption); + } + }); + } + + @Override + protected String[] getPluginDirectories() { + String[] dirs = new String[1]; + dirs[0] = ScummVMApplication.getLastCacheDir().getPath(); + return dirs; + } + + @Override + protected void showVirtualKeyboard(final boolean enable) { + runOnUiThread(new Runnable() { + public void run() { + showKeyboard(enable); + } + }); + } + + @Override + protected String[] getSysArchives() { + return new String[0]; + } + + } + + private MyScummVM _scummvm; + private ScummVMEvents _events; + private Thread _scummvm_thread; + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setVolumeControlStream(AudioManager.STREAM_MUSIC); + + setContentView(R.layout.main); + takeKeyEvents(true); + + // This is a common enough error that we should warn about it + // explicitly. + if (!Environment.getExternalStorageDirectory().canRead()) { + new AlertDialog.Builder(this) + .setTitle(R.string.no_sdcard_title) + .setIcon(android.R.drawable.ic_dialog_alert) + .setMessage(R.string.no_sdcard) + .setNegativeButton(R.string.quit, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + finish(); + } + }) + .show(); + + return; + } + + SurfaceView main_surface = (SurfaceView)findViewById(R.id.main_surface); + + main_surface.requestFocus(); + + getFilesDir().mkdirs(); + + // Start ScummVM + _scummvm = new MyScummVM(main_surface.getHolder()); + + _scummvm.setArgs(new String[] { + "ScummVM", + "--config=" + getFileStreamPath("scummvmrc").getPath(), + "--path=" + Environment.getExternalStorageDirectory().getPath(), + "--gui-theme=scummmodern", + "--savepath=" + getDir("saves", 0).getPath() + }); + + _events = new ScummVMEvents(this, _scummvm); + + main_surface.setOnKeyListener(_events); + main_surface.setOnTouchListener(_events); + + _scummvm_thread = new Thread(_scummvm, "ScummVM"); + _scummvm_thread.start(); + } + + @Override + public void onStart() { + Log.d(ScummVM.LOG_TAG, "onStart"); + + super.onStart(); + } + + @Override + public void onResume() { + Log.d(ScummVM.LOG_TAG, "onResume"); + + super.onResume(); + + if (_scummvm != null) + _scummvm.setPause(false); + } + + @Override + public void onPause() { + Log.d(ScummVM.LOG_TAG, "onPause"); + + super.onPause(); + + if (_scummvm != null) + _scummvm.setPause(true); + } + + @Override + public void onStop() { + Log.d(ScummVM.LOG_TAG, "onStop"); + + super.onStop(); + } + + @Override + public void onDestroy() { + Log.d(ScummVM.LOG_TAG, "onDestroy"); + + super.onDestroy(); + + if (_events != null) { + _events.sendQuitEvent(); + + try { + // 1s timeout + _scummvm_thread.join(1000); + } catch (InterruptedException e) { + Log.i(ScummVM.LOG_TAG, "Error while joining ScummVM thread", e); + } + + _scummvm = null; + } + } + + @Override + public boolean onTrackballEvent(MotionEvent e) { + if (_events != null) + return _events.onTrackballEvent(e); + + return false; + } + + private void showKeyboard(boolean show) { + SurfaceView main_surface = (SurfaceView)findViewById(R.id.main_surface); + InputMethodManager imm = (InputMethodManager) + getSystemService(INPUT_METHOD_SERVICE); + + if (show) + imm.showSoftInput(main_surface, InputMethodManager.SHOW_IMPLICIT); + else + imm.hideSoftInputFromWindow(main_surface.getWindowToken(), + InputMethodManager.HIDE_IMPLICIT_ONLY); + } +} diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java b/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java new file mode 100644 index 0000000000..9241cba918 --- /dev/null +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java @@ -0,0 +1,30 @@ +package org.scummvm.scummvm; + +import android.app.Application; + +import java.io.File; + +public class ScummVMApplication extends Application { + public final static String ACTION_PLUGIN_QUERY = "org.scummvm.scummvm.action.PLUGIN_QUERY"; + public final static String EXTRA_UNPACK_LIBS = "org.scummvm.scummvm.extra.UNPACK_LIBS"; + + private static File _cache_dir; + + @Override + public void onCreate() { + super.onCreate(); + + // This is still on /data :( + _cache_dir = getCacheDir(); + // This is mounted noexec :( + //cache_dir = new File(Environment.getExternalStorageDirectory(), + // "/.ScummVM.tmp"); + // This is owned by download manager and requires special + // permissions to access :( + //cache_dir = Environment.getDownloadCacheDirectory(); + } + + public static File getLastCacheDir() { + return _cache_dir; + } +} diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java new file mode 100644 index 0000000000..86227b9352 --- /dev/null +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java @@ -0,0 +1,231 @@ +package org.scummvm.scummvm; + +import android.os.Handler; +import android.os.Message; +import android.util.Log; +import android.content.Context; +import android.view.KeyEvent; +import android.view.KeyCharacterMap; +import android.view.MotionEvent; +import android.view.View; +import android.view.ViewConfiguration; +import android.view.GestureDetector; +import android.view.inputmethod.InputMethodManager; + +public class ScummVMEvents implements + android.view.View.OnKeyListener, + android.view.View.OnTouchListener, + android.view.GestureDetector.OnGestureListener, + android.view.GestureDetector.OnDoubleTapListener { + + public static final int JE_SYS_KEY = 0; + public static final int JE_KEY = 1; + public static final int JE_DPAD = 2; + public static final int JE_DOWN = 3; + public static final int JE_SCROLL = 4; + public static final int JE_TAP = 5; + public static final int JE_DOUBLE_TAP = 6; + public static final int JE_MULTI = 7; + public static final int JE_BALL = 8; + public static final int JE_QUIT = 0x1000; + + final protected Context _context; + final protected ScummVM _scummvm; + final protected GestureDetector _gd; + final protected int _longPress; + + public ScummVMEvents(Context context, ScummVM scummvm) { + _context = context; + _scummvm = scummvm; + + _gd = new GestureDetector(context, this); + _gd.setOnDoubleTapListener(this); + _gd.setIsLongpressEnabled(false); + + _longPress = ViewConfiguration.getLongPressTimeout(); + } + + final public void sendQuitEvent() { + _scummvm.pushEvent(JE_QUIT, 0, 0, 0, 0, 0); + } + + public boolean onTrackballEvent(MotionEvent e) { + _scummvm.pushEvent(JE_BALL, e.getAction(), + (int)(e.getX() * e.getXPrecision() * 100), + (int)(e.getY() * e.getYPrecision() * 100), + 0, 0); + return true; + } + + final static int MSG_MENU_LONG_PRESS = 1; + + final private Handler keyHandler = new Handler() { + @Override + public void handleMessage(Message msg) { + if (msg.what == MSG_MENU_LONG_PRESS) { + InputMethodManager imm = (InputMethodManager) + _context.getSystemService(_context.INPUT_METHOD_SERVICE); + + if (imm != null) + imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); + } + } + }; + + // OnKeyListener + final public boolean onKey(View v, int keyCode, KeyEvent e) { + final int action = e.getAction(); + + if (e.isSystem()) { + // filter what we handle + switch (keyCode) { + case KeyEvent.KEYCODE_BACK: + case KeyEvent.KEYCODE_MENU: + case KeyEvent.KEYCODE_CAMERA: + case KeyEvent.KEYCODE_SEARCH: + break; + + default: + return false; + } + + // no repeats for system keys + if (e.getRepeatCount() > 0) + return false; + + // Have to reimplement hold-down-menu-brings-up-softkeybd + // ourselves, since we are otherwise hijacking the menu key :( + // See com.android.internal.policy.impl.PhoneWindow.onKeyDownPanel() + // for the usual Android implementation of this feature. + if (keyCode == KeyEvent.KEYCODE_MENU) { + final boolean fired = + !keyHandler.hasMessages(MSG_MENU_LONG_PRESS); + + keyHandler.removeMessages(MSG_MENU_LONG_PRESS); + + if (action == KeyEvent.ACTION_DOWN) { + keyHandler.sendMessageDelayed(keyHandler.obtainMessage( + MSG_MENU_LONG_PRESS), _longPress); + return true; + } + + if (fired) + return true; + + // only send up events of the menu button to the native side + if (action != KeyEvent.ACTION_UP) + return true; + } + + _scummvm.pushEvent(JE_SYS_KEY, action, keyCode, 0, 0, 0); + + return true; + } + + // sequence of characters + if (action == KeyEvent.ACTION_MULTIPLE && + keyCode == KeyEvent.KEYCODE_UNKNOWN) { + final KeyCharacterMap m = KeyCharacterMap.load(e.getDeviceId()); + final KeyEvent[] es = m.getEvents(e.getCharacters().toCharArray()); + + if (es == null) + return true; + + for (KeyEvent s : es) { + _scummvm.pushEvent(JE_KEY, s.getAction(), s.getKeyCode(), + s.getUnicodeChar() & KeyCharacterMap.COMBINING_ACCENT_MASK, + s.getMetaState(), s.getRepeatCount()); + } + + return true; + } + + switch (keyCode) { + case KeyEvent.KEYCODE_DPAD_UP: + case KeyEvent.KEYCODE_DPAD_DOWN: + case KeyEvent.KEYCODE_DPAD_LEFT: + case KeyEvent.KEYCODE_DPAD_RIGHT: + case KeyEvent.KEYCODE_DPAD_CENTER: + _scummvm.pushEvent(JE_DPAD, action, keyCode, + (int)(e.getEventTime() - e.getDownTime()), + e.getRepeatCount(), 0); + return true; + } + + _scummvm.pushEvent(JE_KEY, action, keyCode, + e.getUnicodeChar() & KeyCharacterMap.COMBINING_ACCENT_MASK, + e.getMetaState(), e.getRepeatCount()); + + return true; + } + + // OnTouchListener + final public boolean onTouch(View v, MotionEvent e) { + final int action = e.getAction(); + + // constants from APIv5: + // (action & ACTION_POINTER_INDEX_MASK) >> ACTION_POINTER_INDEX_SHIFT + final int pointer = (action & 0xff00) >> 8; + + if (pointer > 0) { + _scummvm.pushEvent(JE_MULTI, pointer, action & 0xff, // ACTION_MASK + (int)e.getX(), (int)e.getY(), 0); + return true; + } + + return _gd.onTouchEvent(e); + } + + // OnGestureListener + final public boolean onDown(MotionEvent e) { + _scummvm.pushEvent(JE_DOWN, (int)e.getX(), (int)e.getY(), 0, 0, 0); + return true; + } + + final public boolean onFling(MotionEvent e1, MotionEvent e2, + float velocityX, float velocityY) { + //Log.d(ScummVM.LOG_TAG, String.format("onFling: %s -> %s (%.3f %.3f)", + // e1.toString(), e2.toString(), + // velocityX, velocityY)); + + return true; + } + + final public void onLongPress(MotionEvent e) { + // disabled, interferes with drag&drop + } + + final public boolean onScroll(MotionEvent e1, MotionEvent e2, + float distanceX, float distanceY) { + _scummvm.pushEvent(JE_SCROLL, (int)e1.getX(), (int)e1.getY(), + (int)e2.getX(), (int)e2.getY(), 0); + + return true; + } + + final public void onShowPress(MotionEvent e) { + } + + final public boolean onSingleTapUp(MotionEvent e) { + _scummvm.pushEvent(JE_TAP, (int)e.getX(), (int)e.getY(), + (int)(e.getEventTime() - e.getDownTime()), 0, 0); + + return true; + } + + // OnDoubleTapListener + final public boolean onDoubleTap(MotionEvent e) { + return true; + } + + final public boolean onDoubleTapEvent(MotionEvent e) { + _scummvm.pushEvent(JE_DOUBLE_TAP, (int)e.getX(), (int)e.getY(), + e.getAction(), 0, 0); + + return true; + } + + final public boolean onSingleTapConfirmed(MotionEvent e) { + return true; + } +} diff --git a/backends/platform/android/org/scummvm/scummvm/Unpacker.java b/backends/platform/android/org/scummvm/scummvm/Unpacker.java new file mode 100644 index 0000000000..4564d96622 --- /dev/null +++ b/backends/platform/android/org/scummvm/scummvm/Unpacker.java @@ -0,0 +1,378 @@ +package org.scummvm.scummvm; + +import android.app.Activity; +import android.app.AlertDialog; +import android.content.ActivityNotFoundException; +import android.content.BroadcastReceiver; +import android.content.ComponentName; +import android.content.Context; +import android.content.ContextWrapper; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.pm.ActivityInfo; +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.net.Uri; +import android.os.AsyncTask; +import android.os.Bundle; +import android.util.Log; +import android.widget.ProgressBar; + +import java.io.IOException; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.zip.ZipFile; +import java.util.zip.ZipEntry; + +public class Unpacker extends Activity { + protected final static String LOG_TAG = "ScummVM"; + // TODO don't hardcode this + private final static boolean PLUGINS_ENABLED = false; + private final static String META_NEXT_ACTIVITY = + "org.scummvm.unpacker.nextActivity"; + private ProgressBar mProgress; + private File mUnpackDest; // location to unpack into + private AsyncTask mUnpacker; + private final static int REQUEST_MARKET = 1; + + // Android 3.1+ only + public static final int FLAG_INCLUDE_STOPPED_PACKAGES = 32; + + private static class UnpackJob { + public ZipFile zipfile; + public Set paths; + + public UnpackJob(ZipFile zipfile, Set paths) { + this.zipfile = zipfile; + this.paths = paths; + } + + public long UnpackSize() { + long size = 0; + for (String path: paths) { + ZipEntry entry = zipfile.getEntry(path); + if (entry != null) size += entry.getSize(); + } + return size; + } + } + + private class UnpackTask extends AsyncTask { + @Override + protected void onProgressUpdate(Integer... progress) { + mProgress.setIndeterminate(false); + mProgress.setMax(progress[1]); + mProgress.setProgress(progress[0]); + mProgress.postInvalidate(); + } + + @Override + protected void onPostExecute(Void result) { + Bundle md = getMetaData(); + String nextActivity = md.getString(META_NEXT_ACTIVITY); + if (nextActivity != null) { + final ComponentName cn = + ComponentName.unflattenFromString(nextActivity); + if (cn != null) { + final Intent origIntent = getIntent(); + Intent intent = new Intent(); + intent.setComponent(cn); + if (origIntent.getExtras() != null) + intent.putExtras(origIntent.getExtras()); + intent.putExtra(Intent.EXTRA_INTENT, origIntent); + intent.setDataAndType(origIntent.getData(), + origIntent.getType()); + //intent.fillIn(getIntent(), 0); + intent.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP); + Log.i(LOG_TAG, + "Starting next activity with intent " + intent); + startActivity(intent); + } else { + Log.w(LOG_TAG, + "Unable to extract a component name from " + nextActivity); + } + } + + finish(); + } + + @Override + protected Void doInBackground(String... all_libs) { + // This will contain all unpack jobs + Map unpack_jobs = + new HashMap(all_libs.length); + + // This will contain all unpack filenames (so we can + // detect stale files in the unpack directory) + Set all_files = new HashSet(all_libs.length); + + for (String lib: all_libs) { + final Uri uri = Uri.parse(lib); + final String pkg = uri.getAuthority(); + final String path = uri.getPath().substring(1); // skip first / + + all_files.add(new File(path).getName()); + + UnpackJob job = unpack_jobs.get(pkg); + if (job == null) { + try { + // getPackageResourcePath is hidden in Context, + // but exposed in ContextWrapper... + ContextWrapper context = + new ContextWrapper(createPackageContext(pkg, 0)); + ZipFile zipfile = + new ZipFile(context.getPackageResourcePath()); + job = new UnpackJob(zipfile, new HashSet(1)); + } catch (PackageManager.NameNotFoundException e) { + Log.e(LOG_TAG, "Package " + pkg + + " not found", e); + continue; + } catch (IOException e) { + // FIXME: show some sort of GUI error dialog + Log.e(LOG_TAG, + "Error opening ZIP for package " + pkg, e); + continue; + } + unpack_jobs.put(pkg, job); + } + job.paths.add(path); + } + + // Delete stale filenames from mUnpackDest + for (File file: mUnpackDest.listFiles()) { + if (!all_files.contains(file.getName())) { + Log.i(LOG_TAG, + "Deleting stale cached file " + file); + file.delete(); + } + } + + int total_size = 0; + for (UnpackJob job: unpack_jobs.values()) + total_size += job.UnpackSize(); + + publishProgress(0, total_size); + + mUnpackDest.mkdirs(); + + int progress = 0; + + for (UnpackJob job: unpack_jobs.values()) { + try { + ZipFile zipfile = job.zipfile; + for (String path: job.paths) { + ZipEntry zipentry = zipfile.getEntry(path); + if (zipentry == null) + throw new FileNotFoundException( + "Couldn't find " + path + " in zip"); + File dest = new File(mUnpackDest, new File(path).getName()); + if (dest.exists() && + dest.lastModified() == zipentry.getTime() && + dest.length() == zipentry.getSize()) { + // Already unpacked + progress += zipentry.getSize(); + } else { + if (dest.exists()) + Log.d(LOG_TAG, + "Replacing " + dest.getPath() + + " old.mtime=" + dest.lastModified() + + " new.mtime=" + zipentry.getTime() + + " old.size=" + dest.length() + + " new.size=" + zipentry.getSize()); + else + Log.i(LOG_TAG, + "Extracting " + zipentry.getName() + + " from " + zipfile.getName() + + " to " + dest.getPath()); + + long next_update = progress; + + InputStream in = zipfile.getInputStream(zipentry); + OutputStream out = new FileOutputStream(dest); + int len; + byte[] buffer = new byte[4096]; + while ((len = in.read(buffer)) != -1) { + out.write(buffer, 0, len); + progress += len; + if (progress >= next_update) { + publishProgress(progress, total_size); + // Arbitrary limit of 2% update steps + next_update += total_size / 50; + } + } + + in.close(); + out.close(); + dest.setLastModified(zipentry.getTime()); + } + publishProgress(progress, total_size); + } + + zipfile.close(); + } catch (IOException e) { + // FIXME: show some sort of GUI error dialog + Log.e(LOG_TAG, "Error unpacking plugin", e); + } + } + + if (progress != total_size) + Log.d(LOG_TAG, "Ended with progress " + progress + + " != total size " + total_size); + + setResult(RESULT_OK); + + return null; + } + } + + private class PluginBroadcastReciever extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + if (!intent.getAction() + .equals(ScummVMApplication.ACTION_PLUGIN_QUERY)) { + Log.e(LOG_TAG, + "Received unexpected action " + intent.getAction()); + return; + } + + Bundle extras = getResultExtras(false); + if (extras == null) { + // Nothing for us to do. + Unpacker.this.setResult(RESULT_OK); + finish(); + } + + ArrayList unpack_libs = + extras.getStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS); + + if (unpack_libs != null && !unpack_libs.isEmpty()) { + final String[] libs = + unpack_libs.toArray(new String[unpack_libs.size()]); + mUnpacker = new UnpackTask().execute(libs); + } + } + } + + private void initPlugins() { + Bundle extras = new Bundle(1); + + ArrayList unpack_libs = new ArrayList(1); + // This is the common ScummVM code (not really a "plugin" as such) + unpack_libs.add(new Uri.Builder() + .scheme("plugin") + .authority(getPackageName()) + .path("mylib/armeabi/libscummvm.so") + .toString()); + extras.putStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS, + unpack_libs); + + Intent intent = new Intent(ScummVMApplication.ACTION_PLUGIN_QUERY); + // Android 3.1 defaults to FLAG_EXCLUDE_STOPPED_PACKAGES, and since + // none of our plugins will ever be running, that is not helpful + intent.setFlags(FLAG_INCLUDE_STOPPED_PACKAGES); + sendOrderedBroadcast(intent, Manifest.permission.SCUMMVM_PLUGIN, + new PluginBroadcastReciever(), + null, RESULT_OK, null, extras); + } + + @Override + public void onCreate(Bundle b) { + super.onCreate(b); + + mUnpackDest = ScummVMApplication.getLastCacheDir(); + + setContentView(R.layout.splash); + mProgress = (ProgressBar)findViewById(R.id.progress); + + setResult(RESULT_CANCELED); + + tryUnpack(); + } + + private void tryUnpack() { + Intent intent = new Intent(ScummVMApplication.ACTION_PLUGIN_QUERY); + List plugins = getPackageManager() + .queryBroadcastReceivers(intent, 0); + if (PLUGINS_ENABLED && plugins.isEmpty()) { + // No plugins installed + AlertDialog.Builder alert = new AlertDialog.Builder(this) + .setTitle(R.string.no_plugins_title) + .setMessage(R.string.no_plugins_found) + .setIcon(android.R.drawable.ic_dialog_alert) + .setOnCancelListener(new DialogInterface.OnCancelListener() { + public void onCancel(DialogInterface dialog) { + finish(); + } + }) + .setNegativeButton(R.string.quit, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + finish(); + } + }); + + final Uri uri = Uri.parse("market://search?q=ScummVM plugin"); + final Intent market_intent = new Intent(Intent.ACTION_VIEW, uri); + if (getPackageManager().resolveActivity(market_intent, 0) != null) { + alert.setPositiveButton(R.string.to_market, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + dialog.dismiss(); + try { + startActivityForResult(market_intent, + REQUEST_MARKET); + } catch (ActivityNotFoundException e) { + Log.e(LOG_TAG, + "Error starting market", e); + } + } + }); + } + + alert.show(); + + } else { + // Already have at least one plugin installed + initPlugins(); + } + } + + @Override + public void onStop() { + if (mUnpacker != null) + mUnpacker.cancel(true); + super.onStop(); + } + + @Override + protected void onActivityResult(int requestCode, int resultCode, + Intent data) { + switch (requestCode) { + case REQUEST_MARKET: + if (resultCode != RESULT_OK) + Log.w(LOG_TAG, "Market returned " + resultCode); + tryUnpack(); + break; + } + } + + private Bundle getMetaData() { + try { + ActivityInfo ai = getPackageManager() + .getActivityInfo(getComponentName(), PackageManager.GET_META_DATA); + return ai.metaData; + } catch (PackageManager.NameNotFoundException e) { + Log.w(LOG_TAG, "Unable to find my own meta-data", e); + return new Bundle(); + } + } +} -- cgit v1.2.3 From 80e55c5e78a5161bda41b730892e1a853c872ccb Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 25 Oct 2011 22:52:25 +0200 Subject: ANDROID: Point the default savepath to external storage. (If that fails, fall back to a readable app-specific directory.) --- .../android/org/scummvm/scummvm/ScummVMActivity.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java index a41e843323..7c61520d43 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java @@ -14,6 +14,8 @@ import android.view.MotionEvent; import android.view.inputmethod.InputMethodManager; import android.widget.Toast; +import java.io.File; + public class ScummVMActivity extends Activity { private class MyScummVM extends ScummVM { @@ -128,6 +130,15 @@ public class ScummVMActivity extends Activity { getFilesDir().mkdirs(); + // Store savegames on external storage if we can, which means they're + // world-readable and don't get deleted on uninstall. + String savePath = Environment.getExternalStorageDirectory() + "/ScummVM/Saves/"; + File saveDir = new File(savePath); + if (!saveDir.isDirectory()) { + // If it doesn't work, resort to the internal app path. + savePath = getDir("saves", MODE_WORLD_READABLE).getPath(); + } + // Start ScummVM _scummvm = new MyScummVM(main_surface.getHolder()); @@ -136,7 +147,7 @@ public class ScummVMActivity extends Activity { "--config=" + getFileStreamPath("scummvmrc").getPath(), "--path=" + Environment.getExternalStorageDirectory().getPath(), "--gui-theme=scummmodern", - "--savepath=" + getDir("saves", 0).getPath() + "--savepath=" + savePath }); _events = new ScummVMEvents(this, _scummvm); -- cgit v1.2.3 From 764ffff578d9650621a82ddc5bd5c9530940c5ae Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 25 Oct 2011 23:08:29 +0200 Subject: ANDROID: Match versions when checking for plugins. --- .../platform/android/org/scummvm/scummvm/PluginProvider.java | 10 ++++++++++ .../android/org/scummvm/scummvm/ScummVMApplication.java | 1 + backends/platform/android/org/scummvm/scummvm/Unpacker.java | 10 ++++++++++ 3 files changed, 21 insertions(+) (limited to 'backends') diff --git a/backends/platform/android/org/scummvm/scummvm/PluginProvider.java b/backends/platform/android/org/scummvm/scummvm/PluginProvider.java index 0c43529f83..e27e8d41a8 100644 --- a/backends/platform/android/org/scummvm/scummvm/PluginProvider.java +++ b/backends/platform/android/org/scummvm/scummvm/PluginProvider.java @@ -5,6 +5,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.net.Uri; import android.os.Bundle; @@ -25,15 +26,24 @@ public class PluginProvider extends BroadcastReceiver { Bundle extras = getResultExtras(true); final ActivityInfo info; + final PackageInfo pinfo; try { info = context.getPackageManager() .getReceiverInfo(new ComponentName(context, this.getClass()), PackageManager.GET_META_DATA); + pinfo = context.getPackageManager() + .getPackageInfo(context.getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { Log.e(LOG_TAG, "Error finding my own info?", e); return; } + String host_version = extras.getString(ScummVMApplication.EXTRA_VERSION); + if (!pinfo.versionName.equals(host_version)) { + Log.e(LOG_TAG, "Plugin version " + pinfo.versionName + " is not equal to ScummVM version " + host_version); + return; + } + String mylib = info.metaData.getString(META_UNPACK_LIB); if (mylib != null) { ArrayList all_libs = diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java b/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java index 9241cba918..0adc166222 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMApplication.java @@ -7,6 +7,7 @@ import java.io.File; public class ScummVMApplication extends Application { public final static String ACTION_PLUGIN_QUERY = "org.scummvm.scummvm.action.PLUGIN_QUERY"; public final static String EXTRA_UNPACK_LIBS = "org.scummvm.scummvm.extra.UNPACK_LIBS"; + public final static String EXTRA_VERSION = "org.scummvm.scummvm.extra.VERSION"; private static File _cache_dir; diff --git a/backends/platform/android/org/scummvm/scummvm/Unpacker.java b/backends/platform/android/org/scummvm/scummvm/Unpacker.java index 4564d96622..da76ceb5e5 100644 --- a/backends/platform/android/org/scummvm/scummvm/Unpacker.java +++ b/backends/platform/android/org/scummvm/scummvm/Unpacker.java @@ -10,6 +10,7 @@ import android.content.ContextWrapper; import android.content.DialogInterface; import android.content.Intent; import android.content.pm.ActivityInfo; +import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; @@ -275,6 +276,15 @@ public class Unpacker extends Activity { extras.putStringArrayList(ScummVMApplication.EXTRA_UNPACK_LIBS, unpack_libs); + final PackageInfo info; + try { + info = getPackageManager().getPackageInfo(getPackageName(), 0); + } catch (PackageManager.NameNotFoundException e) { + Log.e(LOG_TAG, "Error finding my own info?", e); + return; + } + extras.putString(ScummVMApplication.EXTRA_VERSION, info.versionName); + Intent intent = new Intent(ScummVMApplication.ACTION_PLUGIN_QUERY); // Android 3.1 defaults to FLAG_EXCLUDE_STOPPED_PACKAGES, and since // none of our plugins will ever be running, that is not helpful -- cgit v1.2.3 From d5aa988f1669f08001d6a06ede661e00d81bd021 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Sun, 9 Oct 2011 14:11:06 -0500 Subject: KEYMAPPER: Disable the broken auto mapping code --- backends/keymapper/keymap.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'backends') diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp index 1518cba693..d2c9b9b572 100644 --- a/backends/keymapper/keymap.cpp +++ b/backends/keymapper/keymap.cpp @@ -199,6 +199,7 @@ bool Keymap::isComplete(const HardwareKeySet *hwKeys) { // - if an action finds a key with required type but a parent action with // higher priority is using it, that key is never used void Keymap::automaticMapping(HardwareKeySet *hwKeys) { +#if 0 //disabling the broken automapper for now // Create copies of action and key lists. List actions(_actions); List keys(hwKeys->getHardwareKeys()); @@ -318,6 +319,7 @@ void Keymap::automaticMapping(HardwareKeySet *hwKeys) { break; } } +#endif } Action *Keymap::getParentMappedAction(KeyState key) { -- cgit v1.2.3 From 5e2ab7435d6deb13565de3240d2cf13e12f95f12 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Sat, 15 Oct 2011 00:39:39 -0500 Subject: KEYMAPPER: Fix showing active keymap in remap dialog --- backends/keymapper/remap-dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 7f2df2f0fe..c89d0a9652 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -60,7 +60,7 @@ void RemapDialog::open() { bool divider = false; const Stack &activeKeymaps = _keymapper->getActiveStack(); - if (!(activeKeymaps.size() > 0)) { + if (activeKeymaps.size() > 0) { _kmPopUp->appendEntry(activeKeymaps.top().keymap->getName() + _(" (Active)")); divider = true; } -- cgit v1.2.3 From e4f127791395df3c4b1f7127ad23b7fe6d80a357 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Sat, 15 Oct 2011 01:45:44 -0500 Subject: KEYMAPPER: Debugging and minor cleanup --- backends/keymapper/keymapper.cpp | 4 ++-- backends/keymapper/remap-dialog.cpp | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index f5f29a2940..29f495cd53 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -192,10 +192,10 @@ bool Keymapper::mapKey(const KeyState& key, bool keyDown) { // Search for key in active keymap stack for (int i = _activeMaps.size() - 1; i >= 0; --i) { MapRecord mr = _activeMaps[i]; - + debug(5, "Keymapper::mapKey keymap: %s", mr.keymap->getName().c_str()); action = mr.keymap->getMappedAction(key); - if (action || mr.inherit == false) + if (action || !mr.inherit) break; } diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index c89d0a9652..b67eecc165 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -84,7 +84,7 @@ void RemapDialog::open() { keymapCount += _gameKeymaps->size(); } - debug(3, "keymaps: %d", keymapCount); + debug(3, "RemapDialog::open keymaps: %d", keymapCount); _keymapTable = (Keymap **)malloc(sizeof(Keymap*) * keymapCount); @@ -192,7 +192,7 @@ void RemapDialog::reflowLayout() { } void RemapDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { - debug(0, "Command!"); + debug(3, "RemapDialog::handleCommand"); if (cmd >= kRemapCmd && cmd < kRemapCmd + _keymapWidgets.size()) { startRemapping(cmd - kRemapCmd); @@ -240,7 +240,7 @@ void RemapDialog::handleKeyUp(Common::KeyState state) { if (_activeRemapAction) { const HardwareKey *hwkey = _keymapper->findHardwareKey(state); - debug(0, "Key: %d, %d (%c), %x", state.keycode, state.ascii, (state.ascii ? state.ascii : ' '), state.flags); + debug(4, "RemapDialog::handleKeyUp Key: %d, %d (%c), %x", state.keycode, state.ascii, (state.ascii ? state.ascii : ' '), state.flags); if (hwkey) { _activeRemapAction->mapKey(hwkey); @@ -270,6 +270,8 @@ void RemapDialog::loadKeymap() { _currentActions.clear(); const Stack &activeKeymaps = _keymapper->getActiveStack(); + debug(3, "RemapDialog::loadKeymap active keymaps: %u", activeKeymaps.size()); + if (!activeKeymaps.empty() && _kmPopUp->getSelected() == 0) { // load active keymaps @@ -278,7 +280,7 @@ void RemapDialog::loadKeymap() { // add most active keymap's keys Keymapper::MapRecord top = activeKeymaps.top(); List::iterator actIt; - + debug(3, "RemapDialog::loadKeymap top keymap: %s", top.keymap->getName().c_str()); for (actIt = top.keymap->getActions().begin(); actIt != top.keymap->getActions().end(); ++actIt) { Action *act = *actIt; ActionInfo info = {act, false, act->description}; @@ -293,6 +295,7 @@ void RemapDialog::loadKeymap() { if (top.inherit) { for (int i = activeKeymaps.size() - 2; i >= 0; --i) { Keymapper::MapRecord mr = activeKeymaps[i]; + debug(3, "RemapDialog::loadKeymap keymap: %s", mr.keymap->getName().c_str()); List::iterator keyIt = freeKeys.begin(); while (keyIt != freeKeys.end()) { -- cgit v1.2.3 From 913b36ab830dc19fece710a0b1a883d1cc48f3cf Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Sat, 15 Oct 2011 15:30:32 -0500 Subject: KEYMAPPER: Added clear buttons in remap dialog This allows clearing of the assigned key for an action. --- backends/keymapper/remap-dialog.cpp | 41 +++++++++++++++++++++++++++++++++---- backends/keymapper/remap-dialog.h | 2 ++ 2 files changed, 39 insertions(+), 4 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index b67eecc165..94b0cbf66b 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -35,6 +35,7 @@ namespace Common { enum { kRemapCmd = 'REMP', + kClearCmd = 'CLER', kCloseCmd = 'CLOS' }; @@ -140,8 +141,10 @@ void RemapDialog::reflowLayout() { uint16 areaW, areaH; int spacing = g_gui.xmlEval()->getVar("Globals.KeyMapper.Spacing"); int labelWidth = g_gui.xmlEval()->getVar("Globals.KeyMapper.LabelWidth"); - int buttonWidth = g_gui.xmlEval()->getVar("Globals.KeyMapper.ButtonWidth"); - int colWidth = labelWidth + buttonWidth + spacing; + int keyButtonWidth = g_gui.xmlEval()->getVar("Globals.KeyMapper.ButtonWidth"); + int clearButtonWidth = g_gui.xmlEval()->getVar("Globals.Line.Height"); + int clearButtonHeight = g_gui.xmlEval()->getVar("Globals.Line.Height"); + int colWidth = labelWidth + keyButtonWidth + clearButtonWidth + spacing; g_gui.xmlEval()->getWidgetData((const String&)String("KeyMapper.KeymapArea"), areaX, areaY, areaW, areaH); @@ -156,6 +159,7 @@ void RemapDialog::reflowLayout() { _scrollBar->recalc(); uint textYOff = (buttonHeight - kLineHeight) / 2; + uint clearButtonYOff = (buttonHeight - clearButtonHeight) / 2; uint oldSize = _keymapWidgets.size(); uint newSize = _rowCount * _colCount; @@ -169,6 +173,9 @@ void RemapDialog::reflowLayout() { new GUI::StaticTextWidget(this, 0, 0, 0, 0, "", Graphics::kTextAlignRight); widg.keyButton = new GUI::ButtonWidget(this, 0, 0, 0, 0, "", 0, kRemapCmd + i); + widg.clearButton = + new GUI::ButtonWidget(this, 0, 0, 0, 0, "C", 0, kClearCmd + i); + _keymapWidgets.push_back(widg); } else { widg = _keymapWidgets[i]; @@ -178,7 +185,8 @@ void RemapDialog::reflowLayout() { uint y = areaY + (i / _colCount) * (buttonHeight + spacing); widg.actionText->resize(x, y + textYOff, labelWidth, kLineHeight); - widg.keyButton->resize(x + labelWidth, y, buttonWidth, buttonHeight); + widg.keyButton->resize(x + labelWidth, y, keyButtonWidth, buttonHeight); + widg.clearButton->resize(x + labelWidth + keyButtonWidth + spacing, y + clearButtonYOff, clearButtonWidth, clearButtonHeight); } while (oldSize > newSize) { ActionWidgets widg = _keymapWidgets.remove_at(--oldSize); @@ -188,14 +196,19 @@ void RemapDialog::reflowLayout() { removeWidget(widg.keyButton); delete widg.keyButton; + + removeWidget(widg.clearButton); + delete widg.clearButton; } } void RemapDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) { - debug(3, "RemapDialog::handleCommand"); + debug(3, "RemapDialog::handleCommand %u %u", cmd, data); if (cmd >= kRemapCmd && cmd < kRemapCmd + _keymapWidgets.size()) { startRemapping(cmd - kRemapCmd); + } else if (cmd >= kClearCmd && cmd < kClearCmd + _keymapWidgets.size()) { + clearMapping(cmd - kClearCmd); } else if (cmd == GUI::kPopUpItemSelectedCmd) { loadKeymap(); } else if (cmd == GUI::kSetPositionCmd) { @@ -207,6 +220,23 @@ void RemapDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 d } } +void RemapDialog::clearMapping(uint i) { + if (_topAction + i >= _currentActions.size()) + return; + + debug(3, "clear the mapping %u", i); + _activeRemapAction = _currentActions[_topAction + i].action; + _activeRemapAction->mapKey(0); + _activeRemapAction->getParent()->saveMappings(); + _changes = true; + + // force refresh + _topAction = -1; + refreshKeymap(); + + _activeRemapAction = 0; +} + void RemapDialog::startRemapping(uint i) { if (_topAction + i >= _currentActions.size()) return; @@ -354,6 +384,7 @@ void RemapDialog::refreshKeymap() { ActionWidgets& widg = _keymapWidgets[widgetI]; if (actionI < _currentActions.size()) { + debug(8, "RemapDialog::refreshKeymap actionI=%u", actionI); ActionInfo& info = _currentActions[actionI]; widg.actionText->setLabel(info.description + ": "); @@ -368,11 +399,13 @@ void RemapDialog::refreshKeymap() { widg.actionText->setVisible(true); widg.keyButton->setVisible(true); + widg.clearButton->setVisible(true); actionI++; } else { widg.actionText->setVisible(false); widg.keyButton->setVisible(false); + widg.clearButton->setVisible(false); } //widg.actionText->draw(); //widg.keyButton->draw(); diff --git a/backends/keymapper/remap-dialog.h b/backends/keymapper/remap-dialog.h index f587ae515d..25e336c4fe 100644 --- a/backends/keymapper/remap-dialog.h +++ b/backends/keymapper/remap-dialog.h @@ -55,6 +55,7 @@ protected: struct ActionWidgets { GUI::StaticTextWidget *actionText; GUI::ButtonWidget *keyButton; + GUI::ButtonWidget *clearButton; }; struct ActionInfo { Action *action; @@ -64,6 +65,7 @@ protected: void loadKeymap(); void refreshKeymap(); + void clearMapping(uint i); void startRemapping(uint i); void stopRemapping(); -- cgit v1.2.3 From ac85d134b31f770f27d085c0fe4c307e278c1875 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 21 Oct 2011 10:33:56 -0500 Subject: KEYMAPPER: Make global keymap that is always active Keymapper now has a global keymap outside the active keymap stack. That global keymap is always checked after the active stack has been checked. --- backends/keymapper/keymapper.cpp | 6 +++++- backends/keymapper/keymapper.h | 4 ++++ backends/keymapper/remap-dialog.cpp | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index 29f495cd53..f9d6e7a60f 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -54,7 +54,7 @@ Keymap *Keymapper::Domain::getKeymap(const String& name) { } Keymapper::Keymapper(EventManager *evtMgr) - : _eventMan(evtMgr), _enabled(true), _hardwareKeys(0) { + : _eventMan(evtMgr), _enabled(true), _hardwareKeys(0), _globalKeymap(0) { ConfigManager::Domain *confDom = ConfMan.getDomain(ConfigManager::kKeymapperDomain); _globalDomain.setConfigDomain(confDom); @@ -199,6 +199,10 @@ bool Keymapper::mapKey(const KeyState& key, bool keyDown) { break; } + // fallback to the global keymap + if (!action && _globalKeymap) + action = _globalKeymap->getMappedAction(key); + if (action) _keysDown[key] = action; } else { diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index fcb444aa64..347b9e0ec0 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -171,6 +171,9 @@ public: Domain& getGameDomain() { return _gameDomain; } const Stack& getActiveStack() const { return _activeMaps; } + void setGlobalKeymap(Keymap *keymap) { _globalKeymap = keymap; } + Keymap* getGlobalKeymap() const { return _globalKeymap; } + private: void initKeymap(Domain &domain, Keymap *keymap); @@ -190,6 +193,7 @@ private: bool _enabled; Stack _activeMaps; + Keymap *_globalKeymap; HashMap _keysDown; }; diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 94b0cbf66b..0882c69080 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -345,6 +345,26 @@ void RemapDialog::loadKeymap() { } } + // get the mapping out of the global keymap + if (_keymapper->getGlobalKeymap()) { + List::iterator keyIt = freeKeys.begin(); + Keymap *globalKeymap = _keymapper->getGlobalKeymap(); + while (keyIt != freeKeys.end()) { + Action *act = globalKeymap->getMappedAction((*keyIt)->key); + + if (act) { + ActionInfo info = {act, true, act->description + " (" + globalKeymap->getName() + ")"}; + _currentActions.push_back(info); + freeKeys.erase(keyIt++); + } else { + ++keyIt; + } + if (freeKeys.empty()) + break; + } + + } + } else if (_kmPopUp->getSelected() != -1) { Keymap *km = _keymapTable[_kmPopUp->getSelectedTag()]; -- cgit v1.2.3 From a5082ffa5d12483f2e65fe653509989b1314164c Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 21 Oct 2011 22:54:33 -0500 Subject: KEYMAPPER: Skip GUI keymap when displaying active keymap in keymapper dialog This fixes a problem where opening the keymapper dialog would cause the current game keymap to be displayed as the active keymap but then changing the keymap selection back to it would cause the GUI keymap to be displayed as the active one. The GUI keymap was indeed at the top of the stack but that's not the desired effect. Also move the pushing and popping of the keymap to Dialog::Open/Close Also constantify the GUI keymap name --- backends/keymapper/keymapper.h | 2 ++ backends/keymapper/remap-dialog.cpp | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index 347b9e0ec0..4722de5774 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -36,6 +36,8 @@ namespace Common { +const char *const kGuiKeymapName = "gui"; + class Keymapper : public Common::EventMapper, private Common::ArtificialEventSource { public: diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 0882c69080..adbf199960 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -307,8 +307,14 @@ void RemapDialog::loadKeymap() { List freeKeys(_keymapper->getHardwareKeys()); + int topIndex = activeKeymaps.size() - 1; + // skip all gui maps + // TODO: Don't use the keymap name as a way to discriminate GUI maps + while (topIndex > 0 && activeKeymaps[topIndex].keymap->getName().equals(kGuiKeymapName)) + --topIndex; + // add most active keymap's keys - Keymapper::MapRecord top = activeKeymaps.top(); + Keymapper::MapRecord top = activeKeymaps[topIndex]; List::iterator actIt; debug(3, "RemapDialog::loadKeymap top keymap: %s", top.keymap->getName().c_str()); for (actIt = top.keymap->getActions().begin(); actIt != top.keymap->getActions().end(); ++actIt) { @@ -322,8 +328,8 @@ void RemapDialog::loadKeymap() { } // loop through remaining finding mappings for unmapped keys - if (top.inherit) { - for (int i = activeKeymaps.size() - 2; i >= 0; --i) { + if (top.inherit && topIndex >= 0) { + for (int i = topIndex - 1; i >= 0; --i) { Keymapper::MapRecord mr = activeKeymaps[i]; debug(3, "RemapDialog::loadKeymap keymap: %s", mr.keymap->getName().c_str()); List::iterator keyIt = freeKeys.begin(); -- cgit v1.2.3 From b8ef739d142577d3415ec7e8302d5da2df9ce252 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Sat, 22 Oct 2011 14:50:40 -0500 Subject: KEYMAPPER: Only skip the top GUI keymap when populating the active keymap This is because the top GUI keymap is for the keymapper dialog itself. If all GUI keymaps are skipped then when inside a game with the GMM displayed and the keymapper dialog invoked, the game keymap is displayed even though it is not the active one. --- backends/keymapper/remap-dialog.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index adbf199960..44d7e273dd 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -308,9 +308,9 @@ void RemapDialog::loadKeymap() { List freeKeys(_keymapper->getHardwareKeys()); int topIndex = activeKeymaps.size() - 1; - // skip all gui maps + // skip the top gui keymap since it is for the keymapper itself // TODO: Don't use the keymap name as a way to discriminate GUI maps - while (topIndex > 0 && activeKeymaps[topIndex].keymap->getName().equals(kGuiKeymapName)) + if (topIndex > 0 && activeKeymaps[topIndex].keymap->getName().equals(kGuiKeymapName)) --topIndex; // add most active keymap's keys -- cgit v1.2.3 From 07f1c2032ae9ae96be5a29ccbba49d3637fd5da7 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 28 Oct 2011 22:51:53 -0500 Subject: KEYMAPPER: Add tooltip text for clear buttons --- backends/keymapper/remap-dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 44d7e273dd..afc228c85a 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -174,7 +174,7 @@ void RemapDialog::reflowLayout() { widg.keyButton = new GUI::ButtonWidget(this, 0, 0, 0, 0, "", 0, kRemapCmd + i); widg.clearButton = - new GUI::ButtonWidget(this, 0, 0, 0, 0, "C", 0, kClearCmd + i); + new GUI::ButtonWidget(this, 0, 0, 0, 0, "C", _("Clear value"), kClearCmd + i); _keymapWidgets.push_back(widg); } else { -- cgit v1.2.3 From 57bc9a21cce59b967d6ee8c2318799f4ba0ecbac Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 28 Oct 2011 22:53:30 -0500 Subject: KEYMAPPER: Improved clear button It uses the fancy new kImageEraser now --- backends/keymapper/remap-dialog.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index afc228c85a..8edc5c5d39 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -28,7 +28,6 @@ #include "gui/widgets/popup.h" #include "gui/widgets/scrollbar.h" #include "gui/ThemeEval.h" - #include "common/translation.h" namespace Common { @@ -173,8 +172,15 @@ void RemapDialog::reflowLayout() { new GUI::StaticTextWidget(this, 0, 0, 0, 0, "", Graphics::kTextAlignRight); widg.keyButton = new GUI::ButtonWidget(this, 0, 0, 0, 0, "", 0, kRemapCmd + i); - widg.clearButton = - new GUI::ButtonWidget(this, 0, 0, 0, 0, "C", _("Clear value"), kClearCmd + i); +#ifndef DISABLE_FANCY_THEMES + if (g_gui.xmlEval()->getVar("Globals.ShowSearchPic") == 1 && g_gui.theme()->supportsImages()) { + widg.clearButton = new GUI::PicButtonWidget(this, 0, 0, clearButtonWidth, clearButtonHeight, _("Clear value"), kClearCmd + i); + ((GUI::PicButtonWidget *)widg.clearButton)->useThemeTransparency(true); + ((GUI::PicButtonWidget *)widg.clearButton)->setGfx(g_gui.theme()->getImageSurface(GUI::ThemeEngine::kImageEraser)); + } + else +#endif + widg.clearButton = new GUI::ButtonWidget(this, 0, 0, 0, 0, "C", _("Clear value"), kClearCmd + i); _keymapWidgets.push_back(widg); } else { -- cgit v1.2.3 From b708d6de79e2893cddf95d72864d4487a483e0c1 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Wed, 2 Nov 2011 10:16:16 -0500 Subject: Revert "KEYMAPPER: Make global keymap that is always active" This reverts commit ac85d134b31f770f27d085c0fe4c307e278c1875. --- backends/keymapper/keymapper.cpp | 6 +----- backends/keymapper/keymapper.h | 4 ---- backends/keymapper/remap-dialog.cpp | 20 -------------------- 3 files changed, 1 insertion(+), 29 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index f9d6e7a60f..29f495cd53 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -54,7 +54,7 @@ Keymap *Keymapper::Domain::getKeymap(const String& name) { } Keymapper::Keymapper(EventManager *evtMgr) - : _eventMan(evtMgr), _enabled(true), _hardwareKeys(0), _globalKeymap(0) { + : _eventMan(evtMgr), _enabled(true), _hardwareKeys(0) { ConfigManager::Domain *confDom = ConfMan.getDomain(ConfigManager::kKeymapperDomain); _globalDomain.setConfigDomain(confDom); @@ -199,10 +199,6 @@ bool Keymapper::mapKey(const KeyState& key, bool keyDown) { break; } - // fallback to the global keymap - if (!action && _globalKeymap) - action = _globalKeymap->getMappedAction(key); - if (action) _keysDown[key] = action; } else { diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index 4722de5774..c5a2558964 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -173,9 +173,6 @@ public: Domain& getGameDomain() { return _gameDomain; } const Stack& getActiveStack() const { return _activeMaps; } - void setGlobalKeymap(Keymap *keymap) { _globalKeymap = keymap; } - Keymap* getGlobalKeymap() const { return _globalKeymap; } - private: void initKeymap(Domain &domain, Keymap *keymap); @@ -195,7 +192,6 @@ private: bool _enabled; Stack _activeMaps; - Keymap *_globalKeymap; HashMap _keysDown; }; diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 8edc5c5d39..b0f42fe426 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -357,26 +357,6 @@ void RemapDialog::loadKeymap() { } } - // get the mapping out of the global keymap - if (_keymapper->getGlobalKeymap()) { - List::iterator keyIt = freeKeys.begin(); - Keymap *globalKeymap = _keymapper->getGlobalKeymap(); - while (keyIt != freeKeys.end()) { - Action *act = globalKeymap->getMappedAction((*keyIt)->key); - - if (act) { - ActionInfo info = {act, true, act->description + " (" + globalKeymap->getName() + ")"}; - _currentActions.push_back(info); - freeKeys.erase(keyIt++); - } else { - ++keyIt; - } - if (freeKeys.empty()) - break; - } - - } - } else if (_kmPopUp->getSelected() != -1) { Keymap *km = _keymapTable[_kmPopUp->getSelectedTag()]; -- cgit v1.2.3 From 09697a9c31d22cec8e1a484cbb6fdab7efc4ee95 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Tue, 15 Nov 2011 14:51:23 -0600 Subject: MAEMO: Update debian/changelog with 1.4 release --- backends/platform/maemo/debian/changelog | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'backends') diff --git a/backends/platform/maemo/debian/changelog b/backends/platform/maemo/debian/changelog index d3e0287186..9bea36b8ad 100644 --- a/backends/platform/maemo/debian/changelog +++ b/backends/platform/maemo/debian/changelog @@ -1,8 +1,8 @@ -scummvm (1.4.0~git) unstable; urgency=low +scummvm (1.4.0) unstable; urgency=low - * development snapshot + * 1.4.0 release - -- Tarek Soliman Wed, 05 Oct 2011 19:01:25 -0500 + -- Tarek Soliman Thu, 03 Nov 2011 13:54:04 -0500 scummvm (1.2.1~pre) unstable; urgency=low -- cgit v1.2.3 From 7a225191b074a3c694799857864c69970aa401a5 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Tue, 15 Nov 2011 14:58:38 -0600 Subject: MAEMO: Update debian/changelog to version 1.5.0~git --- backends/platform/maemo/debian/changelog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'backends') diff --git a/backends/platform/maemo/debian/changelog b/backends/platform/maemo/debian/changelog index 9bea36b8ad..8a9d8ee3c3 100644 --- a/backends/platform/maemo/debian/changelog +++ b/backends/platform/maemo/debian/changelog @@ -1,3 +1,9 @@ +scummvm (1.5.0~git) unstable; urgency=low + + * Development snapshot + + -- Tarek Soliman Tue, 15 Nov 2011 14:56:57 -0600 + scummvm (1.4.0) unstable; urgency=low * 1.4.0 release -- cgit v1.2.3 From 61795739f8f45c5de4cfd0fe57af459146c5173c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 16 Nov 2011 18:06:30 +0100 Subject: COMMON: Rename Common::set_to to Common::fill. This makes the name match with the name of the STL function with the same behavior. --- backends/platform/android/texture.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp index 53b4d1cc59..e211e5941f 100644 --- a/backends/platform/android/texture.cpp +++ b/backends/platform/android/texture.cpp @@ -287,7 +287,7 @@ void GLESTexture::fillBuffer(uint32 color) { ((color & 0xff) == ((color >> 8) & 0xff))) memset(_pixels, color & 0xff, _surface.pitch * _surface.h); else - Common::set_to(_pixels, _pixels + _surface.pitch * _surface.h, + Common::fill(_pixels, _pixels + _surface.pitch * _surface.h, (uint16)color); setDirty(); -- cgit v1.2.3 From f17b9bc5cb80ce9db75c1c35edf2109c9476ccfa Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Thu, 17 Nov 2011 10:29:04 +0100 Subject: COMMON: Remove outdated fixme --- backends/timer/default/default-timer.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'backends') diff --git a/backends/timer/default/default-timer.cpp b/backends/timer/default/default-timer.cpp index e1aadb62b8..8681102cd0 100644 --- a/backends/timer/default/default-timer.cpp +++ b/backends/timer/default/default-timer.cpp @@ -122,7 +122,7 @@ bool DefaultTimerManager::installTimerProc(TimerProc callback, int32 interval, v for (i = _callbacks.begin(); i != _callbacks.end(); ++i) { if (i->_value == callback) { - error("Same callback is referred by different names (%s vs %s)", i->_key.c_str(), id.c_str()); + error("Same callback added twice (old name: %s, new name: %s)", i->_key.c_str(), id.c_str()); } } _callbacks[id] = callback; @@ -136,12 +136,6 @@ bool DefaultTimerManager::installTimerProc(TimerProc callback, int32 interval, v slot->nextFireTimeMicro = interval % 1000; slot->next = 0; - // FIXME: It seems we do allow the client to add one callback multiple times over here, - // but "removeTimerProc" will remove *all* added instances. We should either prevent - // multiple additions of a timer proc OR we should change removeTimerProc to only remove - // a specific timer proc entry. - // Probably we can safely just allow a single addition of a specific function once - // and just update our Timer documentation accordingly. insertPrioQueue(_head, slot); return true; -- cgit v1.2.3 From 5647637ea2d239681a9dc0facc4071e33235fe4f Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Thu, 17 Nov 2011 12:44:05 +0100 Subject: COMMON: Move include into scummsys.h. The header contains forbidden symbols on some platforms, and the simplest solution seems to be to include it here. This also includes it from all the portdefs.h files, except the Symbian one. Probably the FIXME and the #if can be removed once it's known to work. --- backends/platform/bada/portdefs.h | 1 + backends/platform/dc/portdefs.h | 1 + backends/platform/ds/arm9/source/portdefs.h | 1 + backends/platform/n64/portdefs.h | 1 + backends/platform/psp/portdefs.h | 1 + backends/platform/wince/portdefs.h | 1 + 6 files changed, 6 insertions(+) (limited to 'backends') diff --git a/backends/platform/bada/portdefs.h b/backends/platform/bada/portdefs.h index e85d578678..7d85a9ec35 100644 --- a/backends/platform/bada/portdefs.h +++ b/backends/platform/bada/portdefs.h @@ -30,6 +30,7 @@ #include #include #include +#include #define M_PI 3.14159265358979323846 diff --git a/backends/platform/dc/portdefs.h b/backends/platform/dc/portdefs.h index ca2b5208a3..1f5c8f566a 100644 --- a/backends/platform/dc/portdefs.h +++ b/backends/platform/dc/portdefs.h @@ -29,6 +29,7 @@ #include #include #include +#include #ifndef RONIN_TIMER_ACCESS #define Timer ronin_Timer #endif diff --git a/backends/platform/ds/arm9/source/portdefs.h b/backends/platform/ds/arm9/source/portdefs.h index f512ce3ea2..e40849a513 100644 --- a/backends/platform/ds/arm9/source/portdefs.h +++ b/backends/platform/ds/arm9/source/portdefs.h @@ -37,6 +37,7 @@ #include #include #include +#include #define double float diff --git a/backends/platform/n64/portdefs.h b/backends/platform/n64/portdefs.h index 677ad48477..10f5ed6488 100644 --- a/backends/platform/n64/portdefs.h +++ b/backends/platform/n64/portdefs.h @@ -31,6 +31,7 @@ #include #include #include +#include #undef assert #define assert(x) ((x) ? 0 : (print_error("ASSERT TRIGGERED:\n\n("#x")\n%s\nline: %d", __FILE__, __LINE__))) diff --git a/backends/platform/psp/portdefs.h b/backends/platform/psp/portdefs.h index e8a28b31e2..620a27a601 100644 --- a/backends/platform/psp/portdefs.h +++ b/backends/platform/psp/portdefs.h @@ -38,6 +38,7 @@ #include #include #include +#include #include #include diff --git a/backends/platform/wince/portdefs.h b/backends/platform/wince/portdefs.h index 93df6cd39e..289406c2a4 100644 --- a/backends/platform/wince/portdefs.h +++ b/backends/platform/wince/portdefs.h @@ -73,6 +73,7 @@ #include #include //#include +#include #ifdef __MINGW32CE__ void *bsearch(const void *, const void *, size_t, size_t, int (*x)(const void *, const void *)); -- cgit v1.2.3 From 8f58ddefc629a270b4661b5263c07f59ca0560d6 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 20 Nov 2011 04:34:22 +0100 Subject: ALL: Remove more m4/mads leftovers. Some project files (iPhone) and backend files (Symbian) still reference m4.dat, but I know not enough on how to remove that without breaking something. --- backends/platform/maemo/debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/maemo/debian/rules b/backends/platform/maemo/debian/rules index 7613df25b4..64add08de8 100755 --- a/backends/platform/maemo/debian/rules +++ b/backends/platform/maemo/debian/rules @@ -47,7 +47,7 @@ install: build install -m0644 gui/themes/scummclassic.zip gui/themes/scummmodern.zip debian/scummvm/opt/scummvm/share install -m0644 backends/vkeybd/packs/vkeybd_default.zip debian/scummvm/opt/scummvm/share # for optified version we can also add engine datafiles - install -m0644 dists/engine-data/drascula.dat dists/engine-data/hugo.dat dists/engine-data/kyra.dat dists/engine-data/lure.dat dists/engine-data/m4.dat dists/engine-data/mads.dat dists/engine-data/queen.tbl dists/engine-data/sky.cpt dists/engine-data/teenagent.dat dists/engine-data/toon.dat debian/scummvm/opt/scummvm/share + install -m0644 dists/engine-data/drascula.dat dists/engine-data/hugo.dat dists/engine-data/kyra.dat dists/engine-data/lure.dat dists/engine-data/queen.tbl dists/engine-data/sky.cpt dists/engine-data/teenagent.dat dists/engine-data/toon.dat debian/scummvm/opt/scummvm/share install -m0644 -d debian/scummvm/usr/share/doc/scummvm install -m0644 NEWS README COPYRIGHT debian/scummvm/usr/share/doc/scummvm -- cgit v1.2.3 From e578cb8976f10cd9217cddef48c6693cf5d03c7b Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Sun, 7 Aug 2011 20:05:25 +0200 Subject: ALL: Remove unnecessary forward declarations. --- backends/platform/ps2/Gs2dScreen.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'backends') diff --git a/backends/platform/ps2/Gs2dScreen.h b/backends/platform/ps2/Gs2dScreen.h index dffdce5b36..3701afd590 100644 --- a/backends/platform/ps2/Gs2dScreen.h +++ b/backends/platform/ps2/Gs2dScreen.h @@ -42,10 +42,6 @@ enum GsInterlace { }; -namespace Graphics { -struct Surface; -} - class Gs2dScreen { public: Gs2dScreen(uint16 width, uint16 height, TVMode tvMode); -- cgit v1.2.3 From c451bd4340cc8d76e1ba6bb55d3d75b67c38e4cf Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Thu, 24 Nov 2011 23:06:21 -0600 Subject: MAEMO: Make setupIcon do nothing It seems N900 is hit by SDL_WM_SetIcon bug (window cannot receive input) http://bugzilla.libsdl.org/show_bug.cgi?id=586 This fix is based on the old 1.2.1 Maemo port code --- backends/platform/maemo/maemo.cpp | 6 ++++++ backends/platform/maemo/maemo.h | 1 + 2 files changed, 7 insertions(+) (limited to 'backends') diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index 3571039e62..a1885036e7 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -108,6 +108,12 @@ const Maemo::Model OSystem_SDL_Maemo::detectModel() { return *model; } +void OSystem_SDL_Maemo::setupIcon() { + // no Maemo version needs setupIcon + // also N900 is hit by SDL_WM_SetIcon bug (window cannot receive input) + // http://bugzilla.libsdl.org/show_bug.cgi?id=586 +} + } //namespace Maemo #endif diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h index e42936ddf0..32b52470bc 100644 --- a/backends/platform/maemo/maemo.h +++ b/backends/platform/maemo/maemo.h @@ -38,6 +38,7 @@ public: virtual void quit(); virtual void fatalError(); virtual void setWindowCaption(const char *caption); + virtual void setupIcon(); Model getModel() { return _model; } -- cgit v1.2.3 From a78b2d777d98e494b988843bfd9694c58c6c6018 Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Sat, 26 Nov 2011 13:33:42 +0100 Subject: JANITORIAL: Remove extra semicolons. --- backends/fs/amigaos4/amigaos4-fs.h | 8 ++++---- backends/fs/ps2/ps2-fs.h | 2 +- backends/fs/psp/psp-fs-factory.h | 2 +- backends/platform/dc/dc-fs.cpp | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) (limited to 'backends') diff --git a/backends/fs/amigaos4/amigaos4-fs.h b/backends/fs/amigaos4/amigaos4-fs.h index 4e231330f0..c5ca61476f 100644 --- a/backends/fs/amigaos4/amigaos4-fs.h +++ b/backends/fs/amigaos4/amigaos4-fs.h @@ -91,10 +91,10 @@ public: virtual ~AmigaOSFilesystemNode(); virtual bool exists() const; - virtual Common::String getDisplayName() const { return _sDisplayName; }; - virtual Common::String getName() const { return _sDisplayName; }; - virtual Common::String getPath() const { return _sPath; }; - virtual bool isDirectory() const { return _bIsDirectory; }; + virtual Common::String getDisplayName() const { return _sDisplayName; } + virtual Common::String getName() const { return _sDisplayName; } + virtual Common::String getPath() const { return _sPath; } + virtual bool isDirectory() const { return _bIsDirectory; } virtual bool isReadable() const; virtual bool isWritable() const; diff --git a/backends/fs/ps2/ps2-fs.h b/backends/fs/ps2/ps2-fs.h index 9323715c7f..df78f9f68a 100644 --- a/backends/fs/ps2/ps2-fs.h +++ b/backends/fs/ps2/ps2-fs.h @@ -96,7 +96,7 @@ public: virtual Common::SeekableReadStream *createReadStream(); virtual Common::WriteStream *createWriteStream(); - int getDev() { return 0; }; + int getDev() { return 0; } }; #endif diff --git a/backends/fs/psp/psp-fs-factory.h b/backends/fs/psp/psp-fs-factory.h index aeaa9d6a87..d57c8fb655 100644 --- a/backends/fs/psp/psp-fs-factory.h +++ b/backends/fs/psp/psp-fs-factory.h @@ -37,7 +37,7 @@ public: virtual AbstractFSNode *makeFileNodePath(const Common::String &path) const; protected: - PSPFilesystemFactory() {}; + PSPFilesystemFactory() {} private: friend class Common::Singleton; diff --git a/backends/platform/dc/dc-fs.cpp b/backends/platform/dc/dc-fs.cpp index f30c9c56d1..36f5a1465c 100644 --- a/backends/platform/dc/dc-fs.cpp +++ b/backends/platform/dc/dc-fs.cpp @@ -39,7 +39,7 @@ protected: Common::String _path; public: - RoninCDFileNode(const Common::String &path) : _path(path) {}; + RoninCDFileNode(const Common::String &path) : _path(path) {} virtual bool exists() const { return true; } virtual Common::String getName() const { return lastPathComponent(_path, '/'); } @@ -61,7 +61,7 @@ public: /* A directory */ class RoninCDDirectoryNode : public RoninCDFileNode { public: - RoninCDDirectoryNode(const Common::String &path) : RoninCDFileNode(path) {}; + RoninCDDirectoryNode(const Common::String &path) : RoninCDFileNode(path) {} virtual bool isDirectory() const { return true; } virtual AbstractFSNode *getChild(const Common::String &n) const; @@ -72,7 +72,7 @@ public: /* A file/directory which does not exist */ class RoninCDNonexistingNode : public RoninCDFileNode { public: - RoninCDNonexistingNode(const Common::String &path) : RoninCDFileNode(path) {}; + RoninCDNonexistingNode(const Common::String &path) : RoninCDFileNode(path) {} virtual bool exists() const { return false; } virtual bool isReadable() const { return false; } -- cgit v1.2.3 From 89ccde39485196c5131e88e30ab34d268a0f32cc Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Mon, 21 Nov 2011 12:39:34 +0100 Subject: DS: Remove the unused method OSystem_DS::grabRawScreen(). This was removed from OSystem in b51f2f3212ae8a5abbdce4d947ec2d1cad1a0b6f. --- backends/platform/ds/arm9/source/osystem_ds.cpp | 17 ----------------- backends/platform/ds/arm9/source/osystem_ds.h | 2 -- 2 files changed, 19 deletions(-) (limited to 'backends') diff --git a/backends/platform/ds/arm9/source/osystem_ds.cpp b/backends/platform/ds/arm9/source/osystem_ds.cpp index fdd310ec17..73340ed18a 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.cpp +++ b/backends/platform/ds/arm9/source/osystem_ds.cpp @@ -267,23 +267,6 @@ void OSystem_DS::setCursorPalette(const byte *colors, uint start, uint num) { refreshCursor(); } -bool OSystem_DS::grabRawScreen(Graphics::Surface *surf) { - surf->create(DS::getGameWidth(), DS::getGameHeight(), Graphics::PixelFormat::createFormatCLUT8()); - - // Ensure we copy using 16 bit quantities due to limitation of VRAM addressing - - - const u16 *image = (const u16 *) DS::get8BitBackBuffer(); - for (int y = 0; y < DS::getGameHeight(); y++) { - DC_FlushRange(image + (y << 8), DS::getGameWidth()); - for (int x = 0; x < DS::getGameWidth() >> 1; x++) { - *(((u16 *) (surf->pixels)) + y * (DS::getGameWidth() >> 1) + x) = image[(y << 8) + x]; - } - } - - return true; -} - void OSystem_DS::grabPalette(unsigned char *colors, uint start, uint num) { // consolePrintf("Grabpalette"); diff --git a/backends/platform/ds/arm9/source/osystem_ds.h b/backends/platform/ds/arm9/source/osystem_ds.h index b1222a152d..6aa3731916 100644 --- a/backends/platform/ds/arm9/source/osystem_ds.h +++ b/backends/platform/ds/arm9/source/osystem_ds.h @@ -141,8 +141,6 @@ public: void addEvent(const Common::Event& e); bool isEventQueueEmpty() const { return queuePos == 0; } - virtual bool grabRawScreen(Graphics::Surface *surf); - virtual void setFocusRectangle(const Common::Rect& rect); virtual void clearFocusRectangle(); -- cgit v1.2.3 From 6a9ab747f9ec97d644787bf8a3415b55ca44c2d1 Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Mon, 21 Nov 2011 12:52:43 +0100 Subject: PS2: Remove the unused method OSystem_PS2::grabRawScreen(). This was removed from OSystem in b51f2f3212ae8a5abbdce4d947ec2d1cad1a0b6f. --- backends/platform/ps2/Gs2dScreen.cpp | 8 -------- backends/platform/ps2/Gs2dScreen.h | 1 - backends/platform/ps2/systemps2.cpp | 5 ----- backends/platform/ps2/systemps2.h | 1 - 4 files changed, 15 deletions(-) (limited to 'backends') diff --git a/backends/platform/ps2/Gs2dScreen.cpp b/backends/platform/ps2/Gs2dScreen.cpp index ddc1bdf668..b70e8b13fa 100644 --- a/backends/platform/ps2/Gs2dScreen.cpp +++ b/backends/platform/ps2/Gs2dScreen.cpp @@ -437,14 +437,6 @@ void Gs2dScreen::grabPalette(uint8 *pal, uint8 start, uint16 num) { } } -void Gs2dScreen::grabScreen(Graphics::Surface *surf) { - assert(surf); - WaitSema(g_DmacSema); - surf->create(_width, _height, Graphics::PixelFormat::createFormatCLUT8()); - memcpy(surf->pixels, _screenBuf, _width * _height); - SignalSema(g_DmacSema); -} - void Gs2dScreen::uploadToVram(void) { if (_clutChanged) { _clutChanged = false; diff --git a/backends/platform/ps2/Gs2dScreen.h b/backends/platform/ps2/Gs2dScreen.h index 3701afd590..4fbb3fdef8 100644 --- a/backends/platform/ps2/Gs2dScreen.h +++ b/backends/platform/ps2/Gs2dScreen.h @@ -61,7 +61,6 @@ public: void setPalette(const uint8 *pal, uint8 start, uint16 num); void updateScreen(void); void grabPalette(uint8 *pal, uint8 start, uint16 num); - void grabScreen(Graphics::Surface *surf); //- overlay routines void copyOverlayRect(const uint16 *buf, uint16 pitch, uint16 x, uint16 y, uint16 w, uint16 h); void grabOverlay(uint16 *buf, uint16 pitch); diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp index c75d7493a2..481227dd02 100644 --- a/backends/platform/ps2/systemps2.cpp +++ b/backends/platform/ps2/systemps2.cpp @@ -558,11 +558,6 @@ void OSystem_PS2::copyRectToScreen(const byte *buf, int pitch, int x, int y, int _screen->copyScreenRect((const uint8*)buf, pitch, x, y, w, h); } -bool OSystem_PS2::grabRawScreen(Graphics::Surface *surf) { - _screen->grabScreen(surf); - return true; -} - void OSystem_PS2::updateScreen(void) { if (_msgClearTime && (_msgClearTime < getMillis())) { _screen->clearPrintfOverlay(); diff --git a/backends/platform/ps2/systemps2.h b/backends/platform/ps2/systemps2.h index 35ceaf829e..3a0e247737 100644 --- a/backends/platform/ps2/systemps2.h +++ b/backends/platform/ps2/systemps2.h @@ -64,7 +64,6 @@ public: virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h); virtual void setShakePos(int shakeOffset); - virtual bool grabRawScreen(Graphics::Surface *surf); virtual Graphics::Surface *lockScreen(); virtual void unlockScreen(); virtual void updateScreen(); -- cgit v1.2.3 From dabea2b5151b5f220fb06a93e50a3eb43903385c Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Tue, 29 Nov 2011 11:19:47 -0600 Subject: MAMEO: Add GMM keybinding for N900 (fix bug #3443043) The keybinding is Ctrl-Shift-m. Ctrl-m is more desirable but is toggling mouse capture. --- backends/events/maemosdl/maemosdl-events.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp index 32d5cfb5ac..07af368064 100644 --- a/backends/events/maemosdl/maemosdl-events.cpp +++ b/backends/events/maemosdl/maemosdl-events.cpp @@ -47,7 +47,11 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { switch (ev.type) { case SDL_KEYDOWN:{ - if (ev.key.keysym.sym == SDLK_F4) { + if (ev.key.keysym.sym == SDLK_F4 + || (model.modelType == kModelTypeN900 + && ev.key.keysym.sym == SDLK_m + && (ev.key.keysym.mod & KMOD_CTRL) + && (ev.key.keysym.mod & KMOD_SHIFT))) { event.type = Common::EVENT_MAINMENU; debug(9, "remapping to main menu"); return true; @@ -83,7 +87,11 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { break; } case SDL_KEYUP: { - if (ev.key.keysym.sym == SDLK_F4) { + if (ev.key.keysym.sym == SDLK_F4 + || (model.modelType == kModelTypeN900 + && ev.key.keysym.sym == SDLK_m + && (ev.key.keysym.mod & KMOD_CTRL) + && (ev.key.keysym.mod & KMOD_SHIFT))) { event.type = Common::EVENT_MAINMENU; return true; } else if (ev.key.keysym.sym == SDLK_F6) { -- cgit v1.2.3 From 29c0386f2c5d1a8a03cab0010e7c7c7e27fe2e94 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Tue, 29 Nov 2011 13:38:17 -0600 Subject: MAEMO: Add basic graphics manager --- backends/graphics/maemosdl/maemosdl-graphics.cpp | 34 ++++++++++++++++++++++ backends/graphics/maemosdl/maemosdl-graphics.h | 37 ++++++++++++++++++++++++ backends/module.mk | 3 +- backends/platform/maemo/maemo.cpp | 4 +++ 4 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 backends/graphics/maemosdl/maemosdl-graphics.cpp create mode 100644 backends/graphics/maemosdl/maemosdl-graphics.h (limited to 'backends') diff --git a/backends/graphics/maemosdl/maemosdl-graphics.cpp b/backends/graphics/maemosdl/maemosdl-graphics.cpp new file mode 100644 index 0000000000..3309d91228 --- /dev/null +++ b/backends/graphics/maemosdl/maemosdl-graphics.cpp @@ -0,0 +1,34 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ +#if defined(MAEMO) + +#include "common/scummsys.h" + +#include "backends/platform/maemo/maemo.h" +#include "backends/events/maemosdl/maemosdl-events.h" +#include "backends/graphics/maemosdl/maemosdl-graphics.h" + +MaemoSdlGraphicsManager::MaemoSdlGraphicsManager(SdlEventSource *sdlEventSource) + : SurfaceSdlGraphicsManager(sdlEventSource) { +} + +#endif diff --git a/backends/graphics/maemosdl/maemosdl-graphics.h b/backends/graphics/maemosdl/maemosdl-graphics.h new file mode 100644 index 0000000000..4a675b6159 --- /dev/null +++ b/backends/graphics/maemosdl/maemosdl-graphics.h @@ -0,0 +1,37 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#if defined(MAEMO) + +#ifndef BACKENDS_GRAPHICS_MAEMOSDL_GRAPHICS_H +#define BACKENDS_GRAPHICS_MAEMOSDL_GRAPHICS_H + +#include "backends/graphics/surfacesdl/surfacesdl-graphics.h" + +class MaemoSdlGraphicsManager : public SurfaceSdlGraphicsManager { +public: + MaemoSdlGraphicsManager(SdlEventSource *sdlEventSource); +}; + +#endif + +#endif diff --git a/backends/module.mk b/backends/module.mk index 89cde44536..6be595a65e 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -149,7 +149,8 @@ endif ifeq ($(BACKEND),maemo) MODULE_OBJS += \ - events/maemosdl/maemosdl-events.o + events/maemosdl/maemosdl-events.o \ + graphics/maemosdl/maemosdl-graphics.o endif ifeq ($(BACKEND),n64) diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index a1885036e7..454a13631c 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -29,6 +29,7 @@ #include "backends/platform/maemo/maemo.h" #include "backends/events/maemosdl/maemosdl-events.h" +#include "backends/graphics/maemosdl/maemosdl-graphics.h" #include "common/textconsole.h" @@ -47,6 +48,9 @@ void OSystem_SDL_Maemo::initBackend() { if (_eventSource == 0) _eventSource = new MaemoSdlEventSource(); + if (_graphicsManager == 0) + _graphicsManager = new MaemoSdlGraphicsManager(_eventSource); + ConfMan.set("vkeybdpath", DATA_PATH); _model = Model(detectModel()); -- cgit v1.2.3 From fda6e1534bc1dfad7f1f32ccf0bb51f3eb34974d Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Tue, 29 Nov 2011 14:01:20 -0600 Subject: MAEMO: Fix zoom key capture on N900 (fixes bug#3443037) This was semi-intentionally skipped in the intial port revival because the focus was on N810 at the time. This is mostly copied from the old 1.2.1 port and then cleaned up. --- backends/graphics/maemosdl/maemosdl-graphics.cpp | 26 ++++++++++++++++++++++++ backends/graphics/maemosdl/maemosdl-graphics.h | 3 +++ 2 files changed, 29 insertions(+) (limited to 'backends') diff --git a/backends/graphics/maemosdl/maemosdl-graphics.cpp b/backends/graphics/maemosdl/maemosdl-graphics.cpp index 3309d91228..527ef82b9d 100644 --- a/backends/graphics/maemosdl/maemosdl-graphics.cpp +++ b/backends/graphics/maemosdl/maemosdl-graphics.cpp @@ -21,6 +21,8 @@ */ #if defined(MAEMO) +#include "SDL_syswm.h" + #include "common/scummsys.h" #include "backends/platform/maemo/maemo.h" @@ -31,4 +33,28 @@ MaemoSdlGraphicsManager::MaemoSdlGraphicsManager(SdlEventSource *sdlEventSource) : SurfaceSdlGraphicsManager(sdlEventSource) { } +bool MaemoSdlGraphicsManager::loadGFXMode() { + bool success = SurfaceSdlGraphicsManager::loadGFXMode(); + + // fix the problematic zoom key capture in Maemo5/N900 + SDL_SysWMinfo info; + SDL_VERSION(&info.version); + if (SDL_GetWMInfo(&info)) { + Display *dpy = info.info.x11.display; + Window win; + unsigned long val = 1; + Atom atom_zoom = XInternAtom(dpy, "_HILDON_ZOOM_KEY_ATOM", 0); + info.info.x11.lock_func(); + win = info.info.x11.fswindow; + if (win) + XChangeProperty(dpy, win, atom_zoom, XA_INTEGER, 32, PropModeReplace, (unsigned char *) &val, 1); // grab zoom keys + win = info.info.x11.wmwindow; + if (win) + XChangeProperty(dpy, win, atom_zoom, XA_INTEGER, 32, PropModeReplace, (unsigned char *) &val, 1); // grab zoom keys + info.info.x11.unlock_func(); + } + + return success; +} + #endif diff --git a/backends/graphics/maemosdl/maemosdl-graphics.h b/backends/graphics/maemosdl/maemosdl-graphics.h index 4a675b6159..81064d2d5f 100644 --- a/backends/graphics/maemosdl/maemosdl-graphics.h +++ b/backends/graphics/maemosdl/maemosdl-graphics.h @@ -30,6 +30,9 @@ class MaemoSdlGraphicsManager : public SurfaceSdlGraphicsManager { public: MaemoSdlGraphicsManager(SdlEventSource *sdlEventSource); + +protected: + virtual bool loadGFXMode(); }; #endif -- cgit v1.2.3 From 29b1f9f517fcee2e6328502eaaa7271113131438 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Sat, 3 Dec 2011 13:29:50 -0600 Subject: MAEMO: Add fields to debian/control --- backends/platform/maemo/debian/control | 2 ++ 1 file changed, 2 insertions(+) (limited to 'backends') diff --git a/backends/platform/maemo/debian/control b/backends/platform/maemo/debian/control index a1f0d95002..cb82bbcdd2 100644 --- a/backends/platform/maemo/debian/control +++ b/backends/platform/maemo/debian/control @@ -17,6 +17,8 @@ Description: interpreter that will play graphic adventure games Coktel Vision's Gobliiins, Wyrmkeep's Inherit the Earth, Westwood's Legend of Kyrandia, and various others. This package does not contain any actual games. +XSBC-Bugtracker: https://sourceforge.net/tracker/?atid=418820&group_id=37116&func=browse +XB-Maemo-Display-Name: ScummVM XBS-Maemo-Icon-26: iVBORw0KGgoAAAANSUhEUgAAABoAAAAaCAMAAACelLz8AAAC/VBMVEUICwcH CQUKDAgLDQoMDwsOEAwREAUPEQ0QEg8PFQoRExAUEwoVFAwPGAcTFBIRFg0W -- cgit v1.2.3 From 19228af1070af0cdcb2b768ed514a3529e458bd7 Mon Sep 17 00:00:00 2001 From: CeRiAl Date: Mon, 5 Dec 2011 00:40:58 +0100 Subject: WINCE: Update port specific README --- backends/platform/wince/README-WinCE.txt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'backends') diff --git a/backends/platform/wince/README-WinCE.txt b/backends/platform/wince/README-WinCE.txt index 429168c293..a28c126f7c 100644 --- a/backends/platform/wince/README-WinCE.txt +++ b/backends/platform/wince/README-WinCE.txt @@ -1,10 +1,17 @@ ScummVM Windows CE FAQ -Last updated: 2011-10-15 -Release version: 1.4.0 +Last updated: 2011-12-05 +Release version: x.x.x ------------------------------------------------------------------------ New in this version ------------------- +x.x.x: +- Removed FLAC support for audio datafiles (now for real, this was originally + announced for 1.0.0, but the library was still included until now). This is + done because of size constrains of the executable and also FLAC on a mobile + device isn't really recommended - so please use MP3 or Ogg for your audio + datafiles. + 1.4.0: - Changed the memory management so that it is finally possible to break the 32MB per process barrier on Windows CE. It should be possible now (finally) @@ -18,6 +25,8 @@ New in this version - Discworld 2 is now playable (works now because of the new memory management) - Replaced the game mass-adding functionality with the functionality used on all other platforms. It now shows progress while searching for games. +- Mapped "Skip" button to F10 for AGI games +- Mapped "Multi Function" to F10 in Simon 1 & 2 (enables hotspot highlighting) 1.3.1: - Fix for Normal2xAspect scaler which was causing screen update issues in some @@ -60,7 +69,7 @@ scummvm2.exe: - agos, cine, drascula, gob, groovie, kyra, made, parallaction, saga, teenagent, tucker scummvm3.exe: - - hugo, mohawk, sci, sword2, toon + - hugo, mohawk, sci, sword2, toon, tsage There are no other port specific changes. -- cgit v1.2.3 From cc81dfed17633363f78e84333c0f4c0de2c32ff5 Mon Sep 17 00:00:00 2001 From: CeRiAl Date: Mon, 5 Dec 2011 01:44:34 +0100 Subject: WINCE: Update port specific README --- backends/platform/wince/README-WinCE.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'backends') diff --git a/backends/platform/wince/README-WinCE.txt b/backends/platform/wince/README-WinCE.txt index a28c126f7c..11467fd482 100644 --- a/backends/platform/wince/README-WinCE.txt +++ b/backends/platform/wince/README-WinCE.txt @@ -273,6 +273,7 @@ The following actions are available : * Quit : quit ScummVM (without saving, be careful when using it) * Skip : skip a non interactive sequence, the current dialog or behaves like the ESC key on a regular keyboard + All AGI games -> F10 to quit full-screen dialogs * Hide : hide or display the toolbar * Keyboard : hide or display the virtual keyboard * Sound : turns all sound effects and music off and on @@ -291,6 +292,7 @@ The following actions are available : Fate of Atlantis -> sucker punch (cheat) Bargon -> F1 (start the game) All AGI games -> bring up the predictive input dialog + Simon 1 & 2 -> highlight all hotspots in screen * Bind keys map a key action to a device button * Up,Down,Left : Right, : emulate mouse/stylus behavior -- cgit v1.2.3 From 4b315b1f158770b0a24027f07cfb6b1a47f70401 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Sun, 4 Dec 2011 21:20:51 -0600 Subject: MAEMO: Remove i386 from Architecture field of debian/control It confuses the maemo.org autobuilder which tries to build x86 builds with ARMisms in them --- backends/platform/maemo/debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/maemo/debian/control b/backends/platform/maemo/debian/control index cb82bbcdd2..6e1dfe2fd4 100644 --- a/backends/platform/maemo/debian/control +++ b/backends/platform/maemo/debian/control @@ -7,7 +7,7 @@ Build-Depends: debhelper (>> 4.0.0), libsdl1.2-dev, libmad0-dev, libasound2-dev, Standards-Version: 3.6.1.1 Package: scummvm Depends: ${shlibs:Depends} -Architecture: i386 armel +Architecture: armel Section: user/games Description: interpreter that will play graphic adventure games written for LucasArts' SCUMM virtual machine, Sierra's AGI adventures, -- cgit v1.2.3 From fe79ce5038bd90b3aebd8d94644a3d1e1910c800 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 12 Dec 2011 16:27:20 +0100 Subject: AUDIO: Add endian FIXME to timdity code --- backends/midi/timidity.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'backends') diff --git a/backends/midi/timidity.cpp b/backends/midi/timidity.cpp index 87cd08659c..172d31e799 100644 --- a/backends/midi/timidity.cpp +++ b/backends/midi/timidity.cpp @@ -197,6 +197,8 @@ int MidiDriver_TIMIDITY::open() { /* should read something like "200 63017 is ready acceptable", * where 63017 is port for data connection */ + // FIXME: The following looks like a cheap endian test. If this is true, then + // it should be replaced by suitable #ifdef SCUMM_LITTLE_ENDIAN. i = 1; if (*(char *)&i == 1) res = timidity_ctl_command("OPEN lsb"); -- cgit v1.2.3 From 9095de46741c9044c2deff8ecfc911903203b6fe Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 12 Dec 2011 16:43:17 +0100 Subject: MACOSX: Optionally allow building against "new" (10.5+) CoreAudio API This silences a bunch of deprecation warnings when compiling on any current system. Moreover, the new API is available on the iPhone, so perhaps this is interesting for the iPhone port, too. On the long run, ScummVM will have to switch to the new API, as Apple will eventually drop the old one. --- backends/midi/coreaudio.cpp | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) (limited to 'backends') diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp index 305b462836..4b707eace6 100644 --- a/backends/midi/coreaudio.cpp +++ b/backends/midi/coreaudio.cpp @@ -26,15 +26,24 @@ #ifdef MACOSX -// HACK to disable deprecated warnings under Mac OS X 10.5. -// Apple depracted the AUGraphNewNode & AUGraphGetNodeInfo APIs -// in favor of the new AUGraphAddNode & AUGraphNodeInfo APIs. -// While it would be trivial to switch to those, this would break -// binary compatibility with all pre-10.5 systems, so we don't want -// to do that just now. Maybe when 10.6 comes... :) + +// HACK to disable deprecated warnings under Mac OS X 10.5. Apple deprecated the +// AUGraphNewNode & AUGraphGetNodeInfo APIs in favor of the new AUGraphAddNode & +// AUGraphNodeInfo APIs. While it is easy to switch to those, it breaks +// compatibility with all pre-10.5 systems. +// If you want to retain compatibility with old systems, enable the following +// switch. But Apple will eventually remove these APIs, at which point the +// switch needs to be disabled. +// +// Also note that only the new API is available on the iPhone! +#define USE_DEPRECATED_COREAUDIO_API + + +#ifdef USE_DEPRECATED_COREAUDIO_API #include #undef DEPRECATED_ATTRIBUTE #define DEPRECATED_ATTRIBUTE +#endif #include "common/config-manager.h" @@ -105,7 +114,11 @@ int MidiDriver_CORE::open() { RequireNoErr(NewAUGraph(&_auGraph)); AUNode outputNode, synthNode; +#ifdef USE_DEPRECATED_COREAUDIO_API ComponentDescription desc; +#else + AudioComponentDescription desc; +#endif // The default output device desc.componentType = kAudioUnitType_Output; @@ -113,13 +126,21 @@ int MidiDriver_CORE::open() { desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; +#ifdef USE_DEPRECATED_COREAUDIO_API RequireNoErr(AUGraphNewNode(_auGraph, &desc, 0, NULL, &outputNode)); +#else + RequireNoErr(AUGraphAddNode(_auGraph, &desc, &outputNode)); +#endif // The built-in default (softsynth) music device desc.componentType = kAudioUnitType_MusicDevice; desc.componentSubType = kAudioUnitSubType_DLSSynth; desc.componentManufacturer = kAudioUnitManufacturer_Apple; +#ifdef USE_DEPRECATED_COREAUDIO_API RequireNoErr(AUGraphNewNode(_auGraph, &desc, 0, NULL, &synthNode)); +#else + RequireNoErr(AUGraphAddNode(_auGraph, &desc, &synthNode)); +#endif // Connect the softsynth to the default output RequireNoErr(AUGraphConnectNodeInput(_auGraph, synthNode, 0, outputNode, 0)); @@ -129,8 +150,11 @@ int MidiDriver_CORE::open() { RequireNoErr(AUGraphInitialize(_auGraph)); // Get the music device from the graph. +#ifdef USE_DEPRECATED_COREAUDIO_API RequireNoErr(AUGraphGetNodeInfo(_auGraph, synthNode, NULL, NULL, NULL, &_synth)); - +#else + RequireNoErr(AUGraphNodeInfo(_auGraph, synthNode, NULL, &_synth)); +#endif // Load custom soundfont, if specified if (ConfMan.hasKey("soundfont")) { -- cgit v1.2.3 From feb04d2164766378d40304a843ab0374b87320a1 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Mon, 12 Dec 2011 20:15:08 -0600 Subject: KEYMAPPER: Add Common::KeyActionEntry for making simple keymap tables --- backends/keymapper/action.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'backends') diff --git a/backends/keymapper/action.h b/backends/keymapper/action.h index b15b3aaaad..e5bf6d51dd 100644 --- a/backends/keymapper/action.h +++ b/backends/keymapper/action.h @@ -40,6 +40,12 @@ class Keymap; #define ACTION_ID_SIZE (4) +struct KeyActionEntry { + const KeyState ks; + const char *id; + const char *description; +}; + struct Action { /** unique id used for saving/loading to config */ char id[ACTION_ID_SIZE]; -- cgit v1.2.3 From 1b11139dc53da2dc95f74eb19e3a903d7d786f84 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Mon, 12 Dec 2011 21:26:35 -0600 Subject: KEYMAPPER: Switch to using addClearButton() --- backends/keymapper/remap-dialog.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index b0f42fe426..4813beb38c 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -172,16 +172,7 @@ void RemapDialog::reflowLayout() { new GUI::StaticTextWidget(this, 0, 0, 0, 0, "", Graphics::kTextAlignRight); widg.keyButton = new GUI::ButtonWidget(this, 0, 0, 0, 0, "", 0, kRemapCmd + i); -#ifndef DISABLE_FANCY_THEMES - if (g_gui.xmlEval()->getVar("Globals.ShowSearchPic") == 1 && g_gui.theme()->supportsImages()) { - widg.clearButton = new GUI::PicButtonWidget(this, 0, 0, clearButtonWidth, clearButtonHeight, _("Clear value"), kClearCmd + i); - ((GUI::PicButtonWidget *)widg.clearButton)->useThemeTransparency(true); - ((GUI::PicButtonWidget *)widg.clearButton)->setGfx(g_gui.theme()->getImageSurface(GUI::ThemeEngine::kImageEraser)); - } - else -#endif - widg.clearButton = new GUI::ButtonWidget(this, 0, 0, 0, 0, "C", _("Clear value"), kClearCmd + i); - + widg.clearButton = addClearButton(this, "", kClearCmd, 0, 0, clearButtonWidth, clearButtonHeight); _keymapWidgets.push_back(widg); } else { widg = _keymapWidgets[i]; -- cgit v1.2.3 From d085f4f4e26f018347292bf9d3c0a5037bbe0e65 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 13 Dec 2011 18:29:40 +0100 Subject: WIN32: (Hopefully) fix compilation by adapting to latest Archive changes. --- backends/platform/sdl/win32/win32.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index a2c8e43424..b82afca168 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -256,9 +256,9 @@ class Win32ResourceArchive : public Common::Archive { public: Win32ResourceArchive(); - virtual bool hasFile(const Common::String &name); - virtual int listMembers(Common::ArchiveMemberList &list); - virtual Common::ArchiveMemberPtr getMember(const Common::String &name); + virtual bool hasFile(const Common::String &name) const; + virtual int listMembers(Common::ArchiveMemberList &list) const; + virtual Common::ArchiveMemberPtr getMember(const Common::String &name) const; virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; private: typedef Common::List FilenameList; @@ -279,7 +279,7 @@ Win32ResourceArchive::Win32ResourceArchive() { EnumResourceNames(NULL, MAKEINTRESOURCE(256), &EnumResNameProc, (LONG_PTR)this); } -bool Win32ResourceArchive::hasFile(const Common::String &name) { +bool Win32ResourceArchive::hasFile(const Common::String &name) const { for (FilenameList::const_iterator i = _files.begin(); i != _files.end(); ++i) { if (i->equalsIgnoreCase(name)) return true; @@ -288,7 +288,7 @@ bool Win32ResourceArchive::hasFile(const Common::String &name) { return false; } -int Win32ResourceArchive::listMembers(Common::ArchiveMemberList &list) { +int Win32ResourceArchive::listMembers(Common::ArchiveMemberList &list) const { int count = 0; for (FilenameList::const_iterator i = _files.begin(); i != _files.end(); ++i, ++count) @@ -297,7 +297,7 @@ int Win32ResourceArchive::listMembers(Common::ArchiveMemberList &list) { return count; } -Common::ArchiveMemberPtr Win32ResourceArchive::getMember(const Common::String &name) { +Common::ArchiveMemberPtr Win32ResourceArchive::getMember(const Common::String &name) const { return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); } -- cgit v1.2.3 From 6c790ea6a7b34ed24dd207c78e5dec7512adc191 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 13 Dec 2011 18:37:33 +0100 Subject: ANDROID: Fix compilation by adapting to latest Archive changes (thanks LordHoto). --- backends/platform/android/asset-archive.cpp | 6 +++--- backends/platform/android/asset-archive.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'backends') diff --git a/backends/platform/android/asset-archive.cpp b/backends/platform/android/asset-archive.cpp index fe52a3d8d4..ed143994e4 100644 --- a/backends/platform/android/asset-archive.cpp +++ b/backends/platform/android/asset-archive.cpp @@ -389,7 +389,7 @@ AndroidAssetArchive::~AndroidAssetArchive() { env->DeleteGlobalRef(_am); } -bool AndroidAssetArchive::hasFile(const Common::String &name) { +bool AndroidAssetArchive::hasFile(const Common::String &name) const { JNIEnv *env = JNI::getEnv(); jstring path = env->NewStringUTF(name.c_str()); jobject result = env->CallObjectMethod(_am, MID_open, path, ACCESS_UNKNOWN); @@ -409,7 +409,7 @@ bool AndroidAssetArchive::hasFile(const Common::String &name) { return true; } -int AndroidAssetArchive::listMembers(Common::ArchiveMemberList &member_list) { +int AndroidAssetArchive::listMembers(Common::ArchiveMemberList &member_list) const { JNIEnv *env = JNI::getEnv(); Common::List dirlist; dirlist.push_back(""); @@ -466,7 +466,7 @@ int AndroidAssetArchive::listMembers(Common::ArchiveMemberList &member_list) { return count; } -Common::ArchiveMemberPtr AndroidAssetArchive::getMember(const Common::String &name) { +const Common::ArchiveMemberPtr AndroidAssetArchive::getMember(const Common::String &name) const { return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); } diff --git a/backends/platform/android/asset-archive.h b/backends/platform/android/asset-archive.h index 9216412e0a..c5e43555e0 100644 --- a/backends/platform/android/asset-archive.h +++ b/backends/platform/android/asset-archive.h @@ -37,9 +37,9 @@ public: AndroidAssetArchive(jobject am); virtual ~AndroidAssetArchive(); - virtual bool hasFile(const Common::String &name); - virtual int listMembers(Common::ArchiveMemberList &list); - virtual Common::ArchiveMemberPtr getMember(const Common::String &name); + virtual bool hasFile(const Common::String &name) const; + virtual int listMembers(Common::ArchiveMemberList &list) const; + virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const; virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; private: -- cgit v1.2.3 From c780b58e88f2ae19c3610744bb2c3740e98b3056 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Tue, 13 Dec 2011 18:44:58 +0100 Subject: ANDROID: Fix assert in JavaInputStream (thanks clone2727). --- backends/platform/android/asset-archive.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/android/asset-archive.cpp b/backends/platform/android/asset-archive.cpp index ed143994e4..14840de996 100644 --- a/backends/platform/android/asset-archive.cpp +++ b/backends/platform/android/asset-archive.cpp @@ -103,7 +103,7 @@ JavaInputStream::JavaInputStream(JNIEnv *env, jobject is) : MID_mark = env->GetMethodID(cls, "mark", "(I)V"); assert(MID_mark); MID_available = env->GetMethodID(cls, "available", "()I"); - assert(MID_mark); + assert(MID_available); MID_close = env->GetMethodID(cls, "close", "()V"); assert(MID_close); MID_read = env->GetMethodID(cls, "read", "([BII)I"); -- cgit v1.2.3 From 5eb592a1c92d6069529dc3a78b06a9d40d384ed7 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 13 Dec 2011 22:47:46 +0200 Subject: WIN32: Fix build by adapting to the latest Archive changes --- backends/platform/sdl/win32/win32.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index b82afca168..3e09aa2640 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -258,7 +258,7 @@ public: virtual bool hasFile(const Common::String &name) const; virtual int listMembers(Common::ArchiveMemberList &list) const; - virtual Common::ArchiveMemberPtr getMember(const Common::String &name) const; + virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const; virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; private: typedef Common::List FilenameList; @@ -297,7 +297,7 @@ int Win32ResourceArchive::listMembers(Common::ArchiveMemberList &list) const { return count; } -Common::ArchiveMemberPtr Win32ResourceArchive::getMember(const Common::String &name) const { +const Common::ArchiveMemberPtr Win32ResourceArchive::getMember(const Common::String &name) const { return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, this)); } -- cgit v1.2.3 From c91b6d7d357300597e74126b48aa1473587a8133 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 15 Dec 2011 21:45:52 +0100 Subject: OPENGLSDL: Fix video mode initialization for 640x400 games with AR enabled. Formerly they always used a height of 240 * scaleFactor, which would for exmaple make the games requesting a 1x scaler use a height of 240 if AR is enabled. This was a regression from b8dcd9a25eb27ef40aa5535fc83879d20db7e10c. --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'backends') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index cfc78cfcac..ab44b00104 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -318,12 +318,14 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { // only used to ensure that the original pixel size aspect for these // modes is used. // (Non-square pixels on old monitors vs square pixel on new ones). - if (_videoMode.aspectRatioCorrection - && ((_videoMode.screenWidth == 320 && _videoMode.screenHeight == 200) - || (_videoMode.screenWidth == 640 && _videoMode.screenHeight == 400))) - _videoMode.overlayHeight = _videoMode.hardwareHeight = 240 * scaleFactor; - else + if (_videoMode.aspectRatioCorrection) { + if (_videoMode.screenWidth == 320 && _videoMode.screenHeight == 200) + _videoMode.overlayHeight = _videoMode.hardwareHeight = 240 * scaleFactor; + else if (_videoMode.screenWidth == 640 && _videoMode.screenHeight == 400) + _videoMode.overlayHeight = _videoMode.hardwareHeight = 480 * scaleFactor; + } else { _videoMode.overlayHeight = _videoMode.hardwareHeight = _videoMode.screenHeight * scaleFactor; + } } _screenResized = false; -- cgit v1.2.3 From 772aecf5f8c5ac69dd3755bb948c6ebdb5a11f94 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 15 Dec 2011 21:53:09 +0100 Subject: OPENGLSDL: Simplify the code a bit. --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'backends') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index ab44b00104..f2b3168e36 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -323,8 +323,6 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { _videoMode.overlayHeight = _videoMode.hardwareHeight = 240 * scaleFactor; else if (_videoMode.screenWidth == 640 && _videoMode.screenHeight == 400) _videoMode.overlayHeight = _videoMode.hardwareHeight = 480 * scaleFactor; - } else { - _videoMode.overlayHeight = _videoMode.hardwareHeight = _videoMode.screenHeight * scaleFactor; } } -- cgit v1.2.3 From 410c9e0b30ae3f140bd55cfcfa05308d929da24e Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 30 Dec 2011 00:08:31 +0200 Subject: KEYMAPPER: Fix broken implementation of findHardwareKey() This fixes the keymapper dialog (at least on desktop platforms), but the keymapper itself is still not working (tested with LoL) --- backends/keymapper/hardware-key.h | 8 ++++++-- backends/keymapper/keymap.cpp | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h index 32df042525..014e73a11e 100644 --- a/backends/keymapper/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -97,8 +97,12 @@ public: List::const_iterator it; for (it = _keys.begin(); it != _keys.end(); it++) { - if ((*it)->key == keystate) - return (*it); + if ((*it)->key.keycode == keystate.keycode) { + // Only check for control/alt/shift modifiers, not for sticky + // modifiers like num lock/caps lock/scroll lock + if ((*it)->key.flags == (keystate.flags & 7)) + return (*it); + } } return 0; } diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp index d2c9b9b572..d64b888702 100644 --- a/backends/keymapper/keymap.cpp +++ b/backends/keymapper/keymap.cpp @@ -145,7 +145,7 @@ void Keymap::loadMappings(const HardwareKeySet *hwKeys) { const HardwareKey *hwKey = hwKeys->findHardwareKey(it->_value.c_str()); if (!hwKey) { - warning("HardwareKey with ID %s not known", it->_value.c_str()); + warning("HardwareKey with ID '%s' not known", it->_value.c_str()); _configDomain->erase(key); continue; } @@ -199,7 +199,7 @@ bool Keymap::isComplete(const HardwareKeySet *hwKeys) { // - if an action finds a key with required type but a parent action with // higher priority is using it, that key is never used void Keymap::automaticMapping(HardwareKeySet *hwKeys) { -#if 0 //disabling the broken automapper for now +#if 1 //disabling the broken automapper for now // Create copies of action and key lists. List actions(_actions); List keys(hwKeys->getHardwareKeys()); -- cgit v1.2.3 From 1d3ff353730c26a3adba3599db70334630c1da94 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 30 Dec 2011 00:12:45 +0200 Subject: KEYMAPPER: Disable the (accidentally reenabled automatic mapper again --- backends/keymapper/keymap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp index d64b888702..6fc1b1e08d 100644 --- a/backends/keymapper/keymap.cpp +++ b/backends/keymapper/keymap.cpp @@ -199,7 +199,7 @@ bool Keymap::isComplete(const HardwareKeySet *hwKeys) { // - if an action finds a key with required type but a parent action with // higher priority is using it, that key is never used void Keymap::automaticMapping(HardwareKeySet *hwKeys) { -#if 1 //disabling the broken automapper for now +#if 0 //disabling the broken automapper for now // Create copies of action and key lists. List actions(_actions); List keys(hwKeys->getHardwareKeys()); -- cgit v1.2.3 From d55ce3626800cfa316bb90a1e2fcc0b3d5dbe203 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 30 Dec 2011 01:15:06 +0200 Subject: KEYMAPPER: Use hasFlags() in findHardwareKey() --- backends/keymapper/hardware-key.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h index 014e73a11e..daa853df08 100644 --- a/backends/keymapper/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -97,12 +97,8 @@ public: List::const_iterator it; for (it = _keys.begin(); it != _keys.end(); it++) { - if ((*it)->key.keycode == keystate.keycode) { - // Only check for control/alt/shift modifiers, not for sticky - // modifiers like num lock/caps lock/scroll lock - if ((*it)->key.flags == (keystate.flags & 7)) - return (*it); - } + if (keystate.keycode == (*it)->key.keycode && keystate.hasFlags((*it)->key.flags)) + return (*it); } return 0; } -- cgit v1.2.3 From a473934abd2dc4d402963c6f43cec4147ab71e82 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 30 Dec 2011 13:59:05 +0200 Subject: COMMON: Perform some keymapper-related changes to the KeyState struct The == operator in KeyState should not be checking for sticky modifier keys. This allows the keymapper's defined actions to function correctly in desktop platforms, when sticky modifier keys such as caps lock and num lock are turned on. Also, added some sanity checks to hasFlags() and enums for sticky and non-sticky keys --- backends/keymapper/hardware-key.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h index daa853df08..32df042525 100644 --- a/backends/keymapper/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -97,7 +97,7 @@ public: List::const_iterator it; for (it = _keys.begin(); it != _keys.end(); it++) { - if (keystate.keycode == (*it)->key.keycode && keystate.hasFlags((*it)->key.flags)) + if ((*it)->key == keystate) return (*it); } return 0; -- cgit v1.2.3 From 366a942a3a3dd9c3005c0f29d9e0b498eaf976ef Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 30 Dec 2011 13:03:39 -0600 Subject: KEYMAPPER: Simplify calling getKeymap --- backends/keymapper/keymapper.cpp | 9 ++++++--- backends/keymapper/keymapper.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index 29f495cd53..025e917273 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -128,21 +128,24 @@ void Keymapper::cleanupGameKeymaps() { _activeMaps = newStack; } -Keymap *Keymapper::getKeymap(const String& name, bool &global) { +Keymap *Keymapper::getKeymap(const String& name, bool *globalReturn) { Keymap *keymap = _gameDomain.getKeymap(name); - global = false; + bool global = false; if (!keymap) { keymap = _globalDomain.getKeymap(name); global = true; } + if (globalReturn) + *globalReturn = global; + return keymap; } bool Keymapper::pushKeymap(const String& name, bool inherit) { bool global; - Keymap *newMap = getKeymap(name, global); + Keymap *newMap = getKeymap(name, &global); if (!newMap) { warning("Keymap '%s' not registered", name.c_str()); diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index c5a2558964..d38109f210 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -116,7 +116,7 @@ public: * @param name name of the keymap to return * @param global set to true if returned keymap is global, false if game */ - Keymap *getKeymap(const String& name, bool &global); + Keymap *getKeymap(const String& name, bool *global = 0); /** * Push a new keymap to the top of the active stack, activating -- cgit v1.2.3 From 0e0eddbab333589759480941b5e01bbe77413ac8 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 30 Dec 2011 13:13:41 -0600 Subject: KEYMAPPER: Fix clear button behavior in remap dialog This is a regression from 1b11139dc53da2dc95f74eb19e3a903d7d786f84 --- backends/keymapper/remap-dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 4813beb38c..93b8725341 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -172,7 +172,7 @@ void RemapDialog::reflowLayout() { new GUI::StaticTextWidget(this, 0, 0, 0, 0, "", Graphics::kTextAlignRight); widg.keyButton = new GUI::ButtonWidget(this, 0, 0, 0, 0, "", 0, kRemapCmd + i); - widg.clearButton = addClearButton(this, "", kClearCmd, 0, 0, clearButtonWidth, clearButtonHeight); + widg.clearButton = addClearButton(this, "", kClearCmd + i, 0, 0, clearButtonWidth, clearButtonHeight); _keymapWidgets.push_back(widg); } else { widg = _keymapWidgets[i]; -- cgit v1.2.3 From 16d529cdc335feea858fde690fc1b3eae48449a2 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 30 Dec 2011 15:28:46 -0600 Subject: KEYMAPPER: Use single column in remap dialog This is to allow for long labels like in the eob keymap --- backends/keymapper/remap-dialog.cpp | 21 +++++++++++---------- backends/keymapper/remap-dialog.h | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 93b8725341..2039acf245 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -138,18 +138,19 @@ void RemapDialog::reflowLayout() { int16 areaX, areaY; uint16 areaW, areaH; + g_gui.xmlEval()->getWidgetData((const String&)String("KeyMapper.KeymapArea"), areaX, areaY, areaW, areaH); + int spacing = g_gui.xmlEval()->getVar("Globals.KeyMapper.Spacing"); - int labelWidth = g_gui.xmlEval()->getVar("Globals.KeyMapper.LabelWidth"); int keyButtonWidth = g_gui.xmlEval()->getVar("Globals.KeyMapper.ButtonWidth"); int clearButtonWidth = g_gui.xmlEval()->getVar("Globals.Line.Height"); int clearButtonHeight = g_gui.xmlEval()->getVar("Globals.Line.Height"); - int colWidth = labelWidth + keyButtonWidth + clearButtonWidth + spacing; - g_gui.xmlEval()->getWidgetData((const String&)String("KeyMapper.KeymapArea"), areaX, areaY, areaW, areaH); + int colWidth = areaW - scrollbarWidth; + int labelWidth = colWidth - (keyButtonWidth + spacing + clearButtonWidth + spacing); - _colCount = (areaW - scrollbarWidth) / colWidth; _rowCount = (areaH + spacing) / (buttonHeight + spacing); - if (_colCount <= 0 || _rowCount <= 0) + debug("rowCount = %d" , _rowCount); + if (colWidth <= 0 || _rowCount <= 0) error("Remap dialog too small to display any keymaps"); _scrollBar->resize(areaX + areaW - scrollbarWidth, areaY, scrollbarWidth, areaH); @@ -160,7 +161,7 @@ void RemapDialog::reflowLayout() { uint textYOff = (buttonHeight - kLineHeight) / 2; uint clearButtonYOff = (buttonHeight - clearButtonHeight) / 2; uint oldSize = _keymapWidgets.size(); - uint newSize = _rowCount * _colCount; + uint newSize = _rowCount; _keymapWidgets.reserve(newSize); @@ -178,8 +179,8 @@ void RemapDialog::reflowLayout() { widg = _keymapWidgets[i]; } - uint x = areaX + (i % _colCount) * colWidth; - uint y = areaY + (i / _colCount) * (buttonHeight + spacing); + uint x = areaX; + uint y = areaY + (i) * (buttonHeight + spacing); widg.actionText->resize(x, y + textYOff, labelWidth, kLineHeight); widg.keyButton->resize(x + labelWidth, y, keyButtonWidth, buttonHeight); @@ -362,7 +363,7 @@ void RemapDialog::loadKeymap() { // refresh scroll bar _scrollBar->_currentPos = 0; - _scrollBar->_numEntries = (_currentActions.size() + _colCount - 1) / _colCount; + _scrollBar->_numEntries = _currentActions.size(); _scrollBar->recalc(); // force refresh @@ -371,7 +372,7 @@ void RemapDialog::loadKeymap() { } void RemapDialog::refreshKeymap() { - int newTopAction = _scrollBar->_currentPos * _colCount; + int newTopAction = _scrollBar->_currentPos; if (newTopAction == _topAction) return; diff --git a/backends/keymapper/remap-dialog.h b/backends/keymapper/remap-dialog.h index 25e336c4fe..1cb930bd42 100644 --- a/backends/keymapper/remap-dialog.h +++ b/backends/keymapper/remap-dialog.h @@ -82,7 +82,7 @@ protected: //GUI::ContainerWidget *_container; GUI::ScrollBarWidget *_scrollBar; - uint _colCount, _rowCount; + uint _rowCount; Array _keymapWidgets; Action *_activeRemapAction; -- cgit v1.2.3 From b89bc000d96fce9d4e977b8ad59391282e35704e Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 30 Dec 2011 15:51:08 -0600 Subject: KEYMAPPER: Remap dialog shows buttons before labels --- backends/keymapper/remap-dialog.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 2039acf245..c0654fc0ea 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -170,7 +170,7 @@ void RemapDialog::reflowLayout() { if (i >= _keymapWidgets.size()) { widg.actionText = - new GUI::StaticTextWidget(this, 0, 0, 0, 0, "", Graphics::kTextAlignRight); + new GUI::StaticTextWidget(this, 0, 0, 0, 0, "", Graphics::kTextAlignLeft); widg.keyButton = new GUI::ButtonWidget(this, 0, 0, 0, 0, "", 0, kRemapCmd + i); widg.clearButton = addClearButton(this, "", kClearCmd + i, 0, 0, clearButtonWidth, clearButtonHeight); @@ -182,9 +182,10 @@ void RemapDialog::reflowLayout() { uint x = areaX; uint y = areaY + (i) * (buttonHeight + spacing); - widg.actionText->resize(x, y + textYOff, labelWidth, kLineHeight); - widg.keyButton->resize(x + labelWidth, y, keyButtonWidth, buttonHeight); - widg.clearButton->resize(x + labelWidth + keyButtonWidth + spacing, y + clearButtonYOff, clearButtonWidth, clearButtonHeight); + widg.keyButton->resize(x, y, keyButtonWidth, buttonHeight); + widg.clearButton->resize(x + keyButtonWidth + spacing, y + clearButtonYOff, clearButtonWidth, clearButtonHeight); + widg.actionText->resize(x + keyButtonWidth + spacing + clearButtonWidth + spacing, y + textYOff, labelWidth, kLineHeight); + } while (oldSize > newSize) { ActionWidgets widg = _keymapWidgets.remove_at(--oldSize); @@ -391,7 +392,7 @@ void RemapDialog::refreshKeymap() { debug(8, "RemapDialog::refreshKeymap actionI=%u", actionI); ActionInfo& info = _currentActions[actionI]; - widg.actionText->setLabel(info.description + ": "); + widg.actionText->setLabel(info.description); widg.actionText->setEnabled(!info.inherited); const HardwareKey *mappedKey = info.action->getMappedKey(); -- cgit v1.2.3 From e2ded73d923a2be759b272ebca7c989603ef0f31 Mon Sep 17 00:00:00 2001 From: Strangerke Date: Sun, 1 Jan 2012 11:49:41 +0100 Subject: MISC: This is year 2012 --- backends/platform/symbian/README | 2 +- backends/platform/symbian/S60/ScummVM_S60.mmp.in | 2 +- backends/platform/symbian/S60/ScummVM_S60_App.mmp | 2 +- backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in | 2 +- backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in | 2 +- backends/platform/symbian/S80/ScummVM_S80.mmp.in | 2 +- backends/platform/symbian/S80/ScummVM_S80_App.mmp | 2 +- backends/platform/symbian/S90/Scummvm_S90.mmp.in | 2 +- backends/platform/symbian/S90/Scummvm_S90_App.mmp | 2 +- backends/platform/symbian/UIQ2/ScummVM.rss | 2 +- backends/platform/symbian/UIQ3/ScummVM.rss | 2 +- backends/platform/symbian/UIQ3/ScummVM_A0000658.rss | 2 +- backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in | 2 +- backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in | 2 +- backends/platform/symbian/UIQ3/scummvm_A0000658_loc.rss | 2 +- backends/platform/symbian/mmp/scummvm_agi.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_agos.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_base.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_cine.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_cruise.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_draci.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_drascula.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_gob.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_groovie.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_hugo.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_kyra.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_lastexpress.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_lure.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_m4.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_made.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_mohawk.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_parallaction.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_queen.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_saga.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_sci.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_scumm.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_sky.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_sword1.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_sword2.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_teenagent.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_tinsel.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_toon.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_touche.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_tsage.mmp.in | 2 +- backends/platform/symbian/mmp/scummvm_tucker.mmp.in | 2 +- backends/platform/symbian/res/ScummVmAif.rss | 2 +- backends/platform/symbian/res/scummvm.rss | 2 +- backends/platform/symbian/res/scummvm_A0000658.rss | 2 +- backends/platform/symbian/src/ScummVm.hrh | 2 +- 49 files changed, 49 insertions(+), 49 deletions(-) (limited to 'backends') diff --git a/backends/platform/symbian/README b/backends/platform/symbian/README index 83e98a534a..31bc3d8fce 100644 --- a/backends/platform/symbian/README +++ b/backends/platform/symbian/README @@ -1,7 +1,7 @@ ScummVM - ScummVM ported to EPOC/SymbianOS - Copyright (C) 2008-2011 ScummVM Team + Copyright (C) 2008-2012 ScummVM Team Copyright (C) 2003-2008 Lars 'AnotherGuest' Persson Copyright (C) 2002-2008 Jurgen 'SumthinWicked' Braam diff --git a/backends/platform/symbian/S60/ScummVM_S60.mmp.in b/backends/platform/symbian/S60/ScummVM_S60.mmp.in index 7b401fd310..81068ba073 100644 --- a/backends/platform/symbian/S60/ScummVM_S60.mmp.in +++ b/backends/platform/symbian/S60/ScummVM_S60.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/S60/ScummVM_S60_App.mmp b/backends/platform/symbian/S60/ScummVM_S60_App.mmp index 940997cc73..e00987e2ad 100644 --- a/backends/platform/symbian/S60/ScummVM_S60_App.mmp +++ b/backends/platform/symbian/S60/ScummVM_S60_App.mmp @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in b/backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in index 583d1a35e7..ccf38818dc 100644 --- a/backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in +++ b/backends/platform/symbian/S60v3/ScummVM_A0000658_S60v3.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in b/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in index 5367bf0d1f..0162061284 100644 --- a/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in +++ b/backends/platform/symbian/S60v3/ScummVM_S60v3.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/S80/ScummVM_S80.mmp.in b/backends/platform/symbian/S80/ScummVM_S80.mmp.in index 5e4b6d447e..7987ccd639 100644 --- a/backends/platform/symbian/S80/ScummVM_S80.mmp.in +++ b/backends/platform/symbian/S80/ScummVM_S80.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/S80/ScummVM_S80_App.mmp b/backends/platform/symbian/S80/ScummVM_S80_App.mmp index e91b504087..b66bef7518 100644 --- a/backends/platform/symbian/S80/ScummVM_S80_App.mmp +++ b/backends/platform/symbian/S80/ScummVM_S80_App.mmp @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/S90/Scummvm_S90.mmp.in b/backends/platform/symbian/S90/Scummvm_S90.mmp.in index 06d65f1641..d803ce5647 100644 --- a/backends/platform/symbian/S90/Scummvm_S90.mmp.in +++ b/backends/platform/symbian/S90/Scummvm_S90.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/S90/Scummvm_S90_App.mmp b/backends/platform/symbian/S90/Scummvm_S90_App.mmp index 3aa2cc2a65..0d8d2b8710 100644 --- a/backends/platform/symbian/S90/Scummvm_S90_App.mmp +++ b/backends/platform/symbian/S90/Scummvm_S90_App.mmp @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/UIQ2/ScummVM.rss b/backends/platform/symbian/UIQ2/ScummVM.rss index 374bd50680..a6ba4021e4 100644 --- a/backends/platform/symbian/UIQ2/ScummVM.rss +++ b/backends/platform/symbian/UIQ2/ScummVM.rss @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License diff --git a/backends/platform/symbian/UIQ3/ScummVM.rss b/backends/platform/symbian/UIQ3/ScummVM.rss index 2021b0506e..00ed4e3b5c 100644 --- a/backends/platform/symbian/UIQ3/ScummVM.rss +++ b/backends/platform/symbian/UIQ3/ScummVM.rss @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/UIQ3/ScummVM_A0000658.rss b/backends/platform/symbian/UIQ3/ScummVM_A0000658.rss index 2021b0506e..00ed4e3b5c 100644 --- a/backends/platform/symbian/UIQ3/ScummVM_A0000658.rss +++ b/backends/platform/symbian/UIQ3/ScummVM_A0000658.rss @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in b/backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in index 3bc93d8ce3..9e419ad6d9 100644 --- a/backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in +++ b/backends/platform/symbian/UIQ3/ScummVM_A0000658_UIQ3.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2009 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2009 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in b/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in index bd5016f8d1..41452127ca 100644 --- a/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in +++ b/backends/platform/symbian/UIQ3/ScummVM_UIQ3.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/UIQ3/scummvm_A0000658_loc.rss b/backends/platform/symbian/UIQ3/scummvm_A0000658_loc.rss index 7f3b71ef84..9af9a33a75 100644 --- a/backends/platform/symbian/UIQ3/scummvm_A0000658_loc.rss +++ b/backends/platform/symbian/UIQ3/scummvm_A0000658_loc.rss @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_agi.mmp.in b/backends/platform/symbian/mmp/scummvm_agi.mmp.in index 5805d36133..7d197f786f 100644 --- a/backends/platform/symbian/mmp/scummvm_agi.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_agi.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_agos.mmp.in b/backends/platform/symbian/mmp/scummvm_agos.mmp.in index 236a62f1b8..587d1f0b69 100644 --- a/backends/platform/symbian/mmp/scummvm_agos.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_agos.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_base.mmp.in b/backends/platform/symbian/mmp/scummvm_base.mmp.in index 0387bfaf26..05cf526233 100644 --- a/backends/platform/symbian/mmp/scummvm_base.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_base.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_cine.mmp.in b/backends/platform/symbian/mmp/scummvm_cine.mmp.in index e75ece95f1..79806eb8c2 100644 --- a/backends/platform/symbian/mmp/scummvm_cine.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_cine.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_cruise.mmp.in b/backends/platform/symbian/mmp/scummvm_cruise.mmp.in index a91d33b5f5..53d52c80e7 100644 --- a/backends/platform/symbian/mmp/scummvm_cruise.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_cruise.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_draci.mmp.in b/backends/platform/symbian/mmp/scummvm_draci.mmp.in index 044247fac7..9a7c87c963 100644 --- a/backends/platform/symbian/mmp/scummvm_draci.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_draci.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_drascula.mmp.in b/backends/platform/symbian/mmp/scummvm_drascula.mmp.in index 0561e494c1..fcd7ce7585 100644 --- a/backends/platform/symbian/mmp/scummvm_drascula.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_drascula.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_gob.mmp.in b/backends/platform/symbian/mmp/scummvm_gob.mmp.in index 7c92611fd2..23f110bc7d 100644 --- a/backends/platform/symbian/mmp/scummvm_gob.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_gob.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_groovie.mmp.in b/backends/platform/symbian/mmp/scummvm_groovie.mmp.in index c0294b3b0d..6bdeb06b10 100644 --- a/backends/platform/symbian/mmp/scummvm_groovie.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_groovie.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_hugo.mmp.in b/backends/platform/symbian/mmp/scummvm_hugo.mmp.in index 66e22fc34b..69888bb0ee 100644 --- a/backends/platform/symbian/mmp/scummvm_hugo.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_hugo.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_kyra.mmp.in b/backends/platform/symbian/mmp/scummvm_kyra.mmp.in index d5f2ec951c..4a2a87216e 100644 --- a/backends/platform/symbian/mmp/scummvm_kyra.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_kyra.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_lastexpress.mmp.in b/backends/platform/symbian/mmp/scummvm_lastexpress.mmp.in index 57efa31a85..27ec0b2148 100644 --- a/backends/platform/symbian/mmp/scummvm_lastexpress.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_lastexpress.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_lure.mmp.in b/backends/platform/symbian/mmp/scummvm_lure.mmp.in index 2ac1f8f8ff..20b938a83f 100644 --- a/backends/platform/symbian/mmp/scummvm_lure.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_lure.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_m4.mmp.in b/backends/platform/symbian/mmp/scummvm_m4.mmp.in index 81ec94dbd4..fafd5e1e5f 100644 --- a/backends/platform/symbian/mmp/scummvm_m4.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_m4.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_made.mmp.in b/backends/platform/symbian/mmp/scummvm_made.mmp.in index dc24aee279..4d5ab6cc33 100644 --- a/backends/platform/symbian/mmp/scummvm_made.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_made.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_mohawk.mmp.in b/backends/platform/symbian/mmp/scummvm_mohawk.mmp.in index cb5b18ba18..3fc7c4ca5b 100644 --- a/backends/platform/symbian/mmp/scummvm_mohawk.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_mohawk.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_parallaction.mmp.in b/backends/platform/symbian/mmp/scummvm_parallaction.mmp.in index e86473e47a..05578b5994 100644 --- a/backends/platform/symbian/mmp/scummvm_parallaction.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_parallaction.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_queen.mmp.in b/backends/platform/symbian/mmp/scummvm_queen.mmp.in index b5326abe74..bfc0a2f760 100644 --- a/backends/platform/symbian/mmp/scummvm_queen.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_queen.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_saga.mmp.in b/backends/platform/symbian/mmp/scummvm_saga.mmp.in index 55d89f7868..831f02bdb6 100644 --- a/backends/platform/symbian/mmp/scummvm_saga.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_saga.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_sci.mmp.in b/backends/platform/symbian/mmp/scummvm_sci.mmp.in index dc06f44a5d..705f8d0c43 100644 --- a/backends/platform/symbian/mmp/scummvm_sci.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_sci.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_scumm.mmp.in b/backends/platform/symbian/mmp/scummvm_scumm.mmp.in index 527ce75181..6b2ad35594 100644 --- a/backends/platform/symbian/mmp/scummvm_scumm.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_scumm.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_sky.mmp.in b/backends/platform/symbian/mmp/scummvm_sky.mmp.in index eeb517ffcc..5fdfb56320 100644 --- a/backends/platform/symbian/mmp/scummvm_sky.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_sky.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_sword1.mmp.in b/backends/platform/symbian/mmp/scummvm_sword1.mmp.in index 0adc156719..075968cf98 100644 --- a/backends/platform/symbian/mmp/scummvm_sword1.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_sword1.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_sword2.mmp.in b/backends/platform/symbian/mmp/scummvm_sword2.mmp.in index c8034c3015..32ab259ee4 100644 --- a/backends/platform/symbian/mmp/scummvm_sword2.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_sword2.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_teenagent.mmp.in b/backends/platform/symbian/mmp/scummvm_teenagent.mmp.in index f065bf4376..61c50bd307 100644 --- a/backends/platform/symbian/mmp/scummvm_teenagent.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_teenagent.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_tinsel.mmp.in b/backends/platform/symbian/mmp/scummvm_tinsel.mmp.in index d61492de6b..375d948190 100644 --- a/backends/platform/symbian/mmp/scummvm_tinsel.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_tinsel.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_toon.mmp.in b/backends/platform/symbian/mmp/scummvm_toon.mmp.in index 01924614b4..d105156107 100644 --- a/backends/platform/symbian/mmp/scummvm_toon.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_toon.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_touche.mmp.in b/backends/platform/symbian/mmp/scummvm_touche.mmp.in index b9cb53b4bf..36588e051f 100644 --- a/backends/platform/symbian/mmp/scummvm_touche.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_touche.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_tsage.mmp.in b/backends/platform/symbian/mmp/scummvm_tsage.mmp.in index fa4968f704..fb9b075435 100644 --- a/backends/platform/symbian/mmp/scummvm_tsage.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_tsage.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/mmp/scummvm_tucker.mmp.in b/backends/platform/symbian/mmp/scummvm_tucker.mmp.in index 1ea564c0c0..f8954e6d21 100644 --- a/backends/platform/symbian/mmp/scummvm_tucker.mmp.in +++ b/backends/platform/symbian/mmp/scummvm_tucker.mmp.in @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/res/ScummVmAif.rss b/backends/platform/symbian/res/ScummVmAif.rss index b2addc3f21..3e7a86a3bc 100644 --- a/backends/platform/symbian/res/ScummVmAif.rss +++ b/backends/platform/symbian/res/ScummVmAif.rss @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/res/scummvm.rss b/backends/platform/symbian/res/scummvm.rss index 62da39e6a8..361f831e3c 100644 --- a/backends/platform/symbian/res/scummvm.rss +++ b/backends/platform/symbian/res/scummvm.rss @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/res/scummvm_A0000658.rss b/backends/platform/symbian/res/scummvm_A0000658.rss index 5615bbda9f..14d591c990 100644 --- a/backends/platform/symbian/res/scummvm_A0000658.rss +++ b/backends/platform/symbian/res/scummvm_A0000658.rss @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT diff --git a/backends/platform/symbian/src/ScummVm.hrh b/backends/platform/symbian/src/ScummVm.hrh index c18048c922..a84664f995 100644 --- a/backends/platform/symbian/src/ScummVm.hrh +++ b/backends/platform/symbian/src/ScummVm.hrh @@ -2,7 +2,7 @@ * Copyright (C) 2003-2005 Andreas 'Sprawl' Karlsson - Original EPOC port, ESDL * Copyright (C) 2003-2005 Lars 'AnotherGuest' Persson - Original EPOC port, Audio System * Copyright (C) 2005 Jurgen 'SumthinWicked' Braam - EPOC/CVS maintainer - * Copyright (C) 2005-2011 The ScummVM project + * Copyright (C) 2005-2012 The ScummVM project * * ScummVM is the legal property of its developers, whose names * are too numerous to list here. Please refer to the COPYRIGHT -- cgit v1.2.3 From c98a123f4c69b7e04a116dd7501bdc80afa3afcc Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 3 Jan 2012 01:25:16 +0100 Subject: VKEYBD: Some formatting fixes. --- backends/vkeybd/image-map.cpp | 8 +++--- backends/vkeybd/image-map.h | 4 +-- backends/vkeybd/polygon.cpp | 2 +- backends/vkeybd/polygon.h | 4 +-- backends/vkeybd/virtual-keyboard-gui.cpp | 39 ++++++++++++++--------------- backends/vkeybd/virtual-keyboard-gui.h | 8 +++--- backends/vkeybd/virtual-keyboard-parser.cpp | 24 +++++++++--------- backends/vkeybd/virtual-keyboard-parser.h | 27 ++++++++++---------- backends/vkeybd/virtual-keyboard.cpp | 6 ++--- backends/vkeybd/virtual-keyboard.h | 30 +++++++++++----------- 10 files changed, 76 insertions(+), 76 deletions(-) (limited to 'backends') diff --git a/backends/vkeybd/image-map.cpp b/backends/vkeybd/image-map.cpp index 275ec865ed..e3f986ee1b 100644 --- a/backends/vkeybd/image-map.cpp +++ b/backends/vkeybd/image-map.cpp @@ -35,7 +35,7 @@ ImageMap::~ImageMap() { removeAllAreas(); } -Polygon *ImageMap::createArea(const String& id) { +Polygon *ImageMap::createArea(const String &id) { if (_areas.contains(id)) { warning("Image map already contains an area with target of '%s'", id.c_str()); return 0; @@ -45,7 +45,7 @@ Polygon *ImageMap::createArea(const String& id) { return p; } -void ImageMap::removeArea(const String& id) { +void ImageMap::removeArea(const String &id) { if (!_areas.contains(id)) return; delete _areas[id]; @@ -53,7 +53,7 @@ void ImageMap::removeArea(const String& id) { } void ImageMap::removeAllAreas() { - HashMap::iterator it; + HashMap::iterator it; for (it = _areas.begin(); it != _areas.end(); ++it) { delete it->_value; } @@ -61,7 +61,7 @@ void ImageMap::removeAllAreas() { } String ImageMap::findMapArea(int16 x, int16 y) { - HashMap::iterator it; + HashMap::iterator it; for (it = _areas.begin(); it != _areas.end(); ++it) { if (it->_value->contains(x, y)) return it->_key; diff --git a/backends/vkeybd/image-map.h b/backends/vkeybd/image-map.h index 3bd8cfa0db..5132c31083 100644 --- a/backends/vkeybd/image-map.h +++ b/backends/vkeybd/image-map.h @@ -40,8 +40,8 @@ public: ~ImageMap(); - Polygon *createArea(const String& id); - void removeArea(const String& id); + Polygon *createArea(const String &id); + void removeArea(const String &id); void removeAllAreas(); String findMapArea(int16 x, int16 y); diff --git a/backends/vkeybd/polygon.cpp b/backends/vkeybd/polygon.cpp index ac42cb1d2e..08727a6fe8 100644 --- a/backends/vkeybd/polygon.cpp +++ b/backends/vkeybd/polygon.cpp @@ -42,7 +42,7 @@ bool Polygon::contains(int16 x, int16 y) const { yflag1 = (vtx1->y >= y); if (yflag0 != yflag1) { if (((vtx1->y - y) * (vtx0->x - vtx1->x) >= - (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) { + (vtx1->x - x) * (vtx0->y - vtx1->y)) == yflag1) { inside_flag = !inside_flag; } } diff --git a/backends/vkeybd/polygon.h b/backends/vkeybd/polygon.h index 19a12a0409..91c8d017b2 100644 --- a/backends/vkeybd/polygon.h +++ b/backends/vkeybd/polygon.h @@ -46,13 +46,13 @@ struct Polygon { } } - void addPoint(const Point& p) { + void addPoint(const Point &p) { _points.push_back(p); _bound.extend(Rect(p.x, p.y, p.x, p.y)); } void addPoint(int16 x, int16 y) { - addPoint(Point(x,y)); + addPoint(Point(x, y)); } uint getPointCount() { diff --git a/backends/vkeybd/virtual-keyboard-gui.cpp b/backends/vkeybd/virtual-keyboard-gui.cpp index 1c05d62316..14a508a82e 100644 --- a/backends/vkeybd/virtual-keyboard-gui.cpp +++ b/backends/vkeybd/virtual-keyboard-gui.cpp @@ -75,8 +75,8 @@ static void blit(Graphics::Surface *surf_dst, Graphics::Surface *surf_src, int16 VirtualKeyboardGUI::VirtualKeyboardGUI(VirtualKeyboard *kbd) : _kbd(kbd), _displaying(false), _drag(false), - _drawCaret(false), _displayEnabled(false), _firstRun(true), - _cursorAnimateTimer(0), _cursorAnimateCounter(0) { + _drawCaret(false), _displayEnabled(false), _firstRun(true), + _cursorAnimateTimer(0), _cursorAnimateCounter(0) { assert(_kbd); assert(g_system); @@ -111,7 +111,7 @@ void VirtualKeyboardGUI::initMode(VirtualKeyboard::Mode *mode) { } } -void VirtualKeyboardGUI::setupDisplayArea(Rect& r, OverlayColor forecolor) { +void VirtualKeyboardGUI::setupDisplayArea(Rect &r, OverlayColor forecolor) { _dispFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); if (!fontIsSuitable(_dispFont, r)) { @@ -135,9 +135,9 @@ void VirtualKeyboardGUI::setupDisplayArea(Rect& r, OverlayColor forecolor) { _displayEnabled = true; } -bool VirtualKeyboardGUI::fontIsSuitable(const Graphics::Font *font, const Rect& rect) { +bool VirtualKeyboardGUI::fontIsSuitable(const Graphics::Font *font, const Rect &rect) { return (font->getMaxCharWidth() < rect.width() && - font->getFontHeight() < rect.height()); + font->getFontHeight() < rect.height()); } void VirtualKeyboardGUI::checkScreenChanged() { @@ -161,7 +161,7 @@ void VirtualKeyboardGUI::run() { _system->clearOverlay(); } _overlayBackup.create(_screenW, _screenH, _system->getOverlayFormat()); - _system->grabOverlay((OverlayColor*)_overlayBackup.pixels, _overlayBackup.w); + _system->grabOverlay((OverlayColor *)_overlayBackup.pixels, _overlayBackup.w); setupCursor(); @@ -171,7 +171,7 @@ void VirtualKeyboardGUI::run() { removeCursor(); - _system->copyRectToOverlay((OverlayColor*)_overlayBackup.pixels, _overlayBackup.w, 0, 0, _overlayBackup.w, _overlayBackup.h); + _system->copyRectToOverlay((OverlayColor *)_overlayBackup.pixels, _overlayBackup.w, 0, 0, _overlayBackup.w, _overlayBackup.h); if (!g_gui.isActive()) _system->hideOverlay(); _overlayBackup.free(); @@ -183,16 +183,15 @@ void VirtualKeyboardGUI::close() { } void VirtualKeyboardGUI::reset() { - _kbdBound.left = _kbdBound.top - = _kbdBound.right = _kbdBound.bottom = 0; + _kbdBound.left = _kbdBound.top = 0; + _kbdBound.right = _kbdBound.bottom = 0; _displaying = _drag = false; _firstRun = true; _lastScreenChanged = _system->getScreenChangeID(); _kbdSurface = 0; } -void VirtualKeyboardGUI::moveToDefaultPosition() -{ +void VirtualKeyboardGUI::moveToDefaultPosition() { int16 kbdW = _kbdBound.width(), kbdH = _kbdBound.height(); int16 x = 0, y = 0; if (_screenW != kbdW) { @@ -263,7 +262,7 @@ void VirtualKeyboardGUI::screenChanged() { _screenH = newScreenH; _overlayBackup.create(_screenW, _screenH, _system->getOverlayFormat()); - _system->grabOverlay((OverlayColor*)_overlayBackup.pixels, _overlayBackup.w); + _system->grabOverlay((OverlayColor *)_overlayBackup.pixels, _overlayBackup.w); if (!_kbd->checkModeResolutions()) { _displaying = false; @@ -290,19 +289,19 @@ void VirtualKeyboardGUI::mainLoop() { case Common::EVENT_LBUTTONDOWN: if (_kbdBound.contains(event.mouse)) { _kbd->handleMouseDown(event.mouse.x - _kbdBound.left, - event.mouse.y - _kbdBound.top); + event.mouse.y - _kbdBound.top); } break; case Common::EVENT_LBUTTONUP: if (_kbdBound.contains(event.mouse)) { _kbd->handleMouseUp(event.mouse.x - _kbdBound.left, - event.mouse.y - _kbdBound.top); + event.mouse.y - _kbdBound.top); } break; case Common::EVENT_MOUSEMOVE: if (_drag) move(event.mouse.x - _dragPoint.x, - event.mouse.y - _dragPoint.y); + event.mouse.y - _dragPoint.y); break; case Common::EVENT_SCREEN_CHANGED: screenChanged(); @@ -367,20 +366,20 @@ void VirtualKeyboardGUI::redraw() { } blit(&surf, _kbdSurface, _kbdBound.left - _dirtyRect.left, - _kbdBound.top - _dirtyRect.top, _kbdTransparentColor); + _kbdBound.top - _dirtyRect.top, _kbdTransparentColor); if (_displayEnabled) { blit(&surf, &_dispSurface, _dispX - _dirtyRect.left, - _dispY - _dirtyRect.top, _dispBackColor); + _dispY - _dirtyRect.top, _dispBackColor); } - _system->copyRectToOverlay((OverlayColor*)surf.pixels, surf.w, - _dirtyRect.left, _dirtyRect.top, surf.w, surf.h); + _system->copyRectToOverlay((OverlayColor *)surf.pixels, surf.w, + _dirtyRect.left, _dirtyRect.top, surf.w, surf.h); surf.free(); resetDirtyRect(); } -uint VirtualKeyboardGUI::calculateEndIndex(const String& str, uint startIndex) { +uint VirtualKeyboardGUI::calculateEndIndex(const String &str, uint startIndex) { int16 w = 0; while (w <= _dispSurface.w && startIndex < str.size()) { w += _dispFont->getCharWidth(str[startIndex++]); diff --git a/backends/vkeybd/virtual-keyboard-gui.h b/backends/vkeybd/virtual-keyboard-gui.h index da80ef2223..d0f9c884ed 100644 --- a/backends/vkeybd/virtual-keyboard-gui.h +++ b/backends/vkeybd/virtual-keyboard-gui.h @@ -121,7 +121,7 @@ private: bool _displaying; bool _firstRun; - void setupDisplayArea(Rect& r, OverlayColor forecolor); + void setupDisplayArea(Rect &r, OverlayColor forecolor); void move(int16 x, int16 y); void moveToDefaultPosition(); void screenChanged(); @@ -131,8 +131,8 @@ private: void redraw(); void forceRedraw(); void updateDisplay(); - bool fontIsSuitable(const Graphics::Font *font, const Rect& rect); - uint calculateEndIndex(const String& str, uint startIndex); + bool fontIsSuitable(const Graphics::Font *font, const Rect &rect); + uint calculateEndIndex(const String &str, uint startIndex); bool _drawCaret; int16 _caretX; @@ -141,7 +141,7 @@ private: static const int kCursorAnimateDelay = 250; int _cursorAnimateCounter; - int _cursorAnimateTimer; + int _cursorAnimateTimer; byte _cursor[2048]; void setupCursor(); void removeCursor(); diff --git a/backends/vkeybd/virtual-keyboard-parser.cpp b/backends/vkeybd/virtual-keyboard-parser.cpp index 58f0c468f6..bbac503ff9 100644 --- a/backends/vkeybd/virtual-keyboard-parser.cpp +++ b/backends/vkeybd/virtual-keyboard-parser.cpp @@ -116,7 +116,7 @@ bool VirtualKeyboardParser::parserCallback_mode(ParserNode *node) { _keyboard->_initialMode = _mode; String resolutions = node->values["resolutions"]; - StringTokenizer tok (resolutions, " ,"); + StringTokenizer tok(resolutions, " ,"); // select best resolution simply by minimising the difference between the // overlay size and the resolution dimensions. @@ -189,7 +189,7 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) { } evt->type = VirtualKeyboard::kVKEventKey; - KeyState *ks = (KeyState*) malloc(sizeof(KeyState)); + KeyState *ks = (KeyState *)malloc(sizeof(KeyState)); ks->keycode = (KeyCode)atoi(node->values["code"].c_str()); ks->ascii = atoi(node->values["ascii"].c_str()); ks->flags = 0; @@ -204,7 +204,7 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) { } evt->type = VirtualKeyboard::kVKEventModifier; - byte *flags = (byte*) malloc(sizeof(byte)); + byte *flags = (byte *)malloc(sizeof(byte)); if (!flags) error("[VirtualKeyboardParser::parserCallback_event] Cannot allocate memory"); @@ -218,8 +218,8 @@ bool VirtualKeyboardParser::parserCallback_event(ParserNode *node) { } evt->type = VirtualKeyboard::kVKEventSwitchMode; - String& mode = node->values["mode"]; - char *str = (char*) malloc(sizeof(char) * mode.size() + 1); + String &mode = node->values["mode"]; + char *str = (char *)malloc(sizeof(char) * mode.size() + 1); if (!str) error("[VirtualKeyboardParser::parserCallback_event] Cannot allocate memory"); @@ -302,9 +302,9 @@ bool VirtualKeyboardParser::parserCallback_map(ParserNode *node) { } bool VirtualKeyboardParser::parserCallback_area(ParserNode *node) { - String& shape = node->values["shape"]; - String& target = node->values["target"]; - String& coords = node->values["coords"]; + String &shape = node->values["shape"]; + String &target = node->values["target"]; + String &coords = node->values["coords"]; if (target.equalsIgnoreCase("display_area")) { if (!shape.equalsIgnoreCase("rect")) @@ -321,7 +321,7 @@ bool VirtualKeyboardParser::parserCallback_area(ParserNode *node) { return parserError("Area shape '" + shape + "' not known"); } -byte VirtualKeyboardParser::parseFlags(const String& flags) { +byte VirtualKeyboardParser::parseFlags(const String &flags) { if (flags.empty()) return 0; @@ -338,7 +338,7 @@ byte VirtualKeyboardParser::parseFlags(const String& flags) { return val; } -bool VirtualKeyboardParser::parseRect(Rect &rect, const String& coords) { +bool VirtualKeyboardParser::parseRect(Rect &rect, const String &coords) { int x1, y1, x2, y2; if (!parseIntegerKey(coords, 4, &x1, &y1, &x2, &y2)) return parserError("Invalid coords for rect area"); @@ -351,7 +351,7 @@ bool VirtualKeyboardParser::parseRect(Rect &rect, const String& coords) { return true; } -bool VirtualKeyboardParser::parsePolygon(Polygon &poly, const String& coords) { +bool VirtualKeyboardParser::parsePolygon(Polygon &poly, const String &coords) { StringTokenizer tok(coords, ", "); for (String st = tok.nextToken(); !st.empty(); st = tok.nextToken()) { int x, y; @@ -368,7 +368,7 @@ bool VirtualKeyboardParser::parsePolygon(Polygon &poly, const String& coords) { return true; } -bool VirtualKeyboardParser::parseRectAsPolygon(Polygon &poly, const String& coords) { +bool VirtualKeyboardParser::parseRectAsPolygon(Polygon &poly, const String &coords) { Rect rect; if (!parseRect(rect, coords)) return false; diff --git a/backends/vkeybd/virtual-keyboard-parser.h b/backends/vkeybd/virtual-keyboard-parser.h index eb25ebe6fd..c8a2c4158e 100644 --- a/backends/vkeybd/virtual-keyboard-parser.h +++ b/backends/vkeybd/virtual-keyboard-parser.h @@ -56,31 +56,31 @@ keyboard layouts for different screen resolutions. - ... + ... - - - ... - + + + ... + - ... - + ... + - ... + ... - ... + ... @@ -188,6 +188,7 @@ public: * Full parse - when loading keyboard pack for first time */ kParseFull, + /** * Just check resolutions and reload layouts if needed - following a * change in screen size @@ -257,10 +258,10 @@ protected: virtual bool closedKeyCallback(ParserNode *node); /** Parse helper functions */ - byte parseFlags(const String& flags); - bool parseRect(Rect &rect, const String& coords); - bool parsePolygon(Polygon &poly, const String& coords); - bool parseRectAsPolygon(Polygon &poly, const String& coords); + byte parseFlags(const String &flags); + bool parseRect(Rect &rect, const String &coords); + bool parsePolygon(Polygon &poly, const String &coords); + bool parseRectAsPolygon(Polygon &poly, const String &coords); }; } // End of namespace GUI diff --git a/backends/vkeybd/virtual-keyboard.cpp b/backends/vkeybd/virtual-keyboard.cpp index 1dada06951..7d47b709a7 100644 --- a/backends/vkeybd/virtual-keyboard.cpp +++ b/backends/vkeybd/virtual-keyboard.cpp @@ -160,7 +160,7 @@ String VirtualKeyboard::findArea(int16 x, int16 y) { return _currentMode->imageMap.findMapArea(x, y); } -void VirtualKeyboard::processAreaClick(const String& area) { +void VirtualKeyboard::processAreaClick(const String &area) { if (!_currentMode->events.contains(area)) return; @@ -169,10 +169,10 @@ void VirtualKeyboard::processAreaClick(const String& area) { switch (evt->type) { case kVKEventKey: // add virtual keypress to queue - _keyQueue.insertKey(*(KeyState*)evt->data); + _keyQueue.insertKey(*(KeyState *)evt->data); break; case kVKEventModifier: - _keyQueue.toggleFlags(*(byte*)(evt->data)); + _keyQueue.toggleFlags(*(byte *)(evt->data)); break; case kVKEventSwitchMode: // switch to new mode diff --git a/backends/vkeybd/virtual-keyboard.h b/backends/vkeybd/virtual-keyboard.h index 21db5a47da..21f149ae57 100644 --- a/backends/vkeybd/virtual-keyboard.h +++ b/backends/vkeybd/virtual-keyboard.h @@ -102,21 +102,21 @@ protected: } }; - typedef HashMap VKEventMap; + typedef HashMap VKEventMap; /** * Mode struct encapsulates all the data for each mode of the keyboard */ struct Mode { - String name; - String resolution; - String bitmapName; - Graphics::Surface *image; - OverlayColor transparentColor; - ImageMap imageMap; - VKEventMap events; - Rect displayArea; - OverlayColor displayFontColor; + String name; + String resolution; + String bitmapName; + Graphics::Surface *image; + OverlayColor transparentColor; + ImageMap imageMap; + VKEventMap events; + Rect displayArea; + OverlayColor displayFontColor; Mode() : image(0) {} ~Mode() { @@ -193,7 +193,7 @@ public: * The system first looks for an uncompressed keyboard pack by searching * for packName.xml in the filesystem, if this does not exist then it * searches for a compressed keyboard pack by looking for packName.zip. - * @param packName name of the keyboard pack + * @param packName name of the keyboard pack */ bool loadKeyboardPack(const String &packName); @@ -206,8 +206,8 @@ public: /** * Hides the keyboard, ending the event loop. - * @param submit if true all accumulated key presses are submitted to - * the event manager + * @param submit if true all accumulated key presses are submitted to + * the event manager */ void close(bool submit); @@ -229,7 +229,7 @@ protected: Archive *_fileArchive; friend class VirtualKeyboardGUI; - VirtualKeyboardGUI *_kbdGUI; + VirtualKeyboardGUI *_kbdGUI; KeyPressQueue _keyQueue; @@ -241,7 +241,7 @@ protected: void deleteEvents(); bool checkModeResolutions(); void switchMode(Mode *newMode); - void switchMode(const String& newMode); + void switchMode(const String &newMode); void handleMouseDown(int16 x, int16 y); void handleMouseUp(int16 x, int16 y); String findArea(int16 x, int16 y); -- cgit v1.2.3 From d0ddd299a4f19463749922859d2b5e9e5123b15f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 3 Jan 2012 01:47:31 +0100 Subject: VKEYBD: Slight cleanup in ImageMap code. --- backends/vkeybd/image-map.cpp | 7 +++---- backends/vkeybd/image-map.h | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'backends') diff --git a/backends/vkeybd/image-map.cpp b/backends/vkeybd/image-map.cpp index e3f986ee1b..359fc58d20 100644 --- a/backends/vkeybd/image-map.cpp +++ b/backends/vkeybd/image-map.cpp @@ -53,19 +53,18 @@ void ImageMap::removeArea(const String &id) { } void ImageMap::removeAllAreas() { - HashMap::iterator it; - for (it = _areas.begin(); it != _areas.end(); ++it) { + for (AreaMap::iterator it = _areas.begin(); it != _areas.end(); ++it) { delete it->_value; } _areas.clear(); } String ImageMap::findMapArea(int16 x, int16 y) { - HashMap::iterator it; - for (it = _areas.begin(); it != _areas.end(); ++it) { + for (AreaMap::iterator it = _areas.begin(); it != _areas.end(); ++it) { if (it->_value->contains(x, y)) return it->_key; } + return String(); } diff --git a/backends/vkeybd/image-map.h b/backends/vkeybd/image-map.h index 5132c31083..952ba624b0 100644 --- a/backends/vkeybd/image-map.h +++ b/backends/vkeybd/image-map.h @@ -35,9 +35,7 @@ namespace Common { struct Polygon; class ImageMap { - public: - ~ImageMap(); Polygon *createArea(const String &id); @@ -46,7 +44,8 @@ public: String findMapArea(int16 x, int16 y); protected: - HashMap _areas; + typedef HashMap AreaMap; + AreaMap _areas; }; -- cgit v1.2.3 From 24d99038e44cb8ab7bf15dc3517a3deeecac0568 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 3 Jan 2012 01:49:45 +0100 Subject: VKEYBD: Properly error out parsing if an area is defined again. Formerly the code did never check whether ImageMap::createArea returned a valid pointer and always just assumed so. --- backends/vkeybd/virtual-keyboard-parser.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/vkeybd/virtual-keyboard-parser.cpp b/backends/vkeybd/virtual-keyboard-parser.cpp index bbac503ff9..1958113578 100644 --- a/backends/vkeybd/virtual-keyboard-parser.cpp +++ b/backends/vkeybd/virtual-keyboard-parser.cpp @@ -313,10 +313,16 @@ bool VirtualKeyboardParser::parserCallback_area(ParserNode *node) { return parseRect(_mode->displayArea, coords); } else if (shape.equalsIgnoreCase("rect")) { Polygon *poly = _mode->imageMap.createArea(target); - return parseRectAsPolygon(*poly, coords); + if (!poly) + return parserError(Common::String::format("Cannot define area '%s' again", target.c_str())); + else + return parseRectAsPolygon(*poly, coords); } else if (shape.equalsIgnoreCase("poly")) { Polygon *poly = _mode->imageMap.createArea(target); - return parsePolygon(*poly, coords); + if (!poly) + return parserError(Common::String::format("Cannot define area '%s' again", target.c_str())); + else + return parsePolygon(*poly, coords); } return parserError("Area shape '" + shape + "' not known"); } -- cgit v1.2.3 From 1c2a21c42b9485000fd3a27c06f88d3eb1b38abc Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 3 Jan 2012 01:56:43 +0100 Subject: VKEYBD: Slight cleanup. --- backends/vkeybd/virtual-keyboard.cpp | 10 ++++------ backends/vkeybd/virtual-keyboard.h | 6 +++--- 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'backends') diff --git a/backends/vkeybd/virtual-keyboard.cpp b/backends/vkeybd/virtual-keyboard.cpp index 7d47b709a7..678c751410 100644 --- a/backends/vkeybd/virtual-keyboard.cpp +++ b/backends/vkeybd/virtual-keyboard.cpp @@ -56,11 +56,9 @@ VirtualKeyboard::~VirtualKeyboard() { } void VirtualKeyboard::deleteEvents() { - ModeMap::iterator it_m; - VKEventMap::iterator it_e; - for (it_m = _modes.begin(); it_m != _modes.end(); ++it_m) { - VKEventMap *evt = &(it_m->_value.events); - for (it_e = evt->begin(); it_e != evt->end(); ++it_e) + for (ModeMap::iterator it_m = _modes.begin(); it_m != _modes.end(); ++it_m) { + VKEventMap &evt = it_m->_value.events; + for (VKEventMap::iterator it_e = evt.begin(); it_e != evt.end(); ++it_e) delete it_e->_value; } } @@ -332,7 +330,7 @@ void VirtualKeyboard::KeyPressQueue::insertKey(KeyState key) { void VirtualKeyboard::KeyPressQueue::deleteKey() { if (_keyPos == _keys.begin()) return; - List::iterator it = _keyPos; + KeyPressList::iterator it = _keyPos; it--; _strPos -= it->strLen; while ((it->strLen)-- > 0) diff --git a/backends/vkeybd/virtual-keyboard.h b/backends/vkeybd/virtual-keyboard.h index 21f149ae57..4ab5ad446d 100644 --- a/backends/vkeybd/virtual-keyboard.h +++ b/backends/vkeybd/virtual-keyboard.h @@ -172,13 +172,13 @@ protected: byte _flags; String _flagsStr; - - List _keys; + typedef List KeyPressList; + KeyPressList _keys; String _keysStr; bool _strChanged; - List::iterator _keyPos; + KeyPressList::iterator _keyPos; uint _strPos; }; -- cgit v1.2.3 From 2af87fd4f02cff9f1d6b7140a8244c7c0b3ddd5a Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 3 Jan 2012 02:05:03 +0100 Subject: VKEYBD: Fix cursor palette. --- backends/vkeybd/virtual-keyboard-gui.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'backends') diff --git a/backends/vkeybd/virtual-keyboard-gui.cpp b/backends/vkeybd/virtual-keyboard-gui.cpp index 14a508a82e..42f9707ddc 100644 --- a/backends/vkeybd/virtual-keyboard-gui.cpp +++ b/backends/vkeybd/virtual-keyboard-gui.cpp @@ -435,10 +435,10 @@ void VirtualKeyboardGUI::updateDisplay() { void VirtualKeyboardGUI::setupCursor() { const byte palette[] = { - 255, 255, 255, 0, - 255, 255, 255, 0, - 171, 171, 171, 0, - 87, 87, 87, 0 + 255, 255, 255, + 255, 255, 255, + 171, 171, 171, + 87, 87, 87 }; CursorMan.pushCursorPalette(palette, 0, 4); -- cgit v1.2.3 From 90178d9b8755b5752305dddcdd6d40b622c813d8 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 3 Jan 2012 04:17:48 +0100 Subject: OPENGL: Fix mouse cursor scaling. --- backends/graphics/opengl/opengl-graphics.cpp | 76 ++++++++++++++++------------ 1 file changed, 44 insertions(+), 32 deletions(-) (limited to 'backends') diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index 5b1f7b4b28..edc7a5f28e 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -838,38 +838,50 @@ void OpenGLGraphicsManager::refreshCursor() { } void OpenGLGraphicsManager::refreshCursorScale() { - // Get the window minimum scale factor. The cursor will mantain its original aspect - // ratio, and we do not want it to get too big if only one dimension is resized - uint screenScaleFactor = MIN(_videoMode.hardwareWidth * 10000 / _videoMode.screenWidth, - _videoMode.hardwareHeight * 10000 / _videoMode.screenHeight); - - // Do not scale cursor if original size is used - if (_videoMode.mode == OpenGL::GFX_ORIGINAL) - screenScaleFactor = _videoMode.scaleFactor * 10000; - - if ((uint)_cursorTargetScale * 10000 >= screenScaleFactor && (uint)_videoMode.scaleFactor * 10000 >= screenScaleFactor) { - // If the cursor target scale and the video mode scale factor are bigger than - // the current window scale, do not scale the cursor for the overlay - _cursorState.rW = _cursorState.w; - _cursorState.rH = _cursorState.h; - _cursorState.rHotX = _cursorState.hotX; - _cursorState.rHotY = _cursorState.hotY; - } else { - // Otherwise, scale the cursor for the overlay - int targetScaleFactor = MIN(_cursorTargetScale, _videoMode.scaleFactor); - // We limit the maximum scale to 3 here to avoid too big cursors, for large overlay resolutions - int actualFactor = MIN(3, screenScaleFactor - (targetScaleFactor - 1)) * 10000; - _cursorState.rW = (int16)(_cursorState.w * actualFactor / 10000); - _cursorState.rH = (int16)(_cursorState.h * actualFactor / 10000); - _cursorState.rHotX = (int16)(_cursorState.hotX * actualFactor / 10000); - _cursorState.rHotY = (int16)(_cursorState.hotY * actualFactor / 10000); - } - - // Always scale the cursor for the game - _cursorState.vW = (int16)(_cursorState.w * screenScaleFactor / 10000); - _cursorState.vH = (int16)(_cursorState.h * screenScaleFactor / 10000); - _cursorState.vHotX = (int16)(_cursorState.hotX * screenScaleFactor / 10000); - _cursorState.vHotY = (int16)(_cursorState.hotY * screenScaleFactor / 10000); + // Calculate the scale factors of the screen. We limit ourselves to 3 at + // most here to avoid really big (and ugly) cursors for big resolutions. + // It might be noteworthy that 3 is the (current) target scale for the + // modern theme and thus assures the cursor is *never* scaled. + // We also totally ignore the aspect of the overlay cursor, since aspect + // ratio correction only applies to the game screen. + uint screenScaleFactorX = MIN(30000, _videoMode.hardwareWidth * 10000 / _videoMode.screenWidth); + uint screenScaleFactorY = MIN(30000, _videoMode.hardwareHeight * 10000 / _videoMode.screenHeight); + + // Apply the target scale factor to the cursor. + // It might be noteworthy we only apply any scaling to the cursor in case + // the current scale factor is bigger than the target scale to match + // SurfaceSdlGraphicsManager's behavior. Otherwise we would downscale the + // GUI cursor of the modern theme for example. + if (screenScaleFactorX > uint(_cursorTargetScale * 10000)) + screenScaleFactorX /= _cursorTargetScale; + else + screenScaleFactorX = 10000; + if (screenScaleFactorY > uint(_cursorTargetScale * 10000)) + screenScaleFactorY /= _cursorTargetScale; + else + screenScaleFactorY = 10000; + + // Apply them (without any possible) aspect ratio correction to the + // overlay. + _cursorState.rW = (int16)(_cursorState.w * screenScaleFactorX / 10000); + _cursorState.rH = (int16)(_cursorState.h * screenScaleFactorY / 10000); + _cursorState.rHotX = (int16)(_cursorState.hotX * screenScaleFactorX / 10000); + _cursorState.rHotY = (int16)(_cursorState.hotY * screenScaleFactorY / 10000); + + // Make sure we properly scale the cursor according to the desired aspect. + // It might be noteworthy that, unlike with the overlay, we do not limit + // the scale factor here to avoid odd looks if the game uses items as + // mouse cursor, which would otherwise suddenly be smaller. + int width, height; + calculateDisplaySize(width, height); + screenScaleFactorX = (width * 10000 / _videoMode.screenWidth) / _cursorTargetScale; + screenScaleFactorY = (height * 10000 / _videoMode.screenHeight) / _cursorTargetScale; + + // Always scale the cursor for the game. + _cursorState.vW = (int16)(_cursorState.w * screenScaleFactorX / 10000); + _cursorState.vH = (int16)(_cursorState.h * screenScaleFactorY / 10000); + _cursorState.vHotX = (int16)(_cursorState.hotX * screenScaleFactorX / 10000); + _cursorState.vHotY = (int16)(_cursorState.hotY * screenScaleFactorY / 10000); } void OpenGLGraphicsManager::calculateDisplaySize(int &width, int &height) { -- cgit v1.2.3 From 82e0900678ab755256e141e15dd58a99090388f1 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Sat, 7 Jan 2012 21:10:05 -0600 Subject: KEYMAPPER: Rename inherit flag to transparent Less confusing --- backends/keymapper/keymapper.cpp | 10 +++++----- backends/keymapper/keymapper.h | 14 +++++++------- backends/keymapper/remap-dialog.cpp | 4 ++-- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index 025e917273..f950b1f4a2 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -143,7 +143,7 @@ Keymap *Keymapper::getKeymap(const String& name, bool *globalReturn) { return keymap; } -bool Keymapper::pushKeymap(const String& name, bool inherit) { +bool Keymapper::pushKeymap(const String& name, bool transparent) { bool global; Keymap *newMap = getKeymap(name, &global); @@ -152,13 +152,13 @@ bool Keymapper::pushKeymap(const String& name, bool inherit) { return false; } - pushKeymap(newMap, inherit, global); + pushKeymap(newMap, transparent, global); return true; } -void Keymapper::pushKeymap(Keymap *newMap, bool inherit, bool global) { - MapRecord mr = {newMap, inherit, global}; +void Keymapper::pushKeymap(Keymap *newMap, bool transparent, bool global) { + MapRecord mr = {newMap, transparent, global}; _activeMaps.push(mr); } @@ -198,7 +198,7 @@ bool Keymapper::mapKey(const KeyState& key, bool keyDown) { debug(5, "Keymapper::mapKey keymap: %s", mr.keymap->getName().c_str()); action = mr.keymap->getMappedAction(key); - if (action || !mr.inherit) + if (action || !mr.transparent) break; } diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index d38109f210..90d9581d91 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -43,7 +43,7 @@ public: struct MapRecord { Keymap* keymap; - bool inherit; + bool transparent; bool global; }; @@ -121,12 +121,12 @@ public: /** * Push a new keymap to the top of the active stack, activating * it for use. - * @param name name of the keymap to push - * @param inherit if true keymapper will iterate down the - * stack if it cannot find a key in the new map - * @return true if succesful + * @param name name of the keymap to push + * @param transparent if true keymapper will iterate down the + * stack if it cannot find a key in the new map + * @return true if succesful */ - bool pushKeymap(const String& name, bool inherit = false); + bool pushKeymap(const String& name, bool transparent = false); /** * Pop the top keymap off the active stack. @@ -182,7 +182,7 @@ private: HardwareKeySet *_hardwareKeys; - void pushKeymap(Keymap *newMap, bool inherit, bool global); + void pushKeymap(Keymap *newMap, bool transparent, bool global); Action *getAction(const KeyState& key); void executeAction(const Action *act, bool keyDown); diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index c0654fc0ea..5c339f8c27 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -327,7 +327,7 @@ void RemapDialog::loadKeymap() { } // loop through remaining finding mappings for unmapped keys - if (top.inherit && topIndex >= 0) { + if (top.transparent && topIndex >= 0) { for (int i = topIndex - 1; i >= 0; --i) { Keymapper::MapRecord mr = activeKeymaps[i]; debug(3, "RemapDialog::loadKeymap keymap: %s", mr.keymap->getName().c_str()); @@ -345,7 +345,7 @@ void RemapDialog::loadKeymap() { } } - if (mr.inherit == false || freeKeys.empty()) + if (mr.transparent == false || freeKeys.empty()) break; } } -- cgit v1.2.3 From d143872be605b881eaec63b0168c9d4d551787ee Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Sat, 7 Jan 2012 21:20:29 -0600 Subject: KEYMAPPER: Constantify global keymap name --- backends/keymapper/keymapper.h | 1 + backends/platform/android/events.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index 90d9581d91..cd060a413c 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -37,6 +37,7 @@ namespace Common { const char *const kGuiKeymapName = "gui"; +const char *const kGlobalKeymapName = "global"; class Keymapper : public Common::EventMapper, private Common::ArtificialEventSource { public: diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp index 2a16e69411..e73e689e3b 100644 --- a/backends/platform/android/events.cpp +++ b/backends/platform/android/events.cpp @@ -231,7 +231,7 @@ void OSystem_Android::setupKeymapper() { mapper->registerHardwareKeySet(keySet); - Keymap *globalMap = new Keymap("global"); + Keymap *globalMap = new Keymap(kGlobalKeymapName); Action *act; act = new Action(globalMap, "VIRT", "Display keyboard", @@ -240,7 +240,7 @@ void OSystem_Android::setupKeymapper() { mapper->addGlobalKeymap(globalMap); - mapper->pushKeymap("global"); + mapper->pushKeymap(kGlobalKeymapName); #endif } -- cgit v1.2.3 From 37d77253cfd5cc1c7bef635d4d5bd05eb53ac02c Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Sat, 7 Jan 2012 22:07:16 -0600 Subject: KEYMAPPER: Add failsafe code for popping into Keymapper itself Thanks LordHoto --- backends/keymapper/keymapper.cpp | 16 +++++++++++++--- backends/keymapper/keymapper.h | 5 ++++- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index f950b1f4a2..38711343c2 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -163,9 +163,19 @@ void Keymapper::pushKeymap(Keymap *newMap, bool transparent, bool global) { _activeMaps.push(mr); } -void Keymapper::popKeymap() { - if (!_activeMaps.empty()) - _activeMaps.pop(); +void Keymapper::popKeymap(const char *name) { + if (!_activeMaps.empty()) { + if (name) { + String topKeymapName = _activeMaps.top().keymap->getName(); + if (topKeymapName.equals(name)) + _activeMaps.pop(); + else + warning("An attempt to pop wrong keymap was blocked (expected %s but was %s)", name, topKeymapName.c_str()); + } else { + _activeMaps.pop(); + } + } + } bool Keymapper::notifyEvent(const Common::Event &ev) { diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index cd060a413c..d2aa89cad6 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -131,8 +131,11 @@ public: /** * Pop the top keymap off the active stack. + * @param name (optional) name of keymap expected to be popped + * if provided, will not pop unless name is the same + * as the top keymap */ - void popKeymap(); + void popKeymap(const char *name = 0); // Implementation of the EventMapper interface bool notifyEvent(const Common::Event &ev); -- cgit v1.2.3 From 09ce3407b12bc532fed47c80f1c9f883c86e9530 Mon Sep 17 00:00:00 2001 From: Oystein Eftevaag Date: Sat, 14 Jan 2012 10:44:11 -0500 Subject: OSX: Avoid use of NSString:stringWithCString, for OS X 10.2 and 10.3 compatibility --- backends/platform/sdl/macosx/appmenu_osx.mm | 44 ++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 10 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/macosx/appmenu_osx.mm b/backends/platform/sdl/macosx/appmenu_osx.mm index bb089a6b61..97c7edba3e 100755 --- a/backends/platform/sdl/macosx/appmenu_osx.mm +++ b/backends/platform/sdl/macosx/appmenu_osx.mm @@ -35,6 +35,11 @@ - (void)setAppleMenu:(NSMenu *)menu; @end +NSString *constructNSStringFromCString(const char* rawCString, NSStringEncoding stringEncoding) { + NSData *nsData = [NSData dataWithBytes:rawCString length:strlen(rawCString)]; + return [[NSString alloc] initWithData:nsData encoding:stringEncoding]; +} + void replaceApplicationMenuItems() { // Code mainly copied and adapted from SDLmain.m @@ -50,34 +55,47 @@ void replaceApplicationMenuItems() { // Create new application menu appleMenu = [[NSMenu alloc] initWithTitle:@""]; + NSString *nsString = NULL; + // Get current encoding #ifdef USE_TRANSLATION - NSStringEncoding stringEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)[NSString stringWithCString:(TransMan.getCurrentCharset()).c_str() encoding:NSASCIIStringEncoding])); + nsString = constructNSStringFromCString((TransMan.getCurrentCharset()).c_str(), NSASCIIStringEncoding); + NSStringEncoding stringEncoding = CFStringConvertEncodingToNSStringEncoding(CFStringConvertIANACharSetNameToEncoding((CFStringRef)nsString)); + [nsString release]; #else NSStringEncoding stringEncoding = NSASCIIStringEncoding; #endif - + // Add "About ScummVM" menu item - [appleMenu addItemWithTitle:[NSString stringWithCString:_("About ScummVM") encoding:stringEncoding] action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; + nsString = constructNSStringFromCString(_("About ScummVM"), stringEncoding); + [appleMenu addItemWithTitle:nsString action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; + [nsString release]; // Add separator [appleMenu addItem:[NSMenuItem separatorItem]]; // Add "Hide ScummVM" menu item - [appleMenu addItemWithTitle:[NSString stringWithCString:_("Hide ScummVM") encoding:stringEncoding] action:@selector(hide:) keyEquivalent:@"h"]; + nsString = constructNSStringFromCString(_("Hide ScummVM"), stringEncoding); + [appleMenu addItemWithTitle:nsString action:@selector(hide:) keyEquivalent:@"h"]; + [nsString release]; // Add "Hide Others" menu item - menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:[NSString stringWithCString:_("Hide Others") encoding:stringEncoding] action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; + nsString = constructNSStringFromCString(_("Hide Others"), stringEncoding); + menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:nsString action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask|NSCommandKeyMask)]; // Add "Show All" menu item - [appleMenu addItemWithTitle:[NSString stringWithCString:_("Show All") encoding:stringEncoding] action:@selector(unhideAllApplications:) keyEquivalent:@""]; + nsString = constructNSStringFromCString(_("Show All"), stringEncoding); + [appleMenu addItemWithTitle:nsString action:@selector(unhideAllApplications:) keyEquivalent:@""]; + [nsString release]; // Add separator [appleMenu addItem:[NSMenuItem separatorItem]]; // Add "Quit ScummVM" menu item - [appleMenu addItemWithTitle:[NSString stringWithCString:_("Quit ScummVM") encoding:stringEncoding] action:@selector(terminate:) keyEquivalent:@"q"]; + nsString = constructNSStringFromCString(_("Quit ScummVM"), stringEncoding); + [appleMenu addItemWithTitle:nsString action:@selector(terminate:) keyEquivalent:@"q"]; + [nsString release]; // Put application menu into the menubar menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; @@ -89,16 +107,22 @@ void replaceApplicationMenuItems() { // Create new "Window" menu - windowMenu = [[NSMenu alloc] initWithTitle:[NSString stringWithCString:_("Window") encoding:stringEncoding]]; + nsString = constructNSStringFromCString(_("Window"), stringEncoding); + windowMenu = [[NSMenu alloc] initWithTitle:nsString]; + [nsString release]; // Add "Minimize" menu item - menuItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithCString:_("Minimize") encoding:stringEncoding] action:@selector(performMiniaturize:) keyEquivalent:@"m"]; + nsString = constructNSStringFromCString(_("Minimize"), stringEncoding); + menuItem = [[NSMenuItem alloc] initWithTitle:nsString action:@selector(performMiniaturize:) keyEquivalent:@"m"]; [windowMenu addItem:menuItem]; + [nsString release]; // Put menu into the menubar - menuItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithCString:_("Window") encoding:stringEncoding] action:nil keyEquivalent:@""]; + nsString = constructNSStringFromCString(_("Window"), stringEncoding); + menuItem = [[NSMenuItem alloc] initWithTitle:nsString action:nil keyEquivalent:@""]; [menuItem setSubmenu:windowMenu]; [[NSApp mainMenu] addItem:menuItem]; + [nsString release]; // Tell the application object that this is now the window menu. [NSApp setWindowsMenu:windowMenu]; -- cgit v1.2.3 From ad1c2a45f12bb5401ae5c0d73ef948dea734c467 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 28 Dec 2011 23:13:39 +0100 Subject: MACOSX: Default to new CoreAudio API on x86, and to old on PowerPC The new API has been present since Mac OS X 10.5 (released four years ago, in October 2007), and also since iOS 2.0 (thus, the iOS port may be able to use it, too). Moreover, 10.5 was the last system to support PowerPC. --- backends/midi/coreaudio.cpp | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'backends') diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp index 4b707eace6..0c251a2d8d 100644 --- a/backends/midi/coreaudio.cpp +++ b/backends/midi/coreaudio.cpp @@ -27,22 +27,36 @@ #ifdef MACOSX -// HACK to disable deprecated warnings under Mac OS X 10.5. Apple deprecated the +// With the release of Mac OS X 10.5 in October 2007, Apple deprecated the // AUGraphNewNode & AUGraphGetNodeInfo APIs in favor of the new AUGraphAddNode & // AUGraphNodeInfo APIs. While it is easy to switch to those, it breaks // compatibility with all pre-10.5 systems. -// If you want to retain compatibility with old systems, enable the following -// switch. But Apple will eventually remove these APIs, at which point the -// switch needs to be disabled. // -// Also note that only the new API is available on the iPhone! -#define USE_DEPRECATED_COREAUDIO_API - +// Since 10.5 was the last system to support PowerPC, we use the old, deprecated +// APIs on PowerPC based systems by default. On all other systems (such as Mac +// OS X running on Intel hardware, or iOS running on ARM), we use the new API by +// default. +// +// This leaves Mac OS X 10.4 running on x86 processors as the only system +// combination that this code will not support by default. It seems quite +// reasonable to assume that anybody with an Intel system has since then moved +// on to a newer Mac OS X release. But if for some reason you absolutely need to +// build an x86 version of this code using the old, deprecated API, you can +// simply do so by manually enable the USE_DEPRECATED_COREAUDIO_API switch (e.g. +// by adding setting it suitably in CPPFLAGS). +#if !defined(USE_DEPRECATED_COREAUDIO_API) + #if TARGET_CPU_PPC || TARGET_CPU_PPC64 + #define USE_DEPRECATED_COREAUDIO_API 1 + #else + #define USE_DEPRECATED_COREAUDIO_API 0 + #endif +#endif -#ifdef USE_DEPRECATED_COREAUDIO_API -#include -#undef DEPRECATED_ATTRIBUTE -#define DEPRECATED_ATTRIBUTE +#if USE_DEPRECATED_COREAUDIO_API + #include + // Try to silence warnings about use of deprecated APIs + #undef DEPRECATED_ATTRIBUTE + #define DEPRECATED_ATTRIBUTE #endif @@ -114,7 +128,7 @@ int MidiDriver_CORE::open() { RequireNoErr(NewAUGraph(&_auGraph)); AUNode outputNode, synthNode; -#ifdef USE_DEPRECATED_COREAUDIO_API +#if USE_DEPRECATED_COREAUDIO_API ComponentDescription desc; #else AudioComponentDescription desc; @@ -126,7 +140,7 @@ int MidiDriver_CORE::open() { desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; -#ifdef USE_DEPRECATED_COREAUDIO_API +#if USE_DEPRECATED_COREAUDIO_API RequireNoErr(AUGraphNewNode(_auGraph, &desc, 0, NULL, &outputNode)); #else RequireNoErr(AUGraphAddNode(_auGraph, &desc, &outputNode)); @@ -136,7 +150,7 @@ int MidiDriver_CORE::open() { desc.componentType = kAudioUnitType_MusicDevice; desc.componentSubType = kAudioUnitSubType_DLSSynth; desc.componentManufacturer = kAudioUnitManufacturer_Apple; -#ifdef USE_DEPRECATED_COREAUDIO_API +#if USE_DEPRECATED_COREAUDIO_API RequireNoErr(AUGraphNewNode(_auGraph, &desc, 0, NULL, &synthNode)); #else RequireNoErr(AUGraphAddNode(_auGraph, &desc, &synthNode)); @@ -150,7 +164,7 @@ int MidiDriver_CORE::open() { RequireNoErr(AUGraphInitialize(_auGraph)); // Get the music device from the graph. -#ifdef USE_DEPRECATED_COREAUDIO_API +#if USE_DEPRECATED_COREAUDIO_API RequireNoErr(AUGraphGetNodeInfo(_auGraph, synthNode, NULL, NULL, NULL, &_synth)); #else RequireNoErr(AUGraphNodeInfo(_auGraph, synthNode, NULL, &_synth)); -- cgit v1.2.3 From ba1396954d64306578f4459f2aa418b6055c1dd2 Mon Sep 17 00:00:00 2001 From: Oystein Eftevaag Date: Sat, 14 Jan 2012 12:12:10 -0500 Subject: MACOSX: Changed CoreAudio deprecation check slightly to allow building with older SDKs --- backends/midi/coreaudio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp index 0c251a2d8d..6a4a9fa909 100644 --- a/backends/midi/coreaudio.cpp +++ b/backends/midi/coreaudio.cpp @@ -45,7 +45,7 @@ // simply do so by manually enable the USE_DEPRECATED_COREAUDIO_API switch (e.g. // by adding setting it suitably in CPPFLAGS). #if !defined(USE_DEPRECATED_COREAUDIO_API) - #if TARGET_CPU_PPC || TARGET_CPU_PPC64 + #if TARGET_CPU_PPC || TARGET_CPU_PPC64 || !defined(MAC_OS_X_VERSION_10_6) #define USE_DEPRECATED_COREAUDIO_API 1 #else #define USE_DEPRECATED_COREAUDIO_API 0 -- cgit v1.2.3 From 78baa27e0ef9abee006327323172a2a009690e44 Mon Sep 17 00:00:00 2001 From: Oystein Eftevaag Date: Tue, 17 Jan 2012 15:19:54 -0500 Subject: MACOSX: Moved an include a bit to make sure that some defines are there before they are actually used. --- backends/midi/coreaudio.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp index 6a4a9fa909..43c801287d 100644 --- a/backends/midi/coreaudio.cpp +++ b/backends/midi/coreaudio.cpp @@ -26,6 +26,7 @@ #ifdef MACOSX +#include // With the release of Mac OS X 10.5 in October 2007, Apple deprecated the // AUGraphNewNode & AUGraphGetNodeInfo APIs in favor of the new AUGraphAddNode & @@ -53,7 +54,6 @@ #endif #if USE_DEPRECATED_COREAUDIO_API - #include // Try to silence warnings about use of deprecated APIs #undef DEPRECATED_ATTRIBUTE #define DEPRECATED_ATTRIBUTE -- cgit v1.2.3 From cc98a1acea9998d788992d458738cc1e2dac9d4d Mon Sep 17 00:00:00 2001 From: dhewg Date: Sat, 21 Jan 2012 18:47:36 +0100 Subject: WEBOS: Fix whitespace error Random whitespace fix to kick off the OpenPandora toolchain on buildbot. --- backends/events/webossdl/webossdl-events.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/events/webossdl/webossdl-events.cpp b/backends/events/webossdl/webossdl-events.cpp index d01e51fafe..996ac48b15 100644 --- a/backends/events/webossdl/webossdl-events.cpp +++ b/backends/events/webossdl/webossdl-events.cpp @@ -376,7 +376,7 @@ bool WebOSSdlEventSource::pollEvent(Common::Event &event) { if (_firstPoll) { // Set the initial dimensions calculateDimensions(); - + // Having a mouse pointer on screen when not in Touchpad mode is poor // interface design, because the user won't know whether to tap buttons // or drag the pointer to them. On the first poll, set the appropriate -- cgit v1.2.3 From b429096b36cf44f773f01b371c0ff5a60ed61c95 Mon Sep 17 00:00:00 2001 From: David-John Willis Date: Sun, 22 Jan 2012 16:36:52 +0000 Subject: OPENPANDORA: Move all dist files into own folder under dists. * Update OpenPandora bundle targets to suit new layout. * Also add .in input files so we can automatically update version numbers. --- backends/platform/openpandora/build/PXML.xml | 55 ---- .../platform/openpandora/build/PXML_schema.xsd | 341 --------------------- .../platform/openpandora/build/README-OPENPANDORA | 19 -- backends/platform/openpandora/build/README-PND.txt | 38 --- .../openpandora/build/icon/preview-pic.png | Bin 72496 -> 0 bytes .../platform/openpandora/build/icon/scummvm.png | Bin 2656 -> 0 bytes backends/platform/openpandora/build/index.html | 26 -- backends/platform/openpandora/build/pnd_make.sh | 321 ------------------- backends/platform/openpandora/build/runscummvm.sh | 14 - backends/platform/openpandora/op-bundle.mk | 29 +- 10 files changed, 15 insertions(+), 828 deletions(-) delete mode 100755 backends/platform/openpandora/build/PXML.xml delete mode 100644 backends/platform/openpandora/build/PXML_schema.xsd delete mode 100755 backends/platform/openpandora/build/README-OPENPANDORA delete mode 100755 backends/platform/openpandora/build/README-PND.txt delete mode 100755 backends/platform/openpandora/build/icon/preview-pic.png delete mode 100755 backends/platform/openpandora/build/icon/scummvm.png delete mode 100755 backends/platform/openpandora/build/index.html delete mode 100755 backends/platform/openpandora/build/pnd_make.sh delete mode 100755 backends/platform/openpandora/build/runscummvm.sh (limited to 'backends') diff --git a/backends/platform/openpandora/build/PXML.xml b/backends/platform/openpandora/build/PXML.xml deleted file mode 100755 index a87c49e2b8..0000000000 --- a/backends/platform/openpandora/build/PXML.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - ScummVM - - ScummVM - - - - ScummVM is a program which allows you to run certain classic graphical point-and-click adventure games, provided you already have their data files. The clever part about this: ScummVM just replaces the executables shipped with the games, allowing you to play them on systems for which they were never designed! - - ScummVM supports many adventure games, including LucasArts SCUMM games (such as Monkey Island 1-3, Day of the Tentacle, Sam & Max, ...), many of Sierra's AGI and SCI games (such as King's Quest 1-6, Space Quest 1-5, ...), Discworld 1 and 2, Simon the Sorcerer 1 and 2, Beneath A Steel Sky, Lure of the Temptress, Broken Sword 1 and 2, Flight of the Amazon Queen, Gobliiins 1-3, The Legend of Kyrandia 1-3, many of Humongous Entertainment's children's SCUMM games (including Freddi Fish and Putt Putt games) and many more. - - - - - - - - - - - - - ScummVM - - ScummVM - - - - ScummVM is a program which allows you to run certain classic graphical point-and-click adventure games, provided you already have their data files. The clever part about this: ScummVM just replaces the executables shipped with the games, allowing you to play them on systems for which they were never designed! - - ScummVM supports many adventure games, including LucasArts SCUMM games (such as Monkey Island 1-3, Day of the Tentacle, Sam & Max, ...), many of Sierra's AGI and SCI games (such as King's Quest 1-6, Space Quest 1-5, ...), Discworld 1 and 2, Simon the Sorcerer 1 and 2, Beneath A Steel Sky, Lure of the Temptress, Broken Sword 1 and 2, Flight of the Amazon Queen, Gobliiins 1-3, The Legend of Kyrandia 1-3, many of Humongous Entertainment's children's SCUMM games (including Freddi Fish and Putt Putt games) and many more. - - - - - - - - - - - - - - - - - diff --git a/backends/platform/openpandora/build/PXML_schema.xsd b/backends/platform/openpandora/build/PXML_schema.xsd deleted file mode 100644 index 7c0d635016..0000000000 --- a/backends/platform/openpandora/build/PXML_schema.xsd +++ /dev/null @@ -1,341 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/backends/platform/openpandora/build/README-OPENPANDORA b/backends/platform/openpandora/build/README-OPENPANDORA deleted file mode 100755 index c8aabcbb7a..0000000000 --- a/backends/platform/openpandora/build/README-OPENPANDORA +++ /dev/null @@ -1,19 +0,0 @@ -ScummVM - OPENPANDORA SPECIFIC README ------------------------------------------------------------------------- -Please refer to the: - -ScummVM Forum: -WiKi: - -for the most current information on the port and any updates to this -documentation. - -The wiki includes detailed instructions on how to use the port and -control information. - ------------------------------------------------------------------------- -Credits - -Core ScummVM code (c) The ScummVM Team -OpenPandora backend (c) John Willis -Detailed (c) information can be found within the source code diff --git a/backends/platform/openpandora/build/README-PND.txt b/backends/platform/openpandora/build/README-PND.txt deleted file mode 100755 index 942c3a43e2..0000000000 --- a/backends/platform/openpandora/build/README-PND.txt +++ /dev/null @@ -1,38 +0,0 @@ -ScummVM - OPENPANDORA README - HOW TO INSTALL ------------------------------------------------------------------------- - -Please refer to the: - -ScummVM Forum: -WiKi: - -for the most current information on the port and any updates to this -documentation. - ------------------------------------------------------------------------- -Installing: - -This archive contains ScummVM in a PND format ready to be copied to the -OpenPandora and used. - -To install just copy the .pnd file from this archive to your device. - -You will need to place the .pnd file in a suitable location on your SD -card. - -/pandora/desktop <- place here if you wish the icon to show on the - desktop. Documentation will show in the menu. - -/pandora/menu <- place here if you wish the icon to show on the - Xfce menu. Documentation will show in the menu. - -/pandora/apps <- place here if you wish the icon to show on the - desktop and in the menu. Documentation will show - in the menu. - ------------------------------------------------------------------------- -Credits - -Core ScummVM code (c) The ScummVM Team -OpenPandora backend (c) John Willis -Detailed (c) information can be found within the source code diff --git a/backends/platform/openpandora/build/icon/preview-pic.png b/backends/platform/openpandora/build/icon/preview-pic.png deleted file mode 100755 index 2f4a536d30..0000000000 Binary files a/backends/platform/openpandora/build/icon/preview-pic.png and /dev/null differ diff --git a/backends/platform/openpandora/build/icon/scummvm.png b/backends/platform/openpandora/build/icon/scummvm.png deleted file mode 100755 index 128e59efc4..0000000000 Binary files a/backends/platform/openpandora/build/icon/scummvm.png and /dev/null differ diff --git a/backends/platform/openpandora/build/index.html b/backends/platform/openpandora/build/index.html deleted file mode 100755 index 34d381d0f8..0000000000 --- a/backends/platform/openpandora/build/index.html +++ /dev/null @@ -1,26 +0,0 @@ - - -

-

Welcome to the ScummVM!

-

- -

-

ScummVM: OpenPandora Specific Documentation

-

- -ScummVM OpenPandora README
-ScummVM OpenPandora Website
-ScummVM OpenPandora WiKi
- -

-

ScummVM: General Documentation

-

- -ScummVM website
-ScummVM README
-ScummVM NEWS
-ScummVM Authors
-ScummVM Copyright
-GPL Licence
- - diff --git a/backends/platform/openpandora/build/pnd_make.sh b/backends/platform/openpandora/build/pnd_make.sh deleted file mode 100755 index 0c03e8154d..0000000000 --- a/backends/platform/openpandora/build/pnd_make.sh +++ /dev/null @@ -1,321 +0,0 @@ -#!/bin/bash -# -# pnd_make.sh -# -# This script is meant to ease generation of a pnd file. Please consult the output -# when running --help for a list of available parameters and an explaination of -# those. -# -# Required tools when running the script: -# bash -# echo, cat, mv, rm -# mkisofs or mksquashfs (the latter when using the -c param!) -# xmllint (optional, only for validation of the PXML against the schema) - - -PXML_schema=$(dirname ${0})/PXML_schema.xsd -GENPXML_PATH=$(dirname ${0})/genpxml.sh - -# useful functions ... -black='\E[30m' -red='\E[31m' -green='\E[32m' -yellow='\E[33m' -blue='\E[34m' -magenta='\E[35m' -cyan='\E[36m' -white='\E[37m' - -check_for_tool() -{ - which $1 &> /dev/null - if [ "$?" -ne "0" ]; - then - cecho "ERROR: Could not find the program '$1'. Please make sure -that it is available in your PATH since it is required to complete your request." $red - exit 1 - fi -} - -cecho () # Color-echo. Argument $1 = message, Argument $2 = color -{ - local default_msg="No message passed." # Doesn't really need to be a local variable. - message=${1:-$default_msg} # Defaults to default message. - color=${2:-$black} # Defaults to black, if not specified. - echo -e "$color$message" - tput sgr0 # Reset to normal. - return -} - - -print_help() -{ - cat << EOSTREAM -pnd_make.sh - A script to package "something" into a PND. - -Usage: - $(basename ${0}) {--directory|-d} {--pndname|-p} [{--compress-squashfs|-c}] - [{--genpxml} ] [{--icon|-i} ] [{--pxml|-x} ] - [{--schema|-s} ] [{--help|-h}] - - -Switches: - --compress-squashfs / -c Define whether or not the pnd should be compressed using - squashfs. If this parameter is selected, a compressed pnd - will be created. - - --directory / -d Sets the folder that is to be used for the resulting pnd - to . This option is mandatory for the script to - function correctly. - - --genpxml Sets the script used for generating a PXML file (if none - is available already) to . Please make sure to either - provide a full path or prefix a script in the current folder - with './' so that the script can actually be executed. If - this variable is not specified, $GENPXML_PATH - will be used. - - --help / -h Displays this help text. - - --icon / -i Sets the icon that will be appended in the pnd to . - - --pndname / -p Sets the output filename of the resulting pnd to . - This option is mandatory for the script to function - correctly. - - --pxml / -x Sets the PXML file that is to be used to . If you - neither provide a PXML file or set this entry to 'guess', - an existing 'PXML.xml' in your selected '--directory' - will be used, or the script $GENPXML_PATH - will be called to try to generate a basic PXML file for you. - - --schema / -s Sets the schema file, that is to be used for validation, - to =4.0 of squashfs -is required to be available in your PATH. -EOSTREAM -} - - -# Parse command line parameters -while [ "${1}" != "" ]; do - if [ "${1}" = "--compress-squashfs" ] || [ "${1}" = "-c" ]; - then - SQUASH=1 - shift 1 - elif [ "${1}" = "--directory" ] || [ "${1}" = "-d" ]; - then - FOLDER=$2 - shift 2 - elif [ "${1}" = "--genpxml" ]; - then - GENPXML_PATH=$2 - shift 2 - elif [ "${1}" = "--help" ] || [ "${1}" = "-h" ]; - then - print_help - exit 0 - elif [ "${1}" = "--icon" ] || [ "${1}" = "-i" ]; - then - ICON=$2 - shift 2 - elif [ "${1}" = "--pndname" ] || [ "${1}" = "-p" ]; - then - PNDNAME=$2 - shift 2 - elif [ "${1}" = "--pxml" ] || [ "${1}" = "-x" ]; - then - PXML=$2 - shift 2 - elif [ "${1}" = "--schema" ] || [ "${1}" = "-f" ] - then - PXML_schema=$2 - shift 2 - else - cecho "ERROR: '$1' is not a known argument. Printing --help and aborting." $red - print_help - exit 1 - fi -done - - -# Generate a PXML if the param is set to Guess or it is empty. -if [ ! $PXML ] || [ $PXML = "guess" ] && [ $PNDNAME ] && [ $FOLDER ]; -then - if [ -f $FOLDER/PXML.xml ]; # use the already existing PXML.xml file if there is one... - then - PXML=$FOLDER/PXML.xml - PXML_ALREADY_EXISTING="true" - else - if [ -f $GENPXML_PATH ]; - then - $GENPXML_PATH --src $FOLDER --dest $FOLDER --author $USER - if [ -f $FOLDER/PXML.xml ]; - then - PXML_GENERATED="true" - else - cecho "ERROR: Generating a PXML file using '$GENPXML_PATH' failed. -Please generate a PXML file manually." $red - exit 1 - fi - else - cecho "ERROR: Could not find '$GENPXML_PATH' for generating a PXML file." $red - exit 1 - fi - fi -fi - - -# Probe if required variables were set -echo -e -cecho "Checking if all required variables were set." $green -if [ ! $PNDNAME ] || [ ! $FOLDER ] || [ ! $PXML ]; -then - echo -e - cecho "ERROR: Not all required options were set! Please see the --help information below." $red - echo -e - print_help - exit 1 -else - echo "PNDNAME set to '$PNDNAME'." -fi -# Check if the selected folder actually exists -if [ ! -d $FOLDER ]; -then - echo -e - cecho "ERROR: '$FOLDER' doesn't exist or is not a folder." $red - exit 1 -else - echo "FOLDER set to '$FOLDER'." -fi -# Check if the selected PXML file actually exists -if [ ! -f $PXML ]; -then - echo -e - cecho "ERROR: '$PXML' doesn't exist or is not a file." $red - exit 1 -else - if [ $PXML_ALREADY_EXISTING ]; - then - echo "You have not explicitly specified a PXML to use, but an existing file was -found. Will be using this one." - elif [ $PXML_GENERATED ]; - then - echo "A PXML file was generated for you using '$GENPXML_PATH'. This file will -not be removed at the end of this script because you might want to review it, adjust -single entries and rerun the script to generate a pnd with a PXML file with all the -information you want to have listed." - fi - echo "PXML set to '$PXML'." -fi - -# Print the other variables: -if [ $ICON ]; -then - if [ ! -f $ICON ] - then - cecho "WARNING: '$ICON' doesn't exist, will not append the selected icon to the pnd." $red - else - echo "ICON set to '$ICON'." - USE_ICON="true" - fi -fi -if [ $SQUASH ]; -then - echo "Will use a squashfs for '$PNDNAME'." -fi - - -# Validate the PXML file (if xmllint is available) -# Errors and problems in this section will be shown but are not fatal. -echo -e -cecho "Trying to validate '$PXML' now. Will be using '$PXML_schema' to do so." $green -which xmllint &> /dev/null -if [ "$?" -ne "0" ]; -then - VALIDATED=false - cecho "WARNING: Could not find 'xmllint'. Validity check of '$PXML' is not possible!" $red -else - if [ ! -f "$PXML_schema" ]; - then - VALIDATED=false - cecho "WARNING: Could not find '$PXML_schema'. If you want to validate your -PXML file please make sure to provide a schema using the --schema option." $red - else - xmllint --noout --schema $PXML_schema $PXML - if [ "$?" -ne "0" ]; then VALIDATED=false; else VALIDATED=true; fi - fi -fi -# Print some message at the end about the validation in case the user missed the output above -if [ $VALIDATED = "false" ] -then - cecho "WARNING: Could not successfully validate '$PXML'. Please check the output -above. This does not mean that your pnd will be broken. Either you are not following the strict -syntax required for validation or you don't have all files/programs required for validating." $red -else - cecho "Your file '$PXML' was validated successfully. The resulting pnd should -work nicely with libpnd." $green -fi - - -# Make iso from folder -echo -e -cecho "Creating an iso file based on '$FOLDER'." $green -if [ $SQUASH ]; -then - check_for_tool mksquashfs - if [ $(mksquashfs -version | awk 'BEGIN{r=0} $3>=4{r=1} END{print r}') -eq 0 ]; - then - cecho "ERROR: Your squashfs version is older then version 4, please upgrade to 4.0 or later" $red - exit 1 - fi - mksquashfs $FOLDER $PNDNAME.iso -nopad -no-recovery -else - check_for_tool mkisofs - mkisofs -o $PNDNAME.iso -R $FOLDER -fi - -# Check that the iso file was actually created before continuing -if [ ! -f $PNDNAME.iso ]; -then - cecho "ERROR: The temporary file '$PNDNAME.iso' could not be created. -Please check the output above for any errors and retry after fixing them. Aborting." $red - exit 1 -fi - - -# Append pxml to iso -echo -e -cecho "Appending '$PXML' to the created iso file." $green -cat $PNDNAME.iso $PXML > $PNDNAME -rm $PNDNAME.iso #cleanup - - -# Append icon if specified and available -if [ $USE_ICON ]; -then - echo -e - cecho "Appending the icon '$ICON' to the pnd." $green - mv $PNDNAME $PNDNAME.tmp - cat $PNDNAME.tmp $ICON > $PNDNAME # append icon - rm $PNDNAME.tmp #cleanup -fi - - -# Final message -echo -e -if [ -f $PNDNAME ]; -then - cecho "Successfully finished creating the pnd '$PNDNAME'." $green -else - cecho "There seems to have been a problem and '$PNDNAME' was not created. Please check -the output above for any error messages. A possible cause for this is that there was -not enough space available." $red - exit 1 -fi - - -#if [ $PXML = "guess" ];then rm $FOLDER/PXML.xml; fi #cleanup diff --git a/backends/platform/openpandora/build/runscummvm.sh b/backends/platform/openpandora/build/runscummvm.sh deleted file mode 100755 index 9c9d8362cb..0000000000 --- a/backends/platform/openpandora/build/runscummvm.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -# Make sure any extra libs not in the firmware are pulled in. -LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../lib -export LD_LIBRARY_PATH - -# Ensure we have a folder to store save games on the SD card. -mkdir saves - -# make a runtime dir, just incase it creates anything in CWD -mkdir runtime -cd runtime - -../bin/scummvm --fullscreen --gfx-mode=2x --config=../scummvm.config --themepath=../data diff --git a/backends/platform/openpandora/op-bundle.mk b/backends/platform/openpandora/op-bundle.mk index 089430f43c..284a0497a8 100755 --- a/backends/platform/openpandora/op-bundle.mk +++ b/backends/platform/openpandora/op-bundle.mk @@ -14,15 +14,15 @@ op-bundle: $(EXECUTABLE) $(MKDIR) "$(bundle_name)/scummvm/icon" $(MKDIR) "$(bundle_name)/scummvm/lib" - $(CP) $(srcdir)/backends/platform/openpandora/build/runscummvm.sh $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/openpandora/build/PXML.xml $(bundle_name)/scummvm/data/ + $(CP) $(srcdir)/dists/openpandora/runscummvm.sh $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/openpandora/PXML.xml $(bundle_name)/scummvm/data/ - $(CP) $(srcdir)/backends/platform/openpandora/build/icon/scummvm.png $(bundle_name)/scummvm/icon/ - $(CP) $(srcdir)/backends/platform/openpandora/build/icon/preview-pic.png $(bundle_name)/scummvm/icon/ + $(CP) $(srcdir)/dists/openpandora/icon/scummvm.png $(bundle_name)/scummvm/icon/ + $(CP) $(srcdir)/dists/openpandora/icon/preview-pic.png $(bundle_name)/scummvm/icon/ - $(CP) $(srcdir)/backends/platform/openpandora/build/README-OPENPANDORA $(bundle_name)/scummvm/docs/ - $(CP) $(srcdir)/backends/platform/openpandora/build/index.html $(bundle_name)/scummvm/docs/ + $(CP) $(srcdir)/dists/openpandora/README-OPENPANDORA $(bundle_name)/scummvm/docs/ + $(CP) $(srcdir)/dists/openpandora/index.html $(bundle_name)/scummvm/docs/ $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/docs/ @@ -50,15 +50,15 @@ op-pnd: $(EXECUTABLE) $(MKDIR) "$(bundle_name)/scummvm/icon" $(MKDIR) "$(bundle_name)/scummvm/lib" - $(CP) $(srcdir)/backends/platform/openpandora/build/runscummvm.sh $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/openpandora/build/PXML.xml $(bundle_name)/scummvm/data/ + $(CP) $(srcdir)/dists/openpandora/runscummvm.sh $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/openpandora/PXML.xml $(bundle_name)/scummvm/data/ - $(CP) $(srcdir)/backends/platform/openpandora/build/icon/scummvm.png $(bundle_name)/scummvm/icon/ - $(CP) $(srcdir)/backends/platform/openpandora/build/icon/preview-pic.png $(bundle_name)/scummvm/icon/ + $(CP) $(srcdir)/dists/openpandora/icon/scummvm.png $(bundle_name)/scummvm/icon/ + $(CP) $(srcdir)/dists/openpandora/icon/preview-pic.png $(bundle_name)/scummvm/icon/ - $(CP) $(srcdir)/backends/platform/openpandora/build/README-OPENPANDORA $(bundle_name)/scummvm/docs/ - $(CP) $(srcdir)/backends/platform/openpandora/build/index.html $(bundle_name)/scummvm/docs/ + $(CP) $(srcdir)/dists/openpandora/README-OPENPANDORA $(bundle_name)/scummvm/docs/ + $(CP) $(srcdir)/dists/openpandora/index.html $(bundle_name)/scummvm/docs/ $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/docs/ @@ -75,9 +75,10 @@ endif $(CP) $(libloc)/../arm-angstrom-linux-gnueabi/usr/lib/libFLAC.so.8.2.0 $(bundle_name)/scummvm/lib/libFLAC.so.8 - $(srcdir)/backends/platform/openpandora/build/pnd_make.sh -p $(bundle_name).pnd -c -d $(bundle_name)/scummvm -x $(bundle_name)/scummvm/data/PXML.xml -i $(bundle_name)/scummvm/icon/scummvm.png + $(srcdir)/dists/openpandora/pnd_make.sh -p $(bundle_name).pnd -c -d $(bundle_name)/scummvm -x $(bundle_name)/scummvm/data/PXML.xml -i $(bundle_name)/scummvm/icon/scummvm.png + + $(CP) $(srcdir)/dists/openpandora/README-PND.txt $(bundle_name) - $(CP) $(srcdir)/backends/platform/openpandora/build/README-PND.txt $(bundle_name) tar -cvjf $(bundle_name)-pnd.tar.bz2 $(bundle_name).pnd $(bundle_name)/README-PND.txt rm -R ./$(bundle_name) -- cgit v1.2.3 From 7e0a88f69b05e71f41e2ea776b85a13fbb132bfc Mon Sep 17 00:00:00 2001 From: David-John Willis Date: Sun, 22 Jan 2012 16:46:43 +0000 Subject: GPH: Move all dist files into own folder under dists. * Update vairous GPH bundle targets to suit new layout. * Also add .in input files so we can automatically update version numbers. --- backends/platform/gph/caanoo-bundle.mk | 20 ++-- .../platform/gph/devices/caanoo/scummvm-gdb.gpe | 16 --- backends/platform/gph/devices/caanoo/scummvm.gpe | 15 --- backends/platform/gph/devices/common/README-GPH | 60 ---------- backends/platform/gph/devices/common/scummvm.ini | 5 - backends/platform/gph/devices/common/scummvm.png | Bin 2656 -> 0 bytes backends/platform/gph/devices/common/scummvmb.png | Bin 34274 -> 0 bytes .../platform/gph/devices/gp2x/mmuhack/Makefile | 11 -- backends/platform/gph/devices/gp2x/mmuhack/README | 116 ------------------- .../devices/gp2x/mmuhack/flush_uppermem_cache.h | 10 -- .../devices/gp2x/mmuhack/flush_uppermem_cache.s | 5 - .../platform/gph/devices/gp2x/mmuhack/mmuhack.c | 126 --------------------- .../platform/gph/devices/gp2x/mmuhack/mmuhack.o | Bin 1720 -> 0 bytes backends/platform/gph/devices/gp2x/scummvm.gpe | 18 --- .../platform/gph/devices/gp2xwiz/scummvm-gdb.gpe | 16 --- backends/platform/gph/devices/gp2xwiz/scummvm.gpe | 15 --- backends/platform/gph/gp2x-bundle.mk | 16 +-- backends/platform/gph/gp2xwiz-bundle.mk | 20 ++-- 18 files changed, 28 insertions(+), 441 deletions(-) delete mode 100644 backends/platform/gph/devices/caanoo/scummvm-gdb.gpe delete mode 100644 backends/platform/gph/devices/caanoo/scummvm.gpe delete mode 100644 backends/platform/gph/devices/common/README-GPH delete mode 100644 backends/platform/gph/devices/common/scummvm.ini delete mode 100644 backends/platform/gph/devices/common/scummvm.png delete mode 100644 backends/platform/gph/devices/common/scummvmb.png delete mode 100644 backends/platform/gph/devices/gp2x/mmuhack/Makefile delete mode 100644 backends/platform/gph/devices/gp2x/mmuhack/README delete mode 100644 backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.h delete mode 100644 backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.s delete mode 100644 backends/platform/gph/devices/gp2x/mmuhack/mmuhack.c delete mode 100644 backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o delete mode 100644 backends/platform/gph/devices/gp2x/scummvm.gpe delete mode 100644 backends/platform/gph/devices/gp2xwiz/scummvm-gdb.gpe delete mode 100644 backends/platform/gph/devices/gp2xwiz/scummvm.gpe (limited to 'backends') diff --git a/backends/platform/gph/caanoo-bundle.mk b/backends/platform/gph/caanoo-bundle.mk index 8aabca9028..2cf8e62b37 100755 --- a/backends/platform/gph/caanoo-bundle.mk +++ b/backends/platform/gph/caanoo-bundle.mk @@ -14,11 +14,11 @@ caanoo-bundle: $(EXECUTABLE) echo "Please put your save games in this dir" >> "$(bundle_name)/scummvm/saves/PUT_SAVES_IN_THIS_DIR" - $(CP) $(srcdir)/backends/platform/gph/devices/caanoo/scummvm.gpe $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvmb.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.ini $(bundle_name)/ + $(CP) $(srcdir)/dists/gph/caanoo/scummvm.gpe $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvmb.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvm.ini $(bundle_name)/ $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/ $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/scummvm/ @@ -45,11 +45,11 @@ caanoo-bundle-debug: $(EXECUTABLE) echo "Please put your save games in this dir" >> "$(bundle_name)/scummvm/saves/PUT_SAVES_IN_THIS_DIR" - $(CP) $(srcdir)/backends/platform/gph/devices/caanoo/scummvm-gdb.gpe $(bundle_name)/scummvm/scummvm.gpe - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvmb.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.ini $(bundle_name)/ + $(CP) $(srcdir)/dists/gph/caanoo/scummvm-gdb.gpe $(bundle_name)/scummvm/scummvm.gpe + $(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvmb.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvm.ini $(bundle_name)/ $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/ $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/scummvm/ diff --git a/backends/platform/gph/devices/caanoo/scummvm-gdb.gpe b/backends/platform/gph/devices/caanoo/scummvm-gdb.gpe deleted file mode 100644 index 63ce193ca8..0000000000 --- a/backends/platform/gph/devices/caanoo/scummvm-gdb.gpe +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -# Export the location of any libs ScummVM depends on -# (to avoid installing to the NAND and overwriting the broken ones there). -export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH - -# Run ScummVM via GDB (so make sure you have a terminal open or serial). -# Oh, and GDB installed of course ;) -gdb --args ./scummvm.gph --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc - -# Sync the SD card to check that everything is written. -sync - -# Return to the GPH menu screen -cd /usr/gp2x -exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gph/devices/caanoo/scummvm.gpe b/backends/platform/gph/devices/caanoo/scummvm.gpe deleted file mode 100644 index 37d0f65d18..0000000000 --- a/backends/platform/gph/devices/caanoo/scummvm.gpe +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# Export the location of any libs ScummVM depends on -# (to avoid installing to the NAND and overwriting the broken ones there). -export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH - -# Run ScummVM, important this bit. -./scummvm.gph --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc - -# Sync the SD card to check that everything is written. -sync - -# Return to the GPH menu screen -cd /usr/gp2x -exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gph/devices/common/README-GPH b/backends/platform/gph/devices/common/README-GPH deleted file mode 100644 index ea196f6649..0000000000 --- a/backends/platform/gph/devices/common/README-GPH +++ /dev/null @@ -1,60 +0,0 @@ -ScummVM - GPH DEVICE SPECIFIC README ------------------------------------------------------------------------- - -Contents: - - * About the backend/port <#About_the_backendport> - * Supported audio options <#Supported_audio_options> - * Credits <#Credits> - ------------------------------------------------------------------------- - -Please refer to the: - -GPH ScummVM Forum: - -WiKi: (Select your device) - - - - - -for the most current information on the port and any updates to this -documentation. - -The wiki includes detailed instructions on how to use the port and -control information. - ------------------------------------------------------------------------- -About the backend/port - -This is the readme for the official GPH ScummVM backend (also known as -the GP2X port/GP2XWiz port or Caanoo port). - -This is an SVN test release of ScummVM for GPH devices, it would be -appreciated if this SVN test distribution was not mirrored and that -people be directed to http://scummvm.distant-earth.com/ instead for -updated SVN builds. - -Fully supported official releases of the GPH ScummVM backend are made in -line with main official releases and are avalalble from the ScummVM -downloads page for the GP2X, -GP2XWiz and Caanoo. - ------------------------------------------------------------------------- -Supported audio options - -Raw audio. -MP3 audio. -OGG Vorbis audio. - -FLAC audio is currently unsupported. - -For best results use uncompressed audio in games. - ------------------------------------------------------------------------- -Credits - -Core ScummVM code (c) The ScummVM Team -Portions of the GPH backend (c) John Willis -Detailed (c) information can be found within the source code diff --git a/backends/platform/gph/devices/common/scummvm.ini b/backends/platform/gph/devices/common/scummvm.ini deleted file mode 100644 index c9cce92379..0000000000 --- a/backends/platform/gph/devices/common/scummvm.ini +++ /dev/null @@ -1,5 +0,0 @@ -[info] -name="ScummVM" -path="/scummvm/scummvm.gpe" -icon="/scummvm/scummvm.png" -title="/scummvm/scummvmb.png" diff --git a/backends/platform/gph/devices/common/scummvm.png b/backends/platform/gph/devices/common/scummvm.png deleted file mode 100644 index 128e59efc4..0000000000 Binary files a/backends/platform/gph/devices/common/scummvm.png and /dev/null differ diff --git a/backends/platform/gph/devices/common/scummvmb.png b/backends/platform/gph/devices/common/scummvmb.png deleted file mode 100644 index 24a27bc0e1..0000000000 Binary files a/backends/platform/gph/devices/common/scummvmb.png and /dev/null differ diff --git a/backends/platform/gph/devices/gp2x/mmuhack/Makefile b/backends/platform/gph/devices/gp2x/mmuhack/Makefile deleted file mode 100644 index a35d5c2a98..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -TARGET = mmuhack -INCLUDE = -I/opt/gcc-3.4.4-glibc-2.3.6/arm-open2x-linux/sys-include -CFLAGS = -O2 -DMODULE -D__KERNEL__ ${INCLUDE} -CC = arm-open2x-linux-gcc - -all: ${TARGET}.o - -${TARGET}.o: ${TARGET}.c - -clean: - rm -rf ${TARGET}.o diff --git a/backends/platform/gph/devices/gp2x/mmuhack/README b/backends/platform/gph/devices/gp2x/mmuhack/README deleted file mode 100644 index 6db7d81845..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/README +++ /dev/null @@ -1,116 +0,0 @@ -PLEASE NOTE: - -The binary object 'mmuhack.o' is stored in the source tree as it is very awkward to -build it manually each time and would require the use of 2 toolchains to do so. - -Notes on how to rebuild from the included source can be found below. - -About ------ - -This is a module for GP2X 2.4 based Linux kernel, created for developers to use in their -programs. - -Normally the upper 32MB is uncached. This means that reads/writes on the memory -are always done via the physical memory modules rather than the much faster -memory built into the processor (called 'cache'). Access to the upper 32MB can -be sped up by Squidge's MMU hack. The easiest way to use the MMU hack is to add -and load the MMU hack kernel module into your program. - -Note: Building this module requries a GP2X 'kernel' toolchain (i.e. GCC 2.95.* -for the GP2X stock, 3.* for Open2X). - -You can't build this module with the GCC 4 based application toolchains. - -Operation ---------- - -When loaded into kernel, this module creates /dev/mmuhack device. Whenever -a program opens that device using open() call, the module traverses all -memory, which was allocated in 0x02000000-0x03ffffff range by the program via -using mmap() system call. While doing that, it marks all encountered memory -as bufferable and cacheable. - -The most common use of this is to remove the framebuffer access bottleneck. -Note that, however, by making the framebuffer cacheable you can cause display -artifacts. This can happen because parts of your framebuffer may stay in CPU -cache and not to be written back to the physical memory. The display -controller only fetches data from the physical memory, so you get incomplete -image (the memory will most likely contain data from previous frame, so these -artifacts are better visible during fade effects). The easy way to fix this -is by using a special ARM Linux system call, which flushes the cache (forces -the CPU to write data in cache to the physical memory (see section "Flushing -the cache")). - -Using this module affects the whole upper memory area. But in some situations -this may be not desirable, for example when using ARM940 core in your program -(ether using 940 libraries like ogg940 and gpu940, or using your custom code, -which needs uncacheable memory for communication and such). If you need part -of your upper memory to be cached, and other part not, you should mmap() that -memory (which you want to be uncached) _after_ doing open("/dev/mmuhack"). -Another way is to modify mmuhack.c to suit your needs and rebuild the module. - - -Usage ------ - -The very first thing to do is to load the kernel module (mmuhack.o) into the -running kernel. But before that you should try to unload mmuhack module, -because other program might have left a different version loaded with -different memory configuration, which may not suit your program. - -system("/sbin/rmmod mmuhack"); -system("/sbin/insmod mmuhack.o"); - -Now you can assume the module is loaded into kernel and open /dev/mmuhack -device. You don't need to worry about previous calls failing, because in that -case open() will simply fail and nothing bad will happen. - -IMPORTANT: you _must_ do the open() call _after_ you initialize your graphics -library or allocate your memory, because it can only work with memory which is -already allocated, it won't affect memory you or your lib allocates after the -open() call. - -int mmufd = open("/dev/mmuhack", O_RDWR); -if(mmufd < 0) -{ - printf("MMU hack failed"); -} -else -{ - printf("MMU hack loaded"); - close(mmufd); -} - -If the above call succeeded, you are all done. -I recommend to unload the module when your program exits, because the other -program may want to load a different mmuhack.o and may fail, because you left -your mmuhack.o loaded (it does not get unloaded automatically on exit). - -system("/sbin/rmmod mmuhack"); - - -Flushing the cache ------------------- - -If using mmuhack.o causes your program to display artifacts (see "Operation" -section for explanation), you will need to flush the CPU cache. This should -be done after finishing every frame and just before flipping your display -buffer/surface. You will need to add flush_uppermem_cache.s file to your -Makefile/project and add a call to flush_uppermem_cache() just before final -framebuffer flip or blit. - -flush_uppermem_cache() has 3 parameters. First param is the start address, -second param is the end address, third one should always be 0. The addresses -should be virtual ones (most often pointers to the start/end of your -framebuffer). Example: - -flush_uppermem_cache(screen_surface->pixels, screen_surface->pixels + 320*240, 0); - - -Credits -------- - -Original idea/implementation: Squidge (this whole thing is also known as squidgehack) -Kernel module: NK -Documentation: notaz diff --git a/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.h b/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.h deleted file mode 100644 index d01548e474..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifdef __cplusplus -extern "C" -{ -#endif - -void flush_uppermem_cache(void *start_address, void *end_address, int flags); - -#ifdef __cplusplus -} -#endif diff --git a/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.s b/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.s deleted file mode 100644 index 265908e1fd..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/flush_uppermem_cache.s +++ /dev/null @@ -1,5 +0,0 @@ -.global flush_uppermem_cache @ void *start_address, void *end_address, int flags - -flush_uppermem_cache: - swi #0x9f0002 - bx lr diff --git a/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.c b/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.c deleted file mode 100644 index 2e38bdb284..0000000000 --- a/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.c +++ /dev/null @@ -1,126 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include -#include -#include -#include -#include -#include - -#define MMUHACK_MINOR 225 -#define DEVICE_NAME "mmuhack" - -#if __GNUC__ == 3 -#include -static const char __module_kernel_version_gcc3[] __attribute__((__used__)) __attribute__((section(".modinfo"))) = -"kernel_version=" UTS_RELEASE; -#endif - -static ssize_t mmuhack_open(struct inode *inode, struct file *filp) -{ - unsigned int *pgtable; - unsigned int *cpt; - int i, j; - int ttb; - int ret = -EFAULT; - - // get the pointer to the translation table base... - asm volatile( - "stmdb sp!, {r0}\n\t" - "mrc p15, 0, r0, c2, c0, 0\n\t" - "mov %0, r0\n\t" - "ldmia sp!, {r0}\n\t": "=r"(ttb) - ); - - pgtable = __va(ttb); - - for (i = 0; i < 4096; i ++) if ( (pgtable[i] & 3) == 1 ) { - cpt = __va(pgtable[i] & 0xfffffc00); - - for (j = 0; j < 256; j ++) {/* - if ( (cpt[j] & 0xfe00000f) == 0x02000002 ) { - // set C and B bits in upper 32MB memory area... - printk("Set C&B bits %08x\n",cpt[j]); - cpt[j] |= 0xFFC; - ret = 0; - } - */ - if (((cpt[j] & 0xff000000) == 0x02000000) && ((cpt[j] & 12)==0) ) - { - //printk("Set C&B bits %08x\n",cpt[j]); - cpt[j] |= 0xFFC; - } - //if ((a>=0x31 && a<=0x36) && ((cpt[i] & 12)==0)) - if (((cpt[j] & 0xff000000) == 0x03000000) && ((cpt[j] & 12)==0)) - { - //printk("Set C&B bits %08x\n",cpt[j]); - //printf("SDL c and b bits not set, overwriting\n"); - cpt[j] |= 0xFFC; - } - } - } - - // drain the write buffer and flush the tlb caches... - asm volatile( - "stmdb sp!, {r0}\n\t" - "mov r0, #0\n\t" - "mcr 15, 0, r0, cr7, cr10, 4\n\t" - "mcr 15, 0, r0, cr8, cr7, 0\n\t" - "ldmia sp!, {r0}\n\t" - ); - - if (ret == 0) - printk("MMU hack applied.\n"); - - return 0; -} - -static struct file_operations mmuhack_fops = { - owner: THIS_MODULE, - open: mmuhack_open, -}; - - -static struct miscdevice mmuhack = { - MMUHACK_MINOR, DEVICE_NAME, &mmuhack_fops -}; - -static int __init mmuhack_init(void) -{ - misc_register(&mmuhack); -/* - printk("MMSP2 MMU Hack module.\n"); -*/ - return 0; -} - -static void __exit mmuhack_exit(void) -{ - misc_deregister(&mmuhack); -/* - printk(KERN_ALERT "MMU Hack module removed.\n"); -*/ -} - -module_init(mmuhack_init); -module_exit(mmuhack_exit); diff --git a/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o b/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o deleted file mode 100644 index 475f4a54ae..0000000000 Binary files a/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o and /dev/null differ diff --git a/backends/platform/gph/devices/gp2x/scummvm.gpe b/backends/platform/gph/devices/gp2x/scummvm.gpe deleted file mode 100644 index 51a49f7560..0000000000 --- a/backends/platform/gph/devices/gp2x/scummvm.gpe +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -# Remount SD with forced Sync, does this really work? -mount -o sync,remount /dev/mmcsd/disc0/part1 /mnt/sd/ - -# Export the location of any libs ScummVM depends on -# (to avoid installing to the NAND and overwriting the broken ones there). -export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH - -# Run ScummVM, important this bit. -./scummvm.gph --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc - -# Sync the SD card to check that everything is written. -sync - -# Return to the GPH menu screen -cd /usr/gp2x -exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gph/devices/gp2xwiz/scummvm-gdb.gpe b/backends/platform/gph/devices/gp2xwiz/scummvm-gdb.gpe deleted file mode 100644 index 63ce193ca8..0000000000 --- a/backends/platform/gph/devices/gp2xwiz/scummvm-gdb.gpe +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -# Export the location of any libs ScummVM depends on -# (to avoid installing to the NAND and overwriting the broken ones there). -export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH - -# Run ScummVM via GDB (so make sure you have a terminal open or serial). -# Oh, and GDB installed of course ;) -gdb --args ./scummvm.gph --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc - -# Sync the SD card to check that everything is written. -sync - -# Return to the GPH menu screen -cd /usr/gp2x -exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gph/devices/gp2xwiz/scummvm.gpe b/backends/platform/gph/devices/gp2xwiz/scummvm.gpe deleted file mode 100644 index 59ff562aeb..0000000000 --- a/backends/platform/gph/devices/gp2xwiz/scummvm.gpe +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -# Export the location of any libs ScummVM depends on -# (to avoid installing to the NAND and overwriting the broken ones there). -export LD_LIBRARY_PATH=`pwd`/lib:$LD_LIBRARY_PATH - -# Run ScummVM, important this bit. -./scummvm.gph --fullscreen --gfx-mode=1x --config=$(pwd)/.scummvmrc - -# Sync the SD card to check that everything is written. -sync - -# Return to the GPH menu screen -cd /usr/gp2x -exec /usr/gp2x/gp2xmenu diff --git a/backends/platform/gph/gp2x-bundle.mk b/backends/platform/gph/gp2x-bundle.mk index 810ff8b8f0..adac489a6b 100644 --- a/backends/platform/gph/gp2x-bundle.mk +++ b/backends/platform/gph/gp2x-bundle.mk @@ -12,10 +12,10 @@ gp2x-bundle: $(EXECUTABLE) echo "Please put your save games in this dir" >> "$(bundle_name)/saves/PUT_SAVES_IN_THIS_DIR" - $(CP) $(srcdir)/backends/platform/gph/devices/gp2x/scummvm.gpe $(bundle_name)/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/ - $(CP) $(srcdir)/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o $(bundle_name)/ + $(CP) $(srcdir)/dists/gph/gp2x/scummvm.gpe $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/gp2x/mmuhack/mmuhack.o $(bundle_name)/ $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/ $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/ @@ -42,10 +42,10 @@ gp2x-bundle-debug: $(EXECUTABLE) echo "Please put your save games in this dir" >> "$(bundle_name)/saves/PUT_SAVES_IN_THIS_DIR" - $(CP) $(srcdir)/backends/platform/gph/devices/gp2x/scummvm.gpe $(bundle_name)/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/ - $(CP) $(srcdir)/backends/platform/gph/devices/gp2x/mmuhack/mmuhack.o $(bundle_name)/ + $(CP) $(srcdir)/dists/gph/gp2x/scummvm.gpe $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/gp2x/mmuhack/mmuhack.o $(bundle_name)/ $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/ $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/ diff --git a/backends/platform/gph/gp2xwiz-bundle.mk b/backends/platform/gph/gp2xwiz-bundle.mk index 65e2952fde..4f49850813 100755 --- a/backends/platform/gph/gp2xwiz-bundle.mk +++ b/backends/platform/gph/gp2xwiz-bundle.mk @@ -13,11 +13,11 @@ gp2xwiz-bundle: $(EXECUTABLE) echo "Please put your save games in this dir" >> "$(bundle_name)/scummvm/saves/PUT_SAVES_IN_THIS_DIR" - $(CP) $(srcdir)/backends/platform/gph/devices/gp2xwiz/scummvm.gpe $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvmb.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.ini $(bundle_name)/ + $(CP) $(srcdir)/dists/gph/gp2xwiz/scummvm.gpe $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvmb.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvm.ini $(bundle_name)/ $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/ $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/scummvm/ @@ -47,11 +47,11 @@ gp2xwiz-bundle-debug: $(EXECUTABLE) echo "Please put your save games in this dir" >> "$(bundle_name)/scummvm/saves/PUT_SAVES_IN_THIS_DIR" - $(CP) $(srcdir)/backends/platform/gph/devices/gp2xwiz/scummvm-gdb.gpe $(bundle_name)/scummvm/scummvm.gpe - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvmb.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/README-GPH $(bundle_name)/scummvm/ - $(CP) $(srcdir)/backends/platform/gph/devices/common/scummvm.ini $(bundle_name)/ + $(CP) $(srcdir)/dists/gph/gp2xwiz/scummvm-gdb.gpe $(bundle_name)/scummvm/scummvm.gpe + $(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvmb.png $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name)/scummvm/ + $(CP) $(srcdir)/dists/gph/scummvm.ini $(bundle_name)/ $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/scummvm/ $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/scummvm/ -- cgit v1.2.3 From 2294b8aa661128407e259d919e666d8d910c7ce6 Mon Sep 17 00:00:00 2001 From: David-John Willis Date: Mon, 23 Jan 2012 12:14:52 +0000 Subject: GPH: Fix silly copy/paste error in GP2X bundle target. --- backends/platform/gph/gp2x-bundle.mk | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'backends') diff --git a/backends/platform/gph/gp2x-bundle.mk b/backends/platform/gph/gp2x-bundle.mk index adac489a6b..9fcb379e04 100644 --- a/backends/platform/gph/gp2x-bundle.mk +++ b/backends/platform/gph/gp2x-bundle.mk @@ -12,15 +12,15 @@ gp2x-bundle: $(EXECUTABLE) echo "Please put your save games in this dir" >> "$(bundle_name)/saves/PUT_SAVES_IN_THIS_DIR" - $(CP) $(srcdir)/dists/gph/gp2x/scummvm.gpe $(bundle_name)/scummvm/ - $(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name)/scummvm/ - $(CP) $(srcdir)/dists/gph/gp2x/mmuhack/mmuhack.o $(bundle_name)/ + $(CP) $(srcdir)/dists/gph/gp2x/scummvm.gpe $(bundle_name) + $(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name) + $(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name) + $(CP) $(srcdir)/dists/gph/gp2x/mmuhack/mmuhack.o $(bundle_name) - $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/ - $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/ + $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name) + $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name) $(INSTALL) -c -m 644 $(DIST_FILES_ENGINEDATA) $(bundle_name)/engine-data - $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(bundle_name)/ + $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(bundle_name) $(STRIP) $(EXECUTABLE) -o $(bundle_name)/$(EXECUTABLE) @@ -39,18 +39,19 @@ gp2x-bundle-debug: $(EXECUTABLE) $(MKDIR) "$(bundle_name)" $(MKDIR) "$(bundle_name)/saves" $(MKDIR) "$(bundle_name)/engine-data" + $(MKDIR) "$(bundle_name)/lib" echo "Please put your save games in this dir" >> "$(bundle_name)/saves/PUT_SAVES_IN_THIS_DIR" - $(CP) $(srcdir)/dists/gph/gp2x/scummvm.gpe $(bundle_name)/scummvm/ - $(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name)/scummvm/ - $(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name)/scummvm/ - $(CP) $(srcdir)/dists/gph/gp2x/mmuhack/mmuhack.o $(bundle_name)/ + $(CP) $(srcdir)/dists/gph/gp2x/scummvm.gpe $(bundle_name) + $(CP) $(srcdir)/dists/gph/scummvm.png $(bundle_name) + $(CP) $(srcdir)/dists/gph/README-GPH $(bundle_name) + $(CP) $(srcdir)/dists/gph/gp2x/mmuhack/mmuhack.o $(bundle_name) - $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name)/ - $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name)/ + $(INSTALL) -c -m 644 $(DIST_FILES_DOCS) $(bundle_name) + $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(bundle_name) $(INSTALL) -c -m 644 $(DIST_FILES_ENGINEDATA) $(bundle_name)/engine-data - $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(bundle_name)/ + $(CP) $(srcdir)/backends/vkeybd/packs/vkeybd_default.zip $(bundle_name) $(INSTALL) -c -m 777 $(srcdir)/$(EXECUTABLE) $(bundle_name)/$(EXECUTABLE) -- cgit v1.2.3 From 8701e0a382b4b42d75cf38006234612c344808cf Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Mon, 23 Jan 2012 23:17:55 +1100 Subject: WINDOWS: Add default save paths for Windows NT4 onwards --- backends/module.mk | 1 + backends/platform/sdl/win32/win32.cpp | 5 ++ backends/saves/windows/windows-saves.cpp | 78 ++++++++++++++++++++++++++++++++ backends/saves/windows/windows-saves.h | 36 +++++++++++++++ 4 files changed, 120 insertions(+) create mode 100644 backends/saves/windows/windows-saves.cpp create mode 100644 backends/saves/windows/windows-saves.h (limited to 'backends') diff --git a/backends/module.mk b/backends/module.mk index 6be595a65e..37209ffcef 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -98,6 +98,7 @@ MODULE_OBJS += \ fs/windows/windows-fs-factory.o \ midi/windows.o \ plugins/win32/win32-provider.o \ + saves/windows/windows-saves.o \ taskbar/win32/win32-taskbar.o endif diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp index 3e09aa2640..453d566c7b 100644 --- a/backends/platform/sdl/win32/win32.cpp +++ b/backends/platform/sdl/win32/win32.cpp @@ -38,6 +38,7 @@ #include // For setting the icon #include "backends/platform/sdl/win32/win32.h" +#include "backends/saves/windows/windows-saves.h" #include "backends/fs/windows/windows-fs-factory.h" #include "backends/taskbar/win32/win32-taskbar.h" @@ -74,6 +75,10 @@ void OSystem_Win32::initBackend() { FreeConsole(); } + // Create the savefile manager + if (_savefileManager == 0) + _savefileManager = new WindowsSaveFileManager(); + // Invoke parent implementation of this method OSystem_SDL::initBackend(); } diff --git a/backends/saves/windows/windows-saves.cpp b/backends/saves/windows/windows-saves.cpp new file mode 100644 index 0000000000..87348c3416 --- /dev/null +++ b/backends/saves/windows/windows-saves.cpp @@ -0,0 +1,78 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "common/scummsys.h" + +#include "backends/saves/windows/windows-saves.h" + +#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(DISABLE_DEFAULT_SAVEFILEMANAGER) + +#define WIN32_LEAN_AND_MEAN +#include + +#include "common/config-manager.h" +#include "common/savefile.h" + +WindowsSaveFileManager::WindowsSaveFileManager() { + char defaultSavepath[MAXPATHLEN]; + + OSVERSIONINFO win32OsVersion; + ZeroMemory(&win32OsVersion, sizeof(OSVERSIONINFO)); + win32OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&win32OsVersion); + // Check for non-9X version of Windows. + if (win32OsVersion.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) { + // Use the Application Data directory of the user profile. + if (win32OsVersion.dwMajorVersion >= 5) { + if (!GetEnvironmentVariable("APPDATA", defaultSavepath, sizeof(defaultSavepath))) + error("Unable to access application data directory"); + } else { + if (!GetEnvironmentVariable("USERPROFILE", defaultSavepath, sizeof(defaultSavepath))) + error("Unable to access user profile directory"); + + strcat(defaultSavepath, "\\Application Data"); + + // If the directory already exists (as it should in most cases), + // we don't want to fail, but we need to stop on other errors (such as ERROR_PATH_NOT_FOUND) + if (!CreateDirectory(defaultSavepath, NULL)) { + if (GetLastError() != ERROR_ALREADY_EXISTS) + error("Cannot create Application data folder"); + } + } + + strcat(defaultSavepath, "\\ScummVM"); + if (!CreateDirectory(defaultSavepath, NULL)) { + if (GetLastError() != ERROR_ALREADY_EXISTS) + error("Cannot create ScummVM application data folder"); + } + + strcat(defaultSavepath, "\\Saved games"); + if (!CreateDirectory(defaultSavepath, NULL)) { + if (GetLastError() != ERROR_ALREADY_EXISTS) + error("Cannot create ScummVM Saved games folder"); + } + + ConfMan.registerDefault("savepath", defaultSavepath); + } +} + +#endif diff --git a/backends/saves/windows/windows-saves.h b/backends/saves/windows/windows-saves.h new file mode 100644 index 0000000000..a705aa2b7f --- /dev/null +++ b/backends/saves/windows/windows-saves.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. + * + */ + +#ifndef BACKEND_WINDOWS_SAVES_H +#define BACKEND_WINDOWS_SAVES_H + +#include "backends/saves/default/default-saves.h" + +/** + * Provides a default savefile manager implementation for common platforms. + */ +class WindowsSaveFileManager : public DefaultSaveFileManager { +public: + WindowsSaveFileManager(); +}; + +#endif -- cgit v1.2.3 From 51778ed4af069c0286cbe165d224dfd4524fc211 Mon Sep 17 00:00:00 2001 From: dhewg Date: Mon, 23 Jan 2012 18:33:09 +0100 Subject: TASKBAR: Fix compilation with mingw-w64 mingw-compat.h is not required for newer mingw-w64, all required symbols are present in the system headers. --- backends/taskbar/win32/win32-taskbar.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'backends') diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp index 046ddb1cd0..4cc451247b 100644 --- a/backends/taskbar/win32/win32-taskbar.cpp +++ b/backends/taskbar/win32/win32-taskbar.cpp @@ -29,12 +29,8 @@ #if defined(WIN32) && defined(USE_TASKBAR) // Needed for taskbar functions -#if defined(__GNUC__) -#ifdef __MINGW32__ +#if defined(__GNUC__) && defined(__MINGW32__) && !defined(__MINGW64__) #include "backends/taskbar/win32/mingw-compat.h" -#else - #error Only compilation with MingW is supported -#endif #else // We need certain functions that are excluded by default #undef NONLS @@ -44,9 +40,12 @@ #undef ARRAYSIZE #endif - // Default MSVC headers for ITaskbarList3 and IShellLink - #include + #if defined(_MSC_VER) + // Default MSVC headers for ITaskbarList3 and IShellLink + #include + #endif #endif + #include // For HWND -- cgit v1.2.3 From 7ee77cbd26f131ce00cd4a9ddf6515a283b646a3 Mon Sep 17 00:00:00 2001 From: Klaus Reimer Date: Sat, 28 Jan 2012 11:44:31 +0100 Subject: WEBOS: Renamed "Touchpad Mode" to "Trackpad Mode" to prevent confusion because one of the target devices is called the "HP Touchpad". --- backends/events/webossdl/webossdl-events.cpp | 26 +++++++++++++------------- backends/events/webossdl/webossdl-events.h | 6 +++--- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'backends') diff --git a/backends/events/webossdl/webossdl-events.cpp b/backends/events/webossdl/webossdl-events.cpp index 996ac48b15..286289f7a6 100644 --- a/backends/events/webossdl/webossdl-events.cpp +++ b/backends/events/webossdl/webossdl-events.cpp @@ -151,8 +151,8 @@ bool WebOSSdlEventSource::handleMouseButtonDown(SDL_Event &ev, event.type = Common::EVENT_LBUTTONDOWN; processMouseEvent(event, _curX, _curY); } - // If we're not in touchpad mode, move the cursor to the tap - if (!_touchpadMode) { + // If we're not in trackpad mode, move the cursor to the tap + if (!_trackpadMode) { _curX = MIN(_screenX, MAX(0, 0 + ev.motion.x)); _curY = MIN(_screenY, MAX(0, 0 + ev.motion.y)); // If we're already clicking, hold it until after the move. @@ -254,7 +254,7 @@ bool WebOSSdlEventSource::handleMouseMotion(SDL_Event &ev, // If only one finger is on the screen and moving, that's // the mouse pointer. if (!_fingerDown[1] && !_fingerDown[2]) { - if (_touchpadMode) { + if (_trackpadMode) { _curX = MIN(_screenX, MAX(0, _curX + ev.motion.xrel)); _curY = MIN(_screenY, MAX(0, _curY + ev.motion.yrel)); } else { @@ -301,16 +301,16 @@ bool WebOSSdlEventSource::handleMouseMotion(SDL_Event &ev, _queuedEscapeUpTime = g_system->getMillis() + QUEUED_KEY_DELAY; } else if (_dragDiffX[0] > 0 && _dragDiffX[1] > 0) { - // A swipe right toggles touchpad mode - _touchpadMode = !_touchpadMode; - g_system->showMouse(_touchpadMode); - // I18N: Touchpad mode toggle status. - Common::String dialogMsg(_("Touchpad mode is now")); + // A swipe right toggles trackpad mode + _trackpadMode = !_trackpadMode; + g_system->showMouse(_trackpadMode); + // I18N: Trackpad mode toggle status. + Common::String dialogMsg(_("Trackpad mode is now")); dialogMsg += " "; - // I18N: Touchpad mode on or off. - dialogMsg += (_touchpadMode ? _("ON") : _("OFF")); + // I18N: Trackpad mode on or off. + dialogMsg += (_trackpadMode ? _("ON") : _("OFF")); dialogMsg += ".\n"; - // I18N: Instructions to toggle Touchpad mode. + // I18N: Instructions to toggle Trackpad mode. dialogMsg += _("Swipe two fingers to the right to toggle."); GUI::TimedMessageDialog dialog(dialogMsg, 1500); @@ -377,11 +377,11 @@ bool WebOSSdlEventSource::pollEvent(Common::Event &event) { // Set the initial dimensions calculateDimensions(); - // Having a mouse pointer on screen when not in Touchpad mode is poor + // Having a mouse pointer on screen when not in Trackpad mode is poor // interface design, because the user won't know whether to tap buttons // or drag the pointer to them. On the first poll, set the appropriate // pointer visibility. - g_system->showMouse(_touchpadMode); + g_system->showMouse(_trackpadMode); _firstPoll = false; } diff --git a/backends/events/webossdl/webossdl-events.h b/backends/events/webossdl/webossdl-events.h index a36ee535a3..99ed3105f8 100644 --- a/backends/events/webossdl/webossdl-events.h +++ b/backends/events/webossdl/webossdl-events.h @@ -45,7 +45,7 @@ public: _dragStartTime(0), _dragging(false), _curX(0), _curY(0), _screenX(0), _screenY(0), - _touchpadMode(false), _autoDragMode(true), + _trackpadMode(false), _autoDragMode(true), _doClick(true), _queuedDragTime(0), _queuedEscapeUpTime(0), _queuedSpaceUpTime(0), _queuedRUpTime(0), @@ -80,8 +80,8 @@ protected: // The drag distance for linear gestures int _swipeDistX, _swipeDistY; - // Indicates if we're in touchpad mode or tap-to-move mode. - bool _touchpadMode; + // Indicates if we're in trackpad mode or tap-to-move mode. + bool _trackpadMode; // Indicates if we're in automatic drag mode. bool _autoDragMode; -- cgit v1.2.3 From 70d94bdd2c469bd8cd52b8d2367c64130b1679f1 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Thu, 2 Feb 2012 18:52:12 -0600 Subject: KEYMAPPER: Allow simple events to be added to an Action This also simplifies the Action code a little bit --- backends/keymapper/action.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/action.h b/backends/keymapper/action.h index e5bf6d51dd..308a76aa88 100644 --- a/backends/keymapper/action.h +++ b/backends/keymapper/action.h @@ -75,6 +75,13 @@ public: events.push_back(evt); } + void addEvent(const EventType evtType) { + Event evt; + + evt.type = evtType; + events.push_back(evt); + } + void addKeyEvent(const KeyState &ks) { Event evt; @@ -84,24 +91,15 @@ public: } void addLeftClickEvent() { - Event evt; - - evt.type = EVENT_LBUTTONDOWN; - addEvent(evt); + addEvent(EVENT_LBUTTONDOWN); } void addMiddleClickEvent() { - Event evt; - - evt.type = EVENT_MBUTTONDOWN; - addEvent(evt); + addEvent(EVENT_MBUTTONDOWN); } void addRightClickEvent() { - Event evt; - - evt.type = EVENT_RBUTTONDOWN; - addEvent(evt); + addEvent(EVENT_RBUTTONDOWN); } Keymap *getParent() { -- cgit v1.2.3 From a488556dcdfb69ec30af740aa2c71977f505ef35 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Thu, 2 Feb 2012 18:53:14 -0600 Subject: KEYMAPPER: Handle EVENT_MAINMENU directly --- backends/keymapper/keymapper.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'backends') diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index 38711343c2..6d9ae21ef8 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -268,6 +268,9 @@ void Keymapper::executeAction(const Action *action, bool keyDown) { case EVENT_MBUTTONUP: if (keyDown) evt.type = EVENT_MBUTTONDOWN; break; + case EVENT_MAINMENU: + if (!keyDown) evt.type = EVENT_MAINMENU; + break; default: // don't deliver other events on key up if (!keyDown) continue; -- cgit v1.2.3 From 4763b2c51b4c73dae4340993fc9b71200bcdbe28 Mon Sep 17 00:00:00 2001 From: Alyssa Milburn Date: Fri, 3 Feb 2012 12:36:03 +0100 Subject: ANDROID: Add faked input delay. This adds an artificial delay for mouse up events to make engines like Gob work, similar to the iPhone fix in b3062b5e. --- backends/platform/android/android.cpp | 1 + backends/platform/android/android.h | 2 ++ backends/platform/android/events.cpp | 23 +++++++++++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp index aba31320ea..902599d50f 100644 --- a/backends/platform/android/android.cpp +++ b/backends/platform/android/android.cpp @@ -134,6 +134,7 @@ OSystem_Android::OSystem_Android(int audio_sample_rate, int audio_buffer_size) : _enable_zoning(false), _mixer(0), _shake_offset(0), + _queuedEventTime(0), _event_queue_lock(createMutex()), _touch_pt_down(), _touch_pt_scroll(), diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h index f39a8f1144..47a6515a2a 100644 --- a/backends/platform/android/android.h +++ b/backends/platform/android/android.h @@ -220,6 +220,8 @@ public: private: Common::Queue _event_queue; + Common::Event _queuedEvent; + uint32 _queuedEventTime; MutexRef _event_queue_lock; Common::Point _touch_pt_down, _touch_pt_scroll, _touch_pt_dt; diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp index e73e689e3b..b46c144344 100644 --- a/backends/platform/android/events.cpp +++ b/backends/platform/android/events.cpp @@ -216,6 +216,8 @@ static inline T scalef(T in, float numerator, float denominator) { return static_cast(in) * numerator / denominator; } +static const int kQueuedInputEventDelay = 50; + void OSystem_Android::setupKeymapper() { #ifdef ENABLE_KEYMAPPER using namespace Common; @@ -601,13 +603,18 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, lockMutex(_event_queue_lock); + if (_queuedEventTime) + _event_queue.push(_queuedEvent); + if (!_touchpad_mode) _event_queue.push(e); e.type = down; _event_queue.push(e); + e.type = up; - _event_queue.push(e); + _queuedEvent = e; + _queuedEventTime = getMillis() + kQueuedInputEventDelay; unlockMutex(_event_queue_lock); } @@ -702,9 +709,14 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, lockMutex(_event_queue_lock); + if (_queuedEventTime) + _event_queue.push(_queuedEvent); + _event_queue.push(e); + e.type = up; - _event_queue.push(e); + _queuedEvent = e; + _queuedEventTime = getMillis() + kQueuedInputEventDelay; unlockMutex(_event_queue_lock); return; @@ -800,6 +812,13 @@ bool OSystem_Android::pollEvent(Common::Event &event) { lockMutex(_event_queue_lock); + if (_queuedEventTime && (getMillis() > _queuedEventTime)) { + event = _queuedEvent; + _queuedEventTime = 0; + unlockMutex(_event_queue_lock); + return true; + } + if (_event_queue.empty()) { unlockMutex(_event_queue_lock); return false; -- cgit v1.2.3 From 38b8e0906949090d517d1ccab3a852e659ab449e Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 3 Feb 2012 12:19:23 -0600 Subject: MAEMO: Add detection entry for the Nokia 700 running OS2008HE This allows the Nokia 770 running OS2008HE to be used. Fixes bug#3483921 "Volume rocker do no emulate keypress as it used" --- backends/platform/maemo/maemo-common.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'backends') diff --git a/backends/platform/maemo/maemo-common.h b/backends/platform/maemo/maemo-common.h index f33aa24278..5f8645a6b7 100644 --- a/backends/platform/maemo/maemo-common.h +++ b/backends/platform/maemo/maemo-common.h @@ -28,9 +28,10 @@ namespace Maemo { enum ModelType { - kModelTypeN800 = 1, - kModelTypeN810 = 2, - kModelTypeN900 = 4, + kModelType770 = 1, + kModelTypeN800 = 2, + kModelTypeN810 = 4, + kModelTypeN900 = 8, kModelTypeInvalid = 0 }; @@ -42,6 +43,7 @@ struct Model { }; static const Model models[] = { + {"SU-18", kModelType770, "770", false}, {"RX-34", kModelTypeN800, "N800", false}, {"RX-44", kModelTypeN810, "N810", true}, {"RX-48", kModelTypeN810, "N810W", true}, -- cgit v1.2.3 From 07f1d33ef7fea990b851d1e35fcc553380f368e2 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Sat, 4 Feb 2012 20:45:05 -0600 Subject: KEYMAPPER: Fix annoying debug message --- backends/keymapper/remap-dialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 5c339f8c27..445ed67e8a 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -149,7 +149,7 @@ void RemapDialog::reflowLayout() { int labelWidth = colWidth - (keyButtonWidth + spacing + clearButtonWidth + spacing); _rowCount = (areaH + spacing) / (buttonHeight + spacing); - debug("rowCount = %d" , _rowCount); + debug(7, "rowCount = %d" , _rowCount); if (colWidth <= 0 || _rowCount <= 0) error("Remap dialog too small to display any keymaps"); -- cgit v1.2.3 From 9de279b2ab1eb75ca937d63fe337078d1d44cf3d Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Sun, 5 Feb 2012 19:01:51 -0600 Subject: KEYMAPPER: Fix active keymap name displayed in remap dialog This workaround no longer applies and is in fact causing a bug in the name of active keymap --- backends/keymapper/remap-dialog.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 445ed67e8a..8f187778d8 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -307,10 +307,6 @@ void RemapDialog::loadKeymap() { List freeKeys(_keymapper->getHardwareKeys()); int topIndex = activeKeymaps.size() - 1; - // skip the top gui keymap since it is for the keymapper itself - // TODO: Don't use the keymap name as a way to discriminate GUI maps - if (topIndex > 0 && activeKeymaps[topIndex].keymap->getName().equals(kGuiKeymapName)) - --topIndex; // add most active keymap's keys Keymapper::MapRecord top = activeKeymaps[topIndex]; -- cgit v1.2.3 From 38dea529e8bfa3ae88011751f6c35c02dfe61668 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Thu, 9 Feb 2012 02:10:19 -0600 Subject: KEYMAPPER: Display active keymap stack in remap dialog popup list This should make it clear what keymaps are on the stack and in what order. Also renamed the label of the top "special" entry in the list to "(Effective)" since it displays the top keymap's action and also displays reachable mapped actions from other active keymaps. --- backends/keymapper/remap-dialog.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 8f187778d8..bf4144a59f 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -61,7 +61,7 @@ void RemapDialog::open() { const Stack &activeKeymaps = _keymapper->getActiveStack(); if (activeKeymaps.size() > 0) { - _kmPopUp->appendEntry(activeKeymaps.top().keymap->getName() + _(" (Active)")); + _kmPopUp->appendEntry(activeKeymaps.top().keymap->getName() + _(" (Effective)")); divider = true; } @@ -84,6 +84,10 @@ void RemapDialog::open() { keymapCount += _gameKeymaps->size(); } + if (activeKeymaps.size() > 1) { + keymapCount += activeKeymaps.size() - 1; + } + debug(3, "RemapDialog::open keymaps: %d", keymapCount); _keymapTable = (Keymap **)malloc(sizeof(Keymap*) * keymapCount); @@ -91,6 +95,18 @@ void RemapDialog::open() { Keymapper::Domain::iterator it; uint32 idx = 0; + if (activeKeymaps.size() > 1) { + if (divider) + _kmPopUp->appendEntry(""); + int topIndex = activeKeymaps.size() - 1; + for (int i = topIndex - 1; i >= 0; --i) { + Keymapper::MapRecord mr = activeKeymaps[i]; + _kmPopUp->appendEntry(mr.keymap->getName() + _(" (Active)"), idx); + _keymapTable[idx++] = mr.keymap; + } + divider = true; + } + if (_globalKeymaps) { if (divider) _kmPopUp->appendEntry(""); @@ -108,6 +124,7 @@ void RemapDialog::open() { _kmPopUp->appendEntry(it->_value->getName() + _(" (Game)"), idx); _keymapTable[idx++] = it->_value; } + divider = true; } _changes = false; -- cgit v1.2.3 From 06b52994619fb9a7ef9e54e50b5cc67d07f6a0a0 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Thu, 9 Feb 2012 02:42:53 -0600 Subject: KEYMAPPER: Fix re-selecting the top keymap Re-selecting the top entry would always populate the actions from the GUI keymap since it is the active keymap (the remap dialog itself is GUI) The top keymap was correct during RemapDialog::open() because the gui keymap had not been pushed to the stack yet. --- backends/keymapper/remap-dialog.cpp | 9 ++++++++- backends/keymapper/remap-dialog.h | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index bf4144a59f..4b95a1a021 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -39,7 +39,7 @@ enum { }; RemapDialog::RemapDialog() - : Dialog("KeyMapper"), _keymapTable(0), _activeRemapAction(0), _topAction(0), _remapTimeout(0) { + : Dialog("KeyMapper"), _keymapTable(0), _activeRemapAction(0), _topAction(0), _remapTimeout(0), _topKeymapIsGui(false) { _keymapper = g_system->getEventManager()->getKeymapper(); assert(_keymapper); @@ -61,6 +61,8 @@ void RemapDialog::open() { const Stack &activeKeymaps = _keymapper->getActiveStack(); if (activeKeymaps.size() > 0) { + if (activeKeymaps.top().keymap->getName() == Common::kGuiKeymapName) + _topKeymapIsGui = true; _kmPopUp->appendEntry(activeKeymaps.top().keymap->getName() + _(" (Effective)")); divider = true; } @@ -325,6 +327,11 @@ void RemapDialog::loadKeymap() { int topIndex = activeKeymaps.size() - 1; + // This is a WORKAROUND for changing the popup list selected item and changing it back + // to the top entry. Upon changing it back, the top keymap is always "gui". + if (!_topKeymapIsGui && activeKeymaps[topIndex].keymap->getName() == kGuiKeymapName) + --topIndex; + // add most active keymap's keys Keymapper::MapRecord top = activeKeymaps[topIndex]; List::iterator actIt; diff --git a/backends/keymapper/remap-dialog.h b/backends/keymapper/remap-dialog.h index 1cb930bd42..143deca4cf 100644 --- a/backends/keymapper/remap-dialog.h +++ b/backends/keymapper/remap-dialog.h @@ -91,6 +91,8 @@ protected: bool _changes; + bool _topKeymapIsGui; + }; } // End of namespace Common -- cgit v1.2.3 From edc52497726139498bb68e3b3334a792b3602ede Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 10 Feb 2012 21:14:48 -0600 Subject: JANITORIAL: Fix template definition whitespace --- backends/platform/android/events.cpp | 2 +- backends/platform/android/texture.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp index b46c144344..0e116a7145 100644 --- a/backends/platform/android/events.cpp +++ b/backends/platform/android/events.cpp @@ -211,7 +211,7 @@ static const Common::KeyCode jkeymap[] = { }; // floating point. use sparingly -template +template static inline T scalef(T in, float numerator, float denominator) { return static_cast(in) * numerator / denominator; } diff --git a/backends/platform/android/texture.cpp b/backends/platform/android/texture.cpp index e211e5941f..95c96e0d25 100644 --- a/backends/platform/android/texture.cpp +++ b/backends/platform/android/texture.cpp @@ -61,7 +61,7 @@ static inline GLfixed xdiv(int numerator, int denominator) { return (numerator << 16) / denominator; } -template +template static T nextHigher2(T k) { if (k == 0) return 1; -- cgit v1.2.3 From 52da780fbc10200b91d92e7cd04932b101c7539b Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Thu, 9 Feb 2012 01:26:11 -0600 Subject: KEYMAPPER: Refactor HardwareKeySet generation --- backends/keymapper/hardware-key.h | 66 ++++++++++++++++++++++++++++++++-- backends/platform/sdl/hardwarekeys.cpp | 50 ++------------------------ backends/platform/sdl/sdl.h | 5 +++ 3 files changed, 72 insertions(+), 49 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h index 32df042525..713b086791 100644 --- a/backends/keymapper/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -32,7 +32,6 @@ namespace Common { - #define HWKEY_ID_SIZE (30) /** @@ -62,6 +61,27 @@ struct HardwareKey { } }; +/** + * Entry in a static table of available non-modifier keys + */ +struct KeyTableEntry { + const char *hwId; + KeyCode keycode; + uint16 ascii; + const char *desc; + KeyType preferredAction; + bool shiftable; +}; + +/** + * Entry in a static table of available key modifiers + */ +struct ModifierTableEntry { + byte flag; + const char *id; + const char *desc; + bool shiftable; +}; /** * Simple class to encapsulate a device's set of HardwareKeys. @@ -71,6 +91,17 @@ struct HardwareKey { class HardwareKeySet { public: + /** + * Add hardware keys to the set out of key and modifier tables. + * @param keys table of available keys + * @param modifiers table of available modifiers + */ + HardwareKeySet(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) { + addHardwareKeys(keys, modifiers); + } + + HardwareKeySet() { } + virtual ~HardwareKeySet() { List::const_iterator it; @@ -111,6 +142,38 @@ public: return _keys.size(); } + /** + * Add hardware keys to the set out of key and modifier tables. + * @param keys table of available keys + * @param modifiers table of available modifiers + */ + void addHardwareKeys(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) { + const KeyTableEntry *key; + const ModifierTableEntry *mod; + char fullKeyId[50]; + char fullKeyDesc[100]; + uint16 ascii; + + for (mod = modifiers; mod->id; mod++) { + for (key = keys; key->hwId; key++) { + ascii = key->ascii; + + if (mod->shiftable && key->shiftable) { + snprintf(fullKeyId, 50, "%s%c", mod->id, toupper(key->hwId[0])); + snprintf(fullKeyDesc, 100, "%s%c", mod->desc, toupper(key->desc[0])); + ascii = toupper(key->ascii); + } else if (mod->shiftable) { + snprintf(fullKeyId, 50, "S+%s%s", mod->id, key->hwId); + snprintf(fullKeyDesc, 100, "Shift+%s%s", mod->desc, key->desc); + } else { + snprintf(fullKeyId, 50, "%s%s", mod->id, key->hwId); + snprintf(fullKeyDesc, 100, "%s%s", mod->desc, key->desc); + } + + addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc, key->preferredAction )); + } + } + } private: @@ -128,7 +191,6 @@ private: List _keys; }; - } // End of namespace Common #endif // #ifdef ENABLE_KEYMAPPER diff --git a/backends/platform/sdl/hardwarekeys.cpp b/backends/platform/sdl/hardwarekeys.cpp index 9a33e357da..3e9378602e 100644 --- a/backends/platform/sdl/hardwarekeys.cpp +++ b/backends/platform/sdl/hardwarekeys.cpp @@ -28,16 +28,7 @@ using namespace Common; -struct Key { - const char *hwId; - KeyCode keycode; - uint16 ascii; - const char *desc; - KeyType preferredAction; - bool shiftable; -}; - -static const Key keys[] = { +static const KeyTableEntry sdlKeys[] = { {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", kActionKeyType, false}, {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", kActionKeyType, false}, {"CLEAR", KEYCODE_CLEAR, 0, "Clear", kActionKeyType, false}, @@ -173,14 +164,7 @@ static const Key keys[] = { {0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false} }; -struct Mod { - byte flag; - const char *id; - const char *desc; - bool shiftable; -}; - -static const Mod modifiers[] = { +static const ModifierTableEntry sdlModifiers[] = { { 0, "", "", false }, { KBD_CTRL, "C+", "Ctrl+", false }, { KBD_ALT, "A+", "Alt+", false }, @@ -195,35 +179,7 @@ static const Mod modifiers[] = { Common::HardwareKeySet *OSystem_SDL::getHardwareKeySet() { #ifdef ENABLE_KEYMAPPER - HardwareKeySet *keySet = new HardwareKeySet(); - const Key *key; - const Mod *mod; - char fullKeyId[50]; - char fullKeyDesc[100]; - uint16 ascii; - - for (mod = modifiers; mod->id; mod++) { - for (key = keys; key->hwId; key++) { - ascii = key->ascii; - - if (mod->shiftable && key->shiftable) { - snprintf(fullKeyId, 50, "%s%c", mod->id, toupper(key->hwId[0])); - snprintf(fullKeyDesc, 100, "%s%c", mod->desc, toupper(key->desc[0])); - ascii = toupper(key->ascii); - } else if (mod->shiftable) { - snprintf(fullKeyId, 50, "S+%s%s", mod->id, key->hwId); - snprintf(fullKeyDesc, 100, "Shift+%s%s", mod->desc, key->desc); - } else { - snprintf(fullKeyId, 50, "%s%s", mod->id, key->hwId); - snprintf(fullKeyDesc, 100, "%s%s", mod->desc, key->desc); - } - - keySet->addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc, key->preferredAction )); - } - } - - return keySet; - + return new HardwareKeySet(sdlKeys, sdlModifiers); #else return 0; #endif diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 22d79dbfe7..6c84c5c26a 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -30,6 +30,11 @@ #include "backends/events/sdl/sdl-events.h" #include "backends/log/log.h" +namespace Common { +struct KeyTableEntry; +struct ModifierTableEntry; +} + /** * Base OSystem class for all SDL ports. */ -- cgit v1.2.3 From e52f75eaa40b6a8f6f0db3a14a7dabf2e54506d3 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Thu, 9 Feb 2012 01:26:23 -0600 Subject: MAEMO: Define HardwareKeySet --- backends/platform/maemo/maemo-keys.h | 144 +++++++++++++++++++++++++++++++++++ backends/platform/maemo/maemo.cpp | 11 +++ backends/platform/maemo/maemo.h | 1 + 3 files changed, 156 insertions(+) create mode 100644 backends/platform/maemo/maemo-keys.h (limited to 'backends') diff --git a/backends/platform/maemo/maemo-keys.h b/backends/platform/maemo/maemo-keys.h new file mode 100644 index 0000000000..6725b1164d --- /dev/null +++ b/backends/platform/maemo/maemo-keys.h @@ -0,0 +1,144 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#if defined(MAEMO) +#if defined(ENABLE_KEYMAPPER) + +#ifndef PLATFORM_SDL_MAEMO_KEYS_H +#define PLATFORM_SDL_MAEMO_KEYS_H + +#include "common/keyboard.h" + +#include "backends/keymapper/hardware-key.h" + +namespace Common { + +static const ModifierTableEntry maemoModifiers[] = { + { 0, "", "", false }, + { KBD_CTRL, "C+", "Ctrl+", false }, + { KBD_SHIFT, "", "", true }, + { KBD_SHIFT | KBD_CTRL, "S+C+", "Shift+Ctrl+", true }, + { 0, 0, 0, false } +}; + +static const KeyTableEntry maemoKeys[] = { + {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", kActionKeyType, false}, + {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", kActionKeyType, false}, + {"CLEAR", KEYCODE_CLEAR, 0, "Clear", kActionKeyType, false}, + {"RETURN", KEYCODE_RETURN, ASCII_RETURN, "MCenter", kActionKeyType, false}, + {"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", kStartKeyType, false}, + {"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", kActionKeyType, false}, + {"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", kActionKeyType, false}, + {"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", kActionKeyType, false}, + {"HASH", KEYCODE_HASH, '#', "#", kActionKeyType, false}, + {"DOLLAR", KEYCODE_DOLLAR, '$', "$", kActionKeyType, false}, + {"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", kActionKeyType, false}, + {"QUOTE", KEYCODE_QUOTE, '\'', "'", kActionKeyType, false}, + {"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", kActionKeyType, false}, + {"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", kActionKeyType, false}, + {"ASTERISK", KEYCODE_ASTERISK, '*', "*", kActionKeyType, false}, + {"PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, false}, + {"COMMA", KEYCODE_COMMA, ',', ",", kActionKeyType, false}, + {"MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, false}, + {"PERIOD", KEYCODE_PERIOD, '.', ".", kActionKeyType, false}, + {"SLASH", KEYCODE_SLASH, '/', "/", kActionKeyType, false}, + {"0", KEYCODE_0, '0', "0", kActionKeyType, false}, + {"1", KEYCODE_1, '1', "1", kActionKeyType, false}, + {"2", KEYCODE_2, '2', "2", kActionKeyType, false}, + {"3", KEYCODE_3, '3', "3", kActionKeyType, false}, + {"4", KEYCODE_4, '4', "4", kActionKeyType, false}, + {"5", KEYCODE_5, '5', "5", kActionKeyType, false}, + {"6", KEYCODE_6, '6', "6", kActionKeyType, false}, + {"7", KEYCODE_7, '7', "7", kActionKeyType, false}, + {"8", KEYCODE_8, '8', "8", kActionKeyType, false}, + {"9", KEYCODE_9, '9', "9", kActionKeyType, false}, + {"COLON", KEYCODE_COLON, ':', ":", kActionKeyType, false}, + {"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", kActionKeyType, false}, + {"LESS", KEYCODE_LESS, '<', "<", kActionKeyType, false}, + {"EQUALS", KEYCODE_EQUALS, '=', "=", kActionKeyType, false}, + {"GREATER", KEYCODE_GREATER, '>', ">", kActionKeyType, false}, + {"QUESTION", KEYCODE_QUESTION, '?', "?", kActionKeyType, false}, + {"AT", KEYCODE_AT, '@', "@", kActionKeyType, false}, + + {"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", kActionKeyType, false}, + {"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", kActionKeyType, false}, + {"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", kActionKeyType, false}, + {"CARET", KEYCODE_CARET, '^', "^", kActionKeyType, false}, + {"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", kActionKeyType, false}, + {"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", kActionKeyType, false}, + {"a", KEYCODE_a, 'a', "a", kActionKeyType, true}, + {"b", KEYCODE_b, 'b', "b", kActionKeyType, true}, + {"c", KEYCODE_c, 'c', "c", kActionKeyType, true}, + {"d", KEYCODE_d, 'd', "d", kActionKeyType, true}, + {"e", KEYCODE_e, 'e', "e", kActionKeyType, true}, + {"f", KEYCODE_f, 'f', "f", kActionKeyType, true}, + {"g", KEYCODE_g, 'g', "g", kActionKeyType, true}, + {"h", KEYCODE_h, 'h', "h", kActionKeyType, true}, + {"i", KEYCODE_i, 'i', "i", kActionKeyType, true}, + {"j", KEYCODE_j, 'j', "j", kActionKeyType, true}, + {"k", KEYCODE_k, 'k', "k", kActionKeyType, true}, + {"l", KEYCODE_l, 'l', "l", kActionKeyType, true}, + {"m", KEYCODE_m, 'm', "m", kActionKeyType, true}, + {"n", KEYCODE_n, 'n', "n", kActionKeyType, true}, + {"o", KEYCODE_o, 'o', "o", kActionKeyType, true}, + {"p", KEYCODE_p, 'p', "p", kActionKeyType, true}, + {"q", KEYCODE_q, 'q', "q", kActionKeyType, true}, + {"r", KEYCODE_r, 'r', "r", kActionKeyType, true}, + {"s", KEYCODE_s, 's', "s", kActionKeyType, true}, + {"t", KEYCODE_t, 't', "t", kActionKeyType, true}, + {"u", KEYCODE_u, 'u', "u", kActionKeyType, true}, + {"v", KEYCODE_v, 'v', "v", kActionKeyType, true}, + {"w", KEYCODE_w, 'w', "w", kActionKeyType, true}, + {"x", KEYCODE_x, 'x', "x", kActionKeyType, true}, + {"y", KEYCODE_y, 'y', "y", kActionKeyType, true}, + {"z", KEYCODE_z, 'z', "z", kActionKeyType, true}, + {"DELETE", KEYCODE_DELETE, 0, "Del", kActionKeyType, false}, + + {"KP_ENTER", KEYCODE_KP_ENTER, 0, "Enter", kActionKeyType, false}, + + // Arrows + Home/End pad + {"UP", KEYCODE_UP, 0, "Up", kDirUpKeyType, false}, + {"DOWN", KEYCODE_DOWN, 0, "Down", kDirDownKeyType, false}, + {"RIGHT", KEYCODE_RIGHT, 0, "Right", kDirRightKeyType, false}, + {"LEFT", KEYCODE_LEFT, 0, "Left", kDirLeftKeyType, false}, + + // Function keys + {"F1", KEYCODE_F1, ASCII_F1, "F1", kActionKeyType, false}, + {"F2", KEYCODE_F2, ASCII_F2, "F2", kActionKeyType, false}, + {"F3", KEYCODE_F3, ASCII_F3, "F3", kActionKeyType, false}, + {"F4", KEYCODE_F4, ASCII_F4, "Menu", kActionKeyType, false}, + {"F5", KEYCODE_F5, ASCII_F5, "Home", kActionKeyType, false}, + {"F6", KEYCODE_F6, ASCII_F6, "FullScreen", kActionKeyType, false}, + {"F7", KEYCODE_F7, ASCII_F7, "Zoom+", kActionKeyType, false}, + {"F8", KEYCODE_F8, ASCII_F8, "Zoom-", kActionKeyType, false}, + {"F9", KEYCODE_F9, ASCII_F9, "F9", kActionKeyType, false}, + + {0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false} +}; + + +} // namespace Common + +#endif // ifndef PLATFORM_SDL_MAEMO_KEYS_H + +#endif // if defined(ENABLE_KEYMAPPER) +#endif // if defined(MAEMO) diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index 454a13631c..24f5d38e5e 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -28,6 +28,7 @@ #include "common/config-manager.h" #include "backends/platform/maemo/maemo.h" +#include "backends/platform/maemo/maemo-keys.h" #include "backends/events/maemosdl/maemosdl-events.h" #include "backends/graphics/maemosdl/maemosdl-graphics.h" #include "common/textconsole.h" @@ -118,6 +119,16 @@ void OSystem_SDL_Maemo::setupIcon() { // http://bugzilla.libsdl.org/show_bug.cgi?id=586 } +Common::HardwareKeySet *OSystem_SDL_Maemo::getHardwareKeySet() { +#ifdef ENABLE_KEYMAPPER + return new Common::HardwareKeySet(Common::maemoKeys, Common::maemoModifiers); +#else + return OSystem_POSIX::getHardwareKeySet(); +#endif +} + } //namespace Maemo + + #endif diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h index 32b52470bc..44b84cd9b5 100644 --- a/backends/platform/maemo/maemo.h +++ b/backends/platform/maemo/maemo.h @@ -39,6 +39,7 @@ public: virtual void fatalError(); virtual void setWindowCaption(const char *caption); virtual void setupIcon(); + virtual Common::HardwareKeySet *getHardwareKeySet(); Model getModel() { return _model; } -- cgit v1.2.3 From 705761011d24f08eb56add90f6dfa605b36ac8ee Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Thu, 9 Feb 2012 01:26:29 -0600 Subject: KEYMAPPER: Allow ports to define their own global keymap --- backends/keymapper/keymapper.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'backends') diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index 6d9ae21ef8..10cff9418b 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -145,6 +145,8 @@ Keymap *Keymapper::getKeymap(const String& name, bool *globalReturn) { bool Keymapper::pushKeymap(const String& name, bool transparent) { bool global; + + assert(!name.empty()); Keymap *newMap = getKeymap(name, &global); if (!newMap) { -- cgit v1.2.3 From 8c245af35cc2ac3666b631be12e1f130bfbad503 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Thu, 9 Feb 2012 01:26:34 -0600 Subject: MAEMO: Define platform global keymap --- backends/platform/maemo/maemo.cpp | 27 +++++++++++++++++++++++++++ backends/platform/maemo/maemo.h | 1 + 2 files changed, 28 insertions(+) (limited to 'backends') diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index 24f5d38e5e..eae18cc4fd 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -31,7 +31,9 @@ #include "backends/platform/maemo/maemo-keys.h" #include "backends/events/maemosdl/maemosdl-events.h" #include "backends/graphics/maemosdl/maemosdl-graphics.h" +#include "backends/keymapper/keymapper.h" #include "common/textconsole.h" +#include "common/translation.h" #include @@ -127,6 +129,31 @@ Common::HardwareKeySet *OSystem_SDL_Maemo::getHardwareKeySet() { #endif } +Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() { +#ifdef ENABLE_KEYMAPPER + using namespace Common; + Keymap *globalMap = new Keymap("maemo"); + + Action *act; + +// act = new Action(globalMap, "CLKM", _("Click Mode"), kKeyRemapActionType); +// act->addCustomEvent(CLICK_MODE); + + act = new Action(globalMap, "LCLK", _("Left Click"), kKeyRemapActionType); + act->addLeftClickEvent(); + + act = new Action(globalMap, "MCLK", _("Middle Click"), kKeyRemapActionType); + act->addMiddleClickEvent(); + + act = new Action(globalMap, "RCLK", _("Right Click"), kKeyRemapActionType); + act->addRightClickEvent(); + + return globalMap; +#else + return OSystem_POSIX::getGlobalKeymap(); +#endif +} + } //namespace Maemo diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h index 44b84cd9b5..e94c6c603b 100644 --- a/backends/platform/maemo/maemo.h +++ b/backends/platform/maemo/maemo.h @@ -40,6 +40,7 @@ public: virtual void setWindowCaption(const char *caption); virtual void setupIcon(); virtual Common::HardwareKeySet *getHardwareKeySet(); + virtual Common::Keymap *getGlobalKeymap(); Model getModel() { return _model; } -- cgit v1.2.3 From d90d4d10a09e1bab04154aa81162aac9c994f23c Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Thu, 9 Feb 2012 01:26:46 -0600 Subject: MAEMO: Refactor toggle click mode --- backends/events/maemosdl/maemosdl-events.cpp | 12 +++++++++--- backends/events/maemosdl/maemosdl-events.h | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'backends') diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp index 07af368064..d7bda8c8d5 100644 --- a/backends/events/maemosdl/maemosdl-events.cpp +++ b/backends/events/maemosdl/maemosdl-events.cpp @@ -124,9 +124,7 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { debug(9, "remapping to F7 up (virtual keyboard)"); return true; } else { - _clickEnabled = !_clickEnabled; - ((SurfaceSdlGraphicsManager*) _graphicsManager)->displayMessageOnOSD( - _clickEnabled ? _("Clicking Enabled") : _("Clicking Disabled")); + toggleClickMode(); debug(9, "remapping to click toggle"); return true; } @@ -158,6 +156,14 @@ bool MaemoSdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &even return SdlEventSource::handleMouseButtonUp(ev, event); } +bool MaemoSdlEventSource::toggleClickMode() { + _clickEnabled = !_clickEnabled; + ((SurfaceSdlGraphicsManager*) _graphicsManager)->displayMessageOnOSD( + _clickEnabled ? _("Clicking Enabled") : _("Clicking Disabled")); + + return _clickEnabled; +} + } // namespace Maemo #endif // if defined(MAEMO) diff --git a/backends/events/maemosdl/maemosdl-events.h b/backends/events/maemosdl/maemosdl-events.h index 5c06c4bc22..f7b2bbf70b 100644 --- a/backends/events/maemosdl/maemosdl-events.h +++ b/backends/events/maemosdl/maemosdl-events.h @@ -37,6 +37,8 @@ namespace Maemo { class MaemoSdlEventSource : public SdlEventSource { public: MaemoSdlEventSource(); + + bool toggleClickMode(); protected: virtual bool remapKey(SDL_Event &ev, Common::Event &event); virtual bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event); -- cgit v1.2.3 From c2640ed33a1b9c28e58b04877b7c4bf7b5fff570 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Thu, 9 Feb 2012 01:26:42 -0600 Subject: MAEMO: Use custom event Click Mode keymap action --- backends/events/maemosdl/maemosdl-events.cpp | 16 ++++++++++++++++ backends/events/maemosdl/maemosdl-events.h | 9 +++++++++ backends/platform/maemo/maemo-common.h | 5 +++++ backends/platform/maemo/maemo.cpp | 22 ++++++++++++++++++---- backends/platform/maemo/maemo.h | 5 ++++- 5 files changed, 52 insertions(+), 5 deletions(-) (limited to 'backends') diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp index d7bda8c8d5..acca1a3c02 100644 --- a/backends/events/maemosdl/maemosdl-events.cpp +++ b/backends/events/maemosdl/maemosdl-events.cpp @@ -164,6 +164,22 @@ bool MaemoSdlEventSource::toggleClickMode() { return _clickEnabled; } +MaemoSdlEventObserver::MaemoSdlEventObserver(MaemoSdlEventSource *eventSource) { + assert(_eventSource); + _eventSource = eventSource; +} + +bool MaemoSdlEventObserver::notifyEvent(const Common::Event &event) { + if (event.type != Common::EVENT_CUSTOM_BACKEND) + return false; + if (event.customType == kEventClickMode) { + assert(_eventSource); + _eventSource->toggleClickMode(); + return true; + } + return false; +} + } // namespace Maemo #endif // if defined(MAEMO) diff --git a/backends/events/maemosdl/maemosdl-events.h b/backends/events/maemosdl/maemosdl-events.h index f7b2bbf70b..f3f05feeca 100644 --- a/backends/events/maemosdl/maemosdl-events.h +++ b/backends/events/maemosdl/maemosdl-events.h @@ -47,6 +47,15 @@ protected: bool _clickEnabled; }; +class MaemoSdlEventObserver : public Common::EventObserver { +public: + MaemoSdlEventObserver(MaemoSdlEventSource *eventSource); + + virtual bool notifyEvent(const Common::Event &event); +private: + MaemoSdlEventSource *_eventSource; +}; + } // namespace Maemo #endif // include guard diff --git a/backends/platform/maemo/maemo-common.h b/backends/platform/maemo/maemo-common.h index 5f8645a6b7..cd4bb3b027 100644 --- a/backends/platform/maemo/maemo-common.h +++ b/backends/platform/maemo/maemo-common.h @@ -51,6 +51,11 @@ static const Model models[] = { {0, kModelTypeInvalid, 0, true} }; +enum CustomEventType { + kEventClickMode = 1, + kEventInvalid = 0 +}; + } // namespace Maemo #endif // ifndef PLATFORM_SDL_MAEMO_COMMON_H diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index eae18cc4fd..fe60bdc042 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -46,6 +46,10 @@ OSystem_SDL_Maemo::OSystem_SDL_Maemo() OSystem_POSIX() { } +OSystem_SDL_Maemo::~OSystem_SDL_Maemo() { + delete _eventObserver; +} + void OSystem_SDL_Maemo::initBackend() { // Create the events manager if (_eventSource == 0) @@ -54,12 +58,16 @@ void OSystem_SDL_Maemo::initBackend() { if (_graphicsManager == 0) _graphicsManager = new MaemoSdlGraphicsManager(_eventSource); + if (_eventObserver == 0) + _eventObserver = new MaemoSdlEventObserver((MaemoSdlEventSource *)_eventSource); + ConfMan.set("vkeybdpath", DATA_PATH); _model = Model(detectModel()); // Call parent implementation of this method OSystem_POSIX::initBackend(); + initObserver(); } void OSystem_SDL_Maemo::quit() { @@ -136,8 +144,11 @@ Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() { Action *act; -// act = new Action(globalMap, "CLKM", _("Click Mode"), kKeyRemapActionType); -// act->addCustomEvent(CLICK_MODE); + act = new Action(globalMap, "CLKM", _("Click Mode"), kKeyRemapActionType); + Event evt = Event(); + evt.type = EVENT_CUSTOM_BACKEND; + evt.customType = Maemo::kEventClickMode; + act->addEvent(evt); act = new Action(globalMap, "LCLK", _("Left Click"), kKeyRemapActionType); act->addLeftClickEvent(); @@ -154,8 +165,11 @@ Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() { #endif } -} //namespace Maemo - +void OSystem_SDL_Maemo::initObserver() { + assert(_eventManager); + _eventManager->getEventDispatcher()->registerObserver(_eventObserver, 10, false); +} +} //namespace Maemo #endif diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h index e94c6c603b..821f3526e8 100644 --- a/backends/platform/maemo/maemo.h +++ b/backends/platform/maemo/maemo.h @@ -29,10 +29,12 @@ #include "backends/platform/maemo/maemo-common.h" namespace Maemo { +class MaemoSdlEventObserver; class OSystem_SDL_Maemo : public OSystem_POSIX { public: OSystem_SDL_Maemo(); + ~OSystem_SDL_Maemo(); virtual void initBackend(); virtual void quit(); @@ -46,10 +48,11 @@ public: private: virtual void setXWindowName(const char *caption); + void initObserver(); const Model detectModel(); Model _model; - + MaemoSdlEventObserver *_eventObserver; }; } // namespace Maemo -- cgit v1.2.3 From d811240a9d38098f5b1f77b7d8dbef7a947f9a67 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 13 Feb 2012 01:20:02 +0100 Subject: ALL: Enable Keymapper specific OSystem API only when the Keymapper is enabled. --- backends/modular-backend.h | 7 ------- backends/platform/linuxmoto/hardwarekeys.cpp | 3 +-- backends/platform/linuxmoto/linuxmoto-sdl.h | 2 ++ backends/platform/maemo/maemo.cpp | 10 ++-------- backends/platform/maemo/maemo.h | 2 ++ backends/platform/sdl/hardwarekeys.cpp | 7 +------ backends/platform/sdl/sdl.h | 2 ++ backends/platform/webos/webos.cpp | 6 ++---- backends/platform/webos/webos.h | 2 ++ 9 files changed, 14 insertions(+), 27 deletions(-) (limited to 'backends') diff --git a/backends/modular-backend.h b/backends/modular-backend.h index b864da0df5..072ee805b6 100644 --- a/backends/modular-backend.h +++ b/backends/modular-backend.h @@ -105,13 +105,6 @@ public: //@} - /** @name Events and Time */ - //@{ - - virtual Common::HardwareKeySet *getHardwareKeySet() { return 0; } - - //@} - /** @name Mutex handling */ //@{ diff --git a/backends/platform/linuxmoto/hardwarekeys.cpp b/backends/platform/linuxmoto/hardwarekeys.cpp index e10e39a23d..cbd9dccf52 100644 --- a/backends/platform/linuxmoto/hardwarekeys.cpp +++ b/backends/platform/linuxmoto/hardwarekeys.cpp @@ -106,9 +106,8 @@ static const Mod modifiers[] = { { KBD_SHIFT | KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", true }, { 0, 0, 0, false } }; -#endif - Common::HardwareKeySet *OSystem_LINUXMOTO::getHardwareKeySet() { return OSystem_SDL::getHardwareKeySet(); } +#endif diff --git a/backends/platform/linuxmoto/linuxmoto-sdl.h b/backends/platform/linuxmoto/linuxmoto-sdl.h index 97262ccbca..9a0be56e11 100644 --- a/backends/platform/linuxmoto/linuxmoto-sdl.h +++ b/backends/platform/linuxmoto/linuxmoto-sdl.h @@ -29,8 +29,10 @@ class OSystem_LINUXMOTO : public OSystem_POSIX { public: virtual void initBackend(); +#ifdef ENABLE_KEYMAPPER // FIXME: This just calls parent methods, is it needed? virtual Common::HardwareKeySet *getHardwareKeySet(); +#endif }; #endif diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index fe60bdc042..728e8b4023 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -129,16 +129,12 @@ void OSystem_SDL_Maemo::setupIcon() { // http://bugzilla.libsdl.org/show_bug.cgi?id=586 } -Common::HardwareKeySet *OSystem_SDL_Maemo::getHardwareKeySet() { #ifdef ENABLE_KEYMAPPER +Common::HardwareKeySet *OSystem_SDL_Maemo::getHardwareKeySet() { return new Common::HardwareKeySet(Common::maemoKeys, Common::maemoModifiers); -#else - return OSystem_POSIX::getHardwareKeySet(); -#endif } Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() { -#ifdef ENABLE_KEYMAPPER using namespace Common; Keymap *globalMap = new Keymap("maemo"); @@ -160,10 +156,8 @@ Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() { act->addRightClickEvent(); return globalMap; -#else - return OSystem_POSIX::getGlobalKeymap(); -#endif } +#endif void OSystem_SDL_Maemo::initObserver() { assert(_eventManager); diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h index 821f3526e8..382770219b 100644 --- a/backends/platform/maemo/maemo.h +++ b/backends/platform/maemo/maemo.h @@ -41,8 +41,10 @@ public: virtual void fatalError(); virtual void setWindowCaption(const char *caption); virtual void setupIcon(); +#ifdef ENABLE_KEYMAPPER virtual Common::HardwareKeySet *getHardwareKeySet(); virtual Common::Keymap *getGlobalKeymap(); +#endif Model getModel() { return _model; } diff --git a/backends/platform/sdl/hardwarekeys.cpp b/backends/platform/sdl/hardwarekeys.cpp index 3e9378602e..1469698a8b 100644 --- a/backends/platform/sdl/hardwarekeys.cpp +++ b/backends/platform/sdl/hardwarekeys.cpp @@ -174,13 +174,8 @@ static const ModifierTableEntry sdlModifiers[] = { { KBD_SHIFT | KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", true }, { 0, 0, 0, false } }; -#endif - Common::HardwareKeySet *OSystem_SDL::getHardwareKeySet() { -#ifdef ENABLE_KEYMAPPER return new HardwareKeySet(sdlKeys, sdlModifiers); -#else - return 0; -#endif } +#endif diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 6c84c5c26a..1b0204a6e1 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -63,7 +63,9 @@ public: virtual void engineInit(); virtual void engineDone(); #endif +#ifdef ENABLE_KEYMAPPER virtual Common::HardwareKeySet *getHardwareKeySet(); +#endif virtual void quit(); virtual void fatalError(); diff --git a/backends/platform/webos/webos.cpp b/backends/platform/webos/webos.cpp index bfb19ed3bc..abf572e6be 100644 --- a/backends/platform/webos/webos.cpp +++ b/backends/platform/webos/webos.cpp @@ -51,8 +51,8 @@ void OSystem_SDL_WebOS::initBackend() { * * @return The hardware key set with added webOS specific keys. */ -HardwareKeySet *OSystem_SDL_WebOS::getHardwareKeySet() { #ifdef ENABLE_KEYMAPPER +HardwareKeySet *OSystem_SDL_WebOS::getHardwareKeySet() { // Get the original SDL hardware key set HardwareKeySet *keySet = OSystem_SDL::getHardwareKeySet(); @@ -62,9 +62,7 @@ HardwareKeySet *OSystem_SDL_WebOS::getHardwareKeySet() { // Return the modified hardware key set return keySet; -#else - return 0; -#endif } +#endif #endif diff --git a/backends/platform/webos/webos.h b/backends/platform/webos/webos.h index 850aaf9ce2..71390a1d2c 100644 --- a/backends/platform/webos/webos.h +++ b/backends/platform/webos/webos.h @@ -31,7 +31,9 @@ public: OSystem_SDL_WebOS(); virtual void initBackend(); +#ifdef ENABLE_KEYMAPPER virtual Common::HardwareKeySet *getHardwareKeySet(); +#endif }; #endif -- cgit v1.2.3 From 57e3388197ed42aa9a43a9ba4e9ffa4bd8a3ae58 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 13 Feb 2012 01:25:25 +0100 Subject: SDL: Get rid of unneeded forwards. --- backends/platform/sdl/sdl.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'backends') diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 1b0204a6e1..64e63b40a6 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -30,11 +30,6 @@ #include "backends/events/sdl/sdl-events.h" #include "backends/log/log.h" -namespace Common { -struct KeyTableEntry; -struct ModifierTableEntry; -} - /** * Base OSystem class for all SDL ports. */ -- cgit v1.2.3 From 5cf932198e289b8e8d2fe0ee3e57d7cfbf3b65eb Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Mon, 13 Feb 2012 23:24:09 -0600 Subject: KEYMAPPER: Fix Action ctor args in most keymaps --- backends/platform/maemo/maemo.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'backends') diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index 728e8b4023..77d630fc30 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -140,19 +140,19 @@ Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() { Action *act; - act = new Action(globalMap, "CLKM", _("Click Mode"), kKeyRemapActionType); + act = new Action(globalMap, "CLKM", _("Click Mode")); Event evt = Event(); evt.type = EVENT_CUSTOM_BACKEND; evt.customType = Maemo::kEventClickMode; act->addEvent(evt); - act = new Action(globalMap, "LCLK", _("Left Click"), kKeyRemapActionType); + act = new Action(globalMap, "LCLK", _("Left Click"), kLeftClickActionType); act->addLeftClickEvent(); - act = new Action(globalMap, "MCLK", _("Middle Click"), kKeyRemapActionType); + act = new Action(globalMap, "MCLK", _("Middle Click")); act->addMiddleClickEvent(); - act = new Action(globalMap, "RCLK", _("Right Click"), kKeyRemapActionType); + act = new Action(globalMap, "RCLK", _("Right Click"), kRightClickActionType); act->addRightClickEvent(); return globalMap; -- cgit v1.2.3 From 56971f11d1b086fe057e5b658afd318bebb429cc Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 15 Feb 2012 00:14:47 +0100 Subject: OPENGL: Remove redundant check in adjustMousePosition. --- backends/graphics/opengl/opengl-graphics.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'backends') diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index edc7a5f28e..f4ffd47f75 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -1276,15 +1276,13 @@ void OpenGLGraphicsManager::adjustMousePosition(int16 &x, int16 &y) { if (_overlayVisible) return; - if (!_overlayVisible) { - x -= _displayX; - y -= _displayY; - - if (_displayWidth != _videoMode.screenWidth) - x = x * _videoMode.screenWidth / _displayWidth; - if (_displayHeight != _videoMode.screenHeight) - y = y * _videoMode.screenHeight / _displayHeight; - } + x -= _displayX; + y -= _displayY; + + if (_displayWidth != _videoMode.screenWidth) + x = x * _videoMode.screenWidth / _displayWidth; + if (_displayHeight != _videoMode.screenHeight) + y = y * _videoMode.screenHeight / _displayHeight; } bool OpenGLGraphicsManager::saveScreenshot(const char *filename) { -- cgit v1.2.3 From 93435b2e3f2ba79a6f794b0486cb9c0b19e06775 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 15 Feb 2012 00:26:36 +0100 Subject: OPENGL: Unvirtualize all GLTexture methods. --- backends/graphics/opengl/gltexture.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'backends') diff --git a/backends/graphics/opengl/gltexture.h b/backends/graphics/opengl/gltexture.h index d8c42eeb2d..4fa29383f9 100644 --- a/backends/graphics/opengl/gltexture.h +++ b/backends/graphics/opengl/gltexture.h @@ -68,29 +68,29 @@ public: static void initGLExtensions(); GLTexture(byte bpp, GLenum internalFormat, GLenum format, GLenum type); - virtual ~GLTexture(); + ~GLTexture(); /** * Refresh the texture after a context change. The * process will be completed on next allocBuffer call. */ - virtual void refresh(); + void refresh(); /** * Allocates memory needed for the given size. */ - virtual void allocBuffer(GLuint width, GLuint height); + void allocBuffer(GLuint width, GLuint height); /** * Updates the texture pixels. */ - virtual void updateBuffer(const void *buf, int pitch, GLuint x, GLuint y, + void updateBuffer(const void *buf, int pitch, GLuint x, GLuint y, GLuint w, GLuint h); /** * Draws the texture to the screen buffer. */ - virtual void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h); + void drawTexture(GLshort x, GLshort y, GLshort w, GLshort h); /** * Get the texture width. -- cgit v1.2.3 From 864eec8cd264a94a61dc2d700e2bed62b0b457d4 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 15 Feb 2012 00:27:03 +0100 Subject: OPENGL: Make all GLTexture members private. --- backends/graphics/opengl/gltexture.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/graphics/opengl/gltexture.h b/backends/graphics/opengl/gltexture.h index 4fa29383f9..8ff9838ff7 100644 --- a/backends/graphics/opengl/gltexture.h +++ b/backends/graphics/opengl/gltexture.h @@ -113,7 +113,7 @@ public: */ void setFilter(GLint filter) { _filter = filter; } -protected: +private: const byte _bytesPerPixel; const GLenum _internalFormat; const GLenum _glFormat; -- cgit v1.2.3 From beab93e746cb0600c922a68d3ba6409f530a7b38 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 15 Feb 2012 00:42:47 +0100 Subject: OPENGL: Slight formatting fixes. --- backends/graphics/opengl/gltexture.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'backends') diff --git a/backends/graphics/opengl/gltexture.cpp b/backends/graphics/opengl/gltexture.cpp index b7f5c90105..c4d29259b6 100644 --- a/backends/graphics/opengl/gltexture.cpp +++ b/backends/graphics/opengl/gltexture.cpp @@ -11,7 +11,7 @@ * 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 + * 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 @@ -60,8 +60,8 @@ void GLTexture::initGLExtensions() { return; // Get a string with all extensions - const char* ext_string = - reinterpret_cast(glGetString(GL_EXTENSIONS)); + const char *ext_string = + reinterpret_cast(glGetString(GL_EXTENSIONS)); CHECK_GL_ERROR(); Common::StringTokenizer tokenizer(ext_string, " "); // Iterate all string tokens @@ -132,7 +132,7 @@ void GLTexture::allocBuffer(GLuint w, GLuint h) { // Allocate room for the texture glTexImage2D(GL_TEXTURE_2D, 0, _internalFormat, - _textureWidth, _textureHeight, 0, _glFormat, _glType, NULL); CHECK_GL_ERROR(); + _textureWidth, _textureHeight, 0, _glFormat, _glType, NULL); CHECK_GL_ERROR(); _refresh = false; } @@ -148,13 +148,13 @@ void GLTexture::updateBuffer(const void *buf, int pitch, GLuint x, GLuint y, GLu // Check if the buffer has its data contiguously if (static_cast(w) * _bytesPerPixel == pitch) { glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, - _glFormat, _glType, buf); CHECK_GL_ERROR(); + _glFormat, _glType, buf); CHECK_GL_ERROR(); } else { // Update the texture row by row const byte *src = static_cast(buf); do { glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, - w, 1, _glFormat, _glType, src); CHECK_GL_ERROR(); + w, 1, _glFormat, _glType, src); CHECK_GL_ERROR(); ++y; src += pitch; } while (--h); -- cgit v1.2.3 From e5d48797d9866c155e3a4af8a6dd614a8978d428 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 15 Feb 2012 00:44:19 +0100 Subject: OPENGL: Let getGlErrStr return a Common::String. This also makes getGlErrStr use Common::String::format instead of snprintf. --- backends/graphics/opengl/glerrorcheck.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'backends') diff --git a/backends/graphics/opengl/glerrorcheck.cpp b/backends/graphics/opengl/glerrorcheck.cpp index 682207c7ef..439593577d 100644 --- a/backends/graphics/opengl/glerrorcheck.cpp +++ b/backends/graphics/opengl/glerrorcheck.cpp @@ -26,6 +26,7 @@ #include "backends/graphics/opengl/glerrorcheck.h" #include "common/textconsole.h" +#include "common/str.h" #ifdef WIN32 #if defined(ARRAYSIZE) && !defined(_WINDOWS_) @@ -44,7 +45,7 @@ #include #endif -static const char *getGlErrStr(GLenum error) { +static Common::String getGlErrStr(GLenum error) { switch (error) { case GL_NO_ERROR: return "GL_NO_ERROR"; case GL_INVALID_ENUM: return "GL_INVALID_ENUM"; @@ -54,16 +55,13 @@ static const char *getGlErrStr(GLenum error) { case GL_OUT_OF_MEMORY: return "GL_OUT_OF_MEMORY"; } - // FIXME: Convert to use Common::String::format() - static char buf[40]; - snprintf(buf, sizeof(buf), "(Unknown GL error code 0x%x)", error); - return buf; + return Common::String::format("(Unknown GL error code 0x%x)", error); } void checkGlError(const char *file, int line) { GLenum error = glGetError(); if (error != GL_NO_ERROR) - warning("%s:%d: GL error: %s", file, line, getGlErrStr(error)); + warning("%s:%d: GL error: %s", file, line, getGlErrStr(error).c_str()); } #endif -- cgit v1.2.3 From 1f01fb330ca5a621c0a55293762806049ca98c35 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 15 Feb 2012 00:47:08 +0100 Subject: OPENGL: Use C-style casts. --- backends/graphics/opengl/gltexture.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'backends') diff --git a/backends/graphics/opengl/gltexture.cpp b/backends/graphics/opengl/gltexture.cpp index c4d29259b6..ce69dc4aab 100644 --- a/backends/graphics/opengl/gltexture.cpp +++ b/backends/graphics/opengl/gltexture.cpp @@ -60,8 +60,7 @@ void GLTexture::initGLExtensions() { return; // Get a string with all extensions - const char *ext_string = - reinterpret_cast(glGetString(GL_EXTENSIONS)); + const char *ext_string = (const char *)glGetString(GL_EXTENSIONS); CHECK_GL_ERROR(); Common::StringTokenizer tokenizer(ext_string, " "); // Iterate all string tokens @@ -146,12 +145,12 @@ void GLTexture::updateBuffer(const void *buf, int pitch, GLuint x, GLuint y, GLu glBindTexture(GL_TEXTURE_2D, _textureName); CHECK_GL_ERROR(); // Check if the buffer has its data contiguously - if (static_cast(w) * _bytesPerPixel == pitch) { + if ((int)w * _bytesPerPixel == pitch) { glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, h, _glFormat, _glType, buf); CHECK_GL_ERROR(); } else { // Update the texture row by row - const byte *src = static_cast(buf); + const byte *src = (const byte *)buf; do { glTexSubImage2D(GL_TEXTURE_2D, 0, x, y, w, 1, _glFormat, _glType, src); CHECK_GL_ERROR(); -- cgit v1.2.3 From 97760ff10135274c4487ade5fcc999e46a237c16 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 15 Feb 2012 01:48:33 +0100 Subject: OPENGLSDL: Don't cast EventType into int for switch. --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index f2b3168e36..4154b6731b 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -486,7 +486,7 @@ void OpenGLSdlGraphicsManager::toggleFullScreen(int loop) { } bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) { - switch ((int)event.type) { + switch (event.type) { case Common::EVENT_KEYDOWN: if (event.kbd.hasFlags(Common::KBD_ALT)) { // Alt-Return and Alt-Enter toggle full screen mode -- cgit v1.2.3 From 05af37c08e9d359d509a29f7c5a85b70c0c10fdd Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 15 Feb 2012 01:56:59 +0100 Subject: OPENGL: Use tabs instead of spaces for indentation. --- backends/graphics/opengl/opengl-graphics.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'backends') diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index 6ded680eae..17810ddb78 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -316,10 +316,10 @@ protected: */ Common::Array _osdLines; - /** - * Returns the font used for on screen display - */ - virtual const Graphics::Font *getFontOSD(); + /** + * Returns the font used for on screen display + */ + virtual const Graphics::Font *getFontOSD(); /** * Update the OSD texture / surface. -- cgit v1.2.3 From 5b3ebdf43de0bd9f04138a6e841f816f34377021 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 15 Feb 2012 02:09:46 +0100 Subject: OPENGL: Prevent access to a few more members in the SDL OpenGL code. --- backends/graphics/opengl/opengl-graphics.cpp | 4 +--- backends/graphics/opengl/opengl-graphics.h | 19 ++++++++++++++----- backends/graphics/openglsdl/openglsdl-graphics.cpp | 5 ++--- 3 files changed, 17 insertions(+), 11 deletions(-) (limited to 'backends') diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index f4ffd47f75..b69764f7c5 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -594,10 +594,8 @@ void OpenGLGraphicsManager::warpMouse(int x, int y) { scaledY += _displayY; } + setMousePosition(scaledX, scaledY); setInternalMousePosition(scaledX, scaledY); - - _cursorState.x = scaledX; - _cursorState.y = scaledY; } void OpenGLGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { diff --git a/backends/graphics/opengl/opengl-graphics.h b/backends/graphics/opengl/opengl-graphics.h index 17810ddb78..ad8765bab1 100644 --- a/backends/graphics/opengl/opengl-graphics.h +++ b/backends/graphics/opengl/opengl-graphics.h @@ -217,6 +217,7 @@ protected: uint getAspectRatio() const; + void setFormatIsBGR(bool isBGR) { _formatBGR = isBGR; } bool _formatBGR; // @@ -285,6 +286,14 @@ protected: int _cursorTargetScale; bool _cursorNeedsRedraw; + /** + * Set up the mouse position for graphics output. + * + * @param x X coordinate in native coordinates. + * @param y Y coordinate in native coordinates. + */ + void setMousePosition(int x, int y) { _cursorState.x = x; _cursorState.y = y; } + virtual void refreshCursor(); virtual void refreshCursorScale(); @@ -311,11 +320,6 @@ protected: virtual bool saveScreenshot(const char *filename); #ifdef USE_OSD - /** - * The OSD contents. - */ - Common::Array _osdLines; - /** * Returns the font used for on screen display */ @@ -326,6 +330,11 @@ protected: */ void updateOSD(); + /** + * The OSD contents. + */ + Common::Array _osdLines; + GLTexture *_osdTexture; Graphics::Surface _osdSurface; uint8 _osdAlpha; diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index 4154b6731b..53688e2fb5 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -376,7 +376,7 @@ bool OpenGLSdlGraphicsManager::loadGFXMode() { } // Check if the screen is BGR format - _formatBGR = _hwscreen->format->Rshift != 0; + setFormatIsBGR(_hwscreen->format->Rshift != 0); if (isFullscreen) { _lastFullscreenModeWidth = _videoMode.hardwareWidth; @@ -671,8 +671,7 @@ void OpenGLSdlGraphicsManager::transformMouseCoordinates(Common::Point &point) { } void OpenGLSdlGraphicsManager::notifyMousePos(Common::Point mouse) { - _cursorState.x = mouse.x; - _cursorState.y = mouse.y; + setMousePosition(mouse.x, mouse.y); } #endif -- cgit v1.2.3 From b6f7d697090ca6f90d20f0f2d5661cc4c8b71bf2 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 15 Feb 2012 02:10:38 +0100 Subject: OPENGLSDL: Remove HACK in fullscreen toggle mode. Altering the fullscreen state will automatically force a refresh now. --- backends/graphics/openglsdl/openglsdl-graphics.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'backends') diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index 53688e2fb5..b37d631c6d 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -460,10 +460,6 @@ void OpenGLSdlGraphicsManager::toggleFullScreen(int loop) { _activeFullscreenMode = -2; setFullscreenMode(!isFullscreen); } - - // HACK: We need to force a refresh here, since we change the - // fullscreen mode. - _transactionDetails.needRefresh = true; endGFXTransaction(); // Ignore resize events for the next 10 frames -- cgit v1.2.3 From 37e5b209a71af725456a42be2605dea28ffceb84 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 15 Feb 2012 02:21:08 +0100 Subject: OPENGL: More formatting fixes. --- backends/graphics/opengl/opengl-graphics.cpp | 47 ++++++++++++++-------------- 1 file changed, 24 insertions(+), 23 deletions(-) (limited to 'backends') diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index b69764f7c5..cca8058625 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -81,8 +81,8 @@ OpenGLGraphicsManager::~OpenGLGraphicsManager() { bool OpenGLGraphicsManager::hasFeature(OSystem::Feature f) { return - (f == OSystem::kFeatureAspectRatioCorrection) || - (f == OSystem::kFeatureCursorPalette); + (f == OSystem::kFeatureAspectRatioCorrection) || + (f == OSystem::kFeatureCursorPalette); } void OpenGLGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) { @@ -269,9 +269,9 @@ OSystem::TransactionError OpenGLGraphicsManager::endGFXTransaction() { } if (_videoMode.fullscreen == _oldVideoMode.fullscreen && - _videoMode.mode == _oldVideoMode.mode && - _videoMode.screenWidth == _oldVideoMode.screenWidth && - _videoMode.screenHeight == _oldVideoMode.screenHeight) { + _videoMode.mode == _oldVideoMode.mode && + _videoMode.screenWidth == _oldVideoMode.screenWidth && + _videoMode.screenHeight == _oldVideoMode.screenHeight) { _oldVideoMode.setup = false; } @@ -420,7 +420,7 @@ void OpenGLGraphicsManager::setShakePos(int shakeOffset) { _shakePos = shakeOffset; } -void OpenGLGraphicsManager::setFocusRectangle(const Common::Rect& rect) { +void OpenGLGraphicsManager::setFocusRectangle(const Common::Rect &rect) { } void OpenGLGraphicsManager::clearFocusRectangle() { @@ -487,7 +487,8 @@ void OpenGLGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch } if (y < 0) { - h += y; buf -= y * pitch; + h += y; + buf -= y * pitch; y = 0; } @@ -611,7 +612,7 @@ void OpenGLGraphicsManager::setMouseCursor(const byte *buf, uint w, uint h, int // Allocate space for cursor data if (_cursorData.w != w || _cursorData.h != h || - _cursorData.format.bytesPerPixel != _cursorFormat.bytesPerPixel) + _cursorData.format.bytesPerPixel != _cursorFormat.bytesPerPixel) _cursorData.create(w, h, _cursorFormat); // Save cursor data @@ -715,7 +716,7 @@ void OpenGLGraphicsManager::refreshGameScreen() { } else { // Update the texture _gameTexture->updateBuffer((byte *)_screenData.pixels + y * _screenData.pitch + - x * _screenData.format.bytesPerPixel, _screenData.pitch, x, y, w, h); + x * _screenData.format.bytesPerPixel, _screenData.pitch, x, y, w, h); } _screenNeedsRedraw = false; @@ -757,7 +758,7 @@ void OpenGLGraphicsManager::refreshOverlay() { } else { // Update the texture _overlayTexture->updateBuffer((byte *)_overlayData.pixels + y * _overlayData.pitch + - x * _overlayData.format.bytesPerPixel, _overlayData.pitch, x, y, w, h); + x * _overlayData.format.bytesPerPixel, _overlayData.pitch, x, y, w, h); } _overlayNeedsRedraw = false; @@ -1041,10 +1042,10 @@ void OpenGLGraphicsManager::internUpdateScreen() { // Draw the cursor if (_overlayVisible) _cursorTexture->drawTexture(_cursorState.x - _cursorState.rHotX, - _cursorState.y - _cursorState.rHotY, _cursorState.rW, _cursorState.rH); + _cursorState.y - _cursorState.rHotY, _cursorState.rW, _cursorState.rH); else _cursorTexture->drawTexture(_cursorState.x - _cursorState.vHotX, - _cursorState.y - _cursorState.vHotY, _cursorState.vW, _cursorState.vH); + _cursorState.y - _cursorState.vHotY, _cursorState.vW, _cursorState.vH); glPopMatrix(); } @@ -1168,23 +1169,23 @@ void OpenGLGraphicsManager::loadTextures() { if ( #ifdef USE_RGB_COLOR - _transactionDetails.formatChanged || + _transactionDetails.formatChanged || #endif - _oldVideoMode.screenWidth != _videoMode.screenWidth || - _oldVideoMode.screenHeight != _videoMode.screenHeight) + _oldVideoMode.screenWidth != _videoMode.screenWidth || + _oldVideoMode.screenHeight != _videoMode.screenHeight) _screenData.create(_videoMode.screenWidth, _videoMode.screenHeight, #ifdef USE_RGB_COLOR - _screenFormat + _screenFormat #else - Graphics::PixelFormat::createFormatCLUT8() + Graphics::PixelFormat::createFormatCLUT8() #endif - ); + ); if (_oldVideoMode.overlayWidth != _videoMode.overlayWidth || - _oldVideoMode.overlayHeight != _videoMode.overlayHeight) + _oldVideoMode.overlayHeight != _videoMode.overlayHeight) _overlayData.create(_videoMode.overlayWidth, _videoMode.overlayHeight, - _overlayFormat); + _overlayFormat); _screenNeedsRedraw = true; _overlayNeedsRedraw = true; @@ -1261,8 +1262,8 @@ uint OpenGLGraphicsManager::getAspectRatio() const { // ratio correction is enabled, but it's better than the previous 4/3 mode // mess at least... if (_videoMode.aspectRatioCorrection - && ((_videoMode.screenWidth == 320 && _videoMode.screenHeight == 200) - || (_videoMode.screenWidth == 640 && _videoMode.screenHeight == 400))) + && ((_videoMode.screenWidth == 320 && _videoMode.screenHeight == 200) + || (_videoMode.screenWidth == 640 && _videoMode.screenHeight == 400))) return 13333; else if (_videoMode.mode == OpenGL::GFX_NORMAL) return _videoMode.hardwareWidth * 10000 / _videoMode.hardwareHeight; @@ -1355,7 +1356,7 @@ const char *OpenGLGraphicsManager::getCurrentModeName() { #ifdef USE_OSD const Graphics::Font *OpenGLGraphicsManager::getFontOSD() { - return FontMan.getFontByUsage(Graphics::FontManager::kLocalizedFont); + return FontMan.getFontByUsage(Graphics::FontManager::kLocalizedFont); } void OpenGLGraphicsManager::updateOSD() { -- cgit v1.2.3 From dbcd177606818f3b50a4b4700d9789bd0dea862c Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Tue, 14 Feb 2012 23:33:34 -0600 Subject: KEYMAPPER: Make some parameters const --- backends/keymapper/hardware-key.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h index 713b086791..2b9280516a 100644 --- a/backends/keymapper/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -109,7 +109,7 @@ public: delete *it; } - void addHardwareKey(HardwareKey *key) { + void addHardwareKey(const HardwareKey *key) { checkForKey(key); _keys.push_back(key); } @@ -177,7 +177,7 @@ public: private: - void checkForKey(HardwareKey *key) { + void checkForKey(const HardwareKey *key) { List::iterator it; for (it = _keys.begin(); it != _keys.end(); it++) { -- cgit v1.2.3 From 921f602ab8631a9d10e0a173b6b331dbafda564a Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Wed, 15 Feb 2012 00:06:13 -0600 Subject: JANITORIAL: Fix whitespace in pointer template arg --- backends/fs/symbian/symbian-fs.cpp | 8 ++++---- backends/fs/symbian/symbianstream.cpp | 8 ++++---- backends/keymapper/hardware-key.h | 12 ++++++------ backends/keymapper/keymap.cpp | 24 ++++++++++++------------ backends/keymapper/keymap.h | 6 +++--- backends/keymapper/keymapper.cpp | 2 +- backends/keymapper/keymapper.h | 4 ++-- backends/keymapper/remap-dialog.cpp | 8 ++++---- backends/taskbar/win32/win32-taskbar.cpp | 6 +++--- 9 files changed, 39 insertions(+), 39 deletions(-) (limited to 'backends') diff --git a/backends/fs/symbian/symbian-fs.cpp b/backends/fs/symbian/symbian-fs.cpp index 9f70e7a7c9..1beab3c13a 100644 --- a/backends/fs/symbian/symbian-fs.cpp +++ b/backends/fs/symbian/symbian-fs.cpp @@ -70,7 +70,7 @@ SymbianFilesystemNode::SymbianFilesystemNode(const Common::String &path) { TPtrC8 ptr((const unsigned char*)_path.c_str(),_path.size()); fname.Copy(ptr); - if (static_cast(g_system)->FsSession().Entry(fname, fileAttribs) == KErrNone) { + if (static_cast(g_system)->FsSession().Entry(fname, fileAttribs) == KErrNone) { _isValid = true; _isDirectory = fileAttribs.IsDir(); } else { @@ -87,7 +87,7 @@ bool SymbianFilesystemNode::exists() const { TFileName fname; TPtrC8 ptr((const unsigned char*) _path.c_str(), _path.size()); fname.Copy(ptr); - bool fileExists = BaflUtils::FileExists(static_cast (g_system)->FsSession(), fname); + bool fileExists = BaflUtils::FileExists(static_cast (g_system)->FsSession(), fname); if (!fileExists) { TParsePtrC parser(fname); if (parser.PathPresent() && parser.Path().Compare(_L("\\")) == KErrNone && !parser.NameOrExtPresent()) { @@ -125,7 +125,7 @@ bool SymbianFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b if (_isPseudoRoot) { // Drives enumeration - RFs& fs = static_cast(g_system)->FsSession(); + RFs& fs = static_cast(g_system)->FsSession(); TInt driveNumber; TChar driveLetter; TUint driveLetterValue; @@ -170,7 +170,7 @@ bool SymbianFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b if (_path.lastChar() != '\\') fname.Append('\\'); - if (static_cast(g_system)->FsSession().GetDir(fname, KEntryAttNormal|KEntryAttDir, 0, dirPtr) == KErrNone) { + if (static_cast(g_system)->FsSession().GetDir(fname, KEntryAttNormal|KEntryAttDir, 0, dirPtr) == KErrNone) { CleanupStack::PushL(dirPtr); TInt cnt = dirPtr->Count(); for (TInt loop = 0; loop < cnt; loop++) { diff --git a/backends/fs/symbian/symbianstream.cpp b/backends/fs/symbian/symbianstream.cpp index 39249578f7..f4873292b3 100644 --- a/backends/fs/symbian/symbianstream.cpp +++ b/backends/fs/symbian/symbianstream.cpp @@ -70,22 +70,22 @@ TSymbianFileEntry* CreateSymbianFileEntry(const char* name, const char* mode) { switch (mode[0]) { case 'a': - if (fileEntry->_fileHandle.Open(static_cast(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) { - if (fileEntry->_fileHandle.Create(static_cast(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) { + if (fileEntry->_fileHandle.Open(static_cast(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) { + if (fileEntry->_fileHandle.Create(static_cast(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) { delete fileEntry; fileEntry = NULL; } } break; case 'r': - if (fileEntry->_fileHandle.Open(static_cast(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) { + if (fileEntry->_fileHandle.Open(static_cast(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) { delete fileEntry; fileEntry = NULL; } break; case 'w': - if (fileEntry->_fileHandle.Replace(static_cast(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) { + if (fileEntry->_fileHandle.Replace(static_cast(g_system)->FsSession(), tempFileName, fileMode) != KErrNone) { delete fileEntry; fileEntry = NULL; } diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h index 2b9280516a..071a38968f 100644 --- a/backends/keymapper/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -103,7 +103,7 @@ public: HardwareKeySet() { } virtual ~HardwareKeySet() { - List::const_iterator it; + List::const_iterator it; for (it = _keys.begin(); it != _keys.end(); it++) delete *it; @@ -115,7 +115,7 @@ public: } const HardwareKey *findHardwareKey(const char *id) const { - List::const_iterator it; + List::const_iterator it; for (it = _keys.begin(); it != _keys.end(); it++) { if (strncmp((*it)->hwKeyId, id, HWKEY_ID_SIZE) == 0) @@ -125,7 +125,7 @@ public: } const HardwareKey *findHardwareKey(const KeyState& keystate) const { - List::const_iterator it; + List::const_iterator it; for (it = _keys.begin(); it != _keys.end(); it++) { if ((*it)->key == keystate) @@ -134,7 +134,7 @@ public: return 0; } - const List &getHardwareKeys() const { + const List &getHardwareKeys() const { return _keys; } @@ -178,7 +178,7 @@ public: private: void checkForKey(const HardwareKey *key) { - List::iterator it; + List::iterator it; for (it = _keys.begin(); it != _keys.end(); it++) { if (strncmp((*it)->hwKeyId, key->hwKeyId, HWKEY_ID_SIZE) == 0) @@ -188,7 +188,7 @@ private: } } - List _keys; + List _keys; }; } // End of namespace Common diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp index 6fc1b1e08d..bd020937eb 100644 --- a/backends/keymapper/keymap.cpp +++ b/backends/keymapper/keymap.cpp @@ -31,7 +31,7 @@ namespace Common { Keymap::Keymap(const Keymap& km) : _actions(km._actions), _keymap(), _configDomain(0) { - List::iterator it; + List::iterator it; for (it = _actions.begin(); it != _actions.end(); ++it) { const HardwareKey *hwKey = (*it)->getMappedKey(); @@ -43,7 +43,7 @@ Keymap::Keymap(const Keymap& km) : _actions(km._actions), _keymap(), _configDoma } Keymap::~Keymap() { - List::iterator it; + List::iterator it; for (it = _actions.begin(); it != _actions.end(); ++it) delete *it; @@ -57,7 +57,7 @@ void Keymap::addAction(Action *action) { } void Keymap::registerMapping(Action *action, const HardwareKey *hwKey) { - HashMap::iterator it; + HashMap::iterator it; it = _keymap.find(hwKey->key); @@ -82,7 +82,7 @@ Action *Keymap::getAction(const char *id) { } Action *Keymap::findAction(const char *id) { - List::iterator it; + List::iterator it; for (it = _actions.begin(); it != _actions.end(); ++it) { if (strncmp((*it)->id, id, ACTION_ID_SIZE) == 0) @@ -92,7 +92,7 @@ Action *Keymap::findAction(const char *id) { } const Action *Keymap::findAction(const char *id) const { - List::const_iterator it; + List::const_iterator it; for (it = _actions.begin(); it != _actions.end(); ++it) { if (strncmp((*it)->id, id, ACTION_ID_SIZE) == 0) @@ -103,7 +103,7 @@ const Action *Keymap::findAction(const char *id) const { } Action *Keymap::getMappedAction(const KeyState& ks) const { - HashMap::iterator it; + HashMap::iterator it; it = _keymap.find(ks); @@ -158,7 +158,7 @@ void Keymap::saveMappings() { if (!_configDomain) return; - List::const_iterator it; + List::const_iterator it; String prefix = KEYMAP_KEY_PREFIX + _name + "_"; for (it = _actions.begin(); it != _actions.end(); ++it) { @@ -179,7 +179,7 @@ void Keymap::saveMappings() { } bool Keymap::isComplete(const HardwareKeySet *hwKeys) { - List::iterator it; + List::iterator it; bool allMapped = true; uint numberMapped = 0; @@ -201,11 +201,11 @@ bool Keymap::isComplete(const HardwareKeySet *hwKeys) { void Keymap::automaticMapping(HardwareKeySet *hwKeys) { #if 0 //disabling the broken automapper for now // Create copies of action and key lists. - List actions(_actions); - List keys(hwKeys->getHardwareKeys()); + List actions(_actions); + List keys(hwKeys->getHardwareKeys()); - List::iterator actIt; - List::iterator keyIt, selectedKey; + List::iterator actIt; + List::iterator keyIt, selectedKey; // Remove actions and keys from local lists that have already been mapped. actIt = actions.begin(); diff --git a/backends/keymapper/keymap.h b/backends/keymapper/keymap.h index 73f2293653..bbcc4a1926 100644 --- a/backends/keymapper/keymap.h +++ b/backends/keymapper/keymap.h @@ -67,7 +67,7 @@ public: /** * Get the list of all the Actions contained in this Keymap */ - List& getActions() { return _actions; } + List& getActions() { return _actions; } /** * Find the Action that a key is mapped to @@ -137,8 +137,8 @@ private: String _name; Keymap *_parent; - List _actions; - HashMap _keymap; + List _actions; + HashMap _keymap; ConfigManager::Domain *_configDomain; }; diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index 10cff9418b..1c83bb877e 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -217,7 +217,7 @@ bool Keymapper::mapKey(const KeyState& key, bool keyDown) { if (action) _keysDown[key] = action; } else { - HashMap::iterator it = _keysDown.find(key); + HashMap::iterator it = _keysDown.find(key); if (it != _keysDown.end()) { action = it->_value; diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index d2aa89cad6..27e981923b 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -86,7 +86,7 @@ public: /** * Get a list of all registered HardwareKeys */ - const List &getHardwareKeys() const { + const List &getHardwareKeys() const { assert(_hardwareKeys); return _hardwareKeys->getHardwareKeys(); } @@ -196,7 +196,7 @@ private: bool _enabled; Stack _activeMaps; - HashMap _keysDown; + HashMap _keysDown; }; diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 4b95a1a021..6f5716b306 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -323,7 +323,7 @@ void RemapDialog::loadKeymap() { if (!activeKeymaps.empty() && _kmPopUp->getSelected() == 0) { // load active keymaps - List freeKeys(_keymapper->getHardwareKeys()); + List freeKeys(_keymapper->getHardwareKeys()); int topIndex = activeKeymaps.size() - 1; @@ -334,7 +334,7 @@ void RemapDialog::loadKeymap() { // add most active keymap's keys Keymapper::MapRecord top = activeKeymaps[topIndex]; - List::iterator actIt; + List::iterator actIt; debug(3, "RemapDialog::loadKeymap top keymap: %s", top.keymap->getName().c_str()); for (actIt = top.keymap->getActions().begin(); actIt != top.keymap->getActions().end(); ++actIt) { Action *act = *actIt; @@ -351,7 +351,7 @@ void RemapDialog::loadKeymap() { for (int i = topIndex - 1; i >= 0; --i) { Keymapper::MapRecord mr = activeKeymaps[i]; debug(3, "RemapDialog::loadKeymap keymap: %s", mr.keymap->getName().c_str()); - List::iterator keyIt = freeKeys.begin(); + List::iterator keyIt = freeKeys.begin(); while (keyIt != freeKeys.end()) { Action *act = mr.keymap->getMappedAction((*keyIt)->key); @@ -373,7 +373,7 @@ void RemapDialog::loadKeymap() { } else if (_kmPopUp->getSelected() != -1) { Keymap *km = _keymapTable[_kmPopUp->getSelectedTag()]; - List::iterator it; + List::iterator it; for (it = km->getActions().begin(); it != km->getActions().end(); ++it) { ActionInfo info = {*it, false, (*it)->description}; diff --git a/backends/taskbar/win32/win32-taskbar.cpp b/backends/taskbar/win32/win32-taskbar.cpp index 4cc451247b..5c9105b0eb 100644 --- a/backends/taskbar/win32/win32-taskbar.cpp +++ b/backends/taskbar/win32/win32-taskbar.cpp @@ -74,7 +74,7 @@ Win32TaskbarManager::Win32TaskbarManager() : _taskbar(NULL), _count(0), _icon(NU 0, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, - reinterpret_cast (&(_taskbar))); + reinterpret_cast (&(_taskbar))); if (SUCCEEDED(hr)) { // Initialize taskbar object @@ -274,7 +274,7 @@ void Win32TaskbarManager::addRecent(const Common::String &name, const Common::St GetModuleFileNameW(NULL, path, MAX_PATH); // Create a shell link. - if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC, IID_IShellLinkW, reinterpret_cast (&link)))) { + if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC, IID_IShellLinkW, reinterpret_cast (&link)))) { // Convert game name and description to Unicode. LPWSTR game = ansiToUnicode(name.c_str()); LPWSTR desc = ansiToUnicode(description.c_str()); @@ -296,7 +296,7 @@ void Win32TaskbarManager::addRecent(const Common::String &name, const Common::St // The link's display name must be set via property store. IPropertyStore* propStore; - HRESULT hr = link->QueryInterface(IID_IPropertyStore, reinterpret_cast (&(propStore))); + HRESULT hr = link->QueryInterface(IID_IPropertyStore, reinterpret_cast (&(propStore))); if (SUCCEEDED(hr)) { PROPVARIANT pv; pv.vt = VT_LPWSTR; -- cgit v1.2.3 From a4798602d7a025dc13fd253d584dbf29dbec488d Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Wed, 15 Feb 2012 09:53:31 -0600 Subject: JANITORIAL: Fix missing whitespace in pointer cast find -name '*.h' -or -name '*.cpp' | xargs sed -r -i 's@\(([A-Za-z0-9]+)\*\)@(\1 *)@g' This seems to have caught some params as well which is not undesirable IMO. It also caught some strings containing this which is undesirable so I excluded them manually. (engines/sci/engine/kernel_tables.h) --- backends/events/maemosdl/maemosdl-events.cpp | 2 +- backends/fs/symbian/symbian-fs.cpp | 2 +- backends/fs/symbian/symbianstream.cpp | 30 +++++++++++++-------------- backends/fs/windows/windows-fs.cpp | 2 +- backends/keymapper/remap-dialog.cpp | 2 +- backends/platform/bada/application.cpp | 2 +- backends/platform/bada/audio.cpp | 2 +- backends/platform/bada/fs.cpp | 10 ++++----- backends/platform/bada/missing.cpp | 2 +- backends/platform/bada/portdefs.h | 6 +++--- backends/platform/dc/audio.cpp | 2 +- backends/platform/dc/dcloader.cpp | 4 ++-- backends/platform/dc/display.cpp | 14 ++++++------- backends/platform/ds/arm7/source/main.cpp | 18 ++++++++-------- backends/platform/ds/arm9/source/blitters.cpp | 10 ++++----- backends/platform/ds/arm9/source/dsmain.cpp | 6 +++--- backends/platform/iphone/iphone_keyboard.h | 2 +- backends/platform/iphone/osys_video.cpp | 2 +- backends/platform/n64/osys_n64_utilities.cpp | 4 ++-- backends/platform/ps2/DmaPipe.cpp | 6 +++--- backends/platform/ps2/Gs2dScreen.cpp | 18 ++++++++-------- backends/platform/ps2/fileio.cpp | 12 +++++------ backends/platform/ps2/icon.cpp | 8 +++---- backends/platform/ps2/ps2mutex.cpp | 6 +++--- backends/platform/ps2/ps2pad.cpp | 2 +- backends/platform/ps2/systemps2.cpp | 18 ++++++++-------- backends/platform/psp/display_manager.cpp | 8 +++---- backends/platform/sdl/posix/posix.cpp | 4 ++-- backends/platform/wince/wince-sdl.cpp | 12 +++++------ backends/plugins/elf/elf-loader.cpp | 2 +- 30 files changed, 109 insertions(+), 109 deletions(-) (limited to 'backends') diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp index acca1a3c02..c01f175863 100644 --- a/backends/events/maemosdl/maemosdl-events.cpp +++ b/backends/events/maemosdl/maemosdl-events.cpp @@ -158,7 +158,7 @@ bool MaemoSdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &even bool MaemoSdlEventSource::toggleClickMode() { _clickEnabled = !_clickEnabled; - ((SurfaceSdlGraphicsManager*) _graphicsManager)->displayMessageOnOSD( + ((SurfaceSdlGraphicsManager *) _graphicsManager)->displayMessageOnOSD( _clickEnabled ? _("Clicking Enabled") : _("Clicking Disabled")); return _clickEnabled; diff --git a/backends/fs/symbian/symbian-fs.cpp b/backends/fs/symbian/symbian-fs.cpp index 1beab3c13a..fc78f7580b 100644 --- a/backends/fs/symbian/symbian-fs.cpp +++ b/backends/fs/symbian/symbian-fs.cpp @@ -153,7 +153,7 @@ bool SymbianFilesystemNode::getChildren(AbstractFSList &myList, ListMode mode, b sprintf(path,"%c:\\", driveNumber+'A'); SymbianFilesystemNode entry(false); - entry._displayName = (char*) driveString8.PtrZ(); // drive_name + entry._displayName = (char *) driveString8.PtrZ(); // drive_name entry._isDirectory = true; entry._isValid = true; entry._isPseudoRoot = false; diff --git a/backends/fs/symbian/symbianstream.cpp b/backends/fs/symbian/symbianstream.cpp index f4873292b3..fa7842d3b1 100644 --- a/backends/fs/symbian/symbianstream.cpp +++ b/backends/fs/symbian/symbianstream.cpp @@ -96,7 +96,7 @@ TSymbianFileEntry* CreateSymbianFileEntry(const char* name, const char* mode) { } size_t ReadData(const void* ptr, size_t size, size_t numItems, TSymbianFileEntry* handle) { - TSymbianFileEntry* entry = ((TSymbianFileEntry*)(handle)); + TSymbianFileEntry* entry = ((TSymbianFileEntry *)(handle)); TUint32 totsize = size*numItems; TPtr8 pointer ( (unsigned char*) ptr, totsize); @@ -169,29 +169,29 @@ SymbianStdioStream::SymbianStdioStream(void *handle) : _handle(handle) { } SymbianStdioStream::~SymbianStdioStream() { - ((TSymbianFileEntry*)(_handle))->_fileHandle.Close(); + ((TSymbianFileEntry *)(_handle))->_fileHandle.Close(); - delete (TSymbianFileEntry*)(_handle); + delete (TSymbianFileEntry *)(_handle); } bool SymbianStdioStream::err() const { - return ((TSymbianFileEntry*)(_handle))->_lastError != 0; + return ((TSymbianFileEntry *)(_handle))->_lastError != 0; } void SymbianStdioStream::clearErr() { - ((TSymbianFileEntry*)(_handle))->_lastError = 0; - ((TSymbianFileEntry*)(_handle))->_eofReached = 0; + ((TSymbianFileEntry *)(_handle))->_lastError = 0; + ((TSymbianFileEntry *)(_handle))->_eofReached = 0; } bool SymbianStdioStream::eos() const { - TSymbianFileEntry* entry = ((TSymbianFileEntry*)(_handle)); + TSymbianFileEntry* entry = ((TSymbianFileEntry *)(_handle)); return entry->_eofReached != 0; } int32 SymbianStdioStream::pos() const { TInt pos = 0; - TSymbianFileEntry* entry = ((TSymbianFileEntry*)(_handle)); + TSymbianFileEntry* entry = ((TSymbianFileEntry *)(_handle)); entry->_lastError = entry->_fileHandle.Seek(ESeekCurrent, pos); if (entry->_lastError == KErrNone && entry->_inputPos != KErrNotFound) { @@ -204,7 +204,7 @@ int32 SymbianStdioStream::pos() const { int32 SymbianStdioStream::size() const { TInt length = 0; - ((TSymbianFileEntry*)(_handle))->_fileHandle.Size(length); + ((TSymbianFileEntry *)(_handle))->_fileHandle.Size(length); return length; } @@ -214,7 +214,7 @@ bool SymbianStdioStream::seek(int32 offs, int whence) { TSeek seekMode = ESeekStart; TInt pos = offs; - TSymbianFileEntry* entry = ((TSymbianFileEntry*)(_handle)); + TSymbianFileEntry* entry = ((TSymbianFileEntry *)(_handle)); switch (whence) { case SEEK_SET: @@ -246,11 +246,11 @@ uint32 SymbianStdioStream::read(void *ptr, uint32 len) { uint32 SymbianStdioStream::write(const void *ptr, uint32 len) { TPtrC8 pointer( (unsigned char*) ptr, len); - ((TSymbianFileEntry*)(_handle))->_inputPos = KErrNotFound; - ((TSymbianFileEntry*)(_handle))->_lastError = ((TSymbianFileEntry*)(_handle))->_fileHandle.Write(pointer); - ((TSymbianFileEntry*)(_handle))->_eofReached = EFalse; + ((TSymbianFileEntry *)(_handle))->_inputPos = KErrNotFound; + ((TSymbianFileEntry *)(_handle))->_lastError = ((TSymbianFileEntry *)(_handle))->_fileHandle.Write(pointer); + ((TSymbianFileEntry *)(_handle))->_eofReached = EFalse; - if (((TSymbianFileEntry*)(_handle))->_lastError == KErrNone) { + if (((TSymbianFileEntry *)(_handle))->_lastError == KErrNone) { return len; } @@ -258,7 +258,7 @@ uint32 SymbianStdioStream::write(const void *ptr, uint32 len) { } bool SymbianStdioStream::flush() { - ((TSymbianFileEntry*)(_handle))->_fileHandle.Flush(); + ((TSymbianFileEntry *)(_handle))->_fileHandle.Flush(); return true; } diff --git a/backends/fs/windows/windows-fs.cpp b/backends/fs/windows/windows-fs.cpp index c32ad2da94..030f394f81 100644 --- a/backends/fs/windows/windows-fs.cpp +++ b/backends/fs/windows/windows-fs.cpp @@ -87,7 +87,7 @@ void WindowsFilesystemNode::addFile(AbstractFSList &list, ListMode mode, const c char* WindowsFilesystemNode::toAscii(TCHAR *str) { #ifndef UNICODE - return (char*)str; + return (char *)str; #else static char asciiString[MAX_PATH]; WideCharToMultiByte(CP_ACP, 0, str, _tcslen(str) + 1, asciiString, sizeof(asciiString), NULL, NULL); diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 6f5716b306..eb2d4c5441 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -92,7 +92,7 @@ void RemapDialog::open() { debug(3, "RemapDialog::open keymaps: %d", keymapCount); - _keymapTable = (Keymap **)malloc(sizeof(Keymap*) * keymapCount); + _keymapTable = (Keymap **)malloc(sizeof(Keymap *) * keymapCount); Keymapper::Domain::iterator it; uint32 idx = 0; diff --git a/backends/platform/bada/application.cpp b/backends/platform/bada/application.cpp index bf585d2782..ba8e544983 100644 --- a/backends/platform/bada/application.cpp +++ b/backends/platform/bada/application.cpp @@ -68,7 +68,7 @@ void BadaScummVM::OnUserEventReceivedN(RequestId requestId, // assertion failure termination String *message = NULL; if (args) { - message = (String*)args->GetAt(0); + message = (String *)args->GetAt(0); } if (!message) { message = new String("Unknown error"); diff --git a/backends/platform/bada/audio.cpp b/backends/platform/bada/audio.cpp index b868e91357..65a5a80fa5 100644 --- a/backends/platform/bada/audio.cpp +++ b/backends/platform/bada/audio.cpp @@ -238,7 +238,7 @@ void AudioThread::OnAudioOutBufferEndReached(Osp::Media::AudioOut &src) { void AudioThread::OnTimerExpired(Timer &timer) { if (_ready < NUM_AUDIO_BUFFERS) { uint len = _audioBuffer[_head].GetCapacity(); - int samples = _mixer->mixCallback((byte*)_audioBuffer[_head].GetPointer(), len); + int samples = _mixer->mixCallback((byte *)_audioBuffer[_head].GetPointer(), len); if (samples) { _head = (_head + 1) % NUM_AUDIO_BUFFERS; _ready++; diff --git a/backends/platform/bada/fs.cpp b/backends/platform/bada/fs.cpp index 0ae0cde43d..37ca496d18 100644 --- a/backends/platform/bada/fs.cpp +++ b/backends/platform/bada/fs.cpp @@ -170,17 +170,17 @@ uint32 BadaFileStream::read(void *ptr, uint32 len) { uint32 available = bufferLength - bufferIndex; if (len <= available) { // use allocation - memcpy((byte*)ptr, &buffer[bufferIndex], len); + memcpy((byte *)ptr, &buffer[bufferIndex], len); bufferIndex += len; result = len; } else { // use remaining allocation - memcpy((byte*)ptr, &buffer[bufferIndex], available); + memcpy((byte *)ptr, &buffer[bufferIndex], available); uint32 remaining = len - available; result = available; if (remaining) { - result += file->Read(((byte*)ptr) + available, remaining); + result += file->Read(((byte *)ptr) + available, remaining); } bufferIndex = bufferLength = 0; } @@ -192,11 +192,11 @@ uint32 BadaFileStream::read(void *ptr, uint32 len) { if (bufferLength < len) { len = bufferLength; } - memcpy((byte*)ptr, buffer, len); + memcpy((byte *)ptr, buffer, len); result = bufferIndex = len; } } else { - result = file->Read((byte*)ptr, len); + result = file->Read((byte *)ptr, len); bufferIndex = bufferLength = 0; } } else { diff --git a/backends/platform/bada/missing.cpp b/backends/platform/bada/missing.cpp index a5433ec61a..10d45ca4b5 100644 --- a/backends/platform/bada/missing.cpp +++ b/backends/platform/bada/missing.cpp @@ -96,7 +96,7 @@ int sprintf(char *str, const char *format, ...) { char *strdup(const char *strSource) { char *buffer; int len = strlen(strSource) + 1; - buffer = (char*)malloc(len); + buffer = (char *)malloc(len); if (buffer) { memcpy(buffer, strSource, len); } diff --git a/backends/platform/bada/portdefs.h b/backends/platform/bada/portdefs.h index 7d85a9ec35..813c5acde3 100644 --- a/backends/platform/bada/portdefs.h +++ b/backends/platform/bada/portdefs.h @@ -65,9 +65,9 @@ void stderr_vfprintf(void*, const char *format, va_list ap); #undef fputs #undef fflush -#define stderr (void*)0 -#define stdout (void*)1 -#define stdin (void*)2 +#define stderr (void *)0 +#define stdout (void *)1 +#define stdin (void *)2 #define fputs(str, file) #define fflush(file) #define sscanf simple_sscanf diff --git a/backends/platform/dc/audio.cpp b/backends/platform/dc/audio.cpp index 35cb51f349..4f01531486 100644 --- a/backends/platform/dc/audio.cpp +++ b/backends/platform/dc/audio.cpp @@ -59,7 +59,7 @@ void OSystem_Dreamcast::checkSound() if (n<100) return; - _mixer->mixCallback((byte*)temp_sound_buffer, + _mixer->mixCallback((byte *)temp_sound_buffer, 2*SAMPLES_TO_BYTES(n)); if (fillpos+n > curr_ring_buffer_samples) { diff --git a/backends/platform/dc/dcloader.cpp b/backends/platform/dc/dcloader.cpp index 675f7ad8c7..56193c282a 100644 --- a/backends/platform/dc/dcloader.cpp +++ b/backends/platform/dc/dcloader.cpp @@ -385,8 +385,8 @@ void *DLObject::symbol(const char *name) for (int c = symbol_cnt; c--; s++) if ((s->st_info>>4 == 1 || s->st_info>>4 == 2) && strtab[s->st_name] == '_' && !strcmp(name, strtab+s->st_name+1)) { - DBG(("=> %p\n", (void*)s->st_value)); - return (void*)s->st_value; + DBG(("=> %p\n", (void *)s->st_value)); + return (void *)s->st_value; } seterror("Symbol \"%s\" not found.", name); diff --git a/backends/platform/dc/display.cpp b/backends/platform/dc/display.cpp index 76658c6590..e886b55869 100644 --- a/backends/platform/dc/display.cpp +++ b/backends/platform/dc/display.cpp @@ -334,8 +334,8 @@ void OSystem_Dreamcast::updateScreenTextures(void) unsigned short *dst = (unsigned short *)screen_tx[_screen_buffer]; unsigned char *src = screen; - // while ((*((volatile unsigned int *)(void*)0xa05f810c) & 0x3ff) != 200); - // *((volatile unsigned int *)(void*)0xa05f8040) = 0xff0000; + // while ((*((volatile unsigned int *)(void *)0xa05f810c) & 0x3ff) != 200); + // *((volatile unsigned int *)(void *)0xa05f8040) = 0xff0000; if (_screenFormat == 0) for ( int y = 0; y<_screen_h; y++ ) @@ -379,7 +379,7 @@ void OSystem_Dreamcast::updateScreenPolygons(void) struct polygon_list mypoly; struct packed_colour_vertex_list myvertex; - // *((volatile unsigned int *)(void*)0xa05f8040) = 0x00ff00; + // *((volatile unsigned int *)(void *)0xa05f8040) = 0x00ff00; mypoly.cmd = TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_OPAQUE|TA_CMD_POLYGON_SUBLIST| @@ -395,7 +395,7 @@ void OSystem_Dreamcast::updateScreenPolygons(void) mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0; ta_begin_frame(); - // *((volatile unsigned int *)(void*)0xa05f8040) = 0x0000ff; + // *((volatile unsigned int *)(void *)0xa05f8040) = 0x0000ff; ta_commit_list(&mypoly); myvertex.cmd = TA_CMD_VERTEX; @@ -493,12 +493,12 @@ void OSystem_Dreamcast::updateScreenPolygons(void) _softkbd.draw(330.0*sin(0.013*_softkbd_motion) - 320.0, 200.0, 120-_softkbd_motion); - // *((volatile unsigned int *)(void*)0xa05f8040) = 0xffff00; + // *((volatile unsigned int *)(void *)0xa05f8040) = 0xffff00; drawMouse(_ms_cur_x, _ms_cur_y, _ms_cur_w, _ms_cur_h, _ms_buf, _ms_visible); - // *((volatile unsigned int *)(void*)0xa05f8040) = 0xff00ff; + // *((volatile unsigned int *)(void *)0xa05f8040) = 0xff00ff; ta_commit_frame(); - // *((volatile unsigned int *)(void*)0xa05f8040) = 0x0; + // *((volatile unsigned int *)(void *)0xa05f8040) = 0x0; _last_screen_refresh = Timer(); } diff --git a/backends/platform/ds/arm7/source/main.cpp b/backends/platform/ds/arm7/source/main.cpp index 2e9cacc669..6e714b22fa 100644 --- a/backends/platform/ds/arm7/source/main.cpp +++ b/backends/platform/ds/arm7/source/main.cpp @@ -46,10 +46,10 @@ #include "cartreset_nolibfat.h" -#define TOUCH_CAL_X1 (*(vs16*)0x027FFCD8) -#define TOUCH_CAL_Y1 (*(vs16*)0x027FFCDA) -#define TOUCH_CAL_X2 (*(vs16*)0x027FFCDE) -#define TOUCH_CAL_Y2 (*(vs16*)0x027FFCE0) +#define TOUCH_CAL_X1 (*(vs16 *)0x027FFCD8) +#define TOUCH_CAL_Y1 (*(vs16 *)0x027FFCDA) +#define TOUCH_CAL_X2 (*(vs16 *)0x027FFCDE) +#define TOUCH_CAL_Y2 (*(vs16 *)0x027FFCE0) #define SCREEN_WIDTH 256 #define SCREEN_HEIGHT 192 s32 TOUCH_WIDTH = TOUCH_CAL_X2 - TOUCH_CAL_X1; @@ -71,10 +71,10 @@ int temp; int adpcmBufferNum = 0; // those are pixel positions of the two points you click when calibrating -#define TOUCH_CNTRL_X1 (*(vu8*)0x027FFCDC) -#define TOUCH_CNTRL_Y1 (*(vu8*)0x027FFCDD) -#define TOUCH_CNTRL_X2 (*(vu8*)0x027FFCE2) -#define TOUCH_CNTRL_Y2 (*(vu8*)0x027FFCE3) +#define TOUCH_CNTRL_X1 (*(vu8 *)0x027FFCDC) +#define TOUCH_CNTRL_Y1 (*(vu8 *)0x027FFCDD) +#define TOUCH_CNTRL_X2 (*(vu8 *)0x027FFCE2) +#define TOUCH_CNTRL_Y2 (*(vu8 *)0x027FFCE3) ////////////////////////////////////////////////////////////////////// @@ -330,7 +330,7 @@ void performSleep() { // int saveInts = REG_IE; // REG_IE = (1 << 22) | IRQ_VBLANK; // Lid open -// *((u32*) (0x0380FFF8)) = *((u32*) (0x0380FFF8)) | (REG_IE & REG_IF); +// *((u32 *) (0x0380FFF8)) = *((u32 *) (0x0380FFF8)) | (REG_IE & REG_IF); // VBLANK_INTR_WAIT_FLAGS = IRQ_VBLANK; diff --git a/backends/platform/ds/arm9/source/blitters.cpp b/backends/platform/ds/arm9/source/blitters.cpp index 0076b302fd..1e8d56615d 100644 --- a/backends/platform/ds/arm9/source/blitters.cpp +++ b/backends/platform/ds/arm9/source/blitters.cpp @@ -222,8 +222,8 @@ static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3 u32 d10 = 0x80008000 | (rd1 << 26) | (gd1 << 21) | (bd1 << 16) | (rd0 << 10) | (gd0 << 5) | bd0; u32 d32 = 0x80008000 | (rd3 << 26) | (gd3 << 21) | (bd3 << 16) | (rd2 << 10) | (gd2 << 5) | bd2; - ((u32*)dest)[0] = d10; - ((u32*)dest)[1] = d32; + ((u32 *)dest)[0] = d10; + ((u32 *)dest)[1] = d32; } #else static inline void RescaleBlock_5x1555_To_4x1555( u16 s0, u16 s1, u16 s2, u16 s3, u16 s4, @@ -290,7 +290,7 @@ static inline void RescaleBlock_5x8888_To_4x1555( u32 s0, u32 s1, u32 s2, u32 s3 gd0 = DIV_BY_5[gd0]; gd1 = DIV_BY_5[gd1]; bd0 = DIV_BY_5[bd0]; bd1 = DIV_BY_5[bd1]; u32 d10 = 0x80008000 | (rd1 << 26) | (gd1 << 21) | (bd1 << 16) | (rd0 << 10) | (gd0 << 5) | bd0; - ((u32*)dest)[0] = d10; + ((u32 *)dest)[0] = d10; u32 d2 = 2*s2 + 2*s3 + s3; u32 d3 = s3 + 4*s4; @@ -307,7 +307,7 @@ static inline void RescaleBlock_5x8888_To_4x1555( u32 s0, u32 s1, u32 s2, u32 s3 bd2 = DIV_BY_5[bd2]; bd3 = DIV_BY_5[bd3]; u32 d32 = 0x80008000 | (rd3 << 26) | (gd3 << 21) | (bd3 << 16) | (rd2 << 10) | (gd2 << 5) | bd2; - ((u32*)dest)[1] = d32; + ((u32 *)dest)[1] = d32; } // Can't work in place @@ -377,7 +377,7 @@ void Rescale_320x256xPAL8_To_256x256x1555(u16 *dest, const u8 *src, int destStri void Rescale_320x256xPAL8_To_256x256x1555(u16 *dest, const u8 *src, int destStride, int srcStride, const u16 *palette) { u16 fastRam[256]; for (size_t i = 0; i < 128; ++i) - ((u32*)fastRam)[i] = ((const u32*)palette)[i]; + ((u32 *)fastRam)[i] = ((const u32*)palette)[i]; for (size_t i = 0; i < 200; ++i) { Rescale_320xPAL8Scanline_To_256x1555Scanline(dest + i*destStride, src + i *srcStride, fastRam); diff --git a/backends/platform/ds/arm9/source/dsmain.cpp b/backends/platform/ds/arm9/source/dsmain.cpp index dfd906d816..cedbdcb167 100644 --- a/backends/platform/ds/arm9/source/dsmain.cpp +++ b/backends/platform/ds/arm9/source/dsmain.cpp @@ -926,7 +926,7 @@ void displayMode16Bit() { SUB_BG0_Y0 = 0; consoleInit(NULL, 0, BgType_Text4bpp, BgSize_T_256x256, 4, 0, false, true); -// consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(4), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); +// consoleInitDefault((u16 *)SCREEN_BASE_BLOCK_SUB(4), (u16 *)CHAR_BASE_BLOCK_SUB(0), 16); for (int r = 0; r < 32 * 32; r++) { ((u16 *) SCREEN_BASE_BLOCK_SUB(4))[r] = buffer[r]; @@ -2414,7 +2414,7 @@ void initHardware() { BG_PALETTE[255] = RGB15(31,31,31);//by default font will be rendered with color 255 //consoleInit() is a lot more flexible but this gets you up and running quick -// consoleInitDefault((u16*)SCREEN_BASE_BLOCK(0), (u16*)CHAR_BASE_BLOCK(1), 16); +// consoleInitDefault((u16 *)SCREEN_BASE_BLOCK(0), (u16 *)CHAR_BASE_BLOCK(1), 16); //consolePrintSet(0, 6); //irqs are nice @@ -2886,7 +2886,7 @@ void dsExceptionHandler() { setExceptionHandler(NULL); u32 currentMode = getCPSR() & 0x1f; - u32 thumbState = ((*(u32*)0x027FFD90) & 0x20); + u32 thumbState = ((*(u32 *)0x027FFD90) & 0x20); u32 codeAddress, exceptionAddress = 0; diff --git a/backends/platform/iphone/iphone_keyboard.h b/backends/platform/iphone/iphone_keyboard.h index eecad09398..c4b4a9a2a7 100644 --- a/backends/platform/iphone/iphone_keyboard.h +++ b/backends/platform/iphone/iphone_keyboard.h @@ -29,7 +29,7 @@ } - (id)initWithFrame:(CGRect)frame; -- (UITextView*)inputView; +- (UITextView *)inputView; - (void)setInputDelegate:(id)delegate; - (void)handleKeyPress:(unichar)c; diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index fa425b108a..f9ae5ea06b 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -466,7 +466,7 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot int texWidth = getSizeNextPOT(w); int texHeight = getSizeNextPOT(h); int bufferSize = texWidth * texHeight * sizeof(int16); - int16* mouseBuf = (int16*)malloc(bufferSize); + int16* mouseBuf = (int16 *)malloc(bufferSize); memset(mouseBuf, 0, bufferSize); for (uint x = 0; x < w; ++x) { diff --git a/backends/platform/n64/osys_n64_utilities.cpp b/backends/platform/n64/osys_n64_utilities.cpp index 94d727e421..f007a1bd25 100644 --- a/backends/platform/n64/osys_n64_utilities.cpp +++ b/backends/platform/n64/osys_n64_utilities.cpp @@ -100,9 +100,9 @@ void refillAudioBuffers(void) { Audio::MixerImpl *localmixer = (Audio::MixerImpl *)osys->getMixer(); while (_requiredSoundSlots) { - sndBuf = (byte*)getAIBuffer(); + sndBuf = (byte *)getAIBuffer(); - localmixer->mixCallback((byte*)sndBuf, osys->_audioBufferSize); + localmixer->mixCallback((byte *)sndBuf, osys->_audioBufferSize); putAIBuffer(); diff --git a/backends/platform/ps2/DmaPipe.cpp b/backends/platform/ps2/DmaPipe.cpp index c6f6ab72ac..a346a67566 100644 --- a/backends/platform/ps2/DmaPipe.cpp +++ b/backends/platform/ps2/DmaPipe.cpp @@ -48,7 +48,7 @@ private: DmaPipe::DmaPipe(uint32 size) { size &= ~0x1F; - _buf = (uint64*)memalign(64, size); + _buf = (uint64 *)memalign(64, size); _curPipe = 0; _pipes[0] = new SinglePipe(_buf, size >> 4); _pipes[1] = new SinglePipe(_buf + (size >> 4), size >> 4); @@ -260,7 +260,7 @@ void SinglePipe::init(void) { _buf[0] = 0x0000000070000000; _buf[1] = 0; _chainHead = _buf; - _chainSize = (uint16*)_chainHead; + _chainSize = (uint16 *)_chainHead; _bufPos = _buf + 2; } @@ -272,7 +272,7 @@ void SinglePipe::appendChain(uint64 dmaTag) { _chainHead = _bufPos; _chainHead[0] = dmaTag; _chainHead[1] = 0; - _chainSize = (uint16*)_chainHead; + _chainSize = (uint16 *)_chainHead; _bufPos += 2; } diff --git a/backends/platform/ps2/Gs2dScreen.cpp b/backends/platform/ps2/Gs2dScreen.cpp index b70e8b13fa..8df6198c38 100644 --- a/backends/platform/ps2/Gs2dScreen.cpp +++ b/backends/platform/ps2/Gs2dScreen.cpp @@ -130,9 +130,9 @@ Gs2dScreen::Gs2dScreen(uint16 width, uint16 height, TVMode tvMode) { _height = height; _pitch = (width + 127) & ~127; - _screenBuf = (uint8*)memalign(64, _width * _height); - _overlayBuf = (uint16*)memalign(64, _width * _height * 2); - _clut = (uint32*)memalign(64, 256 * 4); + _screenBuf = (uint8 *)memalign(64, _width * _height); + _overlayBuf = (uint16 *)memalign(64, _width * _height * 2); + _clut = (uint32 *)memalign(64, 256 * 4); memset(_screenBuf, 0, _width * _height); memset(_clut, 0, 256 * sizeof(uint32)); @@ -291,11 +291,11 @@ void Gs2dScreen::quit(void) { } void Gs2dScreen::createAnimTextures(void) { - uint8 *buf = (uint8*)memalign(64, 16 * 64); + uint8 *buf = (uint8 *)memalign(64, 16 * 64); memset(buf, 0, 16 * 64); uint32 vramDest = _texPtrs[TEXT]; for (int i = 0; i < 16; i++) { - uint32 *destPos = (uint32*)buf; + uint32 *destPos = (uint32 *)buf; for (int ch = 15; ch >= 0; ch--) { const uint32 *src = (const uint32*)(_binaryData + ((_binaryPattern[i] >> ch) & 1) * 4 * 14); for (int line = 0; line < 14; line++) @@ -331,8 +331,8 @@ void Gs2dScreen::newScreenSize(uint16 width, uint16 height) { // malloc new buffers free(_screenBuf); free(_overlayBuf); - _screenBuf = (uint8*)memalign(64, _width * _height); - _overlayBuf = (uint16*)memalign(64, _width * _height * 2); + _screenBuf = (uint8 *)memalign(64, _width * _height); + _overlayBuf = (uint16 *)memalign(64, _width * _height * 2); memset(_screenBuf, 0, _width * height); memset(_overlayBuf, 0, _width * height * 2); memset(_clut, 0, 256 * sizeof(uint32)); @@ -556,7 +556,7 @@ void Gs2dScreen::copyPrintfOverlay(const uint8 *buf) { } void Gs2dScreen::clearPrintfOverlay(void) { - uint8 *tmpBuf = (uint8*)memalign(64, 320 * 200); + uint8 *tmpBuf = (uint8 *)memalign(64, 320 * 200); memset(tmpBuf, 4, 320 * 200); _dmaPipe->uploadTex(_texPtrs[PRINTF], 3 * 128, 0, 0, GS_PSMT8H, tmpBuf, 320, 200); _dmaPipe->flush(); @@ -619,7 +619,7 @@ void Gs2dScreen::setMouseOverlay(const uint8 *buf, uint16 width, uint16 height, _mTraCol = transpCol; _clutChanged = true; } - uint8 *bufCopy = (uint8*)memalign(64, M_SIZE * M_SIZE); // make a copy to align to 64 bytes + uint8 *bufCopy = (uint8 *)memalign(64, M_SIZE * M_SIZE); // make a copy to align to 64 bytes memset(bufCopy, _mTraCol, M_SIZE * M_SIZE); for (int cnt = 0; cnt < height; cnt++) memcpy(bufCopy + cnt * M_SIZE, buf + cnt * width, width); diff --git a/backends/platform/ps2/fileio.cpp b/backends/platform/ps2/fileio.cpp index ef01f3a693..1ec16a3817 100644 --- a/backends/platform/ps2/fileio.cpp +++ b/backends/platform/ps2/fileio.cpp @@ -52,7 +52,7 @@ Ps2File::Ps2File() { _eof = false; _err = false; - _cacheBuf = (uint8*)memalign(64, CACHE_SIZE * 2); + _cacheBuf = (uint8 *)memalign(64, CACHE_SIZE * 2); _cacheOpRunning = 0; _filePos = _physFilePos = _cachePos = 0; @@ -362,7 +362,7 @@ uint32 Ps2File::read(void *dest, uint32 len) { _eof = true; } - uint8 *destBuf = (uint8*)dest; + uint8 *destBuf = (uint8 *)dest; if ((_filePos < _cachePos) || (_filePos + len > _cachePos + _bytesInCache)) cacheReadSync(); // we have to read from CD, sync cache. @@ -413,7 +413,7 @@ uint32 Ps2File::read(void *dest, uint32 len) { #ifdef __PS2_FILE_SEMA__ SignalSema(_sema); #endif - return destBuf - (uint8*)dest; + return destBuf - (uint8 *)dest; } uint32 Ps2File::write(const void *src, uint32 len) { @@ -518,7 +518,7 @@ FILE *ps2_fopen(const char *fname, const char *mode) { } int ps2_fclose(FILE *stream) { - Ps2File *file = (Ps2File*)stream; + Ps2File *file = (Ps2File *)stream; delete file; @@ -528,10 +528,10 @@ int ps2_fclose(FILE *stream) { size_t ps2_fread(void *buf, size_t r, size_t n, FILE *stream) { assert(r != 0); - return ((Ps2File*)stream)->read(buf, r * n) / r; + return ((Ps2File *)stream)->read(buf, r * n) / r; } size_t ps2_fwrite(const void *buf, size_t r, size_t n, FILE *stream) { assert(r != 0); - return ((Ps2File*)stream)->write(buf, r * n) / r; + return ((Ps2File *)stream)->write(buf, r * n) / r; } diff --git a/backends/platform/ps2/icon.cpp b/backends/platform/ps2/icon.cpp index 9852e6d40b..bda4843647 100644 --- a/backends/platform/ps2/icon.cpp +++ b/backends/platform/ps2/icon.cpp @@ -960,13 +960,13 @@ void PS2Icon::setup(mcIcon *icon) { memcpy(icon->head, "PS2D", 4); icon->nlOffset = strlen(_info) + 1; strcpy(title, _info); - strcpy_sjis((short*)&(icon->title), title); + strcpy_sjis((short *)&(icon->title), title); icon->trans = 0x10; memcpy(icon->bgCol, _bgcolor, sizeof(_bgcolor)); memcpy(icon->lightDir, _lightdir, sizeof(_lightdir)); memcpy(icon->lightCol, _lightcol, sizeof(_lightcol)); memcpy(icon->lightAmbient, _ambient, sizeof(_ambient)); - strcpy((char*)icon->view, "scummvm.icn"); - strcpy((char*)icon->copy, "scummvm.icn"); - strcpy((char*)icon->del, "scummvm.icn"); + strcpy((char *)icon->view, "scummvm.icn"); + strcpy((char *)icon->copy, "scummvm.icn"); + strcpy((char *)icon->del, "scummvm.icn"); } diff --git a/backends/platform/ps2/ps2mutex.cpp b/backends/platform/ps2/ps2mutex.cpp index 5b30fa7862..ae63fe5724 100644 --- a/backends/platform/ps2/ps2mutex.cpp +++ b/backends/platform/ps2/ps2mutex.cpp @@ -57,7 +57,7 @@ OSystem::MutexRef OSystem_PS2::createMutex(void) { void OSystem_PS2::lockMutex(MutexRef mutex) { WaitSema(_mutexSema); - Ps2Mutex *sysMutex = (Ps2Mutex*)mutex; + Ps2Mutex *sysMutex = (Ps2Mutex *)mutex; int tid = GetThreadId(); assert(tid != 0); @@ -75,7 +75,7 @@ void OSystem_PS2::lockMutex(MutexRef mutex) { void OSystem_PS2::unlockMutex(MutexRef mutex) { WaitSema(_mutexSema); - Ps2Mutex *sysMutex = (Ps2Mutex*)mutex; + Ps2Mutex *sysMutex = (Ps2Mutex *)mutex; int tid = GetThreadId(); if (sysMutex->owner && sysMutex->count && (sysMutex->owner == tid)) @@ -90,7 +90,7 @@ void OSystem_PS2::unlockMutex(MutexRef mutex) { void OSystem_PS2::deleteMutex(MutexRef mutex) { WaitSema(_mutexSema); - Ps2Mutex *sysMutex = (Ps2Mutex*)mutex; + Ps2Mutex *sysMutex = (Ps2Mutex *)mutex; if (sysMutex->owner || sysMutex->count) printf("WARNING: Deleting LOCKED mutex!\n"); DeleteSema(sysMutex->sema); diff --git a/backends/platform/ps2/ps2pad.cpp b/backends/platform/ps2/ps2pad.cpp index eeb9dfbd93..b6afc217e6 100644 --- a/backends/platform/ps2/ps2pad.cpp +++ b/backends/platform/ps2/ps2pad.cpp @@ -30,7 +30,7 @@ Ps2Pad::Ps2Pad(OSystem_PS2 *system) { _system = system; - _padBuf = (uint8*)memalign(64, 256); + _padBuf = (uint8 *)memalign(64, 256); _padStatus = STAT_NONE; padInit(0); // initialize library diff --git a/backends/platform/ps2/systemps2.cpp b/backends/platform/ps2/systemps2.cpp index 481227dd02..d4e993da63 100644 --- a/backends/platform/ps2/systemps2.cpp +++ b/backends/platform/ps2/systemps2.cpp @@ -384,8 +384,8 @@ void OSystem_PS2::initTimer(void) { ee_thread_t timerThread, soundThread, thisThread; ReferThreadStatus(GetThreadId(), &thisThread); - _timerStack = (uint8*)malloc(TIMER_STACK_SIZE); - _soundStack = (uint8*)malloc(SOUND_STACK_SIZE); + _timerStack = (uint8 *)malloc(TIMER_STACK_SIZE); + _soundStack = (uint8 *)malloc(SOUND_STACK_SIZE); // give timer thread a higher priority than main thread timerThread.initial_priority = thisThread.current_priority - 1; @@ -435,7 +435,7 @@ void OSystem_PS2::timerThreadCallback(void) { } void OSystem_PS2::soundThreadCallback(void) { - int16 *soundBufL = (int16*)memalign(64, SMP_PER_BLOCK * sizeof(int16) * 2); + int16 *soundBufL = (int16 *)memalign(64, SMP_PER_BLOCK * sizeof(int16) * 2); int16 *soundBufR = soundBufL + SMP_PER_BLOCK; int bufferedSamples = 0; @@ -453,9 +453,9 @@ void OSystem_PS2::soundThreadCallback(void) { if (bufferedSamples <= 8 * SMP_PER_BLOCK) { // we have to produce more samples, call sound mixer // the scratchpad at 0x70000000 is used as temporary soundbuffer - //_scummSoundProc(_scummSoundParam, (uint8*)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); - // Audio::Mixer::mixCallback(_scummMixer, (byte*)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); - _scummMixer->mixCallback((byte*)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); + //_scummSoundProc(_scummSoundParam, (uint8 *)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); + // Audio::Mixer::mixCallback(_scummMixer, (byte *)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); + _scummMixer->mixCallback((byte *)0x70000000, SMP_PER_BLOCK * 2 * sizeof(int16)); // demux data into 2 buffers, L and R __asm__ ( @@ -635,7 +635,7 @@ void OSystem_PS2::clearOverlay(void) { } void OSystem_PS2::grabOverlay(OverlayColor *buf, int pitch) { - _screen->grabOverlay((uint16*)buf, (uint16)pitch); + _screen->grabOverlay((uint16 *)buf, (uint16)pitch); } void OSystem_PS2::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { @@ -738,12 +738,12 @@ void OSystem_PS2::msgPrintf(int millis, const char *format, ...) { lnSta = lnEnd + 1; } - uint8 *scrBuf = (uint8*)memalign(64, 320 * 200); + uint8 *scrBuf = (uint8 *)memalign(64, 320 * 200); memset(scrBuf, 4, 320 * 200); uint8 *dstPos = scrBuf + ((200 - posY) >> 1) * 320 + (320 - maxWidth) / 2; for (int y = 0; y < posY; y++) { - uint8 *srcPos = (uint8*)surf.getBasePtr((300 - maxWidth) / 2, y); + uint8 *srcPos = (uint8 *)surf.getBasePtr((300 - maxWidth) / 2, y); for (int x = 0; x < maxWidth; x++) dstPos[x] = srcPos[x] + 5; dstPos += 320; diff --git a/backends/platform/psp/display_manager.cpp b/backends/platform/psp/display_manager.cpp index cdb130e2a0..10a732b1e3 100644 --- a/backends/platform/psp/display_manager.cpp +++ b/backends/platform/psp/display_manager.cpp @@ -210,14 +210,14 @@ void MasterGuRenderer::guProgramDisplayBufferSizes() { switch (GuRenderer::_displayManager->getOutputBitsPerPixel()) { case 16: sceGuDrawBuffer(GU_PSM_4444, (void *)0, PSP_BUFFER_WIDTH); - sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void*)(PSP_FRAME_SIZE * sizeof(uint16)), PSP_BUFFER_WIDTH); - sceGuDepthBuffer((void*)(PSP_FRAME_SIZE * sizeof(uint16) * 2), PSP_BUFFER_WIDTH); + sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void *)(PSP_FRAME_SIZE * sizeof(uint16)), PSP_BUFFER_WIDTH); + sceGuDepthBuffer((void *)(PSP_FRAME_SIZE * sizeof(uint16) * 2), PSP_BUFFER_WIDTH); VramAllocator::instance().allocate(PSP_FRAME_SIZE * sizeof(uint16) * 2); break; case 32: sceGuDrawBuffer(GU_PSM_8888, (void *)0, PSP_BUFFER_WIDTH); - sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void*)(PSP_FRAME_SIZE * sizeof(uint32)), PSP_BUFFER_WIDTH); - sceGuDepthBuffer((void*)(PSP_FRAME_SIZE * sizeof(uint32) * 2), PSP_BUFFER_WIDTH); + sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, (void *)(PSP_FRAME_SIZE * sizeof(uint32)), PSP_BUFFER_WIDTH); + sceGuDepthBuffer((void *)(PSP_FRAME_SIZE * sizeof(uint32) * 2), PSP_BUFFER_WIDTH); VramAllocator::instance().allocate(PSP_FRAME_SIZE * sizeof(uint32) * 2); break; } diff --git a/backends/platform/sdl/posix/posix.cpp b/backends/platform/sdl/posix/posix.cpp index 05c779a4e0..7a8b1e7b70 100644 --- a/backends/platform/sdl/posix/posix.cpp +++ b/backends/platform/sdl/posix/posix.cpp @@ -175,7 +175,7 @@ bool OSystem_POSIX::displayLogFile() { } else if (pid == 0) { // Try xdg-open first - execlp("xdg-open", "xdg-open", _logFilePath.c_str(), (char*)0); + execlp("xdg-open", "xdg-open", _logFilePath.c_str(), (char *)0); // If we're here, that clearly failed. @@ -184,7 +184,7 @@ bool OSystem_POSIX::displayLogFile() { // Try xterm+less next - execlp("xterm", "xterm", "-e", "less", _logFilePath.c_str(), (char*)0); + execlp("xterm", "xterm", "-e", "less", _logFilePath.c_str(), (char *)0); // TODO: If less does not exist we could fall back to 'more'. // However, we'll have to use 'xterm -hold' for that to prevent the diff --git a/backends/platform/wince/wince-sdl.cpp b/backends/platform/wince/wince-sdl.cpp index 4e17827e5c..a57fcb9628 100644 --- a/backends/platform/wince/wince-sdl.cpp +++ b/backends/platform/wince/wince-sdl.cpp @@ -87,15 +87,15 @@ extern "C" void *__wrap_malloc(size_t size) { void *ptr = __real_malloc(size+4); // printf("malloc(%d) = %p\n", size, ptr); if (ptr != NULL) { - *((HANDLE*)ptr) = 0; - return 4+(char*)ptr; + *((HANDLE *)ptr) = 0; + return 4+(char *)ptr; } return NULL; } HANDLE H = CreateFileMapping((HANDLE)INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, size+4, 0); void *ptr = MapViewOfFile(H, FILE_MAP_ALL_ACCESS, 0, 0, 0); - *((HANDLE*)ptr) = H; - return 4+(char*)ptr; + *((HANDLE *)ptr) = H; + return 4+(char *)ptr; } extern "C" void __wrap_free(void *ptr) { @@ -104,9 +104,9 @@ extern "C" void __wrap_free(void *ptr) { printf("free(%p)\n", ptr); */ if (ptr != NULL) { - HANDLE H = *(HANDLE*)((char *)ptr-4); + HANDLE H = *(HANDLE *)((char *)ptr-4); if (H == 0) { - __real_free((char*)ptr-4); + __real_free((char *)ptr-4); return; } UnmapViewOfFile((char *)ptr-4); diff --git a/backends/plugins/elf/elf-loader.cpp b/backends/plugins/elf/elf-loader.cpp index d75010196a..d60ddce57e 100644 --- a/backends/plugins/elf/elf-loader.cpp +++ b/backends/plugins/elf/elf-loader.cpp @@ -480,7 +480,7 @@ void *DLObject::symbol(const char *name) { !strcmp(name, _strtab + s->st_name)) { // We found the symbol debug(2, "elfloader: => 0x%08x", s->st_value); - return (void*)s->st_value; + return (void *)s->st_value; } // We didn't find the symbol -- cgit v1.2.3 From ea325909cf1a2652e75c707395199ff4276e40ba Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Wed, 15 Feb 2012 12:39:24 -0600 Subject: MAEMO: Fix wrong assert --- backends/events/maemosdl/maemosdl-events.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp index c01f175863..756125a41c 100644 --- a/backends/events/maemosdl/maemosdl-events.cpp +++ b/backends/events/maemosdl/maemosdl-events.cpp @@ -165,7 +165,7 @@ bool MaemoSdlEventSource::toggleClickMode() { } MaemoSdlEventObserver::MaemoSdlEventObserver(MaemoSdlEventSource *eventSource) { - assert(_eventSource); + assert(eventSource); _eventSource = eventSource; } -- cgit v1.2.3 From 856744aa6a8d10ea62807a28df24f539fd8f2d06 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Wed, 15 Feb 2012 15:17:37 -0600 Subject: MAEMO: Use bitshifting in ModelType --- backends/platform/maemo/maemo-common.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'backends') diff --git a/backends/platform/maemo/maemo-common.h b/backends/platform/maemo/maemo-common.h index cd4bb3b027..30279bc2ef 100644 --- a/backends/platform/maemo/maemo-common.h +++ b/backends/platform/maemo/maemo-common.h @@ -28,10 +28,10 @@ namespace Maemo { enum ModelType { - kModelType770 = 1, - kModelTypeN800 = 2, - kModelTypeN810 = 4, - kModelTypeN900 = 8, + kModelType770 = 1 << 0, + kModelTypeN800 = 1 << 1, + kModelTypeN810 = 1 << 2, + kModelTypeN900 = 1 << 3, kModelTypeInvalid = 0 }; -- cgit v1.2.3 From 7ae7e8073972dfbfc5d450b1a2b43134f3c64d27 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Wed, 15 Feb 2012 16:13:35 -0600 Subject: MAEMO: Rename hasHwKeyboard and add hasMenuKey --- backends/events/maemosdl/maemosdl-events.cpp | 6 +++--- backends/platform/maemo/maemo-common.h | 15 ++++++++------- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'backends') diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp index 756125a41c..057205ee2c 100644 --- a/backends/events/maemosdl/maemosdl-events.cpp +++ b/backends/events/maemosdl/maemosdl-events.cpp @@ -36,7 +36,7 @@ MaemoSdlEventSource::MaemoSdlEventSource() : SdlEventSource(), _clickEnabled(tru bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { Model model = Model(((OSystem_SDL_Maemo *)g_system)->getModel()); - debug(10, "Model: %s %u %s %s", model.hwId, model.modelType, model.hwAlias, model.hwKeyboard ? "true" : "false"); + debug(10, "Model: %s %u %s %s", model.hwId, model.modelType, model.hwAlias, model.hasHwKeyboard ? "true" : "false"); // List of special N810 keys: // SDLK_F4 -> menu @@ -56,7 +56,7 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { debug(9, "remapping to main menu"); return true; } else if (ev.key.keysym.sym == SDLK_F6) { - if (!model.hwKeyboard) { + if (!model.hasHwKeyboard) { event.type = Common::EVENT_KEYDOWN; event.kbd.keycode = Common::KEYCODE_F7; event.kbd.ascii = Common::ASCII_F7; @@ -95,7 +95,7 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_MAINMENU; return true; } else if (ev.key.keysym.sym == SDLK_F6) { - if (!model.hwKeyboard) { + if (!model.hasHwKeyboard) { event.type = Common::EVENT_KEYUP; event.kbd.keycode = Common::KEYCODE_F7; event.kbd.ascii = Common::ASCII_F7; diff --git a/backends/platform/maemo/maemo-common.h b/backends/platform/maemo/maemo-common.h index 30279bc2ef..453c70c45f 100644 --- a/backends/platform/maemo/maemo-common.h +++ b/backends/platform/maemo/maemo-common.h @@ -39,16 +39,17 @@ struct Model { const char *hwId; ModelType modelType; const char *hwAlias; - bool hwKeyboard; + bool hasHwKeyboard; + bool hasMenuKey; }; static const Model models[] = { - {"SU-18", kModelType770, "770", false}, - {"RX-34", kModelTypeN800, "N800", false}, - {"RX-44", kModelTypeN810, "N810", true}, - {"RX-48", kModelTypeN810, "N810W", true}, - {"RX-51", kModelTypeN900, "N900", true}, - {0, kModelTypeInvalid, 0, true} + {"SU-18", kModelType770, "770", false, true}, + {"RX-34", kModelTypeN800, "N800", false, true}, + {"RX-44", kModelTypeN810, "N810", true, true}, + {"RX-48", kModelTypeN810, "N810W", true, true}, + {"RX-51", kModelTypeN900, "N900", true, false}, + {0, kModelTypeInvalid, 0, true, true} }; enum CustomEventType { -- cgit v1.2.3 From 974f5eb7b8291535ea34be5260607d6e383543a7 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Thu, 9 Feb 2012 01:27:55 -0600 Subject: MAEMO: Drop the hardcoded keymap in favor of the keymapper --- backends/events/maemosdl/maemosdl-events.cpp | 30 ++++++++++++++++++++++++++++ backends/platform/maemo/maemo-keys.h | 14 +++++-------- 2 files changed, 35 insertions(+), 9 deletions(-) (limited to 'backends') diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp index 057205ee2c..932be0dc47 100644 --- a/backends/events/maemosdl/maemosdl-events.cpp +++ b/backends/events/maemosdl/maemosdl-events.cpp @@ -33,6 +33,21 @@ MaemoSdlEventSource::MaemoSdlEventSource() : SdlEventSource(), _clickEnabled(tru } +struct KeymapEntry { + SDLKey sym; + Common::KeyCode keycode; + uint16 ascii; +}; + +static const KeymapEntry keymapEntries[] = { + {SDLK_F4, Common::KEYCODE_F11, 0}, + {SDLK_F5, Common::KEYCODE_F12, 0}, + {SDLK_F6, Common::KEYCODE_F13, 0}, + {SDLK_F7, Common::KEYCODE_F14, 0}, + {SDLK_F8, Common::KEYCODE_F15, 0}, + {SDLK_LAST, Common::KEYCODE_INVALID, 0} +}; + bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { Model model = Model(((OSystem_SDL_Maemo *)g_system)->getModel()); @@ -45,6 +60,20 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { // SDLK_F7 -> zoom + // SDLK_F8 -> zoom - +#ifdef ENABLE_KEYMAPPER + if (ev.type == SDL_KEYDOWN || ev.type == SDL_KEYUP) { + const KeymapEntry *entry; + for (entry = keymapEntries; entry->sym != SDLK_LAST; ++entry) { + if (ev.key.keysym.sym == entry->sym) { + SDLModToOSystemKeyFlags(SDL_GetModState(), event); + event.type = ev.type == SDL_KEYDOWN ? Common::EVENT_KEYDOWN : Common::EVENT_KEYUP; + event.kbd.keycode = entry->keycode; + event.kbd.ascii = entry->ascii; + return true; + } + } + } +#else switch (ev.type) { case SDL_KEYDOWN:{ if (ev.key.keysym.sym == SDLK_F4 @@ -132,6 +161,7 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { break; } } +#endif // Invoke parent implementation of this method return SdlEventSource::remapKey(ev, event); } diff --git a/backends/platform/maemo/maemo-keys.h b/backends/platform/maemo/maemo-keys.h index 6725b1164d..26ee375625 100644 --- a/backends/platform/maemo/maemo-keys.h +++ b/backends/platform/maemo/maemo-keys.h @@ -122,15 +122,11 @@ static const KeyTableEntry maemoKeys[] = { {"LEFT", KEYCODE_LEFT, 0, "Left", kDirLeftKeyType, false}, // Function keys - {"F1", KEYCODE_F1, ASCII_F1, "F1", kActionKeyType, false}, - {"F2", KEYCODE_F2, ASCII_F2, "F2", kActionKeyType, false}, - {"F3", KEYCODE_F3, ASCII_F3, "F3", kActionKeyType, false}, - {"F4", KEYCODE_F4, ASCII_F4, "Menu", kActionKeyType, false}, - {"F5", KEYCODE_F5, ASCII_F5, "Home", kActionKeyType, false}, - {"F6", KEYCODE_F6, ASCII_F6, "FullScreen", kActionKeyType, false}, - {"F7", KEYCODE_F7, ASCII_F7, "Zoom+", kActionKeyType, false}, - {"F8", KEYCODE_F8, ASCII_F8, "Zoom-", kActionKeyType, false}, - {"F9", KEYCODE_F9, ASCII_F9, "F9", kActionKeyType, false}, + {"MENU", KEYCODE_F11, 0, "Menu", kActionKeyType, false}, + {"HOME", KEYCODE_F12, 0, "Home", kActionKeyType, false}, + {"FULLSCREEN", KEYCODE_F13, 0, "FullScreen", kActionKeyType, false}, + {"ZOOMPLUS", KEYCODE_F14, 0, "Zoom+", kActionKeyType, false}, + {"ZOOMMINUS", KEYCODE_F15, 0, "Zoom-", kActionKeyType, false}, {0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false} }; -- cgit v1.2.3 From cce5be67dc3d171a5b30a9863f250471adecd5b0 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Tue, 14 Feb 2012 23:02:23 -0600 Subject: KEYMAPPER: Allow ports to define default Keymap Action bindings --- backends/keymapper/keymap.cpp | 56 ++++++++++++++++++++++----------- backends/keymapper/keymapper-defaults.h | 56 +++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 19 deletions(-) create mode 100644 backends/keymapper/keymapper-defaults.h (limited to 'backends') diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp index bd020937eb..daf92e1d15 100644 --- a/backends/keymapper/keymap.cpp +++ b/backends/keymapper/keymap.cpp @@ -24,7 +24,10 @@ #ifdef ENABLE_KEYMAPPER +#include "common/system.h" + #include "backends/keymapper/hardware-key.h" +#include "backends/keymapper/keymapper-defaults.h" #define KEYMAP_KEY_PREFIX "keymap_" @@ -121,35 +124,50 @@ void Keymap::loadMappings(const HardwareKeySet *hwKeys) { if (!_configDomain) return; - ConfigManager::Domain::iterator it; - String prefix = KEYMAP_KEY_PREFIX + _name + "_"; - - for (it = _configDomain->begin(); it != _configDomain->end(); ++it) { - const String& key = it->_key; - - if (!key.hasPrefix(prefix.c_str())) - continue; + if (_actions.empty()) + return; - // parse Action ID - const char *actionId = key.c_str() + prefix.size(); - Action *ua = getAction(actionId); + Common::KeymapperDefaultBindings *defaults = g_system->getKeymapperDefaultBindings(); - if (!ua) { - warning("'%s' keymap does not contain Action with ID %s", - _name.c_str(), actionId); - _configDomain->erase(key); + HashMap mappedKeys; + List::iterator it; + String prefix = KEYMAP_KEY_PREFIX + _name + "_"; - continue; + for (it = _actions.begin(); it != _actions.end(); ++it) { + Action* ua = *it; + String actionId(ua->id); + String confKey = prefix + actionId; + + String hwKeyId = _configDomain->getVal(confKey); + + bool defaulted = false; + // fall back to the platform-specific defaults + if (hwKeyId.empty() && defaults) { + hwKeyId = defaults->getDefaultBinding(_name, actionId); + if (!hwKeyId.empty()) + defaulted = true; } + // there's no mapping + if (hwKeyId.empty()) + continue; - const HardwareKey *hwKey = hwKeys->findHardwareKey(it->_value.c_str()); + const HardwareKey *hwKey = hwKeys->findHardwareKey(hwKeyId.c_str()); if (!hwKey) { - warning("HardwareKey with ID '%s' not known", it->_value.c_str()); - _configDomain->erase(key); + warning("HardwareKey with ID '%s' not known", hwKeyId.c_str()); continue; } + if (defaulted) { + if (mappedKeys.contains(hwKeyId)) { + debug(1, "Action [%s] not falling back to hardcoded default value [%s] because the key is in use", confKey.c_str(), hwKeyId.c_str()); + continue; + } + warning("Action [%s] fell back to hardcoded default value [%s]", confKey.c_str(), hwKeyId.c_str()); + } + + mappedKeys.setVal(hwKeyId, hwKey); + // map the key ua->mapKey(hwKey); } } diff --git a/backends/keymapper/keymapper-defaults.h b/backends/keymapper/keymapper-defaults.h new file mode 100644 index 0000000000..5b84ebeaa9 --- /dev/null +++ b/backends/keymapper/keymapper-defaults.h @@ -0,0 +1,56 @@ +/* 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. +* +*/ + +#ifdef ENABLE_KEYMAPPER + +#ifndef KEYMAPPER_DEFAULTS_H +#define KEYMAPPER_DEFAULTS_H + +#include "common/scummsys.h" +#include "common/hashmap.h" +#include "common/str.h" +#include "common/hash-str.h" + +namespace Common { + +class KeymapperDefaultBindings : HashMap { +public: + /** + * This sets a default hwKey for a given Keymap Action + * @param keymapId String representing Keymap id (Keymap.name) + * @param actionId String representing Action id (Action.id) + * @param hwKeyId String representing the HardwareKey id (HardwareKey.hwKeyId) + */ + void setDefaultBinding(String keymapId, String actionId, String hwKeyId) { setVal(keymapId + "_" + actionId, hwKeyId); } + /** + * This retrieves the assigned default hwKey for a given Keymap Action + * @param keymapId String representing Keymap id (Keymap.name) + * @param actionId String representing Action id (Action.id) + * @return hwKeyId String representing the HardwareKey id (HardwareKey.hwKeyId) + */ + String getDefaultBinding(String keymapId, String actionId) { return getVal(keymapId + "_" + actionId); } +}; + +} //namespace Common + +#endif // #ifndef KEYMAPPER_DEFAULTS_H +#endif // #ifdef ENABLE_KEYMAPPER -- cgit v1.2.3 From e55914c51b205a03879bc3b7c8c698cfc8858d39 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Tue, 14 Feb 2012 23:07:54 -0600 Subject: MAEMO: Register Keymapper Keymap Action default bindings --- backends/platform/maemo/maemo.cpp | 35 +++++++++++++++++++++++++++++++++++ backends/platform/maemo/maemo.h | 2 ++ 2 files changed, 37 insertions(+) (limited to 'backends') diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index 77d630fc30..49fa9298d4 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -32,6 +32,7 @@ #include "backends/events/maemosdl/maemosdl-events.h" #include "backends/graphics/maemosdl/maemosdl-graphics.h" #include "backends/keymapper/keymapper.h" +#include "backends/keymapper/keymapper-defaults.h" #include "common/textconsole.h" #include "common/translation.h" @@ -48,6 +49,35 @@ OSystem_SDL_Maemo::OSystem_SDL_Maemo() OSystem_SDL_Maemo::~OSystem_SDL_Maemo() { delete _eventObserver; + delete _keymapperDefaultBindings; +} + +static void registerDefaultKeyBindings(Common::KeymapperDefaultBindings *_keymapperDefaultBindings, Model _model) { + _keymapperDefaultBindings->setDefaultBinding("gui", "REM", "HOME"); + _keymapperDefaultBindings->setDefaultBinding("global", "REM", "HOME"); + + if (_model.hasMenuKey && _model.hasHwKeyboard) { + _keymapperDefaultBindings->setDefaultBinding("gui", "FUL", "FULLSCREEN"); + _keymapperDefaultBindings->setDefaultBinding("global", "FUL", "FULLSCREEN"); + } + + if (_model.hasHwKeyboard) { + _keymapperDefaultBindings->setDefaultBinding("gui", "VIR", "C+ZOOMMINUS"); + _keymapperDefaultBindings->setDefaultBinding("global", "VIR", "C+ZOOMMINUS"); + } else { + _keymapperDefaultBindings->setDefaultBinding("gui", "VIR", "FULLSCREEN"); + _keymapperDefaultBindings->setDefaultBinding("global", "VIR", "FULLSCREEN"); + } + + if (_model.hasMenuKey ) + _keymapperDefaultBindings->setDefaultBinding("global", "MEN", "MENU"); + else + _keymapperDefaultBindings->setDefaultBinding("global", "MEN", "S+C+M"); + + _keymapperDefaultBindings->setDefaultBinding("gui", "CLO", "ESCAPE"); + + _keymapperDefaultBindings->setDefaultBinding("maemo", "RCL", "ZOOMPLUS"); + _keymapperDefaultBindings->setDefaultBinding("maemo", "CLK", "ZOOMMINUS"); } void OSystem_SDL_Maemo::initBackend() { @@ -61,10 +91,15 @@ void OSystem_SDL_Maemo::initBackend() { if (_eventObserver == 0) _eventObserver = new MaemoSdlEventObserver((MaemoSdlEventSource *)_eventSource); + if (_keymapperDefaultBindings == 0) + _keymapperDefaultBindings = new Common::KeymapperDefaultBindings(); + ConfMan.set("vkeybdpath", DATA_PATH); _model = Model(detectModel()); + registerDefaultKeyBindings(_keymapperDefaultBindings, _model); + // Call parent implementation of this method OSystem_POSIX::initBackend(); initObserver(); diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h index 382770219b..1f3c8b8d47 100644 --- a/backends/platform/maemo/maemo.h +++ b/backends/platform/maemo/maemo.h @@ -44,6 +44,7 @@ public: #ifdef ENABLE_KEYMAPPER virtual Common::HardwareKeySet *getHardwareKeySet(); virtual Common::Keymap *getGlobalKeymap(); + virtual Common::KeymapperDefaultBindings *getKeymapperDefaultBindings() { return _keymapperDefaultBindings; } #endif Model getModel() { return _model; } @@ -55,6 +56,7 @@ private: const Model detectModel(); Model _model; MaemoSdlEventObserver *_eventObserver; + Common::KeymapperDefaultBindings *_keymapperDefaultBindings; }; } // namespace Maemo -- cgit v1.2.3 From 85c8c84804125599547f8408962656e2686543e9 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Wed, 15 Feb 2012 17:22:41 -0600 Subject: KEYMAPPER: Add more warning signs --- backends/events/default/default-events.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'backends') diff --git a/backends/events/default/default-events.h b/backends/events/default/default-events.h index 3a8025f5e8..4d89b78861 100644 --- a/backends/events/default/default-events.h +++ b/backends/events/default/default-events.h @@ -92,6 +92,8 @@ public: #endif #ifdef ENABLE_KEYMAPPER + // IMPORTANT NOTE: This is part of the WIP Keymapper. If you plan to use + // this, please talk to tsoliman and/or LordHoto. virtual Common::Keymapper *getKeymapper() { return _keymapper; } #endif }; -- cgit v1.2.3 From b6e5e4fe1e5501b9c196ea3b8c0eb21f8854ce55 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Wed, 15 Feb 2012 17:56:09 -0600 Subject: MAEMO: Remove pointless copy ctor call Thanks LordHoto --- backends/platform/maemo/maemo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index 49fa9298d4..60ed4170e2 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -96,7 +96,7 @@ void OSystem_SDL_Maemo::initBackend() { ConfMan.set("vkeybdpath", DATA_PATH); - _model = Model(detectModel()); + _model = detectModel(); registerDefaultKeyBindings(_keymapperDefaultBindings, _model); -- cgit v1.2.3 From 53d6ef12090d0a0ce34145b3c661dc4e8df619d7 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 17 Feb 2012 14:41:41 -0600 Subject: MAEMO: Fix building without keymapper enabled --- backends/events/maemosdl/maemosdl-events.cpp | 2 ++ backends/platform/maemo/maemo.cpp | 8 ++++++++ backends/platform/maemo/maemo.h | 2 ++ 3 files changed, 12 insertions(+) (limited to 'backends') diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp index 932be0dc47..0046d297eb 100644 --- a/backends/events/maemosdl/maemosdl-events.cpp +++ b/backends/events/maemosdl/maemosdl-events.cpp @@ -200,6 +200,7 @@ MaemoSdlEventObserver::MaemoSdlEventObserver(MaemoSdlEventSource *eventSource) { } bool MaemoSdlEventObserver::notifyEvent(const Common::Event &event) { +#ifdef ENABLE_KEYMAPPER if (event.type != Common::EVENT_CUSTOM_BACKEND) return false; if (event.customType == kEventClickMode) { @@ -207,6 +208,7 @@ bool MaemoSdlEventObserver::notifyEvent(const Common::Event &event) { _eventSource->toggleClickMode(); return true; } +#endif return false; } diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index 60ed4170e2..09bc3407e0 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -49,9 +49,12 @@ OSystem_SDL_Maemo::OSystem_SDL_Maemo() OSystem_SDL_Maemo::~OSystem_SDL_Maemo() { delete _eventObserver; +#ifdef ENABLE_KEYMAPPER delete _keymapperDefaultBindings; +#endif } +#ifdef ENABLE_KEYMAPPER static void registerDefaultKeyBindings(Common::KeymapperDefaultBindings *_keymapperDefaultBindings, Model _model) { _keymapperDefaultBindings->setDefaultBinding("gui", "REM", "HOME"); _keymapperDefaultBindings->setDefaultBinding("global", "REM", "HOME"); @@ -79,6 +82,7 @@ static void registerDefaultKeyBindings(Common::KeymapperDefaultBindings *_keymap _keymapperDefaultBindings->setDefaultBinding("maemo", "RCL", "ZOOMPLUS"); _keymapperDefaultBindings->setDefaultBinding("maemo", "CLK", "ZOOMMINUS"); } +#endif void OSystem_SDL_Maemo::initBackend() { // Create the events manager @@ -91,14 +95,18 @@ void OSystem_SDL_Maemo::initBackend() { if (_eventObserver == 0) _eventObserver = new MaemoSdlEventObserver((MaemoSdlEventSource *)_eventSource); +#ifdef ENABLE_KEYMAPPER if (_keymapperDefaultBindings == 0) _keymapperDefaultBindings = new Common::KeymapperDefaultBindings(); +#endif ConfMan.set("vkeybdpath", DATA_PATH); _model = detectModel(); +#ifdef ENABLE_KEYMAPPER registerDefaultKeyBindings(_keymapperDefaultBindings, _model); +#endif // Call parent implementation of this method OSystem_POSIX::initBackend(); diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h index 1f3c8b8d47..4b84ae573a 100644 --- a/backends/platform/maemo/maemo.h +++ b/backends/platform/maemo/maemo.h @@ -56,7 +56,9 @@ private: const Model detectModel(); Model _model; MaemoSdlEventObserver *_eventObserver; +#ifdef ENABLE_KEYMAPPER Common::KeymapperDefaultBindings *_keymapperDefaultBindings; +#endif }; } // namespace Maemo -- cgit v1.2.3 From ffaa8612c3024f2ec97692015553dd846e31d830 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 19 Feb 2012 05:16:42 +0100 Subject: IPHONE: Change F5 (menu) gesture to open up the GMM. Thanks to tsoliman for this patch. --- backends/platform/iphone/osys_events.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/osys_events.cpp b/backends/platform/iphone/osys_events.cpp index 1ab1db0f27..f6dae2f519 100644 --- a/backends/platform/iphone/osys_events.cpp +++ b/backends/platform/iphone/osys_events.cpp @@ -319,12 +319,9 @@ bool OSystem_IPHONE::handleEvent_mouseSecondDragged(Common::Event &event, int x, if (absX < kMaxDeviation && vecY >= kNeededLength) { // Swipe down - event.type = Common::EVENT_KEYDOWN; - _queuedInputEvent.type = Common::EVENT_KEYUP; + event.type = Common::EVENT_MAINMENU; + _queuedInputEvent.type = Common::EVENT_INVALID; - event.kbd.flags = _queuedInputEvent.kbd.flags = 0; - event.kbd.keycode = _queuedInputEvent.kbd.keycode = Common::KEYCODE_F5; - event.kbd.ascii = _queuedInputEvent.kbd.ascii = Common::ASCII_F5; _queuedEventTime = getMillis() + kQueuedInputEventDelay; return true; } -- cgit v1.2.3 From ab4420b3ca591f707ea831cb077e88b800986471 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 19 Feb 2012 05:18:47 +0100 Subject: IPHONE: Take advantage of Common::EVENT_INVALID. --- backends/platform/iphone/osys_events.cpp | 4 ++-- backends/platform/iphone/osys_main.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/osys_events.cpp b/backends/platform/iphone/osys_events.cpp index f6dae2f519..a3075e23cb 100644 --- a/backends/platform/iphone/osys_events.cpp +++ b/backends/platform/iphone/osys_events.cpp @@ -40,9 +40,9 @@ bool OSystem_IPHONE::pollEvent(Common::Event &event) { _timerCallbackNext = curTime + _timerCallbackTimer; } - if (_queuedInputEvent.type != (Common::EventType)0 && curTime >= _queuedEventTime) { + if (_queuedInputEvent.type != Common::EVENT_INVALID && curTime >= _queuedEventTime) { event = _queuedInputEvent; - _queuedInputEvent.type = (Common::EventType)0; + _queuedInputEvent.type = Common::EVENT_INVALID; return true; } diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 4bc567c39d..b0f475b6ea 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -62,7 +62,7 @@ OSystem_IPHONE::OSystem_IPHONE() : _mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0), _overlayHeight(0), _overlayWidth(0), _overlayBuffer(0) { - _queuedInputEvent.type = (Common::EventType)0; + _queuedInputEvent.type = Common::EVENT_INVALID; _lastDrawnMouseRect = Common::Rect(0, 0, 0, 0); _touchpadModeEnabled = !iPhone_isHighResDevice(); -- cgit v1.2.3 From f6b8fec0f13c739bf48c5b0c01647245fdeaa962 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Sun, 19 Feb 2012 18:38:28 +0000 Subject: NULL: Fix compiler error when using NullMutexManager The compiler error fixed (when trying to set the _mutexManager) is: error: ‘MutexManager’ is an inaccessible base of ‘NullMutexManager’ --- backends/mutex/null/null-mutex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/mutex/null/null-mutex.h b/backends/mutex/null/null-mutex.h index fdb32b241c..7ae10cedb8 100644 --- a/backends/mutex/null/null-mutex.h +++ b/backends/mutex/null/null-mutex.h @@ -28,7 +28,7 @@ /** * Null mutex manager */ -class NullMutexManager : MutexManager { +class NullMutexManager : public MutexManager { public: virtual OSystem::MutexRef createMutex() { return OSystem::MutexRef(); } virtual void lockMutex(OSystem::MutexRef mutex) {} -- cgit v1.2.3 From 7a3df4681b3b399f58585b204b66b582ee17c163 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Sun, 19 Feb 2012 18:41:49 +0000 Subject: NULL: Fix compiler errors when using the NullGraphicsManager The errors fixed are inaccessible base class when trying to set the _graphicsManager and a pure virtual function when trying to create the NullGraphicsManager instance. --- backends/graphics/null/null-graphics.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/graphics/null/null-graphics.h b/backends/graphics/null/null-graphics.h index 28b24f6aca..2e6b24d147 100644 --- a/backends/graphics/null/null-graphics.h +++ b/backends/graphics/null/null-graphics.h @@ -27,7 +27,7 @@ static const OSystem::GraphicsMode s_noGraphicsModes[] = { {0, 0, 0} }; -class NullGraphicsManager : GraphicsManager { +class NullGraphicsManager : public GraphicsManager { public: virtual ~NullGraphicsManager() {} @@ -38,6 +38,7 @@ public: const OSystem::GraphicsMode *getSupportedGraphicsModes() const { return s_noGraphicsModes; } int getDefaultGraphicsMode() const { return 0; } bool setGraphicsMode(int mode) { return true; } + void resetGraphicsScale(){} int getGraphicsMode() const { return 0; } inline Graphics::PixelFormat getScreenFormat() const { return Graphics::PixelFormat::createFormatCLUT8(); -- cgit v1.2.3 From 4244663020c0462eb3fb4f621efcdaac586c84f1 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 19 Feb 2012 20:32:16 +0100 Subject: IPHONE: Remove dead code. --- backends/platform/iphone/blit.cpp | 48 ------------- backends/platform/iphone/blit_arm.h | 35 --------- backends/platform/iphone/blit_arm.s | 137 ------------------------------------ backends/platform/iphone/module.mk | 3 +- 4 files changed, 1 insertion(+), 222 deletions(-) delete mode 100644 backends/platform/iphone/blit.cpp delete mode 100644 backends/platform/iphone/blit_arm.h delete mode 100644 backends/platform/iphone/blit_arm.s (limited to 'backends') diff --git a/backends/platform/iphone/blit.cpp b/backends/platform/iphone/blit.cpp deleted file mode 100644 index 58de22bf75..0000000000 --- a/backends/platform/iphone/blit.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "common/scummsys.h" -#include "blit_arm.h" - -void blitLandscapeScreenRect16bpp(uint16 *dst, uint16 *src, int width, int height, int screenWidth, int screenHeight) -{ - for (int x = width; x > 0; x--) { - for (int y = height; y > 0; y--) { - *(dst++) = *src; - src += screenWidth; - } - dst -= screenHeight + height; - src += 1 - height * screenWidth; - } -} - -void blitLandscapeScreenRect8bpp(uint16 *dst, byte *src, int width, int height, uint16 *palette, int screenWidth, int screenHeight) -{ - for (int x = width; x > 0; x--) { - for (int y = height; y > 0; y--) { - *(dst++) = palette[*src]; - src += screenWidth; - } - dst -= screenHeight + height; - src += 1 - height * screenWidth; - } -} diff --git a/backends/platform/iphone/blit_arm.h b/backends/platform/iphone/blit_arm.h deleted file mode 100644 index 77bb3578ab..0000000000 --- a/backends/platform/iphone/blit_arm.h +++ /dev/null @@ -1,35 +0,0 @@ -/* 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. - * - */ - -extern "C" void blitLandscapeScreenRect16bpp(uint16 *dst, uint16 *src, - int width, - int height, - int screenWidth, - int screenHeight); - -extern "C" void blitLandscapeScreenRect8bpp(uint16 *dst, - byte *src, - int width, - int height, - uint16 *palette, - int screenWidth, - int screenHeight); diff --git a/backends/platform/iphone/blit_arm.s b/backends/platform/iphone/blit_arm.s deleted file mode 100644 index 04f9a87614..0000000000 --- a/backends/platform/iphone/blit_arm.s +++ /dev/null @@ -1,137 +0,0 @@ -@ 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. -@ -@ @author Robin Watts (robin@wss.co.uk) - - .text - - .global _blitLandscapeScreenRect16bpp - .global _blitLandscapeScreenRect8bpp - - -_blitLandscapeScreenRect16bpp: - @ r0 = dst - @ r1 = src - @ r2 = w - @ r3 = h - @ <> = _screenWidth - @ <> = _screenHeight - mov r12,r13 - stmfd r13!,{r4-r11,r14} - ldmfd r12,{r12,r14} @ r12 = _screenWidth - @ r14 = _screenHeight - add r14,r14,r3 @ r14 = _screenHeight + h - mvn r11,#0 - mla r11,r3,r12,r11 @ r11= _screenWidth*h-1 - add r12,r12,r12 -xloop: - subs r4,r3,#5 @ r4 = y = h - ble thin -yloop: - ldrh r5, [r1],r12 @ r5 = *src src += _screenWidth - ldrh r6, [r1],r12 @ r6 = *src src += _screenWidth - ldrh r7, [r1],r12 @ r7 = *src src += _screenWidth - ldrh r8, [r1],r12 @ r8 = *src src += _screenWidth - ldrh r9, [r1],r12 @ r9 = *src src += _screenWidth - ldrh r10,[r1],r12 @ r10= *src src += _screenWidth - subs r4,r4,#6 - strh r5, [r0],#2 @ *dst++ = r5 - strh r6, [r0],#2 @ *dst++ = r6 - strh r7, [r0],#2 @ *dst++ = r7 - strh r8, [r0],#2 @ *dst++ = r8 - strh r9, [r0],#2 @ *dst++ = r9 - strh r10,[r0],#2 @ *dst++ = r10 - bgt yloop -thin: - adds r4,r4,#5 - beq lineend -thin_loop: - ldrh r5,[r1],r12 @ r5 = *src src += _screenWidth - subs r4,r4,#1 - strh r5,[r0],#2 @ *dst++ = r5 - bgt thin_loop -lineend: - sub r0,r0,r14,LSL #1 @ dst -= _screenHeight + h - sub r1,r1,r11,LSL #1 @ src += 1-_screenWidth*h - subs r2,r2,#1 - bgt xloop - - ldmfd r13!,{r4-r11,PC} - -_blitLandscapeScreenRect8bpp: - @ r0 = dst - @ r1 = src - @ r2 = w - @ r3 = h - @ <> = _palette - @ <> = _screenWidth - @ <> = _screenHeight - mov r12,r13 - stmfd r13!,{r4-r11,r14} - ldmfd r12,{r11,r12,r14} @ r11 = _palette - @ r12 = _screenWidth - @ r14 = _screenHeight - add r14,r14,r3 @ r14 = _screenHeight + h - mvn r6,#0 - mla r6,r3,r12,r6 @ r6 = _screenWidth*h-1 -xloop8: - mov r4,r3 @ r4 = y = h - subs r4,r3,#4 @ r4 = y = h - ble thin8 -yloop8: - ldrb r5, [r1],r12 @ r5 = *src src += _screenWidth - ldrb r7, [r1],r12 @ r7 = *src src += _screenWidth - ldrb r8, [r1],r12 @ r8 = *src src += _screenWidth - ldrb r9, [r1],r12 @ r9 = *src src += _screenWidth - ldrb r10,[r1],r12 @ r10= *src src += _screenWidth - add r5, r5, r5 - add r7, r7, r7 - add r8, r8, r8 - add r9, r9, r9 - add r10,r10,r10 - ldrh r5, [r11,r5] - ldrh r7, [r11,r7] - ldrh r8, [r11,r8] - ldrh r9, [r11,r9] - ldrh r10,[r11,r10] - subs r4,r4,#5 - strh r5, [r0],#2 @ *dst++ = r5 - strh r7, [r0],#2 @ *dst++ = r7 - strh r8, [r0],#2 @ *dst++ = r8 - strh r9, [r0],#2 @ *dst++ = r9 - strh r10,[r0],#2 @ *dst++ = r10 - bgt yloop8 -thin8: - adds r4,r4,#4 - beq lineend8 -thin_loop8: - ldrb r5,[r1],r12 @ r5 = *src src += _screenWidth - add r5,r5,r5 - ldrh r5,[r11,r5] - subs r4,r4,#1 - strh r5,[r0],#2 @ *dst++ = r5 - bgt thin_loop8 -lineend8: - sub r0,r0,r14,LSL #1 @ dst -= _screenHeight + h - sub r1,r1,r6 @ src += 1-_screenWidth*h - subs r2,r2,#1 - bgt xloop8 - - ldmfd r13!,{r4-r11,PC} diff --git a/backends/platform/iphone/module.mk b/backends/platform/iphone/module.mk index 9768e6ded4..ea5115782f 100644 --- a/backends/platform/iphone/module.mk +++ b/backends/platform/iphone/module.mk @@ -7,8 +7,7 @@ MODULE_OBJS := \ osys_video.o \ iphone_main.o \ iphone_video.o \ - iphone_keyboard.o \ - blit_arm.o + iphone_keyboard.o # We don't use rules.mk but rather manually update OBJS and MODULE_DIRS. MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS)) -- cgit v1.2.3 From 3d0316ccd215cbb1530f665ff195554e46559efe Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 19 Feb 2012 21:18:17 +0100 Subject: IPHONE: Formatting fixes. --- backends/platform/iphone/iphone_common.h | 14 +- backends/platform/iphone/iphone_keyboard.h | 2 +- backends/platform/iphone/iphone_keyboard.m | 8 +- backends/platform/iphone/iphone_main.m | 49 ++-- backends/platform/iphone/iphone_video.h | 15 +- backends/platform/iphone/iphone_video.m | 55 ++--- backends/platform/iphone/osys_events.cpp | 358 ++++++++++++++--------------- backends/platform/iphone/osys_main.cpp | 5 +- backends/platform/iphone/osys_main.h | 22 +- backends/platform/iphone/osys_video.cpp | 14 +- 10 files changed, 264 insertions(+), 278 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 0cbcb77bcb..9bf559860e 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -20,7 +20,6 @@ * */ - enum InputEvent { kInputMouseDown, kInputMouseUp, @@ -41,13 +40,12 @@ enum ScreenOrientation { kScreenOrientationFlippedLandscape }; -typedef enum -{ +enum UIViewSwipeDirection { kUIViewSwipeUp = 1, kUIViewSwipeDown = 2, kUIViewSwipeLeft = 4, kUIViewSwipeRight = 8 -} UIViewSwipeDirection; +}; #ifdef IPHONE_OFFICIAL void iphone_main(int argc, char **argv); @@ -65,16 +63,16 @@ void iphone_main(int argc, char *argv[]); // On the ObjC side void iPhone_updateScreen(int mouseX, int mouseY); -void iPhone_updateScreenRect(unsigned short* screen, int x1, int y1, int x2, int y2); -void iPhone_updateOverlayRect(unsigned short* screen, int x1, int y1, int x2, int y2); +void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2); +void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2); void iPhone_initSurface(int width, int height); bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY); -const char* iPhone_getDocumentsDir(); +const char *iPhone_getDocumentsDir(); bool iPhone_isHighResDevice(); int iPhone_getScreenHeight(); int iPhone_getScreenWidth(); void iPhone_enableOverlay(int state); -void iPhone_setMouseCursor(short* buffer, int width, int height); +void iPhone_setMouseCursor(short *buffer, int width, int height); uint getSizeNextPOT(uint size); diff --git a/backends/platform/iphone/iphone_keyboard.h b/backends/platform/iphone/iphone_keyboard.h index c4b4a9a2a7..6d64f90ffd 100644 --- a/backends/platform/iphone/iphone_keyboard.h +++ b/backends/platform/iphone/iphone_keyboard.h @@ -25,7 +25,7 @@ @interface SoftKeyboard : UIView { id inputDelegate; - UITextView* inputView; + UITextView *inputView; } - (id)initWithFrame:(CGRect)frame; diff --git a/backends/platform/iphone/iphone_keyboard.m b/backends/platform/iphone/iphone_keyboard.m index 1624d02977..4d92b15450 100644 --- a/backends/platform/iphone/iphone_keyboard.m +++ b/backends/platform/iphone/iphone_keyboard.m @@ -29,17 +29,17 @@ @end @interface TextInputHandler : UITextView { - SoftKeyboard* softKeyboard; + SoftKeyboard *softKeyboard; } -- (id)initWithKeyboard:(SoftKeyboard*)keyboard; +- (id)initWithKeyboard:(SoftKeyboard *)keyboard; @end @implementation TextInputHandler -- (id)initWithKeyboard:(SoftKeyboard*)keyboard; { +- (id)initWithKeyboard:(SoftKeyboard *)keyboard; { self = [super initWithFrame:CGRectMake(0.0f, 0.0f, 0.0f, 0.0f)]; softKeyboard = keyboard; @@ -80,7 +80,7 @@ return self; } -- (UITextView*)inputView { +- (UITextView *)inputView { return inputView; } diff --git a/backends/platform/iphone/iphone_main.m b/backends/platform/iphone/iphone_main.m index c2ec328bf5..1b555f849f 100644 --- a/backends/platform/iphone/iphone_main.m +++ b/backends/platform/iphone/iphone_main.m @@ -28,30 +28,30 @@ void iphone_main(int argc, char *argv[]); @interface iPhoneMain : UIApplication { - UIWindow* _window; - iPhoneView* _view; + UIWindow *_window; + iPhoneView *_view; } -- (void) mainLoop: (id)param; -- (iPhoneView*) getView; -- (UIWindow*) getWindow; +- (void)mainLoop:(id)param; +- (iPhoneView *)getView; +- (UIWindow *)getWindow; - (void)didRotate:(NSNotification *)notification; @end static int gArgc; -static char** gArgv; +static char **gArgv; -int main(int argc, char** argv) { +int main(int argc, char **argv) { gArgc = argc; gArgv = argv; - NSAutoreleasePool *autoreleasePool = [ - [ NSAutoreleasePool alloc ] init - ]; + NSAutoreleasePool *autoreleasePool = [ + [NSAutoreleasePool alloc] init + ]; - int returnCode = UIApplicationMain(argc, argv, @"iPhoneMain", @"iPhoneMain"); - [ autoreleasePool release ]; - return returnCode; + int returnCode = UIApplicationMain(argc, argv, @"iPhoneMain", @"iPhoneMain"); + [autoreleasePool release]; + return returnCode; } @implementation iPhoneMain @@ -63,14 +63,14 @@ int main(int argc, char** argv) { return self; } -- (void) mainLoop: (id)param { +- (void)mainLoop:(id)param { [[NSAutoreleasePool alloc] init]; iphone_main(gArgc, gArgv); exit(0); } -- (iPhoneView*) getView { +- (iPhoneView *)getView { return _view; } @@ -78,8 +78,8 @@ int main(int argc, char** argv) { CGRect rect = [[UIScreen mainScreen] bounds]; // hide the status bar - [application setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; - [application setStatusBarHidden:YES animated:YES]; + [application setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; + [application setStatusBarHidden:YES animated:YES]; _window = [[UIWindow alloc] initWithFrame:rect]; [_window retain]; @@ -100,16 +100,13 @@ int main(int argc, char** argv) { [NSThread detachNewThreadSelector:@selector(mainLoop:) toTarget:self withObject:nil]; } -- (void)applicationDidResume -{ +- (void)applicationDidResume { } -- (void)applicationWillSuspend -{ +- (void)applicationWillSuspend { } -- (void)applicationWillTerminate -{ +- (void)applicationWillTerminate { } - (void)applicationSuspend:(struct __GSEvent *)event { @@ -122,9 +119,9 @@ int main(int argc, char** argv) { // Workaround, need to "hide" and unhide the statusbar to properly remove it, // since the Springboard has put it back without apparently flagging our application. - [self setStatusBarHidden:YES animated:YES]; - [self setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; - [self setStatusBarHidden:YES animated:YES]; + [self setStatusBarHidden:YES animated:YES]; + [self setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; + [self setStatusBarHidden:YES animated:YES]; } - (void)didRotate:(NSNotification *)notification { diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 223f025978..21593b2c3d 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -33,17 +33,16 @@ #import "iphone_keyboard.h" -@interface iPhoneView : UIView -{ - void* _screenSurface; - NSMutableArray* _events; - SoftKeyboard* _keyboardView; - CALayer* _screenLayer; +@interface iPhoneView : UIView { + void *_screenSurface; + NSMutableArray *_events; + SoftKeyboard *_keyboardView; + CALayer *_screenLayer; int _widthOffset; int _heightOffset; - EAGLContext* _context; + EAGLContext *_context; GLuint _viewRenderbuffer; GLuint _viewFramebuffer; GLint _backingWidth; @@ -69,7 +68,7 @@ - (void)updateMouseSurface; - (void)clearColorBuffer; --(void)updateMouseCursor; +- (void)updateMouseCursor; - (id)getEvent; diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index eb16676428..4ef43f20df 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -30,25 +30,25 @@ static int _fullWidth; static int _fullHeight; static CGRect _screenRect; -static char* _textureBuffer = 0; +static char *_textureBuffer = 0; static int _textureWidth = 0; static int _textureHeight = 0; -static char* _overlayTexBuffer = 0; +static char *_overlayTexBuffer = 0; static int _overlayTexWidth = 0; static int _overlayTexHeight = 0; static int _overlayWidth = 0; static int _overlayHeight = 0; static float _overlayPortraitRatio = 1.0f; -NSLock* _lock = nil; +NSLock *_lock = nil; static int _needsScreenUpdate = 0; static int _overlayIsEnabled = 0; -static UITouch* _firstTouch = NULL; -static UITouch* _secondTouch = NULL; +static UITouch *_firstTouch = NULL; +static UITouch *_secondTouch = NULL; -static short* _mouseCursor = NULL; +static short *_mouseCursor = NULL; static int _mouseCursorHeight = 0; static int _mouseCursorWidth = 0; static int _mouseX = 0; @@ -59,14 +59,12 @@ static int _mouseY = 0; #define printOpenGLError() printOglError(__FILE__, __LINE__) -int printOglError(const char *file, int line) -{ +int printOglError(const char *file, int line) { int retCode = 0; // returns 1 if an OpenGL error occurred, 0 otherwise. GLenum glErr = glGetError(); - while( glErr != GL_NO_ERROR) - { + while (glErr != GL_NO_ERROR) { fprintf(stderr, "glError: %u (%s: %d)\n", glErr, file, line ); retCode = 1; glErr = glGetError(); @@ -74,7 +72,7 @@ int printOglError(const char *file, int line) return retCode; } -void iPhone_setMouseCursor(short* buffer, int width, int height) { +void iPhone_setMouseCursor(short *buffer, int width, int height) { _mouseCursor = buffer; _mouseCursorWidth = width; @@ -119,13 +117,13 @@ void iPhone_updateScreen(int mouseX, int mouseY) { } } -void iPhone_updateScreenRect(unsigned short* screen, int x1, int y1, int x2, int y2) { +void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2) { int y; for (y = y1; y < y2; ++y) memcpy(&_textureBuffer[(y * _textureWidth + x1 )* 2], &screen[y * _width + x1], (x2 - x1) * 2); } -void iPhone_updateOverlayRect(unsigned short* screen, int x1, int y1, int x2, int y2) { +void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2) { int y; //printf("Overlaywidth: %u, fullwidth %u\n", _overlayWidth, _fullWidth); for (y = y1; y < y2; ++y) @@ -158,19 +156,19 @@ bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY) { } uint getSizeNextPOT(uint size) { - if ((size & (size - 1)) || !size) { - int log = 0; + if ((size & (size - 1)) || !size) { + int log = 0; - while (size >>= 1) - ++log; + while (size >>= 1) + ++log; - size = (2 << log); - } + size = (2 << log); + } - return size; + return size; } -const char* iPhone_getDocumentsDir() { +const char *iPhone_getDocumentsDir() { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; return [documentsDirectory UTF8String]; @@ -196,18 +194,15 @@ bool getLocalMouseCoords(CGPoint *point) { @implementation iPhoneView -+ (Class) layerClass -{ ++ (Class) layerClass { return [CAEAGLLayer class]; } - (id)initWithFrame:(struct CGRect)frame { self = [super initWithFrame: frame]; - if([[UIScreen mainScreen] respondsToSelector: NSSelectorFromString(@"scale")]) - { - if([self respondsToSelector: NSSelectorFromString(@"contentScaleFactor")]) - { + if ([[UIScreen mainScreen] respondsToSelector: NSSelectorFromString(@"scale")]) { + if ([self respondsToSelector: NSSelectorFromString(@"contentScaleFactor")]) { //self.contentScaleFactor = [[UIScreen mainScreen] scale]; } } @@ -395,7 +390,7 @@ bool getLocalMouseCoords(CGPoint *point) { if (_context == nil) { orientation = UIDeviceOrientationLandscapeRight; - CAEAGLLayer *eaglLayer = (CAEAGLLayer*) self.layer; + CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; eaglLayer.opaque = YES; eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: @@ -475,7 +470,7 @@ bool getLocalMouseCoords(CGPoint *point) { } int textureSize = _textureWidth * _textureHeight * 2; - _textureBuffer = (char*)malloc(textureSize); + _textureBuffer = (char *)malloc(textureSize); memset(_textureBuffer, 0, textureSize); glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); @@ -554,7 +549,7 @@ bool getLocalMouseCoords(CGPoint *point) { return event; } -- (void)addEvent:(NSDictionary*)event { +- (void)addEvent:(NSDictionary *)event { if (_events == nil) _events = [[NSMutableArray alloc] init]; diff --git a/backends/platform/iphone/osys_events.cpp b/backends/platform/iphone/osys_events.cpp index a3075e23cb..5beba8a397 100644 --- a/backends/platform/iphone/osys_events.cpp +++ b/backends/platform/iphone/osys_events.cpp @@ -53,85 +53,85 @@ bool OSystem_IPHONE::pollEvent(Common::Event &event) { int x = 0; int y = 0; switch (_screenOrientation) { - case kScreenOrientationPortrait: - if (_overlayVisible) { - x = (int)(xUnit * _overlayWidth); - y = (int)(yUnit * _overlayHeight); - } else { - x = (int)(xUnit * _screenWidth); - y = (int)(yUnit * _screenHeight); - } - break; - case kScreenOrientationLandscape: - if (_overlayVisible) { - x = (int)(yUnit * _overlayWidth); - y = (int)((1.0 - xUnit) * _overlayHeight); - } else { - x = (int)(yUnit * _screenWidth); - y = (int)((1.0 - xUnit) * _screenHeight); - } - break; - case kScreenOrientationFlippedLandscape: - if (_overlayVisible) { - x = (int)((1.0 - yUnit) * _overlayWidth); - y = (int)(xUnit * _overlayHeight); - } else { - x = (int)((1.0 - yUnit) * _screenWidth); - y = (int)(xUnit * _screenHeight); - } - break; + case kScreenOrientationPortrait: + if (_overlayVisible) { + x = (int)(xUnit * _overlayWidth); + y = (int)(yUnit * _overlayHeight); + } else { + x = (int)(xUnit * _screenWidth); + y = (int)(yUnit * _screenHeight); + } + break; + case kScreenOrientationLandscape: + if (_overlayVisible) { + x = (int)(yUnit * _overlayWidth); + y = (int)((1.0 - xUnit) * _overlayHeight); + } else { + x = (int)(yUnit * _screenWidth); + y = (int)((1.0 - xUnit) * _screenHeight); + } + break; + case kScreenOrientationFlippedLandscape: + if (_overlayVisible) { + x = (int)((1.0 - yUnit) * _overlayWidth); + y = (int)(xUnit * _overlayHeight); + } else { + x = (int)((1.0 - yUnit) * _screenWidth); + y = (int)(xUnit * _screenHeight); + } + break; } switch ((InputEvent)eventType) { - case kInputMouseDown: - if (!handleEvent_mouseDown(event, x, y)) - return false; - break; + case kInputMouseDown: + if (!handleEvent_mouseDown(event, x, y)) + return false; + break; - case kInputMouseUp: + case kInputMouseUp: if (!handleEvent_mouseUp(event, x, y)) return false; - break; - - case kInputMouseDragged: - if (!handleEvent_mouseDragged(event, x, y)) - return false; - break; - case kInputMouseSecondDragged: - if (!handleEvent_mouseSecondDragged(event, x, y)) - return false; - break; - case kInputMouseSecondDown: - _secondaryTapped = true; - if (!handleEvent_secondMouseDown(event, x, y)) - return false; - break; - case kInputMouseSecondUp: - _secondaryTapped = false; - if (!handleEvent_secondMouseUp(event, x, y)) - return false; - break; - case kInputOrientationChanged: - handleEvent_orientationChanged((int)xUnit); - return false; - break; + break; - case kInputApplicationSuspended: - suspendLoop(); + case kInputMouseDragged: + if (!handleEvent_mouseDragged(event, x, y)) + return false; + break; + case kInputMouseSecondDragged: + if (!handleEvent_mouseSecondDragged(event, x, y)) + return false; + break; + case kInputMouseSecondDown: + _secondaryTapped = true; + if (!handleEvent_secondMouseDown(event, x, y)) + return false; + break; + case kInputMouseSecondUp: + _secondaryTapped = false; + if (!handleEvent_secondMouseUp(event, x, y)) return false; - break; + break; + case kInputOrientationChanged: + handleEvent_orientationChanged((int)xUnit); + return false; + break; - case kInputKeyPressed: - handleEvent_keyPressed(event, (int)xUnit); - break; + case kInputApplicationSuspended: + suspendLoop(); + return false; + break; - case kInputSwipe: - if (!handleEvent_swipe(event, (int)xUnit)) - return false; - break; + case kInputKeyPressed: + handleEvent_keyPressed(event, (int)xUnit); + break; + + case kInputSwipe: + if (!handleEvent_swipe(event, (int)xUnit)) + return false; + break; - default: - break; + default: + break; } return true; @@ -170,8 +170,7 @@ bool OSystem_IPHONE::handleEvent_mouseUp(Common::Event &event, int x, int y) { _secondaryTapped = false; if (!handleEvent_secondMouseUp(event, x, y)) return false; - } - else if (_mouseClickAndDragEnabled) { + } else if (_mouseClickAndDragEnabled) { event.type = Common::EVENT_LBUTTONUP; event.mouse.x = _mouseX; event.mouse.y = _mouseY; @@ -206,8 +205,7 @@ bool OSystem_IPHONE::handleEvent_secondMouseDown(Common::Event &event, int x, in _queuedInputEvent.type = Common::EVENT_RBUTTONDOWN; _queuedInputEvent.mouse.x = _mouseX; _queuedInputEvent.mouse.y = _mouseY; - } - else + } else return false; return true; @@ -216,7 +214,7 @@ bool OSystem_IPHONE::handleEvent_secondMouseDown(Common::Event &event, int x, in bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int y) { int curTime = getMillis(); - if (curTime - _lastSecondaryDown < 400 ) { + if (curTime - _lastSecondaryDown < 400) { //printf("Right tap!\n"); if (curTime - _lastSecondaryTap < 400 && !_overlayVisible) { //printf("Right escape!\n"); @@ -262,7 +260,7 @@ bool OSystem_IPHONE::handleEvent_mouseDragged(Common::Event &event, int x, int y //printf("Mouse dragged at (%u, %u)\n", x, y); int mouseNewPosX; int mouseNewPosY; - if (_touchpadModeEnabled ) { + if (_touchpadModeEnabled) { int deltaX = _lastPadX - x; int deltaY = _lastPadY - y; _lastPadX = x; @@ -368,17 +366,17 @@ void OSystem_IPHONE::handleEvent_orientationChanged(int orientation) { ScreenOrientation newOrientation; switch (orientation) { - case 1: - newOrientation = kScreenOrientationPortrait; - break; - case 3: - newOrientation = kScreenOrientationLandscape; - break; - case 4: - newOrientation = kScreenOrientationFlippedLandscape; - break; - default: - return; + case 1: + newOrientation = kScreenOrientationPortrait; + break; + case 3: + newOrientation = kScreenOrientationLandscape; + break; + case 4: + newOrientation = kScreenOrientationFlippedLandscape; + break; + default: + return; } @@ -400,50 +398,50 @@ void OSystem_IPHONE::handleEvent_keyPressed(Common::Event &event, int keyPresse // We remap some of the iPhone keyboard keys. // The first ten here are the row of symbols below the numeric keys. switch (keyPressed) { - case 45: - keyPressed = Common::KEYCODE_F1; - ascii = Common::ASCII_F1; - break; - case 47: - keyPressed = Common::KEYCODE_F2; - ascii = Common::ASCII_F2; - break; - case 58: - keyPressed = Common::KEYCODE_F3; - ascii = Common::ASCII_F3; - break; - case 59: - keyPressed = Common::KEYCODE_F4; - ascii = Common::ASCII_F4; - break; - case 40: - keyPressed = Common::KEYCODE_F5; - ascii = Common::ASCII_F5; - break; - case 41: - keyPressed = Common::KEYCODE_F6; - ascii = Common::ASCII_F6; - break; - case 36: - keyPressed = Common::KEYCODE_F7; - ascii = Common::ASCII_F7; - break; - case 38: - keyPressed = Common::KEYCODE_F8; - ascii = Common::ASCII_F8; - break; - case 64: - keyPressed = Common::KEYCODE_F9; - ascii = Common::ASCII_F9; - break; - case 34: - keyPressed = Common::KEYCODE_F10; - ascii = Common::ASCII_F10; - break; - case 10: - keyPressed = Common::KEYCODE_RETURN; - ascii = Common::ASCII_RETURN; - break; + case 45: + keyPressed = Common::KEYCODE_F1; + ascii = Common::ASCII_F1; + break; + case 47: + keyPressed = Common::KEYCODE_F2; + ascii = Common::ASCII_F2; + break; + case 58: + keyPressed = Common::KEYCODE_F3; + ascii = Common::ASCII_F3; + break; + case 59: + keyPressed = Common::KEYCODE_F4; + ascii = Common::ASCII_F4; + break; + case 40: + keyPressed = Common::KEYCODE_F5; + ascii = Common::ASCII_F5; + break; + case 41: + keyPressed = Common::KEYCODE_F6; + ascii = Common::ASCII_F6; + break; + case 36: + keyPressed = Common::KEYCODE_F7; + ascii = Common::ASCII_F7; + break; + case 38: + keyPressed = Common::KEYCODE_F8; + ascii = Common::ASCII_F8; + break; + case 64: + keyPressed = Common::KEYCODE_F9; + ascii = Common::ASCII_F9; + break; + case 34: + keyPressed = Common::KEYCODE_F10; + ascii = Common::ASCII_F10; + break; + case 10: + keyPressed = Common::KEYCODE_RETURN; + ascii = Common::ASCII_RETURN; + break; } event.type = Common::EVENT_KEYDOWN; _queuedInputEvent.type = Common::EVENT_KEYUP; @@ -457,60 +455,60 @@ void OSystem_IPHONE::handleEvent_keyPressed(Common::Event &event, int keyPresse bool OSystem_IPHONE::handleEvent_swipe(Common::Event &event, int direction) { Common::KeyCode keycode = Common::KEYCODE_INVALID; switch (_screenOrientation) { - case kScreenOrientationPortrait: - switch ((UIViewSwipeDirection)direction) { - case kUIViewSwipeUp: - keycode = Common::KEYCODE_UP; - break; - case kUIViewSwipeDown: - keycode = Common::KEYCODE_DOWN; - break; - case kUIViewSwipeLeft: - keycode = Common::KEYCODE_LEFT; - break; - case kUIViewSwipeRight: - keycode = Common::KEYCODE_RIGHT; - break; - default: - return false; - } + case kScreenOrientationPortrait: + switch ((UIViewSwipeDirection)direction) { + case kUIViewSwipeUp: + keycode = Common::KEYCODE_UP; break; - case kScreenOrientationLandscape: - switch ((UIViewSwipeDirection)direction) { - case kUIViewSwipeUp: - keycode = Common::KEYCODE_LEFT; - break; - case kUIViewSwipeDown: - keycode = Common::KEYCODE_RIGHT; - break; - case kUIViewSwipeLeft: - keycode = Common::KEYCODE_DOWN; - break; - case kUIViewSwipeRight: - keycode = Common::KEYCODE_UP; - break; - default: - return false; - } + case kUIViewSwipeDown: + keycode = Common::KEYCODE_DOWN; break; - case kScreenOrientationFlippedLandscape: - switch ((UIViewSwipeDirection)direction) { - case kUIViewSwipeUp: - keycode = Common::KEYCODE_RIGHT; - break; - case kUIViewSwipeDown: - keycode = Common::KEYCODE_LEFT; - break; - case kUIViewSwipeLeft: - keycode = Common::KEYCODE_UP; - break; - case kUIViewSwipeRight: - keycode = Common::KEYCODE_DOWN; - break; - default: - return false; - } + case kUIViewSwipeLeft: + keycode = Common::KEYCODE_LEFT; break; + case kUIViewSwipeRight: + keycode = Common::KEYCODE_RIGHT; + break; + default: + return false; + } + break; + case kScreenOrientationLandscape: + switch ((UIViewSwipeDirection)direction) { + case kUIViewSwipeUp: + keycode = Common::KEYCODE_LEFT; + break; + case kUIViewSwipeDown: + keycode = Common::KEYCODE_RIGHT; + break; + case kUIViewSwipeLeft: + keycode = Common::KEYCODE_DOWN; + break; + case kUIViewSwipeRight: + keycode = Common::KEYCODE_UP; + break; + default: + return false; + } + break; + case kScreenOrientationFlippedLandscape: + switch ((UIViewSwipeDirection)direction) { + case kUIViewSwipeUp: + keycode = Common::KEYCODE_RIGHT; + break; + case kUIViewSwipeDown: + keycode = Common::KEYCODE_LEFT; + break; + case kUIViewSwipeLeft: + keycode = Common::KEYCODE_UP; + break; + case kUIViewSwipeRight: + keycode = Common::KEYCODE_DOWN; + break; + default: + return false; + } + break; } event.kbd.keycode = _queuedInputEvent.kbd.keycode = keycode; diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index b0f475b6ea..ba1604f435 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -60,8 +60,7 @@ OSystem_IPHONE::OSystem_IPHONE() : _screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false), _gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false), _mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0), - _overlayHeight(0), _overlayWidth(0), _overlayBuffer(0) -{ + _overlayHeight(0), _overlayWidth(0), _overlayBuffer(0) { _queuedInputEvent.type = Common::EVENT_INVALID; _lastDrawnMouseRect = Common::Rect(0, 0, 0, 0); @@ -272,7 +271,7 @@ void iphone_main(int argc, char *argv[]) { } #ifdef IPHONE_OFFICIAL - chdir( iPhone_getDocumentsDir() ); + chdir(iPhone_getDocumentsDir()); #else system("mkdir " SCUMMVM_ROOT_PATH); system("mkdir " SCUMMVM_SAVE_PATH); diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 37896cceeb..04b82ab5e4 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -42,12 +42,12 @@ typedef void (*SoundProc)(void *param, byte *buf, int len); typedef int (*TimerProc)(int interval); -typedef struct AQCallbackStruct { - AudioQueueRef queue; - uint32 frameCount; - AudioQueueBufferRef buffers[AUDIO_BUFFERS]; - AudioStreamBasicDescription dataFormat; -} AQCallbackStruct; +struct AQCallbackStruct { + AudioQueueRef queue; + uint32 frameCount; + AudioQueueBufferRef buffers[AUDIO_BUFFERS]; + AudioStreamBasicDescription dataFormat; +}; class OSystem_IPHONE : public EventsBaseBackend, public PaletteManager { protected: @@ -167,7 +167,7 @@ public: static void mixCallback(void *sys, byte *samples, int len); virtual void setupMixer(void); virtual void setTimerCallback(TimerProc callback, int interval); - virtual int getScreenChangeID() const { return _screenChangeCount; } + virtual int getScreenChangeID() const { return _screenChangeCount; } virtual void quit(); virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0); @@ -188,10 +188,10 @@ protected: void dirtyFullOverlayScreen(); void clipRectToScreen(int16 &x, int16 &y, int16 &w, int16 &h); void suspendLoop(); - void drawDirtyRect(const Common::Rect& dirtyRect); - void drawDirtyOverlayRect(const Common::Rect& dirtyRect); - void drawMouseCursorOnRectUpdate(const Common::Rect& updatedRect, const Common::Rect& mouseRect); - void updateHardwareSurfaceForRect(const Common::Rect& updatedRect); + void drawDirtyRect(const Common::Rect &dirtyRect); + void drawDirtyOverlayRect(const Common::Rect &dirtyRect); + void drawMouseCursorOnRectUpdate(const Common::Rect &updatedRect, const Common::Rect &mouseRect); + void updateHardwareSurfaceForRect(const Common::Rect &updatedRect); static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB); static int timerHandler(int t); diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index f9ae5ea06b..8aabe4e6e9 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -25,7 +25,7 @@ #include "osys_main.h" -const OSystem::GraphicsMode* OSystem_IPHONE::getSupportedGraphicsModes() const { +const OSystem::GraphicsMode *OSystem_IPHONE::getSupportedGraphicsModes() const { return s_supportedGraphicsModes; } @@ -248,7 +248,7 @@ void OSystem_IPHONE::internUpdateScreen() { } } -void OSystem_IPHONE::drawDirtyRect(const Common::Rect& dirtyRect) { +void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { int h = dirtyRect.bottom - dirtyRect.top; int w = dirtyRect.right - dirtyRect.left; @@ -263,7 +263,7 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect& dirtyRect) { } } -void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect& dirtyRect) { +void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) { // int h = dirtyRect.bottom - dirtyRect.top; // // uint16 *src = (uint16 *)&_overlayBuffer[dirtyRect.top * _screenWidth + dirtyRect.left]; @@ -277,7 +277,7 @@ void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect& dirtyRect) { iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); } -void OSystem_IPHONE::drawMouseCursorOnRectUpdate(const Common::Rect& updatedRect, const Common::Rect& mouseRect) { +void OSystem_IPHONE::drawMouseCursorOnRectUpdate(const Common::Rect &updatedRect, const Common::Rect &mouseRect) { //draw mouse on top if (_mouseVisible && (updatedRect.intersects(mouseRect))) { int srcX = 0; @@ -320,8 +320,8 @@ void OSystem_IPHONE::drawMouseCursorOnRectUpdate(const Common::Rect& updatedRect } } -void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect& updatedRect) { - iPhone_updateScreenRect(_fullscreen, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom ); +void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) { + iPhone_updateScreenRect(_fullscreen, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom); } Graphics::Surface *OSystem_IPHONE::lockScreen() { @@ -466,7 +466,7 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot int texWidth = getSizeNextPOT(w); int texHeight = getSizeNextPOT(h); int bufferSize = texWidth * texHeight * sizeof(int16); - int16* mouseBuf = (int16 *)malloc(bufferSize); + int16 *mouseBuf = (int16 *)malloc(bufferSize); memset(mouseBuf, 0, bufferSize); for (uint x = 0; x < w; ++x) { -- cgit v1.2.3 From 13358c541df46b03d3c25a9fa7e4615c64424517 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 19 Feb 2012 21:44:37 +0100 Subject: IPHONE: Add include guards. --- backends/platform/iphone/iphone_common.h | 5 +++++ backends/platform/iphone/iphone_keyboard.h | 5 +++++ backends/platform/iphone/iphone_video.h | 8 +++----- backends/platform/iphone/osys_main.h | 5 +++++ 4 files changed, 18 insertions(+), 5 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 9bf559860e..d6d3a3dc6f 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -20,6 +20,9 @@ * */ +#ifndef BACKENDS_PLATFORM_IPHONE_IPHONE_COMMON_H +#define BACKENDS_PLATFORM_IPHONE_IPHONE_COMMON_H + enum InputEvent { kInputMouseDown, kInputMouseUp, @@ -79,3 +82,5 @@ uint getSizeNextPOT(uint size); #ifdef __cplusplus } #endif + +#endif diff --git a/backends/platform/iphone/iphone_keyboard.h b/backends/platform/iphone/iphone_keyboard.h index 6d64f90ffd..b13ac35616 100644 --- a/backends/platform/iphone/iphone_keyboard.h +++ b/backends/platform/iphone/iphone_keyboard.h @@ -20,6 +20,9 @@ * */ +#ifndef BACKENDS_PLATFORM_IPHONE_IPHONE_KEYBOARD_H +#define BACKENDS_PLATFORM_IPHONE_IPHONE_KEYBOARD_H + #import #import @@ -34,3 +37,5 @@ - (void)handleKeyPress:(unichar)c; @end + +#endif diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 21593b2c3d..a7a83e2a99 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -20,8 +20,8 @@ * */ -#ifndef _IPHONE_VIDEO__H -#define _IPHONE_VIDEO__H +#ifndef BACKENDS_PLATFORM_IPHONE_IPHONE_VIDEO_H +#define BACKENDS_PLATFORM_IPHONE_IPHONE_VIDEO_H #import #import @@ -80,6 +80,4 @@ @end - - -#endif /* _IPHONE_VIDEO__H */ +#endif diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 04b82ab5e4..993c1aab4c 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -20,6 +20,9 @@ * */ +#ifndef BACKENDS_PLATFORM_IPHONE_OSYS_MAIN_H +#define BACKENDS_PLATFORM_IPHONE_OSYS_MAIN_H + #include "graphics/surface.h" #include "iphone_common.h" #include "backends/base-backend.h" @@ -208,3 +211,5 @@ protected: bool handleEvent_mouseDragged(Common::Event &event, int x, int y); bool handleEvent_mouseSecondDragged(Common::Event &event, int x, int y); }; + +#endif -- cgit v1.2.3 From 6a31dadfea1d13970e7d0bb21f3a9b2287ff067d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 19 Feb 2012 22:10:08 +0100 Subject: IPHONE: Use include instead of import for all of our headers. --- backends/platform/iphone/iphone_keyboard.m | 2 +- backends/platform/iphone/iphone_video.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_keyboard.m b/backends/platform/iphone/iphone_keyboard.m index 4d92b15450..b00930ab31 100644 --- a/backends/platform/iphone/iphone_keyboard.m +++ b/backends/platform/iphone/iphone_keyboard.m @@ -20,7 +20,7 @@ * */ -#import "iphone_keyboard.h" +#include "iphone_keyboard.h" @interface UITextInputTraits - (void)setAutocorrectionType:(int)type; diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index a7a83e2a99..25208deaaf 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -31,7 +31,7 @@ #import #import -#import "iphone_keyboard.h" +#include "iphone_keyboard.h" @interface iPhoneView : UIView { void *_screenSurface; -- cgit v1.2.3 From ceae3dd191039711ea388e2878397d26a0932611 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 19 Feb 2012 22:16:38 +0100 Subject: IPHONE: Rename _palette to _gamePalette. --- backends/platform/iphone/osys_main.h | 2 +- backends/platform/iphone/osys_video.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 993c1aab4c..b89eed9d43 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -70,7 +70,7 @@ protected: uint16 *_fullscreen; - uint16 _palette[256]; + uint16 _gamePalette[256]; bool _overlayVisible; uint16 _screenWidth; uint16 _screenHeight; diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index 8aabe4e6e9..c97b6757ea 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -98,7 +98,7 @@ void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { const byte *b = colors; for (uint i = start; i < start + num; ++i) { - _palette[i] = Graphics::RGBToColor >(b[0], b[1], b[2]); + _gamePalette[i] = Graphics::RGBToColor >(b[0], b[1], b[2]); b += 3; } @@ -110,7 +110,7 @@ void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) { byte *b = colors; for (uint i = start; i < start + num; ++i) { - Graphics::colorToRGB >(_palette[i], b[0], b[1], b[2]); + Graphics::colorToRGB >(_gamePalette[i], b[0], b[1], b[2]); b += 3; } } @@ -256,7 +256,7 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left]; for (int y = h; y > 0; y--) { for (int x = w; x > 0; x--) - *dst++ = _palette[*src++]; + *dst++ = _gamePalette[*src++]; dst += _screenWidth - w; src += _screenWidth - w; @@ -310,7 +310,7 @@ void OSystem_IPHONE::drawMouseCursorOnRectUpdate(const Common::Rect &updatedRect for (int y = displayHeight; y > srcY; y--) { for (int x = displayWidth; x > srcX; x--) { if (*src != _mouseKeyColor) - *dst = _palette[*src]; + *dst = _gamePalette[*src]; dst++; src++; } @@ -473,7 +473,7 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot for (uint y = 0; y < h; ++y) { byte color = buf[y * w + x]; if (color != keycolor) - mouseBuf[y * texWidth + x] = _palette[color] | 0x1; + mouseBuf[y * texWidth + x] = _gamePalette[color] | 0x1; else mouseBuf[y * texWidth + x] = 0x0; } -- cgit v1.2.3 From 87d85a7b20c611898bbb4c714b40de5691a8d8ff Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 19 Feb 2012 22:19:38 +0100 Subject: IPHONE: Use the proper RGBA5551 palette for the mouse cursor. Formerly the overlay cursor was using a RGB565 palette, even though the texture is really set up as RGBA5551. --- backends/platform/iphone/osys_main.h | 3 +++ backends/platform/iphone/osys_video.cpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index b89eed9d43..c63ba41319 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -70,7 +70,10 @@ protected: uint16 *_fullscreen; + // For use with the game texture uint16 _gamePalette[256]; + // For use with the mouse texture + uint16 _gamePaletteRGBA5551[256]; bool _overlayVisible; uint16 _screenWidth; uint16 _screenHeight; diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index c97b6757ea..3b14126234 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -99,6 +99,7 @@ void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { for (uint i = start; i < start + num; ++i) { _gamePalette[i] = Graphics::RGBToColor >(b[0], b[1], b[2]); + _gamePaletteRGBA5551[i] = Graphics::RGBToColor >(b[0], b[1], b[2]); b += 3; } @@ -473,7 +474,7 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot for (uint y = 0; y < h; ++y) { byte color = buf[y * w + x]; if (color != keycolor) - mouseBuf[y * texWidth + x] = _gamePalette[color] | 0x1; + mouseBuf[y * texWidth + x] = _gamePaletteRGBA5551[color] | 0x1; else mouseBuf[y * texWidth + x] = 0x0; } -- cgit v1.2.3 From 68bbe973bdbf0a455fc416f2c533092d920f5ac7 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 00:04:47 +0100 Subject: IPHONE: Always use the mouse texture. Formerly the mouse texture was only used when the overlay was visible. When only the game screen was visible, the code rendered the mouse cursor on the game screen texture. This simplifies the drawing pipeline a bit. --- backends/platform/iphone/iphone_video.m | 44 +++++++++----- backends/platform/iphone/osys_main.cpp | 2 - backends/platform/iphone/osys_main.h | 3 - backends/platform/iphone/osys_video.cpp | 102 +------------------------------- 4 files changed, 31 insertions(+), 120 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index 4ef43f20df..df95b36310 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -108,8 +108,8 @@ void iPhone_updateScreen(int mouseX, int mouseY) { //_mouseX = _overlayHeight - mouseX; //_mouseY = mouseY; - _mouseX = (_overlayWidth - mouseX) / (float)_overlayWidth * _overlayHeight; - _mouseY = mouseY / (float)_overlayHeight * _overlayWidth; + _mouseX = mouseX; + _mouseY = mouseY; if (!_needsScreenUpdate) { _needsScreenUpdate = 1; @@ -259,16 +259,14 @@ bool getLocalMouseCoords(CGPoint *point) { } _needsScreenUpdate = 0; - if (_overlayIsEnabled) { - glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); - } + glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); [self updateMainSurface]; - if (_overlayIsEnabled) { + if (_overlayIsEnabled) [self updateOverlaySurface]; - [self updateMouseSurface]; - } + + [self updateMouseSurface]; glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); [_context presentRenderbuffer:GL_RENDERBUFFER_OES]; @@ -350,14 +348,32 @@ bool getLocalMouseCoords(CGPoint *point) { - (void)updateMouseSurface { - int width = _mouseCursorWidth / (float)_backingWidth * _backingHeight; - int height = _mouseCursorHeight / (float)_backingHeight * _backingWidth; + int width = _mouseCursorWidth; + int height = _mouseCursorHeight; + + int mouseX = _mouseX; + int mouseY = _mouseY; + + if (!_overlayIsEnabled) { + const GLint gameWidth = (_visibleHeight - 2 * _widthOffset); + const GLint gameHeight = (_visibleWidth - 2 * _heightOffset); + + mouseX = (_width - mouseX) / (float)_width * gameHeight + _heightOffset; + mouseY = mouseY / (float)_height * gameWidth + _widthOffset; + width = width / (float)_width * gameHeight; + height = height / (float)_height * gameWidth; + } else { + mouseX = (_overlayWidth - mouseX) / (float)_overlayWidth * _backingWidth; + mouseY = mouseY / (float)_overlayHeight * _backingHeight; + width = width / (float)_overlayWidth * _backingWidth; + height = height / (float)_overlayHeight * _backingHeight; + } GLfloat vertices[] = { - _mouseX, _mouseY, - _mouseX + height, _mouseY, - _mouseX, _mouseY + width, - _mouseX + height, _mouseY + width + mouseX , mouseY, + mouseX + width, mouseY, + mouseX , mouseY + height, + mouseX + width, mouseY + height }; //printf("Cursor: width %u height %u\n", _mouseCursorWidth, _mouseCursorHeight); diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index ba1604f435..5cf8913835 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -62,8 +62,6 @@ OSystem_IPHONE::OSystem_IPHONE() : _mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0), _overlayHeight(0), _overlayWidth(0), _overlayBuffer(0) { _queuedInputEvent.type = Common::EVENT_INVALID; - _lastDrawnMouseRect = Common::Rect(0, 0, 0, 0); - _touchpadModeEnabled = !iPhone_isHighResDevice(); _fsFactory = new POSIXFilesystemFactory(); } diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index c63ba41319..dad2e9f676 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -91,7 +91,6 @@ protected: long _lastMouseDown; long _lastMouseTap; long _queuedEventTime; - Common::Rect _lastDrawnMouseRect; Common::Event _queuedInputEvent; bool _secondaryTapped; long _lastSecondaryDown; @@ -192,11 +191,9 @@ protected: void internUpdateScreen(); void dirtyFullScreen(); void dirtyFullOverlayScreen(); - void clipRectToScreen(int16 &x, int16 &y, int16 &w, int16 &h); void suspendLoop(); void drawDirtyRect(const Common::Rect &dirtyRect); void drawDirtyOverlayRect(const Common::Rect &dirtyRect); - void drawMouseCursorOnRectUpdate(const Common::Rect &updatedRect, const Common::Rect &mouseRect); void updateHardwareSurfaceForRect(const Common::Rect &updatedRect); static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB); static int timerHandler(int t); diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index 3b14126234..ad434153ec 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -159,32 +159,6 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, } } -void OSystem_IPHONE::clipRectToScreen(int16 &x, int16 &y, int16 &w, int16 &h) { - if (x < 0) { - w += x; - x = 0; - } - - if (y < 0) { - h += y; - y = 0; - } - - if (w > _screenWidth - x) - w = _screenWidth - x; - - if (h > _screenHeight - y) - h = _screenHeight - y; - - if (w < 0) { - w = 0; - } - - if (h < 0) { - h = 0; - } -} - void OSystem_IPHONE::updateScreen() { //printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size()); @@ -192,6 +166,7 @@ void OSystem_IPHONE::updateScreen() { return; internUpdateScreen(); + _mouseDirty = false; _fullScreenIsDirty = false; _fullScreenOverlayIsDirty = false; @@ -199,40 +174,11 @@ void OSystem_IPHONE::updateScreen() { } void OSystem_IPHONE::internUpdateScreen() { - int16 mouseX = _mouseX - _mouseHotspotX; - int16 mouseY = _mouseY - _mouseHotspotY; - int16 mouseWidth = _mouseWidth; - int16 mouseHeight = _mouseHeight; - - clipRectToScreen(mouseX, mouseY, mouseWidth, mouseHeight); - - Common::Rect mouseRect(mouseX, mouseY, mouseX + mouseWidth, mouseY + mouseHeight); - - if (_mouseDirty) { - if (!_fullScreenIsDirty) { - _dirtyRects.push_back(_lastDrawnMouseRect); - _dirtyRects.push_back(mouseRect); - } - if (!_fullScreenOverlayIsDirty && _overlayVisible) { - _dirtyOverlayRects.push_back(_lastDrawnMouseRect); - _dirtyOverlayRects.push_back(mouseRect); - } - _mouseDirty = false; - _lastDrawnMouseRect = mouseRect; - } - while (_dirtyRects.size()) { Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1); //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); - drawDirtyRect(dirtyRect); - - if (_overlayVisible) - drawDirtyOverlayRect(dirtyRect); - else - drawMouseCursorOnRectUpdate(dirtyRect, mouseRect); - updateHardwareSurfaceForRect(dirtyRect); } @@ -241,10 +187,7 @@ void OSystem_IPHONE::internUpdateScreen() { Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1); //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); - drawDirtyOverlayRect(dirtyRect); - //drawMouseCursorOnRectUpdate(dirtyRect, mouseRect); - //updateHardwareSurfaceForRect(dirtyRect); } } } @@ -278,49 +221,6 @@ void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) { iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); } -void OSystem_IPHONE::drawMouseCursorOnRectUpdate(const Common::Rect &updatedRect, const Common::Rect &mouseRect) { - //draw mouse on top - if (_mouseVisible && (updatedRect.intersects(mouseRect))) { - int srcX = 0; - int srcY = 0; - int left = _mouseX - _mouseHotspotX; - if (left < 0) { - srcX -= left; - left = 0; - } - int top = _mouseY - _mouseHotspotY; - if (top < 0) { - srcY -= top; - top = 0; - } - - int bottom = top + _mouseHeight; - if (bottom > _screenWidth) - bottom = _screenWidth; - - int displayWidth = _mouseWidth; - if (_mouseWidth + left > _screenWidth) - displayWidth = _screenWidth - left; - - int displayHeight = _mouseHeight; - if (_mouseHeight + top > _screenHeight) - displayHeight = _screenHeight - top; - - byte *src = &_mouseBuf[srcY * _mouseWidth + srcX]; - uint16 *dst = &_fullscreen[top * _screenWidth + left]; - for (int y = displayHeight; y > srcY; y--) { - for (int x = displayWidth; x > srcX; x--) { - if (*src != _mouseKeyColor) - *dst = _gamePalette[*src]; - dst++; - src++; - } - dst += _screenWidth - displayWidth + srcX; - src += _mouseWidth - displayWidth + srcX; - } - } -} - void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) { iPhone_updateScreenRect(_fullscreen, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom); } -- cgit v1.2.3 From 438bc50115b7d1faf62c5821514d9941792790d0 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 00:25:48 +0100 Subject: IPHONE: Fix cursor hotspots. --- backends/platform/iphone/iphone_common.h | 2 +- backends/platform/iphone/iphone_video.m | 17 ++++++++++++++++- backends/platform/iphone/osys_video.cpp | 4 ++-- 3 files changed, 19 insertions(+), 4 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index d6d3a3dc6f..98d1244054 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -75,7 +75,7 @@ bool iPhone_isHighResDevice(); int iPhone_getScreenHeight(); int iPhone_getScreenWidth(); void iPhone_enableOverlay(int state); -void iPhone_setMouseCursor(short *buffer, int width, int height); +void iPhone_setMouseCursor(short *buffer, int width, int height, int hotspotX, int hotspotY); uint getSizeNextPOT(uint size); diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index df95b36310..a412945a5e 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -51,6 +51,8 @@ static UITouch *_secondTouch = NULL; static short *_mouseCursor = NULL; static int _mouseCursorHeight = 0; static int _mouseCursorWidth = 0; +static int _mouseCursorHotspotX = 0; +static int _mouseCursorHotspotY = 0; static int _mouseX = 0; static int _mouseY = 0; @@ -72,12 +74,15 @@ int printOglError(const char *file, int line) { return retCode; } -void iPhone_setMouseCursor(short *buffer, int width, int height) { +void iPhone_setMouseCursor(short *buffer, int width, int height, int hotspotX, int hotspotY) { _mouseCursor = buffer; _mouseCursorWidth = width; _mouseCursorHeight = height; + _mouseCursorHotspotX = hotspotX; + _mouseCursorHotspotY = hotspotY; + [sharedInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; } @@ -354,21 +359,31 @@ bool getLocalMouseCoords(CGPoint *point) { int mouseX = _mouseX; int mouseY = _mouseY; + int hotspotX = _mouseCursorHotspotX; + int hotspotY = _mouseCursorHotspotY; + if (!_overlayIsEnabled) { const GLint gameWidth = (_visibleHeight - 2 * _widthOffset); const GLint gameHeight = (_visibleWidth - 2 * _heightOffset); mouseX = (_width - mouseX) / (float)_width * gameHeight + _heightOffset; mouseY = mouseY / (float)_height * gameWidth + _widthOffset; + hotspotX = hotspotX / (float)_width * gameHeight; + hotspotY = hotspotY / (float)_height * gameWidth; width = width / (float)_width * gameHeight; height = height / (float)_height * gameWidth; } else { mouseX = (_overlayWidth - mouseX) / (float)_overlayWidth * _backingWidth; mouseY = mouseY / (float)_overlayHeight * _backingHeight; + hotspotX = hotspotX / (float)_overlayWidth * _backingWidth; + hotspotY = hotspotY / (float)_overlayHeight * _backingHeight; width = width / (float)_overlayWidth * _backingWidth; height = height / (float)_overlayHeight * _backingHeight; } + mouseX -= hotspotX; + mouseY -= hotspotY; + GLfloat vertices[] = { mouseX , mouseY, mouseX + width, mouseY, diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index ad434153ec..4d3d49c552 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -170,7 +170,7 @@ void OSystem_IPHONE::updateScreen() { _fullScreenIsDirty = false; _fullScreenOverlayIsDirty = false; - iPhone_updateScreen(_mouseX - _mouseHotspotX, _mouseY - _mouseHotspotY); + iPhone_updateScreen(_mouseX, _mouseY); } void OSystem_IPHONE::internUpdateScreen() { @@ -380,7 +380,7 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot } } - iPhone_setMouseCursor(mouseBuf, w, h); + iPhone_setMouseCursor(mouseBuf, w, h, hotspotX, hotspotY); if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) { free(_mouseBuf); -- cgit v1.2.3 From 93d80793b459d6567fdd9717e02a3473e5f4fcec Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 00:29:08 +0100 Subject: IPHONE: Implement cursor visibility change again. --- backends/platform/iphone/iphone_common.h | 1 + backends/platform/iphone/iphone_video.m | 8 +++++++- backends/platform/iphone/osys_video.cpp | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 98d1244054..470c042b0e 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -75,6 +75,7 @@ bool iPhone_isHighResDevice(); int iPhone_getScreenHeight(); int iPhone_getScreenWidth(); void iPhone_enableOverlay(int state); +void iPhone_showCursor(int state); void iPhone_setMouseCursor(short *buffer, int width, int height, int hotspotX, int hotspotY); uint getSizeNextPOT(uint size); diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index a412945a5e..a18d68e6da 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -55,6 +55,7 @@ static int _mouseCursorHotspotX = 0; static int _mouseCursorHotspotY = 0; static int _mouseX = 0; static int _mouseY = 0; +static int _mouseCursorEnabled = 0; // static long lastTick = 0; // static int frames = 0; @@ -74,6 +75,10 @@ int printOglError(const char *file, int line) { return retCode; } +void iPhone_showCursor(int state) { + _mouseCursorEnabled = state; +} + void iPhone_setMouseCursor(short *buffer, int width, int height, int hotspotX, int hotspotY) { _mouseCursor = buffer; @@ -271,7 +276,8 @@ bool getLocalMouseCoords(CGPoint *point) { if (_overlayIsEnabled) [self updateOverlaySurface]; - [self updateMouseSurface]; + if (_mouseCursorEnabled) + [self updateMouseSurface]; glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); [_context presentRenderbuffer:GL_RENDERBUFFER_OES]; diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index 4d3d49c552..2c9e5633a4 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -332,6 +332,7 @@ int16 OSystem_IPHONE::getOverlayWidth() { bool OSystem_IPHONE::showMouse(bool visible) { bool last = _mouseVisible; _mouseVisible = visible; + iPhone_showCursor(visible); _mouseDirty = true; return last; -- cgit v1.2.3 From 723a38c699d2bd7a8e8967e231ae4360d5a77f1b Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 00:35:14 +0100 Subject: IPHONE: Rename screen related buffers a bit. --- backends/platform/iphone/osys_main.cpp | 8 ++++---- backends/platform/iphone/osys_main.h | 4 ++-- backends/platform/iphone/osys_video.cpp | 22 +++++++++++----------- 3 files changed, 17 insertions(+), 17 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 5cf8913835..8064fe4445 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -53,8 +53,8 @@ SoundProc OSystem_IPHONE::s_soundCallback = NULL; void *OSystem_IPHONE::s_soundParam = NULL; OSystem_IPHONE::OSystem_IPHONE() : - _mixer(NULL), _offscreen(NULL), - _overlayVisible(false), _fullscreen(NULL), + _mixer(NULL), _gameScreenRaw(NULL), + _overlayVisible(false), _gameScreenConverted(NULL), _mouseHeight(0), _mouseWidth(0), _mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0), _secondaryTapped(false), _lastSecondaryTap(0), _screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false), @@ -70,8 +70,8 @@ OSystem_IPHONE::~OSystem_IPHONE() { AudioQueueDispose(s_AudioQueue.queue, true); delete _mixer; - delete _offscreen; - delete _fullscreen; + delete _gameScreenRaw; + delete _gameScreenConverted; } int OSystem_IPHONE::timerHandler(int t) { diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index dad2e9f676..6a779a8fde 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -63,12 +63,12 @@ protected: Audio::MixerImpl *_mixer; Graphics::Surface _framebuffer; - byte *_offscreen; + byte *_gameScreenRaw; OverlayColor *_overlayBuffer; uint16 _overlayHeight; uint16 _overlayWidth; - uint16 *_fullscreen; + uint16 *_gameScreenConverted; // For use with the game texture uint16 _gamePalette[256]; diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index 2c9e5633a4..2b86c1d1de 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -52,10 +52,10 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm _screenWidth = width; _screenHeight = height; - free(_offscreen); + free(_gameScreenRaw); - _offscreen = (byte *)malloc(width * height); - bzero(_offscreen, width * height); + _gameScreenRaw = (byte *)malloc(width * height); + bzero(_gameScreenRaw, width * height); //free(_overlayBuffer); @@ -63,10 +63,10 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm //_overlayBuffer = (OverlayColor *)malloc(fullSize); clearOverlay(); - free(_fullscreen); + free(_gameScreenConverted); - _fullscreen = (uint16 *)malloc(fullSize); - bzero(_fullscreen, fullSize); + _gameScreenConverted = (uint16 *)malloc(fullSize); + bzero(_gameScreenConverted, fullSize); iPhone_initSurface(width, height); @@ -147,7 +147,7 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, } - byte *dst = _offscreen + y * _screenWidth + x; + byte *dst = _gameScreenRaw + y * _screenWidth + x; if (_screenWidth == pitch && pitch == w) memcpy(dst, buf, h * w); else { @@ -196,8 +196,8 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { int h = dirtyRect.bottom - dirtyRect.top; int w = dirtyRect.right - dirtyRect.left; - byte *src = &_offscreen[dirtyRect.top * _screenWidth + dirtyRect.left]; - uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left]; + byte *src = &_gameScreenRaw[dirtyRect.top * _screenWidth + dirtyRect.left]; + uint16 *dst = &_gameScreenConverted[dirtyRect.top * _screenWidth + dirtyRect.left]; for (int y = h; y > 0; y--) { for (int x = w; x > 0; x--) *dst++ = _gamePalette[*src++]; @@ -222,13 +222,13 @@ void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) { } void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) { - iPhone_updateScreenRect(_fullscreen, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom); + iPhone_updateScreenRect(_gameScreenConverted, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom); } Graphics::Surface *OSystem_IPHONE::lockScreen() { //printf("lockScreen()\n"); - _framebuffer.pixels = _offscreen; + _framebuffer.pixels = _gameScreenRaw; _framebuffer.w = _screenWidth; _framebuffer.h = _screenHeight; _framebuffer.pitch = _screenWidth; -- cgit v1.2.3 From 1b9c4f38456d607abf13dc483bd205351553122f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 00:35:44 +0100 Subject: IPHONE: Remove some dead code. --- backends/platform/iphone/osys_video.cpp | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index 2b86c1d1de..a610708478 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -208,16 +208,6 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { } void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) { - // int h = dirtyRect.bottom - dirtyRect.top; - // - // uint16 *src = (uint16 *)&_overlayBuffer[dirtyRect.top * _screenWidth + dirtyRect.left]; - // uint16 *dst = &_fullscreen[dirtyRect.top * _screenWidth + dirtyRect.left]; - // int x = (dirtyRect.right - dirtyRect.left) * 2; - // for (int y = h; y > 0; y--) { - // memcpy(dst, src, x); - // src += _screenWidth; - // dst += _screenWidth; - // } iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); } -- cgit v1.2.3 From 65cda4cd6b39c9b9e694a0a8ef696458ac1c2b20 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 00:36:13 +0100 Subject: IPHONE: Fix some mismatching malloc/delete calls. --- backends/platform/iphone/osys_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 8064fe4445..c47a2fc3a1 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -70,8 +70,8 @@ OSystem_IPHONE::~OSystem_IPHONE() { AudioQueueDispose(s_AudioQueue.queue, true); delete _mixer; - delete _gameScreenRaw; - delete _gameScreenConverted; + free(_gameScreenRaw); + free(_gameScreenConverted); } int OSystem_IPHONE::timerHandler(int t) { -- cgit v1.2.3 From 8102e7e645db5103369799cd7aae390da099746f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 01:07:48 +0100 Subject: IPHONE: Implement cursor palette support. --- backends/platform/iphone/iphone_common.h | 2 +- backends/platform/iphone/iphone_video.m | 8 ++-- backends/platform/iphone/osys_main.cpp | 32 ++++++++++++++-- backends/platform/iphone/osys_main.h | 5 +++ backends/platform/iphone/osys_video.cpp | 65 +++++++++++++++++++++++--------- 5 files changed, 84 insertions(+), 28 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 470c042b0e..2c573656a6 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -76,7 +76,7 @@ int iPhone_getScreenHeight(); int iPhone_getScreenWidth(); void iPhone_enableOverlay(int state); void iPhone_showCursor(int state); -void iPhone_setMouseCursor(short *buffer, int width, int height, int hotspotX, int hotspotY); +void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int hotspotX, int hotspotY); uint getSizeNextPOT(uint size); diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index a18d68e6da..c1633841f5 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -48,7 +48,7 @@ static int _overlayIsEnabled = 0; static UITouch *_firstTouch = NULL; static UITouch *_secondTouch = NULL; -static short *_mouseCursor = NULL; +static unsigned short *_mouseCursor = NULL; static int _mouseCursorHeight = 0; static int _mouseCursorWidth = 0; static int _mouseCursorHotspotX = 0; @@ -79,7 +79,7 @@ void iPhone_showCursor(int state) { _mouseCursorEnabled = state; } -void iPhone_setMouseCursor(short *buffer, int width, int height, int hotspotX, int hotspotY) { +void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int hotspotX, int hotspotY) { _mouseCursor = buffer; _mouseCursorWidth = width; @@ -326,7 +326,6 @@ bool getLocalMouseCoords(CGPoint *point) { // due to the iPhone internals having to convert the whole texture back from its internal format when used. // In the future we could use several tiled textures instead. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _textureWidth, _textureHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _textureBuffer); printOpenGLError(); - glDisable(GL_BLEND); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); } @@ -353,7 +352,6 @@ bool getLocalMouseCoords(CGPoint *point) { glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError(); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _overlayTexWidth, _overlayTexHeight, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _overlayTexBuffer); printOpenGLError(); - glEnable(GL_BLEND); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); } @@ -413,7 +411,6 @@ bool getLocalMouseCoords(CGPoint *point) { glTexCoordPointer(2, GL_FLOAT, 0, texCoords); printOpenGLError(); glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); - glEnable(GL_BLEND); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); } @@ -463,6 +460,7 @@ bool getLocalMouseCoords(CGPoint *point) { glViewport(0, 0, _backingWidth, _backingHeight); printOpenGLError(); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); printOpenGLError(); + glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_TEXTURE_2D); printOpenGLError(); diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index c47a2fc3a1..06b32270f4 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -56,11 +56,11 @@ OSystem_IPHONE::OSystem_IPHONE() : _mixer(NULL), _gameScreenRaw(NULL), _overlayVisible(false), _gameScreenConverted(NULL), _mouseHeight(0), _mouseWidth(0), _mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0), - _secondaryTapped(false), _lastSecondaryTap(0), + _mouseNeedTextureUpdate(false), _secondaryTapped(false), _lastSecondaryTap(0), _screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false), _gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false), _mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0), - _overlayHeight(0), _overlayWidth(0), _overlayBuffer(0) { + _overlayHeight(0), _overlayWidth(0), _overlayBuffer(0), _mouseCursorPaletteEnabled(false) { _queuedInputEvent.type = Common::EVENT_INVALID; _touchpadModeEnabled = !iPhone_isHighResDevice(); _fsFactory = new POSIXFilesystemFactory(); @@ -99,14 +99,38 @@ void OSystem_IPHONE::initBackend() { } bool OSystem_IPHONE::hasFeature(Feature f) { - return false; + switch (f) { + case kFeatureCursorPalette: + return true; + + default: + return false; + } } void OSystem_IPHONE::setFeatureState(Feature f, bool enable) { + switch (f) { + case kFeatureCursorPalette: + if (_mouseCursorPaletteEnabled != enable) { + _mouseNeedTextureUpdate = true; + _mouseDirty = true; + _mouseCursorPaletteEnabled = enable; + } + break; + + default: + break; + } } bool OSystem_IPHONE::getFeatureState(Feature f) { - return false; + switch (f) { + case kFeatureCursorPalette: + return _mouseCursorPaletteEnabled; + + default: + return false; + } } void OSystem_IPHONE::suspendLoop() { diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 6a779a8fde..61816cfa35 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -82,12 +82,15 @@ protected: uint32 _timeSuspended; bool _mouseVisible; + bool _mouseCursorPaletteEnabled; + uint16 _mouseCursorPalette[256]; byte *_mouseBuf; byte _mouseKeyColor; uint _mouseWidth, _mouseHeight; uint _mouseX, _mouseY; int _mouseHotspotX, _mouseHotspotY; bool _mouseDirty; + bool _mouseNeedTextureUpdate; long _lastMouseDown; long _lastMouseTap; long _queuedEventTime; @@ -159,6 +162,7 @@ public: virtual void warpMouse(int x, int y); virtual void setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor = 255, int cursorTargetScale = 1, const Graphics::PixelFormat *format = NULL); + virtual void setCursorPalette(const byte *colors, uint start, uint num); virtual bool pollEvent(Common::Event &event); virtual uint32 getMillis(); @@ -195,6 +199,7 @@ protected: void drawDirtyRect(const Common::Rect &dirtyRect); void drawDirtyOverlayRect(const Common::Rect &dirtyRect); void updateHardwareSurfaceForRect(const Common::Rect &updatedRect); + void updateMouseTexture(); static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB); static int timerHandler(int t); diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index a610708478..0483c72949 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -81,6 +81,7 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm _fullScreenIsDirty = false; dirtyFullScreen(); _mouseVisible = false; + _mouseCursorPaletteEnabled = false; _screenChangeCount++; updateScreen(); } @@ -174,6 +175,11 @@ void OSystem_IPHONE::updateScreen() { } void OSystem_IPHONE::internUpdateScreen() { + if (_mouseNeedTextureUpdate) { + updateMouseTexture(); + _mouseNeedTextureUpdate = false; + } + while (_dirtyRects.size()) { Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1); @@ -355,24 +361,6 @@ void OSystem_IPHONE::dirtyFullOverlayScreen() { void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { //printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale); - int texWidth = getSizeNextPOT(w); - int texHeight = getSizeNextPOT(h); - int bufferSize = texWidth * texHeight * sizeof(int16); - int16 *mouseBuf = (int16 *)malloc(bufferSize); - memset(mouseBuf, 0, bufferSize); - - for (uint x = 0; x < w; ++x) { - for (uint y = 0; y < h; ++y) { - byte color = buf[y * w + x]; - if (color != keycolor) - mouseBuf[y * texWidth + x] = _gamePaletteRGBA5551[color] | 0x1; - else - mouseBuf[y * texWidth + x] = 0x0; - } - } - - iPhone_setMouseCursor(mouseBuf, w, h, hotspotX, hotspotY); - if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) { free(_mouseBuf); _mouseBuf = NULL; @@ -392,4 +380,45 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot memcpy(_mouseBuf, buf, w * h); _mouseDirty = true; + _mouseNeedTextureUpdate = true; +} + +void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num) { + assert(start + num <= 256); + + for (uint i = start; i < start + num; ++i, colors += 3) + _mouseCursorPalette[i] = Graphics::RGBToColor >(colors[0], colors[1], colors[2]); + + // FIXME: This is just stupid, our client code seems to assume that this + // automatically enables the cursor palette. + _mouseCursorPaletteEnabled = true; + + if (_mouseCursorPaletteEnabled) + _mouseDirty = _mouseNeedTextureUpdate = true; +} + +void OSystem_IPHONE::updateMouseTexture() { + int texWidth = getSizeNextPOT(_mouseWidth); + int texHeight = getSizeNextPOT(_mouseHeight); + int bufferSize = texWidth * texHeight * sizeof(int16); + uint16 *mouseBuf = (uint16 *)malloc(bufferSize); + memset(mouseBuf, 0, bufferSize); + + const uint16 *palette; + if (_mouseCursorPaletteEnabled) + palette = _mouseCursorPalette; + else + palette = _gamePaletteRGBA5551; + + for (uint x = 0; x < _mouseWidth; ++x) { + for (uint y = 0; y < _mouseHeight; ++y) { + const byte color = _mouseBuf[y * _mouseWidth + x]; + if (color != _mouseKeyColor) + mouseBuf[y * texWidth + x] = palette[color] | 0x1; + else + mouseBuf[y * texWidth + x] = 0x0; + } + } + + iPhone_setMouseCursor(mouseBuf, _mouseWidth, _mouseHeight, _mouseHotspotX, _mouseHotspotY); } -- cgit v1.2.3 From d77253fbe592714e57b87a258fb403e1ea84d17a Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 02:32:10 +0100 Subject: IPHONE: Add support for unfiltered upscaling. --- backends/platform/iphone/iphone_common.h | 6 +++++ backends/platform/iphone/iphone_video.h | 2 ++ backends/platform/iphone/iphone_video.m | 46 +++++++++++++++++++++++++------- backends/platform/iphone/osys_main.cpp | 7 +++-- backends/platform/iphone/osys_main.h | 4 +-- backends/platform/iphone/osys_video.cpp | 19 ++++++++----- 6 files changed, 64 insertions(+), 20 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 2c573656a6..75a83a067b 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -50,6 +50,11 @@ enum UIViewSwipeDirection { kUIViewSwipeRight = 8 }; +typedef enum { + kGraphicsModeLinear = 0, + kGraphicsModeNone = 1 +} GraphicsModes; + #ifdef IPHONE_OFFICIAL void iphone_main(int argc, char **argv); #endif @@ -65,6 +70,7 @@ void iphone_main(int argc, char *argv[]); #endif // On the ObjC side +void iPhone_setGraphicsMode(int mode); void iPhone_updateScreen(int mouseX, int mouseY); void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2); void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2); diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 25208deaaf..f484ebbb9e 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -62,6 +62,8 @@ - (void)initSurface; +- (void)setGraphicsMode; + - (void)updateSurface; - (void)updateMainSurface; - (void)updateOverlaySurface; diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index c1633841f5..2723cae23a 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -24,6 +24,7 @@ #include "iphone_common.h" static iPhoneView *sharedInstance = nil; +static GraphicsModes _graphicsMode = kGraphicsModeLinear; static int _width = 0; static int _height = 0; static int _fullWidth; @@ -75,6 +76,12 @@ int printOglError(const char *file, int line) { return retCode; } +void iPhone_setGraphicsMode(int mode) { + _graphicsMode = mode; + + [sharedInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES]; +} + void iPhone_showCursor(int state) { _mouseCursorEnabled = state; } @@ -201,6 +208,27 @@ bool getLocalMouseCoords(CGPoint *point) { return true; } +static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { + if (!tex) + return; + + glBindTexture(GL_TEXTURE_2D, tex); printOpenGLError(); + + GLint filter = GL_LINEAR; + + switch (mode) { + case kGraphicsModeLinear: + filter = GL_LINEAR; + break; + + case kGraphicsModeNone: + filter = GL_NEAREST; + break; + } + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); printOpenGLError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); printOpenGLError(); +} @implementation iPhoneView @@ -263,6 +291,12 @@ bool getLocalMouseCoords(CGPoint *point) { // } } +- (void)setGraphicsMode { + setFilterModeForTexture(_screenTexture, _graphicsMode); + setFilterModeForTexture(_overlayTexture, _graphicsMode); + setFilterModeForTexture(_mouseCursorTexture, _graphicsMode); +} + - (void)updateSurface { if (!_needsScreenUpdate) { return; @@ -287,9 +321,7 @@ bool getLocalMouseCoords(CGPoint *point) { -(void)updateMouseCursor { if (_mouseCursorTexture == 0) { glGenTextures(1, &_mouseCursorTexture); printOpenGLError(); - glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printOpenGLError(); + setFilterModeForTexture(_mouseCursorTexture, _graphicsMode); } glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); @@ -487,18 +519,14 @@ bool getLocalMouseCoords(CGPoint *point) { } glGenTextures(1, &_screenTexture); printOpenGLError(); - glBindTexture(GL_TEXTURE_2D, _screenTexture); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printOpenGLError(); + setFilterModeForTexture(_screenTexture, _graphicsMode); if (_overlayTexture > 0) { glDeleteTextures(1, &_overlayTexture); printOpenGLError(); } glGenTextures(1, &_overlayTexture); printOpenGLError(); - glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printOpenGLError(); + setFilterModeForTexture(_overlayTexture, _graphicsMode); if (_textureBuffer) { free(_textureBuffer); diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 06b32270f4..3395ea6e56 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -45,7 +45,9 @@ const OSystem::GraphicsMode OSystem_IPHONE::s_supportedGraphicsModes[] = { - {0, 0, 0} + { "linear", "Linear filtering", kGraphicsModeLinear }, + { "none", "No filtering", kGraphicsModeNone }, + { 0, 0, 0 } }; AQCallbackStruct OSystem_IPHONE::s_AudioQueue; @@ -60,7 +62,8 @@ OSystem_IPHONE::OSystem_IPHONE() : _screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false), _gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false), _mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0), - _overlayHeight(0), _overlayWidth(0), _overlayBuffer(0), _mouseCursorPaletteEnabled(false) { + _overlayHeight(0), _overlayWidth(0), _overlayBuffer(0), _mouseCursorPaletteEnabled(false), + _currentGraphicsMode(kGraphicsModeLinear) { _queuedInputEvent.type = Common::EVENT_INVALID; _touchpadModeEnabled = !iPhone_isHighResDevice(); _fsFactory = new POSIXFilesystemFactory(); diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 61816cfa35..e4b3d358d5 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -54,12 +54,13 @@ struct AQCallbackStruct { class OSystem_IPHONE : public EventsBaseBackend, public PaletteManager { protected: - static const OSystem::GraphicsMode s_supportedGraphicsModes[]; static AQCallbackStruct s_AudioQueue; static SoundProc s_soundCallback; static void *s_soundParam; + int _currentGraphicsMode; + Audio::MixerImpl *_mixer; Graphics::Surface _framebuffer; @@ -129,7 +130,6 @@ public: virtual bool getFeatureState(Feature f); virtual const GraphicsMode *getSupportedGraphicsModes() const; virtual int getDefaultGraphicsMode() const; - bool setGraphicsMode(const char *name); virtual bool setGraphicsMode(int mode); virtual int getGraphicsMode() const; virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format); diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index 0483c72949..78c6cd4625 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -31,19 +31,24 @@ const OSystem::GraphicsMode *OSystem_IPHONE::getSupportedGraphicsModes() const { int OSystem_IPHONE::getDefaultGraphicsMode() const { - return -1; -} - -bool OSystem_IPHONE::setGraphicsMode(const char *mode) { - return true; + return kGraphicsModeLinear; } bool OSystem_IPHONE::setGraphicsMode(int mode) { - return true; + switch (mode) { + case kGraphicsModeNone: + case kGraphicsModeLinear: + _currentGraphicsMode = mode; + iPhone_setGraphicsMode(mode); + return true; + + default: + return false; + } } int OSystem_IPHONE::getGraphicsMode() const { - return -1; + return _currentGraphicsMode; } void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) { -- cgit v1.2.3 From ae992bebe391ac1d0196e9e32f688b38cb3fd56f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 13:48:09 +0100 Subject: IPHONE: More formatting fixes. --- backends/platform/iphone/iphone_video.m | 152 +++++++++++++++----------------- 1 file changed, 69 insertions(+), 83 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index 2723cae23a..416344265e 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -232,7 +232,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { @implementation iPhoneView -+ (Class) layerClass { ++ (Class)layerClass { return [CAEAGLLayer class]; } @@ -261,7 +261,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { return self; } --(void) dealloc { +-(void)dealloc { [super dealloc]; if (_keyboardView != nil) { @@ -388,7 +388,6 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { } - (void)updateMouseSurface { - int width = _mouseCursorWidth; int height = _mouseCursorHeight; @@ -604,7 +603,6 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { return nil; } - id event = [_events objectAtIndex: 0]; [_events removeObjectAtIndex: 0]; @@ -613,7 +611,6 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { } - (void)addEvent:(NSDictionary *)event { - if (_events == nil) _events = [[NSMutableArray alloc] init]; @@ -631,57 +628,53 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { ]; } -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event -{ +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSSet *allTouches = [event allTouches]; switch ([allTouches count]) { - case 1: - { - UITouch *touch = [touches anyObject]; - CGPoint point = [touch locationInView:self]; - if (!getLocalMouseCoords(&point)) - return; - - _firstTouch = touch; - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseDown], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", - nil - ] - ]; - break; + case 1: { + UITouch *touch = [touches anyObject]; + CGPoint point = [touch locationInView:self]; + if (!getLocalMouseCoords(&point)) + return; + + _firstTouch = touch; + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseDown], @"type", + [NSNumber numberWithFloat:point.x], @"x", + [NSNumber numberWithFloat:point.y], @"y", + nil + ] + ]; + break; } - case 2: - { - UITouch *touch = [touches anyObject]; - CGPoint point = [touch locationInView:self]; - if (!getLocalMouseCoords(&point)) - return; - _secondTouch = touch; - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseSecondDown], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", - nil - ] - ]; - break; + case 2: { + UITouch *touch = [touches anyObject]; + CGPoint point = [touch locationInView:self]; + if (!getLocalMouseCoords(&point)) + return; + + _secondTouch = touch; + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseSecondDown], @"type", + [NSNumber numberWithFloat:point.x], @"x", + [NSNumber numberWithFloat:point.y], @"y", + nil + ] + ]; + break; } } } -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event -{ +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { //NSSet *allTouches = [event allTouches]; - for (UITouch* touch in touches) { + for (UITouch *touch in touches) { if (touch == _firstTouch) { - CGPoint point = [touch locationInView:self]; if (!getLocalMouseCoords(&point)) return; @@ -694,9 +687,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { nil ] ]; - } else if (touch == _secondTouch) { - CGPoint point = [touch locationInView:self]; if (!getLocalMouseCoords(&point)) return; @@ -709,56 +700,51 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { nil ] ]; - } } } -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event -{ +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSSet *allTouches = [event allTouches]; switch ([allTouches count]) { - case 1: - { - UITouch *touch = [[allTouches allObjects] objectAtIndex:0]; - CGPoint point = [touch locationInView:self]; - if (!getLocalMouseCoords(&point)) - return; - - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseUp], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", - nil - ] - ]; - break; + case 1: { + UITouch *touch = [[allTouches allObjects] objectAtIndex:0]; + CGPoint point = [touch locationInView:self]; + if (!getLocalMouseCoords(&point)) + return; + + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseUp], @"type", + [NSNumber numberWithFloat:point.x], @"x", + [NSNumber numberWithFloat:point.y], @"y", + nil + ] + ]; + break; } - case 2: - { - UITouch *touch = [[allTouches allObjects] objectAtIndex:1]; - CGPoint point = [touch locationInView:self]; - if (!getLocalMouseCoords(&point)) - return; - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseSecondUp], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", - nil - ] - ]; - break; + case 2: { + UITouch *touch = [[allTouches allObjects] objectAtIndex:1]; + CGPoint point = [touch locationInView:self]; + if (!getLocalMouseCoords(&point)) + return; + + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseSecondUp], @"type", + [NSNumber numberWithFloat:point.x], @"x", + [NSNumber numberWithFloat:point.y], @"y", + nil + ] + ]; + break; } } } -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event -{ - +- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { } - (void)handleKeyPress:(unichar)c { -- cgit v1.2.3 From e7ade8ae05aff3669059e6003e046d1ef6e914a3 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 17 Feb 2012 12:17:51 -0600 Subject: KEYMAPPER: EventMapper must now eat all events --- backends/keymapper/keymapper.cpp | 18 +++++++++++++++--- backends/keymapper/keymapper.h | 6 ++++++ 2 files changed, 21 insertions(+), 3 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index 1c83bb877e..cda34ff052 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -181,12 +181,24 @@ void Keymapper::popKeymap(const char *name) { } bool Keymapper::notifyEvent(const Common::Event &ev) { + bool mapped = false; + if (ev.type == Common::EVENT_KEYDOWN) - return mapKeyDown(ev.kbd); + mapped = mapKeyDown(ev.kbd); else if (ev.type == Common::EVENT_KEYUP) - return mapKeyUp(ev.kbd); + mapped = mapKeyUp(ev.kbd); + + if (mapped) + return true; else - return false; + return mapEvent(ev); +} + +bool Keymapper::mapEvent(const Common::Event &ev) { + // pass through - copy the event + Event evt = ev; + addEvent(evt); + return true; } bool Keymapper::mapKeyDown(const KeyState& key) { diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index 27e981923b..626df013ac 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -163,6 +163,12 @@ public: */ bool mapKeyUp(const KeyState& key); + /** + * Map non-key incoming events + * @param ev incoming event + */ + bool mapEvent(const Common::Event &ev); + /** * Enable/disable the keymapper */ -- cgit v1.2.3 From 5c3e48fddf2f021d51e41db1672d7ff543c52426 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 17 Feb 2012 14:42:17 -0600 Subject: KEYMAPPER: Create a DefaultEventMapper when Keymapper isn't enabled This allows migration to unconditional mapping --- backends/events/default/default-events.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'backends') diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index 78072b0021..074c42ff7f 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -60,6 +60,8 @@ DefaultEventManager::DefaultEventManager(Common::EventSource *boss) : // EventDispatcher will automatically free the keymapper _dispatcher.registerMapper(_keymapper); _remap = false; +#else + _dispatcher.registerMapper(new Common::DefaultEventMapper()); #endif } -- cgit v1.2.3 From a0ba4eb569ae9ec0e05a7ba8532ab304e6852f84 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 17 Feb 2012 17:08:58 -0600 Subject: KEYMAPPER: Rewrite the EventMapper API --- backends/keymapper/keymapper.cpp | 45 +++++++++++++++++++--------------------- backends/keymapper/keymapper.h | 25 ++++++++-------------- 2 files changed, 30 insertions(+), 40 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index cda34ff052..7ada676516 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -180,38 +180,35 @@ void Keymapper::popKeymap(const char *name) { } -bool Keymapper::notifyEvent(const Common::Event &ev) { - bool mapped = false; +List Keymapper::mapEvent(const Event &ev, EventSource *source) { + if (source && !source->allowMapping()) { + return DefaultEventMapper::mapEvent(ev, source); + } + + List mappedEvents; if (ev.type == Common::EVENT_KEYDOWN) - mapped = mapKeyDown(ev.kbd); + mappedEvents = mapKeyDown(ev.kbd); else if (ev.type == Common::EVENT_KEYUP) - mapped = mapKeyUp(ev.kbd); + mappedEvents = mapKeyUp(ev.kbd); - if (mapped) - return true; + if (!mappedEvents.empty()) + return mappedEvents; else - return mapEvent(ev); -} - -bool Keymapper::mapEvent(const Common::Event &ev) { - // pass through - copy the event - Event evt = ev; - addEvent(evt); - return true; + return DefaultEventMapper::mapEvent(ev, source); } -bool Keymapper::mapKeyDown(const KeyState& key) { +List Keymapper::mapKeyDown(const KeyState& key) { return mapKey(key, true); } -bool Keymapper::mapKeyUp(const KeyState& key) { +List Keymapper::mapKeyUp(const KeyState& key) { return mapKey(key, false); } -bool Keymapper::mapKey(const KeyState& key, bool keyDown) { +List Keymapper::mapKey(const KeyState& key, bool keyDown) { if (!_enabled || _activeMaps.empty()) - return false; + return List(); Action *action = 0; @@ -238,11 +235,9 @@ bool Keymapper::mapKey(const KeyState& key, bool keyDown) { } if (!action) - return false; + return List(); - executeAction(action, keyDown); - - return true; + return executeAction(action, keyDown); } Action *Keymapper::getAction(const KeyState& key) { @@ -251,7 +246,8 @@ Action *Keymapper::getAction(const KeyState& key) { return action; } -void Keymapper::executeAction(const Action *action, bool keyDown) { +List Keymapper::executeAction(const Action *action, bool keyDown) { + List mappedEvents; List::const_iterator it; for (it = action->events.begin(); it != action->events.end(); ++it) { @@ -291,8 +287,9 @@ void Keymapper::executeAction(const Action *action, bool keyDown) { } evt.mouse = _eventMan->getMousePos(); - addEvent(evt); + mappedEvents.push_back(evt); } + return mappedEvents; } const HardwareKey *Keymapper::findHardwareKey(const KeyState& key) { diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index 626df013ac..31bfcbc080 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -39,7 +39,7 @@ namespace Common { const char *const kGuiKeymapName = "gui"; const char *const kGlobalKeymapName = "global"; -class Keymapper : public Common::EventMapper, private Common::ArtificialEventSource { +class Keymapper : public Common::DefaultEventMapper { public: struct MapRecord { @@ -77,6 +77,9 @@ public: Keymapper(EventManager *eventMan); ~Keymapper(); + // EventMapper interface + virtual List mapEvent(const Event &ev, EventSource *source); + /** * Registers a HardwareKeySet with the Keymapper * @note should only be called once (during backend initialisation) @@ -137,37 +140,27 @@ public: */ void popKeymap(const char *name = 0); - // Implementation of the EventMapper interface - bool notifyEvent(const Common::Event &ev); - bool pollEvent(Common::Event &ev) { return Common::ArtificialEventSource::pollEvent(ev); } - /** * @brief Map a key press event. * If the active keymap contains a Action mapped to the given key, then * the Action's events are pushed into the EventManager's event queue. * @param key key that was pressed * @param keyDown true for key down, false for key up - * @return true if key was mapped + * @return mapped events */ - bool mapKey(const KeyState& key, bool keyDown); + List mapKey(const KeyState& key, bool keyDown); /** * @brief Map a key down event. * @see mapKey */ - bool mapKeyDown(const KeyState& key); + List mapKeyDown(const KeyState& key); /** * @brief Map a key up event. * @see mapKey */ - bool mapKeyUp(const KeyState& key); - - /** - * Map non-key incoming events - * @param ev incoming event - */ - bool mapEvent(const Common::Event &ev); + List mapKeyUp(const KeyState& key); /** * Enable/disable the keymapper @@ -195,7 +188,7 @@ private: void pushKeymap(Keymap *newMap, bool transparent, bool global); Action *getAction(const KeyState& key); - void executeAction(const Action *act, bool keyDown); + List executeAction(const Action *act, bool keyDown); EventManager *_eventMan; -- cgit v1.2.3 From cfe91c8d444b8535c30d6766821ee4eeb4108b07 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Sat, 18 Feb 2012 17:42:39 -0600 Subject: KEYMAPPER: Move CTRL-F5 handling to DefaultEventMapper --- backends/events/default/default-events.cpp | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) (limited to 'backends') diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index 074c42ff7f..3930038870 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -104,35 +104,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { // Global Main Menu if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_F5) { - if (g_engine && !g_engine->isPaused()) { - Common::Event menuEvent; - menuEvent.type = Common::EVENT_MAINMENU; - - // FIXME: GSoC RTL branch passes the F6 key event to the - // engine, and also enqueues a EVENT_MAINMENU. For now, - // we just drop the key event and return an EVENT_MAINMENU - // instead. This way, we don't have to add special cases - // to engines (like it was the case for LURE in the RTL branch). - // - // However, this has other consequences, possibly negative ones. - // Like, what happens with key repeat for the trigger key? - - //pushEvent(menuEvent); - event = menuEvent; - - // FIXME: Since now we do not push another MAINMENU event onto - // our event stack, the GMM would never open, so we have to do - // that here. Of course when the engine would handle MAINMENU - // as an event now and open up the GMM itself it would open the - // menu twice. - if (g_engine && !g_engine->isPaused()) - g_engine->openMainMenuDialog(); - - if (_shouldQuit) - event.type = Common::EVENT_QUIT; - else if (_shouldRTL) - event.type = Common::EVENT_RTL; - } + //do nothing - EventMapper handles this case for us } #ifdef ENABLE_VKEYBD else if (event.kbd.keycode == Common::KEYCODE_F7 && event.kbd.hasFlags(0)) { -- cgit v1.2.3 From 3f6d549b0e891be33ef48926629d6e626009fc8f Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Sat, 18 Feb 2012 22:17:48 -0600 Subject: KEYMAPPER: Move F7 and F8 handling to DefaultEventMapper --- backends/events/default/default-events.cpp | 63 ++++++++++++++---------------- 1 file changed, 29 insertions(+), 34 deletions(-) (limited to 'backends') diff --git a/backends/events/default/default-events.cpp b/backends/events/default/default-events.cpp index 3930038870..99d12c73dc 100644 --- a/backends/events/default/default-events.cpp +++ b/backends/events/default/default-events.cpp @@ -102,39 +102,7 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { _currentKeyDown.flags = event.kbd.flags; _keyRepeatTime = time + kKeyRepeatInitialDelay; - // Global Main Menu - if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_F5) { - //do nothing - EventMapper handles this case for us - } -#ifdef ENABLE_VKEYBD - else if (event.kbd.keycode == Common::KEYCODE_F7 && event.kbd.hasFlags(0)) { - if (_vk->isDisplaying()) { - _vk->close(true); - } else { - if (g_engine) - g_engine->pauseEngine(true); - _vk->show(); - if (g_engine) - g_engine->pauseEngine(false); - result = false; - } - } -#endif -#ifdef ENABLE_KEYMAPPER - else if (event.kbd.keycode == Common::KEYCODE_F8 && event.kbd.hasFlags(0)) { - if (!_remap) { - _remap = true; - Common::RemapDialog _remapDialog; - if (g_engine) - g_engine->pauseEngine(true); - _remapDialog.runModal(); - if (g_engine) - g_engine->pauseEngine(false); - _remap = false; - } - } -#endif - else if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) { + if (event.kbd.keycode == Common::KEYCODE_BACKSPACE) { // WORKAROUND: Some engines incorrectly attempt to use the // ascii value instead of the keycode to detect the backspace // key (a non-portable behavior). This fails at least on @@ -188,7 +156,34 @@ bool DefaultEventManager::pollEvent(Common::Event &event) { else if (_shouldRTL) event.type = Common::EVENT_RTL; break; - +#ifdef ENABLE_VKEYBD + case Common::EVENT_VIRTUAL_KEYBOARD: + if (_vk->isDisplaying()) { + _vk->close(true); + } else { + if (g_engine) + g_engine->pauseEngine(true); + _vk->show(); + if (g_engine) + g_engine->pauseEngine(false); + result = false; + } + break; +#endif +#ifdef ENABLE_KEYMAPPER + case Common::EVENT_KEYMAPPER_REMAP: + if (!_remap) { + _remap = true; + Common::RemapDialog _remapDialog; + if (g_engine) + g_engine->pauseEngine(true); + _remapDialog.runModal(); + if (g_engine) + g_engine->pauseEngine(false); + _remap = false; + } + break; +#endif case Common::EVENT_RTL: if (ConfMan.getBool("confirm_exit")) { if (g_engine) -- cgit v1.2.3 From 76be031ed4b000ec96d7a650c21c2158ecea2b4b Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 14:43:55 +0100 Subject: IPHONE: Remove some unused variables. --- backends/platform/iphone/iphone_video.h | 1 - backends/platform/iphone/iphone_video.m | 3 --- 2 files changed, 4 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index f484ebbb9e..5b4e0fdbd0 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -37,7 +37,6 @@ void *_screenSurface; NSMutableArray *_events; SoftKeyboard *_keyboardView; - CALayer *_screenLayer; int _widthOffset; int _heightOffset; diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index 416344265e..06ed7e871e 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -42,7 +42,6 @@ static int _overlayWidth = 0; static int _overlayHeight = 0; static float _overlayPortraitRatio = 1.0f; -NSLock *_lock = nil; static int _needsScreenUpdate = 0; static int _overlayIsEnabled = 0; @@ -247,11 +246,9 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { _fullWidth = frame.size.width; _fullHeight = frame.size.height; - _screenLayer = nil; sharedInstance = self; - _lock = [NSLock new]; _keyboardView = nil; _context = nil; _screenTexture = 0; -- cgit v1.2.3 From 46e622c0fe080abd4627971135cea31a492edcb4 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 15:12:12 +0100 Subject: IPHONE: Slight cleanup. --- backends/platform/iphone/iphone_video.m | 52 +++++++++++++++------------------ 1 file changed, 24 insertions(+), 28 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index 06ed7e871e..da10b41ea4 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -57,18 +57,20 @@ static int _mouseX = 0; static int _mouseY = 0; static int _mouseCursorEnabled = 0; -// static long lastTick = 0; -// static int frames = 0; +#if 0 +static long lastTick = 0; +static int frames = 0; +#endif #define printOpenGLError() printOglError(__FILE__, __LINE__) int printOglError(const char *file, int line) { - int retCode = 0; + int retCode = 0; // returns 1 if an OpenGL error occurred, 0 otherwise. GLenum glErr = glGetError(); while (glErr != GL_NO_ERROR) { - fprintf(stderr, "glError: %u (%s: %d)\n", glErr, file, line ); + fprintf(stderr, "glError: %u (%s: %d)\n", glErr, file, line); retCode = 1; glErr = glGetError(); } @@ -118,12 +120,6 @@ bool iPhone_isHighResDevice() { void iPhone_updateScreen(int mouseX, int mouseY) { //printf("Mouse: (%i, %i)\n", mouseX, mouseY); - //_mouseX = _overlayHeight - (float)mouseX / _width * _overlayHeight; - //_mouseY = (float)mouseY / _height * _overlayWidth; - - //_mouseX = _overlayHeight - mouseX; - //_mouseY = mouseY; - _mouseX = mouseX; _mouseY = mouseY; @@ -136,14 +132,14 @@ void iPhone_updateScreen(int mouseX, int mouseY) { void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2) { int y; for (y = y1; y < y2; ++y) - memcpy(&_textureBuffer[(y * _textureWidth + x1 )* 2], &screen[y * _width + x1], (x2 - x1) * 2); + memcpy(&_textureBuffer[(y * _textureWidth + x1) * 2], &screen[y * _width + x1], (x2 - x1) * 2); } void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2) { int y; //printf("Overlaywidth: %u, fullwidth %u\n", _overlayWidth, _fullWidth); for (y = y1; y < y2; ++y) - memcpy(&_overlayTexBuffer[(y * _overlayTexWidth + x1 )* 2], &screen[y * _overlayWidth + x1], (x2 - x1) * 2); + memcpy(&_overlayTexBuffer[(y * _overlayTexWidth + x1) * 2], &screen[y * _overlayWidth + x1], (x2 - x1) * 2); } void iPhone_initSurface(int width, int height) { @@ -258,16 +254,14 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { return self; } --(void)dealloc { +- (void)dealloc { [super dealloc]; if (_keyboardView != nil) { [_keyboardView dealloc]; } - if (_screenTexture) - free(_textureBuffer); - + free(_textureBuffer); free(_overlayTexBuffer); } @@ -276,16 +270,18 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { } - (void)drawRect:(CGRect)frame { - // if (lastTick == 0) { - // lastTick = time(0); - // } - // - // frames++; - // if (time(0) > lastTick) { - // lastTick = time(0); - // printf("FPS: %i\n", frames); - // frames = 0; - // } +#if 0 + if (lastTick == 0) { + lastTick = time(0); + } + + frames++; + if (time(0) > lastTick) { + lastTick = time(0); + printf("FPS: %i\n", frames); + frames = 0; + } +#endif } - (void)setGraphicsMode { @@ -315,7 +311,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { } --(void)updateMouseCursor { +- (void)updateMouseCursor { if (_mouseCursorTexture == 0) { glGenTextures(1, &_mouseCursorTexture); printOpenGLError(); setFilterModeForTexture(_mouseCursorTexture, _graphicsMode); @@ -456,7 +452,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { eaglLayer.opaque = YES; eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, nil]; + [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, nil]; _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; if (!_context || [EAGLContext setCurrentContext:_context]) { -- cgit v1.2.3 From a291679445a538ed8143a8f26952c38d6e9d3dd4 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 15:24:47 +0100 Subject: IPHONE: Slight game screen texture related variable renaming. --- backends/platform/iphone/iphone_video.m | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index da10b41ea4..5d57b6dcd5 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -31,9 +31,9 @@ static int _fullWidth; static int _fullHeight; static CGRect _screenRect; -static char *_textureBuffer = 0; -static int _textureWidth = 0; -static int _textureHeight = 0; +static char *_gameScreenTextureBuffer = 0; +static int _gameScreenTextureWidth = 0; +static int _gameScreenTextureHeight = 0; static char *_overlayTexBuffer = 0; static int _overlayTexWidth = 0; @@ -132,7 +132,7 @@ void iPhone_updateScreen(int mouseX, int mouseY) { void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2) { int y; for (y = y1; y < y2; ++y) - memcpy(&_textureBuffer[(y * _textureWidth + x1) * 2], &screen[y * _width + x1], (x2 - x1) * 2); + memcpy(&_gameScreenTextureBuffer[(y * _gameScreenTextureWidth + x1) * 2], &screen[y * _width + x1], (x2 - x1) * 2); } void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2) { @@ -261,7 +261,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { [_keyboardView dealloc]; } - free(_textureBuffer); + free(_gameScreenTextureBuffer); free(_overlayTexBuffer); } @@ -332,8 +332,8 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { _visibleWidth - _heightOffset, _visibleHeight - _widthOffset }; - float texWidth = _width / (float)_textureWidth; - float texHeight = _height / (float)_textureHeight; + float texWidth = _width / (float)_gameScreenTextureWidth; + float texHeight = _height / (float)_gameScreenTextureHeight; const GLfloat texCoords[] = { texWidth, 0.0f, @@ -350,7 +350,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { // Unfortunately we have to update the whole texture every frame, since glTexSubImage2D is actually slower in all cases // due to the iPhone internals having to convert the whole texture back from its internal format when used. // In the future we could use several tiled textures instead. - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _textureWidth, _textureHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _textureBuffer); printOpenGLError(); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _gameScreenTextureWidth, _gameScreenTextureHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _gameScreenTextureBuffer); printOpenGLError(); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); } @@ -439,12 +439,12 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { } - (void)initSurface { - _textureWidth = getSizeNextPOT(_width); - _textureHeight = getSizeNextPOT(_height); + _gameScreenTextureWidth = getSizeNextPOT(_width); + _gameScreenTextureHeight = getSizeNextPOT(_height); UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; - //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _width, _height, _textureWidth, _textureHeight); + //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _width, _height, _gameScreenTextureWidth, _gameScreenTextureHeight); if (_context == nil) { orientation = UIDeviceOrientationLandscapeRight; @@ -520,13 +520,10 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { glGenTextures(1, &_overlayTexture); printOpenGLError(); setFilterModeForTexture(_overlayTexture, _graphicsMode); - if (_textureBuffer) { - free(_textureBuffer); - } - - int textureSize = _textureWidth * _textureHeight * 2; - _textureBuffer = (char *)malloc(textureSize); - memset(_textureBuffer, 0, textureSize); + free(_gameScreenTextureBuffer); + int textureSize = _gameScreenTextureWidth * _gameScreenTextureHeight * 2; + _gameScreenTextureBuffer = (char *)malloc(textureSize); + memset(_gameScreenTextureBuffer, 0, textureSize); glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); -- cgit v1.2.3 From 6c4d65e53f2bd4d61043ed06fcdf61416405bf87 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Mon, 20 Feb 2012 10:52:50 -0600 Subject: KEYMAPPER: Change how keymaps are displayed in the remap dialog This makes it so that there's 2 groups: 1 - The keymap stack 2 - The loaded keymaps The first group displays which keymaps are active and which keymaps are completely blocked due to an opaque keymap on top. The second group displays which loaded keymaps store their mappings globally and which ones store their mappings per-target. --- backends/keymapper/remap-dialog.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index eb2d4c5441..4ef39a15e5 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -57,14 +57,12 @@ RemapDialog::~RemapDialog() { } void RemapDialog::open() { - bool divider = false; const Stack &activeKeymaps = _keymapper->getActiveStack(); if (activeKeymaps.size() > 0) { if (activeKeymaps.top().keymap->getName() == Common::kGuiKeymapName) _topKeymapIsGui = true; _kmPopUp->appendEntry(activeKeymaps.top().keymap->getName() + _(" (Effective)")); - divider = true; } Keymapper::Domain *_globalKeymaps = &_keymapper->getGlobalDomain(); @@ -98,35 +96,30 @@ void RemapDialog::open() { uint32 idx = 0; if (activeKeymaps.size() > 1) { - if (divider) - _kmPopUp->appendEntry(""); int topIndex = activeKeymaps.size() - 1; + bool active = activeKeymaps[topIndex].transparent; for (int i = topIndex - 1; i >= 0; --i) { Keymapper::MapRecord mr = activeKeymaps[i]; - _kmPopUp->appendEntry(mr.keymap->getName() + _(" (Active)"), idx); + _kmPopUp->appendEntry(mr.keymap->getName() + (active ? _(" (Active)") : _(" (Blocked)")), idx); _keymapTable[idx++] = mr.keymap; + active &= mr.transparent; } - divider = true; } + _kmPopUp->appendEntry(""); + if (_globalKeymaps) { - if (divider) - _kmPopUp->appendEntry(""); for (it = _globalKeymaps->begin(); it != _globalKeymaps->end(); ++it) { _kmPopUp->appendEntry(it->_value->getName() + _(" (Global)"), idx); _keymapTable[idx++] = it->_value; } - divider = true; } if (_gameKeymaps) { - if (divider) - _kmPopUp->appendEntry(""); for (it = _gameKeymaps->begin(); it != _gameKeymaps->end(); ++it) { _kmPopUp->appendEntry(it->_value->getName() + _(" (Game)"), idx); _keymapTable[idx++] = it->_value; } - divider = true; } _changes = false; -- cgit v1.2.3 From 5cc3d754f72c640f905b535f662b742c8b3794dc Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 15:57:47 +0100 Subject: IPHONE: Even more slight formatting fixes. --- backends/platform/iphone/iphone_main.m | 9 +++++---- backends/platform/iphone/osys_main.cpp | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_main.m b/backends/platform/iphone/iphone_main.m index 1b555f849f..a72b2fd69d 100644 --- a/backends/platform/iphone/iphone_main.m +++ b/backends/platform/iphone/iphone_main.m @@ -84,18 +84,19 @@ int main(int argc, char **argv) { _window = [[UIWindow alloc] initWithFrame:rect]; [_window retain]; - _view = [[iPhoneView alloc] initWithFrame: rect]; + _view = [[iPhoneView alloc] initWithFrame:rect]; _view.multipleTouchEnabled = YES; - [_window setContentView: _view]; + [_window setContentView:_view]; [_window addSubview:_view]; [_window makeKeyAndVisible]; [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(didRotate:) - name:@"UIDeviceOrientationDidChangeNotification" object:nil]; + selector:@selector(didRotate:) + name:@"UIDeviceOrientationDidChangeNotification" + object:nil]; [NSThread detachNewThreadSelector:@selector(mainLoop:) toTarget:self withObject:nil]; } diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 3395ea6e56..36f21363be 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -250,7 +250,6 @@ Common::String OSystem_IPHONE::getDefaultConfigFileName() { #endif } - void OSystem_IPHONE::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) { // Get URL of the Resource directory of the .app bundle CFURLRef fileUrl = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle()); -- cgit v1.2.3 From d4c167414d13bab393f95ec430d717a0413a1b82 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 17:35:19 +0100 Subject: IPHONE: Refactor event code a bit. Now mouse x/y coordinates are passed as int. --- backends/platform/iphone/iphone_common.h | 2 +- backends/platform/iphone/iphone_main.m | 4 +- backends/platform/iphone/iphone_video.h | 4 +- backends/platform/iphone/iphone_video.m | 149 ++++++++++++++++++++++--------- backends/platform/iphone/osys_events.cpp | 42 ++------- backends/platform/iphone/osys_main.cpp | 4 +- 6 files changed, 118 insertions(+), 87 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 75a83a067b..2f03309215 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -75,7 +75,7 @@ void iPhone_updateScreen(int mouseX, int mouseY); void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2); void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2); void iPhone_initSurface(int width, int height); -bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY); +bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY); const char *iPhone_getDocumentsDir(); bool iPhone_isHighResDevice(); int iPhone_getScreenHeight(); diff --git a/backends/platform/iphone/iphone_main.m b/backends/platform/iphone/iphone_main.m index a72b2fd69d..051da417ea 100644 --- a/backends/platform/iphone/iphone_main.m +++ b/backends/platform/iphone/iphone_main.m @@ -126,8 +126,8 @@ int main(int argc, char **argv) { } - (void)didRotate:(NSNotification *)notification { - int screenOrientation = [[UIDevice currentDevice] orientation]; - [_view deviceOrientationChanged: screenOrientation]; + UIDeviceOrientation screenOrientation = [[UIDevice currentDevice] orientation]; + [_view deviceOrientationChanged:screenOrientation]; } - (UIWindow*) getWindow { diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 5b4e0fdbd0..173814a028 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -51,6 +51,8 @@ GLuint _screenTexture; GLuint _overlayTexture; GLuint _mouseCursorTexture; + + UIDeviceOrientation _orientation; } - (id)initWithFrame:(struct CGRect)frame; @@ -73,7 +75,7 @@ - (id)getEvent; -- (void)deviceOrientationChanged:(int)orientation; +- (void)deviceOrientationChanged:(UIDeviceOrientation)orientation; - (void)applicationSuspend; diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index 5d57b6dcd5..977dcce4bd 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -148,7 +148,7 @@ void iPhone_initSurface(int width, int height) { [sharedInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES]; } -bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY) { +bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY) { id event = [sharedInstance getEvent]; if (event == nil) { return false; @@ -162,8 +162,8 @@ bool iPhone_fetchEvent(int *outEvent, float *outX, float *outY) { } *outEvent = [type intValue]; - *outX = [[event objectForKey:@"x"] floatValue]; - *outY = [[event objectForKey:@"y"] floatValue]; + *outX = [[event objectForKey:@"x"] intValue]; + *outY = [[event objectForKey:@"y"] intValue]; return true; } @@ -186,18 +186,55 @@ const char *iPhone_getDocumentsDir() { return [documentsDirectory UTF8String]; } -bool getLocalMouseCoords(CGPoint *point) { +static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int *x, int *y) { if (_overlayIsEnabled) { - point->x = point->x / _overlayHeight; - point->y = point->y / _overlayWidth; + switch (orientation) { + case UIDeviceOrientationLandscapeLeft: + *x = (int)point.y; + *y = _overlayHeight - (int)point.x; + break; + + case UIDeviceOrientationLandscapeRight: + *x = _overlayWidth - (int)point.y; + *y = (int)point.x; + break; + + case UIDeviceOrientationPortrait: + *x = (int)point.x; + *y = (int)point.y; + break; + + default: + return false; + } } else { - if (point->x < _screenRect.origin.x || point->x >= _screenRect.origin.x + _screenRect.size.width || - point->y < _screenRect.origin.y || point->y >= _screenRect.origin.y + _screenRect.size.height) { + if (point.x < _screenRect.origin.x || point.x >= _screenRect.origin.x + _screenRect.size.width || + point.y < _screenRect.origin.y || point.y >= _screenRect.origin.y + _screenRect.size.height) { return false; } - point->x = (point->x - _screenRect.origin.x) / _screenRect.size.width; - point->y = (point->y - _screenRect.origin.y) / _screenRect.size.height; + point.x = (point.x - _screenRect.origin.x) / _screenRect.size.width; + point.y = (point.y - _screenRect.origin.y) / _screenRect.size.height; + + switch (orientation) { + case UIDeviceOrientationLandscapeLeft: + *x = point.y * _width; + *y = (1.0f - point.x) * _height; + break; + + case UIDeviceOrientationLandscapeRight: + *x = (1.0f - point.y) * _width; + *y = point.x * _height; + break; + + case UIDeviceOrientationPortrait: + *x = point.x * _width; + *y = point.y * _height; + break; + + default: + return false; + } } return true; @@ -442,12 +479,22 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { _gameScreenTextureWidth = getSizeNextPOT(_width); _gameScreenTextureHeight = getSizeNextPOT(_height); - UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; + _orientation = [[UIDevice currentDevice] orientation]; + + switch (_orientation) { + case UIDeviceOrientationLandscapeLeft: + case UIDeviceOrientationLandscapeRight: + case UIDeviceOrientationPortrait: + break; + + default: + _orientation = UIDeviceOrientationLandscapeRight; + } //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _width, _height, _gameScreenTextureWidth, _gameScreenTextureHeight); if (_context == nil) { - orientation = UIDeviceOrientationLandscapeRight; + _orientation = UIDeviceOrientationLandscapeRight; CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; eaglLayer.opaque = YES; @@ -496,9 +543,9 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); - if (orientation == UIDeviceOrientationLandscapeRight) { + if (_orientation == UIDeviceOrientationLandscapeRight) { glRotatef(-90, 0, 0, 1); printOpenGLError(); - } else if (orientation == UIDeviceOrientationLandscapeLeft) { + } else if (_orientation == UIDeviceOrientationLandscapeLeft) { glRotatef(90, 0, 0, 1); printOpenGLError(); } else { glRotatef(180, 0, 0, 1); printOpenGLError(); @@ -534,7 +581,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { [[_keyboardView inputView] removeFromSuperview]; } - if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight) { + if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation == UIDeviceOrientationLandscapeRight) { _visibleHeight = _backingHeight; _visibleWidth = _backingWidth; @@ -607,12 +654,23 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { [_events addObject: event]; } -- (void)deviceOrientationChanged:(int)orientation { +- (void)deviceOrientationChanged:(UIDeviceOrientation)orientation { + switch (orientation) { + case UIDeviceOrientationLandscapeLeft: + case UIDeviceOrientationLandscapeRight: + case UIDeviceOrientationPortrait: + _orientation = orientation; + break; + + default: + return; + } + [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputOrientationChanged], @"type", - [NSNumber numberWithFloat:(float)orientation], @"x", - [NSNumber numberWithFloat:0], @"y", + [NSNumber numberWithInt:orientation], @"x", + [NSNumber numberWithInt:0], @"y", nil ] ]; @@ -620,20 +678,21 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { NSSet *allTouches = [event allTouches]; + int x, y; switch ([allTouches count]) { case 1: { UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self]; - if (!getLocalMouseCoords(&point)) + if (!getMouseCoords(_orientation, point, &x, &y)) return; _firstTouch = touch; [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseDown], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", nil ] ]; @@ -643,15 +702,15 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { case 2: { UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self]; - if (!getLocalMouseCoords(&point)) + if (!getMouseCoords(_orientation, point, &x, &y)) return; _secondTouch = touch; [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseSecondDown], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", nil ] ]; @@ -662,31 +721,32 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { //NSSet *allTouches = [event allTouches]; + int x, y; for (UITouch *touch in touches) { if (touch == _firstTouch) { CGPoint point = [touch locationInView:self]; - if (!getLocalMouseCoords(&point)) + if (!getMouseCoords(_orientation, point, &x, &y)) return; [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseDragged], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", nil ] ]; } else if (touch == _secondTouch) { CGPoint point = [touch locationInView:self]; - if (!getLocalMouseCoords(&point)) + if (!getMouseCoords(_orientation, point, &x, &y)) return; [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseSecondDragged], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", nil ] ]; @@ -696,19 +756,20 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { NSSet *allTouches = [event allTouches]; + int x, y; switch ([allTouches count]) { case 1: { UITouch *touch = [[allTouches allObjects] objectAtIndex:0]; CGPoint point = [touch locationInView:self]; - if (!getLocalMouseCoords(&point)) + if (!getMouseCoords(_orientation, point, &x, &y)) return; [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseUp], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", nil ] ]; @@ -718,14 +779,14 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { case 2: { UITouch *touch = [[allTouches allObjects] objectAtIndex:1]; CGPoint point = [touch locationInView:self]; - if (!getLocalMouseCoords(&point)) + if (!getMouseCoords(_orientation, point, &x, &y)) return; [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseSecondUp], @"type", - [NSNumber numberWithFloat:point.x], @"x", - [NSNumber numberWithFloat:point.y], @"y", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", nil ] ]; @@ -741,8 +802,8 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputKeyPressed], @"type", - [NSNumber numberWithFloat:(float)c], @"x", - [NSNumber numberWithFloat:0], @"y", + [NSNumber numberWithInt:c], @"x", + [NSNumber numberWithInt:0], @"y", nil ] ]; @@ -758,8 +819,8 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputSwipe], @"type", - [NSNumber numberWithFloat:(float)num], @"x", - [NSNumber numberWithFloat:0], @"y", + [NSNumber numberWithInt:num], @"x", + [NSNumber numberWithInt:0], @"y", nil ] ]; @@ -769,8 +830,8 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputApplicationSuspended], @"type", - [NSNumber numberWithFloat:0], @"x", - [NSNumber numberWithFloat:0], @"y", + [NSNumber numberWithInt:0], @"x", + [NSNumber numberWithInt:0], @"y", nil ] ]; @@ -780,8 +841,8 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputApplicationResumed], @"type", - [NSNumber numberWithFloat:0], @"x", - [NSNumber numberWithFloat:0], @"y", + [NSNumber numberWithInt:0], @"x", + [NSNumber numberWithInt:0], @"y", nil ] ]; diff --git a/backends/platform/iphone/osys_events.cpp b/backends/platform/iphone/osys_events.cpp index 5beba8a397..c167da35e6 100644 --- a/backends/platform/iphone/osys_events.cpp +++ b/backends/platform/iphone/osys_events.cpp @@ -47,41 +47,9 @@ bool OSystem_IPHONE::pollEvent(Common::Event &event) { } int eventType; - float xUnit, yUnit; - - if (iPhone_fetchEvent(&eventType, &xUnit, &yUnit)) { - int x = 0; - int y = 0; - switch (_screenOrientation) { - case kScreenOrientationPortrait: - if (_overlayVisible) { - x = (int)(xUnit * _overlayWidth); - y = (int)(yUnit * _overlayHeight); - } else { - x = (int)(xUnit * _screenWidth); - y = (int)(yUnit * _screenHeight); - } - break; - case kScreenOrientationLandscape: - if (_overlayVisible) { - x = (int)(yUnit * _overlayWidth); - y = (int)((1.0 - xUnit) * _overlayHeight); - } else { - x = (int)(yUnit * _screenWidth); - y = (int)((1.0 - xUnit) * _screenHeight); - } - break; - case kScreenOrientationFlippedLandscape: - if (_overlayVisible) { - x = (int)((1.0 - yUnit) * _overlayWidth); - y = (int)(xUnit * _overlayHeight); - } else { - x = (int)((1.0 - yUnit) * _screenWidth); - y = (int)(xUnit * _screenHeight); - } - break; - } + int x, y; + if (iPhone_fetchEvent(&eventType, &x, &y)) { switch ((InputEvent)eventType) { case kInputMouseDown: if (!handleEvent_mouseDown(event, x, y)) @@ -112,7 +80,7 @@ bool OSystem_IPHONE::pollEvent(Common::Event &event) { return false; break; case kInputOrientationChanged: - handleEvent_orientationChanged((int)xUnit); + handleEvent_orientationChanged(x); return false; break; @@ -122,11 +90,11 @@ bool OSystem_IPHONE::pollEvent(Common::Event &event) { break; case kInputKeyPressed: - handleEvent_keyPressed(event, (int)xUnit); + handleEvent_keyPressed(event, x); break; case kInputSwipe: - if (!handleEvent_swipe(event, (int)xUnit)) + if (!handleEvent_swipe(event, x)) return false; break; diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 36f21363be..2bdc09c9ce 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -139,13 +139,13 @@ bool OSystem_IPHONE::getFeatureState(Feature f) { void OSystem_IPHONE::suspendLoop() { bool done = false; int eventType; - float xUnit, yUnit; + int x, y; uint32 startTime = getMillis(); stopSoundsystem(); while (!done) { - if (iPhone_fetchEvent(&eventType, &xUnit, &yUnit)) + if (iPhone_fetchEvent(&eventType, &x, &y)) if ((InputEvent)eventType == kInputApplicationResumed) done = true; usleep(100000); -- cgit v1.2.3 From 624d5547dc691952b92f2317e252264dab7399d8 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 17:36:49 +0100 Subject: IPHONE: Don't overwrite orientation when the OpenGL ES context is created. --- backends/platform/iphone/iphone_video.m | 1 - 1 file changed, 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index 977dcce4bd..c917dcccfb 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -494,7 +494,6 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _width, _height, _gameScreenTextureWidth, _gameScreenTextureHeight); if (_context == nil) { - _orientation = UIDeviceOrientationLandscapeRight; CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; eaglLayer.opaque = YES; -- cgit v1.2.3 From 87fb115def77cba564215e75f52bf6154211d1ec Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 18:17:06 +0100 Subject: IPHONE: Rename _backing[Width,Height] to _renderBuffer[Width,Height]. --- backends/platform/iphone/iphone_video.h | 4 ++-- backends/platform/iphone/iphone_video.m | 30 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 173814a028..d6ef46977b 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -44,8 +44,8 @@ EAGLContext *_context; GLuint _viewRenderbuffer; GLuint _viewFramebuffer; - GLint _backingWidth; - GLint _backingHeight; + GLint _renderBufferWidth; + GLint _renderBufferHeight; GLint _visibleWidth; GLint _visibleHeight; GLuint _screenTexture; diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index c917dcccfb..6b96874085 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -438,12 +438,12 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { width = width / (float)_width * gameHeight; height = height / (float)_height * gameWidth; } else { - mouseX = (_overlayWidth - mouseX) / (float)_overlayWidth * _backingWidth; - mouseY = mouseY / (float)_overlayHeight * _backingHeight; - hotspotX = hotspotX / (float)_overlayWidth * _backingWidth; - hotspotY = hotspotY / (float)_overlayHeight * _backingHeight; - width = width / (float)_overlayWidth * _backingWidth; - height = height / (float)_overlayHeight * _backingHeight; + mouseX = (_overlayWidth - mouseX) / (float)_overlayWidth * _renderBufferWidth; + mouseY = mouseY / (float)_overlayHeight * _renderBufferHeight; + hotspotX = hotspotX / (float)_overlayWidth * _renderBufferWidth; + hotspotY = hotspotY / (float)_overlayHeight * _renderBufferHeight; + width = width / (float)_overlayWidth * _renderBufferWidth; + height = height / (float)_overlayHeight * _renderBufferHeight; } mouseX -= hotspotX; @@ -510,16 +510,16 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { [_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id)self.layer]; glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &_backingWidth); printOpenGLError(); - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &_backingHeight); printOpenGLError(); + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &_renderBufferWidth); printOpenGLError(); + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &_renderBufferHeight); printOpenGLError(); if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { NSLog(@"Failed to make complete framebuffer object %x.", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); return; } - _overlayHeight = _backingWidth; - _overlayWidth = _backingHeight; + _overlayHeight = _renderBufferWidth; + _overlayWidth = _renderBufferHeight; _overlayTexWidth = getSizeNextPOT(_overlayHeight); _overlayTexHeight = getSizeNextPOT(_overlayWidth); @@ -527,7 +527,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { _overlayTexBuffer = (char *)malloc(textureSize); memset(_overlayTexBuffer, 0, textureSize); - glViewport(0, 0, _backingWidth, _backingHeight); printOpenGLError(); + glViewport(0, 0, _renderBufferWidth, _renderBufferHeight); printOpenGLError(); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); printOpenGLError(); glEnable(GL_BLEND); @@ -550,7 +550,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { glRotatef(180, 0, 0, 1); printOpenGLError(); } - glOrthof(0, _backingWidth, 0, _backingHeight, 0, 1); printOpenGLError(); + glOrthof(0, _renderBufferWidth, 0, _renderBufferHeight, 0, 1); printOpenGLError(); if (_screenTexture > 0) { glDeleteTextures(1, &_screenTexture); printOpenGLError(); @@ -581,8 +581,8 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { } if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation == UIDeviceOrientationLandscapeRight) { - _visibleHeight = _backingHeight; - _visibleWidth = _backingWidth; + _visibleHeight = _renderBufferHeight; + _visibleWidth = _renderBufferWidth; float ratioDifference = ((float)_height / (float)_width) / ((float)_fullWidth / (float)_fullHeight); int rectWidth, rectHeight; @@ -608,7 +608,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { _screenRect = CGRectMake(0, 0, _fullWidth - 1, height - 1); _visibleHeight = height; - _visibleWidth = _backingWidth; + _visibleWidth = _renderBufferWidth; _heightOffset = 0.0f; _widthOffset = 0.0f; -- cgit v1.2.3 From d91268c4c1e3e0b830e97d144a0548d9d7929bb8 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 18:19:56 +0100 Subject: IPHONE: Rename _screenRect to _gameScreenRect. --- backends/platform/iphone/iphone_video.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index 6b96874085..49c66a6a7d 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -29,7 +29,7 @@ static int _width = 0; static int _height = 0; static int _fullWidth; static int _fullHeight; -static CGRect _screenRect; +static CGRect _gameScreenRect; static char *_gameScreenTextureBuffer = 0; static int _gameScreenTextureWidth = 0; @@ -208,13 +208,13 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int * return false; } } else { - if (point.x < _screenRect.origin.x || point.x >= _screenRect.origin.x + _screenRect.size.width || - point.y < _screenRect.origin.y || point.y >= _screenRect.origin.y + _screenRect.size.height) { + if (point.x < _gameScreenRect.origin.x || point.x >= _gameScreenRect.origin.x + _gameScreenRect.size.width || + point.y < _gameScreenRect.origin.y || point.y >= _gameScreenRect.origin.y + _gameScreenRect.size.height) { return false; } - point.x = (point.x - _screenRect.origin.x) / _screenRect.size.width; - point.y = (point.y - _screenRect.origin.y) / _screenRect.size.height; + point.x = (point.x - _gameScreenRect.origin.x) / _gameScreenRect.size.width; + point.y = (point.y - _gameScreenRect.origin.y) / _gameScreenRect.size.height; switch (orientation) { case UIDeviceOrientationLandscapeLeft: @@ -599,13 +599,13 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { } //printf("Rect: %i, %i, %i, %i\n", _widthOffset, _heightOffset, rectWidth, rectHeight); - _screenRect = CGRectMake(_widthOffset, _heightOffset, rectWidth, rectHeight); + _gameScreenRect = CGRectMake(_widthOffset, _heightOffset, rectWidth, rectHeight); _overlayPortraitRatio = 1.0f; } else { float ratio = (float)_height / (float)_width; int height = _fullWidth * ratio; //printf("Making rect (%u, %u)\n", _fullWidth, height); - _screenRect = CGRectMake(0, 0, _fullWidth - 1, height - 1); + _gameScreenRect = CGRectMake(0, 0, _fullWidth - 1, height - 1); _visibleHeight = height; _visibleWidth = _renderBufferWidth; -- cgit v1.2.3 From 7957cc956e8bf66bd6f7a588d70150de70ef8917 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 18:36:23 +0100 Subject: IPHONE: Use render buffer size instead of application frame size for video size calculations. These match as far as I can tell, but in case they don't match, the render buffer size should be the correct thing to use. --- backends/platform/iphone/iphone_video.m | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index 49c66a6a7d..a27234bc41 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -584,17 +584,17 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { _visibleHeight = _renderBufferHeight; _visibleWidth = _renderBufferWidth; - float ratioDifference = ((float)_height / (float)_width) / ((float)_fullWidth / (float)_fullHeight); + float ratioDifference = ((float)_height / (float)_width) / ((float)_renderBufferWidth / (float)_renderBufferHeight); int rectWidth, rectHeight; if (ratioDifference < 1.0f) { - rectWidth = _fullWidth * ratioDifference; - rectHeight = _fullHeight; - _widthOffset = (_fullWidth - rectWidth) / 2; + rectWidth = _renderBufferWidth * ratioDifference; + rectHeight = _renderBufferHeight; + _widthOffset = (_renderBufferWidth - rectWidth) / 2; _heightOffset = 0; } else { - rectWidth = _fullWidth; - rectHeight = _fullHeight / ratioDifference; - _heightOffset = (_fullHeight - rectHeight) / 2; + rectWidth = _renderBufferWidth; + rectHeight = _renderBufferHeight / ratioDifference; + _heightOffset = (_renderBufferHeight - rectHeight) / 2; _widthOffset = 0; } @@ -603,9 +603,9 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { _overlayPortraitRatio = 1.0f; } else { float ratio = (float)_height / (float)_width; - int height = _fullWidth * ratio; - //printf("Making rect (%u, %u)\n", _fullWidth, height); - _gameScreenRect = CGRectMake(0, 0, _fullWidth - 1, height - 1); + int height = _renderBufferWidth * ratio; + //printf("Making rect (%u, %u)\n", _renderBufferWidth, height); + _gameScreenRect = CGRectMake(0, 0, _renderBufferWidth - 1, height - 1); _visibleHeight = height; _visibleWidth = _renderBufferWidth; -- cgit v1.2.3 From 56e517fdad416a71a7ec685f9b372b8674a4dc99 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Mon, 20 Feb 2012 12:26:25 -0600 Subject: KEYMAPPER: Add some comments --- backends/keymapper/remap-dialog.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index 4ef39a15e5..a869909196 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -62,6 +62,7 @@ void RemapDialog::open() { if (activeKeymaps.size() > 0) { if (activeKeymaps.top().keymap->getName() == Common::kGuiKeymapName) _topKeymapIsGui = true; + // Add the entry for the "effective" special view. See RemapDialog::loadKeymap() _kmPopUp->appendEntry(activeKeymaps.top().keymap->getName() + _(" (Effective)")); } @@ -100,6 +101,8 @@ void RemapDialog::open() { bool active = activeKeymaps[topIndex].transparent; for (int i = topIndex - 1; i >= 0; --i) { Keymapper::MapRecord mr = activeKeymaps[i]; + // Add an entry for each keymap in the stack after the top keymap. Mark it Active if it is + // reachable or Blocked if an opaque keymap is on top of it thus blocking access to it. _kmPopUp->appendEntry(mr.keymap->getName() + (active ? _(" (Active)") : _(" (Blocked)")), idx); _keymapTable[idx++] = mr.keymap; active &= mr.transparent; @@ -108,8 +111,11 @@ void RemapDialog::open() { _kmPopUp->appendEntry(""); + // Now add entries for all known keymaps. Note that there will be duplicates with the stack entries. + if (_globalKeymaps) { for (it = _globalKeymaps->begin(); it != _globalKeymaps->end(); ++it) { + // "global" means its keybindings apply to all games; saved in a global conf domain _kmPopUp->appendEntry(it->_value->getName() + _(" (Global)"), idx); _keymapTable[idx++] = it->_value; } @@ -117,6 +123,7 @@ void RemapDialog::open() { if (_gameKeymaps) { for (it = _gameKeymaps->begin(); it != _gameKeymaps->end(); ++it) { + // "game" means its keybindings are saved per-target _kmPopUp->appendEntry(it->_value->getName() + _(" (Game)"), idx); _keymapTable[idx++] = it->_value; } @@ -314,7 +321,9 @@ void RemapDialog::loadKeymap() { debug(3, "RemapDialog::loadKeymap active keymaps: %u", activeKeymaps.size()); if (!activeKeymaps.empty() && _kmPopUp->getSelected() == 0) { - // load active keymaps + // This is the "effective" view which shows all effective actions: + // - all of the topmost keymap action + // - all mapped actions that are reachable List freeKeys(_keymapper->getHardwareKeys()); @@ -364,6 +373,9 @@ void RemapDialog::loadKeymap() { } } else if (_kmPopUp->getSelected() != -1) { + // This is the regular view of a keymap that isn't the topmost one. + // It shows all of that keymap's actions + Keymap *km = _keymapTable[_kmPopUp->getSelectedTag()]; List::iterator it; -- cgit v1.2.3 From cf44d49d1977c50a4cc977cbd0196032e86bd31d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 19:40:54 +0100 Subject: IPHONE: Precalculate vertex/tex coordinates for game screen/overlay. --- backends/platform/iphone/iphone_video.h | 6 +++ backends/platform/iphone/iphone_video.m | 82 ++++++++++++++++++--------------- 2 files changed, 50 insertions(+), 38 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index d6ef46977b..02b9c8692d 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -53,6 +53,12 @@ GLuint _mouseCursorTexture; UIDeviceOrientation _orientation; + + GLfloat _gameScreenVertCoords[4 * 2]; + GLfloat _gameScreenTexCoords[4 * 2]; + + GLfloat _overlayVertCoords[4 * 2]; + GLfloat _overlayTexCoords[4 * 2]; } - (id)initWithFrame:(struct CGRect)frame; diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index a27234bc41..5e1132ff52 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -288,6 +288,26 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { _overlayTexture = 0; _mouseCursorTexture = 0; + _gameScreenVertCoords[0] = _gameScreenVertCoords[1] = + _gameScreenVertCoords[2] = _gameScreenVertCoords[3] = + _gameScreenVertCoords[4] = _gameScreenVertCoords[5] = + _gameScreenVertCoords[6] = _gameScreenVertCoords[7] = 0; + + _gameScreenTexCoords[0] = _gameScreenTexCoords[1] = + _gameScreenTexCoords[2] = _gameScreenTexCoords[3] = + _gameScreenTexCoords[4] = _gameScreenTexCoords[5] = + _gameScreenTexCoords[6] = _gameScreenTexCoords[7] = 0; + + _overlayVertCoords[0] = _overlayVertCoords[1] = + _overlayVertCoords[2] = _overlayVertCoords[3] = + _overlayVertCoords[4] = _overlayVertCoords[5] = + _overlayVertCoords[6] = _overlayVertCoords[7] = 0; + + _overlayTexCoords[0] = _overlayTexCoords[1] = + _overlayTexCoords[2] = _overlayTexCoords[3] = + _overlayTexCoords[4] = _overlayTexCoords[5] = + _overlayTexCoords[6] = _overlayTexCoords[7] = 0; + return self; } @@ -362,25 +382,8 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { } - (void)updateMainSurface { - GLfloat vertices[] = { - 0.0f + _heightOffset, 0.0f + _widthOffset, - _visibleWidth - _heightOffset, 0.0f + _widthOffset, - 0.0f + _heightOffset, _visibleHeight - _widthOffset, - _visibleWidth - _heightOffset, _visibleHeight - _widthOffset - }; - - float texWidth = _width / (float)_gameScreenTextureWidth; - float texHeight = _height / (float)_gameScreenTextureHeight; - - const GLfloat texCoords[] = { - texWidth, 0.0f, - 0.0f, 0.0f, - texWidth, texHeight, - 0.0f, texHeight - }; - - glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError(); - glTexCoordPointer(2, GL_FLOAT, 0, texCoords); printOpenGLError(); + glVertexPointer(2, GL_FLOAT, 0, _gameScreenVertCoords); printOpenGLError(); + glTexCoordPointer(2, GL_FLOAT, 0, _gameScreenTexCoords); printOpenGLError(); glBindTexture(GL_TEXTURE_2D, _screenTexture); printOpenGLError(); @@ -392,25 +395,8 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { } - (void)updateOverlaySurface { - GLfloat vertices[] = { - 0.0f, 0.0f, - _overlayHeight, 0.0f, - 0.0f, _overlayWidth * _overlayPortraitRatio, - _overlayHeight, _overlayWidth * _overlayPortraitRatio - }; - - float texWidth = _overlayWidth / (float)_overlayTexWidth; - float texHeight = _overlayHeight / (float)_overlayTexHeight; - - const GLfloat texCoords[] = { - texWidth, 0.0f, - 0.0f, 0.0f, - texWidth, texHeight, - 0.0f, texHeight - }; - - glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError(); - glTexCoordPointer(2, GL_FLOAT, 0, texCoords); printOpenGLError(); + glVertexPointer(2, GL_FLOAT, 0, _overlayVertCoords); printOpenGLError(); + glTexCoordPointer(2, GL_FLOAT, 0, _overlayTexCoords); printOpenGLError(); glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError(); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _overlayTexWidth, _overlayTexHeight, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _overlayTexBuffer); printOpenGLError(); @@ -479,6 +465,9 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { _gameScreenTextureWidth = getSizeNextPOT(_width); _gameScreenTextureHeight = getSizeNextPOT(_height); + _gameScreenTexCoords[0] = _gameScreenTexCoords[4] = _width / (GLfloat)_gameScreenTextureWidth; + _gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _height / (GLfloat)_gameScreenTextureHeight; + _orientation = [[UIDevice currentDevice] orientation]; switch (_orientation) { @@ -523,6 +512,9 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { _overlayTexWidth = getSizeNextPOT(_overlayHeight); _overlayTexHeight = getSizeNextPOT(_overlayWidth); + _overlayTexCoords[0] = _overlayTexCoords[4] = _overlayWidth / (GLfloat)_overlayTexWidth; + _overlayTexCoords[5] = _overlayTexCoords[7] = _overlayHeight / (GLfloat)_overlayTexHeight; + int textureSize = _overlayTexWidth * _overlayTexHeight * 2; _overlayTexBuffer = (char *)malloc(textureSize); memset(_overlayTexBuffer, 0, textureSize); @@ -623,6 +615,20 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { [[_keyboardView inputView] becomeFirstResponder]; _overlayPortraitRatio = (_overlayHeight * ratio) / _overlayWidth; } + + _gameScreenVertCoords[0] = _heightOffset; + _gameScreenVertCoords[1] = _widthOffset; + _gameScreenVertCoords[2] = _visibleWidth - _heightOffset; + _gameScreenVertCoords[3] = _widthOffset; + _gameScreenVertCoords[4] = _heightOffset; + _gameScreenVertCoords[5] = _visibleHeight - _widthOffset; + _gameScreenVertCoords[6] = _visibleWidth - _heightOffset; + _gameScreenVertCoords[7] = _visibleHeight - _widthOffset; + + _overlayVertCoords[2] = _overlayHeight; + _overlayVertCoords[5] = _overlayWidth * _overlayPortraitRatio; + _overlayVertCoords[6] = _overlayHeight; + _overlayVertCoords[7] = _overlayWidth * _overlayPortraitRatio; } - (void)clearColorBuffer { -- cgit v1.2.3 From d8531a939e75bebe20590806b65d594b6e214203 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 21:15:14 +0100 Subject: IPHONE: Move OpenGL ES context generation to its own method. --- backends/platform/iphone/iphone_video.m | 115 ++++++++++++++++++-------------- 1 file changed, 65 insertions(+), 50 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index 5e1132ff52..b0b9da8885 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -268,6 +268,68 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { return [CAEAGLLayer class]; } +- (void)createContext { + CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; + + eaglLayer.opaque = YES; + eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, nil]; + + _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; + + // In case creating the OpenGL ES context failed, we will error out here. + if (_context == nil) { + fprintf(stderr, "Could not create OpenGL ES context\n"); + exit(-1); + } + + if ([EAGLContext setCurrentContext:_context]) { + glGenFramebuffersOES(1, &_viewFramebuffer); printOpenGLError(); + glGenRenderbuffersOES(1, &_viewRenderbuffer); printOpenGLError(); + + glBindFramebufferOES(GL_FRAMEBUFFER_OES, _viewFramebuffer); printOpenGLError(); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); + [_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id)self.layer]; + + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); + + // Retrieve the render buffer size. This *should* match the frame size, + // i.e. _fullWidth and _fullHeight. + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &_renderBufferWidth); printOpenGLError(); + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &_renderBufferHeight); printOpenGLError(); + + if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { + NSLog(@"Failed to make complete framebuffer object %x.", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); + return; + } + + _overlayHeight = _renderBufferWidth; + _overlayWidth = _renderBufferHeight; + _overlayTexWidth = getSizeNextPOT(_overlayHeight); + _overlayTexHeight = getSizeNextPOT(_overlayWidth); + + // Since the overlay size won't change the whole run, we can + // precalculate the texture coordinates for the overlay texture here + // and just use it later on. + _overlayTexCoords[0] = _overlayTexCoords[4] = _overlayWidth / (GLfloat)_overlayTexWidth; + _overlayTexCoords[5] = _overlayTexCoords[7] = _overlayHeight / (GLfloat)_overlayTexHeight; + + int textureSize = _overlayTexWidth * _overlayTexHeight * 2; + _overlayTexBuffer = (char *)malloc(textureSize); + memset(_overlayTexBuffer, 0, textureSize); + + glViewport(0, 0, _renderBufferWidth, _renderBufferHeight); printOpenGLError(); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); printOpenGLError(); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glEnable(GL_TEXTURE_2D); printOpenGLError(); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); printOpenGLError(); + glEnableClientState(GL_VERTEX_ARRAY); printOpenGLError(); + } +} + - (id)initWithFrame:(struct CGRect)frame { self = [super initWithFrame: frame]; @@ -283,7 +345,6 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { sharedInstance = self; _keyboardView = nil; - _context = nil; _screenTexture = 0; _overlayTexture = 0; _mouseCursorTexture = 0; @@ -308,6 +369,9 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { _overlayTexCoords[4] = _overlayTexCoords[5] = _overlayTexCoords[6] = _overlayTexCoords[7] = 0; + // Initialize the OpenGL ES context + [self createContext]; + return self; } @@ -482,55 +546,6 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _width, _height, _gameScreenTextureWidth, _gameScreenTextureHeight); - if (_context == nil) { - CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; - - eaglLayer.opaque = YES; - eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, nil]; - - _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; - if (!_context || [EAGLContext setCurrentContext:_context]) { - glGenFramebuffersOES(1, &_viewFramebuffer); printOpenGLError(); - glGenRenderbuffersOES(1, &_viewRenderbuffer); printOpenGLError(); - - glBindFramebufferOES(GL_FRAMEBUFFER_OES, _viewFramebuffer); printOpenGLError(); - glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); - [_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id)self.layer]; - glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); - - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &_renderBufferWidth); printOpenGLError(); - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &_renderBufferHeight); printOpenGLError(); - - if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { - NSLog(@"Failed to make complete framebuffer object %x.", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); - return; - } - - _overlayHeight = _renderBufferWidth; - _overlayWidth = _renderBufferHeight; - _overlayTexWidth = getSizeNextPOT(_overlayHeight); - _overlayTexHeight = getSizeNextPOT(_overlayWidth); - - _overlayTexCoords[0] = _overlayTexCoords[4] = _overlayWidth / (GLfloat)_overlayTexWidth; - _overlayTexCoords[5] = _overlayTexCoords[7] = _overlayHeight / (GLfloat)_overlayTexHeight; - - int textureSize = _overlayTexWidth * _overlayTexHeight * 2; - _overlayTexBuffer = (char *)malloc(textureSize); - memset(_overlayTexBuffer, 0, textureSize); - - glViewport(0, 0, _renderBufferWidth, _renderBufferHeight); printOpenGLError(); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); printOpenGLError(); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glEnable(GL_TEXTURE_2D); printOpenGLError(); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); printOpenGLError(); - glEnableClientState(GL_VERTEX_ARRAY); printOpenGLError(); - } - } - glMatrixMode(GL_PROJECTION); glLoadIdentity(); -- cgit v1.2.3 From 6cc5b83bba51a4d048c09dc35c0d4ed78e07f7ad Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 21:17:19 +0100 Subject: IPHONE: Default to portrait mode in case the orientation could not be determined. --- backends/platform/iphone/iphone_video.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index b0b9da8885..d5002ff3d2 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -541,7 +541,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { break; default: - _orientation = UIDeviceOrientationLandscapeRight; + _orientation = UIDeviceOrientationPortrait; } //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _width, _height, _gameScreenTextureWidth, _gameScreenTextureHeight); -- cgit v1.2.3 From 297d15e122e39ca1c80dc255b1d36b03111630fc Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sun, 19 Feb 2012 20:05:35 +0100 Subject: OPENGL: Don't force alpha to 1 This was likely a hack to work around an alpha blending bug in the gui vector renderer. --- backends/graphics/opengl/opengl-graphics.cpp | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) (limited to 'backends') diff --git a/backends/graphics/opengl/opengl-graphics.cpp b/backends/graphics/opengl/opengl-graphics.cpp index cca8058625..45804b5d6e 100644 --- a/backends/graphics/opengl/opengl-graphics.cpp +++ b/backends/graphics/opengl/opengl-graphics.cpp @@ -501,26 +501,13 @@ void OpenGLGraphicsManager::copyRectToOverlay(const OverlayColor *buf, int pitch if (w <= 0 || h <= 0) return; - if (_overlayFormat.aBits() == 1) { - // Copy buffer with the alpha bit on for all pixels for correct - // overlay drawing. - const uint16 *src = (const uint16 *)buf; - uint16 *dst = (uint16 *)_overlayData.pixels + y * _overlayData.w + x; - for (int i = 0; i < h; i++) { - for (int e = 0; e < w; e++) - dst[e] = src[e] | 0x1; - src += pitch; - dst += _overlayData.w; - } - } else { - // Copy buffer data to internal overlay surface - const byte *src = (const byte *)buf; - byte *dst = (byte *)_overlayData.pixels + y * _overlayData.pitch; - for (int i = 0; i < h; i++) { - memcpy(dst + x * _overlayData.format.bytesPerPixel, src, w * _overlayData.format.bytesPerPixel); - src += pitch * sizeof(buf[0]); - dst += _overlayData.pitch; - } + // Copy buffer data to internal overlay surface + const byte *src = (const byte *)buf; + byte *dst = (byte *)_overlayData.pixels + y * _overlayData.pitch; + for (int i = 0; i < h; i++) { + memcpy(dst + x * _overlayData.format.bytesPerPixel, src, w * _overlayData.format.bytesPerPixel); + src += pitch * sizeof(buf[0]); + dst += _overlayData.pitch; } // Extend dirty area if not full screen redraw is flagged -- cgit v1.2.3 From aa42d78658eacc17a36ffe0d86541deffa534f79 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Tue, 21 Feb 2012 06:57:32 -0600 Subject: KEYMAPPER: Remove automapping dead code --- backends/keymapper/action.cpp | 5 +- backends/keymapper/action.h | 5 - backends/keymapper/hardware-key.h | 12 +- backends/keymapper/keymap.cpp | 141 ---------------- backends/keymapper/keymap.h | 11 +- backends/keymapper/keymapper.cpp | 1 - backends/keymapper/types.h | 74 -------- backends/platform/android/events.cpp | 7 +- backends/platform/linuxmoto/hardwarekeys.cpp | 75 ++++----- backends/platform/maemo/maemo-keys.h | 167 +++++++++--------- backends/platform/maemo/maemo.cpp | 4 +- backends/platform/sdl/hardwarekeys.cpp | 242 +++++++++++++-------------- backends/platform/webos/webos.cpp | 2 +- 13 files changed, 252 insertions(+), 494 deletions(-) delete mode 100644 backends/keymapper/types.h (limited to 'backends') diff --git a/backends/keymapper/action.cpp b/backends/keymapper/action.cpp index 6ee506e7c3..515ec70e32 100644 --- a/backends/keymapper/action.cpp +++ b/backends/keymapper/action.cpp @@ -28,9 +28,8 @@ namespace Common { -Action::Action(Keymap *boss, const char *i, String des, ActionType typ, - KeyType prefKey, int pri, int flg) - : _boss(boss), description(des), type(typ), preferredKey(prefKey), +Action::Action(Keymap *boss, const char *i, String des, int pri, int flg) + : _boss(boss), description(des), priority(pri), flags(flg), _hwKey(0) { assert(i); assert(_boss); diff --git a/backends/keymapper/action.h b/backends/keymapper/action.h index 308a76aa88..bf3773b7e3 100644 --- a/backends/keymapper/action.h +++ b/backends/keymapper/action.h @@ -27,7 +27,6 @@ #ifdef ENABLE_KEYMAPPER -#include "backends/keymapper/types.h" #include "common/events.h" #include "common/func.h" #include "common/list.h" @@ -54,8 +53,6 @@ struct Action { /** Events to be sent when mapped key is pressed */ List events; - ActionType type; - KeyType preferredKey; int priority; int group; int flags; @@ -67,8 +64,6 @@ private: public: Action(Keymap *boss, const char *id, String des = "", - ActionType typ = kGenericActionType, - KeyType prefKey = kGenericKeyType, int pri = 0, int flg = 0 ); void addEvent(const Event &evt) { diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h index 071a38968f..8c46ee6358 100644 --- a/backends/keymapper/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -27,7 +27,6 @@ #ifdef ENABLE_KEYMAPPER -#include "backends/keymapper/types.h" #include "common/textconsole.h" namespace Common { @@ -50,12 +49,8 @@ struct HardwareKey { */ KeyState key; - KeyType type; - ActionType preferredAction; - - HardwareKey(const char *i, KeyState ky = KeyState(), String desc = "", - KeyType typ = kGenericKeyType, ActionType prefAct = kGenericActionType) - : key(ky), description(desc), type(typ), preferredAction(prefAct) { + HardwareKey(const char *i, KeyState ky = KeyState(), String desc = "") + : key(ky), description(desc) { assert(i); Common::strlcpy(hwKeyId, i, HWKEY_ID_SIZE); } @@ -69,7 +64,6 @@ struct KeyTableEntry { KeyCode keycode; uint16 ascii; const char *desc; - KeyType preferredAction; bool shiftable; }; @@ -170,7 +164,7 @@ public: snprintf(fullKeyDesc, 100, "%s%s", mod->desc, key->desc); } - addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc, key->preferredAction )); + addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc)); } } } diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp index daf92e1d15..5bee1a246d 100644 --- a/backends/keymapper/keymap.cpp +++ b/backends/keymapper/keymap.cpp @@ -212,147 +212,6 @@ bool Keymap::isComplete(const HardwareKeySet *hwKeys) { return allMapped || (numberMapped == hwKeys->size()); } -// TODO: -// - current weakness: -// - if an action finds a key with required type but a parent action with -// higher priority is using it, that key is never used -void Keymap::automaticMapping(HardwareKeySet *hwKeys) { -#if 0 //disabling the broken automapper for now - // Create copies of action and key lists. - List actions(_actions); - List keys(hwKeys->getHardwareKeys()); - - List::iterator actIt; - List::iterator keyIt, selectedKey; - - // Remove actions and keys from local lists that have already been mapped. - actIt = actions.begin(); - - while (actIt != actions.end()) { - Action *act = *actIt; - const HardwareKey *key = act->getMappedKey(); - - if (key) { - keys.remove(key); - actIt = actions.erase(actIt); - } else { - ++actIt; - } - } - - // Sort remaining actions by priority. - ActionPriorityComp priorityComp; - sort(actions.begin(), actions.end(), priorityComp); - - // First mapping pass: - // - Match if a key's preferred action type is the same as the action's - // type, or vice versa. - // - Priority is given to: - // - keys that match action types over key types. - // - keys that have not been used by parent maps. - // - If a key has been used by a parent map the new action must have a - // higher priority than the parent action. - // - As soon as the number of skipped actions equals the number of keys - // remaining we stop matching. This means that the second pass will assign keys - // to these higher priority skipped actions. - uint skipped = 0; - actIt = actions.begin(); - - while (actIt != actions.end() && skipped < keys.size()) { - selectedKey = keys.end(); - int matchRank = 0; - Action *act = *actIt; - - for (keyIt = keys.begin(); keyIt != keys.end(); ++keyIt) { - if ((*keyIt)->preferredAction == act->type && act->type != kGenericActionType) { - Action *parentAct = getParentMappedAction((*keyIt)->key); - - if (!parentAct) { - selectedKey = keyIt; - break; - } else if (parentAct->priority <= act->priority && matchRank < 3) { - selectedKey = keyIt; - matchRank = 3; - } - } else if ((*keyIt)->type == act->preferredKey && act->preferredKey != kGenericKeyType && matchRank < 2) { - Action *parentAct = getParentMappedAction((*keyIt)->key); - - if (!parentAct) { - selectedKey = keyIt; - matchRank = 2; - } else if (parentAct->priority <= act->priority && matchRank < 1) { - selectedKey = keyIt; - matchRank = 1; - } - } - } - if (selectedKey != keys.end()) { - // Map action and delete action & key from local lists. - act->mapKey(*selectedKey); - keys.erase(selectedKey); - actIt = actions.erase(actIt); - } else { - // Skip action (will be mapped in next pass). - ++actIt; - ++skipped; - } - } - - // Second mapping pass: - // - Maps any remaining actions to keys - // - priority given to: - // - keys that have no parent action - // - keys whose parent action has lower priority than the new action - // - keys whose parent action has the lowest priority - // - is guaranteed to match a key if they are not all used up - for (actIt = actions.begin(); actIt != actions.end(); ++actIt) { - selectedKey = keys.end(); - - int matchRank = 0; - int lowestPriority = 0; - Action *act = *actIt; - - for (keyIt = keys.begin(); keyIt != keys.end(); ++keyIt) { - Action *parentAct = getParentMappedAction((*keyIt)->key); - - if (!parentAct) { - selectedKey = keyIt; - break; - } else if (matchRank < 2) { - if (parentAct->priority <= act->priority) { - matchRank = 2; - selectedKey = keyIt; - } else if (parentAct->priority < lowestPriority || matchRank == 0) { - matchRank = 1; - lowestPriority = parentAct->priority; - selectedKey = keyIt; - } - } - } - - if (selectedKey != keys.end()) { - act->mapKey(*selectedKey); - keys.erase(selectedKey); - } else {// no match = no keys left - break; - } - } -#endif -} - -Action *Keymap::getParentMappedAction(KeyState key) { - if (_parent) { - Action *act = _parent->getMappedAction(key); - - if (act) - return act; - else - return _parent->getParentMappedAction(key); - } else { - return 0; - } -} - } // End of namespace Common #endif // #ifdef ENABLE_KEYMAPPER diff --git a/backends/keymapper/keymap.h b/backends/keymapper/keymap.h index bbcc4a1926..2e9f08533e 100644 --- a/backends/keymapper/keymap.h +++ b/backends/keymapper/keymap.h @@ -52,7 +52,7 @@ template<> struct Hash class Keymap { public: - Keymap(const String& name, Keymap *parent = 0) : _name(name), _parent(parent) {} + Keymap(const String& name) : _name(name) {} Keymap(const Keymap& km); ~Keymap(); @@ -91,9 +91,6 @@ public: */ void saveMappings(); - - void automaticMapping(HardwareKeySet *hwKeys); - /** * Returns true if all UserAction's in Keymap are mapped, or, * all HardwareKey's from the given set have been used up. @@ -101,7 +98,6 @@ public: bool isComplete(const HardwareKeySet *hwKeys); const String& getName() { return _name; } - Keymap *getParent() { return _parent; } private: friend struct Action; @@ -131,12 +127,7 @@ private: Action *findAction(const char *id); const Action *findAction(const char *id) const; - void internalMapKey(Action *action, HardwareKey *hwKey); - - Action *getParentMappedAction(KeyState key); - String _name; - Keymap *_parent; List _actions; HashMap _keymap; ConfigManager::Domain *_configDomain; diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index 7ada676516..aafdd604a2 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -104,7 +104,6 @@ void Keymapper::initKeymap(Domain &domain, Keymap *map) { map->loadMappings(_hardwareKeys); if (map->isComplete(_hardwareKeys) == false) { - map->automaticMapping(_hardwareKeys); map->saveMappings(); ConfMan.flushToDisk(); } diff --git a/backends/keymapper/types.h b/backends/keymapper/types.h deleted file mode 100644 index ed2e498bd0..0000000000 --- a/backends/keymapper/types.h +++ /dev/null @@ -1,74 +0,0 @@ -/* 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. -* -*/ - -#ifndef KEYMAPPER_TYPES_H -#define KEYMAPPER_TYPES_H - -#include "common/scummsys.h" - -#ifdef ENABLE_KEYMAPPER - -namespace Common { - -enum KeyType { - kGenericKeyType, - kDirUpKeyType, - kDirDownKeyType, - kDirLeftKeyType, - kDirRightKeyType, - kActionKeyType, - kTriggerLeftKeyType, - kTriggerRightKeyType, - kStartKeyType, - kSelectKeyType, - /* ... */ - - kKeyTypeMax -}; - -enum ActionType { - kGenericActionType, - - // common actions - kDirUpActionType, - kDirDownActionType, - kDirLeftActionType, - kDirRightActionType, - kLeftClickActionType, - kRightClickActionType, - kSaveActionType, - kMenuActionType, - kQuitActionType, - kVirtualKeyboardActionType, - kKeyRemapActionType, - kVolumeUpActionType, - kVolumeDownActionType, - - - kActionTypeMax -}; - -} // End of namespace Common - -#endif // #ifdef ENABLE_KEYMAPPER - -#endif // #ifndef KEYMAPPER_TYPES_H diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp index 0e116a7145..a58b93e3bb 100644 --- a/backends/platform/android/events.cpp +++ b/backends/platform/android/events.cpp @@ -227,17 +227,14 @@ void OSystem_Android::setupKeymapper() { HardwareKeySet *keySet = new HardwareKeySet(); keySet->addHardwareKey( - new HardwareKey("n", KeyState(KEYCODE_n), "n (vk)", - kTriggerLeftKeyType, - kVirtualKeyboardActionType)); + new HardwareKey("n", KeyState(KEYCODE_n), "n (vk)")); mapper->registerHardwareKeySet(keySet); Keymap *globalMap = new Keymap(kGlobalKeymapName); Action *act; - act = new Action(globalMap, "VIRT", "Display keyboard", - kVirtualKeyboardActionType); + act = new Action(globalMap, "VIRT", "Display keyboard"); act->addKeyEvent(KeyState(KEYCODE_F7, ASCII_F7, 0)); mapper->addGlobalKeymap(globalMap); diff --git a/backends/platform/linuxmoto/hardwarekeys.cpp b/backends/platform/linuxmoto/hardwarekeys.cpp index cbd9dccf52..da093c6508 100644 --- a/backends/platform/linuxmoto/hardwarekeys.cpp +++ b/backends/platform/linuxmoto/hardwarekeys.cpp @@ -33,60 +33,59 @@ struct Key { KeyCode keycode; uint16 ascii; const char *desc; - KeyType preferredAction; bool shiftable; }; static const Key keys[] = { - { "FIRE", KEYCODE_RETURN, ASCII_RETURN, "Fire", kActionKeyType, false }, - { "CAMERA", KEYCODE_PAUSE, 0, "Camera", kActionKeyType, false }, - { "HANGUP", KEYCODE_ESCAPE, ASCII_ESCAPE, "Hangup", kStartKeyType, false }, - { "CALL", KEYCODE_SPACE, ASCII_SPACE, "Call", kActionKeyType, false }, - { "PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, false }, - { "MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, false }, + { "FIRE", KEYCODE_RETURN, ASCII_RETURN, "Fire", false }, + { "CAMERA", KEYCODE_PAUSE, 0, "Camera", false }, + { "HANGUP", KEYCODE_ESCAPE, ASCII_ESCAPE, "Hangup", false }, + { "CALL", KEYCODE_SPACE, ASCII_SPACE, "Call", false }, + { "PLUS", KEYCODE_PLUS, '+', "+", false }, + { "MINUS", KEYCODE_MINUS, '-', "-", false }, #ifdef MOTOMAGX - {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", kActionKeyType, false}, - {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", kActionKeyType, false}, - {"HASH", KEYCODE_HASH, '#', "#", kActionKeyType, false}, - {"ASTERISK", KEYCODE_ASTERISK, '*', "*", kActionKeyType, false}, - {"LEFTSOFT", KEYCODE_F9, ASCII_F9, "LeftSoft", kActionKeyType, false}, - {"RIGHTSOFT", KEYCODE_F11, ASCII_F11, "RightSoft", kActionKeyType, false}, - {"0", KEYCODE_0, '0', "0", kActionKeyType, false}, - {"1", KEYCODE_1, '1', "1", kActionKeyType, false}, - {"2", KEYCODE_2, '2', "2", kActionKeyType, false}, - {"3", KEYCODE_3, '3', "3", kActionKeyType, false}, - {"4", KEYCODE_4, '4', "4", kActionKeyType, false}, - {"5", KEYCODE_5, '5', "5", kActionKeyType, false}, - {"6", KEYCODE_6, '6', "6", kActionKeyType, false}, - {"7", KEYCODE_7, '7', "7", kActionKeyType, false}, - {"8", KEYCODE_8, '8', "8", kActionKeyType, false}, - {"9", KEYCODE_9, '9', "9", kActionKeyType, false}, + {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", false}, + {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", false}, + {"HASH", KEYCODE_HASH, '#', "#", false}, + {"ASTERISK", KEYCODE_ASTERISK, '*', "*", false}, + {"LEFTSOFT", KEYCODE_F9, ASCII_F9, "LeftSoft", false}, + {"RIGHTSOFT", KEYCODE_F11, ASCII_F11, "RightSoft", false}, + {"0", KEYCODE_0, '0', "0", false}, + {"1", KEYCODE_1, '1', "1", false}, + {"2", KEYCODE_2, '2', "2", false}, + {"3", KEYCODE_3, '3', "3", false}, + {"4", KEYCODE_4, '4', "4", false}, + {"5", KEYCODE_5, '5', "5", false}, + {"6", KEYCODE_6, '6', "6", false}, + {"7", KEYCODE_7, '7', "7", false}, + {"8", KEYCODE_8, '8', "8", false}, + {"9", KEYCODE_9, '9', "9", false}, #endif #ifdef MOTOEZX - { "a", KEYCODE_a, 'a', "a", kActionKeyType, true }, - { "b", KEYCODE_b, 'b', "b", kActionKeyType, true }, - { "c", KEYCODE_c, 'c', "c", kActionKeyType, true }, - { "d", KEYCODE_d, 'd', "d", kActionKeyType, true }, - { "e", KEYCODE_e, 'e', "e", kActionKeyType, true }, - { "f", KEYCODE_f, 'f', "f", kActionKeyType, true }, - { "g", KEYCODE_g, 'g', "g", kActionKeyType, true }, - { "h", KEYCODE_h, 'h', "h", kActionKeyType, true }, - { "i", KEYCODE_i, 'i', "i", kActionKeyType, true }, - { "j", KEYCODE_j, 'j', "j", kActionKeyType, true }, + { "a", KEYCODE_a, 'a', "a", true }, + { "b", KEYCODE_b, 'b', "b", true }, + { "c", KEYCODE_c, 'c', "c", true }, + { "d", KEYCODE_d, 'd', "d", true }, + { "e", KEYCODE_e, 'e', "e", true }, + { "f", KEYCODE_f, 'f', "f", true }, + { "g", KEYCODE_g, 'g', "g", true }, + { "h", KEYCODE_h, 'h', "h", true }, + { "i", KEYCODE_i, 'i', "i", true }, + { "j", KEYCODE_j, 'j', "j", true }, #endif // Numeric keypad // Arrows + Home/End pad - {"UP", KEYCODE_UP, 0, "Up", kDirUpKeyType, false}, - {"DOWN", KEYCODE_DOWN, 0, "Down", kDirDownKeyType, false}, - {"RIGHT", KEYCODE_RIGHT, 0, "Right", kDirRightKeyType, false}, - {"LEFT", KEYCODE_LEFT, 0, "Left", kDirLeftKeyType, false}, + {"UP", KEYCODE_UP, 0, "Up", false}, + {"DOWN", KEYCODE_DOWN, 0, "Down", false}, + {"RIGHT", KEYCODE_RIGHT, 0, "Right", false}, + {"LEFT", KEYCODE_LEFT, 0, "Left", false}, // Function keys // Miscellaneous function keys - {0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false} + {0, KEYCODE_INVALID, 0, 0, false} }; struct Mod { diff --git a/backends/platform/maemo/maemo-keys.h b/backends/platform/maemo/maemo-keys.h index 26ee375625..e1337515a7 100644 --- a/backends/platform/maemo/maemo-keys.h +++ b/backends/platform/maemo/maemo-keys.h @@ -41,97 +41,96 @@ static const ModifierTableEntry maemoModifiers[] = { }; static const KeyTableEntry maemoKeys[] = { - {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", kActionKeyType, false}, - {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", kActionKeyType, false}, - {"CLEAR", KEYCODE_CLEAR, 0, "Clear", kActionKeyType, false}, - {"RETURN", KEYCODE_RETURN, ASCII_RETURN, "MCenter", kActionKeyType, false}, - {"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", kStartKeyType, false}, - {"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", kActionKeyType, false}, - {"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", kActionKeyType, false}, - {"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", kActionKeyType, false}, - {"HASH", KEYCODE_HASH, '#', "#", kActionKeyType, false}, - {"DOLLAR", KEYCODE_DOLLAR, '$', "$", kActionKeyType, false}, - {"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", kActionKeyType, false}, - {"QUOTE", KEYCODE_QUOTE, '\'', "'", kActionKeyType, false}, - {"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", kActionKeyType, false}, - {"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", kActionKeyType, false}, - {"ASTERISK", KEYCODE_ASTERISK, '*', "*", kActionKeyType, false}, - {"PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, false}, - {"COMMA", KEYCODE_COMMA, ',', ",", kActionKeyType, false}, - {"MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, false}, - {"PERIOD", KEYCODE_PERIOD, '.', ".", kActionKeyType, false}, - {"SLASH", KEYCODE_SLASH, '/', "/", kActionKeyType, false}, - {"0", KEYCODE_0, '0', "0", kActionKeyType, false}, - {"1", KEYCODE_1, '1', "1", kActionKeyType, false}, - {"2", KEYCODE_2, '2', "2", kActionKeyType, false}, - {"3", KEYCODE_3, '3', "3", kActionKeyType, false}, - {"4", KEYCODE_4, '4', "4", kActionKeyType, false}, - {"5", KEYCODE_5, '5', "5", kActionKeyType, false}, - {"6", KEYCODE_6, '6', "6", kActionKeyType, false}, - {"7", KEYCODE_7, '7', "7", kActionKeyType, false}, - {"8", KEYCODE_8, '8', "8", kActionKeyType, false}, - {"9", KEYCODE_9, '9', "9", kActionKeyType, false}, - {"COLON", KEYCODE_COLON, ':', ":", kActionKeyType, false}, - {"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", kActionKeyType, false}, - {"LESS", KEYCODE_LESS, '<', "<", kActionKeyType, false}, - {"EQUALS", KEYCODE_EQUALS, '=', "=", kActionKeyType, false}, - {"GREATER", KEYCODE_GREATER, '>', ">", kActionKeyType, false}, - {"QUESTION", KEYCODE_QUESTION, '?', "?", kActionKeyType, false}, - {"AT", KEYCODE_AT, '@', "@", kActionKeyType, false}, - - {"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", kActionKeyType, false}, - {"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", kActionKeyType, false}, - {"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", kActionKeyType, false}, - {"CARET", KEYCODE_CARET, '^', "^", kActionKeyType, false}, - {"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", kActionKeyType, false}, - {"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", kActionKeyType, false}, - {"a", KEYCODE_a, 'a', "a", kActionKeyType, true}, - {"b", KEYCODE_b, 'b', "b", kActionKeyType, true}, - {"c", KEYCODE_c, 'c', "c", kActionKeyType, true}, - {"d", KEYCODE_d, 'd', "d", kActionKeyType, true}, - {"e", KEYCODE_e, 'e', "e", kActionKeyType, true}, - {"f", KEYCODE_f, 'f', "f", kActionKeyType, true}, - {"g", KEYCODE_g, 'g', "g", kActionKeyType, true}, - {"h", KEYCODE_h, 'h', "h", kActionKeyType, true}, - {"i", KEYCODE_i, 'i', "i", kActionKeyType, true}, - {"j", KEYCODE_j, 'j', "j", kActionKeyType, true}, - {"k", KEYCODE_k, 'k', "k", kActionKeyType, true}, - {"l", KEYCODE_l, 'l', "l", kActionKeyType, true}, - {"m", KEYCODE_m, 'm', "m", kActionKeyType, true}, - {"n", KEYCODE_n, 'n', "n", kActionKeyType, true}, - {"o", KEYCODE_o, 'o', "o", kActionKeyType, true}, - {"p", KEYCODE_p, 'p', "p", kActionKeyType, true}, - {"q", KEYCODE_q, 'q', "q", kActionKeyType, true}, - {"r", KEYCODE_r, 'r', "r", kActionKeyType, true}, - {"s", KEYCODE_s, 's', "s", kActionKeyType, true}, - {"t", KEYCODE_t, 't', "t", kActionKeyType, true}, - {"u", KEYCODE_u, 'u', "u", kActionKeyType, true}, - {"v", KEYCODE_v, 'v', "v", kActionKeyType, true}, - {"w", KEYCODE_w, 'w', "w", kActionKeyType, true}, - {"x", KEYCODE_x, 'x', "x", kActionKeyType, true}, - {"y", KEYCODE_y, 'y', "y", kActionKeyType, true}, - {"z", KEYCODE_z, 'z', "z", kActionKeyType, true}, - {"DELETE", KEYCODE_DELETE, 0, "Del", kActionKeyType, false}, - - {"KP_ENTER", KEYCODE_KP_ENTER, 0, "Enter", kActionKeyType, false}, + {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", false}, + {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", false}, + {"CLEAR", KEYCODE_CLEAR, 0, "Clear", false}, + {"RETURN", KEYCODE_RETURN, ASCII_RETURN, "MCenter", false}, + {"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", false}, + {"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", false}, + {"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", false}, + {"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", false}, + {"HASH", KEYCODE_HASH, '#', "#", false}, + {"DOLLAR", KEYCODE_DOLLAR, '$', "$", false}, + {"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", false}, + {"QUOTE", KEYCODE_QUOTE, '\'', "'", false}, + {"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", false}, + {"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", false}, + {"ASTERISK", KEYCODE_ASTERISK, '*', "*", false}, + {"PLUS", KEYCODE_PLUS, '+', "+", false}, + {"COMMA", KEYCODE_COMMA, ',', ",", false}, + {"MINUS", KEYCODE_MINUS, '-', "-", false}, + {"PERIOD", KEYCODE_PERIOD, '.', ".", false}, + {"SLASH", KEYCODE_SLASH, '/', "/", false}, + {"0", KEYCODE_0, '0', "0", false}, + {"1", KEYCODE_1, '1', "1", false}, + {"2", KEYCODE_2, '2', "2", false}, + {"3", KEYCODE_3, '3', "3", false}, + {"4", KEYCODE_4, '4', "4", false}, + {"5", KEYCODE_5, '5', "5", false}, + {"6", KEYCODE_6, '6', "6", false}, + {"7", KEYCODE_7, '7', "7", false}, + {"8", KEYCODE_8, '8', "8", false}, + {"9", KEYCODE_9, '9', "9", false}, + {"COLON", KEYCODE_COLON, ':', ":", false}, + {"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", false}, + {"LESS", KEYCODE_LESS, '<', "<", false}, + {"EQUALS", KEYCODE_EQUALS, '=', "=", false}, + {"GREATER", KEYCODE_GREATER, '>', ">", false}, + {"QUESTION", KEYCODE_QUESTION, '?', "?", false}, + {"AT", KEYCODE_AT, '@', "@", false}, + + {"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", false}, + {"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", false}, + {"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", false}, + {"CARET", KEYCODE_CARET, '^', "^", false}, + {"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", false}, + {"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", false}, + {"a", KEYCODE_a, 'a', "a", true}, + {"b", KEYCODE_b, 'b', "b", true}, + {"c", KEYCODE_c, 'c', "c", true}, + {"d", KEYCODE_d, 'd', "d", true}, + {"e", KEYCODE_e, 'e', "e", true}, + {"f", KEYCODE_f, 'f', "f", true}, + {"g", KEYCODE_g, 'g', "g", true}, + {"h", KEYCODE_h, 'h', "h", true}, + {"i", KEYCODE_i, 'i', "i", true}, + {"j", KEYCODE_j, 'j', "j", true}, + {"k", KEYCODE_k, 'k', "k", true}, + {"l", KEYCODE_l, 'l', "l", true}, + {"m", KEYCODE_m, 'm', "m", true}, + {"n", KEYCODE_n, 'n', "n", true}, + {"o", KEYCODE_o, 'o', "o", true}, + {"p", KEYCODE_p, 'p', "p", true}, + {"q", KEYCODE_q, 'q', "q", true}, + {"r", KEYCODE_r, 'r', "r", true}, + {"s", KEYCODE_s, 's', "s", true}, + {"t", KEYCODE_t, 't', "t", true}, + {"u", KEYCODE_u, 'u', "u", true}, + {"v", KEYCODE_v, 'v', "v", true}, + {"w", KEYCODE_w, 'w', "w", true}, + {"x", KEYCODE_x, 'x', "x", true}, + {"y", KEYCODE_y, 'y', "y", true}, + {"z", KEYCODE_z, 'z', "z", true}, + {"DELETE", KEYCODE_DELETE, 0, "Del", false}, + + {"KP_ENTER", KEYCODE_KP_ENTER, 0, "Enter", false}, // Arrows + Home/End pad - {"UP", KEYCODE_UP, 0, "Up", kDirUpKeyType, false}, - {"DOWN", KEYCODE_DOWN, 0, "Down", kDirDownKeyType, false}, - {"RIGHT", KEYCODE_RIGHT, 0, "Right", kDirRightKeyType, false}, - {"LEFT", KEYCODE_LEFT, 0, "Left", kDirLeftKeyType, false}, + {"UP", KEYCODE_UP, 0, "Up", false}, + {"DOWN", KEYCODE_DOWN, 0, "Down", false}, + {"RIGHT", KEYCODE_RIGHT, 0, "Right", false}, + {"LEFT", KEYCODE_LEFT, 0, "Left", false}, // Function keys - {"MENU", KEYCODE_F11, 0, "Menu", kActionKeyType, false}, - {"HOME", KEYCODE_F12, 0, "Home", kActionKeyType, false}, - {"FULLSCREEN", KEYCODE_F13, 0, "FullScreen", kActionKeyType, false}, - {"ZOOMPLUS", KEYCODE_F14, 0, "Zoom+", kActionKeyType, false}, - {"ZOOMMINUS", KEYCODE_F15, 0, "Zoom-", kActionKeyType, false}, + {"MENU", KEYCODE_F11, 0, "Menu", false}, + {"HOME", KEYCODE_F12, 0, "Home", false}, + {"FULLSCREEN", KEYCODE_F13, 0, "FullScreen", false}, + {"ZOOMPLUS", KEYCODE_F14, 0, "Zoom+", false}, + {"ZOOMMINUS", KEYCODE_F15, 0, "Zoom-", false}, - {0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false} + {0, KEYCODE_INVALID, 0, 0, false} }; - } // namespace Common #endif // ifndef PLATFORM_SDL_MAEMO_KEYS_H diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index 09bc3407e0..209e527e3f 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -189,13 +189,13 @@ Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() { evt.customType = Maemo::kEventClickMode; act->addEvent(evt); - act = new Action(globalMap, "LCLK", _("Left Click"), kLeftClickActionType); + act = new Action(globalMap, "LCLK", _("Left Click")); act->addLeftClickEvent(); act = new Action(globalMap, "MCLK", _("Middle Click")); act->addMiddleClickEvent(); - act = new Action(globalMap, "RCLK", _("Right Click"), kRightClickActionType); + act = new Action(globalMap, "RCLK", _("Right Click")); act->addRightClickEvent(); return globalMap; diff --git a/backends/platform/sdl/hardwarekeys.cpp b/backends/platform/sdl/hardwarekeys.cpp index 1469698a8b..5fb4473ebd 100644 --- a/backends/platform/sdl/hardwarekeys.cpp +++ b/backends/platform/sdl/hardwarekeys.cpp @@ -29,139 +29,139 @@ using namespace Common; static const KeyTableEntry sdlKeys[] = { - {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", kActionKeyType, false}, - {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", kActionKeyType, false}, - {"CLEAR", KEYCODE_CLEAR, 0, "Clear", kActionKeyType, false}, - {"RETURN", KEYCODE_RETURN, ASCII_RETURN, "Return", kActionKeyType, false}, - {"PAUSE", KEYCODE_PAUSE, 0, "Pause", kActionKeyType, false}, - {"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", kStartKeyType, false}, - {"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", kActionKeyType, false}, - {"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", kActionKeyType, false}, - {"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", kActionKeyType, false}, - {"HASH", KEYCODE_HASH, '#', "#", kActionKeyType, false}, - {"DOLLAR", KEYCODE_DOLLAR, '$', "$", kActionKeyType, false}, - {"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", kActionKeyType, false}, - {"QUOTE", KEYCODE_QUOTE, '\'', "'", kActionKeyType, false}, - {"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", kActionKeyType, false}, - {"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", kActionKeyType, false}, - {"ASTERISK", KEYCODE_ASTERISK, '*', "*", kActionKeyType, false}, - {"PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, false}, - {"COMMA", KEYCODE_COMMA, ',', ",", kActionKeyType, false}, - {"MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, false}, - {"PERIOD", KEYCODE_PERIOD, '.', ".", kActionKeyType, false}, - {"SLASH", KEYCODE_SLASH, '/', "/", kActionKeyType, false}, - {"0", KEYCODE_0, '0', "0", kActionKeyType, false}, - {"1", KEYCODE_1, '1', "1", kActionKeyType, false}, - {"2", KEYCODE_2, '2', "2", kActionKeyType, false}, - {"3", KEYCODE_3, '3', "3", kActionKeyType, false}, - {"4", KEYCODE_4, '4', "4", kActionKeyType, false}, - {"5", KEYCODE_5, '5', "5", kActionKeyType, false}, - {"6", KEYCODE_6, '6', "6", kActionKeyType, false}, - {"7", KEYCODE_7, '7', "7", kActionKeyType, false}, - {"8", KEYCODE_8, '8', "8", kActionKeyType, false}, - {"9", KEYCODE_9, '9', "9", kActionKeyType, false}, - {"COLON", KEYCODE_COLON, ':', ":", kActionKeyType, false}, - {"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", kActionKeyType, false}, - {"LESS", KEYCODE_LESS, '<', "<", kActionKeyType, false}, - {"EQUALS", KEYCODE_EQUALS, '=', "=", kActionKeyType, false}, - {"GREATER", KEYCODE_GREATER, '>', ">", kActionKeyType, false}, - {"QUESTION", KEYCODE_QUESTION, '?', "?", kActionKeyType, false}, - {"AT", KEYCODE_AT, '@', "@", kActionKeyType, false}, + {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", false}, + {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", false}, + {"CLEAR", KEYCODE_CLEAR, 0, "Clear", false}, + {"RETURN", KEYCODE_RETURN, ASCII_RETURN, "Return", false}, + {"PAUSE", KEYCODE_PAUSE, 0, "Pause", false}, + {"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", false}, + {"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", false}, + {"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", false}, + {"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", false}, + {"HASH", KEYCODE_HASH, '#', "#", false}, + {"DOLLAR", KEYCODE_DOLLAR, '$', "$", false}, + {"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", false}, + {"QUOTE", KEYCODE_QUOTE, '\'', "'", false}, + {"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", false}, + {"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", false}, + {"ASTERISK", KEYCODE_ASTERISK, '*', "*", false}, + {"PLUS", KEYCODE_PLUS, '+', "+", false}, + {"COMMA", KEYCODE_COMMA, ',', ",", false}, + {"MINUS", KEYCODE_MINUS, '-', "-", false}, + {"PERIOD", KEYCODE_PERIOD, '.', ".", false}, + {"SLASH", KEYCODE_SLASH, '/', "/", false}, + {"0", KEYCODE_0, '0', "0", false}, + {"1", KEYCODE_1, '1', "1", false}, + {"2", KEYCODE_2, '2', "2", false}, + {"3", KEYCODE_3, '3', "3", false}, + {"4", KEYCODE_4, '4', "4", false}, + {"5", KEYCODE_5, '5', "5", false}, + {"6", KEYCODE_6, '6', "6", false}, + {"7", KEYCODE_7, '7', "7", false}, + {"8", KEYCODE_8, '8', "8", false}, + {"9", KEYCODE_9, '9', "9", false}, + {"COLON", KEYCODE_COLON, ':', ":", false}, + {"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", false}, + {"LESS", KEYCODE_LESS, '<', "<", false}, + {"EQUALS", KEYCODE_EQUALS, '=', "=", false}, + {"GREATER", KEYCODE_GREATER, '>', ">", false}, + {"QUESTION", KEYCODE_QUESTION, '?', "?", false}, + {"AT", KEYCODE_AT, '@', "@", false}, - {"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", kActionKeyType, false}, - {"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", kActionKeyType, false}, - {"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", kActionKeyType, false}, - {"CARET", KEYCODE_CARET, '^', "^", kActionKeyType, false}, - {"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", kActionKeyType, false}, - {"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", kActionKeyType, false}, - {"a", KEYCODE_a, 'a', "a", kActionKeyType, true}, - {"b", KEYCODE_b, 'b', "b", kActionKeyType, true}, - {"c", KEYCODE_c, 'c', "c", kActionKeyType, true}, - {"d", KEYCODE_d, 'd', "d", kActionKeyType, true}, - {"e", KEYCODE_e, 'e', "e", kActionKeyType, true}, - {"f", KEYCODE_f, 'f', "f", kActionKeyType, true}, - {"g", KEYCODE_g, 'g', "g", kActionKeyType, true}, - {"h", KEYCODE_h, 'h', "h", kActionKeyType, true}, - {"i", KEYCODE_i, 'i', "i", kActionKeyType, true}, - {"j", KEYCODE_j, 'j', "j", kActionKeyType, true}, - {"k", KEYCODE_k, 'k', "k", kActionKeyType, true}, - {"l", KEYCODE_l, 'l', "l", kActionKeyType, true}, - {"m", KEYCODE_m, 'm', "m", kActionKeyType, true}, - {"n", KEYCODE_n, 'n', "n", kActionKeyType, true}, - {"o", KEYCODE_o, 'o', "o", kActionKeyType, true}, - {"p", KEYCODE_p, 'p', "p", kActionKeyType, true}, - {"q", KEYCODE_q, 'q', "q", kActionKeyType, true}, - {"r", KEYCODE_r, 'r', "r", kActionKeyType, true}, - {"s", KEYCODE_s, 's', "s", kActionKeyType, true}, - {"t", KEYCODE_t, 't', "t", kActionKeyType, true}, - {"u", KEYCODE_u, 'u', "u", kActionKeyType, true}, - {"v", KEYCODE_v, 'v', "v", kActionKeyType, true}, - {"w", KEYCODE_w, 'w', "w", kActionKeyType, true}, - {"x", KEYCODE_x, 'x', "x", kActionKeyType, true}, - {"y", KEYCODE_y, 'y', "y", kActionKeyType, true}, - {"z", KEYCODE_z, 'z', "z", kActionKeyType, true}, - {"DELETE", KEYCODE_DELETE, 0, "Del", kActionKeyType, false}, + {"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", false}, + {"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", false}, + {"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", false}, + {"CARET", KEYCODE_CARET, '^', "^", false}, + {"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", false}, + {"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", false}, + {"a", KEYCODE_a, 'a', "a", true}, + {"b", KEYCODE_b, 'b', "b", true}, + {"c", KEYCODE_c, 'c', "c", true}, + {"d", KEYCODE_d, 'd', "d", true}, + {"e", KEYCODE_e, 'e', "e", true}, + {"f", KEYCODE_f, 'f', "f", true}, + {"g", KEYCODE_g, 'g', "g", true}, + {"h", KEYCODE_h, 'h', "h", true}, + {"i", KEYCODE_i, 'i', "i", true}, + {"j", KEYCODE_j, 'j', "j", true}, + {"k", KEYCODE_k, 'k', "k", true}, + {"l", KEYCODE_l, 'l', "l", true}, + {"m", KEYCODE_m, 'm', "m", true}, + {"n", KEYCODE_n, 'n', "n", true}, + {"o", KEYCODE_o, 'o', "o", true}, + {"p", KEYCODE_p, 'p', "p", true}, + {"q", KEYCODE_q, 'q', "q", true}, + {"r", KEYCODE_r, 'r', "r", true}, + {"s", KEYCODE_s, 's', "s", true}, + {"t", KEYCODE_t, 't', "t", true}, + {"u", KEYCODE_u, 'u', "u", true}, + {"v", KEYCODE_v, 'v', "v", true}, + {"w", KEYCODE_w, 'w', "w", true}, + {"x", KEYCODE_x, 'x', "x", true}, + {"y", KEYCODE_y, 'y', "y", true}, + {"z", KEYCODE_z, 'z', "z", true}, + {"DELETE", KEYCODE_DELETE, 0, "Del", false}, // Numeric keypad - {"KP0", KEYCODE_KP0, 0, "KP0", kActionKeyType, false}, - {"KP1", KEYCODE_KP1, 0, "KP1", kActionKeyType, false}, - {"KP2", KEYCODE_KP2, 0, "KP2", kActionKeyType, false}, - {"KP3", KEYCODE_KP3, 0, "KP3", kActionKeyType, false}, - {"KP4", KEYCODE_KP4, 0, "KP4", kActionKeyType, false}, - {"KP5", KEYCODE_KP5, 0, "KP5", kActionKeyType, false}, - {"KP6", KEYCODE_KP6, 0, "KP6", kActionKeyType, false}, - {"KP7", KEYCODE_KP7, 0, "KP7", kActionKeyType, false}, - {"KP8", KEYCODE_KP8, 0, "KP8", kActionKeyType, false}, - {"KP9", KEYCODE_KP9, 0, "KP9", kActionKeyType, false}, - {"KP_PERIOD", KEYCODE_KP_PERIOD, 0, "KP.", kActionKeyType, false}, - {"KP_DIVIDE", KEYCODE_KP_DIVIDE, 0, "KP/", kActionKeyType, false}, - {"KP_MULTIPLY", KEYCODE_KP_MULTIPLY, 0, "KP*", kActionKeyType, false}, - {"KP_MINUS", KEYCODE_KP_MINUS, 0, "KP-", kActionKeyType, false}, - {"KP_PLUS", KEYCODE_KP_PLUS, 0, "KP+", kActionKeyType, false}, - {"KP_ENTER", KEYCODE_KP_ENTER, 0, "KP Enter", kActionKeyType, false}, - {"KP_EQUALS", KEYCODE_KP_EQUALS, 0, "KP=", kActionKeyType, false}, + {"KP0", KEYCODE_KP0, 0, "KP0", false}, + {"KP1", KEYCODE_KP1, 0, "KP1", false}, + {"KP2", KEYCODE_KP2, 0, "KP2", false}, + {"KP3", KEYCODE_KP3, 0, "KP3", false}, + {"KP4", KEYCODE_KP4, 0, "KP4", false}, + {"KP5", KEYCODE_KP5, 0, "KP5", false}, + {"KP6", KEYCODE_KP6, 0, "KP6", false}, + {"KP7", KEYCODE_KP7, 0, "KP7", false}, + {"KP8", KEYCODE_KP8, 0, "KP8", false}, + {"KP9", KEYCODE_KP9, 0, "KP9", false}, + {"KP_PERIOD", KEYCODE_KP_PERIOD, 0, "KP.", false}, + {"KP_DIVIDE", KEYCODE_KP_DIVIDE, 0, "KP/", false}, + {"KP_MULTIPLY", KEYCODE_KP_MULTIPLY, 0, "KP*", false}, + {"KP_MINUS", KEYCODE_KP_MINUS, 0, "KP-", false}, + {"KP_PLUS", KEYCODE_KP_PLUS, 0, "KP+", false}, + {"KP_ENTER", KEYCODE_KP_ENTER, 0, "KP Enter", false}, + {"KP_EQUALS", KEYCODE_KP_EQUALS, 0, "KP=", false}, // Arrows + Home/End pad - {"UP", KEYCODE_UP, 0, "Up", kDirUpKeyType, false}, - {"DOWN", KEYCODE_DOWN, 0, "Down", kDirDownKeyType, false}, - {"RIGHT", KEYCODE_RIGHT, 0, "Right", kDirRightKeyType, false}, - {"LEFT", KEYCODE_LEFT, 0, "Left", kDirLeftKeyType, false}, - {"INSERT", KEYCODE_INSERT, 0, "Insert", kActionKeyType, false}, - {"HOME", KEYCODE_HOME, 0, "Home", kActionKeyType, false}, - {"END", KEYCODE_END, 0, "End", kActionKeyType, false}, - {"PAGEUP", KEYCODE_PAGEUP, 0, "PgUp", kActionKeyType, false}, - {"PAGEDOWN", KEYCODE_PAGEDOWN, 0, "PgDn", kActionKeyType, false}, + {"UP", KEYCODE_UP, 0, "Up", false}, + {"DOWN", KEYCODE_DOWN, 0, "Down", false}, + {"RIGHT", KEYCODE_RIGHT, 0, "Right", false}, + {"LEFT", KEYCODE_LEFT, 0, "Left", false}, + {"INSERT", KEYCODE_INSERT, 0, "Insert", false}, + {"HOME", KEYCODE_HOME, 0, "Home", false}, + {"END", KEYCODE_END, 0, "End", false}, + {"PAGEUP", KEYCODE_PAGEUP, 0, "PgUp", false}, + {"PAGEDOWN", KEYCODE_PAGEDOWN, 0, "PgDn", false}, // Function keys - {"F1", KEYCODE_F1, ASCII_F1, "F1", kActionKeyType, false}, - {"F2", KEYCODE_F2, ASCII_F2, "F2", kActionKeyType, false}, - {"F3", KEYCODE_F3, ASCII_F3, "F3", kActionKeyType, false}, - {"F4", KEYCODE_F4, ASCII_F4, "F4", kActionKeyType, false}, - {"F5", KEYCODE_F5, ASCII_F5, "F5", kActionKeyType, false}, - {"F6", KEYCODE_F6, ASCII_F6, "F6", kActionKeyType, false}, - {"F7", KEYCODE_F7, ASCII_F7, "F7", kActionKeyType, false}, - {"F8", KEYCODE_F8, ASCII_F8, "F8", kActionKeyType, false}, - {"F9", KEYCODE_F9, ASCII_F9, "F9", kActionKeyType, false}, - {"F10", KEYCODE_F10, ASCII_F10, "F10", kActionKeyType, false}, - {"F11", KEYCODE_F11, ASCII_F11, "F11", kActionKeyType, false}, - {"F12", KEYCODE_F12, ASCII_F12, "F12", kActionKeyType, false}, - {"F13", KEYCODE_F13, 0, "F13", kActionKeyType, false}, - {"F14", KEYCODE_F14, 0, "F14", kActionKeyType, false}, - {"F15", KEYCODE_F15, 0, "F15", kActionKeyType, false}, + {"F1", KEYCODE_F1, ASCII_F1, "F1", false}, + {"F2", KEYCODE_F2, ASCII_F2, "F2", false}, + {"F3", KEYCODE_F3, ASCII_F3, "F3", false}, + {"F4", KEYCODE_F4, ASCII_F4, "F4", false}, + {"F5", KEYCODE_F5, ASCII_F5, "F5", false}, + {"F6", KEYCODE_F6, ASCII_F6, "F6", false}, + {"F7", KEYCODE_F7, ASCII_F7, "F7", false}, + {"F8", KEYCODE_F8, ASCII_F8, "F8", false}, + {"F9", KEYCODE_F9, ASCII_F9, "F9", false}, + {"F10", KEYCODE_F10, ASCII_F10, "F10", false}, + {"F11", KEYCODE_F11, ASCII_F11, "F11", false}, + {"F12", KEYCODE_F12, ASCII_F12, "F12", false}, + {"F13", KEYCODE_F13, 0, "F13", false}, + {"F14", KEYCODE_F14, 0, "F14", false}, + {"F15", KEYCODE_F15, 0, "F15", false}, // Miscellaneous function keys - {"HELP", KEYCODE_HELP, 0, "Help", kActionKeyType, false}, - {"PRINT", KEYCODE_PRINT, 0, "Print", kActionKeyType, false}, - {"SYSREQ", KEYCODE_SYSREQ, 0, "SysRq", kActionKeyType, false}, - {"BREAK", KEYCODE_BREAK, 0, "Break", kActionKeyType, false}, - {"MENU", KEYCODE_MENU, 0, "Menu", kActionKeyType, false}, + {"HELP", KEYCODE_HELP, 0, "Help", false}, + {"PRINT", KEYCODE_PRINT, 0, "Print", false}, + {"SYSREQ", KEYCODE_SYSREQ, 0, "SysRq", false}, + {"BREAK", KEYCODE_BREAK, 0, "Break", false}, + {"MENU", KEYCODE_MENU, 0, "Menu", false}, // Power Macintosh power key - {"POWER", KEYCODE_POWER, 0, "Power", kActionKeyType, false}, + {"POWER", KEYCODE_POWER, 0, "Power", false}, // Some european keyboards - {"EURO", KEYCODE_EURO, 0, "Euro", kActionKeyType, false}, + {"EURO", KEYCODE_EURO, 0, "Euro", false}, // Atari keyboard has Undo - {"UNDO", KEYCODE_UNDO, 0, "Undo", kActionKeyType, false}, - {0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false} + {"UNDO", KEYCODE_UNDO, 0, "Undo", false}, + {0, KEYCODE_INVALID, 0, 0, false} }; static const ModifierTableEntry sdlModifiers[] = { diff --git a/backends/platform/webos/webos.cpp b/backends/platform/webos/webos.cpp index abf572e6be..710a3f79be 100644 --- a/backends/platform/webos/webos.cpp +++ b/backends/platform/webos/webos.cpp @@ -58,7 +58,7 @@ HardwareKeySet *OSystem_SDL_WebOS::getHardwareKeySet() { // Add WebOS specific keys keySet->addHardwareKey(new HardwareKey("FORWARD", - KeyState((KeyCode) 229, 229, 0), "Forward", kActionKeyType)); + KeyState((KeyCode) 229, 229, 0), "Forward")); // Return the modified hardware key set return keySet; -- cgit v1.2.3 From cc8a6cc993b8f6215cb80afa07278b3e5ab5d88f Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 22:21:20 +0100 Subject: IPHONE: Add _overlayRect, which describes the overlay screen rect. --- backends/platform/iphone/iphone_video.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index d5002ff3d2..f60d7de12d 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -40,6 +40,7 @@ static int _overlayTexWidth = 0; static int _overlayTexHeight = 0; static int _overlayWidth = 0; static int _overlayHeight = 0; +static CGRect _overlayRect; static float _overlayPortraitRatio = 1.0f; static int _needsScreenUpdate = 0; @@ -628,9 +629,11 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { [self addSubview:[_keyboardView inputView]]; [self addSubview: _keyboardView]; [[_keyboardView inputView] becomeFirstResponder]; - _overlayPortraitRatio = (_overlayHeight * ratio) / _overlayWidth; + overlayPortraitRatio = (_overlayHeight * ratio) / _overlayWidth; } + _overlayRect = CGRectMake(0, 0, _renderBufferWidth, _renderBufferHeight * overlayPortraitRatio); + _gameScreenVertCoords[0] = _heightOffset; _gameScreenVertCoords[1] = _widthOffset; _gameScreenVertCoords[2] = _visibleWidth - _heightOffset; -- cgit v1.2.3 From f6edcbde8ee3a052f2896c875f853526df0596b0 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 20 Feb 2012 22:31:32 +0100 Subject: IPHONE: Move _overlayPortraitRatio from global scope to local scope. --- backends/platform/iphone/iphone_video.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index f60d7de12d..f7b8edd7b9 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -41,7 +41,6 @@ static int _overlayTexHeight = 0; static int _overlayWidth = 0; static int _overlayHeight = 0; static CGRect _overlayRect; -static float _overlayPortraitRatio = 1.0f; static int _needsScreenUpdate = 0; static int _overlayIsEnabled = 0; @@ -588,6 +587,8 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { [[_keyboardView inputView] removeFromSuperview]; } + float overlayPortraitRatio; + if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation == UIDeviceOrientationLandscapeRight) { _visibleHeight = _renderBufferHeight; _visibleWidth = _renderBufferWidth; @@ -608,7 +609,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { //printf("Rect: %i, %i, %i, %i\n", _widthOffset, _heightOffset, rectWidth, rectHeight); _gameScreenRect = CGRectMake(_widthOffset, _heightOffset, rectWidth, rectHeight); - _overlayPortraitRatio = 1.0f; + overlayPortraitRatio = 1.0f; } else { float ratio = (float)_height / (float)_width; int height = _renderBufferWidth * ratio; -- cgit v1.2.3 From 80b34398174973b6d70673fce94a8a1f670c3f4d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 21 Feb 2012 18:51:16 +0100 Subject: IPHONE: Rewrite video screen rotation. Now it should be a little bit more sane. Formerly the width and height was swapped in rotation mode, which resulted in the x coordinate falling into the range 0..height in landscape mode for example. This also fixes the cursor offset in the modern theme. --- backends/platform/iphone/iphone_video.h | 7 - backends/platform/iphone/iphone_video.m | 248 ++++++++++++++++++-------------- 2 files changed, 141 insertions(+), 114 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 02b9c8692d..f2253f3e21 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -38,16 +38,9 @@ NSMutableArray *_events; SoftKeyboard *_keyboardView; - int _widthOffset; - int _heightOffset; - EAGLContext *_context; GLuint _viewRenderbuffer; GLuint _viewFramebuffer; - GLint _renderBufferWidth; - GLint _renderBufferHeight; - GLint _visibleWidth; - GLint _visibleHeight; GLuint _screenTexture; GLuint _overlayTexture; GLuint _mouseCursorTexture; diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index f7b8edd7b9..5cd9534611 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -57,6 +57,9 @@ static int _mouseX = 0; static int _mouseY = 0; static int _mouseCursorEnabled = 0; +static GLint _renderBufferWidth; +static GLint _renderBufferHeight; + #if 0 static long lastTick = 0; static int frames = 0; @@ -186,57 +189,64 @@ const char *iPhone_getDocumentsDir() { return [documentsDirectory UTF8String]; } -static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int *x, int *y) { - if (_overlayIsEnabled) { - switch (orientation) { - case UIDeviceOrientationLandscapeLeft: - *x = (int)point.y; - *y = _overlayHeight - (int)point.x; - break; - - case UIDeviceOrientationLandscapeRight: - *x = _overlayWidth - (int)point.y; - *y = (int)point.x; - break; - - case UIDeviceOrientationPortrait: - *x = (int)point.x; - *y = (int)point.y; - break; - - default: - return false; - } - } else { - if (point.x < _gameScreenRect.origin.x || point.x >= _gameScreenRect.origin.x + _gameScreenRect.size.width || - point.y < _gameScreenRect.origin.y || point.y >= _gameScreenRect.origin.y + _gameScreenRect.size.height) { - return false; - } +/** + * Converts portrait mode coordinates into rotated mode coordinates. + */ +static bool convertToRotatedCoords(UIDeviceOrientation orientation, CGPoint point, CGPoint *result) { + switch (orientation) { + case UIDeviceOrientationLandscapeLeft: + result->x = point.y; + result->y = _renderBufferWidth - point.x; + return true; - point.x = (point.x - _gameScreenRect.origin.x) / _gameScreenRect.size.width; - point.y = (point.y - _gameScreenRect.origin.y) / _gameScreenRect.size.height; + case UIDeviceOrientationLandscapeRight: + result->x = _renderBufferHeight - point.y; + result->y = point.x; + return true; - switch (orientation) { - case UIDeviceOrientationLandscapeLeft: - *x = point.y * _width; - *y = (1.0f - point.x) * _height; - break; + case UIDeviceOrientationPortrait: + result->x = point.x; + result->y = point.y; + return true; + + default: + return false; + } +} + +static bool normalizeMouseCoords(CGPoint *point, CGRect area) { + if (point->x < CGRectGetMinX(area) || point->x > CGRectGetMaxX(area) || + point->y < CGRectGetMinY(area) || point->y > CGRectGetMaxY(area)) { + return false; + } + + point->x = (point->x - CGRectGetMinX(area)) / CGRectGetWidth(area); + point->y = (point->y - CGRectGetMinY(area)) / CGRectGetHeight(area); + return true; +} - case UIDeviceOrientationLandscapeRight: - *x = (1.0f - point.y) * _width; - *y = point.x * _height; - break; +static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int *x, int *y) { + if (!convertToRotatedCoords(orientation, point, &point)) + return false; - case UIDeviceOrientationPortrait: - *x = point.x * _width; - *y = point.y * _height; - break; + int width, height; + if (_overlayIsEnabled) { + if (!normalizeMouseCoords(&point, _overlayRect)) + return false; - default: + width = _overlayWidth; + height = _overlayHeight; + } else { + if (!normalizeMouseCoords(&point, _gameScreenRect)) return false; - } + + width = _width; + height = _height; } + *x = point.x * width; + *y = point.y * height; + return true; } @@ -311,7 +321,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { // Since the overlay size won't change the whole run, we can // precalculate the texture coordinates for the overlay texture here // and just use it later on. - _overlayTexCoords[0] = _overlayTexCoords[4] = _overlayWidth / (GLfloat)_overlayTexWidth; + _overlayTexCoords[2] = _overlayTexCoords[6] = _overlayWidth / (GLfloat)_overlayTexWidth; _overlayTexCoords[5] = _overlayTexCoords[7] = _overlayHeight / (GLfloat)_overlayTexHeight; int textureSize = _overlayTexWidth * _overlayTexHeight * 2; @@ -477,32 +487,43 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { int hotspotX = _mouseCursorHotspotX; int hotspotY = _mouseCursorHotspotY; + CGRect *rect; + int maxWidth, maxHeight; + if (!_overlayIsEnabled) { - const GLint gameWidth = (_visibleHeight - 2 * _widthOffset); - const GLint gameHeight = (_visibleWidth - 2 * _heightOffset); - - mouseX = (_width - mouseX) / (float)_width * gameHeight + _heightOffset; - mouseY = mouseY / (float)_height * gameWidth + _widthOffset; - hotspotX = hotspotX / (float)_width * gameHeight; - hotspotY = hotspotY / (float)_height * gameWidth; - width = width / (float)_width * gameHeight; - height = height / (float)_height * gameWidth; + rect = &_gameScreenRect; + maxWidth = _width; + maxHeight = _height; } else { - mouseX = (_overlayWidth - mouseX) / (float)_overlayWidth * _renderBufferWidth; - mouseY = mouseY / (float)_overlayHeight * _renderBufferHeight; - hotspotX = hotspotX / (float)_overlayWidth * _renderBufferWidth; - hotspotY = hotspotY / (float)_overlayHeight * _renderBufferHeight; - width = width / (float)_overlayWidth * _renderBufferWidth; - height = height / (float)_overlayHeight * _renderBufferHeight; + rect = &_overlayRect; + maxWidth = _overlayWidth; + maxHeight = _overlayHeight; } + const GLfloat scaleX = CGRectGetWidth(*rect) / (GLfloat)maxWidth; + const GLfloat scaleY = CGRectGetHeight(*rect) / (GLfloat)maxHeight; + + mouseX = mouseX * scaleX; + mouseY = mouseY * scaleY; + hotspotX = hotspotX * scaleX; + hotspotY = hotspotY * scaleY; + width = width * scaleX; + height = height * scaleY; + mouseX -= hotspotX; mouseY -= hotspotY; + mouseX += CGRectGetMinX(*rect); + mouseY += CGRectGetMinY(*rect); + GLfloat vertices[] = { + // Top left mouseX , mouseY, + // Top right mouseX + width, mouseY, + // Bottom left mouseX , mouseY + height, + // Bottom right mouseX + width, mouseY + height }; @@ -512,10 +533,14 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { float texHeight = _mouseCursorHeight / (float)getSizeNextPOT(_mouseCursorHeight); const GLfloat texCoords[] = { - texWidth, 0.0f, - 0.0f, 0.0f, - texWidth, texHeight, - 0.0f, texHeight + // Top left + 0 , 0, + // Top right + texWidth, 0, + // Bottom left + 0 , texHeight, + // Bottom right + texWidth, texHeight }; glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError(); @@ -529,7 +554,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { _gameScreenTextureWidth = getSizeNextPOT(_width); _gameScreenTextureHeight = getSizeNextPOT(_height); - _gameScreenTexCoords[0] = _gameScreenTexCoords[4] = _width / (GLfloat)_gameScreenTextureWidth; + _gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _width / (GLfloat)_gameScreenTextureWidth; _gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _height / (GLfloat)_gameScreenTextureHeight; _orientation = [[UIDevice currentDevice] orientation]; @@ -549,15 +574,27 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); + int screenWidth, screenHeight; + + // Set the origin (0,0) depending on the rotation mode. if (_orientation == UIDeviceOrientationLandscapeRight) { - glRotatef(-90, 0, 0, 1); printOpenGLError(); + glRotatef( 90, 0, 0, 1); printOpenGLError(); + glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); + + screenWidth = _renderBufferHeight; + screenHeight = _renderBufferWidth; } else if (_orientation == UIDeviceOrientationLandscapeLeft) { - glRotatef(90, 0, 0, 1); printOpenGLError(); - } else { - glRotatef(180, 0, 0, 1); printOpenGLError(); - } + glRotatef(-90, 0, 0, 1); printOpenGLError(); + glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); - glOrthof(0, _renderBufferWidth, 0, _renderBufferHeight, 0, 1); printOpenGLError(); + screenWidth = _renderBufferHeight; + screenHeight = _renderBufferWidth; + } else if (_orientation == UIDeviceOrientationPortrait) { + glOrthof(0, _renderBufferWidth, _renderBufferHeight, 0, 0, 1); printOpenGLError(); + + screenWidth = _renderBufferWidth; + screenHeight = _renderBufferHeight; + } if (_screenTexture > 0) { glDeleteTextures(1, &_screenTexture); printOpenGLError(); @@ -590,36 +627,39 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { float overlayPortraitRatio; if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation == UIDeviceOrientationLandscapeRight) { - _visibleHeight = _renderBufferHeight; - _visibleWidth = _renderBufferWidth; + GLfloat gameScreenRatio = (GLfloat)_width / (GLfloat)_height; + GLfloat screenRatio = (GLfloat)screenWidth / (GLfloat)screenHeight; - float ratioDifference = ((float)_height / (float)_width) / ((float)_renderBufferWidth / (float)_renderBufferHeight); + // These are the width/height according to the portrait layout! int rectWidth, rectHeight; - if (ratioDifference < 1.0f) { - rectWidth = _renderBufferWidth * ratioDifference; - rectHeight = _renderBufferHeight; - _widthOffset = (_renderBufferWidth - rectWidth) / 2; - _heightOffset = 0; + int xOffset, yOffset; + + if (gameScreenRatio < screenRatio) { + // When the game screen ratio is less than the screen ratio + // we need to scale the width, since the game screen was higher + // compared to the width than our output screen is. + rectWidth = screenHeight * gameScreenRatio; + rectHeight = screenHeight; + xOffset = (screenWidth - rectWidth) / 2; + yOffset = 0; } else { - rectWidth = _renderBufferWidth; - rectHeight = _renderBufferHeight / ratioDifference; - _heightOffset = (_renderBufferHeight - rectHeight) / 2; - _widthOffset = 0; + // When the game screen ratio is bigger than the screen ratio + // we need to scale the height, since the game screen was wider + // compared to the height than our output screen is. + rectWidth = screenWidth; + rectHeight = screenWidth / gameScreenRatio; + xOffset = 0; + yOffset = (screenHeight - rectHeight) / 2; } - //printf("Rect: %i, %i, %i, %i\n", _widthOffset, _heightOffset, rectWidth, rectHeight); - _gameScreenRect = CGRectMake(_widthOffset, _heightOffset, rectWidth, rectHeight); + //printf("Rect: %i, %i, %i, %i\n", xOffset, yOffset, rectWidth, rectHeight); + _gameScreenRect = CGRectMake(xOffset, yOffset, rectWidth, rectHeight); overlayPortraitRatio = 1.0f; } else { float ratio = (float)_height / (float)_width; - int height = _renderBufferWidth * ratio; - //printf("Making rect (%u, %u)\n", _renderBufferWidth, height); - _gameScreenRect = CGRectMake(0, 0, _renderBufferWidth - 1, height - 1); - - _visibleHeight = height; - _visibleWidth = _renderBufferWidth; - _heightOffset = 0.0f; - _widthOffset = 0.0f; + int height = screenWidth * ratio; + //printf("Making rect (%u, %u)\n", screenWidth, height); + _gameScreenRect = CGRectMake(0, 0, screenWidth, height); CGRect keyFrame = CGRectMake(0.0f, 0.0f, 0.0f, 0.0f); if (_keyboardView == nil) { @@ -633,21 +673,15 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { overlayPortraitRatio = (_overlayHeight * ratio) / _overlayWidth; } - _overlayRect = CGRectMake(0, 0, _renderBufferWidth, _renderBufferHeight * overlayPortraitRatio); - - _gameScreenVertCoords[0] = _heightOffset; - _gameScreenVertCoords[1] = _widthOffset; - _gameScreenVertCoords[2] = _visibleWidth - _heightOffset; - _gameScreenVertCoords[3] = _widthOffset; - _gameScreenVertCoords[4] = _heightOffset; - _gameScreenVertCoords[5] = _visibleHeight - _widthOffset; - _gameScreenVertCoords[6] = _visibleWidth - _heightOffset; - _gameScreenVertCoords[7] = _visibleHeight - _widthOffset; - - _overlayVertCoords[2] = _overlayHeight; - _overlayVertCoords[5] = _overlayWidth * _overlayPortraitRatio; - _overlayVertCoords[6] = _overlayHeight; - _overlayVertCoords[7] = _overlayWidth * _overlayPortraitRatio; + _overlayRect = CGRectMake(0, 0, screenWidth, screenHeight * overlayPortraitRatio); + + _gameScreenVertCoords[0] = _gameScreenVertCoords[4] = CGRectGetMinX(_gameScreenRect); + _gameScreenVertCoords[1] = _gameScreenVertCoords[3] = CGRectGetMinY(_gameScreenRect); + _gameScreenVertCoords[2] = _gameScreenVertCoords[6] = CGRectGetMaxX(_gameScreenRect); + _gameScreenVertCoords[5] = _gameScreenVertCoords[7] = CGRectGetMaxY(_gameScreenRect); + + _overlayVertCoords[2] = _overlayVertCoords[6] = CGRectGetMaxX(_overlayRect); + _overlayVertCoords[5] = _overlayVertCoords[7] = CGRectGetMaxY(_overlayRect); } - (void)clearColorBuffer { -- cgit v1.2.3 From e1e9bd5c0e6d8b2593c0d25970eb7d121146d961 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Tue, 21 Feb 2012 13:34:30 -0600 Subject: KEYMAPPER: Clean up more dead code More automapper related dead code --- backends/keymapper/action.cpp | 5 ++--- backends/keymapper/action.h | 15 +-------------- 2 files changed, 3 insertions(+), 17 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/action.cpp b/backends/keymapper/action.cpp index 515ec70e32..e5b2d9415a 100644 --- a/backends/keymapper/action.cpp +++ b/backends/keymapper/action.cpp @@ -28,9 +28,8 @@ namespace Common { -Action::Action(Keymap *boss, const char *i, String des, int pri, int flg) - : _boss(boss), description(des), - priority(pri), flags(flg), _hwKey(0) { +Action::Action(Keymap *boss, const char *i, String des) + : _boss(boss), description(des), _hwKey(0) { assert(i); assert(_boss); diff --git a/backends/keymapper/action.h b/backends/keymapper/action.h index bf3773b7e3..3132260512 100644 --- a/backends/keymapper/action.h +++ b/backends/keymapper/action.h @@ -53,9 +53,6 @@ struct Action { /** Events to be sent when mapped key is pressed */ List events; - int priority; - int group; - int flags; private: /** Hardware key that is mapped to this Action */ @@ -63,8 +60,7 @@ private: Keymap *_boss; public: - Action(Keymap *boss, const char *id, String des = "", - int pri = 0, int flg = 0 ); + Action(Keymap *boss, const char *id, String des = ""); void addEvent(const Event &evt) { events.push_back(evt); @@ -106,15 +102,6 @@ public: }; -struct ActionPriorityComp : public BinaryFunction { - bool operator()(const Action *x, const Action *y) const { - return x->priority > y->priority; - } - bool operator()(const Action &x, const Action &y) const { - return x.priority > y.priority; - } -}; - } // End of namespace Common #endif // #ifdef ENABLE_KEYMAPPER -- cgit v1.2.3 From 1b26346fc887ce2681b3a70c6b5af030542dc3f1 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 22 Feb 2012 01:50:25 +0100 Subject: IPHONE: Implement setShakeOffset. This should fix bug #3374656 "IPHONE: setShakePos not implemented". --- backends/platform/iphone/iphone_common.h | 1 + backends/platform/iphone/iphone_video.h | 1 + backends/platform/iphone/iphone_video.m | 60 ++++++++++++++++++++++---------- backends/platform/iphone/osys_video.cpp | 3 ++ 4 files changed, 46 insertions(+), 19 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 2f03309215..3c2d414304 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -75,6 +75,7 @@ void iPhone_updateScreen(int mouseX, int mouseY); void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2); void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2); void iPhone_initSurface(int width, int height); +void iPhone_setShakeOffset(int offset); bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY); const char *iPhone_getDocumentsDir(); bool iPhone_isHighResDevice(); diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index f2253f3e21..6d64b8464b 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -61,6 +61,7 @@ - (void *)getSurface; - (void)initSurface; +- (void)setViewTransformation; - (void)setGraphicsMode; diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m index 5cd9534611..5adf594a15 100644 --- a/backends/platform/iphone/iphone_video.m +++ b/backends/platform/iphone/iphone_video.m @@ -60,6 +60,9 @@ static int _mouseCursorEnabled = 0; static GLint _renderBufferWidth; static GLint _renderBufferHeight; +static int _shakeOffsetY; +static int _scaledShakeOffsetY; + #if 0 static long lastTick = 0; static int frames = 0; @@ -148,9 +151,15 @@ void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, in void iPhone_initSurface(int width, int height) { _width = width; _height = height; + _shakeOffsetY = 0; [sharedInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES]; } +void iPhone_setShakeOffset(int offset) { + _shakeOffsetY = offset; + [sharedInstance performSelectorOnMainThread:@selector(setViewTransformation) withObject:nil waitUntilDone: YES]; +} + bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY) { id event = [sharedInstance getEvent]; if (event == nil) { @@ -214,38 +223,35 @@ static bool convertToRotatedCoords(UIDeviceOrientation orientation, CGPoint poin } } -static bool normalizeMouseCoords(CGPoint *point, CGRect area) { - if (point->x < CGRectGetMinX(area) || point->x > CGRectGetMaxX(area) || - point->y < CGRectGetMinY(area) || point->y > CGRectGetMaxY(area)) { - return false; - } - - point->x = (point->x - CGRectGetMinX(area)) / CGRectGetWidth(area); - point->y = (point->y - CGRectGetMinY(area)) / CGRectGetHeight(area); - return true; -} - static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int *x, int *y) { if (!convertToRotatedCoords(orientation, point, &point)) return false; - int width, height; + CGRect *area; + int width, height, offsetY; if (_overlayIsEnabled) { - if (!normalizeMouseCoords(&point, _overlayRect)) - return false; - + area = &_overlayRect; width = _overlayWidth; height = _overlayHeight; + offsetY = _shakeOffsetY; } else { - if (!normalizeMouseCoords(&point, _gameScreenRect)) - return false; - + area = &_gameScreenRect; width = _width; height = _height; + offsetY = _scaledShakeOffsetY; } + point.x = (point.x - CGRectGetMinX(*area)) / CGRectGetWidth(*area); + point.y = (point.y - CGRectGetMinY(*area)) / CGRectGetHeight(*area); + *x = point.x * width; - *y = point.y * height; + // offsetY describes the translation of the screen in the upward direction, + // thus we need to add it here. + *y = point.y * height + offsetY; + + // Clip coordinates + if (*x < 0 || *x > CGRectGetWidth(*area) || *y < 0 || *y > CGRectGetHeight(*area)) + return false; return true; } @@ -682,6 +688,22 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { _overlayVertCoords[2] = _overlayVertCoords[6] = CGRectGetMaxX(_overlayRect); _overlayVertCoords[5] = _overlayVertCoords[7] = CGRectGetMaxY(_overlayRect); + + [self setViewTransformation]; +} + +- (void)setViewTransformation { + // Set the modelview matrix. This matrix will be used for the shake offset + // support. + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + // Scale the shake offset according to the overlay size. We need this to + // adjust the overlay mouse click coordinates when an offset is set. + _scaledShakeOffsetY = _shakeOffsetY / (GLfloat)_height * CGRectGetHeight(_overlayRect); + + // Apply the shakeing to the output screen. + glTranslatef(0, -_scaledShakeOffsetY, 0); } - (void)clearColorBuffer { diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index 78c6cd4625..2b45b5568c 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -245,6 +245,9 @@ void OSystem_IPHONE::unlockScreen() { void OSystem_IPHONE::setShakePos(int shakeOffset) { //printf("setShakePos(%i)\n", shakeOffset); + iPhone_setShakeOffset(shakeOffset); + // HACK: We use this to force a redraw. + _mouseDirty = true; } void OSystem_IPHONE::showOverlay() { -- cgit v1.2.3 From e79f6a631474a49b9e92d3d0c8c5f2a7dc72d123 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 22 Feb 2012 02:30:44 +0100 Subject: IPHONE: Move ObjC code files (.m) to ObjC++ files (.mm). --- backends/platform/iphone/iphone_common.h | 24 +- backends/platform/iphone/iphone_keyboard.m | 95 --- backends/platform/iphone/iphone_keyboard.mm | 95 +++ backends/platform/iphone/iphone_main.m | 137 ---- backends/platform/iphone/iphone_main.mm | 137 ++++ backends/platform/iphone/iphone_video.m | 931 ---------------------------- backends/platform/iphone/iphone_video.mm | 931 ++++++++++++++++++++++++++++ backends/platform/iphone/osys_video.cpp | 2 +- 8 files changed, 1167 insertions(+), 1185 deletions(-) delete mode 100644 backends/platform/iphone/iphone_keyboard.m create mode 100644 backends/platform/iphone/iphone_keyboard.mm delete mode 100644 backends/platform/iphone/iphone_main.m create mode 100644 backends/platform/iphone/iphone_main.mm delete mode 100644 backends/platform/iphone/iphone_video.m create mode 100644 backends/platform/iphone/iphone_video.mm (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 3c2d414304..5a46a6dde6 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -50,27 +50,13 @@ enum UIViewSwipeDirection { kUIViewSwipeRight = 8 }; -typedef enum { +enum GraphicsModes { kGraphicsModeLinear = 0, kGraphicsModeNone = 1 -} GraphicsModes; - -#ifdef IPHONE_OFFICIAL -void iphone_main(int argc, char **argv); -#endif - -// We need this to be able to call functions from/in Objective-C. -#ifdef __cplusplus -extern "C" { -#endif - -// On the C++ side -#ifndef IPHONE_OFFICIAL -void iphone_main(int argc, char *argv[]); -#endif +}; // On the ObjC side -void iPhone_setGraphicsMode(int mode); +void iPhone_setGraphicsMode(GraphicsModes mode); void iPhone_updateScreen(int mouseX, int mouseY); void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2); void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2); @@ -87,8 +73,4 @@ void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int ho uint getSizeNextPOT(uint size); -#ifdef __cplusplus -} -#endif - #endif diff --git a/backends/platform/iphone/iphone_keyboard.m b/backends/platform/iphone/iphone_keyboard.m deleted file mode 100644 index b00930ab31..0000000000 --- a/backends/platform/iphone/iphone_keyboard.m +++ /dev/null @@ -1,95 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "iphone_keyboard.h" - -@interface UITextInputTraits -- (void)setAutocorrectionType:(int)type; -- (void)setAutocapitalizationType:(int)type; -- (void)setEnablesReturnKeyAutomatically:(BOOL)val; -@end - -@interface TextInputHandler : UITextView { - SoftKeyboard *softKeyboard; -} - -- (id)initWithKeyboard:(SoftKeyboard *)keyboard; - -@end - - -@implementation TextInputHandler - -- (id)initWithKeyboard:(SoftKeyboard *)keyboard; { - self = [super initWithFrame:CGRectMake(0.0f, 0.0f, 0.0f, 0.0f)]; - softKeyboard = keyboard; - - [[self textInputTraits] setAutocorrectionType:(UITextAutocorrectionType)1]; - [[self textInputTraits] setAutocapitalizationType:(UITextAutocapitalizationType)0]; - [[self textInputTraits] setEnablesReturnKeyAutomatically:NO]; - - return self; -} - -- (void) keyboardInputShouldDelete:(id)input { - [softKeyboard handleKeyPress:0x08]; -} - -- (BOOL)webView:(id)fp8 shouldInsertText:(id)character - replacingDOMRange:(id)fp16 - givenAction:(int)fp20 { - - if ([character length] != 1) { - [NSException raise:@"Unsupported" format:@"Unhandled multi-char insert!"]; - return NO; - } - - [softKeyboard handleKeyPress:[character characterAtIndex:0]]; - - return NO; -} - -@end - - -@implementation SoftKeyboard - -- (id)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; - inputDelegate = nil; - inputView = [[TextInputHandler alloc] initWithKeyboard:self]; - return self; -} - -- (UITextView *)inputView { - return inputView; -} - -- (void)setInputDelegate:(id)delegate { - inputDelegate = delegate; -} - -- (void)handleKeyPress:(unichar)c { - [inputDelegate handleKeyPress:c]; -} - -@end diff --git a/backends/platform/iphone/iphone_keyboard.mm b/backends/platform/iphone/iphone_keyboard.mm new file mode 100644 index 0000000000..b00930ab31 --- /dev/null +++ b/backends/platform/iphone/iphone_keyboard.mm @@ -0,0 +1,95 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "iphone_keyboard.h" + +@interface UITextInputTraits +- (void)setAutocorrectionType:(int)type; +- (void)setAutocapitalizationType:(int)type; +- (void)setEnablesReturnKeyAutomatically:(BOOL)val; +@end + +@interface TextInputHandler : UITextView { + SoftKeyboard *softKeyboard; +} + +- (id)initWithKeyboard:(SoftKeyboard *)keyboard; + +@end + + +@implementation TextInputHandler + +- (id)initWithKeyboard:(SoftKeyboard *)keyboard; { + self = [super initWithFrame:CGRectMake(0.0f, 0.0f, 0.0f, 0.0f)]; + softKeyboard = keyboard; + + [[self textInputTraits] setAutocorrectionType:(UITextAutocorrectionType)1]; + [[self textInputTraits] setAutocapitalizationType:(UITextAutocapitalizationType)0]; + [[self textInputTraits] setEnablesReturnKeyAutomatically:NO]; + + return self; +} + +- (void) keyboardInputShouldDelete:(id)input { + [softKeyboard handleKeyPress:0x08]; +} + +- (BOOL)webView:(id)fp8 shouldInsertText:(id)character + replacingDOMRange:(id)fp16 + givenAction:(int)fp20 { + + if ([character length] != 1) { + [NSException raise:@"Unsupported" format:@"Unhandled multi-char insert!"]; + return NO; + } + + [softKeyboard handleKeyPress:[character characterAtIndex:0]]; + + return NO; +} + +@end + + +@implementation SoftKeyboard + +- (id)initWithFrame:(CGRect)frame { + self = [super initWithFrame:frame]; + inputDelegate = nil; + inputView = [[TextInputHandler alloc] initWithKeyboard:self]; + return self; +} + +- (UITextView *)inputView { + return inputView; +} + +- (void)setInputDelegate:(id)delegate { + inputDelegate = delegate; +} + +- (void)handleKeyPress:(unichar)c { + [inputDelegate handleKeyPress:c]; +} + +@end diff --git a/backends/platform/iphone/iphone_main.m b/backends/platform/iphone/iphone_main.m deleted file mode 100644 index 051da417ea..0000000000 --- a/backends/platform/iphone/iphone_main.m +++ /dev/null @@ -1,137 +0,0 @@ -/* 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. - * - */ - -#import -#import - -#include "iphone_video.h" - -void iphone_main(int argc, char *argv[]); - -@interface iPhoneMain : UIApplication { - UIWindow *_window; - iPhoneView *_view; -} - -- (void)mainLoop:(id)param; -- (iPhoneView *)getView; -- (UIWindow *)getWindow; -- (void)didRotate:(NSNotification *)notification; -@end - -static int gArgc; -static char **gArgv; - -int main(int argc, char **argv) { - gArgc = argc; - gArgv = argv; - - NSAutoreleasePool *autoreleasePool = [ - [NSAutoreleasePool alloc] init - ]; - - int returnCode = UIApplicationMain(argc, argv, @"iPhoneMain", @"iPhoneMain"); - [autoreleasePool release]; - return returnCode; -} - -@implementation iPhoneMain - --(id) init { - [super init]; - _window = nil; - _view = nil; - return self; -} - -- (void)mainLoop:(id)param { - [[NSAutoreleasePool alloc] init]; - - iphone_main(gArgc, gArgv); - exit(0); -} - -- (iPhoneView *)getView { - return _view; -} - -- (void)applicationDidFinishLaunching:(UIApplication *)application { - CGRect rect = [[UIScreen mainScreen] bounds]; - - // hide the status bar - [application setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; - [application setStatusBarHidden:YES animated:YES]; - - _window = [[UIWindow alloc] initWithFrame:rect]; - [_window retain]; - - _view = [[iPhoneView alloc] initWithFrame:rect]; - _view.multipleTouchEnabled = YES; - - [_window setContentView:_view]; - - [_window addSubview:_view]; - [_window makeKeyAndVisible]; - - [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(didRotate:) - name:@"UIDeviceOrientationDidChangeNotification" - object:nil]; - - [NSThread detachNewThreadSelector:@selector(mainLoop:) toTarget:self withObject:nil]; -} - -- (void)applicationDidResume { -} - -- (void)applicationWillSuspend { -} - -- (void)applicationWillTerminate { -} - -- (void)applicationSuspend:(struct __GSEvent *)event { - //[self setApplicationBadge:NSLocalizedString(@"ON", nil)]; - [_view applicationSuspend]; -} - -- (void)applicationResume:(struct __GSEvent *)event { - [_view applicationResume]; - - // Workaround, need to "hide" and unhide the statusbar to properly remove it, - // since the Springboard has put it back without apparently flagging our application. - [self setStatusBarHidden:YES animated:YES]; - [self setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; - [self setStatusBarHidden:YES animated:YES]; -} - -- (void)didRotate:(NSNotification *)notification { - UIDeviceOrientation screenOrientation = [[UIDevice currentDevice] orientation]; - [_view deviceOrientationChanged:screenOrientation]; -} - -- (UIWindow*) getWindow { - return _window; -} - -@end diff --git a/backends/platform/iphone/iphone_main.mm b/backends/platform/iphone/iphone_main.mm new file mode 100644 index 0000000000..051da417ea --- /dev/null +++ b/backends/platform/iphone/iphone_main.mm @@ -0,0 +1,137 @@ +/* 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. + * + */ + +#import +#import + +#include "iphone_video.h" + +void iphone_main(int argc, char *argv[]); + +@interface iPhoneMain : UIApplication { + UIWindow *_window; + iPhoneView *_view; +} + +- (void)mainLoop:(id)param; +- (iPhoneView *)getView; +- (UIWindow *)getWindow; +- (void)didRotate:(NSNotification *)notification; +@end + +static int gArgc; +static char **gArgv; + +int main(int argc, char **argv) { + gArgc = argc; + gArgv = argv; + + NSAutoreleasePool *autoreleasePool = [ + [NSAutoreleasePool alloc] init + ]; + + int returnCode = UIApplicationMain(argc, argv, @"iPhoneMain", @"iPhoneMain"); + [autoreleasePool release]; + return returnCode; +} + +@implementation iPhoneMain + +-(id) init { + [super init]; + _window = nil; + _view = nil; + return self; +} + +- (void)mainLoop:(id)param { + [[NSAutoreleasePool alloc] init]; + + iphone_main(gArgc, gArgv); + exit(0); +} + +- (iPhoneView *)getView { + return _view; +} + +- (void)applicationDidFinishLaunching:(UIApplication *)application { + CGRect rect = [[UIScreen mainScreen] bounds]; + + // hide the status bar + [application setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; + [application setStatusBarHidden:YES animated:YES]; + + _window = [[UIWindow alloc] initWithFrame:rect]; + [_window retain]; + + _view = [[iPhoneView alloc] initWithFrame:rect]; + _view.multipleTouchEnabled = YES; + + [_window setContentView:_view]; + + [_window addSubview:_view]; + [_window makeKeyAndVisible]; + + [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(didRotate:) + name:@"UIDeviceOrientationDidChangeNotification" + object:nil]; + + [NSThread detachNewThreadSelector:@selector(mainLoop:) toTarget:self withObject:nil]; +} + +- (void)applicationDidResume { +} + +- (void)applicationWillSuspend { +} + +- (void)applicationWillTerminate { +} + +- (void)applicationSuspend:(struct __GSEvent *)event { + //[self setApplicationBadge:NSLocalizedString(@"ON", nil)]; + [_view applicationSuspend]; +} + +- (void)applicationResume:(struct __GSEvent *)event { + [_view applicationResume]; + + // Workaround, need to "hide" and unhide the statusbar to properly remove it, + // since the Springboard has put it back without apparently flagging our application. + [self setStatusBarHidden:YES animated:YES]; + [self setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:NO]; + [self setStatusBarHidden:YES animated:YES]; +} + +- (void)didRotate:(NSNotification *)notification { + UIDeviceOrientation screenOrientation = [[UIDevice currentDevice] orientation]; + [_view deviceOrientationChanged:screenOrientation]; +} + +- (UIWindow*) getWindow { + return _window; +} + +@end diff --git a/backends/platform/iphone/iphone_video.m b/backends/platform/iphone/iphone_video.m deleted file mode 100644 index 5adf594a15..0000000000 --- a/backends/platform/iphone/iphone_video.m +++ /dev/null @@ -1,931 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "iphone_video.h" -#include "iphone_common.h" - -static iPhoneView *sharedInstance = nil; -static GraphicsModes _graphicsMode = kGraphicsModeLinear; -static int _width = 0; -static int _height = 0; -static int _fullWidth; -static int _fullHeight; -static CGRect _gameScreenRect; - -static char *_gameScreenTextureBuffer = 0; -static int _gameScreenTextureWidth = 0; -static int _gameScreenTextureHeight = 0; - -static char *_overlayTexBuffer = 0; -static int _overlayTexWidth = 0; -static int _overlayTexHeight = 0; -static int _overlayWidth = 0; -static int _overlayHeight = 0; -static CGRect _overlayRect; - -static int _needsScreenUpdate = 0; -static int _overlayIsEnabled = 0; - -static UITouch *_firstTouch = NULL; -static UITouch *_secondTouch = NULL; - -static unsigned short *_mouseCursor = NULL; -static int _mouseCursorHeight = 0; -static int _mouseCursorWidth = 0; -static int _mouseCursorHotspotX = 0; -static int _mouseCursorHotspotY = 0; -static int _mouseX = 0; -static int _mouseY = 0; -static int _mouseCursorEnabled = 0; - -static GLint _renderBufferWidth; -static GLint _renderBufferHeight; - -static int _shakeOffsetY; -static int _scaledShakeOffsetY; - -#if 0 -static long lastTick = 0; -static int frames = 0; -#endif - -#define printOpenGLError() printOglError(__FILE__, __LINE__) - -int printOglError(const char *file, int line) { - int retCode = 0; - - // returns 1 if an OpenGL error occurred, 0 otherwise. - GLenum glErr = glGetError(); - while (glErr != GL_NO_ERROR) { - fprintf(stderr, "glError: %u (%s: %d)\n", glErr, file, line); - retCode = 1; - glErr = glGetError(); - } - return retCode; -} - -void iPhone_setGraphicsMode(int mode) { - _graphicsMode = mode; - - [sharedInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES]; -} - -void iPhone_showCursor(int state) { - _mouseCursorEnabled = state; -} - -void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int hotspotX, int hotspotY) { - _mouseCursor = buffer; - - _mouseCursorWidth = width; - _mouseCursorHeight = height; - - _mouseCursorHotspotX = hotspotX; - _mouseCursorHotspotY = hotspotY; - - [sharedInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; -} - -void iPhone_enableOverlay(int state) { - _overlayIsEnabled = state; - - [sharedInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; -} - -int iPhone_getScreenHeight() { - return _overlayHeight; -} - -int iPhone_getScreenWidth() { - return _overlayWidth; -} - -bool iPhone_isHighResDevice() { - return _fullHeight > 480; -} - -void iPhone_updateScreen(int mouseX, int mouseY) { - //printf("Mouse: (%i, %i)\n", mouseX, mouseY); - - _mouseX = mouseX; - _mouseY = mouseY; - - if (!_needsScreenUpdate) { - _needsScreenUpdate = 1; - [sharedInstance performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO]; - } -} - -void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2) { - int y; - for (y = y1; y < y2; ++y) - memcpy(&_gameScreenTextureBuffer[(y * _gameScreenTextureWidth + x1) * 2], &screen[y * _width + x1], (x2 - x1) * 2); -} - -void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2) { - int y; - //printf("Overlaywidth: %u, fullwidth %u\n", _overlayWidth, _fullWidth); - for (y = y1; y < y2; ++y) - memcpy(&_overlayTexBuffer[(y * _overlayTexWidth + x1) * 2], &screen[y * _overlayWidth + x1], (x2 - x1) * 2); -} - -void iPhone_initSurface(int width, int height) { - _width = width; - _height = height; - _shakeOffsetY = 0; - [sharedInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES]; -} - -void iPhone_setShakeOffset(int offset) { - _shakeOffsetY = offset; - [sharedInstance performSelectorOnMainThread:@selector(setViewTransformation) withObject:nil waitUntilDone: YES]; -} - -bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY) { - id event = [sharedInstance getEvent]; - if (event == nil) { - return false; - } - - id type = [event objectForKey:@"type"]; - - if (type == nil) { - printf("fetchEvent says: No type!\n"); - return false; - } - - *outEvent = [type intValue]; - *outX = [[event objectForKey:@"x"] intValue]; - *outY = [[event objectForKey:@"y"] intValue]; - return true; -} - -uint getSizeNextPOT(uint size) { - if ((size & (size - 1)) || !size) { - int log = 0; - - while (size >>= 1) - ++log; - - size = (2 << log); - } - - return size; -} - -const char *iPhone_getDocumentsDir() { - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); - NSString *documentsDirectory = [paths objectAtIndex:0]; - return [documentsDirectory UTF8String]; -} - -/** - * Converts portrait mode coordinates into rotated mode coordinates. - */ -static bool convertToRotatedCoords(UIDeviceOrientation orientation, CGPoint point, CGPoint *result) { - switch (orientation) { - case UIDeviceOrientationLandscapeLeft: - result->x = point.y; - result->y = _renderBufferWidth - point.x; - return true; - - case UIDeviceOrientationLandscapeRight: - result->x = _renderBufferHeight - point.y; - result->y = point.x; - return true; - - case UIDeviceOrientationPortrait: - result->x = point.x; - result->y = point.y; - return true; - - default: - return false; - } -} - -static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int *x, int *y) { - if (!convertToRotatedCoords(orientation, point, &point)) - return false; - - CGRect *area; - int width, height, offsetY; - if (_overlayIsEnabled) { - area = &_overlayRect; - width = _overlayWidth; - height = _overlayHeight; - offsetY = _shakeOffsetY; - } else { - area = &_gameScreenRect; - width = _width; - height = _height; - offsetY = _scaledShakeOffsetY; - } - - point.x = (point.x - CGRectGetMinX(*area)) / CGRectGetWidth(*area); - point.y = (point.y - CGRectGetMinY(*area)) / CGRectGetHeight(*area); - - *x = point.x * width; - // offsetY describes the translation of the screen in the upward direction, - // thus we need to add it here. - *y = point.y * height + offsetY; - - // Clip coordinates - if (*x < 0 || *x > CGRectGetWidth(*area) || *y < 0 || *y > CGRectGetHeight(*area)) - return false; - - return true; -} - -static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { - if (!tex) - return; - - glBindTexture(GL_TEXTURE_2D, tex); printOpenGLError(); - - GLint filter = GL_LINEAR; - - switch (mode) { - case kGraphicsModeLinear: - filter = GL_LINEAR; - break; - - case kGraphicsModeNone: - filter = GL_NEAREST; - break; - } - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); printOpenGLError(); -} - -@implementation iPhoneView - -+ (Class)layerClass { - return [CAEAGLLayer class]; -} - -- (void)createContext { - CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; - - eaglLayer.opaque = YES; - eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, nil]; - - _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; - - // In case creating the OpenGL ES context failed, we will error out here. - if (_context == nil) { - fprintf(stderr, "Could not create OpenGL ES context\n"); - exit(-1); - } - - if ([EAGLContext setCurrentContext:_context]) { - glGenFramebuffersOES(1, &_viewFramebuffer); printOpenGLError(); - glGenRenderbuffersOES(1, &_viewRenderbuffer); printOpenGLError(); - - glBindFramebufferOES(GL_FRAMEBUFFER_OES, _viewFramebuffer); printOpenGLError(); - glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); - [_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id)self.layer]; - - glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); - - // Retrieve the render buffer size. This *should* match the frame size, - // i.e. _fullWidth and _fullHeight. - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &_renderBufferWidth); printOpenGLError(); - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &_renderBufferHeight); printOpenGLError(); - - if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { - NSLog(@"Failed to make complete framebuffer object %x.", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); - return; - } - - _overlayHeight = _renderBufferWidth; - _overlayWidth = _renderBufferHeight; - _overlayTexWidth = getSizeNextPOT(_overlayHeight); - _overlayTexHeight = getSizeNextPOT(_overlayWidth); - - // Since the overlay size won't change the whole run, we can - // precalculate the texture coordinates for the overlay texture here - // and just use it later on. - _overlayTexCoords[2] = _overlayTexCoords[6] = _overlayWidth / (GLfloat)_overlayTexWidth; - _overlayTexCoords[5] = _overlayTexCoords[7] = _overlayHeight / (GLfloat)_overlayTexHeight; - - int textureSize = _overlayTexWidth * _overlayTexHeight * 2; - _overlayTexBuffer = (char *)malloc(textureSize); - memset(_overlayTexBuffer, 0, textureSize); - - glViewport(0, 0, _renderBufferWidth, _renderBufferHeight); printOpenGLError(); - glClearColor(0.0f, 0.0f, 0.0f, 1.0f); printOpenGLError(); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - glEnable(GL_TEXTURE_2D); printOpenGLError(); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); printOpenGLError(); - glEnableClientState(GL_VERTEX_ARRAY); printOpenGLError(); - } -} - -- (id)initWithFrame:(struct CGRect)frame { - self = [super initWithFrame: frame]; - - if ([[UIScreen mainScreen] respondsToSelector: NSSelectorFromString(@"scale")]) { - if ([self respondsToSelector: NSSelectorFromString(@"contentScaleFactor")]) { - //self.contentScaleFactor = [[UIScreen mainScreen] scale]; - } - } - - _fullWidth = frame.size.width; - _fullHeight = frame.size.height; - - sharedInstance = self; - - _keyboardView = nil; - _screenTexture = 0; - _overlayTexture = 0; - _mouseCursorTexture = 0; - - _gameScreenVertCoords[0] = _gameScreenVertCoords[1] = - _gameScreenVertCoords[2] = _gameScreenVertCoords[3] = - _gameScreenVertCoords[4] = _gameScreenVertCoords[5] = - _gameScreenVertCoords[6] = _gameScreenVertCoords[7] = 0; - - _gameScreenTexCoords[0] = _gameScreenTexCoords[1] = - _gameScreenTexCoords[2] = _gameScreenTexCoords[3] = - _gameScreenTexCoords[4] = _gameScreenTexCoords[5] = - _gameScreenTexCoords[6] = _gameScreenTexCoords[7] = 0; - - _overlayVertCoords[0] = _overlayVertCoords[1] = - _overlayVertCoords[2] = _overlayVertCoords[3] = - _overlayVertCoords[4] = _overlayVertCoords[5] = - _overlayVertCoords[6] = _overlayVertCoords[7] = 0; - - _overlayTexCoords[0] = _overlayTexCoords[1] = - _overlayTexCoords[2] = _overlayTexCoords[3] = - _overlayTexCoords[4] = _overlayTexCoords[5] = - _overlayTexCoords[6] = _overlayTexCoords[7] = 0; - - // Initialize the OpenGL ES context - [self createContext]; - - return self; -} - -- (void)dealloc { - [super dealloc]; - - if (_keyboardView != nil) { - [_keyboardView dealloc]; - } - - free(_gameScreenTextureBuffer); - free(_overlayTexBuffer); -} - -- (void *)getSurface { - return _screenSurface; -} - -- (void)drawRect:(CGRect)frame { -#if 0 - if (lastTick == 0) { - lastTick = time(0); - } - - frames++; - if (time(0) > lastTick) { - lastTick = time(0); - printf("FPS: %i\n", frames); - frames = 0; - } -#endif -} - -- (void)setGraphicsMode { - setFilterModeForTexture(_screenTexture, _graphicsMode); - setFilterModeForTexture(_overlayTexture, _graphicsMode); - setFilterModeForTexture(_mouseCursorTexture, _graphicsMode); -} - -- (void)updateSurface { - if (!_needsScreenUpdate) { - return; - } - _needsScreenUpdate = 0; - - glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); - - [self updateMainSurface]; - - if (_overlayIsEnabled) - [self updateOverlaySurface]; - - if (_mouseCursorEnabled) - [self updateMouseSurface]; - - glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); - [_context presentRenderbuffer:GL_RENDERBUFFER_OES]; - -} - -- (void)updateMouseCursor { - if (_mouseCursorTexture == 0) { - glGenTextures(1, &_mouseCursorTexture); printOpenGLError(); - setFilterModeForTexture(_mouseCursorTexture, _graphicsMode); - } - - glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getSizeNextPOT(_mouseCursorWidth), getSizeNextPOT(_mouseCursorHeight), 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _mouseCursor); printOpenGLError(); - - free(_mouseCursor); - _mouseCursor = NULL; -} - -- (void)updateMainSurface { - glVertexPointer(2, GL_FLOAT, 0, _gameScreenVertCoords); printOpenGLError(); - glTexCoordPointer(2, GL_FLOAT, 0, _gameScreenTexCoords); printOpenGLError(); - - glBindTexture(GL_TEXTURE_2D, _screenTexture); printOpenGLError(); - - // Unfortunately we have to update the whole texture every frame, since glTexSubImage2D is actually slower in all cases - // due to the iPhone internals having to convert the whole texture back from its internal format when used. - // In the future we could use several tiled textures instead. - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _gameScreenTextureWidth, _gameScreenTextureHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _gameScreenTextureBuffer); printOpenGLError(); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); -} - -- (void)updateOverlaySurface { - glVertexPointer(2, GL_FLOAT, 0, _overlayVertCoords); printOpenGLError(); - glTexCoordPointer(2, GL_FLOAT, 0, _overlayTexCoords); printOpenGLError(); - - glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError(); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _overlayTexWidth, _overlayTexHeight, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _overlayTexBuffer); printOpenGLError(); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); -} - -- (void)updateMouseSurface { - int width = _mouseCursorWidth; - int height = _mouseCursorHeight; - - int mouseX = _mouseX; - int mouseY = _mouseY; - - int hotspotX = _mouseCursorHotspotX; - int hotspotY = _mouseCursorHotspotY; - - CGRect *rect; - int maxWidth, maxHeight; - - if (!_overlayIsEnabled) { - rect = &_gameScreenRect; - maxWidth = _width; - maxHeight = _height; - } else { - rect = &_overlayRect; - maxWidth = _overlayWidth; - maxHeight = _overlayHeight; - } - - const GLfloat scaleX = CGRectGetWidth(*rect) / (GLfloat)maxWidth; - const GLfloat scaleY = CGRectGetHeight(*rect) / (GLfloat)maxHeight; - - mouseX = mouseX * scaleX; - mouseY = mouseY * scaleY; - hotspotX = hotspotX * scaleX; - hotspotY = hotspotY * scaleY; - width = width * scaleX; - height = height * scaleY; - - mouseX -= hotspotX; - mouseY -= hotspotY; - - mouseX += CGRectGetMinX(*rect); - mouseY += CGRectGetMinY(*rect); - - GLfloat vertices[] = { - // Top left - mouseX , mouseY, - // Top right - mouseX + width, mouseY, - // Bottom left - mouseX , mouseY + height, - // Bottom right - mouseX + width, mouseY + height - }; - - //printf("Cursor: width %u height %u\n", _mouseCursorWidth, _mouseCursorHeight); - - float texWidth = _mouseCursorWidth / (float)getSizeNextPOT(_mouseCursorWidth); - float texHeight = _mouseCursorHeight / (float)getSizeNextPOT(_mouseCursorHeight); - - const GLfloat texCoords[] = { - // Top left - 0 , 0, - // Top right - texWidth, 0, - // Bottom left - 0 , texHeight, - // Bottom right - texWidth, texHeight - }; - - glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError(); - glTexCoordPointer(2, GL_FLOAT, 0, texCoords); printOpenGLError(); - - glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); -} - -- (void)initSurface { - _gameScreenTextureWidth = getSizeNextPOT(_width); - _gameScreenTextureHeight = getSizeNextPOT(_height); - - _gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _width / (GLfloat)_gameScreenTextureWidth; - _gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _height / (GLfloat)_gameScreenTextureHeight; - - _orientation = [[UIDevice currentDevice] orientation]; - - switch (_orientation) { - case UIDeviceOrientationLandscapeLeft: - case UIDeviceOrientationLandscapeRight: - case UIDeviceOrientationPortrait: - break; - - default: - _orientation = UIDeviceOrientationPortrait; - } - - //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _width, _height, _gameScreenTextureWidth, _gameScreenTextureHeight); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - int screenWidth, screenHeight; - - // Set the origin (0,0) depending on the rotation mode. - if (_orientation == UIDeviceOrientationLandscapeRight) { - glRotatef( 90, 0, 0, 1); printOpenGLError(); - glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); - - screenWidth = _renderBufferHeight; - screenHeight = _renderBufferWidth; - } else if (_orientation == UIDeviceOrientationLandscapeLeft) { - glRotatef(-90, 0, 0, 1); printOpenGLError(); - glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); - - screenWidth = _renderBufferHeight; - screenHeight = _renderBufferWidth; - } else if (_orientation == UIDeviceOrientationPortrait) { - glOrthof(0, _renderBufferWidth, _renderBufferHeight, 0, 0, 1); printOpenGLError(); - - screenWidth = _renderBufferWidth; - screenHeight = _renderBufferHeight; - } - - if (_screenTexture > 0) { - glDeleteTextures(1, &_screenTexture); printOpenGLError(); - } - - glGenTextures(1, &_screenTexture); printOpenGLError(); - setFilterModeForTexture(_screenTexture, _graphicsMode); - - if (_overlayTexture > 0) { - glDeleteTextures(1, &_overlayTexture); printOpenGLError(); - } - - glGenTextures(1, &_overlayTexture); printOpenGLError(); - setFilterModeForTexture(_overlayTexture, _graphicsMode); - - free(_gameScreenTextureBuffer); - int textureSize = _gameScreenTextureWidth * _gameScreenTextureHeight * 2; - _gameScreenTextureBuffer = (char *)malloc(textureSize); - memset(_gameScreenTextureBuffer, 0, textureSize); - - glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); - - [self clearColorBuffer]; - - if (_keyboardView != nil) { - [_keyboardView removeFromSuperview]; - [[_keyboardView inputView] removeFromSuperview]; - } - - float overlayPortraitRatio; - - if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation == UIDeviceOrientationLandscapeRight) { - GLfloat gameScreenRatio = (GLfloat)_width / (GLfloat)_height; - GLfloat screenRatio = (GLfloat)screenWidth / (GLfloat)screenHeight; - - // These are the width/height according to the portrait layout! - int rectWidth, rectHeight; - int xOffset, yOffset; - - if (gameScreenRatio < screenRatio) { - // When the game screen ratio is less than the screen ratio - // we need to scale the width, since the game screen was higher - // compared to the width than our output screen is. - rectWidth = screenHeight * gameScreenRatio; - rectHeight = screenHeight; - xOffset = (screenWidth - rectWidth) / 2; - yOffset = 0; - } else { - // When the game screen ratio is bigger than the screen ratio - // we need to scale the height, since the game screen was wider - // compared to the height than our output screen is. - rectWidth = screenWidth; - rectHeight = screenWidth / gameScreenRatio; - xOffset = 0; - yOffset = (screenHeight - rectHeight) / 2; - } - - //printf("Rect: %i, %i, %i, %i\n", xOffset, yOffset, rectWidth, rectHeight); - _gameScreenRect = CGRectMake(xOffset, yOffset, rectWidth, rectHeight); - overlayPortraitRatio = 1.0f; - } else { - float ratio = (float)_height / (float)_width; - int height = screenWidth * ratio; - //printf("Making rect (%u, %u)\n", screenWidth, height); - _gameScreenRect = CGRectMake(0, 0, screenWidth, height); - - CGRect keyFrame = CGRectMake(0.0f, 0.0f, 0.0f, 0.0f); - if (_keyboardView == nil) { - _keyboardView = [[SoftKeyboard alloc] initWithFrame:keyFrame]; - [_keyboardView setInputDelegate:self]; - } - - [self addSubview:[_keyboardView inputView]]; - [self addSubview: _keyboardView]; - [[_keyboardView inputView] becomeFirstResponder]; - overlayPortraitRatio = (_overlayHeight * ratio) / _overlayWidth; - } - - _overlayRect = CGRectMake(0, 0, screenWidth, screenHeight * overlayPortraitRatio); - - _gameScreenVertCoords[0] = _gameScreenVertCoords[4] = CGRectGetMinX(_gameScreenRect); - _gameScreenVertCoords[1] = _gameScreenVertCoords[3] = CGRectGetMinY(_gameScreenRect); - _gameScreenVertCoords[2] = _gameScreenVertCoords[6] = CGRectGetMaxX(_gameScreenRect); - _gameScreenVertCoords[5] = _gameScreenVertCoords[7] = CGRectGetMaxY(_gameScreenRect); - - _overlayVertCoords[2] = _overlayVertCoords[6] = CGRectGetMaxX(_overlayRect); - _overlayVertCoords[5] = _overlayVertCoords[7] = CGRectGetMaxY(_overlayRect); - - [self setViewTransformation]; -} - -- (void)setViewTransformation { - // Set the modelview matrix. This matrix will be used for the shake offset - // support. - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - - // Scale the shake offset according to the overlay size. We need this to - // adjust the overlay mouse click coordinates when an offset is set. - _scaledShakeOffsetY = _shakeOffsetY / (GLfloat)_height * CGRectGetHeight(_overlayRect); - - // Apply the shakeing to the output screen. - glTranslatef(0, -_scaledShakeOffsetY, 0); -} - -- (void)clearColorBuffer { - // The color buffer is triple-buffered, so we clear it multiple times right away to avid doing any glClears later. - int clearCount = 5; - while (clearCount-- > 0) { - glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); - [_context presentRenderbuffer:GL_RENDERBUFFER_OES]; - } -} - -- (id)getEvent { - if (_events == nil || [_events count] == 0) { - return nil; - } - - id event = [_events objectAtIndex: 0]; - - [_events removeObjectAtIndex: 0]; - - return event; -} - -- (void)addEvent:(NSDictionary *)event { - if (_events == nil) - _events = [[NSMutableArray alloc] init]; - - [_events addObject: event]; -} - -- (void)deviceOrientationChanged:(UIDeviceOrientation)orientation { - switch (orientation) { - case UIDeviceOrientationLandscapeLeft: - case UIDeviceOrientationLandscapeRight: - case UIDeviceOrientationPortrait: - _orientation = orientation; - break; - - default: - return; - } - - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputOrientationChanged], @"type", - [NSNumber numberWithInt:orientation], @"x", - [NSNumber numberWithInt:0], @"y", - nil - ] - ]; -} - -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { - NSSet *allTouches = [event allTouches]; - int x, y; - - switch ([allTouches count]) { - case 1: { - UITouch *touch = [touches anyObject]; - CGPoint point = [touch locationInView:self]; - if (!getMouseCoords(_orientation, point, &x, &y)) - return; - - _firstTouch = touch; - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseDown], @"type", - [NSNumber numberWithInt:x], @"x", - [NSNumber numberWithInt:y], @"y", - nil - ] - ]; - break; - } - - case 2: { - UITouch *touch = [touches anyObject]; - CGPoint point = [touch locationInView:self]; - if (!getMouseCoords(_orientation, point, &x, &y)) - return; - - _secondTouch = touch; - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseSecondDown], @"type", - [NSNumber numberWithInt:x], @"x", - [NSNumber numberWithInt:y], @"y", - nil - ] - ]; - break; - } - } -} - -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - //NSSet *allTouches = [event allTouches]; - int x, y; - - for (UITouch *touch in touches) { - if (touch == _firstTouch) { - CGPoint point = [touch locationInView:self]; - if (!getMouseCoords(_orientation, point, &x, &y)) - return; - - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseDragged], @"type", - [NSNumber numberWithInt:x], @"x", - [NSNumber numberWithInt:y], @"y", - nil - ] - ]; - } else if (touch == _secondTouch) { - CGPoint point = [touch locationInView:self]; - if (!getMouseCoords(_orientation, point, &x, &y)) - return; - - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseSecondDragged], @"type", - [NSNumber numberWithInt:x], @"x", - [NSNumber numberWithInt:y], @"y", - nil - ] - ]; - } - } -} - -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - NSSet *allTouches = [event allTouches]; - int x, y; - - switch ([allTouches count]) { - case 1: { - UITouch *touch = [[allTouches allObjects] objectAtIndex:0]; - CGPoint point = [touch locationInView:self]; - if (!getMouseCoords(_orientation, point, &x, &y)) - return; - - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseUp], @"type", - [NSNumber numberWithInt:x], @"x", - [NSNumber numberWithInt:y], @"y", - nil - ] - ]; - break; - } - - case 2: { - UITouch *touch = [[allTouches allObjects] objectAtIndex:1]; - CGPoint point = [touch locationInView:self]; - if (!getMouseCoords(_orientation, point, &x, &y)) - return; - - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputMouseSecondUp], @"type", - [NSNumber numberWithInt:x], @"x", - [NSNumber numberWithInt:y], @"y", - nil - ] - ]; - break; - } - } -} - -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { -} - -- (void)handleKeyPress:(unichar)c { - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputKeyPressed], @"type", - [NSNumber numberWithInt:c], @"x", - [NSNumber numberWithInt:0], @"y", - nil - ] - ]; -} - -- (BOOL)canHandleSwipes { - return TRUE; -} - -- (int)swipe:(int)num withEvent:(struct __GSEvent *)event { - //printf("swipe: %i\n", num); - - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputSwipe], @"type", - [NSNumber numberWithInt:num], @"x", - [NSNumber numberWithInt:0], @"y", - nil - ] - ]; -} - -- (void)applicationSuspend { - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputApplicationSuspended], @"type", - [NSNumber numberWithInt:0], @"x", - [NSNumber numberWithInt:0], @"y", - nil - ] - ]; -} - -- (void)applicationResume { - [self addEvent: - [[NSDictionary alloc] initWithObjectsAndKeys: - [NSNumber numberWithInt:kInputApplicationResumed], @"type", - [NSNumber numberWithInt:0], @"x", - [NSNumber numberWithInt:0], @"y", - nil - ] - ]; -} - -@end diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm new file mode 100644 index 0000000000..2dcca3592c --- /dev/null +++ b/backends/platform/iphone/iphone_video.mm @@ -0,0 +1,931 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +#include "iphone_video.h" +#include "iphone_common.h" + +static iPhoneView *sharedInstance = nil; +static GraphicsModes _graphicsMode = kGraphicsModeLinear; +static int _width = 0; +static int _height = 0; +static int _fullWidth; +static int _fullHeight; +static CGRect _gameScreenRect; + +static char *_gameScreenTextureBuffer = 0; +static int _gameScreenTextureWidth = 0; +static int _gameScreenTextureHeight = 0; + +static char *_overlayTexBuffer = 0; +static int _overlayTexWidth = 0; +static int _overlayTexHeight = 0; +static int _overlayWidth = 0; +static int _overlayHeight = 0; +static CGRect _overlayRect; + +static int _needsScreenUpdate = 0; +static int _overlayIsEnabled = 0; + +static UITouch *_firstTouch = NULL; +static UITouch *_secondTouch = NULL; + +static unsigned short *_mouseCursor = NULL; +static int _mouseCursorHeight = 0; +static int _mouseCursorWidth = 0; +static int _mouseCursorHotspotX = 0; +static int _mouseCursorHotspotY = 0; +static int _mouseX = 0; +static int _mouseY = 0; +static int _mouseCursorEnabled = 0; + +static GLint _renderBufferWidth; +static GLint _renderBufferHeight; + +static int _shakeOffsetY; +static int _scaledShakeOffsetY; + +#if 0 +static long lastTick = 0; +static int frames = 0; +#endif + +#define printOpenGLError() printOglError(__FILE__, __LINE__) + +int printOglError(const char *file, int line) { + int retCode = 0; + + // returns 1 if an OpenGL error occurred, 0 otherwise. + GLenum glErr = glGetError(); + while (glErr != GL_NO_ERROR) { + fprintf(stderr, "glError: %u (%s: %d)\n", glErr, file, line); + retCode = 1; + glErr = glGetError(); + } + return retCode; +} + +void iPhone_setGraphicsMode(GraphicsModes mode) { + _graphicsMode = mode; + + [sharedInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES]; +} + +void iPhone_showCursor(int state) { + _mouseCursorEnabled = state; +} + +void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int hotspotX, int hotspotY) { + _mouseCursor = buffer; + + _mouseCursorWidth = width; + _mouseCursorHeight = height; + + _mouseCursorHotspotX = hotspotX; + _mouseCursorHotspotY = hotspotY; + + [sharedInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; +} + +void iPhone_enableOverlay(int state) { + _overlayIsEnabled = state; + + [sharedInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; +} + +int iPhone_getScreenHeight() { + return _overlayHeight; +} + +int iPhone_getScreenWidth() { + return _overlayWidth; +} + +bool iPhone_isHighResDevice() { + return _fullHeight > 480; +} + +void iPhone_updateScreen(int mouseX, int mouseY) { + //printf("Mouse: (%i, %i)\n", mouseX, mouseY); + + _mouseX = mouseX; + _mouseY = mouseY; + + if (!_needsScreenUpdate) { + _needsScreenUpdate = 1; + [sharedInstance performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO]; + } +} + +void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2) { + int y; + for (y = y1; y < y2; ++y) + memcpy(&_gameScreenTextureBuffer[(y * _gameScreenTextureWidth + x1) * 2], &screen[y * _width + x1], (x2 - x1) * 2); +} + +void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2) { + int y; + //printf("Overlaywidth: %u, fullwidth %u\n", _overlayWidth, _fullWidth); + for (y = y1; y < y2; ++y) + memcpy(&_overlayTexBuffer[(y * _overlayTexWidth + x1) * 2], &screen[y * _overlayWidth + x1], (x2 - x1) * 2); +} + +void iPhone_initSurface(int width, int height) { + _width = width; + _height = height; + _shakeOffsetY = 0; + [sharedInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES]; +} + +void iPhone_setShakeOffset(int offset) { + _shakeOffsetY = offset; + [sharedInstance performSelectorOnMainThread:@selector(setViewTransformation) withObject:nil waitUntilDone: YES]; +} + +bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY) { + id event = [sharedInstance getEvent]; + if (event == nil) { + return false; + } + + id type = [event objectForKey:@"type"]; + + if (type == nil) { + printf("fetchEvent says: No type!\n"); + return false; + } + + *outEvent = [type intValue]; + *outX = [[event objectForKey:@"x"] intValue]; + *outY = [[event objectForKey:@"y"] intValue]; + return true; +} + +uint getSizeNextPOT(uint size) { + if ((size & (size - 1)) || !size) { + int log = 0; + + while (size >>= 1) + ++log; + + size = (2 << log); + } + + return size; +} + +const char *iPhone_getDocumentsDir() { + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentsDirectory = [paths objectAtIndex:0]; + return [documentsDirectory UTF8String]; +} + +/** + * Converts portrait mode coordinates into rotated mode coordinates. + */ +static bool convertToRotatedCoords(UIDeviceOrientation orientation, CGPoint point, CGPoint *result) { + switch (orientation) { + case UIDeviceOrientationLandscapeLeft: + result->x = point.y; + result->y = _renderBufferWidth - point.x; + return true; + + case UIDeviceOrientationLandscapeRight: + result->x = _renderBufferHeight - point.y; + result->y = point.x; + return true; + + case UIDeviceOrientationPortrait: + result->x = point.x; + result->y = point.y; + return true; + + default: + return false; + } +} + +static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int *x, int *y) { + if (!convertToRotatedCoords(orientation, point, &point)) + return false; + + CGRect *area; + int width, height, offsetY; + if (_overlayIsEnabled) { + area = &_overlayRect; + width = _overlayWidth; + height = _overlayHeight; + offsetY = _shakeOffsetY; + } else { + area = &_gameScreenRect; + width = _width; + height = _height; + offsetY = _scaledShakeOffsetY; + } + + point.x = (point.x - CGRectGetMinX(*area)) / CGRectGetWidth(*area); + point.y = (point.y - CGRectGetMinY(*area)) / CGRectGetHeight(*area); + + *x = point.x * width; + // offsetY describes the translation of the screen in the upward direction, + // thus we need to add it here. + *y = point.y * height + offsetY; + + // Clip coordinates + if (*x < 0 || *x > CGRectGetWidth(*area) || *y < 0 || *y > CGRectGetHeight(*area)) + return false; + + return true; +} + +static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { + if (!tex) + return; + + glBindTexture(GL_TEXTURE_2D, tex); printOpenGLError(); + + GLint filter = GL_LINEAR; + + switch (mode) { + case kGraphicsModeLinear: + filter = GL_LINEAR; + break; + + case kGraphicsModeNone: + filter = GL_NEAREST; + break; + } + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); printOpenGLError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); printOpenGLError(); +} + +@implementation iPhoneView + ++ (Class)layerClass { + return [CAEAGLLayer class]; +} + +- (void)createContext { + CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; + + eaglLayer.opaque = YES; + eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGB565, kEAGLDrawablePropertyColorFormat, nil]; + + _context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1]; + + // In case creating the OpenGL ES context failed, we will error out here. + if (_context == nil) { + fprintf(stderr, "Could not create OpenGL ES context\n"); + exit(-1); + } + + if ([EAGLContext setCurrentContext:_context]) { + glGenFramebuffersOES(1, &_viewFramebuffer); printOpenGLError(); + glGenRenderbuffersOES(1, &_viewRenderbuffer); printOpenGLError(); + + glBindFramebufferOES(GL_FRAMEBUFFER_OES, _viewFramebuffer); printOpenGLError(); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); + [_context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(id)self.layer]; + + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); + + // Retrieve the render buffer size. This *should* match the frame size, + // i.e. _fullWidth and _fullHeight. + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &_renderBufferWidth); printOpenGLError(); + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &_renderBufferHeight); printOpenGLError(); + + if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { + NSLog(@"Failed to make complete framebuffer object %x.", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); + return; + } + + _overlayHeight = _renderBufferWidth; + _overlayWidth = _renderBufferHeight; + _overlayTexWidth = getSizeNextPOT(_overlayHeight); + _overlayTexHeight = getSizeNextPOT(_overlayWidth); + + // Since the overlay size won't change the whole run, we can + // precalculate the texture coordinates for the overlay texture here + // and just use it later on. + _overlayTexCoords[2] = _overlayTexCoords[6] = _overlayWidth / (GLfloat)_overlayTexWidth; + _overlayTexCoords[5] = _overlayTexCoords[7] = _overlayHeight / (GLfloat)_overlayTexHeight; + + int textureSize = _overlayTexWidth * _overlayTexHeight * 2; + _overlayTexBuffer = (char *)malloc(textureSize); + memset(_overlayTexBuffer, 0, textureSize); + + glViewport(0, 0, _renderBufferWidth, _renderBufferHeight); printOpenGLError(); + glClearColor(0.0f, 0.0f, 0.0f, 1.0f); printOpenGLError(); + + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glEnable(GL_TEXTURE_2D); printOpenGLError(); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); printOpenGLError(); + glEnableClientState(GL_VERTEX_ARRAY); printOpenGLError(); + } +} + +- (id)initWithFrame:(struct CGRect)frame { + self = [super initWithFrame: frame]; + + if ([[UIScreen mainScreen] respondsToSelector: NSSelectorFromString(@"scale")]) { + if ([self respondsToSelector: NSSelectorFromString(@"contentScaleFactor")]) { + //self.contentScaleFactor = [[UIScreen mainScreen] scale]; + } + } + + _fullWidth = frame.size.width; + _fullHeight = frame.size.height; + + sharedInstance = self; + + _keyboardView = nil; + _screenTexture = 0; + _overlayTexture = 0; + _mouseCursorTexture = 0; + + _gameScreenVertCoords[0] = _gameScreenVertCoords[1] = + _gameScreenVertCoords[2] = _gameScreenVertCoords[3] = + _gameScreenVertCoords[4] = _gameScreenVertCoords[5] = + _gameScreenVertCoords[6] = _gameScreenVertCoords[7] = 0; + + _gameScreenTexCoords[0] = _gameScreenTexCoords[1] = + _gameScreenTexCoords[2] = _gameScreenTexCoords[3] = + _gameScreenTexCoords[4] = _gameScreenTexCoords[5] = + _gameScreenTexCoords[6] = _gameScreenTexCoords[7] = 0; + + _overlayVertCoords[0] = _overlayVertCoords[1] = + _overlayVertCoords[2] = _overlayVertCoords[3] = + _overlayVertCoords[4] = _overlayVertCoords[5] = + _overlayVertCoords[6] = _overlayVertCoords[7] = 0; + + _overlayTexCoords[0] = _overlayTexCoords[1] = + _overlayTexCoords[2] = _overlayTexCoords[3] = + _overlayTexCoords[4] = _overlayTexCoords[5] = + _overlayTexCoords[6] = _overlayTexCoords[7] = 0; + + // Initialize the OpenGL ES context + [self createContext]; + + return self; +} + +- (void)dealloc { + [super dealloc]; + + if (_keyboardView != nil) { + [_keyboardView dealloc]; + } + + free(_gameScreenTextureBuffer); + free(_overlayTexBuffer); +} + +- (void *)getSurface { + return _screenSurface; +} + +- (void)drawRect:(CGRect)frame { +#if 0 + if (lastTick == 0) { + lastTick = time(0); + } + + frames++; + if (time(0) > lastTick) { + lastTick = time(0); + printf("FPS: %i\n", frames); + frames = 0; + } +#endif +} + +- (void)setGraphicsMode { + setFilterModeForTexture(_screenTexture, _graphicsMode); + setFilterModeForTexture(_overlayTexture, _graphicsMode); + setFilterModeForTexture(_mouseCursorTexture, _graphicsMode); +} + +- (void)updateSurface { + if (!_needsScreenUpdate) { + return; + } + _needsScreenUpdate = 0; + + glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); + + [self updateMainSurface]; + + if (_overlayIsEnabled) + [self updateOverlaySurface]; + + if (_mouseCursorEnabled) + [self updateMouseSurface]; + + glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); + [_context presentRenderbuffer:GL_RENDERBUFFER_OES]; + +} + +- (void)updateMouseCursor { + if (_mouseCursorTexture == 0) { + glGenTextures(1, &_mouseCursorTexture); printOpenGLError(); + setFilterModeForTexture(_mouseCursorTexture, _graphicsMode); + } + + glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getSizeNextPOT(_mouseCursorWidth), getSizeNextPOT(_mouseCursorHeight), 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _mouseCursor); printOpenGLError(); + + free(_mouseCursor); + _mouseCursor = NULL; +} + +- (void)updateMainSurface { + glVertexPointer(2, GL_FLOAT, 0, _gameScreenVertCoords); printOpenGLError(); + glTexCoordPointer(2, GL_FLOAT, 0, _gameScreenTexCoords); printOpenGLError(); + + glBindTexture(GL_TEXTURE_2D, _screenTexture); printOpenGLError(); + + // Unfortunately we have to update the whole texture every frame, since glTexSubImage2D is actually slower in all cases + // due to the iPhone internals having to convert the whole texture back from its internal format when used. + // In the future we could use several tiled textures instead. + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _gameScreenTextureWidth, _gameScreenTextureHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _gameScreenTextureBuffer); printOpenGLError(); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); +} + +- (void)updateOverlaySurface { + glVertexPointer(2, GL_FLOAT, 0, _overlayVertCoords); printOpenGLError(); + glTexCoordPointer(2, GL_FLOAT, 0, _overlayTexCoords); printOpenGLError(); + + glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError(); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _overlayTexWidth, _overlayTexHeight, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _overlayTexBuffer); printOpenGLError(); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); +} + +- (void)updateMouseSurface { + int width = _mouseCursorWidth; + int height = _mouseCursorHeight; + + int mouseX = _mouseX; + int mouseY = _mouseY; + + int hotspotX = _mouseCursorHotspotX; + int hotspotY = _mouseCursorHotspotY; + + CGRect *rect; + int maxWidth, maxHeight; + + if (!_overlayIsEnabled) { + rect = &_gameScreenRect; + maxWidth = _width; + maxHeight = _height; + } else { + rect = &_overlayRect; + maxWidth = _overlayWidth; + maxHeight = _overlayHeight; + } + + const GLfloat scaleX = CGRectGetWidth(*rect) / (GLfloat)maxWidth; + const GLfloat scaleY = CGRectGetHeight(*rect) / (GLfloat)maxHeight; + + mouseX = mouseX * scaleX; + mouseY = mouseY * scaleY; + hotspotX = hotspotX * scaleX; + hotspotY = hotspotY * scaleY; + width = width * scaleX; + height = height * scaleY; + + mouseX -= hotspotX; + mouseY -= hotspotY; + + mouseX += CGRectGetMinX(*rect); + mouseY += CGRectGetMinY(*rect); + + GLfloat vertices[] = { + // Top left + mouseX , mouseY, + // Top right + mouseX + width, mouseY, + // Bottom left + mouseX , mouseY + height, + // Bottom right + mouseX + width, mouseY + height + }; + + //printf("Cursor: width %u height %u\n", _mouseCursorWidth, _mouseCursorHeight); + + float texWidth = _mouseCursorWidth / (float)getSizeNextPOT(_mouseCursorWidth); + float texHeight = _mouseCursorHeight / (float)getSizeNextPOT(_mouseCursorHeight); + + const GLfloat texCoords[] = { + // Top left + 0 , 0, + // Top right + texWidth, 0, + // Bottom left + 0 , texHeight, + // Bottom right + texWidth, texHeight + }; + + glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError(); + glTexCoordPointer(2, GL_FLOAT, 0, texCoords); printOpenGLError(); + + glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); +} + +- (void)initSurface { + _gameScreenTextureWidth = getSizeNextPOT(_width); + _gameScreenTextureHeight = getSizeNextPOT(_height); + + _gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _width / (GLfloat)_gameScreenTextureWidth; + _gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _height / (GLfloat)_gameScreenTextureHeight; + + _orientation = [[UIDevice currentDevice] orientation]; + + switch (_orientation) { + case UIDeviceOrientationLandscapeLeft: + case UIDeviceOrientationLandscapeRight: + case UIDeviceOrientationPortrait: + break; + + default: + _orientation = UIDeviceOrientationPortrait; + } + + //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _width, _height, _gameScreenTextureWidth, _gameScreenTextureHeight); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + int screenWidth, screenHeight; + + // Set the origin (0,0) depending on the rotation mode. + if (_orientation == UIDeviceOrientationLandscapeRight) { + glRotatef( 90, 0, 0, 1); printOpenGLError(); + glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); + + screenWidth = _renderBufferHeight; + screenHeight = _renderBufferWidth; + } else if (_orientation == UIDeviceOrientationLandscapeLeft) { + glRotatef(-90, 0, 0, 1); printOpenGLError(); + glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); + + screenWidth = _renderBufferHeight; + screenHeight = _renderBufferWidth; + } else if (_orientation == UIDeviceOrientationPortrait) { + glOrthof(0, _renderBufferWidth, _renderBufferHeight, 0, 0, 1); printOpenGLError(); + + screenWidth = _renderBufferWidth; + screenHeight = _renderBufferHeight; + } + + if (_screenTexture > 0) { + glDeleteTextures(1, &_screenTexture); printOpenGLError(); + } + + glGenTextures(1, &_screenTexture); printOpenGLError(); + setFilterModeForTexture(_screenTexture, _graphicsMode); + + if (_overlayTexture > 0) { + glDeleteTextures(1, &_overlayTexture); printOpenGLError(); + } + + glGenTextures(1, &_overlayTexture); printOpenGLError(); + setFilterModeForTexture(_overlayTexture, _graphicsMode); + + free(_gameScreenTextureBuffer); + int textureSize = _gameScreenTextureWidth * _gameScreenTextureHeight * 2; + _gameScreenTextureBuffer = (char *)malloc(textureSize); + memset(_gameScreenTextureBuffer, 0, textureSize); + + glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); + + [self clearColorBuffer]; + + if (_keyboardView != nil) { + [_keyboardView removeFromSuperview]; + [[_keyboardView inputView] removeFromSuperview]; + } + + float overlayPortraitRatio; + + if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation == UIDeviceOrientationLandscapeRight) { + GLfloat gameScreenRatio = (GLfloat)_width / (GLfloat)_height; + GLfloat screenRatio = (GLfloat)screenWidth / (GLfloat)screenHeight; + + // These are the width/height according to the portrait layout! + int rectWidth, rectHeight; + int xOffset, yOffset; + + if (gameScreenRatio < screenRatio) { + // When the game screen ratio is less than the screen ratio + // we need to scale the width, since the game screen was higher + // compared to the width than our output screen is. + rectWidth = screenHeight * gameScreenRatio; + rectHeight = screenHeight; + xOffset = (screenWidth - rectWidth) / 2; + yOffset = 0; + } else { + // When the game screen ratio is bigger than the screen ratio + // we need to scale the height, since the game screen was wider + // compared to the height than our output screen is. + rectWidth = screenWidth; + rectHeight = screenWidth / gameScreenRatio; + xOffset = 0; + yOffset = (screenHeight - rectHeight) / 2; + } + + //printf("Rect: %i, %i, %i, %i\n", xOffset, yOffset, rectWidth, rectHeight); + _gameScreenRect = CGRectMake(xOffset, yOffset, rectWidth, rectHeight); + overlayPortraitRatio = 1.0f; + } else { + float ratio = (float)_height / (float)_width; + int height = screenWidth * ratio; + //printf("Making rect (%u, %u)\n", screenWidth, height); + _gameScreenRect = CGRectMake(0, 0, screenWidth, height); + + CGRect keyFrame = CGRectMake(0.0f, 0.0f, 0.0f, 0.0f); + if (_keyboardView == nil) { + _keyboardView = [[SoftKeyboard alloc] initWithFrame:keyFrame]; + [_keyboardView setInputDelegate:self]; + } + + [self addSubview:[_keyboardView inputView]]; + [self addSubview: _keyboardView]; + [[_keyboardView inputView] becomeFirstResponder]; + overlayPortraitRatio = (_overlayHeight * ratio) / _overlayWidth; + } + + _overlayRect = CGRectMake(0, 0, screenWidth, screenHeight * overlayPortraitRatio); + + _gameScreenVertCoords[0] = _gameScreenVertCoords[4] = CGRectGetMinX(_gameScreenRect); + _gameScreenVertCoords[1] = _gameScreenVertCoords[3] = CGRectGetMinY(_gameScreenRect); + _gameScreenVertCoords[2] = _gameScreenVertCoords[6] = CGRectGetMaxX(_gameScreenRect); + _gameScreenVertCoords[5] = _gameScreenVertCoords[7] = CGRectGetMaxY(_gameScreenRect); + + _overlayVertCoords[2] = _overlayVertCoords[6] = CGRectGetMaxX(_overlayRect); + _overlayVertCoords[5] = _overlayVertCoords[7] = CGRectGetMaxY(_overlayRect); + + [self setViewTransformation]; +} + +- (void)setViewTransformation { + // Set the modelview matrix. This matrix will be used for the shake offset + // support. + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + // Scale the shake offset according to the overlay size. We need this to + // adjust the overlay mouse click coordinates when an offset is set. + _scaledShakeOffsetY = _shakeOffsetY / (GLfloat)_height * CGRectGetHeight(_overlayRect); + + // Apply the shakeing to the output screen. + glTranslatef(0, -_scaledShakeOffsetY, 0); +} + +- (void)clearColorBuffer { + // The color buffer is triple-buffered, so we clear it multiple times right away to avid doing any glClears later. + int clearCount = 5; + while (clearCount-- > 0) { + glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); + [_context presentRenderbuffer:GL_RENDERBUFFER_OES]; + } +} + +- (id)getEvent { + if (_events == nil || [_events count] == 0) { + return nil; + } + + id event = [_events objectAtIndex: 0]; + + [_events removeObjectAtIndex: 0]; + + return event; +} + +- (void)addEvent:(NSDictionary *)event { + if (_events == nil) + _events = [[NSMutableArray alloc] init]; + + [_events addObject: event]; +} + +- (void)deviceOrientationChanged:(UIDeviceOrientation)orientation { + switch (orientation) { + case UIDeviceOrientationLandscapeLeft: + case UIDeviceOrientationLandscapeRight: + case UIDeviceOrientationPortrait: + _orientation = orientation; + break; + + default: + return; + } + + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputOrientationChanged], @"type", + [NSNumber numberWithInt:orientation], @"x", + [NSNumber numberWithInt:0], @"y", + nil + ] + ]; +} + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { + NSSet *allTouches = [event allTouches]; + int x, y; + + switch ([allTouches count]) { + case 1: { + UITouch *touch = [touches anyObject]; + CGPoint point = [touch locationInView:self]; + if (!getMouseCoords(_orientation, point, &x, &y)) + return; + + _firstTouch = touch; + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseDown], @"type", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", + nil + ] + ]; + break; + } + + case 2: { + UITouch *touch = [touches anyObject]; + CGPoint point = [touch locationInView:self]; + if (!getMouseCoords(_orientation, point, &x, &y)) + return; + + _secondTouch = touch; + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseSecondDown], @"type", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", + nil + ] + ]; + break; + } + } +} + +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { + //NSSet *allTouches = [event allTouches]; + int x, y; + + for (UITouch *touch in touches) { + if (touch == _firstTouch) { + CGPoint point = [touch locationInView:self]; + if (!getMouseCoords(_orientation, point, &x, &y)) + return; + + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseDragged], @"type", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", + nil + ] + ]; + } else if (touch == _secondTouch) { + CGPoint point = [touch locationInView:self]; + if (!getMouseCoords(_orientation, point, &x, &y)) + return; + + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseSecondDragged], @"type", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", + nil + ] + ]; + } + } +} + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { + NSSet *allTouches = [event allTouches]; + int x, y; + + switch ([allTouches count]) { + case 1: { + UITouch *touch = [[allTouches allObjects] objectAtIndex:0]; + CGPoint point = [touch locationInView:self]; + if (!getMouseCoords(_orientation, point, &x, &y)) + return; + + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseUp], @"type", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", + nil + ] + ]; + break; + } + + case 2: { + UITouch *touch = [[allTouches allObjects] objectAtIndex:1]; + CGPoint point = [touch locationInView:self]; + if (!getMouseCoords(_orientation, point, &x, &y)) + return; + + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputMouseSecondUp], @"type", + [NSNumber numberWithInt:x], @"x", + [NSNumber numberWithInt:y], @"y", + nil + ] + ]; + break; + } + } +} + +- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { +} + +- (void)handleKeyPress:(unichar)c { + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputKeyPressed], @"type", + [NSNumber numberWithInt:c], @"x", + [NSNumber numberWithInt:0], @"y", + nil + ] + ]; +} + +- (BOOL)canHandleSwipes { + return TRUE; +} + +- (int)swipe:(int)num withEvent:(struct __GSEvent *)event { + //printf("swipe: %i\n", num); + + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputSwipe], @"type", + [NSNumber numberWithInt:num], @"x", + [NSNumber numberWithInt:0], @"y", + nil + ] + ]; +} + +- (void)applicationSuspend { + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputApplicationSuspended], @"type", + [NSNumber numberWithInt:0], @"x", + [NSNumber numberWithInt:0], @"y", + nil + ] + ]; +} + +- (void)applicationResume { + [self addEvent: + [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithInt:kInputApplicationResumed], @"type", + [NSNumber numberWithInt:0], @"x", + [NSNumber numberWithInt:0], @"y", + nil + ] + ]; +} + +@end diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp index 2b45b5568c..e26c360c82 100644 --- a/backends/platform/iphone/osys_video.cpp +++ b/backends/platform/iphone/osys_video.cpp @@ -39,7 +39,7 @@ bool OSystem_IPHONE::setGraphicsMode(int mode) { case kGraphicsModeNone: case kGraphicsModeLinear: _currentGraphicsMode = mode; - iPhone_setGraphicsMode(mode); + iPhone_setGraphicsMode((GraphicsModes)mode); return true; default: -- cgit v1.2.3 From 66199978e259974428cb9369b288e6da3ddb2c48 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 22 Feb 2012 02:35:36 +0100 Subject: IPHONE: Silence some warnings. --- backends/platform/iphone/iphone_video.mm | 34 +++++++++++++++++--------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 2dcca3592c..0de1a80b15 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -244,10 +244,10 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int * point.x = (point.x - CGRectGetMinX(*area)) / CGRectGetWidth(*area); point.y = (point.y - CGRectGetMinY(*area)) / CGRectGetHeight(*area); - *x = point.x * width; + *x = (int)(point.x * width); // offsetY describes the translation of the screen in the upward direction, // thus we need to add it here. - *y = point.y * height + offsetY; + *y = (int)(point.y * height + offsetY); // Clip coordinates if (*x < 0 || *x > CGRectGetWidth(*area) || *y < 0 || *y > CGRectGetHeight(*area)) @@ -355,8 +355,8 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { } } - _fullWidth = frame.size.width; - _fullHeight = frame.size.height; + _fullWidth = (int)frame.size.width; + _fullHeight = (int)frame.size.height; sharedInstance = self; @@ -509,18 +509,18 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { const GLfloat scaleX = CGRectGetWidth(*rect) / (GLfloat)maxWidth; const GLfloat scaleY = CGRectGetHeight(*rect) / (GLfloat)maxHeight; - mouseX = mouseX * scaleX; - mouseY = mouseY * scaleY; - hotspotX = hotspotX * scaleX; - hotspotY = hotspotY * scaleY; - width = width * scaleX; - height = height * scaleY; + mouseX = (int)(mouseX * scaleX); + mouseY = (int)(mouseY * scaleY); + hotspotX = (int)(hotspotX * scaleX); + hotspotY = (int)(hotspotY * scaleY); + width = (int)(width * scaleX); + height = (int)(height * scaleY); mouseX -= hotspotX; mouseY -= hotspotY; - mouseX += CGRectGetMinX(*rect); - mouseY += CGRectGetMinY(*rect); + mouseX += (int)CGRectGetMinX(*rect); + mouseY += (int)CGRectGetMinY(*rect); GLfloat vertices[] = { // Top left @@ -644,7 +644,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { // When the game screen ratio is less than the screen ratio // we need to scale the width, since the game screen was higher // compared to the width than our output screen is. - rectWidth = screenHeight * gameScreenRatio; + rectWidth = (int)(screenHeight * gameScreenRatio); rectHeight = screenHeight; xOffset = (screenWidth - rectWidth) / 2; yOffset = 0; @@ -653,7 +653,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { // we need to scale the height, since the game screen was wider // compared to the height than our output screen is. rectWidth = screenWidth; - rectHeight = screenWidth / gameScreenRatio; + rectHeight = (int)(screenWidth / gameScreenRatio); xOffset = 0; yOffset = (screenHeight - rectHeight) / 2; } @@ -663,7 +663,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { overlayPortraitRatio = 1.0f; } else { float ratio = (float)_height / (float)_width; - int height = screenWidth * ratio; + int height = (int)(screenWidth * ratio); //printf("Making rect (%u, %u)\n", screenWidth, height); _gameScreenRect = CGRectMake(0, 0, screenWidth, height); @@ -700,7 +700,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { // Scale the shake offset according to the overlay size. We need this to // adjust the overlay mouse click coordinates when an offset is set. - _scaledShakeOffsetY = _shakeOffsetY / (GLfloat)_height * CGRectGetHeight(_overlayRect); + _scaledShakeOffsetY = (int)(_shakeOffsetY / (GLfloat)_height * CGRectGetHeight(_overlayRect)); // Apply the shakeing to the output screen. glTranslatef(0, -_scaledShakeOffsetY, 0); @@ -904,6 +904,8 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { nil ] ]; + + return 0; } - (void)applicationSuspend { -- cgit v1.2.3 From 0e182a958737dbaaf7ecc92100d937cadf8b20b7 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 22 Feb 2012 02:47:16 +0100 Subject: IPHONE: Use #include instead of #import. --- backends/platform/iphone/iphone_keyboard.h | 4 ++-- backends/platform/iphone/iphone_main.mm | 4 ++-- backends/platform/iphone/iphone_video.h | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_keyboard.h b/backends/platform/iphone/iphone_keyboard.h index b13ac35616..2d1238c92f 100644 --- a/backends/platform/iphone/iphone_keyboard.h +++ b/backends/platform/iphone/iphone_keyboard.h @@ -23,8 +23,8 @@ #ifndef BACKENDS_PLATFORM_IPHONE_IPHONE_KEYBOARD_H #define BACKENDS_PLATFORM_IPHONE_IPHONE_KEYBOARD_H -#import -#import +#include +#include @interface SoftKeyboard : UIView { id inputDelegate; diff --git a/backends/platform/iphone/iphone_main.mm b/backends/platform/iphone/iphone_main.mm index 051da417ea..1559ef8a6e 100644 --- a/backends/platform/iphone/iphone_main.mm +++ b/backends/platform/iphone/iphone_main.mm @@ -20,8 +20,8 @@ * */ -#import -#import +#include +#include #include "iphone_video.h" diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 6d64b8464b..43a643ab4a 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -23,13 +23,13 @@ #ifndef BACKENDS_PLATFORM_IPHONE_IPHONE_VIDEO_H #define BACKENDS_PLATFORM_IPHONE_IPHONE_VIDEO_H -#import -#import -#import +#include +#include +#include -#import -#import -#import +#include +#include +#include #include "iphone_keyboard.h" -- cgit v1.2.3 From 6c64fdf4f2e862a15ebd3e336445a89c10deb723 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 22 Feb 2012 02:49:14 +0100 Subject: IPHONE: Very minor cleanup. --- backends/platform/iphone/iphone_video.mm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 0de1a80b15..86365cbefe 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -136,15 +136,13 @@ void iPhone_updateScreen(int mouseX, int mouseY) { } void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2) { - int y; - for (y = y1; y < y2; ++y) + for (int y = y1; y < y2; ++y) memcpy(&_gameScreenTextureBuffer[(y * _gameScreenTextureWidth + x1) * 2], &screen[y * _width + x1], (x2 - x1) * 2); } void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2) { - int y; //printf("Overlaywidth: %u, fullwidth %u\n", _overlayWidth, _fullWidth); - for (y = y1; y < y2; ++y) + for (int y = y1; y < y2; ++y) memcpy(&_overlayTexBuffer[(y * _overlayTexWidth + x1) * 2], &screen[y * _overlayWidth + x1], (x2 - x1) * 2); } -- cgit v1.2.3 From 92aabb686889206060ecb67b8163c6817232f8f9 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Wed, 22 Feb 2012 07:17:38 -0600 Subject: KEYMAPPER: Change HardwareKey id to Common::String --- backends/keymapper/hardware-key.h | 19 +++++++------------ backends/keymapper/keymap.cpp | 6 ++---- 2 files changed, 9 insertions(+), 16 deletions(-) (limited to 'backends') diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h index 8c46ee6358..9fd8d1981a 100644 --- a/backends/keymapper/hardware-key.h +++ b/backends/keymapper/hardware-key.h @@ -31,14 +31,12 @@ namespace Common { -#define HWKEY_ID_SIZE (30) - /** * Describes an available hardware key */ struct HardwareKey { /** unique id used for saving/loading to config */ - char hwKeyId[HWKEY_ID_SIZE]; + String id; /** Human readable description */ String description; @@ -49,11 +47,8 @@ struct HardwareKey { */ KeyState key; - HardwareKey(const char *i, KeyState ky = KeyState(), String desc = "") - : key(ky), description(desc) { - assert(i); - Common::strlcpy(hwKeyId, i, HWKEY_ID_SIZE); - } + HardwareKey(String i, KeyState ky = KeyState(), String desc = "") + : id(i), key(ky), description(desc) { } }; /** @@ -108,11 +103,11 @@ public: _keys.push_back(key); } - const HardwareKey *findHardwareKey(const char *id) const { + const HardwareKey *findHardwareKey(String id) const { List::const_iterator it; for (it = _keys.begin(); it != _keys.end(); it++) { - if (strncmp((*it)->hwKeyId, id, HWKEY_ID_SIZE) == 0) + if ((*it)->id == id) return (*it); } return 0; @@ -175,8 +170,8 @@ private: List::iterator it; for (it = _keys.begin(); it != _keys.end(); it++) { - if (strncmp((*it)->hwKeyId, key->hwKeyId, HWKEY_ID_SIZE) == 0) - error("Error adding HardwareKey '%s' - id of %s already in use!", key->description.c_str(), key->hwKeyId); + if ((*it)->id == key->id) + error("Error adding HardwareKey '%s' - id of %s already in use!", key->description.c_str(), key->id.c_str()); else if ((*it)->key == key->key) error("Error adding HardwareKey '%s' - key already in use!", key->description.c_str()); } diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp index 5bee1a246d..3913fd149e 100644 --- a/backends/keymapper/keymap.cpp +++ b/backends/keymapper/keymap.cpp @@ -185,12 +185,10 @@ void Keymap::saveMappings() { actIdLen = (actIdLen > ACTION_ID_SIZE) ? ACTION_ID_SIZE : actIdLen; String actId((*it)->id, (*it)->id + actIdLen); - char hwId[HWKEY_ID_SIZE+1]; - - memset(hwId, 0, HWKEY_ID_SIZE+1); + String hwId = ""; if ((*it)->getMappedKey()) { - memcpy(hwId, (*it)->getMappedKey()->hwKeyId, HWKEY_ID_SIZE); + hwId = (*it)->getMappedKey()->id; } _configDomain->setVal(prefix + actId, hwId); } -- cgit v1.2.3 From dbdfc13819ee300b738867c2a874dddea56daa2b Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Wed, 22 Feb 2012 15:12:21 -0600 Subject: KEYMAPPER: Fix a signed/unsigned comparison warning --- backends/keymapper/keymapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index aafdd604a2..189f862469 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -119,7 +119,7 @@ void Keymapper::cleanupGameKeymaps() { // the game specific (=deleted) ones. Stack newStack; - for (int i = 0; i < _activeMaps.size(); i++) { + for (Stack::size_type i = 0; i < _activeMaps.size(); i++) { if (_activeMaps[i].global) newStack.push(_activeMaps[i]); } -- cgit v1.2.3 From f4579aab9b107a3485d24ad41cb2748b5babae43 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 01:01:20 +0100 Subject: IPHONE: Create a struct for shared video context variables. --- backends/platform/iphone/iphone_video.h | 19 +++++ backends/platform/iphone/iphone_video.mm | 134 ++++++++++++++----------------- 2 files changed, 81 insertions(+), 72 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 43a643ab4a..83150961d0 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -32,6 +32,25 @@ #include #include "iphone_keyboard.h" +#include "iphone_common.h" + +struct VideoContext { + // Game screen state + int screenWidth, screenHeight; + + // Overlay state + int overlayWidth, overlayHeight; + + // Mouse cursor state + int mouseX, mouseY; + int mouseHotspotX, mouseHotspotY; + int mouseWidth, mouseHeight; + bool mouseIsVisible; + + // Misc state + GraphicsModes graphicsMode; + int shakeOffsetY; +}; @interface iPhoneView : UIView { void *_screenSurface; diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 86365cbefe..3eb2fef1fb 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -21,12 +21,8 @@ */ #include "iphone_video.h" -#include "iphone_common.h" static iPhoneView *sharedInstance = nil; -static GraphicsModes _graphicsMode = kGraphicsModeLinear; -static int _width = 0; -static int _height = 0; static int _fullWidth; static int _fullHeight; static CGRect _gameScreenRect; @@ -38,8 +34,6 @@ static int _gameScreenTextureHeight = 0; static char *_overlayTexBuffer = 0; static int _overlayTexWidth = 0; static int _overlayTexHeight = 0; -static int _overlayWidth = 0; -static int _overlayHeight = 0; static CGRect _overlayRect; static int _needsScreenUpdate = 0; @@ -49,20 +43,14 @@ static UITouch *_firstTouch = NULL; static UITouch *_secondTouch = NULL; static unsigned short *_mouseCursor = NULL; -static int _mouseCursorHeight = 0; -static int _mouseCursorWidth = 0; -static int _mouseCursorHotspotX = 0; -static int _mouseCursorHotspotY = 0; -static int _mouseX = 0; -static int _mouseY = 0; -static int _mouseCursorEnabled = 0; static GLint _renderBufferWidth; static GLint _renderBufferHeight; -static int _shakeOffsetY; static int _scaledShakeOffsetY; +static VideoContext _videoContext; + #if 0 static long lastTick = 0; static int frames = 0; @@ -84,23 +72,23 @@ int printOglError(const char *file, int line) { } void iPhone_setGraphicsMode(GraphicsModes mode) { - _graphicsMode = mode; + _videoContext.graphicsMode = mode; [sharedInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES]; } void iPhone_showCursor(int state) { - _mouseCursorEnabled = state; + _videoContext.mouseIsVisible = state; } void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int hotspotX, int hotspotY) { _mouseCursor = buffer; - _mouseCursorWidth = width; - _mouseCursorHeight = height; + _videoContext.mouseWidth = width; + _videoContext.mouseHeight = height; - _mouseCursorHotspotX = hotspotX; - _mouseCursorHotspotY = hotspotY; + _videoContext.mouseHotspotX = hotspotX; + _videoContext.mouseHotspotY = hotspotY; [sharedInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; } @@ -112,11 +100,11 @@ void iPhone_enableOverlay(int state) { } int iPhone_getScreenHeight() { - return _overlayHeight; + return _videoContext.overlayHeight; } int iPhone_getScreenWidth() { - return _overlayWidth; + return _videoContext.overlayWidth; } bool iPhone_isHighResDevice() { @@ -126,8 +114,8 @@ bool iPhone_isHighResDevice() { void iPhone_updateScreen(int mouseX, int mouseY) { //printf("Mouse: (%i, %i)\n", mouseX, mouseY); - _mouseX = mouseX; - _mouseY = mouseY; + _videoContext.mouseX = mouseX; + _videoContext.mouseY = mouseY; if (!_needsScreenUpdate) { _needsScreenUpdate = 1; @@ -137,24 +125,24 @@ void iPhone_updateScreen(int mouseX, int mouseY) { void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2) { for (int y = y1; y < y2; ++y) - memcpy(&_gameScreenTextureBuffer[(y * _gameScreenTextureWidth + x1) * 2], &screen[y * _width + x1], (x2 - x1) * 2); + memcpy(&_gameScreenTextureBuffer[(y * _gameScreenTextureWidth + x1) * 2], &screen[y * _videoContext.screenWidth + x1], (x2 - x1) * 2); } void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2) { - //printf("Overlaywidth: %u, fullwidth %u\n", _overlayWidth, _fullWidth); + //printf("Overlaywidth: %u, fullwidth %u\n", _videoContext.overlayWidth, _fullWidth); for (int y = y1; y < y2; ++y) - memcpy(&_overlayTexBuffer[(y * _overlayTexWidth + x1) * 2], &screen[y * _overlayWidth + x1], (x2 - x1) * 2); + memcpy(&_overlayTexBuffer[(y * _overlayTexWidth + x1) * 2], &screen[y * _videoContext.overlayWidth + x1], (x2 - x1) * 2); } void iPhone_initSurface(int width, int height) { - _width = width; - _height = height; - _shakeOffsetY = 0; + _videoContext.screenWidth = width; + _videoContext.screenHeight = height; + _videoContext.shakeOffsetY = 0; [sharedInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES]; } void iPhone_setShakeOffset(int offset) { - _shakeOffsetY = offset; + _videoContext.shakeOffsetY = offset; [sharedInstance performSelectorOnMainThread:@selector(setViewTransformation) withObject:nil waitUntilDone: YES]; } @@ -229,13 +217,13 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int * int width, height, offsetY; if (_overlayIsEnabled) { area = &_overlayRect; - width = _overlayWidth; - height = _overlayHeight; - offsetY = _shakeOffsetY; + width = _videoContext.overlayWidth; + height = _videoContext.overlayHeight; + offsetY = _videoContext.shakeOffsetY; } else { area = &_gameScreenRect; - width = _width; - height = _height; + width = _videoContext.screenWidth; + height = _videoContext.screenHeight; offsetY = _scaledShakeOffsetY; } @@ -317,16 +305,16 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { return; } - _overlayHeight = _renderBufferWidth; - _overlayWidth = _renderBufferHeight; - _overlayTexWidth = getSizeNextPOT(_overlayHeight); - _overlayTexHeight = getSizeNextPOT(_overlayWidth); + _videoContext.overlayHeight = _renderBufferWidth; + _videoContext.overlayWidth = _renderBufferHeight; + _overlayTexWidth = getSizeNextPOT(_videoContext.overlayHeight); + _overlayTexHeight = getSizeNextPOT(_videoContext.overlayWidth); // Since the overlay size won't change the whole run, we can // precalculate the texture coordinates for the overlay texture here // and just use it later on. - _overlayTexCoords[2] = _overlayTexCoords[6] = _overlayWidth / (GLfloat)_overlayTexWidth; - _overlayTexCoords[5] = _overlayTexCoords[7] = _overlayHeight / (GLfloat)_overlayTexHeight; + _overlayTexCoords[2] = _overlayTexCoords[6] = _videoContext.overlayWidth / (GLfloat)_overlayTexWidth; + _overlayTexCoords[5] = _overlayTexCoords[7] = _videoContext.overlayHeight / (GLfloat)_overlayTexHeight; int textureSize = _overlayTexWidth * _overlayTexHeight * 2; _overlayTexBuffer = (char *)malloc(textureSize); @@ -363,6 +351,8 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { _overlayTexture = 0; _mouseCursorTexture = 0; + _videoContext.graphicsMode = kGraphicsModeLinear; + _gameScreenVertCoords[0] = _gameScreenVertCoords[1] = _gameScreenVertCoords[2] = _gameScreenVertCoords[3] = _gameScreenVertCoords[4] = _gameScreenVertCoords[5] = @@ -420,9 +410,9 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { } - (void)setGraphicsMode { - setFilterModeForTexture(_screenTexture, _graphicsMode); - setFilterModeForTexture(_overlayTexture, _graphicsMode); - setFilterModeForTexture(_mouseCursorTexture, _graphicsMode); + setFilterModeForTexture(_screenTexture, _videoContext.graphicsMode); + setFilterModeForTexture(_overlayTexture, _videoContext.graphicsMode); + setFilterModeForTexture(_mouseCursorTexture, _videoContext.graphicsMode); } - (void)updateSurface { @@ -438,7 +428,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { if (_overlayIsEnabled) [self updateOverlaySurface]; - if (_mouseCursorEnabled) + if (_videoContext.mouseIsVisible) [self updateMouseSurface]; glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); @@ -449,11 +439,11 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { - (void)updateMouseCursor { if (_mouseCursorTexture == 0) { glGenTextures(1, &_mouseCursorTexture); printOpenGLError(); - setFilterModeForTexture(_mouseCursorTexture, _graphicsMode); + setFilterModeForTexture(_mouseCursorTexture, _videoContext.graphicsMode); } glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getSizeNextPOT(_mouseCursorWidth), getSizeNextPOT(_mouseCursorHeight), 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _mouseCursor); printOpenGLError(); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getSizeNextPOT(_videoContext.mouseWidth), getSizeNextPOT(_videoContext.mouseHeight), 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _mouseCursor); printOpenGLError(); free(_mouseCursor); _mouseCursor = NULL; @@ -482,26 +472,26 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { } - (void)updateMouseSurface { - int width = _mouseCursorWidth; - int height = _mouseCursorHeight; + int width = _videoContext.mouseWidth; + int height = _videoContext.mouseHeight; - int mouseX = _mouseX; - int mouseY = _mouseY; + int mouseX = _videoContext.mouseX; + int mouseY = _videoContext.mouseY; - int hotspotX = _mouseCursorHotspotX; - int hotspotY = _mouseCursorHotspotY; + int hotspotX = _videoContext.mouseHotspotX; + int hotspotY = _videoContext.mouseHotspotY; CGRect *rect; int maxWidth, maxHeight; if (!_overlayIsEnabled) { rect = &_gameScreenRect; - maxWidth = _width; - maxHeight = _height; + maxWidth = _videoContext.screenWidth; + maxHeight = _videoContext.screenHeight; } else { rect = &_overlayRect; - maxWidth = _overlayWidth; - maxHeight = _overlayHeight; + maxWidth = _videoContext.overlayWidth; + maxHeight = _videoContext.overlayHeight; } const GLfloat scaleX = CGRectGetWidth(*rect) / (GLfloat)maxWidth; @@ -531,10 +521,10 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { mouseX + width, mouseY + height }; - //printf("Cursor: width %u height %u\n", _mouseCursorWidth, _mouseCursorHeight); + //printf("Cursor: width %u height %u\n", _videoContext.mouseWidth, _videoContext.mouseHeight); - float texWidth = _mouseCursorWidth / (float)getSizeNextPOT(_mouseCursorWidth); - float texHeight = _mouseCursorHeight / (float)getSizeNextPOT(_mouseCursorHeight); + float texWidth = _videoContext.mouseWidth / (float)getSizeNextPOT(_videoContext.mouseWidth); + float texHeight = _videoContext.mouseHeight / (float)getSizeNextPOT(_videoContext.mouseHeight); const GLfloat texCoords[] = { // Top left @@ -555,11 +545,11 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { } - (void)initSurface { - _gameScreenTextureWidth = getSizeNextPOT(_width); - _gameScreenTextureHeight = getSizeNextPOT(_height); + _gameScreenTextureWidth = getSizeNextPOT(_videoContext.screenWidth); + _gameScreenTextureHeight = getSizeNextPOT(_videoContext.screenHeight); - _gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _width / (GLfloat)_gameScreenTextureWidth; - _gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _height / (GLfloat)_gameScreenTextureHeight; + _gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _videoContext.screenWidth / (GLfloat)_gameScreenTextureWidth; + _gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _videoContext.screenHeight / (GLfloat)_gameScreenTextureHeight; _orientation = [[UIDevice currentDevice] orientation]; @@ -573,7 +563,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { _orientation = UIDeviceOrientationPortrait; } - //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _width, _height, _gameScreenTextureWidth, _gameScreenTextureHeight); + //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _videoContext.screenWidth, _videoContext.screenHeight, _gameScreenTextureWidth, _gameScreenTextureHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -605,14 +595,14 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { } glGenTextures(1, &_screenTexture); printOpenGLError(); - setFilterModeForTexture(_screenTexture, _graphicsMode); + setFilterModeForTexture(_screenTexture, _videoContext.graphicsMode); if (_overlayTexture > 0) { glDeleteTextures(1, &_overlayTexture); printOpenGLError(); } glGenTextures(1, &_overlayTexture); printOpenGLError(); - setFilterModeForTexture(_overlayTexture, _graphicsMode); + setFilterModeForTexture(_overlayTexture, _videoContext.graphicsMode); free(_gameScreenTextureBuffer); int textureSize = _gameScreenTextureWidth * _gameScreenTextureHeight * 2; @@ -631,7 +621,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { float overlayPortraitRatio; if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation == UIDeviceOrientationLandscapeRight) { - GLfloat gameScreenRatio = (GLfloat)_width / (GLfloat)_height; + GLfloat gameScreenRatio = (GLfloat)_videoContext.screenWidth / (GLfloat)_videoContext.screenHeight; GLfloat screenRatio = (GLfloat)screenWidth / (GLfloat)screenHeight; // These are the width/height according to the portrait layout! @@ -660,7 +650,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { _gameScreenRect = CGRectMake(xOffset, yOffset, rectWidth, rectHeight); overlayPortraitRatio = 1.0f; } else { - float ratio = (float)_height / (float)_width; + float ratio = (float)_videoContext.screenHeight / (float)_videoContext.screenWidth; int height = (int)(screenWidth * ratio); //printf("Making rect (%u, %u)\n", screenWidth, height); _gameScreenRect = CGRectMake(0, 0, screenWidth, height); @@ -674,7 +664,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { [self addSubview:[_keyboardView inputView]]; [self addSubview: _keyboardView]; [[_keyboardView inputView] becomeFirstResponder]; - overlayPortraitRatio = (_overlayHeight * ratio) / _overlayWidth; + overlayPortraitRatio = (_videoContext.overlayHeight * ratio) / _videoContext.overlayWidth; } _overlayRect = CGRectMake(0, 0, screenWidth, screenHeight * overlayPortraitRatio); @@ -698,7 +688,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { // Scale the shake offset according to the overlay size. We need this to // adjust the overlay mouse click coordinates when an offset is set. - _scaledShakeOffsetY = (int)(_shakeOffsetY / (GLfloat)_height * CGRectGetHeight(_overlayRect)); + _scaledShakeOffsetY = (int)(_videoContext.shakeOffsetY / (GLfloat)_videoContext.screenHeight * CGRectGetHeight(_overlayRect)); // Apply the shakeing to the output screen. glTranslatef(0, -_scaledShakeOffsetY, 0); -- cgit v1.2.3 From 833ce4f3489f3f9523b0d726d7e3b385e018abba Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 01:03:09 +0100 Subject: IPHONE: Fix scale offset addition in the mouse coordinate code. Formerly the overlay and game screen offset was swapped. --- backends/platform/iphone/iphone_video.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 3eb2fef1fb..8734ffc165 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -219,12 +219,12 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int * area = &_overlayRect; width = _videoContext.overlayWidth; height = _videoContext.overlayHeight; - offsetY = _videoContext.shakeOffsetY; + offsetY = _scaledShakeOffsetY; } else { area = &_gameScreenRect; width = _videoContext.screenWidth; height = _videoContext.screenHeight; - offsetY = _scaledShakeOffsetY; + offsetY = _videoContext.shakeOffsetY; } point.x = (point.x - CGRectGetMinX(*area)) / CGRectGetWidth(*area); -- cgit v1.2.3 From def1471fff478497ed245ed2e296617f0d48b0c6 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 01:04:06 +0100 Subject: IPHONE: Slight formatting fix. --- backends/platform/iphone/iphone_video.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 8734ffc165..d12f75ab73 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -237,7 +237,7 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int * // Clip coordinates if (*x < 0 || *x > CGRectGetWidth(*area) || *y < 0 || *y > CGRectGetHeight(*area)) - return false; + return false; return true; } -- cgit v1.2.3 From 26405be48f1c011a08c51e3bcb1bd0e1a16f14a2 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 01:14:39 +0100 Subject: IPHONE: Move setFilterModeForTexture to iPhoneView. --- backends/platform/iphone/iphone_video.mm | 56 ++++++++++++++++---------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index d12f75ab73..8ea6c2374b 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -242,28 +242,6 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int * return true; } -static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { - if (!tex) - return; - - glBindTexture(GL_TEXTURE_2D, tex); printOpenGLError(); - - GLint filter = GL_LINEAR; - - switch (mode) { - case kGraphicsModeLinear: - filter = GL_LINEAR; - break; - - case kGraphicsModeNone: - filter = GL_NEAREST; - break; - } - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); printOpenGLError(); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); printOpenGLError(); -} - @implementation iPhoneView + (Class)layerClass { @@ -409,10 +387,32 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { #endif } +- (void)setFilterModeForTexture:(GLuint)tex { + if (!tex) + return; + + glBindTexture(GL_TEXTURE_2D, tex); printOpenGLError(); + + GLint filter = GL_LINEAR; + + switch (_videoContext.graphicsMode) { + case kGraphicsModeLinear: + filter = GL_LINEAR; + break; + + case kGraphicsModeNone: + filter = GL_NEAREST; + break; + } + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); printOpenGLError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); printOpenGLError(); +} + - (void)setGraphicsMode { - setFilterModeForTexture(_screenTexture, _videoContext.graphicsMode); - setFilterModeForTexture(_overlayTexture, _videoContext.graphicsMode); - setFilterModeForTexture(_mouseCursorTexture, _videoContext.graphicsMode); + [self setFilterModeForTexture:_screenTexture]; + [self setFilterModeForTexture:_overlayTexture]; + [self setFilterModeForTexture:_mouseCursorTexture]; } - (void)updateSurface { @@ -439,7 +439,7 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { - (void)updateMouseCursor { if (_mouseCursorTexture == 0) { glGenTextures(1, &_mouseCursorTexture); printOpenGLError(); - setFilterModeForTexture(_mouseCursorTexture, _videoContext.graphicsMode); + [self setFilterModeForTexture:_mouseCursorTexture]; } glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); @@ -595,14 +595,14 @@ static void setFilterModeForTexture(GLuint tex, GraphicsModes mode) { } glGenTextures(1, &_screenTexture); printOpenGLError(); - setFilterModeForTexture(_screenTexture, _videoContext.graphicsMode); + [self setFilterModeForTexture:_screenTexture]; if (_overlayTexture > 0) { glDeleteTextures(1, &_overlayTexture); printOpenGLError(); } glGenTextures(1, &_overlayTexture); printOpenGLError(); - setFilterModeForTexture(_overlayTexture, _videoContext.graphicsMode); + [self setFilterModeForTexture:_overlayTexture]; free(_gameScreenTextureBuffer); int textureSize = _gameScreenTextureWidth * _gameScreenTextureHeight * 2; -- cgit v1.2.3 From 174127c1ddd1dcd1cbdf74e61e8e48e02f6c9e2e Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 01:19:34 +0100 Subject: IPHONE: Remove some more dead code. --- backends/platform/iphone/iphone_video.h | 3 --- backends/platform/iphone/iphone_video.mm | 4 ---- 2 files changed, 7 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 83150961d0..733851f8b7 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -53,7 +53,6 @@ struct VideoContext { }; @interface iPhoneView : UIView { - void *_screenSurface; NSMutableArray *_events; SoftKeyboard *_keyboardView; @@ -77,8 +76,6 @@ struct VideoContext { - (void)drawRect:(CGRect)frame; -- (void *)getSurface; - - (void)initSurface; - (void)setViewTransformation; diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 8ea6c2374b..c99346964c 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -368,10 +368,6 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int * free(_overlayTexBuffer); } -- (void *)getSurface { - return _screenSurface; -} - - (void)drawRect:(CGRect)frame { #if 0 if (lastTick == 0) { -- cgit v1.2.3 From 04f9fc3e180afe47385bc189e9f5f36766d2091b Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 01:27:38 +0100 Subject: IPHONE: Move projection setup code to its own method. --- backends/platform/iphone/iphone_video.mm | 66 +++++++++++++++++--------------- 1 file changed, 35 insertions(+), 31 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index c99346964c..b6636e6f9a 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -540,51 +540,55 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int * glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); } -- (void)initSurface { - _gameScreenTextureWidth = getSizeNextPOT(_videoContext.screenWidth); - _gameScreenTextureHeight = getSizeNextPOT(_videoContext.screenHeight); - - _gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _videoContext.screenWidth / (GLfloat)_gameScreenTextureWidth; - _gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _videoContext.screenHeight / (GLfloat)_gameScreenTextureHeight; +- (void)setUpOrientation:(UIDeviceOrientation)orientation width:(int *)width height:(int *)height { + _orientation = orientation; - _orientation = [[UIDevice currentDevice] orientation]; + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + // We always force the origin (0,0) to be in the upper left corner. switch (_orientation) { - case UIDeviceOrientationLandscapeLeft: case UIDeviceOrientationLandscapeRight: - case UIDeviceOrientationPortrait: + glRotatef( 90, 0, 0, 1); printOpenGLError(); + glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); + + *width = _renderBufferHeight; + *height = _renderBufferWidth; break; + case UIDeviceOrientationLandscapeLeft: + glRotatef(-90, 0, 0, 1); printOpenGLError(); + glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); + + *width = _renderBufferHeight; + *height = _renderBufferWidth; + break; + + case UIDeviceOrientationPortrait: default: + // We must force the portrait orientation here, since we might not know + // the real orientation. _orientation = UIDeviceOrientationPortrait; - } - //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _videoContext.screenWidth, _videoContext.screenHeight, _gameScreenTextureWidth, _gameScreenTextureHeight); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); + glOrthof(0, _renderBufferWidth, _renderBufferHeight, 0, 0, 1); printOpenGLError(); - int screenWidth, screenHeight; + *width = _renderBufferWidth; + *height = _renderBufferHeight; + break; + } +} - // Set the origin (0,0) depending on the rotation mode. - if (_orientation == UIDeviceOrientationLandscapeRight) { - glRotatef( 90, 0, 0, 1); printOpenGLError(); - glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); +- (void)initSurface { + _gameScreenTextureWidth = getSizeNextPOT(_videoContext.screenWidth); + _gameScreenTextureHeight = getSizeNextPOT(_videoContext.screenHeight); - screenWidth = _renderBufferHeight; - screenHeight = _renderBufferWidth; - } else if (_orientation == UIDeviceOrientationLandscapeLeft) { - glRotatef(-90, 0, 0, 1); printOpenGLError(); - glOrthof(0, _renderBufferHeight, _renderBufferWidth, 0, 0, 1); printOpenGLError(); + _gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _videoContext.screenWidth / (GLfloat)_gameScreenTextureWidth; + _gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _videoContext.screenHeight / (GLfloat)_gameScreenTextureHeight; - screenWidth = _renderBufferHeight; - screenHeight = _renderBufferWidth; - } else if (_orientation == UIDeviceOrientationPortrait) { - glOrthof(0, _renderBufferWidth, _renderBufferHeight, 0, 0, 1); printOpenGLError(); + int screenWidth, screenHeight; + [self setUpOrientation:[[UIDevice currentDevice] orientation] width:&screenWidth height:&screenHeight]; - screenWidth = _renderBufferWidth; - screenHeight = _renderBufferHeight; - } + //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _videoContext.screenWidth, _videoContext.screenHeight, _gameScreenTextureWidth, _gameScreenTextureHeight); if (_screenTexture > 0) { glDeleteTextures(1, &_screenTexture); printOpenGLError(); -- cgit v1.2.3 From c5ccb32b48ac0cf662539e8d4a1f0392f96c4b1a Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 01:52:50 +0100 Subject: IPHONE: Move graphics related OSystem code to a ObjC++ file. --- backends/platform/iphone/osys_video.cpp | 432 -------------------------------- backends/platform/iphone/osys_video.mm | 432 ++++++++++++++++++++++++++++++++ 2 files changed, 432 insertions(+), 432 deletions(-) delete mode 100644 backends/platform/iphone/osys_video.cpp create mode 100644 backends/platform/iphone/osys_video.mm (limited to 'backends') diff --git a/backends/platform/iphone/osys_video.cpp b/backends/platform/iphone/osys_video.cpp deleted file mode 100644 index e26c360c82..0000000000 --- a/backends/platform/iphone/osys_video.cpp +++ /dev/null @@ -1,432 +0,0 @@ -/* 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. - * - */ - -// Disable symbol overrides so that we can use system headers. -#define FORBIDDEN_SYMBOL_ALLOW_ALL - -#include "osys_main.h" - -const OSystem::GraphicsMode *OSystem_IPHONE::getSupportedGraphicsModes() const { - return s_supportedGraphicsModes; -} - - -int OSystem_IPHONE::getDefaultGraphicsMode() const { - return kGraphicsModeLinear; -} - -bool OSystem_IPHONE::setGraphicsMode(int mode) { - switch (mode) { - case kGraphicsModeNone: - case kGraphicsModeLinear: - _currentGraphicsMode = mode; - iPhone_setGraphicsMode((GraphicsModes)mode); - return true; - - default: - return false; - } -} - -int OSystem_IPHONE::getGraphicsMode() const { - return _currentGraphicsMode; -} - -void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) { - //printf("initSize(%i, %i)\n", width, height); - - _screenWidth = width; - _screenHeight = height; - - free(_gameScreenRaw); - - _gameScreenRaw = (byte *)malloc(width * height); - bzero(_gameScreenRaw, width * height); - - //free(_overlayBuffer); - - int fullSize = _screenWidth * _screenHeight * sizeof(OverlayColor); - //_overlayBuffer = (OverlayColor *)malloc(fullSize); - clearOverlay(); - - free(_gameScreenConverted); - - _gameScreenConverted = (uint16 *)malloc(fullSize); - bzero(_gameScreenConverted, fullSize); - - iPhone_initSurface(width, height); - - if (_overlayBuffer == NULL) { - _overlayHeight = iPhone_getScreenHeight(); - _overlayWidth = iPhone_getScreenWidth(); - - printf("Overlay: (%u x %u)\n", _overlayWidth, _overlayHeight); - _overlayBuffer = new OverlayColor[_overlayHeight * _overlayWidth]; - } - - _fullScreenIsDirty = false; - dirtyFullScreen(); - _mouseVisible = false; - _mouseCursorPaletteEnabled = false; - _screenChangeCount++; - updateScreen(); -} - -int16 OSystem_IPHONE::getHeight() { - return _screenHeight; -} - -int16 OSystem_IPHONE::getWidth() { - return _screenWidth; -} - -void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { - assert(start + num <= 256); - const byte *b = colors; - - for (uint i = start; i < start + num; ++i) { - _gamePalette[i] = Graphics::RGBToColor >(b[0], b[1], b[2]); - _gamePaletteRGBA5551[i] = Graphics::RGBToColor >(b[0], b[1], b[2]); - b += 3; - } - - dirtyFullScreen(); -} - -void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) { - assert(start + num <= 256); - byte *b = colors; - - for (uint i = start; i < start + num; ++i) { - Graphics::colorToRGB >(_gamePalette[i], b[0], b[1], b[2]); - b += 3; - } -} - -void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { - //printf("copyRectToScreen(%i, %i, %i, %i)\n", x, y, w, h); - //Clip the coordinates - if (x < 0) { - w += x; - buf -= x; - x = 0; - } - - if (y < 0) { - h += y; - buf -= y * pitch; - y = 0; - } - - if (w > _screenWidth - x) { - w = _screenWidth - x; - } - - if (h > _screenHeight - y) { - h = _screenHeight - y; - } - - if (w <= 0 || h <= 0) - return; - - if (!_fullScreenIsDirty) { - _dirtyRects.push_back(Common::Rect(x, y, x + w, y + h)); - } - - - byte *dst = _gameScreenRaw + y * _screenWidth + x; - if (_screenWidth == pitch && pitch == w) - memcpy(dst, buf, h * w); - else { - do { - memcpy(dst, buf, w); - buf += pitch; - dst += _screenWidth; - } while (--h); - } -} - -void OSystem_IPHONE::updateScreen() { - //printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size()); - - if (_dirtyRects.size() == 0 && _dirtyOverlayRects.size() == 0 && !_mouseDirty) - return; - - internUpdateScreen(); - _mouseDirty = false; - _fullScreenIsDirty = false; - _fullScreenOverlayIsDirty = false; - - iPhone_updateScreen(_mouseX, _mouseY); -} - -void OSystem_IPHONE::internUpdateScreen() { - if (_mouseNeedTextureUpdate) { - updateMouseTexture(); - _mouseNeedTextureUpdate = false; - } - - while (_dirtyRects.size()) { - Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1); - - //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); - drawDirtyRect(dirtyRect); - updateHardwareSurfaceForRect(dirtyRect); - } - - if (_overlayVisible) { - while (_dirtyOverlayRects.size()) { - Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1); - - //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); - drawDirtyOverlayRect(dirtyRect); - } - } -} - -void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { - int h = dirtyRect.bottom - dirtyRect.top; - int w = dirtyRect.right - dirtyRect.left; - - byte *src = &_gameScreenRaw[dirtyRect.top * _screenWidth + dirtyRect.left]; - uint16 *dst = &_gameScreenConverted[dirtyRect.top * _screenWidth + dirtyRect.left]; - for (int y = h; y > 0; y--) { - for (int x = w; x > 0; x--) - *dst++ = _gamePalette[*src++]; - - dst += _screenWidth - w; - src += _screenWidth - w; - } -} - -void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) { - iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); -} - -void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) { - iPhone_updateScreenRect(_gameScreenConverted, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom); -} - -Graphics::Surface *OSystem_IPHONE::lockScreen() { - //printf("lockScreen()\n"); - - _framebuffer.pixels = _gameScreenRaw; - _framebuffer.w = _screenWidth; - _framebuffer.h = _screenHeight; - _framebuffer.pitch = _screenWidth; - _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8(); - - return &_framebuffer; -} - -void OSystem_IPHONE::unlockScreen() { - //printf("unlockScreen()\n"); - dirtyFullScreen(); -} - -void OSystem_IPHONE::setShakePos(int shakeOffset) { - //printf("setShakePos(%i)\n", shakeOffset); - iPhone_setShakeOffset(shakeOffset); - // HACK: We use this to force a redraw. - _mouseDirty = true; -} - -void OSystem_IPHONE::showOverlay() { - //printf("showOverlay()\n"); - _overlayVisible = true; - dirtyFullOverlayScreen(); - updateScreen(); - iPhone_enableOverlay(true); -} - -void OSystem_IPHONE::hideOverlay() { - //printf("hideOverlay()\n"); - _overlayVisible = false; - _dirtyOverlayRects.clear(); - dirtyFullScreen(); - iPhone_enableOverlay(false); -} - -void OSystem_IPHONE::clearOverlay() { - //printf("clearOverlay()\n"); - bzero(_overlayBuffer, _overlayWidth * _overlayHeight * sizeof(OverlayColor)); - dirtyFullOverlayScreen(); -} - -void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) { - //printf("grabOverlay()\n"); - int h = _overlayHeight; - OverlayColor *src = _overlayBuffer; - - do { - memcpy(buf, src, _overlayWidth * sizeof(OverlayColor)); - src += _overlayWidth; - buf += pitch; - } while (--h); -} - -void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { - //printf("copyRectToOverlay(buf, pitch=%i, x=%i, y=%i, w=%i, h=%i)\n", pitch, x, y, w, h); - - //Clip the coordinates - if (x < 0) { - w += x; - buf -= x; - x = 0; - } - - if (y < 0) { - h += y; - buf -= y * pitch; - y = 0; - } - - if (w > _overlayWidth - x) - w = _overlayWidth - x; - - if (h > _overlayHeight - y) - h = _overlayHeight - y; - - if (w <= 0 || h <= 0) - return; - - if (!_fullScreenOverlayIsDirty) { - _dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h)); - } - - OverlayColor *dst = _overlayBuffer + (y * _overlayWidth + x); - if (_overlayWidth == pitch && pitch == w) - memcpy(dst, buf, h * w * sizeof(OverlayColor)); - else { - do { - memcpy(dst, buf, w * sizeof(OverlayColor)); - buf += pitch; - dst += _overlayWidth; - } while (--h); - } -} - -int16 OSystem_IPHONE::getOverlayHeight() { - return _overlayHeight; -} - -int16 OSystem_IPHONE::getOverlayWidth() { - return _overlayWidth; -} - -bool OSystem_IPHONE::showMouse(bool visible) { - bool last = _mouseVisible; - _mouseVisible = visible; - iPhone_showCursor(visible); - _mouseDirty = true; - - return last; -} - -void OSystem_IPHONE::warpMouse(int x, int y) { - //printf("warpMouse()\n"); - - _mouseX = x; - _mouseY = y; - _mouseDirty = true; -} - -void OSystem_IPHONE::dirtyFullScreen() { - if (!_fullScreenIsDirty) { - _dirtyRects.clear(); - _dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight)); - _fullScreenIsDirty = true; - } -} - -void OSystem_IPHONE::dirtyFullOverlayScreen() { - if (!_fullScreenOverlayIsDirty) { - _dirtyOverlayRects.clear(); - _dirtyOverlayRects.push_back(Common::Rect(0, 0, _overlayWidth, _overlayHeight)); - _fullScreenOverlayIsDirty = true; - } -} - -void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { - //printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale); - - if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) { - free(_mouseBuf); - _mouseBuf = NULL; - } - - if (_mouseBuf == NULL) - _mouseBuf = (byte *)malloc(w * h); - - _mouseWidth = w; - _mouseHeight = h; - - _mouseHotspotX = hotspotX; - _mouseHotspotY = hotspotY; - - _mouseKeyColor = (byte)keycolor; - - memcpy(_mouseBuf, buf, w * h); - - _mouseDirty = true; - _mouseNeedTextureUpdate = true; -} - -void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num) { - assert(start + num <= 256); - - for (uint i = start; i < start + num; ++i, colors += 3) - _mouseCursorPalette[i] = Graphics::RGBToColor >(colors[0], colors[1], colors[2]); - - // FIXME: This is just stupid, our client code seems to assume that this - // automatically enables the cursor palette. - _mouseCursorPaletteEnabled = true; - - if (_mouseCursorPaletteEnabled) - _mouseDirty = _mouseNeedTextureUpdate = true; -} - -void OSystem_IPHONE::updateMouseTexture() { - int texWidth = getSizeNextPOT(_mouseWidth); - int texHeight = getSizeNextPOT(_mouseHeight); - int bufferSize = texWidth * texHeight * sizeof(int16); - uint16 *mouseBuf = (uint16 *)malloc(bufferSize); - memset(mouseBuf, 0, bufferSize); - - const uint16 *palette; - if (_mouseCursorPaletteEnabled) - palette = _mouseCursorPalette; - else - palette = _gamePaletteRGBA5551; - - for (uint x = 0; x < _mouseWidth; ++x) { - for (uint y = 0; y < _mouseHeight; ++y) { - const byte color = _mouseBuf[y * _mouseWidth + x]; - if (color != _mouseKeyColor) - mouseBuf[y * texWidth + x] = palette[color] | 0x1; - else - mouseBuf[y * texWidth + x] = 0x0; - } - } - - iPhone_setMouseCursor(mouseBuf, _mouseWidth, _mouseHeight, _mouseHotspotX, _mouseHotspotY); -} diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm new file mode 100644 index 0000000000..e26c360c82 --- /dev/null +++ b/backends/platform/iphone/osys_video.mm @@ -0,0 +1,432 @@ +/* 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. + * + */ + +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + +#include "osys_main.h" + +const OSystem::GraphicsMode *OSystem_IPHONE::getSupportedGraphicsModes() const { + return s_supportedGraphicsModes; +} + + +int OSystem_IPHONE::getDefaultGraphicsMode() const { + return kGraphicsModeLinear; +} + +bool OSystem_IPHONE::setGraphicsMode(int mode) { + switch (mode) { + case kGraphicsModeNone: + case kGraphicsModeLinear: + _currentGraphicsMode = mode; + iPhone_setGraphicsMode((GraphicsModes)mode); + return true; + + default: + return false; + } +} + +int OSystem_IPHONE::getGraphicsMode() const { + return _currentGraphicsMode; +} + +void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) { + //printf("initSize(%i, %i)\n", width, height); + + _screenWidth = width; + _screenHeight = height; + + free(_gameScreenRaw); + + _gameScreenRaw = (byte *)malloc(width * height); + bzero(_gameScreenRaw, width * height); + + //free(_overlayBuffer); + + int fullSize = _screenWidth * _screenHeight * sizeof(OverlayColor); + //_overlayBuffer = (OverlayColor *)malloc(fullSize); + clearOverlay(); + + free(_gameScreenConverted); + + _gameScreenConverted = (uint16 *)malloc(fullSize); + bzero(_gameScreenConverted, fullSize); + + iPhone_initSurface(width, height); + + if (_overlayBuffer == NULL) { + _overlayHeight = iPhone_getScreenHeight(); + _overlayWidth = iPhone_getScreenWidth(); + + printf("Overlay: (%u x %u)\n", _overlayWidth, _overlayHeight); + _overlayBuffer = new OverlayColor[_overlayHeight * _overlayWidth]; + } + + _fullScreenIsDirty = false; + dirtyFullScreen(); + _mouseVisible = false; + _mouseCursorPaletteEnabled = false; + _screenChangeCount++; + updateScreen(); +} + +int16 OSystem_IPHONE::getHeight() { + return _screenHeight; +} + +int16 OSystem_IPHONE::getWidth() { + return _screenWidth; +} + +void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { + assert(start + num <= 256); + const byte *b = colors; + + for (uint i = start; i < start + num; ++i) { + _gamePalette[i] = Graphics::RGBToColor >(b[0], b[1], b[2]); + _gamePaletteRGBA5551[i] = Graphics::RGBToColor >(b[0], b[1], b[2]); + b += 3; + } + + dirtyFullScreen(); +} + +void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) { + assert(start + num <= 256); + byte *b = colors; + + for (uint i = start; i < start + num; ++i) { + Graphics::colorToRGB >(_gamePalette[i], b[0], b[1], b[2]); + b += 3; + } +} + +void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) { + //printf("copyRectToScreen(%i, %i, %i, %i)\n", x, y, w, h); + //Clip the coordinates + if (x < 0) { + w += x; + buf -= x; + x = 0; + } + + if (y < 0) { + h += y; + buf -= y * pitch; + y = 0; + } + + if (w > _screenWidth - x) { + w = _screenWidth - x; + } + + if (h > _screenHeight - y) { + h = _screenHeight - y; + } + + if (w <= 0 || h <= 0) + return; + + if (!_fullScreenIsDirty) { + _dirtyRects.push_back(Common::Rect(x, y, x + w, y + h)); + } + + + byte *dst = _gameScreenRaw + y * _screenWidth + x; + if (_screenWidth == pitch && pitch == w) + memcpy(dst, buf, h * w); + else { + do { + memcpy(dst, buf, w); + buf += pitch; + dst += _screenWidth; + } while (--h); + } +} + +void OSystem_IPHONE::updateScreen() { + //printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size()); + + if (_dirtyRects.size() == 0 && _dirtyOverlayRects.size() == 0 && !_mouseDirty) + return; + + internUpdateScreen(); + _mouseDirty = false; + _fullScreenIsDirty = false; + _fullScreenOverlayIsDirty = false; + + iPhone_updateScreen(_mouseX, _mouseY); +} + +void OSystem_IPHONE::internUpdateScreen() { + if (_mouseNeedTextureUpdate) { + updateMouseTexture(); + _mouseNeedTextureUpdate = false; + } + + while (_dirtyRects.size()) { + Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1); + + //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); + drawDirtyRect(dirtyRect); + updateHardwareSurfaceForRect(dirtyRect); + } + + if (_overlayVisible) { + while (_dirtyOverlayRects.size()) { + Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1); + + //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); + drawDirtyOverlayRect(dirtyRect); + } + } +} + +void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { + int h = dirtyRect.bottom - dirtyRect.top; + int w = dirtyRect.right - dirtyRect.left; + + byte *src = &_gameScreenRaw[dirtyRect.top * _screenWidth + dirtyRect.left]; + uint16 *dst = &_gameScreenConverted[dirtyRect.top * _screenWidth + dirtyRect.left]; + for (int y = h; y > 0; y--) { + for (int x = w; x > 0; x--) + *dst++ = _gamePalette[*src++]; + + dst += _screenWidth - w; + src += _screenWidth - w; + } +} + +void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) { + iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); +} + +void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) { + iPhone_updateScreenRect(_gameScreenConverted, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom); +} + +Graphics::Surface *OSystem_IPHONE::lockScreen() { + //printf("lockScreen()\n"); + + _framebuffer.pixels = _gameScreenRaw; + _framebuffer.w = _screenWidth; + _framebuffer.h = _screenHeight; + _framebuffer.pitch = _screenWidth; + _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8(); + + return &_framebuffer; +} + +void OSystem_IPHONE::unlockScreen() { + //printf("unlockScreen()\n"); + dirtyFullScreen(); +} + +void OSystem_IPHONE::setShakePos(int shakeOffset) { + //printf("setShakePos(%i)\n", shakeOffset); + iPhone_setShakeOffset(shakeOffset); + // HACK: We use this to force a redraw. + _mouseDirty = true; +} + +void OSystem_IPHONE::showOverlay() { + //printf("showOverlay()\n"); + _overlayVisible = true; + dirtyFullOverlayScreen(); + updateScreen(); + iPhone_enableOverlay(true); +} + +void OSystem_IPHONE::hideOverlay() { + //printf("hideOverlay()\n"); + _overlayVisible = false; + _dirtyOverlayRects.clear(); + dirtyFullScreen(); + iPhone_enableOverlay(false); +} + +void OSystem_IPHONE::clearOverlay() { + //printf("clearOverlay()\n"); + bzero(_overlayBuffer, _overlayWidth * _overlayHeight * sizeof(OverlayColor)); + dirtyFullOverlayScreen(); +} + +void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) { + //printf("grabOverlay()\n"); + int h = _overlayHeight; + OverlayColor *src = _overlayBuffer; + + do { + memcpy(buf, src, _overlayWidth * sizeof(OverlayColor)); + src += _overlayWidth; + buf += pitch; + } while (--h); +} + +void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x, int y, int w, int h) { + //printf("copyRectToOverlay(buf, pitch=%i, x=%i, y=%i, w=%i, h=%i)\n", pitch, x, y, w, h); + + //Clip the coordinates + if (x < 0) { + w += x; + buf -= x; + x = 0; + } + + if (y < 0) { + h += y; + buf -= y * pitch; + y = 0; + } + + if (w > _overlayWidth - x) + w = _overlayWidth - x; + + if (h > _overlayHeight - y) + h = _overlayHeight - y; + + if (w <= 0 || h <= 0) + return; + + if (!_fullScreenOverlayIsDirty) { + _dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h)); + } + + OverlayColor *dst = _overlayBuffer + (y * _overlayWidth + x); + if (_overlayWidth == pitch && pitch == w) + memcpy(dst, buf, h * w * sizeof(OverlayColor)); + else { + do { + memcpy(dst, buf, w * sizeof(OverlayColor)); + buf += pitch; + dst += _overlayWidth; + } while (--h); + } +} + +int16 OSystem_IPHONE::getOverlayHeight() { + return _overlayHeight; +} + +int16 OSystem_IPHONE::getOverlayWidth() { + return _overlayWidth; +} + +bool OSystem_IPHONE::showMouse(bool visible) { + bool last = _mouseVisible; + _mouseVisible = visible; + iPhone_showCursor(visible); + _mouseDirty = true; + + return last; +} + +void OSystem_IPHONE::warpMouse(int x, int y) { + //printf("warpMouse()\n"); + + _mouseX = x; + _mouseY = y; + _mouseDirty = true; +} + +void OSystem_IPHONE::dirtyFullScreen() { + if (!_fullScreenIsDirty) { + _dirtyRects.clear(); + _dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight)); + _fullScreenIsDirty = true; + } +} + +void OSystem_IPHONE::dirtyFullOverlayScreen() { + if (!_fullScreenOverlayIsDirty) { + _dirtyOverlayRects.clear(); + _dirtyOverlayRects.push_back(Common::Rect(0, 0, _overlayWidth, _overlayHeight)); + _fullScreenOverlayIsDirty = true; + } +} + +void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { + //printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale); + + if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) { + free(_mouseBuf); + _mouseBuf = NULL; + } + + if (_mouseBuf == NULL) + _mouseBuf = (byte *)malloc(w * h); + + _mouseWidth = w; + _mouseHeight = h; + + _mouseHotspotX = hotspotX; + _mouseHotspotY = hotspotY; + + _mouseKeyColor = (byte)keycolor; + + memcpy(_mouseBuf, buf, w * h); + + _mouseDirty = true; + _mouseNeedTextureUpdate = true; +} + +void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num) { + assert(start + num <= 256); + + for (uint i = start; i < start + num; ++i, colors += 3) + _mouseCursorPalette[i] = Graphics::RGBToColor >(colors[0], colors[1], colors[2]); + + // FIXME: This is just stupid, our client code seems to assume that this + // automatically enables the cursor palette. + _mouseCursorPaletteEnabled = true; + + if (_mouseCursorPaletteEnabled) + _mouseDirty = _mouseNeedTextureUpdate = true; +} + +void OSystem_IPHONE::updateMouseTexture() { + int texWidth = getSizeNextPOT(_mouseWidth); + int texHeight = getSizeNextPOT(_mouseHeight); + int bufferSize = texWidth * texHeight * sizeof(int16); + uint16 *mouseBuf = (uint16 *)malloc(bufferSize); + memset(mouseBuf, 0, bufferSize); + + const uint16 *palette; + if (_mouseCursorPaletteEnabled) + palette = _mouseCursorPalette; + else + palette = _gamePaletteRGBA5551; + + for (uint x = 0; x < _mouseWidth; ++x) { + for (uint y = 0; y < _mouseHeight; ++y) { + const byte color = _mouseBuf[y * _mouseWidth + x]; + if (color != _mouseKeyColor) + mouseBuf[y * texWidth + x] = palette[color] | 0x1; + else + mouseBuf[y * texWidth + x] = 0x0; + } + } + + iPhone_setMouseCursor(mouseBuf, _mouseWidth, _mouseHeight, _mouseHotspotX, _mouseHotspotY); +} -- cgit v1.2.3 From e83e31c2cc90a5311c839903b0a120eacf3dde20 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 02:02:14 +0100 Subject: IPHONE: Move mouse coordinate conversion code to iPhoneView. --- backends/platform/iphone/iphone_video.mm | 128 +++++++++++++++---------------- 1 file changed, 64 insertions(+), 64 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index b6636e6f9a..e461691454 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -184,64 +184,6 @@ const char *iPhone_getDocumentsDir() { return [documentsDirectory UTF8String]; } -/** - * Converts portrait mode coordinates into rotated mode coordinates. - */ -static bool convertToRotatedCoords(UIDeviceOrientation orientation, CGPoint point, CGPoint *result) { - switch (orientation) { - case UIDeviceOrientationLandscapeLeft: - result->x = point.y; - result->y = _renderBufferWidth - point.x; - return true; - - case UIDeviceOrientationLandscapeRight: - result->x = _renderBufferHeight - point.y; - result->y = point.x; - return true; - - case UIDeviceOrientationPortrait: - result->x = point.x; - result->y = point.y; - return true; - - default: - return false; - } -} - -static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int *x, int *y) { - if (!convertToRotatedCoords(orientation, point, &point)) - return false; - - CGRect *area; - int width, height, offsetY; - if (_overlayIsEnabled) { - area = &_overlayRect; - width = _videoContext.overlayWidth; - height = _videoContext.overlayHeight; - offsetY = _scaledShakeOffsetY; - } else { - area = &_gameScreenRect; - width = _videoContext.screenWidth; - height = _videoContext.screenHeight; - offsetY = _videoContext.shakeOffsetY; - } - - point.x = (point.x - CGRectGetMinX(*area)) / CGRectGetWidth(*area); - point.y = (point.y - CGRectGetMinY(*area)) / CGRectGetHeight(*area); - - *x = (int)(point.x * width); - // offsetY describes the translation of the screen in the upward direction, - // thus we need to add it here. - *y = (int)(point.y * height + offsetY); - - // Clip coordinates - if (*x < 0 || *x > CGRectGetWidth(*area) || *y < 0 || *y > CGRectGetHeight(*area)) - return false; - - return true; -} - @implementation iPhoneView + (Class)layerClass { @@ -722,6 +664,64 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int * [_events addObject: event]; } +/** + * Converts portrait mode coordinates into rotated mode coordinates. + */ +- (bool)convertToRotatedCoords:(CGPoint)point result:(CGPoint *)result { + switch (_orientation) { + case UIDeviceOrientationLandscapeLeft: + result->x = point.y; + result->y = _renderBufferWidth - point.x; + return true; + + case UIDeviceOrientationLandscapeRight: + result->x = _renderBufferHeight - point.y; + result->y = point.x; + return true; + + case UIDeviceOrientationPortrait: + result->x = point.x; + result->y = point.y; + return true; + + default: + return false; + } +} + +- (bool)getMouseCoords:(CGPoint)point eventX:(int *)x eventY:(int *)y { + if (![self convertToRotatedCoords:point result:&point]) + return false; + + CGRect *area; + int width, height, offsetY; + if (_overlayIsEnabled) { + area = &_overlayRect; + width = _videoContext.overlayWidth; + height = _videoContext.overlayHeight; + offsetY = _scaledShakeOffsetY; + } else { + area = &_gameScreenRect; + width = _videoContext.screenWidth; + height = _videoContext.screenHeight; + offsetY = _videoContext.shakeOffsetY; + } + + point.x = (point.x - CGRectGetMinX(*area)) / CGRectGetWidth(*area); + point.y = (point.y - CGRectGetMinY(*area)) / CGRectGetHeight(*area); + + *x = (int)(point.x * width); + // offsetY describes the translation of the screen in the upward direction, + // thus we need to add it here. + *y = (int)(point.y * height + offsetY); + + // Clip coordinates + if (*x < 0 || *x > CGRectGetWidth(*area) || *y < 0 || *y > CGRectGetHeight(*area)) + return false; + + return true; +} + - (void)deviceOrientationChanged:(UIDeviceOrientation)orientation { switch (orientation) { case UIDeviceOrientationLandscapeLeft: @@ -752,7 +752,7 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int * case 1: { UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self]; - if (!getMouseCoords(_orientation, point, &x, &y)) + if (![self getMouseCoords:point eventX:&x eventY:&y]) return; _firstTouch = touch; @@ -770,7 +770,7 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int * case 2: { UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self]; - if (!getMouseCoords(_orientation, point, &x, &y)) + if (![self getMouseCoords:point eventX:&x eventY:&y]) return; _secondTouch = touch; @@ -794,7 +794,7 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int * for (UITouch *touch in touches) { if (touch == _firstTouch) { CGPoint point = [touch locationInView:self]; - if (!getMouseCoords(_orientation, point, &x, &y)) + if (![self getMouseCoords:point eventX:&x eventY:&y]) return; [self addEvent: @@ -807,7 +807,7 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int * ]; } else if (touch == _secondTouch) { CGPoint point = [touch locationInView:self]; - if (!getMouseCoords(_orientation, point, &x, &y)) + if (![self getMouseCoords:point eventX:&x eventY:&y]) return; [self addEvent: @@ -830,7 +830,7 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int * case 1: { UITouch *touch = [[allTouches allObjects] objectAtIndex:0]; CGPoint point = [touch locationInView:self]; - if (!getMouseCoords(_orientation, point, &x, &y)) + if (![self getMouseCoords:point eventX:&x eventY:&y]) return; [self addEvent: @@ -847,7 +847,7 @@ static bool getMouseCoords(UIDeviceOrientation orientation, CGPoint point, int * case 2: { UITouch *touch = [[allTouches allObjects] objectAtIndex:1]; CGPoint point = [touch locationInView:self]; - if (!getMouseCoords(_orientation, point, &x, &y)) + if (![self getMouseCoords:point eventX:&x eventY:&y]) return; [self addEvent: -- cgit v1.2.3 From e1edb20fed788aafc70f70448957b03b4f8f237d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 02:04:40 +0100 Subject: IPHONE: Move VideoContext definition to iphone_common.h. --- backends/platform/iphone/iphone_common.h | 18 ++++++++++++++++++ backends/platform/iphone/iphone_video.h | 18 ------------------ 2 files changed, 18 insertions(+), 18 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 5a46a6dde6..044b279386 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -55,6 +55,24 @@ enum GraphicsModes { kGraphicsModeNone = 1 }; +struct VideoContext { + // Game screen state + int screenWidth, screenHeight; + + // Overlay state + int overlayWidth, overlayHeight; + + // Mouse cursor state + int mouseX, mouseY; + int mouseHotspotX, mouseHotspotY; + int mouseWidth, mouseHeight; + bool mouseIsVisible; + + // Misc state + GraphicsModes graphicsMode; + int shakeOffsetY; +}; + // On the ObjC side void iPhone_setGraphicsMode(GraphicsModes mode); void iPhone_updateScreen(int mouseX, int mouseY); diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 733851f8b7..2677267171 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -34,24 +34,6 @@ #include "iphone_keyboard.h" #include "iphone_common.h" -struct VideoContext { - // Game screen state - int screenWidth, screenHeight; - - // Overlay state - int overlayWidth, overlayHeight; - - // Mouse cursor state - int mouseX, mouseY; - int mouseHotspotX, mouseHotspotY; - int mouseWidth, mouseHeight; - bool mouseIsVisible; - - // Misc state - GraphicsModes graphicsMode; - int shakeOffsetY; -}; - @interface iPhoneView : UIView { NSMutableArray *_events; SoftKeyboard *_keyboardView; -- cgit v1.2.3 From ab15435ad0aac842ab8321b833cae4e7459df01d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 02:08:12 +0100 Subject: IPHONE: Move overlay visibility status to VideoContext. --- backends/platform/iphone/iphone_common.h | 3 ++- backends/platform/iphone/iphone_video.mm | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 044b279386..2696888f87 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -60,6 +60,7 @@ struct VideoContext { int screenWidth, screenHeight; // Overlay state + bool overlayVisible; int overlayWidth, overlayHeight; // Mouse cursor state @@ -85,7 +86,7 @@ const char *iPhone_getDocumentsDir(); bool iPhone_isHighResDevice(); int iPhone_getScreenHeight(); int iPhone_getScreenWidth(); -void iPhone_enableOverlay(int state); +void iPhone_enableOverlay(bool state); void iPhone_showCursor(int state); void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int hotspotX, int hotspotY); diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index e461691454..a4de970420 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -37,7 +37,6 @@ static int _overlayTexHeight = 0; static CGRect _overlayRect; static int _needsScreenUpdate = 0; -static int _overlayIsEnabled = 0; static UITouch *_firstTouch = NULL; static UITouch *_secondTouch = NULL; @@ -93,8 +92,8 @@ void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int ho [sharedInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; } -void iPhone_enableOverlay(int state) { - _overlayIsEnabled = state; +void iPhone_enableOverlay(bool state) { + _videoContext.overlayVisible = state; [sharedInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; } @@ -272,6 +271,7 @@ const char *iPhone_getDocumentsDir() { _mouseCursorTexture = 0; _videoContext.graphicsMode = kGraphicsModeLinear; + _videoContext.overlayVisible = false; _gameScreenVertCoords[0] = _gameScreenVertCoords[1] = _gameScreenVertCoords[2] = _gameScreenVertCoords[3] = @@ -363,7 +363,7 @@ const char *iPhone_getDocumentsDir() { [self updateMainSurface]; - if (_overlayIsEnabled) + if (_videoContext.overlayVisible) [self updateOverlaySurface]; if (_videoContext.mouseIsVisible) @@ -422,7 +422,7 @@ const char *iPhone_getDocumentsDir() { CGRect *rect; int maxWidth, maxHeight; - if (!_overlayIsEnabled) { + if (!_videoContext.overlayVisible) { rect = &_gameScreenRect; maxWidth = _videoContext.screenWidth; maxHeight = _videoContext.screenHeight; @@ -695,7 +695,7 @@ const char *iPhone_getDocumentsDir() { CGRect *area; int width, height, offsetY; - if (_overlayIsEnabled) { + if (_videoContext.overlayVisible) { area = &_overlayRect; width = _videoContext.overlayWidth; height = _videoContext.overlayHeight; -- cgit v1.2.3 From 99ffbfedbcee50d46c49fdd2f78a409a51c91e3b Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 02:25:26 +0100 Subject: IPHONE: Use VideoContext in OSystem_IPHONE. --- backends/platform/iphone/osys_events.cpp | 50 ++++++------- backends/platform/iphone/osys_main.cpp | 13 ++-- backends/platform/iphone/osys_main.h | 13 +--- backends/platform/iphone/osys_video.mm | 120 +++++++++++++++---------------- 4 files changed, 95 insertions(+), 101 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/osys_events.cpp b/backends/platform/iphone/osys_events.cpp index c167da35e6..94ef565317 100644 --- a/backends/platform/iphone/osys_events.cpp +++ b/backends/platform/iphone/osys_events.cpp @@ -122,8 +122,8 @@ bool OSystem_IPHONE::handleEvent_mouseDown(Common::Event &event, int x, int y) { if (_mouseClickAndDragEnabled) { event.type = Common::EVENT_LBUTTONDOWN; - event.mouse.x = _mouseX; - event.mouse.y = _mouseY; + event.mouse.x = _videoContext.mouseX; + event.mouse.y = _videoContext.mouseY; return true; } else { _lastMouseDown = getMillis(); @@ -140,17 +140,17 @@ bool OSystem_IPHONE::handleEvent_mouseUp(Common::Event &event, int x, int y) { return false; } else if (_mouseClickAndDragEnabled) { event.type = Common::EVENT_LBUTTONUP; - event.mouse.x = _mouseX; - event.mouse.y = _mouseY; + event.mouse.x = _videoContext.mouseX; + event.mouse.y = _videoContext.mouseY; } else { if (getMillis() - _lastMouseDown < 250) { event.type = Common::EVENT_LBUTTONDOWN; - event.mouse.x = _mouseX; - event.mouse.y = _mouseY; + event.mouse.x = _videoContext.mouseX; + event.mouse.y = _videoContext.mouseY; _queuedInputEvent.type = Common::EVENT_LBUTTONUP; - _queuedInputEvent.mouse.x = _mouseX; - _queuedInputEvent.mouse.y = _mouseY; + _queuedInputEvent.mouse.x = _videoContext.mouseX; + _queuedInputEvent.mouse.y = _videoContext.mouseY; _lastMouseTap = getMillis(); _queuedEventTime = _lastMouseTap + kQueuedInputEventDelay; } else @@ -167,12 +167,12 @@ bool OSystem_IPHONE::handleEvent_secondMouseDown(Common::Event &event, int x, in if (_mouseClickAndDragEnabled) { event.type = Common::EVENT_LBUTTONUP; - event.mouse.x = _mouseX; - event.mouse.y = _mouseY; + event.mouse.x = _videoContext.mouseX; + event.mouse.y = _videoContext.mouseY; _queuedInputEvent.type = Common::EVENT_RBUTTONDOWN; - _queuedInputEvent.mouse.x = _mouseX; - _queuedInputEvent.mouse.y = _mouseY; + _queuedInputEvent.mouse.x = _videoContext.mouseX; + _queuedInputEvent.mouse.y = _videoContext.mouseY; } else return false; @@ -184,7 +184,7 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int if (curTime - _lastSecondaryDown < 400) { //printf("Right tap!\n"); - if (curTime - _lastSecondaryTap < 400 && !_overlayVisible) { + if (curTime - _lastSecondaryTap < 400 && !_videoContext.overlayVisible) { //printf("Right escape!\n"); event.type = Common::EVENT_KEYDOWN; _queuedInputEvent.type = Common::EVENT_KEYUP; @@ -197,11 +197,11 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int } else if (!_mouseClickAndDragEnabled) { //printf("Rightclick!\n"); event.type = Common::EVENT_RBUTTONDOWN; - event.mouse.x = _mouseX; - event.mouse.y = _mouseY; + event.mouse.x = _videoContext.mouseX; + event.mouse.y = _videoContext.mouseY; _queuedInputEvent.type = Common::EVENT_RBUTTONUP; - _queuedInputEvent.mouse.x = _mouseX; - _queuedInputEvent.mouse.y = _mouseY; + _queuedInputEvent.mouse.x = _videoContext.mouseX; + _queuedInputEvent.mouse.y = _videoContext.mouseY; _lastSecondaryTap = curTime; _queuedEventTime = curTime + kQueuedInputEventDelay; } else { @@ -211,8 +211,8 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int } if (_mouseClickAndDragEnabled) { event.type = Common::EVENT_RBUTTONUP; - event.mouse.x = _mouseX; - event.mouse.y = _mouseY; + event.mouse.x = _videoContext.mouseX; + event.mouse.y = _videoContext.mouseY; } return true; @@ -234,11 +234,11 @@ bool OSystem_IPHONE::handleEvent_mouseDragged(Common::Event &event, int x, int y _lastPadX = x; _lastPadY = y; - mouseNewPosX = (int)(_mouseX - deltaX / 0.5f); - mouseNewPosY = (int)(_mouseY - deltaY / 0.5f); + mouseNewPosX = (int)(_videoContext.mouseX - deltaX / 0.5f); + mouseNewPosY = (int)(_videoContext.mouseY - deltaY / 0.5f); - int widthCap = _overlayVisible ? _overlayWidth : _screenWidth; - int heightCap = _overlayVisible ? _overlayHeight : _screenHeight; + int widthCap = _videoContext.overlayVisible ? _videoContext.overlayWidth : _videoContext.screenWidth; + int heightCap = _videoContext.overlayVisible ? _videoContext.overlayHeight : _videoContext.screenHeight; if (mouseNewPosX < 0) mouseNewPosX = 0; @@ -350,10 +350,10 @@ void OSystem_IPHONE::handleEvent_orientationChanged(int orientation) { if (_screenOrientation != newOrientation) { _screenOrientation = newOrientation; - iPhone_initSurface(_screenWidth, _screenHeight); + iPhone_initSurface(_videoContext.screenWidth, _videoContext.screenHeight); dirtyFullScreen(); - if (_overlayVisible) + if (_videoContext.overlayVisible) dirtyFullOverlayScreen(); updateScreen(); } diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 2bdc09c9ce..9e73fe7756 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -55,18 +55,21 @@ SoundProc OSystem_IPHONE::s_soundCallback = NULL; void *OSystem_IPHONE::s_soundParam = NULL; OSystem_IPHONE::OSystem_IPHONE() : - _mixer(NULL), _gameScreenRaw(NULL), - _overlayVisible(false), _gameScreenConverted(NULL), - _mouseHeight(0), _mouseWidth(0), _mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0), + _mixer(NULL), _gameScreenRaw(NULL), _gameScreenConverted(NULL), + _mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0), _mouseNeedTextureUpdate(false), _secondaryTapped(false), _lastSecondaryTap(0), _screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false), _gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false), _mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0), - _overlayHeight(0), _overlayWidth(0), _overlayBuffer(0), _mouseCursorPaletteEnabled(false), - _currentGraphicsMode(kGraphicsModeLinear) { + _overlayBuffer(0), _mouseCursorPaletteEnabled(false) { _queuedInputEvent.type = Common::EVENT_INVALID; _touchpadModeEnabled = !iPhone_isHighResDevice(); _fsFactory = new POSIXFilesystemFactory(); + + _videoContext.mouseWidth = _videoContext.mouseHeight = 0; + _videoContext.overlayWidth = _videoContext.overlayHeight = 0; + _videoContext.overlayVisible = false; + _videoContext.graphicsMode = kGraphicsModeLinear; } OSystem_IPHONE::~OSystem_IPHONE() { diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index e4b3d358d5..f654537ac6 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -59,15 +59,13 @@ protected: static SoundProc s_soundCallback; static void *s_soundParam; - int _currentGraphicsMode; - Audio::MixerImpl *_mixer; + VideoContext _videoContext; + Graphics::Surface _framebuffer; byte *_gameScreenRaw; OverlayColor *_overlayBuffer; - uint16 _overlayHeight; - uint16 _overlayWidth; uint16 *_gameScreenConverted; @@ -75,21 +73,14 @@ protected: uint16 _gamePalette[256]; // For use with the mouse texture uint16 _gamePaletteRGBA5551[256]; - bool _overlayVisible; - uint16 _screenWidth; - uint16 _screenHeight; struct timeval _startTime; uint32 _timeSuspended; - bool _mouseVisible; bool _mouseCursorPaletteEnabled; uint16 _mouseCursorPalette[256]; byte *_mouseBuf; byte _mouseKeyColor; - uint _mouseWidth, _mouseHeight; - uint _mouseX, _mouseY; - int _mouseHotspotX, _mouseHotspotY; bool _mouseDirty; bool _mouseNeedTextureUpdate; long _lastMouseDown; diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index e26c360c82..bfa96c33e4 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -38,7 +38,7 @@ bool OSystem_IPHONE::setGraphicsMode(int mode) { switch (mode) { case kGraphicsModeNone: case kGraphicsModeLinear: - _currentGraphicsMode = mode; + _videoContext.graphicsMode = (GraphicsModes)mode; iPhone_setGraphicsMode((GraphicsModes)mode); return true; @@ -48,14 +48,14 @@ bool OSystem_IPHONE::setGraphicsMode(int mode) { } int OSystem_IPHONE::getGraphicsMode() const { - return _currentGraphicsMode; + return _videoContext.graphicsMode; } void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) { //printf("initSize(%i, %i)\n", width, height); - _screenWidth = width; - _screenHeight = height; + _videoContext.screenWidth = width; + _videoContext.screenHeight = height; free(_gameScreenRaw); @@ -64,7 +64,7 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm //free(_overlayBuffer); - int fullSize = _screenWidth * _screenHeight * sizeof(OverlayColor); + int fullSize = _videoContext.screenWidth * _videoContext.screenHeight * sizeof(OverlayColor); //_overlayBuffer = (OverlayColor *)malloc(fullSize); clearOverlay(); @@ -76,27 +76,27 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm iPhone_initSurface(width, height); if (_overlayBuffer == NULL) { - _overlayHeight = iPhone_getScreenHeight(); - _overlayWidth = iPhone_getScreenWidth(); + _videoContext.overlayHeight = iPhone_getScreenHeight(); + _videoContext.overlayWidth = iPhone_getScreenWidth(); - printf("Overlay: (%u x %u)\n", _overlayWidth, _overlayHeight); - _overlayBuffer = new OverlayColor[_overlayHeight * _overlayWidth]; + printf("Overlay: (%u x %u)\n", _videoContext.overlayWidth, _videoContext.overlayHeight); + _overlayBuffer = new OverlayColor[_videoContext.overlayHeight * _videoContext.overlayWidth]; } _fullScreenIsDirty = false; dirtyFullScreen(); - _mouseVisible = false; + _videoContext.mouseIsVisible = false; _mouseCursorPaletteEnabled = false; _screenChangeCount++; updateScreen(); } int16 OSystem_IPHONE::getHeight() { - return _screenHeight; + return _videoContext.screenHeight; } int16 OSystem_IPHONE::getWidth() { - return _screenWidth; + return _videoContext.screenWidth; } void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { @@ -137,12 +137,12 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, y = 0; } - if (w > _screenWidth - x) { - w = _screenWidth - x; + if (w > _videoContext.screenWidth - x) { + w = _videoContext.screenWidth - x; } - if (h > _screenHeight - y) { - h = _screenHeight - y; + if (h > _videoContext.screenHeight - y) { + h = _videoContext.screenHeight - y; } if (w <= 0 || h <= 0) @@ -153,14 +153,14 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, } - byte *dst = _gameScreenRaw + y * _screenWidth + x; - if (_screenWidth == pitch && pitch == w) + byte *dst = _gameScreenRaw + y * _videoContext.screenWidth + x; + if (_videoContext.screenWidth == pitch && pitch == w) memcpy(dst, buf, h * w); else { do { memcpy(dst, buf, w); buf += pitch; - dst += _screenWidth; + dst += _videoContext.screenWidth; } while (--h); } } @@ -176,7 +176,7 @@ void OSystem_IPHONE::updateScreen() { _fullScreenIsDirty = false; _fullScreenOverlayIsDirty = false; - iPhone_updateScreen(_mouseX, _mouseY); + iPhone_updateScreen(_videoContext.mouseX, _videoContext.mouseY); } void OSystem_IPHONE::internUpdateScreen() { @@ -193,7 +193,7 @@ void OSystem_IPHONE::internUpdateScreen() { updateHardwareSurfaceForRect(dirtyRect); } - if (_overlayVisible) { + if (_videoContext.overlayVisible) { while (_dirtyOverlayRects.size()) { Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1); @@ -207,14 +207,14 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { int h = dirtyRect.bottom - dirtyRect.top; int w = dirtyRect.right - dirtyRect.left; - byte *src = &_gameScreenRaw[dirtyRect.top * _screenWidth + dirtyRect.left]; - uint16 *dst = &_gameScreenConverted[dirtyRect.top * _screenWidth + dirtyRect.left]; + byte *src = &_gameScreenRaw[dirtyRect.top * _videoContext.screenWidth + dirtyRect.left]; + uint16 *dst = &_gameScreenConverted[dirtyRect.top * _videoContext.screenWidth + dirtyRect.left]; for (int y = h; y > 0; y--) { for (int x = w; x > 0; x--) *dst++ = _gamePalette[*src++]; - dst += _screenWidth - w; - src += _screenWidth - w; + dst += _videoContext.screenWidth - w; + src += _videoContext.screenWidth - w; } } @@ -230,9 +230,9 @@ Graphics::Surface *OSystem_IPHONE::lockScreen() { //printf("lockScreen()\n"); _framebuffer.pixels = _gameScreenRaw; - _framebuffer.w = _screenWidth; - _framebuffer.h = _screenHeight; - _framebuffer.pitch = _screenWidth; + _framebuffer.w = _videoContext.screenWidth; + _framebuffer.h = _videoContext.screenHeight; + _framebuffer.pitch = _videoContext.screenWidth; _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8(); return &_framebuffer; @@ -252,7 +252,7 @@ void OSystem_IPHONE::setShakePos(int shakeOffset) { void OSystem_IPHONE::showOverlay() { //printf("showOverlay()\n"); - _overlayVisible = true; + _videoContext.overlayVisible = true; dirtyFullOverlayScreen(); updateScreen(); iPhone_enableOverlay(true); @@ -260,7 +260,7 @@ void OSystem_IPHONE::showOverlay() { void OSystem_IPHONE::hideOverlay() { //printf("hideOverlay()\n"); - _overlayVisible = false; + _videoContext.overlayVisible = false; _dirtyOverlayRects.clear(); dirtyFullScreen(); iPhone_enableOverlay(false); @@ -268,18 +268,18 @@ void OSystem_IPHONE::hideOverlay() { void OSystem_IPHONE::clearOverlay() { //printf("clearOverlay()\n"); - bzero(_overlayBuffer, _overlayWidth * _overlayHeight * sizeof(OverlayColor)); + bzero(_overlayBuffer, _videoContext.overlayWidth * _videoContext.overlayHeight * sizeof(OverlayColor)); dirtyFullOverlayScreen(); } void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) { //printf("grabOverlay()\n"); - int h = _overlayHeight; + int h = _videoContext.overlayHeight; OverlayColor *src = _overlayBuffer; do { - memcpy(buf, src, _overlayWidth * sizeof(OverlayColor)); - src += _overlayWidth; + memcpy(buf, src, _videoContext.overlayWidth * sizeof(OverlayColor)); + src += _videoContext.overlayWidth; buf += pitch; } while (--h); } @@ -300,11 +300,11 @@ void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x y = 0; } - if (w > _overlayWidth - x) - w = _overlayWidth - x; + if (w > _videoContext.overlayWidth - x) + w = _videoContext.overlayWidth - x; - if (h > _overlayHeight - y) - h = _overlayHeight - y; + if (h > _videoContext.overlayHeight - y) + h = _videoContext.overlayHeight - y; if (w <= 0 || h <= 0) return; @@ -313,29 +313,29 @@ void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x _dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h)); } - OverlayColor *dst = _overlayBuffer + (y * _overlayWidth + x); - if (_overlayWidth == pitch && pitch == w) + OverlayColor *dst = _overlayBuffer + (y * _videoContext.overlayWidth + x); + if (_videoContext.overlayWidth == pitch && pitch == w) memcpy(dst, buf, h * w * sizeof(OverlayColor)); else { do { memcpy(dst, buf, w * sizeof(OverlayColor)); buf += pitch; - dst += _overlayWidth; + dst += _videoContext.overlayWidth; } while (--h); } } int16 OSystem_IPHONE::getOverlayHeight() { - return _overlayHeight; + return _videoContext.overlayHeight; } int16 OSystem_IPHONE::getOverlayWidth() { - return _overlayWidth; + return _videoContext.overlayWidth; } bool OSystem_IPHONE::showMouse(bool visible) { - bool last = _mouseVisible; - _mouseVisible = visible; + bool last = _videoContext.mouseIsVisible; + _videoContext.mouseIsVisible = visible; iPhone_showCursor(visible); _mouseDirty = true; @@ -345,15 +345,15 @@ bool OSystem_IPHONE::showMouse(bool visible) { void OSystem_IPHONE::warpMouse(int x, int y) { //printf("warpMouse()\n"); - _mouseX = x; - _mouseY = y; + _videoContext.mouseX = x; + _videoContext.mouseY = y; _mouseDirty = true; } void OSystem_IPHONE::dirtyFullScreen() { if (!_fullScreenIsDirty) { _dirtyRects.clear(); - _dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight)); + _dirtyRects.push_back(Common::Rect(0, 0, _videoContext.screenWidth, _videoContext.screenHeight)); _fullScreenIsDirty = true; } } @@ -361,7 +361,7 @@ void OSystem_IPHONE::dirtyFullScreen() { void OSystem_IPHONE::dirtyFullOverlayScreen() { if (!_fullScreenOverlayIsDirty) { _dirtyOverlayRects.clear(); - _dirtyOverlayRects.push_back(Common::Rect(0, 0, _overlayWidth, _overlayHeight)); + _dirtyOverlayRects.push_back(Common::Rect(0, 0, _videoContext.overlayWidth, _videoContext.overlayHeight)); _fullScreenOverlayIsDirty = true; } } @@ -369,7 +369,7 @@ void OSystem_IPHONE::dirtyFullOverlayScreen() { void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { //printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale); - if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) { + if (_mouseBuf != NULL && (_videoContext.mouseWidth != w || _videoContext.mouseHeight != h)) { free(_mouseBuf); _mouseBuf = NULL; } @@ -377,11 +377,11 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot if (_mouseBuf == NULL) _mouseBuf = (byte *)malloc(w * h); - _mouseWidth = w; - _mouseHeight = h; + _videoContext.mouseWidth = w; + _videoContext.mouseHeight = h; - _mouseHotspotX = hotspotX; - _mouseHotspotY = hotspotY; + _videoContext.mouseHotspotX = hotspotX; + _videoContext.mouseHotspotY = hotspotY; _mouseKeyColor = (byte)keycolor; @@ -406,8 +406,8 @@ void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num) } void OSystem_IPHONE::updateMouseTexture() { - int texWidth = getSizeNextPOT(_mouseWidth); - int texHeight = getSizeNextPOT(_mouseHeight); + int texWidth = getSizeNextPOT(_videoContext.mouseWidth); + int texHeight = getSizeNextPOT(_videoContext.mouseHeight); int bufferSize = texWidth * texHeight * sizeof(int16); uint16 *mouseBuf = (uint16 *)malloc(bufferSize); memset(mouseBuf, 0, bufferSize); @@ -418,9 +418,9 @@ void OSystem_IPHONE::updateMouseTexture() { else palette = _gamePaletteRGBA5551; - for (uint x = 0; x < _mouseWidth; ++x) { - for (uint y = 0; y < _mouseHeight; ++y) { - const byte color = _mouseBuf[y * _mouseWidth + x]; + for (uint x = 0; x < _videoContext.mouseWidth; ++x) { + for (uint y = 0; y < _videoContext.mouseHeight; ++y) { + const byte color = _mouseBuf[y * _videoContext.mouseWidth + x]; if (color != _mouseKeyColor) mouseBuf[y * texWidth + x] = palette[color] | 0x1; else @@ -428,5 +428,5 @@ void OSystem_IPHONE::updateMouseTexture() { } } - iPhone_setMouseCursor(mouseBuf, _mouseWidth, _mouseHeight, _mouseHotspotX, _mouseHotspotY); + iPhone_setMouseCursor(mouseBuf, _videoContext.mouseWidth, _videoContext.mouseHeight, _videoContext.mouseHotspotX, _videoContext.mouseHotspotY); } -- cgit v1.2.3 From e00fc73eb891b7f460e2377fed7f12224a9103cf Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 02:26:54 +0100 Subject: IPHONE: Silence a few signed/unsigned integer comparison warnings. --- backends/platform/iphone/iphone_common.h | 8 ++++---- backends/platform/iphone/osys_video.mm | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 2696888f87..93637a3bb5 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -57,16 +57,16 @@ enum GraphicsModes { struct VideoContext { // Game screen state - int screenWidth, screenHeight; + uint screenWidth, screenHeight; // Overlay state bool overlayVisible; - int overlayWidth, overlayHeight; + uint overlayWidth, overlayHeight; // Mouse cursor state - int mouseX, mouseY; + uint mouseX, mouseY; int mouseHotspotX, mouseHotspotY; - int mouseWidth, mouseHeight; + uint mouseWidth, mouseHeight; bool mouseIsVisible; // Misc state diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index bfa96c33e4..574fc07d0d 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -137,11 +137,11 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, y = 0; } - if (w > _videoContext.screenWidth - x) { + if (w > (int)_videoContext.screenWidth - x) { w = _videoContext.screenWidth - x; } - if (h > _videoContext.screenHeight - y) { + if (h > (int)_videoContext.screenHeight - y) { h = _videoContext.screenHeight - y; } @@ -154,7 +154,7 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, byte *dst = _gameScreenRaw + y * _videoContext.screenWidth + x; - if (_videoContext.screenWidth == pitch && pitch == w) + if ((int)_videoContext.screenWidth == pitch && pitch == w) memcpy(dst, buf, h * w); else { do { @@ -300,10 +300,10 @@ void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x y = 0; } - if (w > _videoContext.overlayWidth - x) + if (w > (int)_videoContext.overlayWidth - x) w = _videoContext.overlayWidth - x; - if (h > _videoContext.overlayHeight - y) + if (h > (int)_videoContext.overlayHeight - y) h = _videoContext.overlayHeight - y; if (w <= 0 || h <= 0) @@ -314,7 +314,7 @@ void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x } OverlayColor *dst = _overlayBuffer + (y * _videoContext.overlayWidth + x); - if (_videoContext.overlayWidth == pitch && pitch == w) + if ((int)_videoContext.overlayWidth == pitch && pitch == w) memcpy(dst, buf, h * w * sizeof(OverlayColor)); else { do { -- cgit v1.2.3 From 5ae958bcf3a1dc4d7be093eac99eb0d5145c8c7e Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 03:13:09 +0100 Subject: IPHONE: Let iPhoneView and OSystem_IPHONE share the same VideoContext. This allows for better sharing between the current video state in the view and the OSystem implementation. This also gets rid of most C interface functions for calling ObjC code. --- backends/platform/iphone/iphone_common.h | 15 +-- backends/platform/iphone/iphone_video.h | 6 ++ backends/platform/iphone/iphone_video.mm | 76 ++++------------ backends/platform/iphone/osys_events.cpp | 50 +++++----- backends/platform/iphone/osys_main.cpp | 6 +- backends/platform/iphone/osys_main.h | 5 +- backends/platform/iphone/osys_video.mm | 151 ++++++++++++++++--------------- 7 files changed, 136 insertions(+), 173 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 93637a3bb5..18821e697f 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -75,20 +75,13 @@ struct VideoContext { }; // On the ObjC side -void iPhone_setGraphicsMode(GraphicsModes mode); -void iPhone_updateScreen(int mouseX, int mouseY); -void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2); -void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2); -void iPhone_initSurface(int width, int height); -void iPhone_setShakeOffset(int offset); +void iPhone_updateScreen(); +void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width); +void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width); bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY); const char *iPhone_getDocumentsDir(); bool iPhone_isHighResDevice(); -int iPhone_getScreenHeight(); -int iPhone_getScreenWidth(); -void iPhone_enableOverlay(bool state); -void iPhone_showCursor(int state); -void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int hotspotX, int hotspotY); +void iPhone_setMouseCursor(unsigned short *buffer); uint getSizeNextPOT(uint size); diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 2677267171..1d9d7e7d35 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -35,6 +35,8 @@ #include "iphone_common.h" @interface iPhoneView : UIView { + VideoContext _videoContext; + NSMutableArray *_events; SoftKeyboard *_keyboardView; @@ -56,6 +58,8 @@ - (id)initWithFrame:(struct CGRect)frame; +- (VideoContext *)getVideoContext; + - (void)drawRect:(CGRect)frame; - (void)initSurface; @@ -81,4 +85,6 @@ @end +extern iPhoneView *g_iPhoneViewInstance; + #endif diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index a4de970420..387ed7252f 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -22,7 +22,7 @@ #include "iphone_video.h" -static iPhoneView *sharedInstance = nil; +iPhoneView *g_iPhoneViewInstance = nil; static int _fullWidth; static int _fullHeight; static CGRect _gameScreenRect; @@ -48,8 +48,6 @@ static GLint _renderBufferHeight; static int _scaledShakeOffsetY; -static VideoContext _videoContext; - #if 0 static long lastTick = 0; static int frames = 0; @@ -70,83 +68,36 @@ int printOglError(const char *file, int line) { return retCode; } -void iPhone_setGraphicsMode(GraphicsModes mode) { - _videoContext.graphicsMode = mode; - - [sharedInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES]; -} - -void iPhone_showCursor(int state) { - _videoContext.mouseIsVisible = state; -} - -void iPhone_setMouseCursor(unsigned short *buffer, int width, int height, int hotspotX, int hotspotY) { +void iPhone_setMouseCursor(unsigned short *buffer) { _mouseCursor = buffer; - - _videoContext.mouseWidth = width; - _videoContext.mouseHeight = height; - - _videoContext.mouseHotspotX = hotspotX; - _videoContext.mouseHotspotY = hotspotY; - - [sharedInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; -} - -void iPhone_enableOverlay(bool state) { - _videoContext.overlayVisible = state; - - [sharedInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; -} - -int iPhone_getScreenHeight() { - return _videoContext.overlayHeight; -} - -int iPhone_getScreenWidth() { - return _videoContext.overlayWidth; + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; } bool iPhone_isHighResDevice() { return _fullHeight > 480; } -void iPhone_updateScreen(int mouseX, int mouseY) { +void iPhone_updateScreen() { //printf("Mouse: (%i, %i)\n", mouseX, mouseY); - - _videoContext.mouseX = mouseX; - _videoContext.mouseY = mouseY; - if (!_needsScreenUpdate) { _needsScreenUpdate = 1; - [sharedInstance performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO]; + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO]; } } -void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2) { +void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width) { for (int y = y1; y < y2; ++y) - memcpy(&_gameScreenTextureBuffer[(y * _gameScreenTextureWidth + x1) * 2], &screen[y * _videoContext.screenWidth + x1], (x2 - x1) * 2); + memcpy(&_gameScreenTextureBuffer[(y * _gameScreenTextureWidth + x1) * 2], &screen[y * width + x1], (x2 - x1) * 2); } -void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2) { +void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width) { //printf("Overlaywidth: %u, fullwidth %u\n", _videoContext.overlayWidth, _fullWidth); for (int y = y1; y < y2; ++y) - memcpy(&_overlayTexBuffer[(y * _overlayTexWidth + x1) * 2], &screen[y * _videoContext.overlayWidth + x1], (x2 - x1) * 2); -} - -void iPhone_initSurface(int width, int height) { - _videoContext.screenWidth = width; - _videoContext.screenHeight = height; - _videoContext.shakeOffsetY = 0; - [sharedInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES]; -} - -void iPhone_setShakeOffset(int offset) { - _videoContext.shakeOffsetY = offset; - [sharedInstance performSelectorOnMainThread:@selector(setViewTransformation) withObject:nil waitUntilDone: YES]; + memcpy(&_overlayTexBuffer[(y * _overlayTexWidth + x1) * 2], &screen[y * width + x1], (x2 - x1) * 2); } bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY) { - id event = [sharedInstance getEvent]; + id event = [g_iPhoneViewInstance getEvent]; if (event == nil) { return false; } @@ -189,6 +140,10 @@ const char *iPhone_getDocumentsDir() { return [CAEAGLLayer class]; } +- (VideoContext *)getVideoContext { + return &_videoContext; +} + - (void)createContext { CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; @@ -263,13 +218,14 @@ const char *iPhone_getDocumentsDir() { _fullWidth = (int)frame.size.width; _fullHeight = (int)frame.size.height; - sharedInstance = self; + g_iPhoneViewInstance = self; _keyboardView = nil; _screenTexture = 0; _overlayTexture = 0; _mouseCursorTexture = 0; + memset(&_videoContext, 0, sizeof(_videoContext)); _videoContext.graphicsMode = kGraphicsModeLinear; _videoContext.overlayVisible = false; diff --git a/backends/platform/iphone/osys_events.cpp b/backends/platform/iphone/osys_events.cpp index 94ef565317..85efbda208 100644 --- a/backends/platform/iphone/osys_events.cpp +++ b/backends/platform/iphone/osys_events.cpp @@ -122,8 +122,8 @@ bool OSystem_IPHONE::handleEvent_mouseDown(Common::Event &event, int x, int y) { if (_mouseClickAndDragEnabled) { event.type = Common::EVENT_LBUTTONDOWN; - event.mouse.x = _videoContext.mouseX; - event.mouse.y = _videoContext.mouseY; + event.mouse.x = _videoContext->mouseX; + event.mouse.y = _videoContext->mouseY; return true; } else { _lastMouseDown = getMillis(); @@ -140,17 +140,17 @@ bool OSystem_IPHONE::handleEvent_mouseUp(Common::Event &event, int x, int y) { return false; } else if (_mouseClickAndDragEnabled) { event.type = Common::EVENT_LBUTTONUP; - event.mouse.x = _videoContext.mouseX; - event.mouse.y = _videoContext.mouseY; + event.mouse.x = _videoContext->mouseX; + event.mouse.y = _videoContext->mouseY; } else { if (getMillis() - _lastMouseDown < 250) { event.type = Common::EVENT_LBUTTONDOWN; - event.mouse.x = _videoContext.mouseX; - event.mouse.y = _videoContext.mouseY; + event.mouse.x = _videoContext->mouseX; + event.mouse.y = _videoContext->mouseY; _queuedInputEvent.type = Common::EVENT_LBUTTONUP; - _queuedInputEvent.mouse.x = _videoContext.mouseX; - _queuedInputEvent.mouse.y = _videoContext.mouseY; + _queuedInputEvent.mouse.x = _videoContext->mouseX; + _queuedInputEvent.mouse.y = _videoContext->mouseY; _lastMouseTap = getMillis(); _queuedEventTime = _lastMouseTap + kQueuedInputEventDelay; } else @@ -167,12 +167,12 @@ bool OSystem_IPHONE::handleEvent_secondMouseDown(Common::Event &event, int x, in if (_mouseClickAndDragEnabled) { event.type = Common::EVENT_LBUTTONUP; - event.mouse.x = _videoContext.mouseX; - event.mouse.y = _videoContext.mouseY; + event.mouse.x = _videoContext->mouseX; + event.mouse.y = _videoContext->mouseY; _queuedInputEvent.type = Common::EVENT_RBUTTONDOWN; - _queuedInputEvent.mouse.x = _videoContext.mouseX; - _queuedInputEvent.mouse.y = _videoContext.mouseY; + _queuedInputEvent.mouse.x = _videoContext->mouseX; + _queuedInputEvent.mouse.y = _videoContext->mouseY; } else return false; @@ -184,7 +184,7 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int if (curTime - _lastSecondaryDown < 400) { //printf("Right tap!\n"); - if (curTime - _lastSecondaryTap < 400 && !_videoContext.overlayVisible) { + if (curTime - _lastSecondaryTap < 400 && !_videoContext->overlayVisible) { //printf("Right escape!\n"); event.type = Common::EVENT_KEYDOWN; _queuedInputEvent.type = Common::EVENT_KEYUP; @@ -197,11 +197,11 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int } else if (!_mouseClickAndDragEnabled) { //printf("Rightclick!\n"); event.type = Common::EVENT_RBUTTONDOWN; - event.mouse.x = _videoContext.mouseX; - event.mouse.y = _videoContext.mouseY; + event.mouse.x = _videoContext->mouseX; + event.mouse.y = _videoContext->mouseY; _queuedInputEvent.type = Common::EVENT_RBUTTONUP; - _queuedInputEvent.mouse.x = _videoContext.mouseX; - _queuedInputEvent.mouse.y = _videoContext.mouseY; + _queuedInputEvent.mouse.x = _videoContext->mouseX; + _queuedInputEvent.mouse.y = _videoContext->mouseY; _lastSecondaryTap = curTime; _queuedEventTime = curTime + kQueuedInputEventDelay; } else { @@ -211,8 +211,8 @@ bool OSystem_IPHONE::handleEvent_secondMouseUp(Common::Event &event, int x, int } if (_mouseClickAndDragEnabled) { event.type = Common::EVENT_RBUTTONUP; - event.mouse.x = _videoContext.mouseX; - event.mouse.y = _videoContext.mouseY; + event.mouse.x = _videoContext->mouseX; + event.mouse.y = _videoContext->mouseY; } return true; @@ -234,11 +234,11 @@ bool OSystem_IPHONE::handleEvent_mouseDragged(Common::Event &event, int x, int y _lastPadX = x; _lastPadY = y; - mouseNewPosX = (int)(_videoContext.mouseX - deltaX / 0.5f); - mouseNewPosY = (int)(_videoContext.mouseY - deltaY / 0.5f); + mouseNewPosX = (int)(_videoContext->mouseX - deltaX / 0.5f); + mouseNewPosY = (int)(_videoContext->mouseY - deltaY / 0.5f); - int widthCap = _videoContext.overlayVisible ? _videoContext.overlayWidth : _videoContext.screenWidth; - int heightCap = _videoContext.overlayVisible ? _videoContext.overlayHeight : _videoContext.screenHeight; + int widthCap = _videoContext->overlayVisible ? _videoContext->overlayWidth : _videoContext->screenWidth; + int heightCap = _videoContext->overlayVisible ? _videoContext->overlayHeight : _videoContext->screenHeight; if (mouseNewPosX < 0) mouseNewPosX = 0; @@ -350,10 +350,10 @@ void OSystem_IPHONE::handleEvent_orientationChanged(int orientation) { if (_screenOrientation != newOrientation) { _screenOrientation = newOrientation; - iPhone_initSurface(_videoContext.screenWidth, _videoContext.screenHeight); + updateOutputSurface(); dirtyFullScreen(); - if (_videoContext.overlayVisible) + if (_videoContext->overlayVisible) dirtyFullOverlayScreen(); updateScreen(); } diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 9e73fe7756..368434c476 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -65,11 +65,7 @@ OSystem_IPHONE::OSystem_IPHONE() : _queuedInputEvent.type = Common::EVENT_INVALID; _touchpadModeEnabled = !iPhone_isHighResDevice(); _fsFactory = new POSIXFilesystemFactory(); - - _videoContext.mouseWidth = _videoContext.mouseHeight = 0; - _videoContext.overlayWidth = _videoContext.overlayHeight = 0; - _videoContext.overlayVisible = false; - _videoContext.graphicsMode = kGraphicsModeLinear; + initVideoContext(); } OSystem_IPHONE::~OSystem_IPHONE() { diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index f654537ac6..39395ac99a 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -61,7 +61,7 @@ protected: Audio::MixerImpl *_mixer; - VideoContext _videoContext; + VideoContext *_videoContext; Graphics::Surface _framebuffer; byte *_gameScreenRaw; @@ -183,6 +183,9 @@ public: virtual void logMessage(LogMessageType::Type type, const char *message); protected: + void initVideoContext(); + void updateOutputSurface(); + void internUpdateScreen(); void dirtyFullScreen(); void dirtyFullOverlayScreen(); diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index 574fc07d0d..a40fcae78c 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -25,11 +25,16 @@ #include "osys_main.h" +#include "iphone_video.h" + +void OSystem_IPHONE::initVideoContext() { + _videoContext = [g_iPhoneViewInstance getVideoContext]; +} + const OSystem::GraphicsMode *OSystem_IPHONE::getSupportedGraphicsModes() const { return s_supportedGraphicsModes; } - int OSystem_IPHONE::getDefaultGraphicsMode() const { return kGraphicsModeLinear; } @@ -38,8 +43,8 @@ bool OSystem_IPHONE::setGraphicsMode(int mode) { switch (mode) { case kGraphicsModeNone: case kGraphicsModeLinear: - _videoContext.graphicsMode = (GraphicsModes)mode; - iPhone_setGraphicsMode((GraphicsModes)mode); + _videoContext->graphicsMode = (GraphicsModes)mode; + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES]; return true; default: @@ -48,14 +53,15 @@ bool OSystem_IPHONE::setGraphicsMode(int mode) { } int OSystem_IPHONE::getGraphicsMode() const { - return _videoContext.graphicsMode; + return _videoContext->graphicsMode; } void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) { //printf("initSize(%i, %i)\n", width, height); - _videoContext.screenWidth = width; - _videoContext.screenHeight = height; + _videoContext->screenWidth = width; + _videoContext->screenHeight = height; + _videoContext->shakeOffsetY = 0; free(_gameScreenRaw); @@ -64,39 +70,42 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm //free(_overlayBuffer); - int fullSize = _videoContext.screenWidth * _videoContext.screenHeight * sizeof(OverlayColor); + int fullSize = _videoContext->screenWidth * _videoContext->screenHeight * sizeof(OverlayColor); //_overlayBuffer = (OverlayColor *)malloc(fullSize); - clearOverlay(); free(_gameScreenConverted); _gameScreenConverted = (uint16 *)malloc(fullSize); bzero(_gameScreenConverted, fullSize); - iPhone_initSurface(width, height); + updateOutputSurface(); if (_overlayBuffer == NULL) { - _videoContext.overlayHeight = iPhone_getScreenHeight(); - _videoContext.overlayWidth = iPhone_getScreenWidth(); - - printf("Overlay: (%u x %u)\n", _videoContext.overlayWidth, _videoContext.overlayHeight); - _overlayBuffer = new OverlayColor[_videoContext.overlayHeight * _videoContext.overlayWidth]; + printf("Overlay: (%u x %u)\n", _videoContext->overlayWidth, _videoContext->overlayHeight); + _overlayBuffer = new OverlayColor[_videoContext->overlayHeight * _videoContext->overlayWidth]; } + clearOverlay(); + _fullScreenIsDirty = false; dirtyFullScreen(); - _videoContext.mouseIsVisible = false; + _videoContext->mouseIsVisible = false; _mouseCursorPaletteEnabled = false; _screenChangeCount++; + updateScreen(); } +void OSystem_IPHONE::updateOutputSurface() { + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(initSurface) withObject:nil waitUntilDone: YES]; +} + int16 OSystem_IPHONE::getHeight() { - return _videoContext.screenHeight; + return _videoContext->screenHeight; } int16 OSystem_IPHONE::getWidth() { - return _videoContext.screenWidth; + return _videoContext->screenWidth; } void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) { @@ -137,12 +146,12 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, y = 0; } - if (w > (int)_videoContext.screenWidth - x) { - w = _videoContext.screenWidth - x; + if (w > (int)_videoContext->screenWidth - x) { + w = _videoContext->screenWidth - x; } - if (h > (int)_videoContext.screenHeight - y) { - h = _videoContext.screenHeight - y; + if (h > (int)_videoContext->screenHeight - y) { + h = _videoContext->screenHeight - y; } if (w <= 0 || h <= 0) @@ -153,14 +162,14 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, } - byte *dst = _gameScreenRaw + y * _videoContext.screenWidth + x; - if ((int)_videoContext.screenWidth == pitch && pitch == w) + byte *dst = _gameScreenRaw + y * _videoContext->screenWidth + x; + if ((int)_videoContext->screenWidth == pitch && pitch == w) memcpy(dst, buf, h * w); else { do { memcpy(dst, buf, w); buf += pitch; - dst += _videoContext.screenWidth; + dst += _videoContext->screenWidth; } while (--h); } } @@ -176,7 +185,7 @@ void OSystem_IPHONE::updateScreen() { _fullScreenIsDirty = false; _fullScreenOverlayIsDirty = false; - iPhone_updateScreen(_videoContext.mouseX, _videoContext.mouseY); + iPhone_updateScreen(); } void OSystem_IPHONE::internUpdateScreen() { @@ -193,7 +202,7 @@ void OSystem_IPHONE::internUpdateScreen() { updateHardwareSurfaceForRect(dirtyRect); } - if (_videoContext.overlayVisible) { + if (_videoContext->overlayVisible) { while (_dirtyOverlayRects.size()) { Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1); @@ -207,32 +216,32 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { int h = dirtyRect.bottom - dirtyRect.top; int w = dirtyRect.right - dirtyRect.left; - byte *src = &_gameScreenRaw[dirtyRect.top * _videoContext.screenWidth + dirtyRect.left]; - uint16 *dst = &_gameScreenConverted[dirtyRect.top * _videoContext.screenWidth + dirtyRect.left]; + byte *src = &_gameScreenRaw[dirtyRect.top * _videoContext->screenWidth + dirtyRect.left]; + uint16 *dst = &_gameScreenConverted[dirtyRect.top * _videoContext->screenWidth + dirtyRect.left]; for (int y = h; y > 0; y--) { for (int x = w; x > 0; x--) *dst++ = _gamePalette[*src++]; - dst += _videoContext.screenWidth - w; - src += _videoContext.screenWidth - w; + dst += _videoContext->screenWidth - w; + src += _videoContext->screenWidth - w; } } void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) { - iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); + iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom, _videoContext->overlayWidth); } void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) { - iPhone_updateScreenRect(_gameScreenConverted, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom); + iPhone_updateScreenRect(_gameScreenConverted, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom, _videoContext->screenWidth); } Graphics::Surface *OSystem_IPHONE::lockScreen() { //printf("lockScreen()\n"); _framebuffer.pixels = _gameScreenRaw; - _framebuffer.w = _videoContext.screenWidth; - _framebuffer.h = _videoContext.screenHeight; - _framebuffer.pitch = _videoContext.screenWidth; + _framebuffer.w = _videoContext->screenWidth; + _framebuffer.h = _videoContext->screenHeight; + _framebuffer.pitch = _videoContext->screenWidth; _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8(); return &_framebuffer; @@ -245,41 +254,42 @@ void OSystem_IPHONE::unlockScreen() { void OSystem_IPHONE::setShakePos(int shakeOffset) { //printf("setShakePos(%i)\n", shakeOffset); - iPhone_setShakeOffset(shakeOffset); + _videoContext->shakeOffsetY = shakeOffset; + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(setViewTransformation) withObject:nil waitUntilDone: YES]; // HACK: We use this to force a redraw. _mouseDirty = true; } void OSystem_IPHONE::showOverlay() { //printf("showOverlay()\n"); - _videoContext.overlayVisible = true; + _videoContext->overlayVisible = true; dirtyFullOverlayScreen(); updateScreen(); - iPhone_enableOverlay(true); + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; } void OSystem_IPHONE::hideOverlay() { //printf("hideOverlay()\n"); - _videoContext.overlayVisible = false; + _videoContext->overlayVisible = false; _dirtyOverlayRects.clear(); dirtyFullScreen(); - iPhone_enableOverlay(false); + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; } void OSystem_IPHONE::clearOverlay() { //printf("clearOverlay()\n"); - bzero(_overlayBuffer, _videoContext.overlayWidth * _videoContext.overlayHeight * sizeof(OverlayColor)); + bzero(_overlayBuffer, _videoContext->overlayWidth * _videoContext->overlayHeight * sizeof(OverlayColor)); dirtyFullOverlayScreen(); } void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) { //printf("grabOverlay()\n"); - int h = _videoContext.overlayHeight; + int h = _videoContext->overlayHeight; OverlayColor *src = _overlayBuffer; do { - memcpy(buf, src, _videoContext.overlayWidth * sizeof(OverlayColor)); - src += _videoContext.overlayWidth; + memcpy(buf, src, _videoContext->overlayWidth * sizeof(OverlayColor)); + src += _videoContext->overlayWidth; buf += pitch; } while (--h); } @@ -300,11 +310,11 @@ void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x y = 0; } - if (w > (int)_videoContext.overlayWidth - x) - w = _videoContext.overlayWidth - x; + if (w > (int)_videoContext->overlayWidth - x) + w = _videoContext->overlayWidth - x; - if (h > (int)_videoContext.overlayHeight - y) - h = _videoContext.overlayHeight - y; + if (h > (int)_videoContext->overlayHeight - y) + h = _videoContext->overlayHeight - y; if (w <= 0 || h <= 0) return; @@ -313,30 +323,29 @@ void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x _dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h)); } - OverlayColor *dst = _overlayBuffer + (y * _videoContext.overlayWidth + x); - if ((int)_videoContext.overlayWidth == pitch && pitch == w) + OverlayColor *dst = _overlayBuffer + (y * _videoContext->overlayWidth + x); + if ((int)_videoContext->overlayWidth == pitch && pitch == w) memcpy(dst, buf, h * w * sizeof(OverlayColor)); else { do { memcpy(dst, buf, w * sizeof(OverlayColor)); buf += pitch; - dst += _videoContext.overlayWidth; + dst += _videoContext->overlayWidth; } while (--h); } } int16 OSystem_IPHONE::getOverlayHeight() { - return _videoContext.overlayHeight; + return _videoContext->overlayHeight; } int16 OSystem_IPHONE::getOverlayWidth() { - return _videoContext.overlayWidth; + return _videoContext->overlayWidth; } bool OSystem_IPHONE::showMouse(bool visible) { - bool last = _videoContext.mouseIsVisible; - _videoContext.mouseIsVisible = visible; - iPhone_showCursor(visible); + bool last = _videoContext->mouseIsVisible; + _videoContext->mouseIsVisible = visible; _mouseDirty = true; return last; @@ -345,15 +354,15 @@ bool OSystem_IPHONE::showMouse(bool visible) { void OSystem_IPHONE::warpMouse(int x, int y) { //printf("warpMouse()\n"); - _videoContext.mouseX = x; - _videoContext.mouseY = y; + _videoContext->mouseX = x; + _videoContext->mouseY = y; _mouseDirty = true; } void OSystem_IPHONE::dirtyFullScreen() { if (!_fullScreenIsDirty) { _dirtyRects.clear(); - _dirtyRects.push_back(Common::Rect(0, 0, _videoContext.screenWidth, _videoContext.screenHeight)); + _dirtyRects.push_back(Common::Rect(0, 0, _videoContext->screenWidth, _videoContext->screenHeight)); _fullScreenIsDirty = true; } } @@ -361,7 +370,7 @@ void OSystem_IPHONE::dirtyFullScreen() { void OSystem_IPHONE::dirtyFullOverlayScreen() { if (!_fullScreenOverlayIsDirty) { _dirtyOverlayRects.clear(); - _dirtyOverlayRects.push_back(Common::Rect(0, 0, _videoContext.overlayWidth, _videoContext.overlayHeight)); + _dirtyOverlayRects.push_back(Common::Rect(0, 0, _videoContext->overlayWidth, _videoContext->overlayHeight)); _fullScreenOverlayIsDirty = true; } } @@ -369,7 +378,7 @@ void OSystem_IPHONE::dirtyFullOverlayScreen() { void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { //printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale); - if (_mouseBuf != NULL && (_videoContext.mouseWidth != w || _videoContext.mouseHeight != h)) { + if (_mouseBuf != NULL && (_videoContext->mouseWidth != w || _videoContext->mouseHeight != h)) { free(_mouseBuf); _mouseBuf = NULL; } @@ -377,11 +386,11 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot if (_mouseBuf == NULL) _mouseBuf = (byte *)malloc(w * h); - _videoContext.mouseWidth = w; - _videoContext.mouseHeight = h; + _videoContext->mouseWidth = w; + _videoContext->mouseHeight = h; - _videoContext.mouseHotspotX = hotspotX; - _videoContext.mouseHotspotY = hotspotY; + _videoContext->mouseHotspotX = hotspotX; + _videoContext->mouseHotspotY = hotspotY; _mouseKeyColor = (byte)keycolor; @@ -406,8 +415,8 @@ void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num) } void OSystem_IPHONE::updateMouseTexture() { - int texWidth = getSizeNextPOT(_videoContext.mouseWidth); - int texHeight = getSizeNextPOT(_videoContext.mouseHeight); + int texWidth = getSizeNextPOT(_videoContext->mouseWidth); + int texHeight = getSizeNextPOT(_videoContext->mouseHeight); int bufferSize = texWidth * texHeight * sizeof(int16); uint16 *mouseBuf = (uint16 *)malloc(bufferSize); memset(mouseBuf, 0, bufferSize); @@ -418,9 +427,9 @@ void OSystem_IPHONE::updateMouseTexture() { else palette = _gamePaletteRGBA5551; - for (uint x = 0; x < _videoContext.mouseWidth; ++x) { - for (uint y = 0; y < _videoContext.mouseHeight; ++y) { - const byte color = _mouseBuf[y * _videoContext.mouseWidth + x]; + for (uint x = 0; x < _videoContext->mouseWidth; ++x) { + for (uint y = 0; y < _videoContext->mouseHeight; ++y) { + const byte color = _mouseBuf[y * _videoContext->mouseWidth + x]; if (color != _mouseKeyColor) mouseBuf[y * texWidth + x] = palette[color] | 0x1; else @@ -428,5 +437,5 @@ void OSystem_IPHONE::updateMouseTexture() { } } - iPhone_setMouseCursor(mouseBuf, _videoContext.mouseWidth, _videoContext.mouseHeight, _videoContext.mouseHotspotX, _videoContext.mouseHotspotY); + iPhone_setMouseCursor(mouseBuf); } -- cgit v1.2.3 From a71a91db17969cc4149905697dd84e72b1baf330 Mon Sep 17 00:00:00 2001 From: Gavin Hayler Date: Thu, 23 Feb 2012 09:42:53 +0200 Subject: IPHONE: Add aspect ratio correction to iPhone --- backends/platform/iphone/iphone_common.h | 2 ++ backends/platform/iphone/iphone_video.mm | 28 +++++++++++++++++++++++++--- backends/platform/iphone/osys_main.cpp | 5 +++++ 3 files changed, 32 insertions(+), 3 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 18821e697f..d4c4cf3eb2 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -75,6 +75,8 @@ struct VideoContext { }; // On the ObjC side +void iPhone_setAspectRatioState(bool enable); +bool iPhone_getAspectRatioState(); void iPhone_updateScreen(); void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width); void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width); diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 387ed7252f..56c74b9ac5 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -53,6 +53,8 @@ static long lastTick = 0; static int frames = 0; #endif +static bool _aspectRatioCorrect = false; + #define printOpenGLError() printOglError(__FILE__, __LINE__) int printOglError(const char *file, int line) { @@ -73,6 +75,14 @@ void iPhone_setMouseCursor(unsigned short *buffer) { [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; } +void iPhone_setAspectRatioState(bool enable) { + _aspectRatioCorrect = enable; +} + +bool iPhone_getAspectRatioState() { + return _aspectRatioCorrect; +} + bool iPhone_isHighResDevice() { return _fullHeight > 480; } @@ -485,7 +495,7 @@ const char *iPhone_getDocumentsDir() { int screenWidth, screenHeight; [self setUpOrientation:[[UIDevice currentDevice] orientation] width:&screenWidth height:&screenHeight]; - + //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _videoContext.screenWidth, _videoContext.screenHeight, _gameScreenTextureWidth, _gameScreenTextureHeight); if (_screenTexture > 0) { @@ -516,10 +526,22 @@ const char *iPhone_getDocumentsDir() { [[_keyboardView inputView] removeFromSuperview]; } + float adjustedWidth = _videoContext.screenWidth; + float adjustedHeight = _videoContext.screenHeight; + if (_aspectRatioCorrect && ((_videoContext.screenWidth == 320 && _videoContext.screenHeight == 200) + || (_videoContext.screenWidth == 640 && _videoContext.screenHeight == 400)) ) { + if (_videoContext.screenHeight == 200) { + adjustedHeight = 240; + } + if (_videoContext.screenHeight == 400) { + adjustedHeight = 480; + } + } + float overlayPortraitRatio; if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation == UIDeviceOrientationLandscapeRight) { - GLfloat gameScreenRatio = (GLfloat)_videoContext.screenWidth / (GLfloat)_videoContext.screenHeight; + GLfloat gameScreenRatio = (GLfloat)adjustedWidth / (GLfloat)adjustedHeight; GLfloat screenRatio = (GLfloat)screenWidth / (GLfloat)screenHeight; // These are the width/height according to the portrait layout! @@ -548,7 +570,7 @@ const char *iPhone_getDocumentsDir() { _gameScreenRect = CGRectMake(xOffset, yOffset, rectWidth, rectHeight); overlayPortraitRatio = 1.0f; } else { - float ratio = (float)_videoContext.screenHeight / (float)_videoContext.screenWidth; + float ratio = (float)adjustedHeight / (float)adjustedWidth; int height = (int)(screenWidth * ratio); //printf("Making rect (%u, %u)\n", screenWidth, height); _gameScreenRect = CGRectMake(0, 0, screenWidth, height); diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 368434c476..3c9d2d949c 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -119,6 +119,9 @@ void OSystem_IPHONE::setFeatureState(Feature f, bool enable) { _mouseCursorPaletteEnabled = enable; } break; + case kFeatureAspectRatioCorrection: + iPhone_setAspectRatioState(enable); + break; default: break; @@ -129,6 +132,8 @@ bool OSystem_IPHONE::getFeatureState(Feature f) { switch (f) { case kFeatureCursorPalette: return _mouseCursorPaletteEnabled; + case kFeatureAspectRatioCorrection: + return iPhone_getAspectRatioState(); default: return false; -- cgit v1.2.3 From 97feac5342420653bb1f4a5fbca68a5aae6b09a8 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 20:59:26 +0100 Subject: IPHONE: Add a constructor to VideoContext. --- backends/platform/iphone/iphone_common.h | 6 ++++++ backends/platform/iphone/iphone_video.mm | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 18821e697f..f5111fbe8c 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -56,6 +56,12 @@ enum GraphicsModes { }; struct VideoContext { + VideoContext() : screenWidth(), screenHeight(), overlayVisible(false), + overlayWidth(), overlayHeight(), mouseX(), mouseY(), + mouseHotspotX(), mouseHotspotY(), mouseWidth(), mouseHeight(), + mouseIsVisible(), graphicsMode(kGraphicsModeLinear), shakeOffsetY() { + } + // Game screen state uint screenWidth, screenHeight; diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 387ed7252f..4442552c0d 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -225,10 +225,6 @@ const char *iPhone_getDocumentsDir() { _overlayTexture = 0; _mouseCursorTexture = 0; - memset(&_videoContext, 0, sizeof(_videoContext)); - _videoContext.graphicsMode = kGraphicsModeLinear; - _videoContext.overlayVisible = false; - _gameScreenVertCoords[0] = _gameScreenVertCoords[1] = _gameScreenVertCoords[2] = _gameScreenVertCoords[3] = _gameScreenVertCoords[4] = _gameScreenVertCoords[5] = -- cgit v1.2.3 From 2ab5958c93c19a0ea23b76c2360ca8ef4d905b94 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 21:20:24 +0100 Subject: IPHONE: Move screen and overlay texture buffer to VideoContext. --- backends/platform/iphone/iphone_common.h | 6 ++-- backends/platform/iphone/iphone_main.mm | 3 ++ backends/platform/iphone/iphone_video.mm | 58 +++++++++++--------------------- backends/platform/iphone/osys_video.mm | 16 +++++++-- 4 files changed, 40 insertions(+), 43 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index f5111fbe8c..6e97d9d853 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -23,6 +23,8 @@ #ifndef BACKENDS_PLATFORM_IPHONE_IPHONE_COMMON_H #define BACKENDS_PLATFORM_IPHONE_IPHONE_COMMON_H +#include "graphics/surface.h" + enum InputEvent { kInputMouseDown, kInputMouseUp, @@ -64,10 +66,12 @@ struct VideoContext { // Game screen state uint screenWidth, screenHeight; + Graphics::Surface screenTexture; // Overlay state bool overlayVisible; uint overlayWidth, overlayHeight; + Graphics::Surface overlayTexture; // Mouse cursor state uint mouseX, mouseY; @@ -82,8 +86,6 @@ struct VideoContext { // On the ObjC side void iPhone_updateScreen(); -void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width); -void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width); bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY); const char *iPhone_getDocumentsDir(); bool iPhone_isHighResDevice(); diff --git a/backends/platform/iphone/iphone_main.mm b/backends/platform/iphone/iphone_main.mm index 1559ef8a6e..20406e6342 100644 --- a/backends/platform/iphone/iphone_main.mm +++ b/backends/platform/iphone/iphone_main.mm @@ -20,6 +20,9 @@ * */ +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + #include #include diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 4442552c0d..7ae5dd6a7d 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -20,20 +20,18 @@ * */ +// Disable symbol overrides so that we can use system headers. +#define FORBIDDEN_SYMBOL_ALLOW_ALL + #include "iphone_video.h" +#include "graphics/colormasks.h" + iPhoneView *g_iPhoneViewInstance = nil; static int _fullWidth; static int _fullHeight; static CGRect _gameScreenRect; -static char *_gameScreenTextureBuffer = 0; -static int _gameScreenTextureWidth = 0; -static int _gameScreenTextureHeight = 0; - -static char *_overlayTexBuffer = 0; -static int _overlayTexWidth = 0; -static int _overlayTexHeight = 0; static CGRect _overlayRect; static int _needsScreenUpdate = 0; @@ -85,17 +83,6 @@ void iPhone_updateScreen() { } } -void iPhone_updateScreenRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width) { - for (int y = y1; y < y2; ++y) - memcpy(&_gameScreenTextureBuffer[(y * _gameScreenTextureWidth + x1) * 2], &screen[y * width + x1], (x2 - x1) * 2); -} - -void iPhone_updateOverlayRect(unsigned short *screen, int x1, int y1, int x2, int y2, int width) { - //printf("Overlaywidth: %u, fullwidth %u\n", _videoContext.overlayWidth, _fullWidth); - for (int y = y1; y < y2; ++y) - memcpy(&_overlayTexBuffer[(y * _overlayTexWidth + x1) * 2], &screen[y * width + x1], (x2 - x1) * 2); -} - bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY) { id event = [g_iPhoneViewInstance getEvent]; if (event == nil) { @@ -181,18 +168,16 @@ const char *iPhone_getDocumentsDir() { _videoContext.overlayHeight = _renderBufferWidth; _videoContext.overlayWidth = _renderBufferHeight; - _overlayTexWidth = getSizeNextPOT(_videoContext.overlayHeight); - _overlayTexHeight = getSizeNextPOT(_videoContext.overlayWidth); + uint overlayTextureWidth = getSizeNextPOT(_videoContext.overlayHeight); + uint overlayTextureHeight = getSizeNextPOT(_videoContext.overlayWidth); // Since the overlay size won't change the whole run, we can // precalculate the texture coordinates for the overlay texture here // and just use it later on. - _overlayTexCoords[2] = _overlayTexCoords[6] = _videoContext.overlayWidth / (GLfloat)_overlayTexWidth; - _overlayTexCoords[5] = _overlayTexCoords[7] = _videoContext.overlayHeight / (GLfloat)_overlayTexHeight; + _overlayTexCoords[2] = _overlayTexCoords[6] = _videoContext.overlayWidth / (GLfloat)overlayTextureWidth; + _overlayTexCoords[5] = _overlayTexCoords[7] = _videoContext.overlayHeight / (GLfloat)overlayTextureHeight; - int textureSize = _overlayTexWidth * _overlayTexHeight * 2; - _overlayTexBuffer = (char *)malloc(textureSize); - memset(_overlayTexBuffer, 0, textureSize); + _videoContext.overlayTexture.create(overlayTextureWidth, overlayTextureHeight, Graphics::createPixelFormat<5551>()); glViewport(0, 0, _renderBufferWidth, _renderBufferHeight); printOpenGLError(); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); printOpenGLError(); @@ -258,8 +243,8 @@ const char *iPhone_getDocumentsDir() { [_keyboardView dealloc]; } - free(_gameScreenTextureBuffer); - free(_overlayTexBuffer); + _videoContext.screenTexture.free(); + _videoContext.overlayTexture.free(); } - (void)drawRect:(CGRect)frame { @@ -348,7 +333,7 @@ const char *iPhone_getDocumentsDir() { // Unfortunately we have to update the whole texture every frame, since glTexSubImage2D is actually slower in all cases // due to the iPhone internals having to convert the whole texture back from its internal format when used. // In the future we could use several tiled textures instead. - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _gameScreenTextureWidth, _gameScreenTextureHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _gameScreenTextureBuffer); printOpenGLError(); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, _videoContext.screenTexture.w, _videoContext.screenTexture.h, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, _videoContext.screenTexture.pixels); printOpenGLError(); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); } @@ -357,7 +342,7 @@ const char *iPhone_getDocumentsDir() { glTexCoordPointer(2, GL_FLOAT, 0, _overlayTexCoords); printOpenGLError(); glBindTexture(GL_TEXTURE_2D, _overlayTexture); printOpenGLError(); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _overlayTexWidth, _overlayTexHeight, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _overlayTexBuffer); printOpenGLError(); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.overlayTexture.w, _videoContext.overlayTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.overlayTexture.pixels); printOpenGLError(); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); } @@ -473,17 +458,15 @@ const char *iPhone_getDocumentsDir() { } - (void)initSurface { - _gameScreenTextureWidth = getSizeNextPOT(_videoContext.screenWidth); - _gameScreenTextureHeight = getSizeNextPOT(_videoContext.screenHeight); + uint screenTexWidth = getSizeNextPOT(_videoContext.screenWidth); + uint screenTexHeight = getSizeNextPOT(_videoContext.screenHeight); - _gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _videoContext.screenWidth / (GLfloat)_gameScreenTextureWidth; - _gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _videoContext.screenHeight / (GLfloat)_gameScreenTextureHeight; + _gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _videoContext.screenWidth / (GLfloat)screenTexWidth; + _gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _videoContext.screenHeight / (GLfloat)screenTexHeight; int screenWidth, screenHeight; [self setUpOrientation:[[UIDevice currentDevice] orientation] width:&screenWidth height:&screenHeight]; - //printf("Window: (%d, %d), Surface: (%d, %d), Texture(%d, %d)\n", _fullWidth, _fullHeight, _videoContext.screenWidth, _videoContext.screenHeight, _gameScreenTextureWidth, _gameScreenTextureHeight); - if (_screenTexture > 0) { glDeleteTextures(1, &_screenTexture); printOpenGLError(); } @@ -498,10 +481,7 @@ const char *iPhone_getDocumentsDir() { glGenTextures(1, &_overlayTexture); printOpenGLError(); [self setFilterModeForTexture:_overlayTexture]; - free(_gameScreenTextureBuffer); - int textureSize = _gameScreenTextureWidth * _gameScreenTextureHeight * 2; - _gameScreenTextureBuffer = (char *)malloc(textureSize); - memset(_gameScreenTextureBuffer, 0, textureSize); + _videoContext.screenTexture.create(screenTexWidth, screenTexHeight, Graphics::createPixelFormat<565>()); glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index a40fcae78c..45f62377d4 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -228,11 +228,23 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { } void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) { - iPhone_updateOverlayRect(_overlayBuffer, dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom, _videoContext->overlayWidth); + const int x1 = dirtyRect.left; + const int y1 = dirtyRect.top; + const int x2 = dirtyRect.right; + const int y2 = dirtyRect.bottom; + + for (int y = y1; y < y2; ++y) + memcpy(_videoContext->overlayTexture.getBasePtr(x1, y), &_overlayBuffer[y * _videoContext->overlayWidth + x1], (x2 - x1) * 2); } void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) { - iPhone_updateScreenRect(_gameScreenConverted, updatedRect.left, updatedRect.top, updatedRect.right, updatedRect.bottom, _videoContext->screenWidth); + const int x1 = updatedRect.left; + const int y1 = updatedRect.top; + const int x2 = updatedRect.right; + const int y2 = updatedRect.bottom; + + for (int y = y1; y < y2; ++y) + memcpy(_videoContext->screenTexture.getBasePtr(x1, y), &_gameScreenConverted[y * _videoContext->screenWidth + x1], (x2 - x1) * 2); } Graphics::Surface *OSystem_IPHONE::lockScreen() { -- cgit v1.2.3 From 8edcedf3b65965df6ade9899a7a07855cf51195c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 21:34:12 +0100 Subject: IPHONE: Directly use the overlay's texture buffer instead of another intermediate buffer. --- backends/platform/iphone/osys_main.cpp | 2 +- backends/platform/iphone/osys_main.h | 2 -- backends/platform/iphone/osys_video.mm | 46 ++++++++++------------------------ 3 files changed, 14 insertions(+), 36 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 368434c476..e2de6ca478 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -61,7 +61,7 @@ OSystem_IPHONE::OSystem_IPHONE() : _screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false), _gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false), _mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0), - _overlayBuffer(0), _mouseCursorPaletteEnabled(false) { + _mouseCursorPaletteEnabled(false) { _queuedInputEvent.type = Common::EVENT_INVALID; _touchpadModeEnabled = !iPhone_isHighResDevice(); _fsFactory = new POSIXFilesystemFactory(); diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 39395ac99a..8b1365af30 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -65,7 +65,6 @@ protected: Graphics::Surface _framebuffer; byte *_gameScreenRaw; - OverlayColor *_overlayBuffer; uint16 *_gameScreenConverted; @@ -191,7 +190,6 @@ protected: void dirtyFullOverlayScreen(); void suspendLoop(); void drawDirtyRect(const Common::Rect &dirtyRect); - void drawDirtyOverlayRect(const Common::Rect &dirtyRect); void updateHardwareSurfaceForRect(const Common::Rect &updatedRect); void updateMouseTexture(); static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB); diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index 45f62377d4..8fc9535717 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -68,10 +68,7 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm _gameScreenRaw = (byte *)malloc(width * height); bzero(_gameScreenRaw, width * height); - //free(_overlayBuffer); - int fullSize = _videoContext->screenWidth * _videoContext->screenHeight * sizeof(OverlayColor); - //_overlayBuffer = (OverlayColor *)malloc(fullSize); free(_gameScreenConverted); @@ -80,11 +77,6 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm updateOutputSurface(); - if (_overlayBuffer == NULL) { - printf("Overlay: (%u x %u)\n", _videoContext->overlayWidth, _videoContext->overlayHeight); - _overlayBuffer = new OverlayColor[_videoContext->overlayHeight * _videoContext->overlayWidth]; - } - clearOverlay(); _fullScreenIsDirty = false; @@ -203,12 +195,14 @@ void OSystem_IPHONE::internUpdateScreen() { } if (_videoContext->overlayVisible) { - while (_dirtyOverlayRects.size()) { + // TODO: Implement dirty rect code + _dirtyOverlayRects.clear(); + /*while (_dirtyOverlayRects.size()) { Common::Rect dirtyRect = _dirtyOverlayRects.remove_at(_dirtyOverlayRects.size() - 1); //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); drawDirtyOverlayRect(dirtyRect); - } + }*/ } } @@ -227,16 +221,6 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { } } -void OSystem_IPHONE::drawDirtyOverlayRect(const Common::Rect &dirtyRect) { - const int x1 = dirtyRect.left; - const int y1 = dirtyRect.top; - const int x2 = dirtyRect.right; - const int y2 = dirtyRect.bottom; - - for (int y = y1; y < y2; ++y) - memcpy(_videoContext->overlayTexture.getBasePtr(x1, y), &_overlayBuffer[y * _videoContext->overlayWidth + x1], (x2 - x1) * 2); -} - void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) { const int x1 = updatedRect.left; const int y1 = updatedRect.top; @@ -290,18 +274,18 @@ void OSystem_IPHONE::hideOverlay() { void OSystem_IPHONE::clearOverlay() { //printf("clearOverlay()\n"); - bzero(_overlayBuffer, _videoContext->overlayWidth * _videoContext->overlayHeight * sizeof(OverlayColor)); + bzero(_videoContext->overlayTexture.getBasePtr(0, 0), _videoContext->overlayTexture.h * _videoContext->overlayTexture.pitch); dirtyFullOverlayScreen(); } void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) { //printf("grabOverlay()\n"); int h = _videoContext->overlayHeight; - OverlayColor *src = _overlayBuffer; + const byte *src = (const byte *)_videoContext->overlayTexture.getBasePtr(0, 0); do { memcpy(buf, src, _videoContext->overlayWidth * sizeof(OverlayColor)); - src += _videoContext->overlayWidth; + src += _videoContext->overlayTexture.pitch; buf += pitch; } while (--h); } @@ -335,16 +319,12 @@ void OSystem_IPHONE::copyRectToOverlay(const OverlayColor *buf, int pitch, int x _dirtyOverlayRects.push_back(Common::Rect(x, y, x + w, y + h)); } - OverlayColor *dst = _overlayBuffer + (y * _videoContext->overlayWidth + x); - if ((int)_videoContext->overlayWidth == pitch && pitch == w) - memcpy(dst, buf, h * w * sizeof(OverlayColor)); - else { - do { - memcpy(dst, buf, w * sizeof(OverlayColor)); - buf += pitch; - dst += _videoContext->overlayWidth; - } while (--h); - } + byte *dst = (byte *)_videoContext->overlayTexture.getBasePtr(x, y); + do { + memcpy(dst, buf, w * sizeof(OverlayColor)); + buf += pitch; + dst += _videoContext->overlayTexture.pitch; + } while (--h); } int16 OSystem_IPHONE::getOverlayHeight() { -- cgit v1.2.3 From 3f37842580ee0fe2456f301354d0366024cf3f2e Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 21:51:59 +0100 Subject: IPHONE: Directly use the game screen's texture buffer. This gets rid of another intermediate buffer. --- backends/platform/iphone/osys_main.cpp | 3 +-- backends/platform/iphone/osys_main.h | 3 --- backends/platform/iphone/osys_video.mm | 27 ++++++--------------------- 3 files changed, 7 insertions(+), 26 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index e2de6ca478..dabf73bf58 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -55,7 +55,7 @@ SoundProc OSystem_IPHONE::s_soundCallback = NULL; void *OSystem_IPHONE::s_soundParam = NULL; OSystem_IPHONE::OSystem_IPHONE() : - _mixer(NULL), _gameScreenRaw(NULL), _gameScreenConverted(NULL), + _mixer(NULL), _gameScreenRaw(NULL), _mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0), _mouseNeedTextureUpdate(false), _secondaryTapped(false), _lastSecondaryTap(0), _screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false), @@ -73,7 +73,6 @@ OSystem_IPHONE::~OSystem_IPHONE() { delete _mixer; free(_gameScreenRaw); - free(_gameScreenConverted); } int OSystem_IPHONE::timerHandler(int t) { diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 8b1365af30..180d3e9d06 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -66,8 +66,6 @@ protected: Graphics::Surface _framebuffer; byte *_gameScreenRaw; - uint16 *_gameScreenConverted; - // For use with the game texture uint16 _gamePalette[256]; // For use with the mouse texture @@ -190,7 +188,6 @@ protected: void dirtyFullOverlayScreen(); void suspendLoop(); void drawDirtyRect(const Common::Rect &dirtyRect); - void updateHardwareSurfaceForRect(const Common::Rect &updatedRect); void updateMouseTexture(); static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB); static int timerHandler(int t); diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index 8fc9535717..7e2b1eee07 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -68,13 +68,6 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm _gameScreenRaw = (byte *)malloc(width * height); bzero(_gameScreenRaw, width * height); - int fullSize = _videoContext->screenWidth * _videoContext->screenHeight * sizeof(OverlayColor); - - free(_gameScreenConverted); - - _gameScreenConverted = (uint16 *)malloc(fullSize); - bzero(_gameScreenConverted, fullSize); - updateOutputSurface(); clearOverlay(); @@ -191,7 +184,8 @@ void OSystem_IPHONE::internUpdateScreen() { //printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom); drawDirtyRect(dirtyRect); - updateHardwareSurfaceForRect(dirtyRect); + // TODO: Implement dirty rect code + //updateHardwareSurfaceForRect(dirtyRect); } if (_videoContext->overlayVisible) { @@ -210,27 +204,18 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { int h = dirtyRect.bottom - dirtyRect.top; int w = dirtyRect.right - dirtyRect.left; - byte *src = &_gameScreenRaw[dirtyRect.top * _videoContext->screenWidth + dirtyRect.left]; - uint16 *dst = &_gameScreenConverted[dirtyRect.top * _videoContext->screenWidth + dirtyRect.left]; + byte *src = &_gameScreenRaw[dirtyRect.top * _videoContext->screenWidth + dirtyRect.left]; + byte *dstRaw = (byte *)_videoContext->screenTexture.getBasePtr(dirtyRect.left, dirtyRect.top); for (int y = h; y > 0; y--) { + uint16 *dst = (uint16 *)dstRaw; for (int x = w; x > 0; x--) *dst++ = _gamePalette[*src++]; - dst += _videoContext->screenWidth - w; + dstRaw += _videoContext->screenTexture.pitch; src += _videoContext->screenWidth - w; } } -void OSystem_IPHONE::updateHardwareSurfaceForRect(const Common::Rect &updatedRect) { - const int x1 = updatedRect.left; - const int y1 = updatedRect.top; - const int x2 = updatedRect.right; - const int y2 = updatedRect.bottom; - - for (int y = y1; y < y2; ++y) - memcpy(_videoContext->screenTexture.getBasePtr(x1, y), &_gameScreenConverted[y * _videoContext->screenWidth + x1], (x2 - x1) * 2); -} - Graphics::Surface *OSystem_IPHONE::lockScreen() { //printf("lockScreen()\n"); -- cgit v1.2.3 From 4f85ad6b999851adedaed80d4406c09fe2d977a4 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Thu, 23 Feb 2012 21:55:36 +0100 Subject: IPHONE: Fix mouse coordinates for hi res games. --- backends/platform/iphone/iphone_video.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 7ae5dd6a7d..cdd8d68b31 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -648,7 +648,7 @@ const char *iPhone_getDocumentsDir() { *y = (int)(point.y * height + offsetY); // Clip coordinates - if (*x < 0 || *x > CGRectGetWidth(*area) || *y < 0 || *y > CGRectGetHeight(*area)) + if (*x < 0 || *x > width || *y < 0 || *y > height) return false; return true; -- cgit v1.2.3 From 5863f6a5565b22f6e92c1e1254d8e12651d24de4 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 24 Feb 2012 00:55:52 +0100 Subject: IPHONE: Add a mouse texture buffer surface to VideoContext. --- backends/platform/iphone/iphone_common.h | 2 +- backends/platform/iphone/iphone_video.mm | 17 ++++------------- backends/platform/iphone/osys_video.mm | 14 ++++++++------ 3 files changed, 13 insertions(+), 20 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 6e97d9d853..4dd9407064 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -78,6 +78,7 @@ struct VideoContext { int mouseHotspotX, mouseHotspotY; uint mouseWidth, mouseHeight; bool mouseIsVisible; + Graphics::Surface mouseTexture; // Misc state GraphicsModes graphicsMode; @@ -89,7 +90,6 @@ void iPhone_updateScreen(); bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY); const char *iPhone_getDocumentsDir(); bool iPhone_isHighResDevice(); -void iPhone_setMouseCursor(unsigned short *buffer); uint getSizeNextPOT(uint size); diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index cdd8d68b31..d7511c56d4 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -39,8 +39,6 @@ static int _needsScreenUpdate = 0; static UITouch *_firstTouch = NULL; static UITouch *_secondTouch = NULL; -static unsigned short *_mouseCursor = NULL; - static GLint _renderBufferWidth; static GLint _renderBufferHeight; @@ -66,11 +64,6 @@ int printOglError(const char *file, int line) { return retCode; } -void iPhone_setMouseCursor(unsigned short *buffer) { - _mouseCursor = buffer; - [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; -} - bool iPhone_isHighResDevice() { return _fullHeight > 480; } @@ -245,6 +238,7 @@ const char *iPhone_getDocumentsDir() { _videoContext.screenTexture.free(); _videoContext.overlayTexture.free(); + _videoContext.mouseTexture.free(); } - (void)drawRect:(CGRect)frame { @@ -318,10 +312,7 @@ const char *iPhone_getDocumentsDir() { } glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, getSizeNextPOT(_videoContext.mouseWidth), getSizeNextPOT(_videoContext.mouseHeight), 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _mouseCursor); printOpenGLError(); - - free(_mouseCursor); - _mouseCursor = NULL; + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.mouseTexture.w, _videoContext.mouseTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.mouseTexture.pixels); printOpenGLError(); } - (void)updateMainSurface { @@ -398,8 +389,8 @@ const char *iPhone_getDocumentsDir() { //printf("Cursor: width %u height %u\n", _videoContext.mouseWidth, _videoContext.mouseHeight); - float texWidth = _videoContext.mouseWidth / (float)getSizeNextPOT(_videoContext.mouseWidth); - float texHeight = _videoContext.mouseHeight / (float)getSizeNextPOT(_videoContext.mouseHeight); + float texWidth = _videoContext.mouseWidth / (float)_videoContext.mouseTexture.w; + float texHeight = _videoContext.mouseHeight / (float)_videoContext.mouseTexture.h; const GLfloat texCoords[] = { // Top left diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index 7e2b1eee07..6fa800a004 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -392,11 +392,12 @@ void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num) } void OSystem_IPHONE::updateMouseTexture() { - int texWidth = getSizeNextPOT(_videoContext->mouseWidth); - int texHeight = getSizeNextPOT(_videoContext->mouseHeight); - int bufferSize = texWidth * texHeight * sizeof(int16); - uint16 *mouseBuf = (uint16 *)malloc(bufferSize); - memset(mouseBuf, 0, bufferSize); + uint texWidth = getSizeNextPOT(_videoContext->mouseWidth); + uint texHeight = getSizeNextPOT(_videoContext->mouseHeight); + + Graphics::Surface &mouseTexture = _videoContext->mouseTexture; + if (mouseTexture.w != texWidth || mouseTexture.h != texHeight) + mouseTexture.create(texWidth, texHeight, Graphics::createPixelFormat<5551>()); const uint16 *palette; if (_mouseCursorPaletteEnabled) @@ -404,6 +405,7 @@ void OSystem_IPHONE::updateMouseTexture() { else palette = _gamePaletteRGBA5551; + uint16 *mouseBuf = (uint16 *)mouseTexture.getBasePtr(0, 0); for (uint x = 0; x < _videoContext->mouseWidth; ++x) { for (uint y = 0; y < _videoContext->mouseHeight; ++y) { const byte color = _mouseBuf[y * _videoContext->mouseWidth + x]; @@ -414,5 +416,5 @@ void OSystem_IPHONE::updateMouseTexture() { } } - iPhone_setMouseCursor(mouseBuf); + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursor) withObject:nil waitUntilDone: YES]; } -- cgit v1.2.3 From d93e1558fca1a13d71e588189c309b4daec8d150 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 24 Feb 2012 01:02:29 +0100 Subject: IPHONE: Move some global variables to iPhoneView. --- backends/platform/iphone/iphone_video.h | 7 +++++++ backends/platform/iphone/iphone_video.mm | 10 ++-------- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 1d9d7e7d35..4d6d906a3c 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -49,11 +49,18 @@ UIDeviceOrientation _orientation; + GLint _renderBufferWidth; + GLint _renderBufferHeight; + GLfloat _gameScreenVertCoords[4 * 2]; GLfloat _gameScreenTexCoords[4 * 2]; + CGRect _gameScreenRect; GLfloat _overlayVertCoords[4 * 2]; GLfloat _overlayTexCoords[4 * 2]; + CGRect _overlayRect; + + int _scaledShakeOffsetY; } - (id)initWithFrame:(struct CGRect)frame; diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index d7511c56d4..621238d1c2 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -30,20 +30,12 @@ iPhoneView *g_iPhoneViewInstance = nil; static int _fullWidth; static int _fullHeight; -static CGRect _gameScreenRect; - -static CGRect _overlayRect; static int _needsScreenUpdate = 0; static UITouch *_firstTouch = NULL; static UITouch *_secondTouch = NULL; -static GLint _renderBufferWidth; -static GLint _renderBufferHeight; - -static int _scaledShakeOffsetY; - #if 0 static long lastTick = 0; static int frames = 0; @@ -203,6 +195,8 @@ const char *iPhone_getDocumentsDir() { _overlayTexture = 0; _mouseCursorTexture = 0; + _scaledShakeOffsetY = 0; + _gameScreenVertCoords[0] = _gameScreenVertCoords[1] = _gameScreenVertCoords[2] = _gameScreenVertCoords[3] = _gameScreenVertCoords[4] = _gameScreenVertCoords[5] = -- cgit v1.2.3 From d691ef2260fb76ac7bdba60e8383db5c27e842b6 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 24 Feb 2012 01:13:44 +0100 Subject: IPHONE: Clean up mouse texture coordinate handling. --- backends/platform/iphone/iphone_video.h | 2 ++ backends/platform/iphone/iphone_video.mm | 24 +++++++++--------------- 2 files changed, 11 insertions(+), 15 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 4d6d906a3c..bd32a582e9 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -60,6 +60,8 @@ GLfloat _overlayTexCoords[4 * 2]; CGRect _overlayRect; + GLfloat _mouseTexCoords[4 * 2]; + int _scaledShakeOffsetY; } diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 621238d1c2..477254f46d 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -217,6 +217,11 @@ const char *iPhone_getDocumentsDir() { _overlayTexCoords[4] = _overlayTexCoords[5] = _overlayTexCoords[6] = _overlayTexCoords[7] = 0; + _mouseTexCoords[0] = _mouseTexCoords[1] = + _mouseTexCoords[2] = _mouseTexCoords[3] = + _mouseTexCoords[4] = _mouseTexCoords[5] = + _mouseTexCoords[6] = _mouseTexCoords[7] = 0; + // Initialize the OpenGL ES context [self createContext]; @@ -305,6 +310,9 @@ const char *iPhone_getDocumentsDir() { [self setFilterModeForTexture:_mouseCursorTexture]; } + _mouseTexCoords[2] = _mouseTexCoords[6] = _videoContext.mouseWidth / (GLfloat)_videoContext.mouseTexture.w; + _mouseTexCoords[5] = _mouseTexCoords[7] = _videoContext.mouseHeight / (GLfloat)_videoContext.mouseTexture.h; + glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _videoContext.mouseTexture.w, _videoContext.mouseTexture.h, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, _videoContext.mouseTexture.pixels); printOpenGLError(); } @@ -383,22 +391,8 @@ const char *iPhone_getDocumentsDir() { //printf("Cursor: width %u height %u\n", _videoContext.mouseWidth, _videoContext.mouseHeight); - float texWidth = _videoContext.mouseWidth / (float)_videoContext.mouseTexture.w; - float texHeight = _videoContext.mouseHeight / (float)_videoContext.mouseTexture.h; - - const GLfloat texCoords[] = { - // Top left - 0 , 0, - // Top right - texWidth, 0, - // Bottom left - 0 , texHeight, - // Bottom right - texWidth, texHeight - }; - glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError(); - glTexCoordPointer(2, GL_FLOAT, 0, texCoords); printOpenGLError(); + glTexCoordPointer(2, GL_FLOAT, 0, _mouseTexCoords); printOpenGLError(); glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); printOpenGLError(); -- cgit v1.2.3 From 5c558660689e3fb6bad1fd979885a349bf77262c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 24 Feb 2012 01:33:37 +0100 Subject: IPHONE: Cleanup mouse cursor handling slightly. Now the scaling etc. will be precalculated instead of being done on every frame. --- backends/platform/iphone/iphone_video.h | 4 ++ backends/platform/iphone/iphone_video.mm | 83 +++++++++++++++++--------------- backends/platform/iphone/osys_video.mm | 2 + 3 files changed, 51 insertions(+), 38 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index bd32a582e9..135f4e64c3 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -61,6 +61,9 @@ CGRect _overlayRect; GLfloat _mouseTexCoords[4 * 2]; + GLint _mouseHotspotX, _mouseHotspotY; + GLint _mouseWidth, _mouseHeight; + GLfloat _mouseScaleX, _mouseScaleY; int _scaledShakeOffsetY; } @@ -82,6 +85,7 @@ - (void)updateMouseSurface; - (void)clearColorBuffer; +- (void)updateMouseCursorScaling; - (void)updateMouseCursor; - (id)getEvent; diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 477254f46d..da954199ea 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -304,12 +304,50 @@ const char *iPhone_getDocumentsDir() { } +- (void)updateMouseCursorScaling { + CGRect *rect; + int maxWidth, maxHeight; + + if (!_videoContext.overlayVisible) { + rect = &_gameScreenRect; + maxWidth = _videoContext.screenWidth; + maxHeight = _videoContext.screenHeight; + } else { + rect = &_overlayRect; + maxWidth = _videoContext.overlayWidth; + maxHeight = _videoContext.overlayHeight; + } + + if (!maxWidth || !maxHeight) { + printf("WARNING: updateMouseCursorScaling called when screen was not ready (%d)!\n", _videoContext.overlayVisible); + return; + } + + _mouseScaleX = CGRectGetWidth(*rect) / (GLfloat)maxWidth; + _mouseScaleY = CGRectGetHeight(*rect) / (GLfloat)maxHeight; + + _mouseWidth = (GLint)(_videoContext.mouseWidth * _mouseScaleX); + _mouseHeight = (GLint)(_videoContext.mouseHeight * _mouseScaleY); + + _mouseHotspotX = (GLint)(_videoContext.mouseHotspotX * _mouseScaleX); + _mouseHotspotY = (GLint)(_videoContext.mouseHotspotY * _mouseScaleY); + + // We subtract the screen offset to the hotspot here to simplify the + // screen offset handling in the mouse code. Note the subtraction here + // makes sure that the offset actually gets added to the mouse position, + // since the hotspot offset is substracted from the position. + _mouseHotspotX -= (GLint)CGRectGetMinX(*rect); + _mouseHotspotY -= (GLint)CGRectGetMinY(*rect); +} + - (void)updateMouseCursor { if (_mouseCursorTexture == 0) { glGenTextures(1, &_mouseCursorTexture); printOpenGLError(); [self setFilterModeForTexture:_mouseCursorTexture]; } + [self updateMouseCursorScaling]; + _mouseTexCoords[2] = _mouseTexCoords[6] = _videoContext.mouseWidth / (GLfloat)_videoContext.mouseTexture.w; _mouseTexCoords[5] = _mouseTexCoords[7] = _videoContext.mouseHeight / (GLfloat)_videoContext.mouseTexture.h; @@ -340,53 +378,21 @@ const char *iPhone_getDocumentsDir() { } - (void)updateMouseSurface { - int width = _videoContext.mouseWidth; - int height = _videoContext.mouseHeight; - int mouseX = _videoContext.mouseX; int mouseY = _videoContext.mouseY; - int hotspotX = _videoContext.mouseHotspotX; - int hotspotY = _videoContext.mouseHotspotY; - - CGRect *rect; - int maxWidth, maxHeight; - - if (!_videoContext.overlayVisible) { - rect = &_gameScreenRect; - maxWidth = _videoContext.screenWidth; - maxHeight = _videoContext.screenHeight; - } else { - rect = &_overlayRect; - maxWidth = _videoContext.overlayWidth; - maxHeight = _videoContext.overlayHeight; - } - - const GLfloat scaleX = CGRectGetWidth(*rect) / (GLfloat)maxWidth; - const GLfloat scaleY = CGRectGetHeight(*rect) / (GLfloat)maxHeight; - - mouseX = (int)(mouseX * scaleX); - mouseY = (int)(mouseY * scaleY); - hotspotX = (int)(hotspotX * scaleX); - hotspotY = (int)(hotspotY * scaleY); - width = (int)(width * scaleX); - height = (int)(height * scaleY); - - mouseX -= hotspotX; - mouseY -= hotspotY; - - mouseX += (int)CGRectGetMinX(*rect); - mouseY += (int)CGRectGetMinY(*rect); + mouseX = (int)(mouseX * _mouseScaleX) - _mouseHotspotX; + mouseY = (int)(mouseY * _mouseScaleY) - _mouseHotspotY; GLfloat vertices[] = { // Top left - mouseX , mouseY, + mouseX , mouseY, // Top right - mouseX + width, mouseY, + mouseX + _mouseWidth, mouseY, // Bottom left - mouseX , mouseY + height, + mouseX , mouseY + _mouseHeight, // Bottom right - mouseX + width, mouseY + height + mouseX + _mouseWidth, mouseY + _mouseHeight }; //printf("Cursor: width %u height %u\n", _videoContext.mouseWidth, _videoContext.mouseHeight); @@ -531,6 +537,7 @@ const char *iPhone_getDocumentsDir() { _overlayVertCoords[5] = _overlayVertCoords[7] = CGRectGetMaxY(_overlayRect); [self setViewTransformation]; + [self updateMouseCursorScaling]; } - (void)setViewTransformation { diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index 6fa800a004..0efeb78aef 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -246,6 +246,7 @@ void OSystem_IPHONE::showOverlay() { _videoContext->overlayVisible = true; dirtyFullOverlayScreen(); updateScreen(); + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursorScaling) withObject:nil waitUntilDone: YES]; [g_iPhoneViewInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; } @@ -254,6 +255,7 @@ void OSystem_IPHONE::hideOverlay() { _videoContext->overlayVisible = false; _dirtyOverlayRects.clear(); dirtyFullScreen(); + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateMouseCursorScaling) withObject:nil waitUntilDone: YES]; [g_iPhoneViewInstance performSelectorOnMainThread:@selector(clearColorBuffer) withObject:nil waitUntilDone: YES]; } -- cgit v1.2.3 From c3b52343dceaae253df9324a417a526f13c52333 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 24 Feb 2012 01:44:17 +0100 Subject: IPHONE: Only update on screen mouse coordinates when it's needed. --- backends/platform/iphone/iphone_video.h | 2 ++ backends/platform/iphone/iphone_video.mm | 41 ++++++++++++++++---------------- backends/platform/iphone/osys_video.mm | 2 +- 3 files changed, 24 insertions(+), 21 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 135f4e64c3..168f9a4244 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -60,6 +60,7 @@ GLfloat _overlayTexCoords[4 * 2]; CGRect _overlayRect; + GLfloat _mouseVertCoords[4 * 2]; GLfloat _mouseTexCoords[4 * 2]; GLint _mouseHotspotX, _mouseHotspotY; GLint _mouseWidth, _mouseHeight; @@ -85,6 +86,7 @@ - (void)updateMouseSurface; - (void)clearColorBuffer; +- (void)notifyMouseMove; - (void)updateMouseCursorScaling; - (void)updateMouseCursor; diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index da954199ea..3aa76681ab 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -217,6 +217,11 @@ const char *iPhone_getDocumentsDir() { _overlayTexCoords[4] = _overlayTexCoords[5] = _overlayTexCoords[6] = _overlayTexCoords[7] = 0; + _mouseVertCoords[0] = _mouseVertCoords[1] = + _mouseVertCoords[2] = _mouseVertCoords[3] = + _mouseVertCoords[4] = _mouseVertCoords[5] = + _mouseVertCoords[6] = _mouseVertCoords[7] = 0; + _mouseTexCoords[0] = _mouseTexCoords[1] = _mouseTexCoords[2] = _mouseTexCoords[3] = _mouseTexCoords[4] = _mouseTexCoords[5] = @@ -304,6 +309,16 @@ const char *iPhone_getDocumentsDir() { } +- (void)notifyMouseMove { + const GLint mouseX = (GLint)(_videoContext.mouseX * _mouseScaleX) - _mouseHotspotX; + const GLint mouseY = (GLint)(_videoContext.mouseY * _mouseScaleY) - _mouseHotspotY; + + _mouseVertCoords[0] = _mouseVertCoords[4] = mouseX; + _mouseVertCoords[1] = _mouseVertCoords[3] = mouseY; + _mouseVertCoords[2] = _mouseVertCoords[6] = mouseX + _mouseWidth; + _mouseVertCoords[5] = _mouseVertCoords[7] = mouseY + _mouseHeight; +} + - (void)updateMouseCursorScaling { CGRect *rect; int maxWidth, maxHeight; @@ -338,6 +353,11 @@ const char *iPhone_getDocumentsDir() { // since the hotspot offset is substracted from the position. _mouseHotspotX -= (GLint)CGRectGetMinX(*rect); _mouseHotspotY -= (GLint)CGRectGetMinY(*rect); + + // FIXME: For now we also adapt the mouse position here. In reality we + // would be better off to also adjust the event position when switching + // from overlay to game screen or vica versa. + [self notifyMouseMove]; } - (void)updateMouseCursor { @@ -378,26 +398,7 @@ const char *iPhone_getDocumentsDir() { } - (void)updateMouseSurface { - int mouseX = _videoContext.mouseX; - int mouseY = _videoContext.mouseY; - - mouseX = (int)(mouseX * _mouseScaleX) - _mouseHotspotX; - mouseY = (int)(mouseY * _mouseScaleY) - _mouseHotspotY; - - GLfloat vertices[] = { - // Top left - mouseX , mouseY, - // Top right - mouseX + _mouseWidth, mouseY, - // Bottom left - mouseX , mouseY + _mouseHeight, - // Bottom right - mouseX + _mouseWidth, mouseY + _mouseHeight - }; - - //printf("Cursor: width %u height %u\n", _videoContext.mouseWidth, _videoContext.mouseHeight); - - glVertexPointer(2, GL_FLOAT, 0, vertices); printOpenGLError(); + glVertexPointer(2, GL_FLOAT, 0, _mouseVertCoords); printOpenGLError(); glTexCoordPointer(2, GL_FLOAT, 0, _mouseTexCoords); printOpenGLError(); glBindTexture(GL_TEXTURE_2D, _mouseCursorTexture); printOpenGLError(); diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index 0efeb78aef..31db4c70e7 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -332,9 +332,9 @@ bool OSystem_IPHONE::showMouse(bool visible) { void OSystem_IPHONE::warpMouse(int x, int y) { //printf("warpMouse()\n"); - _videoContext->mouseX = x; _videoContext->mouseY = y; + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(notifyMouseMove) withObject:nil waitUntilDone: YES]; _mouseDirty = true; } -- cgit v1.2.3 From f1a4f508afb7552629b8278d3cef8ed23c05998e Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Fri, 24 Feb 2012 22:43:02 +0100 Subject: IPHONE: Move aspect ratio settings to VideoContext. --- backends/platform/iphone/iphone_common.h | 5 ++--- backends/platform/iphone/iphone_video.mm | 27 +++++++-------------------- backends/platform/iphone/osys_main.cpp | 4 ++-- 3 files changed, 11 insertions(+), 25 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_common.h b/backends/platform/iphone/iphone_common.h index 3c0365eff5..19e4f2ce9b 100644 --- a/backends/platform/iphone/iphone_common.h +++ b/backends/platform/iphone/iphone_common.h @@ -58,13 +58,14 @@ enum GraphicsModes { }; struct VideoContext { - VideoContext() : screenWidth(), screenHeight(), overlayVisible(false), + VideoContext() : asprectRatioCorrection(), screenWidth(), screenHeight(), overlayVisible(false), overlayWidth(), overlayHeight(), mouseX(), mouseY(), mouseHotspotX(), mouseHotspotY(), mouseWidth(), mouseHeight(), mouseIsVisible(), graphicsMode(kGraphicsModeLinear), shakeOffsetY() { } // Game screen state + bool asprectRatioCorrection; uint screenWidth, screenHeight; Graphics::Surface screenTexture; @@ -86,8 +87,6 @@ struct VideoContext { }; // On the ObjC side -void iPhone_setAspectRatioState(bool enable); -bool iPhone_getAspectRatioState(); void iPhone_updateScreen(); bool iPhone_fetchEvent(int *outEvent, int *outX, int *outY); const char *iPhone_getDocumentsDir(); diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index ecb514d633..0ddb90bece 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -41,8 +41,6 @@ static long lastTick = 0; static int frames = 0; #endif -static bool _aspectRatioCorrect = false; - #define printOpenGLError() printOglError(__FILE__, __LINE__) int printOglError(const char *file, int line) { @@ -58,14 +56,6 @@ int printOglError(const char *file, int line) { return retCode; } -void iPhone_setAspectRatioState(bool enable) { - _aspectRatioCorrect = enable; -} - -bool iPhone_getAspectRatioState() { - return _aspectRatioCorrect; -} - bool iPhone_isHighResDevice() { return _fullHeight > 480; } @@ -488,22 +478,19 @@ const char *iPhone_getDocumentsDir() { [[_keyboardView inputView] removeFromSuperview]; } - float adjustedWidth = _videoContext.screenWidth; - float adjustedHeight = _videoContext.screenHeight; - if (_aspectRatioCorrect && ((_videoContext.screenWidth == 320 && _videoContext.screenHeight == 200) - || (_videoContext.screenWidth == 640 && _videoContext.screenHeight == 400)) ) { - if (_videoContext.screenHeight == 200) { + GLfloat adjustedWidth = _videoContext.screenWidth; + GLfloat adjustedHeight = _videoContext.screenHeight; + if (_videoContext.asprectRatioCorrection) { + if (_videoContext.screenWidth == 320 && _videoContext.screenHeight == 200) adjustedHeight = 240; - } - if (_videoContext.screenHeight == 400) { + else if (_videoContext.screenWidth == 640 && _videoContext.screenHeight == 400) adjustedHeight = 480; - } } float overlayPortraitRatio; if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation == UIDeviceOrientationLandscapeRight) { - GLfloat gameScreenRatio = (GLfloat)adjustedWidth / (GLfloat)adjustedHeight; + GLfloat gameScreenRatio = adjustedWidth / adjustedHeight; GLfloat screenRatio = (GLfloat)screenWidth / (GLfloat)screenHeight; // These are the width/height according to the portrait layout! @@ -532,7 +519,7 @@ const char *iPhone_getDocumentsDir() { _gameScreenRect = CGRectMake(xOffset, yOffset, rectWidth, rectHeight); overlayPortraitRatio = 1.0f; } else { - float ratio = (float)adjustedHeight / (float)adjustedWidth; + GLfloat ratio = adjustedHeight / adjustedWidth; int height = (int)(screenWidth * ratio); //printf("Making rect (%u, %u)\n", screenWidth, height); _gameScreenRect = CGRectMake(0, 0, screenWidth, height); diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 71404dcd9e..dd34e95c72 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -119,7 +119,7 @@ void OSystem_IPHONE::setFeatureState(Feature f, bool enable) { } break; case kFeatureAspectRatioCorrection: - iPhone_setAspectRatioState(enable); + _videoContext->asprectRatioCorrection = enable; break; default: @@ -132,7 +132,7 @@ bool OSystem_IPHONE::getFeatureState(Feature f) { case kFeatureCursorPalette: return _mouseCursorPaletteEnabled; case kFeatureAspectRatioCorrection: - return iPhone_getAspectRatioState(); + return _videoContext->asprectRatioCorrection; default: return false; -- cgit v1.2.3 From 3edd4180f3fe9fb098a33870d25f7a4fc53eb96e Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 24 Feb 2012 21:43:08 -0600 Subject: MAEMO: Move static table out of .h file Thanks fuzzie & LordHoto for pointing this out --- backends/platform/maemo/maemo-common.h | 9 --------- backends/platform/maemo/maemo.cpp | 11 ++++++++++- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'backends') diff --git a/backends/platform/maemo/maemo-common.h b/backends/platform/maemo/maemo-common.h index 453c70c45f..0442b9c0ae 100644 --- a/backends/platform/maemo/maemo-common.h +++ b/backends/platform/maemo/maemo-common.h @@ -43,15 +43,6 @@ struct Model { bool hasMenuKey; }; -static const Model models[] = { - {"SU-18", kModelType770, "770", false, true}, - {"RX-34", kModelTypeN800, "N800", false, true}, - {"RX-44", kModelTypeN810, "N810", true, true}, - {"RX-48", kModelTypeN810, "N810W", true, true}, - {"RX-51", kModelTypeN900, "N900", true, false}, - {0, kModelTypeInvalid, 0, true, true} -}; - enum CustomEventType { kEventClickMode = 1, kEventInvalid = 0 diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index 209e527e3f..a127926eb0 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -156,10 +156,19 @@ void OSystem_SDL_Maemo::setWindowCaption(const char *caption) { setXWindowName(cap.c_str()); } +static const Model models[] = { + {"SU-18", kModelType770, "770", false, true}, + {"RX-34", kModelTypeN800, "N800", false, true}, + {"RX-44", kModelTypeN810, "N810", true, true}, + {"RX-48", kModelTypeN810, "N810W", true, true}, + {"RX-51", kModelTypeN900, "N900", true, false}, + {0, kModelTypeInvalid, 0, true, true} +}; + const Maemo::Model OSystem_SDL_Maemo::detectModel() { Common::String deviceHwId = Common::String(getenv("SCUMMVM_MAEMO_DEVICE")); const Model *model; - for (model = models; model->hwId; model++) { + for (model = models; model->hwId; ++model) { if (deviceHwId.equals(model->hwId)) return *model; } -- cgit v1.2.3 From 535a55e47a2ef433c4daa88068a6defab801942b Mon Sep 17 00:00:00 2001 From: athrxx Date: Sat, 25 Feb 2012 14:09:05 +0100 Subject: AUDIO: (Windows) fix issue with non-unique MIDI device names This should fix the issue mentioned here: http://forums.scummvm.org/viewtopic.php?t=11255 Apparently Windows doesn't generate unique names for MIDI devices of the exact same type. I do not know whether this could be a problem on other backends, too. --- backends/midi/windows.cpp | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/midi/windows.cpp b/backends/midi/windows.cpp index 828411cd22..f4c5431d6e 100644 --- a/backends/midi/windows.cpp +++ b/backends/midi/windows.cpp @@ -177,13 +177,49 @@ MusicDevices WindowsMusicPlugin::getDevices() const { int numDevs = midiOutGetNumDevs(); MIDIOUTCAPS tmp; + Common::StringArray deviceNames; for (int i = 0; i < numDevs; i++) { if (midiOutGetDevCaps(i, &tmp, sizeof(MIDIOUTCAPS)) != MMSYSERR_NOERROR) break; + deviceNames.push_back(tmp.szPname); + } + + // Check for non-unique device names. This may happen if someone has devices with identical + // names (e. g. more than one USB device of the exact same hardware type). It seems that this + // does happen in reality sometimes. We generate index numbers for these devices. + // This is not an ideal solution, since this index could change whenever another USB + // device gets plugged in or removed, switched off or just plugged into a different port. + // Unfortunately midiOutGetDevCaps() does not generate any other unique information + // that could be used. Our index numbers which match the device order should at least be + // a little more stable than just using the midiOutGetDevCaps() device ID, since a missing + // device (e.g. switched off) should actually not be harmful to our indices (as it would be + // when using the device IDs). The cases where users have devices with identical names should + // be rare enough anyway. + Common::Array nonUniqueIndex; + for (int i = 0; i < numDevs; i++) { + int match = -1; + for (int ii = 0; ii < i; ii++) { + if (deviceNames[i] == deviceNames[ii]) { + if (nonUniqueIndex[ii] == -1) + nonUniqueIndex[ii] = 0; + if (++match == 0) + ++match; + } + } + nonUniqueIndex.push_back(match); + } + + // We now add the index number to the non-unique device names to make them unique. + for (int i = 0; i < numDevs; i++) { + if (nonUniqueIndex[i] != -1) + deviceNames[i] = Common::String::format("%s - #%.02d", deviceNames[i].c_str(), nonUniqueIndex[i]); + } + + for (Common::StringArray::iterator i = deviceNames.begin(); i != deviceNames.end(); ++i) // There is no way to detect the "MusicType" so I just set it to MT_GM // The user will have to manually select his MT32 type device and his GM type device. - devices.push_back(MusicDevice(this, tmp.szPname, MT_GM)); - } + devices.push_back(MusicDevice(this, *i, MT_GM)); + return devices; } -- cgit v1.2.3 From 97e486dee3a66bd8db0ca623ba65ba0a14da899d Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 25 Feb 2012 19:49:05 +0100 Subject: IPHONE: Implement very basic GFX transaction support. This allows for AR ratio correction changes to take place, even when the AR setting is set after initSize for example. --- backends/platform/iphone/osys_main.h | 4 ++++ backends/platform/iphone/osys_video.mm | 17 ++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 180d3e9d06..84c460aaf4 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -121,6 +121,10 @@ public: virtual bool setGraphicsMode(int mode); virtual int getGraphicsMode() const; virtual void initSize(uint width, uint height, const Graphics::PixelFormat *format); + + virtual void beginGFXTransaction(); + virtual TransactionError endGFXTransaction(); + virtual int16 getHeight(); virtual int16 getWidth(); diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index 31db4c70e7..265a36f946 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -44,7 +44,6 @@ bool OSystem_IPHONE::setGraphicsMode(int mode) { case kGraphicsModeNone: case kGraphicsModeLinear: _videoContext->graphicsMode = (GraphicsModes)mode; - [g_iPhoneViewInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES]; return true; default: @@ -68,17 +67,21 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm _gameScreenRaw = (byte *)malloc(width * height); bzero(_gameScreenRaw, width * height); - updateOutputSurface(); - - clearOverlay(); - _fullScreenIsDirty = false; dirtyFullScreen(); - _videoContext->mouseIsVisible = false; _mouseCursorPaletteEnabled = false; +} + +void OSystem_IPHONE::beginGFXTransaction() { +} + +OSystem::TransactionError OSystem_IPHONE::endGFXTransaction() { _screenChangeCount++; + updateOutputSurface(); + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES]; - updateScreen(); + // TODO: Can we return better error codes? + return kTransactionSuccess; } void OSystem_IPHONE::updateOutputSurface() { -- cgit v1.2.3 From 23732c7179ffe0e0a1d3ee3cdcefa5cee83e7518 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 25 Feb 2012 20:21:06 +0100 Subject: IPHONE: Get rid of _gameScreenRaw, instead use _framebuffer internally. --- backends/platform/iphone/osys_main.cpp | 4 ++-- backends/platform/iphone/osys_main.h | 1 - backends/platform/iphone/osys_video.mm | 30 ++++++++++-------------------- 3 files changed, 12 insertions(+), 23 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index dd34e95c72..790e192f97 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -55,7 +55,7 @@ SoundProc OSystem_IPHONE::s_soundCallback = NULL; void *OSystem_IPHONE::s_soundParam = NULL; OSystem_IPHONE::OSystem_IPHONE() : - _mixer(NULL), _gameScreenRaw(NULL), + _mixer(NULL), _mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0), _mouseNeedTextureUpdate(false), _secondaryTapped(false), _lastSecondaryTap(0), _screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false), @@ -72,7 +72,7 @@ OSystem_IPHONE::~OSystem_IPHONE() { AudioQueueDispose(s_AudioQueue.queue, true); delete _mixer; - free(_gameScreenRaw); + _framebuffer.free(); } int OSystem_IPHONE::timerHandler(int t) { diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 84c460aaf4..675fc96321 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -64,7 +64,6 @@ protected: VideoContext *_videoContext; Graphics::Surface _framebuffer; - byte *_gameScreenRaw; // For use with the game texture uint16 _gamePalette[256]; diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index 265a36f946..080b476a9e 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -62,10 +62,7 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm _videoContext->screenHeight = height; _videoContext->shakeOffsetY = 0; - free(_gameScreenRaw); - - _gameScreenRaw = (byte *)malloc(width * height); - bzero(_gameScreenRaw, width * height); + _framebuffer.create(width, height, Graphics::PixelFormat::createFormatCLUT8()); _fullScreenIsDirty = false; dirtyFullScreen(); @@ -134,12 +131,12 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, y = 0; } - if (w > (int)_videoContext->screenWidth - x) { - w = _videoContext->screenWidth - x; + if (w > (int)_framebuffer.w - x) { + w = _framebuffer.w - x; } - if (h > (int)_videoContext->screenHeight - y) { - h = _videoContext->screenHeight - y; + if (h > (int)_framebuffer.h - y) { + h = _framebuffer.h - y; } if (w <= 0 || h <= 0) @@ -150,14 +147,14 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, } - byte *dst = _gameScreenRaw + y * _videoContext->screenWidth + x; - if ((int)_videoContext->screenWidth == pitch && pitch == w) + byte *dst = (byte *)_framebuffer.getBasePtr(x, y); + if (_framebuffer.pitch == pitch && pitch == w) memcpy(dst, buf, h * w); else { do { memcpy(dst, buf, w); buf += pitch; - dst += _videoContext->screenWidth; + dst += _framebuffer.pitch; } while (--h); } } @@ -207,7 +204,7 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { int h = dirtyRect.bottom - dirtyRect.top; int w = dirtyRect.right - dirtyRect.left; - byte *src = &_gameScreenRaw[dirtyRect.top * _videoContext->screenWidth + dirtyRect.left]; + const byte *src = (const byte *)_framebuffer.getBasePtr(dirtyRect.left, dirtyRect.top); byte *dstRaw = (byte *)_videoContext->screenTexture.getBasePtr(dirtyRect.left, dirtyRect.top); for (int y = h; y > 0; y--) { uint16 *dst = (uint16 *)dstRaw; @@ -215,19 +212,12 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { *dst++ = _gamePalette[*src++]; dstRaw += _videoContext->screenTexture.pitch; - src += _videoContext->screenWidth - w; + src += _framebuffer.pitch - w; } } Graphics::Surface *OSystem_IPHONE::lockScreen() { //printf("lockScreen()\n"); - - _framebuffer.pixels = _gameScreenRaw; - _framebuffer.w = _videoContext->screenWidth; - _framebuffer.h = _videoContext->screenHeight; - _framebuffer.pitch = _videoContext->screenWidth; - _framebuffer.format = Graphics::PixelFormat::createFormatCLUT8(); - return &_framebuffer; } -- cgit v1.2.3 From 83ce8da9359d0f015165d8e75c37776a7a49474e Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 25 Feb 2012 21:33:28 +0100 Subject: IPHONE: Implement 16bpp color support. This feature is currently disabled by default. --- backends/platform/iphone/osys_main.cpp | 4 +- backends/platform/iphone/osys_main.h | 10 ++- backends/platform/iphone/osys_video.mm | 131 ++++++++++++++++++++++++--------- 3 files changed, 105 insertions(+), 40 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 790e192f97..0f63a13db7 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -55,8 +55,7 @@ SoundProc OSystem_IPHONE::s_soundCallback = NULL; void *OSystem_IPHONE::s_soundParam = NULL; OSystem_IPHONE::OSystem_IPHONE() : - _mixer(NULL), - _mouseBuf(NULL), _lastMouseTap(0), _queuedEventTime(0), + _mixer(NULL), _lastMouseTap(0), _queuedEventTime(0), _mouseNeedTextureUpdate(false), _secondaryTapped(false), _lastSecondaryTap(0), _screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false), _gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false), @@ -73,6 +72,7 @@ OSystem_IPHONE::~OSystem_IPHONE() { delete _mixer; _framebuffer.free(); + _mouseBuffer.free(); } int OSystem_IPHONE::timerHandler(int t) { diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 675fc96321..5d0f60c34c 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -75,10 +75,11 @@ protected: bool _mouseCursorPaletteEnabled; uint16 _mouseCursorPalette[256]; - byte *_mouseBuf; - byte _mouseKeyColor; + Graphics::Surface _mouseBuffer; + uint16 _mouseKeyColor; bool _mouseDirty; bool _mouseNeedTextureUpdate; + long _lastMouseDown; long _lastMouseTap; long _queuedEventTime; @@ -127,6 +128,11 @@ public: virtual int16 getHeight(); virtual int16 getWidth(); +#ifdef USE_RGB_COLOR + virtual Graphics::PixelFormat getScreenFormat() const { return _framebuffer.format; } + virtual Common::List getSupportedFormats() const; +#endif + virtual PaletteManager *getPaletteManager() { return this; } protected: // PaletteManager API diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index 080b476a9e..258b183bbe 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -24,9 +24,10 @@ #define FORBIDDEN_SYMBOL_ALLOW_ALL #include "osys_main.h" - #include "iphone_video.h" +#include "graphics/conversion.h" + void OSystem_IPHONE::initVideoContext() { _videoContext = [g_iPhoneViewInstance getVideoContext]; } @@ -55,14 +56,35 @@ int OSystem_IPHONE::getGraphicsMode() const { return _videoContext->graphicsMode; } +#ifdef USE_RGB_COLOR +Common::List OSystem_IPHONE::getSupportedFormats() const { + Common::List list; + // RGB565 + list.push_back(Graphics::createPixelFormat<565>()); + // CLUT8 + list.push_back(Graphics::PixelFormat::createFormatCLUT8()); + return list; +} +#endif + void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelFormat *format) { - //printf("initSize(%i, %i)\n", width, height); + //printf("initSize(%u, %u, %p)\n", width, height, (const void *)format); _videoContext->screenWidth = width; _videoContext->screenHeight = height; _videoContext->shakeOffsetY = 0; - _framebuffer.create(width, height, Graphics::PixelFormat::createFormatCLUT8()); + if (!format || format->bytesPerPixel == 1) { + _framebuffer.create(width, height, Graphics::PixelFormat::createFormatCLUT8()); + } else { +#if 0 + printf("bytesPerPixel: %u RGBAlosses: %u,%u,%u,%u RGBAshifts: %u,%u,%u,%u\n", format->bytesPerPixel, + format->rLoss, format->gLoss, format->bLoss, format->aLoss, + format->rShift, format->gShift, format->bShift, format->aShift); +#endif + assert(Graphics::createPixelFormat<565>() == *format); + _framebuffer.create(width, height, *format); + } _fullScreenIsDirty = false; dirtyFullScreen(); @@ -146,13 +168,12 @@ void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, _dirtyRects.push_back(Common::Rect(x, y, x + w, y + h)); } - byte *dst = (byte *)_framebuffer.getBasePtr(x, y); - if (_framebuffer.pitch == pitch && pitch == w) - memcpy(dst, buf, h * w); - else { + if (_framebuffer.pitch == pitch && _framebuffer.w == w) { + memcpy(dst, buf, h * pitch); + } else { do { - memcpy(dst, buf, w); + memcpy(dst, buf, w * _framebuffer.format.bytesPerPixel); buf += pitch; dst += _framebuffer.pitch; } while (--h); @@ -206,13 +227,23 @@ void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { const byte *src = (const byte *)_framebuffer.getBasePtr(dirtyRect.left, dirtyRect.top); byte *dstRaw = (byte *)_videoContext->screenTexture.getBasePtr(dirtyRect.left, dirtyRect.top); - for (int y = h; y > 0; y--) { - uint16 *dst = (uint16 *)dstRaw; - for (int x = w; x > 0; x--) - *dst++ = _gamePalette[*src++]; - dstRaw += _videoContext->screenTexture.pitch; - src += _framebuffer.pitch - w; + if (_framebuffer.format.bytesPerPixel == 1) { + // When we use CLUT8 do a color look up + for (int y = h; y > 0; y--) { + uint16 *dst = (uint16 *)dstRaw; + for (int x = w; x > 0; x--) + *dst++ = _gamePalette[*src++]; + + dstRaw += _videoContext->screenTexture.pitch; + src += _framebuffer.pitch - w; + } + } else { + do { + memcpy(dstRaw, src, w * _framebuffer.format.bytesPerPixel); + dstRaw += _videoContext->screenTexture.pitch; + src += _framebuffer.pitch; + } while (--h); } } @@ -350,13 +381,16 @@ void OSystem_IPHONE::dirtyFullOverlayScreen() { void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, uint32 keycolor, int cursorTargetScale, const Graphics::PixelFormat *format) { //printf("setMouseCursor(%i, %i, scale %u)\n", hotspotX, hotspotY, cursorTargetScale); - if (_mouseBuf != NULL && (_videoContext->mouseWidth != w || _videoContext->mouseHeight != h)) { - free(_mouseBuf); - _mouseBuf = NULL; - } + const Graphics::PixelFormat pixelFormat = format ? *format : Graphics::PixelFormat::createFormatCLUT8(); +#if 0 + printf("bytesPerPixel: %u RGBAlosses: %u,%u,%u,%u RGBAshifts: %u,%u,%u,%u\n", pixelFormat.bytesPerPixel, + pixelFormat.rLoss, pixelFormat.gLoss, pixelFormat.bLoss, pixelFormat.aLoss, + pixelFormat.rShift, pixelFormat.gShift, pixelFormat.bShift, pixelFormat.aShift); +#endif + assert(pixelFormat.bytesPerPixel == 1 || pixelFormat.bytesPerPixel == 2); - if (_mouseBuf == NULL) - _mouseBuf = (byte *)malloc(w * h); + if (_mouseBuffer.w != w || _mouseBuffer.h != h || _mouseBuffer.format != pixelFormat || !_mouseBuffer.pixels) + _mouseBuffer.create(w, h, pixelFormat); _videoContext->mouseWidth = w; _videoContext->mouseHeight = h; @@ -364,9 +398,9 @@ void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspot _videoContext->mouseHotspotX = hotspotX; _videoContext->mouseHotspotY = hotspotY; - _mouseKeyColor = (byte)keycolor; + _mouseKeyColor = keycolor; - memcpy(_mouseBuf, buf, w * h); + memcpy(_mouseBuffer.getBasePtr(0, 0), buf, h * _mouseBuffer.pitch); _mouseDirty = true; _mouseNeedTextureUpdate = true; @@ -394,20 +428,45 @@ void OSystem_IPHONE::updateMouseTexture() { if (mouseTexture.w != texWidth || mouseTexture.h != texHeight) mouseTexture.create(texWidth, texHeight, Graphics::createPixelFormat<5551>()); - const uint16 *palette; - if (_mouseCursorPaletteEnabled) - palette = _mouseCursorPalette; - else - palette = _gamePaletteRGBA5551; - - uint16 *mouseBuf = (uint16 *)mouseTexture.getBasePtr(0, 0); - for (uint x = 0; x < _videoContext->mouseWidth; ++x) { - for (uint y = 0; y < _videoContext->mouseHeight; ++y) { - const byte color = _mouseBuf[y * _videoContext->mouseWidth + x]; - if (color != _mouseKeyColor) - mouseBuf[y * texWidth + x] = palette[color] | 0x1; - else - mouseBuf[y * texWidth + x] = 0x0; + if (_mouseBuffer.format.bytesPerPixel == 1) { + const uint16 *palette; + if (_mouseCursorPaletteEnabled) + palette = _mouseCursorPalette; + else + palette = _gamePaletteRGBA5551; + + uint16 *mouseBuf = (uint16 *)mouseTexture.getBasePtr(0, 0); + for (uint x = 0; x < _videoContext->mouseWidth; ++x) { + for (uint y = 0; y < _videoContext->mouseHeight; ++y) { + const byte color = *(const byte *)_mouseBuffer.getBasePtr(x, y); + if (color != _mouseKeyColor) + mouseBuf[y * texWidth + x] = palette[color] | 0x1; + else + mouseBuf[y * texWidth + x] = 0x0; + } + } + } else { + if (crossBlit((byte *)mouseTexture.getBasePtr(0, 0), (const byte *)_mouseBuffer.getBasePtr(0, 0), mouseTexture.pitch, + _mouseBuffer.pitch, _mouseBuffer.w, _mouseBuffer.h, mouseTexture.format, _mouseBuffer.format)) { + if (!_mouseBuffer.format.aBits()) { + // Apply color keying since the original cursor had no alpha channel. + const uint16 *src = (const uint16 *)_mouseBuffer.getBasePtr(0, 0); + uint8 *dstRaw = (uint8 *)mouseTexture.getBasePtr(0, 0); + + for (uint y = 0; y < _mouseBuffer.h; ++y, dstRaw += mouseTexture.pitch) { + uint16 *dst = (uint16 *)dstRaw; + for (uint x = 0; x < _mouseBuffer.w; ++x, ++dst) { + if (*src++ == _mouseKeyColor) + *dst &= ~1; + else + *dst |= 1; + } + } + } + } else { + // TODO: Log this! + // Make the cursor all transparent... we really need a better fallback ;-). + memset(mouseTexture.getBasePtr(0, 0), 0, mouseTexture.h * mouseTexture.pitch); } } -- cgit v1.2.3 From 3b1e4b5bdcdd67db03c6d225c0a7985d8ce35d3b Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 26 Feb 2012 01:25:18 +0100 Subject: IPHONE: Let hi-color games directly draw onto the screen texture buffer. This avoids an unecessary copying step from the framebuffer to the texture buffer. --- backends/platform/iphone/iphone_video.h | 1 + backends/platform/iphone/iphone_video.mm | 12 +++++---- backends/platform/iphone/osys_main.cpp | 6 ++++- backends/platform/iphone/osys_video.mm | 45 ++++++++++++++++++++------------ 4 files changed, 41 insertions(+), 23 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 168f9a4244..55a4acb7c7 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -75,6 +75,7 @@ - (void)drawRect:(CGRect)frame; +- (void)createScreenTexture; - (void)initSurface; - (void)setViewTransformation; diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 0ddb90bece..04aaf59b21 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -443,13 +443,17 @@ const char *iPhone_getDocumentsDir() { } } -- (void)initSurface { - uint screenTexWidth = getSizeNextPOT(_videoContext.screenWidth); - uint screenTexHeight = getSizeNextPOT(_videoContext.screenHeight); +- (void)createScreenTexture { + const uint screenTexWidth = getSizeNextPOT(_videoContext.screenWidth); + const uint screenTexHeight = getSizeNextPOT(_videoContext.screenHeight); _gameScreenTexCoords[2] = _gameScreenTexCoords[6] = _videoContext.screenWidth / (GLfloat)screenTexWidth; _gameScreenTexCoords[5] = _gameScreenTexCoords[7] = _videoContext.screenHeight / (GLfloat)screenTexHeight; + _videoContext.screenTexture.create(screenTexWidth, screenTexHeight, Graphics::createPixelFormat<565>()); +} + +- (void)initSurface { int screenWidth, screenHeight; [self setUpOrientation:[[UIDevice currentDevice] orientation] width:&screenWidth height:&screenHeight]; @@ -467,8 +471,6 @@ const char *iPhone_getDocumentsDir() { glGenTextures(1, &_overlayTexture); printOpenGLError(); [self setFilterModeForTexture:_overlayTexture]; - _videoContext.screenTexture.create(screenTexWidth, screenTexHeight, Graphics::createPixelFormat<565>()); - glBindRenderbufferOES(GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); [self clearColorBuffer]; diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index 0f63a13db7..f3e0d97b97 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -71,7 +71,11 @@ OSystem_IPHONE::~OSystem_IPHONE() { AudioQueueDispose(s_AudioQueue.queue, true); delete _mixer; - _framebuffer.free(); + // Prevent accidental freeing of the screen texture here. This needs to be + // checked since we might use the screen texture as framebuffer in the case + // of hi-color games for example. + if (_framebuffer.pixels == _videoContext->screenTexture.pixels) + _framebuffer.free(); _mouseBuffer.free(); } diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index 258b183bbe..2b5e78bd35 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -74,6 +74,16 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm _videoContext->screenHeight = height; _videoContext->shakeOffsetY = 0; + // In case we use the screen texture as frame buffer we reset the pixels + // pointer here to avoid freeing the screen texture. + if (_framebuffer.pixels == _videoContext->screenTexture.pixels) + _framebuffer.pixels = 0; + + // Create the screen texture right here. We need to do this here, since + // when a game requests hi-color mode, we actually set the framebuffer + // to the texture buffer to avoid an additional copy step. + [g_iPhoneViewInstance performSelectorOnMainThread:@selector(createScreenTexture) withObject:nil waitUntilDone: YES]; + if (!format || format->bytesPerPixel == 1) { _framebuffer.create(width, height, Graphics::PixelFormat::createFormatCLUT8()); } else { @@ -82,8 +92,13 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm format->rLoss, format->gLoss, format->bLoss, format->aLoss, format->rShift, format->gShift, format->bShift, format->aShift); #endif - assert(Graphics::createPixelFormat<565>() == *format); - _framebuffer.create(width, height, *format); + assert(_videoContext->screenTexture.format == *format); + // We directly draw on the screen texture in hi-color mode. Thus + // we copy over its settings here and just replace the width and + // height to avoid any problems. + _framebuffer = _videoContext->screenTexture; + _framebuffer.w = width; + _framebuffer.h = height; } _fullScreenIsDirty = false; @@ -222,28 +237,24 @@ void OSystem_IPHONE::internUpdateScreen() { } void OSystem_IPHONE::drawDirtyRect(const Common::Rect &dirtyRect) { + // We only need to do a color look up for CLUT8 + if (_framebuffer.format.bytesPerPixel != 1) + return; + int h = dirtyRect.bottom - dirtyRect.top; int w = dirtyRect.right - dirtyRect.left; const byte *src = (const byte *)_framebuffer.getBasePtr(dirtyRect.left, dirtyRect.top); byte *dstRaw = (byte *)_videoContext->screenTexture.getBasePtr(dirtyRect.left, dirtyRect.top); - if (_framebuffer.format.bytesPerPixel == 1) { - // When we use CLUT8 do a color look up - for (int y = h; y > 0; y--) { - uint16 *dst = (uint16 *)dstRaw; - for (int x = w; x > 0; x--) - *dst++ = _gamePalette[*src++]; + // When we use CLUT8 do a color look up + for (int y = h; y > 0; y--) { + uint16 *dst = (uint16 *)dstRaw; + for (int x = w; x > 0; x--) + *dst++ = _gamePalette[*src++]; - dstRaw += _videoContext->screenTexture.pitch; - src += _framebuffer.pitch - w; - } - } else { - do { - memcpy(dstRaw, src, w * _framebuffer.format.bytesPerPixel); - dstRaw += _videoContext->screenTexture.pitch; - src += _framebuffer.pitch; - } while (--h); + dstRaw += _videoContext->screenTexture.pitch; + src += _framebuffer.pitch - w; } } -- cgit v1.2.3 From 367131ef0ebbc446f5589b3523049eac3d5a572d Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 22 Feb 2012 21:03:17 +0100 Subject: COMMON: Move Language and Platform functionality into separate files --- backends/platform/dc/dc.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'backends') diff --git a/backends/platform/dc/dc.h b/backends/platform/dc/dc.h index 2e32ff3eb4..8ca48bf19e 100644 --- a/backends/platform/dc/dc.h +++ b/backends/platform/dc/dc.h @@ -29,6 +29,8 @@ #include "backends/audiocd/default/default-audiocd.h" #include "backends/fs/fs-factory.h" #include "audio/mixer_intern.h" +#include "common/language.h" +#include "common/platform.h" #ifdef DYNAMIC_MODULES #include "backends/plugins/dynamic-plugin.h" #endif -- cgit v1.2.3 From 7de7d1d414f8a5c408c5fd0aed0655af74a7e1ac Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sun, 26 Feb 2012 16:59:32 +0000 Subject: NDS: Fix build after common util.h split. --- backends/platform/ds/arm9/source/scummhelp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/ds/arm9/source/scummhelp.h b/backends/platform/ds/arm9/source/scummhelp.h index 79103b35ed..2735727560 100644 --- a/backends/platform/ds/arm9/source/scummhelp.h +++ b/backends/platform/ds/arm9/source/scummhelp.h @@ -24,7 +24,7 @@ #define _SCUMMHELP_H_ #include "common/str.h" -#include "common/util.h" +#include "common/platform.h" namespace DS { -- cgit v1.2.3 From 6afac4e01eba5c297e99597dd2cb17c2e4732a7e Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Fri, 24 Feb 2012 13:23:55 -0600 Subject: KEYMAPPER: Rename HardwareKey to HardwareInput --- backends/keymapper/action.cpp | 16 +-- backends/keymapper/action.h | 10 +- backends/keymapper/hardware-input.h | 187 +++++++++++++++++++++++++++ backends/keymapper/hardware-key.h | 187 --------------------------- backends/keymapper/keymap.cpp | 64 ++++----- backends/keymapper/keymap.h | 20 +-- backends/keymapper/keymapper-defaults.h | 8 +- backends/keymapper/keymapper.cpp | 28 ++-- backends/keymapper/keymapper.h | 20 +-- backends/keymapper/remap-dialog.cpp | 32 ++--- backends/platform/android/events.cpp | 8 +- backends/platform/linuxmoto/hardwarekeys.cpp | 4 +- backends/platform/linuxmoto/linuxmoto-sdl.h | 2 +- backends/platform/maemo/maemo-keys.h | 2 +- backends/platform/maemo/maemo.cpp | 4 +- backends/platform/maemo/maemo.h | 2 +- backends/platform/sdl/hardwarekeys.cpp | 4 +- backends/platform/sdl/sdl.h | 2 +- backends/platform/webos/webos.cpp | 8 +- backends/platform/webos/webos.h | 2 +- 20 files changed, 305 insertions(+), 305 deletions(-) create mode 100644 backends/keymapper/hardware-input.h delete mode 100644 backends/keymapper/hardware-key.h (limited to 'backends') diff --git a/backends/keymapper/action.cpp b/backends/keymapper/action.cpp index e5b2d9415a..33f5c423b0 100644 --- a/backends/keymapper/action.cpp +++ b/backends/keymapper/action.cpp @@ -29,7 +29,7 @@ namespace Common { Action::Action(Keymap *boss, const char *i, String des) - : _boss(boss), description(des), _hwKey(0) { + : _boss(boss), description(des), _hwInput(0) { assert(i); assert(_boss); @@ -38,18 +38,18 @@ Action::Action(Keymap *boss, const char *i, String des) _boss->addAction(this); } -void Action::mapKey(const HardwareKey *key) { - if (_hwKey) +void Action::mapInput(const HardwareInput *input) { + if (_hwInput) _boss->unregisterMapping(this); - _hwKey = key; + _hwInput = input; - if (_hwKey) - _boss->registerMapping(this, _hwKey); + if (_hwInput) + _boss->registerMapping(this, _hwInput); } -const HardwareKey *Action::getMappedKey() const { - return _hwKey; +const HardwareInput *Action::getMappedInput() const { + return _hwInput; } } // End of namespace Common diff --git a/backends/keymapper/action.h b/backends/keymapper/action.h index 3132260512..5e69ed3918 100644 --- a/backends/keymapper/action.h +++ b/backends/keymapper/action.h @@ -34,7 +34,7 @@ namespace Common { -struct HardwareKey; +struct HardwareInput; class Keymap; #define ACTION_ID_SIZE (4) @@ -55,8 +55,8 @@ struct Action { List events; private: - /** Hardware key that is mapped to this Action */ - const HardwareKey *_hwKey; + /** Hardware input that is mapped to this Action */ + const HardwareInput *_hwInput; Keymap *_boss; public: @@ -97,8 +97,8 @@ public: return _boss; } - void mapKey(const HardwareKey *key); - const HardwareKey *getMappedKey() const; + void mapInput(const HardwareInput *input); + const HardwareInput *getMappedInput() const; }; diff --git a/backends/keymapper/hardware-input.h b/backends/keymapper/hardware-input.h new file mode 100644 index 0000000000..70e0f986fa --- /dev/null +++ b/backends/keymapper/hardware-input.h @@ -0,0 +1,187 @@ +/* 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. +* +*/ + +#ifndef COMMON_HARDWARE_KEY_H +#define COMMON_HARDWARE_KEY_H + +#include "common/scummsys.h" + +#ifdef ENABLE_KEYMAPPER + +#include "common/textconsole.h" + +namespace Common { + +/** +* Describes an available hardware input +*/ +struct HardwareInput { + /** unique id used for saving/loading to config */ + String id; + + /** Human readable description */ + String description; + + /** + * The KeyState that is generated by the back-end + * when this hardware key is pressed. + */ + KeyState key; + + HardwareInput(String i, KeyState ky = KeyState(), String desc = "") + : id(i), key(ky), description(desc) { } +}; + +/** + * Entry in a static table of available non-modifier keys + */ +struct KeyTableEntry { + const char *hwId; + KeyCode keycode; + uint16 ascii; + const char *desc; + bool shiftable; +}; + +/** + * Entry in a static table of available key modifiers + */ +struct ModifierTableEntry { + byte flag; + const char *id; + const char *desc; + bool shiftable; +}; + +/** + * Simple class to encapsulate a device's set of HardwareInputs. + * Each device should instantiate this and call addHardwareInput a number of times + * in its constructor to define the device's available keys. + */ +class HardwareInputSet { +public: + + /** + * Add hardware input keys to the set out of key and modifier tables. + * @param keys table of available keys + * @param modifiers table of available modifiers + */ + HardwareInputSet(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) { + addHardwareInputs(keys, modifiers); + } + + HardwareInputSet() { } + + virtual ~HardwareInputSet() { + List::const_iterator it; + + for (it = _inputs.begin(); it != _inputs.end(); it++) + delete *it; + } + + void addHardwareInput(const HardwareInput *input) { + checkForInput(input); + _inputs.push_back(input); + } + + const HardwareInput *findHardwareInput(String id) const { + List::const_iterator it; + + for (it = _inputs.begin(); it != _inputs.end(); it++) { + if ((*it)->id == id) + return (*it); + } + return 0; + } + + const HardwareInput *findHardwareInput(const KeyState& keystate) const { + List::const_iterator it; + + for (it = _inputs.begin(); it != _inputs.end(); it++) { + if ((*it)->key == keystate) + return (*it); + } + return 0; + } + + const List &getHardwareInputs() const { + return _inputs; + } + + uint size() const { + return _inputs.size(); + } + + /** + * Add hardware inputs to the set out of key and modifier tables. + * @param keys table of available keys + * @param modifiers table of available modifiers + */ + void addHardwareInputs(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) { + const KeyTableEntry *key; + const ModifierTableEntry *mod; + char fullKeyId[50]; + char fullKeyDesc[100]; + uint16 ascii; + + for (mod = modifiers; mod->id; mod++) { + for (key = keys; key->hwId; key++) { + ascii = key->ascii; + + if (mod->shiftable && key->shiftable) { + snprintf(fullKeyId, 50, "%s%c", mod->id, toupper(key->hwId[0])); + snprintf(fullKeyDesc, 100, "%s%c", mod->desc, toupper(key->desc[0])); + ascii = toupper(key->ascii); + } else if (mod->shiftable) { + snprintf(fullKeyId, 50, "S+%s%s", mod->id, key->hwId); + snprintf(fullKeyDesc, 100, "Shift+%s%s", mod->desc, key->desc); + } else { + snprintf(fullKeyId, 50, "%s%s", mod->id, key->hwId); + snprintf(fullKeyDesc, 100, "%s%s", mod->desc, key->desc); + } + + addHardwareInput(new HardwareInput(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc)); + } + } + } + +private: + + void checkForInput(const HardwareInput *input) { + List::iterator it; + + for (it = _inputs.begin(); it != _inputs.end(); it++) { + if ((*it)->id == input->id) + error("Error adding HardwareInput '%s' - id of %s already in use!", input->description.c_str(), input->id.c_str()); + else if ((*it)->key == input->key) + error("Error adding HardwareInput '%s' - key already in use!", input->description.c_str()); + } + } + + List _inputs; +}; + +} // End of namespace Common + +#endif // #ifdef ENABLE_KEYMAPPER + +#endif // #ifndef COMMON_HARDWARE_KEY_H diff --git a/backends/keymapper/hardware-key.h b/backends/keymapper/hardware-key.h deleted file mode 100644 index 9fd8d1981a..0000000000 --- a/backends/keymapper/hardware-key.h +++ /dev/null @@ -1,187 +0,0 @@ -/* 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. -* -*/ - -#ifndef COMMON_HARDWARE_KEY_H -#define COMMON_HARDWARE_KEY_H - -#include "common/scummsys.h" - -#ifdef ENABLE_KEYMAPPER - -#include "common/textconsole.h" - -namespace Common { - -/** -* Describes an available hardware key -*/ -struct HardwareKey { - /** unique id used for saving/loading to config */ - String id; - - /** Human readable description */ - String description; - - /** - * The KeyState that is generated by the back-end - * when this hardware key is pressed. - */ - KeyState key; - - HardwareKey(String i, KeyState ky = KeyState(), String desc = "") - : id(i), key(ky), description(desc) { } -}; - -/** - * Entry in a static table of available non-modifier keys - */ -struct KeyTableEntry { - const char *hwId; - KeyCode keycode; - uint16 ascii; - const char *desc; - bool shiftable; -}; - -/** - * Entry in a static table of available key modifiers - */ -struct ModifierTableEntry { - byte flag; - const char *id; - const char *desc; - bool shiftable; -}; - -/** - * Simple class to encapsulate a device's set of HardwareKeys. - * Each device should instantiate this and call addHardwareKey a number of times - * in its constructor to define the device's available keys. - */ -class HardwareKeySet { -public: - - /** - * Add hardware keys to the set out of key and modifier tables. - * @param keys table of available keys - * @param modifiers table of available modifiers - */ - HardwareKeySet(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) { - addHardwareKeys(keys, modifiers); - } - - HardwareKeySet() { } - - virtual ~HardwareKeySet() { - List::const_iterator it; - - for (it = _keys.begin(); it != _keys.end(); it++) - delete *it; - } - - void addHardwareKey(const HardwareKey *key) { - checkForKey(key); - _keys.push_back(key); - } - - const HardwareKey *findHardwareKey(String id) const { - List::const_iterator it; - - for (it = _keys.begin(); it != _keys.end(); it++) { - if ((*it)->id == id) - return (*it); - } - return 0; - } - - const HardwareKey *findHardwareKey(const KeyState& keystate) const { - List::const_iterator it; - - for (it = _keys.begin(); it != _keys.end(); it++) { - if ((*it)->key == keystate) - return (*it); - } - return 0; - } - - const List &getHardwareKeys() const { - return _keys; - } - - uint size() const { - return _keys.size(); - } - - /** - * Add hardware keys to the set out of key and modifier tables. - * @param keys table of available keys - * @param modifiers table of available modifiers - */ - void addHardwareKeys(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) { - const KeyTableEntry *key; - const ModifierTableEntry *mod; - char fullKeyId[50]; - char fullKeyDesc[100]; - uint16 ascii; - - for (mod = modifiers; mod->id; mod++) { - for (key = keys; key->hwId; key++) { - ascii = key->ascii; - - if (mod->shiftable && key->shiftable) { - snprintf(fullKeyId, 50, "%s%c", mod->id, toupper(key->hwId[0])); - snprintf(fullKeyDesc, 100, "%s%c", mod->desc, toupper(key->desc[0])); - ascii = toupper(key->ascii); - } else if (mod->shiftable) { - snprintf(fullKeyId, 50, "S+%s%s", mod->id, key->hwId); - snprintf(fullKeyDesc, 100, "Shift+%s%s", mod->desc, key->desc); - } else { - snprintf(fullKeyId, 50, "%s%s", mod->id, key->hwId); - snprintf(fullKeyDesc, 100, "%s%s", mod->desc, key->desc); - } - - addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc)); - } - } - } - -private: - - void checkForKey(const HardwareKey *key) { - List::iterator it; - - for (it = _keys.begin(); it != _keys.end(); it++) { - if ((*it)->id == key->id) - error("Error adding HardwareKey '%s' - id of %s already in use!", key->description.c_str(), key->id.c_str()); - else if ((*it)->key == key->key) - error("Error adding HardwareKey '%s' - key already in use!", key->description.c_str()); - } - } - - List _keys; -}; - -} // End of namespace Common - -#endif // #ifdef ENABLE_KEYMAPPER - -#endif // #ifndef COMMON_HARDWARE_KEY_H diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp index 3913fd149e..8ea975c927 100644 --- a/backends/keymapper/keymap.cpp +++ b/backends/keymapper/keymap.cpp @@ -26,7 +26,7 @@ #include "common/system.h" -#include "backends/keymapper/hardware-key.h" +#include "backends/keymapper/hardware-input.h" #include "backends/keymapper/keymapper-defaults.h" #define KEYMAP_KEY_PREFIX "keymap_" @@ -37,10 +37,10 @@ Keymap::Keymap(const Keymap& km) : _actions(km._actions), _keymap(), _configDoma List::iterator it; for (it = _actions.begin(); it != _actions.end(); ++it) { - const HardwareKey *hwKey = (*it)->getMappedKey(); + const HardwareInput *hwInput = (*it)->getMappedInput(); - if (hwKey) { - _keymap[hwKey->key] = *it; + if (hwInput) { + _keymap[hwInput->key] = *it; } } } @@ -59,24 +59,24 @@ void Keymap::addAction(Action *action) { _actions.push_back(action); } -void Keymap::registerMapping(Action *action, const HardwareKey *hwKey) { +void Keymap::registerMapping(Action *action, const HardwareInput *hwInput) { HashMap::iterator it; - it = _keymap.find(hwKey->key); + it = _keymap.find(hwInput->key); // if key is already mapped to a different action then un-map it if (it != _keymap.end() && action != it->_value) { - it->_value->mapKey(0); + it->_value->mapInput(0); } - _keymap[hwKey->key] = action; + _keymap[hwInput->key] = action; } void Keymap::unregisterMapping(Action *action) { - const HardwareKey *hwKey = action->getMappedKey(); + const HardwareInput *hwInput = action->getMappedInput(); - if (hwKey) { - _keymap.erase(hwKey->key); + if (hwInput) { + _keymap.erase(hwInput->key); } } @@ -120,7 +120,7 @@ void Keymap::setConfigDomain(ConfigManager::Domain *dom) { _configDomain = dom; } -void Keymap::loadMappings(const HardwareKeySet *hwKeys) { +void Keymap::loadMappings(const HardwareInputSet *hwKeys) { if (!_configDomain) return; @@ -129,7 +129,7 @@ void Keymap::loadMappings(const HardwareKeySet *hwKeys) { Common::KeymapperDefaultBindings *defaults = g_system->getKeymapperDefaultBindings(); - HashMap mappedKeys; + HashMap mappedInputs; List::iterator it; String prefix = KEYMAP_KEY_PREFIX + _name + "_"; @@ -138,37 +138,37 @@ void Keymap::loadMappings(const HardwareKeySet *hwKeys) { String actionId(ua->id); String confKey = prefix + actionId; - String hwKeyId = _configDomain->getVal(confKey); + String hwInputId = _configDomain->getVal(confKey); bool defaulted = false; // fall back to the platform-specific defaults - if (hwKeyId.empty() && defaults) { - hwKeyId = defaults->getDefaultBinding(_name, actionId); - if (!hwKeyId.empty()) + if (hwInputId.empty() && defaults) { + hwInputId = defaults->getDefaultBinding(_name, actionId); + if (!hwInputId.empty()) defaulted = true; } // there's no mapping - if (hwKeyId.empty()) + if (hwInputId.empty()) continue; - const HardwareKey *hwKey = hwKeys->findHardwareKey(hwKeyId.c_str()); + const HardwareInput *hwInput = hwKeys->findHardwareInput(hwInputId.c_str()); - if (!hwKey) { - warning("HardwareKey with ID '%s' not known", hwKeyId.c_str()); + if (!hwInput) { + warning("HardwareInput with ID '%s' not known", hwInputId.c_str()); continue; } if (defaulted) { - if (mappedKeys.contains(hwKeyId)) { - debug(1, "Action [%s] not falling back to hardcoded default value [%s] because the key is in use", confKey.c_str(), hwKeyId.c_str()); + if (mappedInputs.contains(hwInputId)) { + debug(1, "Action [%s] not falling back to hardcoded default value [%s] because the hardware input is in use", confKey.c_str(), hwInputId.c_str()); continue; } - warning("Action [%s] fell back to hardcoded default value [%s]", confKey.c_str(), hwKeyId.c_str()); + warning("Action [%s] fell back to hardcoded default value [%s]", confKey.c_str(), hwInputId.c_str()); } - mappedKeys.setVal(hwKeyId, hwKey); + mappedInputs.setVal(hwInputId, hwInput); // map the key - ua->mapKey(hwKey); + ua->mapInput(hwInput); } } @@ -187,27 +187,27 @@ void Keymap::saveMappings() { String actId((*it)->id, (*it)->id + actIdLen); String hwId = ""; - if ((*it)->getMappedKey()) { - hwId = (*it)->getMappedKey()->id; + if ((*it)->getMappedInput()) { + hwId = (*it)->getMappedInput()->id; } _configDomain->setVal(prefix + actId, hwId); } } -bool Keymap::isComplete(const HardwareKeySet *hwKeys) { +bool Keymap::isComplete(const HardwareInputSet *hwInputs) { List::iterator it; bool allMapped = true; uint numberMapped = 0; for (it = _actions.begin(); it != _actions.end(); ++it) { - if ((*it)->getMappedKey()) { - numberMapped++; + if ((*it)->getMappedInput()) { + ++numberMapped; } else { allMapped = false; } } - return allMapped || (numberMapped == hwKeys->size()); + return allMapped || (numberMapped == hwInputs->size()); } } // End of namespace Common diff --git a/backends/keymapper/keymap.h b/backends/keymapper/keymap.h index 2e9f08533e..4c3e89700f 100644 --- a/backends/keymapper/keymap.h +++ b/backends/keymapper/keymap.h @@ -36,8 +36,8 @@ namespace Common { -struct HardwareKey; -class HardwareKeySet; +struct HardwareInput; +class HardwareInputSet; /** * Hash function for KeyState @@ -80,9 +80,9 @@ public: /** * Load this keymap's mappings from the config manager. - * @param hwKeys the set to retrieve hardware key pointers from + * @param hwInputs the set to retrieve hardware input pointers from */ - void loadMappings(const HardwareKeySet *hwKeys); + void loadMappings(const HardwareInputSet *hwInputs); /** * Save this keymap's mappings to the config manager @@ -93,9 +93,9 @@ public: /** * Returns true if all UserAction's in Keymap are mapped, or, - * all HardwareKey's from the given set have been used up. + * all HardwareInputs from the given set have been used up. */ - bool isComplete(const HardwareKeySet *hwKeys); + bool isComplete(const HardwareInputSet *hwInputs); const String& getName() { return _name; } @@ -110,15 +110,15 @@ private: void addAction(Action *action); /** - * Registers a HardwareKey to the given Action + * Registers a HardwareInput to the given Action * @param action Action in this Keymap - * @param key pointer to HardwareKey to map + * @param key pointer to HardwareInput to map * @see Action::mapKey */ - void registerMapping(Action *action, const HardwareKey *key); + void registerMapping(Action *action, const HardwareInput *input); /** - * Unregisters a HardwareKey from the given Action (if one is mapped) + * Unregisters a HardwareInput from the given Action (if one is mapped) * @param action Action in this Keymap * @see Action::mapKey */ diff --git a/backends/keymapper/keymapper-defaults.h b/backends/keymapper/keymapper-defaults.h index 5b84ebeaa9..bd4afd4e3a 100644 --- a/backends/keymapper/keymapper-defaults.h +++ b/backends/keymapper/keymapper-defaults.h @@ -35,17 +35,17 @@ namespace Common { class KeymapperDefaultBindings : HashMap { public: /** - * This sets a default hwKey for a given Keymap Action + * This sets a default hwInput for a given Keymap Action * @param keymapId String representing Keymap id (Keymap.name) * @param actionId String representing Action id (Action.id) - * @param hwKeyId String representing the HardwareKey id (HardwareKey.hwKeyId) + * @param hwInputId String representing the HardwareInput id (HardwareInput.id) */ - void setDefaultBinding(String keymapId, String actionId, String hwKeyId) { setVal(keymapId + "_" + actionId, hwKeyId); } + void setDefaultBinding(String keymapId, String actionId, String hwInputId) { setVal(keymapId + "_" + actionId, hwInputId); } /** * This retrieves the assigned default hwKey for a given Keymap Action * @param keymapId String representing Keymap id (Keymap.name) * @param actionId String representing Action id (Action.id) - * @return hwKeyId String representing the HardwareKey id (HardwareKey.hwKeyId) + * @return String representing the HardwareInput id (HardwareInput.id) */ String getDefaultBinding(String keymapId, String actionId) { return getVal(keymapId + "_" + actionId); } }; diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index 189f862469..719902ef20 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -54,26 +54,26 @@ Keymap *Keymapper::Domain::getKeymap(const String& name) { } Keymapper::Keymapper(EventManager *evtMgr) - : _eventMan(evtMgr), _enabled(true), _hardwareKeys(0) { + : _eventMan(evtMgr), _enabled(true), _hardwareInputs(0) { ConfigManager::Domain *confDom = ConfMan.getDomain(ConfigManager::kKeymapperDomain); _globalDomain.setConfigDomain(confDom); } Keymapper::~Keymapper() { - delete _hardwareKeys; + delete _hardwareInputs; } -void Keymapper::registerHardwareKeySet(HardwareKeySet *keys) { - if (_hardwareKeys) - error("Hardware key set already registered"); +void Keymapper::registerHardwareInputSet(HardwareInputSet *inputs) { + if (_hardwareInputs) + error("Hardware input set already registered"); - if (!keys) { - warning("No hardware keys are supplied"); + if (!inputs) { + warning("No hardware input are supplied"); return; } - _hardwareKeys = keys; + _hardwareInputs = inputs; } void Keymapper::addGlobalKeymap(Keymap *keymap) { @@ -95,15 +95,15 @@ void Keymapper::addGameKeymap(Keymap *keymap) { } void Keymapper::initKeymap(Domain &domain, Keymap *map) { - if (!_hardwareKeys) { - warning("No hardware keys were registered yet (%s)", map->getName().c_str()); + if (!_hardwareInputs) { + warning("No hardware inputs were registered yet (%s)", map->getName().c_str()); return; } map->setConfigDomain(domain.getConfigDomain()); - map->loadMappings(_hardwareKeys); + map->loadMappings(_hardwareInputs); - if (map->isComplete(_hardwareKeys) == false) { + if (map->isComplete(_hardwareInputs) == false) { map->saveMappings(); ConfMan.flushToDisk(); } @@ -291,8 +291,8 @@ List Keymapper::executeAction(const Action *action, bool keyDown) { return mappedEvents; } -const HardwareKey *Keymapper::findHardwareKey(const KeyState& key) { - return (_hardwareKeys) ? _hardwareKeys->findHardwareKey(key) : 0; +const HardwareInput *Keymapper::findHardwareInput(const KeyState& key) { + return (_hardwareInputs) ? _hardwareInputs->findHardwareInput(key) : 0; } } // End of namespace Common diff --git a/backends/keymapper/keymapper.h b/backends/keymapper/keymapper.h index 31bfcbc080..daa746f379 100644 --- a/backends/keymapper/keymapper.h +++ b/backends/keymapper/keymapper.h @@ -31,7 +31,7 @@ #include "common/list.h" #include "common/hashmap.h" #include "common/stack.h" -#include "backends/keymapper/hardware-key.h" +#include "backends/keymapper/hardware-input.h" #include "backends/keymapper/keymap.h" namespace Common { @@ -81,17 +81,17 @@ public: virtual List mapEvent(const Event &ev, EventSource *source); /** - * Registers a HardwareKeySet with the Keymapper + * Registers a HardwareInputSet with the Keymapper * @note should only be called once (during backend initialisation) */ - void registerHardwareKeySet(HardwareKeySet *keys); + void registerHardwareInputSet(HardwareInputSet *inputs); /** - * Get a list of all registered HardwareKeys + * Get a list of all registered HardwareInputs */ - const List &getHardwareKeys() const { - assert(_hardwareKeys); - return _hardwareKeys->getHardwareKeys(); + const List &getHardwareInputs() const { + assert(_hardwareInputs); + return _hardwareInputs->getHardwareInputs(); } /** @@ -168,9 +168,9 @@ public: void setEnabled(bool enabled) { _enabled = enabled; } /** - * Return a HardwareKey pointer for the given key state + * Return a HardwareInput pointer for the given key state */ - const HardwareKey *findHardwareKey(const KeyState& key); + const HardwareInput *findHardwareInput(const KeyState& key); Domain& getGlobalDomain() { return _globalDomain; } Domain& getGameDomain() { return _gameDomain; } @@ -183,7 +183,7 @@ private: Domain _globalDomain; Domain _gameDomain; - HardwareKeySet *_hardwareKeys; + HardwareInputSet *_hardwareInputs; void pushKeymap(Keymap *newMap, bool transparent, bool global); diff --git a/backends/keymapper/remap-dialog.cpp b/backends/keymapper/remap-dialog.cpp index a869909196..dab295219a 100644 --- a/backends/keymapper/remap-dialog.cpp +++ b/backends/keymapper/remap-dialog.cpp @@ -244,7 +244,7 @@ void RemapDialog::clearMapping(uint i) { debug(3, "clear the mapping %u", i); _activeRemapAction = _currentActions[_topAction + i].action; - _activeRemapAction->mapKey(0); + _activeRemapAction->mapInput(0); _activeRemapAction->getParent()->saveMappings(); _changes = true; @@ -286,12 +286,12 @@ void RemapDialog::handleKeyDown(Common::KeyState state) { void RemapDialog::handleKeyUp(Common::KeyState state) { if (_activeRemapAction) { - const HardwareKey *hwkey = _keymapper->findHardwareKey(state); + const HardwareInput *hwInput = _keymapper->findHardwareInput(state); debug(4, "RemapDialog::handleKeyUp Key: %d, %d (%c), %x", state.keycode, state.ascii, (state.ascii ? state.ascii : ' '), state.flags); - if (hwkey) { - _activeRemapAction->mapKey(hwkey); + if (hwInput) { + _activeRemapAction->mapInput(hwInput); _activeRemapAction->getParent()->saveMappings(); _changes = true; stopRemapping(); @@ -325,7 +325,7 @@ void RemapDialog::loadKeymap() { // - all of the topmost keymap action // - all mapped actions that are reachable - List freeKeys(_keymapper->getHardwareKeys()); + List freeInputs(_keymapper->getHardwareInputs()); int topIndex = activeKeymaps.size() - 1; @@ -344,8 +344,8 @@ void RemapDialog::loadKeymap() { _currentActions.push_back(info); - if (act->getMappedKey()) - freeKeys.remove(act->getMappedKey()); + if (act->getMappedInput()) + freeInputs.remove(act->getMappedInput()); } // loop through remaining finding mappings for unmapped keys @@ -353,21 +353,21 @@ void RemapDialog::loadKeymap() { for (int i = topIndex - 1; i >= 0; --i) { Keymapper::MapRecord mr = activeKeymaps[i]; debug(3, "RemapDialog::loadKeymap keymap: %s", mr.keymap->getName().c_str()); - List::iterator keyIt = freeKeys.begin(); + List::iterator inputIt = freeInputs.begin(); + while (inputIt != freeInputs.end()) { - while (keyIt != freeKeys.end()) { - Action *act = mr.keymap->getMappedAction((*keyIt)->key); + Action *act = mr.keymap->getMappedAction((*inputIt)->key); if (act) { ActionInfo info = {act, true, act->description + " (" + mr.keymap->getName() + ")"}; _currentActions.push_back(info); - freeKeys.erase(keyIt++); + freeInputs.erase(inputIt); } else { - ++keyIt; + ++inputIt; } } - if (mr.transparent == false || freeKeys.empty()) + if (mr.transparent == false || freeInputs.empty()) break; } } @@ -420,10 +420,10 @@ void RemapDialog::refreshKeymap() { widg.actionText->setLabel(info.description); widg.actionText->setEnabled(!info.inherited); - const HardwareKey *mappedKey = info.action->getMappedKey(); + const HardwareInput *mappedInput = info.action->getMappedInput(); - if (mappedKey) - widg.keyButton->setLabel(mappedKey->description); + if (mappedInput) + widg.keyButton->setLabel(mappedInput->description); else widg.keyButton->setLabel("-"); diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp index a58b93e3bb..21d2344fa7 100644 --- a/backends/platform/android/events.cpp +++ b/backends/platform/android/events.cpp @@ -224,12 +224,12 @@ void OSystem_Android::setupKeymapper() { Keymapper *mapper = getEventManager()->getKeymapper(); - HardwareKeySet *keySet = new HardwareKeySet(); + HardwareInputSet *inputSet = new HardwareInputSet(); - keySet->addHardwareKey( - new HardwareKey("n", KeyState(KEYCODE_n), "n (vk)")); + keySet->addHardwareInput( + new HardwareInput("n", KeyState(KEYCODE_n), "n (vk)")); - mapper->registerHardwareKeySet(keySet); + mapper->registerHardwareInputSet(inputSet); Keymap *globalMap = new Keymap(kGlobalKeymapName); Action *act; diff --git a/backends/platform/linuxmoto/hardwarekeys.cpp b/backends/platform/linuxmoto/hardwarekeys.cpp index da093c6508..e1a5757430 100644 --- a/backends/platform/linuxmoto/hardwarekeys.cpp +++ b/backends/platform/linuxmoto/hardwarekeys.cpp @@ -106,7 +106,7 @@ static const Mod modifiers[] = { { 0, 0, 0, false } }; -Common::HardwareKeySet *OSystem_LINUXMOTO::getHardwareKeySet() { - return OSystem_SDL::getHardwareKeySet(); +Common::HardwareInputSet *OSystem_LINUXMOTO::getHardwareInputSet() { + return OSystem_SDL::getHardwareInputSet(); } #endif diff --git a/backends/platform/linuxmoto/linuxmoto-sdl.h b/backends/platform/linuxmoto/linuxmoto-sdl.h index 9a0be56e11..27f4e744bc 100644 --- a/backends/platform/linuxmoto/linuxmoto-sdl.h +++ b/backends/platform/linuxmoto/linuxmoto-sdl.h @@ -31,7 +31,7 @@ public: #ifdef ENABLE_KEYMAPPER // FIXME: This just calls parent methods, is it needed? - virtual Common::HardwareKeySet *getHardwareKeySet(); + virtual Common::HardwareInputSet *getHardwareInputSet(); #endif }; diff --git a/backends/platform/maemo/maemo-keys.h b/backends/platform/maemo/maemo-keys.h index e1337515a7..ae3a746229 100644 --- a/backends/platform/maemo/maemo-keys.h +++ b/backends/platform/maemo/maemo-keys.h @@ -28,7 +28,7 @@ #include "common/keyboard.h" -#include "backends/keymapper/hardware-key.h" +#include "backends/keymapper/hardware-input.h" namespace Common { diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index a127926eb0..53e88d2286 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -182,8 +182,8 @@ void OSystem_SDL_Maemo::setupIcon() { } #ifdef ENABLE_KEYMAPPER -Common::HardwareKeySet *OSystem_SDL_Maemo::getHardwareKeySet() { - return new Common::HardwareKeySet(Common::maemoKeys, Common::maemoModifiers); +Common::HardwareInputSet *OSystem_SDL_Maemo::getHardwareInputSet() { + return new Common::HardwareInputSet(Common::maemoKeys, Common::maemoModifiers); } Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() { diff --git a/backends/platform/maemo/maemo.h b/backends/platform/maemo/maemo.h index 4b84ae573a..43bc262ade 100644 --- a/backends/platform/maemo/maemo.h +++ b/backends/platform/maemo/maemo.h @@ -42,7 +42,7 @@ public: virtual void setWindowCaption(const char *caption); virtual void setupIcon(); #ifdef ENABLE_KEYMAPPER - virtual Common::HardwareKeySet *getHardwareKeySet(); + virtual Common::HardwareInputSet *getHardwareInputSet(); virtual Common::Keymap *getGlobalKeymap(); virtual Common::KeymapperDefaultBindings *getKeymapperDefaultBindings() { return _keymapperDefaultBindings; } #endif diff --git a/backends/platform/sdl/hardwarekeys.cpp b/backends/platform/sdl/hardwarekeys.cpp index 5fb4473ebd..0b73bfa467 100644 --- a/backends/platform/sdl/hardwarekeys.cpp +++ b/backends/platform/sdl/hardwarekeys.cpp @@ -175,7 +175,7 @@ static const ModifierTableEntry sdlModifiers[] = { { 0, 0, 0, false } }; -Common::HardwareKeySet *OSystem_SDL::getHardwareKeySet() { - return new HardwareKeySet(sdlKeys, sdlModifiers); +Common::HardwareInputSet *OSystem_SDL::getHardwareInputSet() { + return new HardwareInputSet(sdlKeys, sdlModifiers); } #endif diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 64e63b40a6..51a7b2f577 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -59,7 +59,7 @@ public: virtual void engineDone(); #endif #ifdef ENABLE_KEYMAPPER - virtual Common::HardwareKeySet *getHardwareKeySet(); + virtual Common::HardwareInputSet *getHardwareInputSet(); #endif virtual void quit(); virtual void fatalError(); diff --git a/backends/platform/webos/webos.cpp b/backends/platform/webos/webos.cpp index 710a3f79be..7dd42e5440 100644 --- a/backends/platform/webos/webos.cpp +++ b/backends/platform/webos/webos.cpp @@ -52,16 +52,16 @@ void OSystem_SDL_WebOS::initBackend() { * @return The hardware key set with added webOS specific keys. */ #ifdef ENABLE_KEYMAPPER -HardwareKeySet *OSystem_SDL_WebOS::getHardwareKeySet() { +HardwareInputSet *OSystem_SDL_WebOS::getHardwareInputSet() { // Get the original SDL hardware key set - HardwareKeySet *keySet = OSystem_SDL::getHardwareKeySet(); + HardwareInputSet *inputSet = OSystem_SDL::getHardwareInputSet(); // Add WebOS specific keys - keySet->addHardwareKey(new HardwareKey("FORWARD", + keySet->addHardwareInput(new HardwareInput("FORWARD", KeyState((KeyCode) 229, 229, 0), "Forward")); // Return the modified hardware key set - return keySet; + return inputSet; } #endif diff --git a/backends/platform/webos/webos.h b/backends/platform/webos/webos.h index 71390a1d2c..8dfa43239c 100644 --- a/backends/platform/webos/webos.h +++ b/backends/platform/webos/webos.h @@ -32,7 +32,7 @@ public: virtual void initBackend(); #ifdef ENABLE_KEYMAPPER - virtual Common::HardwareKeySet *getHardwareKeySet(); + virtual Common::HardwareInputSet *getHardwareInputSet(); #endif }; -- cgit v1.2.3 From 533f80282befe2e3c345ed1f6fc372b669811b15 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Mon, 27 Feb 2012 12:35:48 -0600 Subject: KEYMAPPER: Rename EVENT_CUSTOM_BACKEND to EVENT_CUSTOM_BACKEND_ACTION --- backends/events/maemosdl/maemosdl-events.cpp | 2 +- backends/platform/maemo/maemo.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp index 0046d297eb..dcdf0384e3 100644 --- a/backends/events/maemosdl/maemosdl-events.cpp +++ b/backends/events/maemosdl/maemosdl-events.cpp @@ -201,7 +201,7 @@ MaemoSdlEventObserver::MaemoSdlEventObserver(MaemoSdlEventSource *eventSource) { bool MaemoSdlEventObserver::notifyEvent(const Common::Event &event) { #ifdef ENABLE_KEYMAPPER - if (event.type != Common::EVENT_CUSTOM_BACKEND) + if (event.type != Common::EVENT_CUSTOM_BACKEND_ACTION) return false; if (event.customType == kEventClickMode) { assert(_eventSource); diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index 53e88d2286..5e8b6e16a7 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -194,7 +194,7 @@ Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() { act = new Action(globalMap, "CLKM", _("Click Mode")); Event evt = Event(); - evt.type = EVENT_CUSTOM_BACKEND; + evt.type = EVENT_CUSTOM_BACKEND_ACTION; evt.customType = Maemo::kEventClickMode; act->addEvent(evt); -- cgit v1.2.3 From dfdfc2f29739359bebb02df63e84b9b5f87c0058 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Mon, 27 Feb 2012 13:45:14 -0600 Subject: KEYMAPPER: Fix WebOS compile --- backends/platform/webos/webos.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends') diff --git a/backends/platform/webos/webos.cpp b/backends/platform/webos/webos.cpp index 7dd42e5440..4ec153a7e9 100644 --- a/backends/platform/webos/webos.cpp +++ b/backends/platform/webos/webos.cpp @@ -57,7 +57,7 @@ HardwareInputSet *OSystem_SDL_WebOS::getHardwareInputSet() { HardwareInputSet *inputSet = OSystem_SDL::getHardwareInputSet(); // Add WebOS specific keys - keySet->addHardwareInput(new HardwareInput("FORWARD", + inputSet->addHardwareInput(new HardwareInput("FORWARD", KeyState((KeyCode) 229, 229, 0), "Forward")); // Return the modified hardware key set -- cgit v1.2.3 From 4d1e6c3d54fc692697144ebe2d4799fa67f30203 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Mon, 27 Feb 2012 13:28:40 -0600 Subject: KEYMAPPER: Move HardwareInputSet implementation out of header file --- backends/keymapper/hardware-input.cpp | 109 ++++++++++++++++++++++++++++++++++ backends/keymapper/hardware-input.h | 78 ++++-------------------- backends/module.mk | 1 + 3 files changed, 120 insertions(+), 68 deletions(-) create mode 100644 backends/keymapper/hardware-input.cpp (limited to 'backends') diff --git a/backends/keymapper/hardware-input.cpp b/backends/keymapper/hardware-input.cpp new file mode 100644 index 0000000000..801c77f4aa --- /dev/null +++ b/backends/keymapper/hardware-input.cpp @@ -0,0 +1,109 @@ +/* ScummVM - Graphic Adventure Engine +* +* ScummVM is the legal property of its developers, whose names +* are too numerous to list here. Please refer to the COPYRIGHT +* file distributed with this source distribution. +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +*/ + +#include "backends/keymapper/hardware-input.h" + +#ifdef ENABLE_KEYMAPPER + +#include "backends/keymapper/keymapper.h" + +namespace Common { + +HardwareInputSet::HardwareInputSet(const KeyTableEntry *keys, const ModifierTableEntry *modifiers) { + addHardwareInputs(keys, modifiers); +} + +HardwareInputSet::~HardwareInputSet() { + List::const_iterator it; + + for (it = _inputs.begin(); it != _inputs.end(); it++) + delete *it; +} + +void HardwareInputSet::addHardwareInput(const HardwareInput *input) { + checkForInput(input); + _inputs.push_back(input); +} + +const HardwareInput *HardwareInputSet::findHardwareInput(String id) const { + List::const_iterator it; + + for (it = _inputs.begin(); it != _inputs.end(); it++) { + if ((*it)->id == id) + return (*it); + } + return 0; +} + +const HardwareInput *HardwareInputSet::findHardwareInput(const KeyState& keystate) const { + List::const_iterator it; + + for (it = _inputs.begin(); it != _inputs.end(); it++) { + if ((*it)->key == keystate) + return (*it); + } + return 0; +} + +void HardwareInputSet::addHardwareInputs(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) { + const KeyTableEntry *key; + const ModifierTableEntry *mod; + char fullKeyId[50]; + char fullKeyDesc[100]; + uint16 ascii; + + for (mod = modifiers; mod->id; mod++) { + for (key = keys; key->hwId; key++) { + ascii = key->ascii; + + if (mod->shiftable && key->shiftable) { + snprintf(fullKeyId, 50, "%s%c", mod->id, toupper(key->hwId[0])); + snprintf(fullKeyDesc, 100, "%s%c", mod->desc, toupper(key->desc[0])); + ascii = toupper(key->ascii); + } else if (mod->shiftable) { + snprintf(fullKeyId, 50, "S+%s%s", mod->id, key->hwId); + snprintf(fullKeyDesc, 100, "Shift+%s%s", mod->desc, key->desc); + } else { + snprintf(fullKeyId, 50, "%s%s", mod->id, key->hwId); + snprintf(fullKeyDesc, 100, "%s%s", mod->desc, key->desc); + } + + addHardwareInput(new HardwareInput(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc)); + } + } +} + +void HardwareInputSet::checkForInput(const HardwareInput *input) { + List::iterator it; + + for (it = _inputs.begin(); it != _inputs.end(); it++) { + if ((*it)->id == input->id) + error("Error adding HardwareInput '%s' - id of %s already in use!", input->description.c_str(), input->id.c_str()); + else if ((*it)->key == input->key) + error("Error adding HardwareInput '%s' - key already in use!", input->description.c_str()); + } +} + +} //namespace Common + +#endif // #ifdef ENABLE_KEYMAPPER + diff --git a/backends/keymapper/hardware-input.h b/backends/keymapper/hardware-input.h index 70e0f986fa..eb165e7b8b 100644 --- a/backends/keymapper/hardware-input.h +++ b/backends/keymapper/hardware-input.h @@ -27,6 +27,9 @@ #ifdef ENABLE_KEYMAPPER +#include "common/keyboard.h" +#include "common/list.h" +#include "common/str.h" #include "common/textconsole.h" namespace Common { @@ -85,43 +88,17 @@ public: * @param keys table of available keys * @param modifiers table of available modifiers */ - HardwareInputSet(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) { - addHardwareInputs(keys, modifiers); - } + HardwareInputSet(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]); HardwareInputSet() { } - virtual ~HardwareInputSet() { - List::const_iterator it; - - for (it = _inputs.begin(); it != _inputs.end(); it++) - delete *it; - } - - void addHardwareInput(const HardwareInput *input) { - checkForInput(input); - _inputs.push_back(input); - } + virtual ~HardwareInputSet(); - const HardwareInput *findHardwareInput(String id) const { - List::const_iterator it; + void addHardwareInput(const HardwareInput *input); - for (it = _inputs.begin(); it != _inputs.end(); it++) { - if ((*it)->id == id) - return (*it); - } - return 0; - } + const HardwareInput *findHardwareInput(String id) const; - const HardwareInput *findHardwareInput(const KeyState& keystate) const { - List::const_iterator it; - - for (it = _inputs.begin(); it != _inputs.end(); it++) { - if ((*it)->key == keystate) - return (*it); - } - return 0; - } + const HardwareInput *findHardwareInput(const KeyState& keystate) const; const List &getHardwareInputs() const { return _inputs; @@ -136,46 +113,11 @@ public: * @param keys table of available keys * @param modifiers table of available modifiers */ - void addHardwareInputs(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) { - const KeyTableEntry *key; - const ModifierTableEntry *mod; - char fullKeyId[50]; - char fullKeyDesc[100]; - uint16 ascii; - - for (mod = modifiers; mod->id; mod++) { - for (key = keys; key->hwId; key++) { - ascii = key->ascii; - - if (mod->shiftable && key->shiftable) { - snprintf(fullKeyId, 50, "%s%c", mod->id, toupper(key->hwId[0])); - snprintf(fullKeyDesc, 100, "%s%c", mod->desc, toupper(key->desc[0])); - ascii = toupper(key->ascii); - } else if (mod->shiftable) { - snprintf(fullKeyId, 50, "S+%s%s", mod->id, key->hwId); - snprintf(fullKeyDesc, 100, "Shift+%s%s", mod->desc, key->desc); - } else { - snprintf(fullKeyId, 50, "%s%s", mod->id, key->hwId); - snprintf(fullKeyDesc, 100, "%s%s", mod->desc, key->desc); - } - - addHardwareInput(new HardwareInput(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc)); - } - } - } + void addHardwareInputs(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]); private: - void checkForInput(const HardwareInput *input) { - List::iterator it; - - for (it = _inputs.begin(); it != _inputs.end(); it++) { - if ((*it)->id == input->id) - error("Error adding HardwareInput '%s' - id of %s already in use!", input->description.c_str(), input->id.c_str()); - else if ((*it)->key == input->key) - error("Error adding HardwareInput '%s' - key already in use!", input->description.c_str()); - } - } + void checkForInput(const HardwareInput *input); List _inputs; }; diff --git a/backends/module.mk b/backends/module.mk index 37209ffcef..95725d9d87 100644 --- a/backends/module.mk +++ b/backends/module.mk @@ -33,6 +33,7 @@ endif ifdef ENABLE_KEYMAPPER MODULE_OBJS += \ keymapper/action.o \ + keymapper/hardware-input.o \ keymapper/keymap.o \ keymapper/keymapper.o \ keymapper/remap-dialog.o -- cgit v1.2.3 From 477c1b9a87046f17c165e66f566d91d0906a8fcd Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Tue, 28 Feb 2012 06:38:07 -0600 Subject: KEYMAPPER: HardwareInputSet now has defaults Ports can add additional special keys. SDL no longer carries the static tables. Default behavior unchanged: HardwareInputSet() still gives an empty one. --- backends/keymapper/hardware-input.cpp | 188 ++++++++++++++++++++++++++++++--- backends/keymapper/hardware-input.h | 28 ++--- backends/keymapper/keymapper.cpp | 4 +- backends/platform/maemo/maemo.cpp | 2 +- backends/platform/sdl/hardwarekeys.cpp | 181 ------------------------------- backends/platform/sdl/module.mk | 1 - backends/platform/sdl/sdl.h | 3 - 7 files changed, 194 insertions(+), 213 deletions(-) delete mode 100644 backends/platform/sdl/hardwarekeys.cpp (limited to 'backends') diff --git a/backends/keymapper/hardware-input.cpp b/backends/keymapper/hardware-input.cpp index 801c77f4aa..a09f0b54fc 100644 --- a/backends/keymapper/hardware-input.cpp +++ b/backends/keymapper/hardware-input.cpp @@ -28,26 +28,181 @@ namespace Common { -HardwareInputSet::HardwareInputSet(const KeyTableEntry *keys, const ModifierTableEntry *modifiers) { - addHardwareInputs(keys, modifiers); +static const KeyTableEntry defaultKeys[] = { + {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", false}, + {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", false}, + {"CLEAR", KEYCODE_CLEAR, 0, "Clear", false}, + {"RETURN", KEYCODE_RETURN, ASCII_RETURN, "Return", false}, + {"PAUSE", KEYCODE_PAUSE, 0, "Pause", false}, + {"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", false}, + {"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", false}, + {"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", false}, + {"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", false}, + {"HASH", KEYCODE_HASH, '#', "#", false}, + {"DOLLAR", KEYCODE_DOLLAR, '$', "$", false}, + {"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", false}, + {"QUOTE", KEYCODE_QUOTE, '\'', "'", false}, + {"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", false}, + {"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", false}, + {"ASTERISK", KEYCODE_ASTERISK, '*', "*", false}, + {"PLUS", KEYCODE_PLUS, '+', "+", false}, + {"COMMA", KEYCODE_COMMA, ',', ",", false}, + {"MINUS", KEYCODE_MINUS, '-', "-", false}, + {"PERIOD", KEYCODE_PERIOD, '.', ".", false}, + {"SLASH", KEYCODE_SLASH, '/', "/", false}, + {"0", KEYCODE_0, '0', "0", false}, + {"1", KEYCODE_1, '1', "1", false}, + {"2", KEYCODE_2, '2', "2", false}, + {"3", KEYCODE_3, '3', "3", false}, + {"4", KEYCODE_4, '4', "4", false}, + {"5", KEYCODE_5, '5', "5", false}, + {"6", KEYCODE_6, '6', "6", false}, + {"7", KEYCODE_7, '7', "7", false}, + {"8", KEYCODE_8, '8', "8", false}, + {"9", KEYCODE_9, '9', "9", false}, + {"COLON", KEYCODE_COLON, ':', ":", false}, + {"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", false}, + {"LESS", KEYCODE_LESS, '<', "<", false}, + {"EQUALS", KEYCODE_EQUALS, '=', "=", false}, + {"GREATER", KEYCODE_GREATER, '>', ">", false}, + {"QUESTION", KEYCODE_QUESTION, '?', "?", false}, + {"AT", KEYCODE_AT, '@', "@", false}, + + {"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", false}, + {"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", false}, + {"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", false}, + {"CARET", KEYCODE_CARET, '^', "^", false}, + {"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", false}, + {"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", false}, + {"a", KEYCODE_a, 'a', "a", true}, + {"b", KEYCODE_b, 'b', "b", true}, + {"c", KEYCODE_c, 'c', "c", true}, + {"d", KEYCODE_d, 'd', "d", true}, + {"e", KEYCODE_e, 'e', "e", true}, + {"f", KEYCODE_f, 'f', "f", true}, + {"g", KEYCODE_g, 'g', "g", true}, + {"h", KEYCODE_h, 'h', "h", true}, + {"i", KEYCODE_i, 'i', "i", true}, + {"j", KEYCODE_j, 'j', "j", true}, + {"k", KEYCODE_k, 'k', "k", true}, + {"l", KEYCODE_l, 'l', "l", true}, + {"m", KEYCODE_m, 'm', "m", true}, + {"n", KEYCODE_n, 'n', "n", true}, + {"o", KEYCODE_o, 'o', "o", true}, + {"p", KEYCODE_p, 'p', "p", true}, + {"q", KEYCODE_q, 'q', "q", true}, + {"r", KEYCODE_r, 'r', "r", true}, + {"s", KEYCODE_s, 's', "s", true}, + {"t", KEYCODE_t, 't', "t", true}, + {"u", KEYCODE_u, 'u', "u", true}, + {"v", KEYCODE_v, 'v', "v", true}, + {"w", KEYCODE_w, 'w', "w", true}, + {"x", KEYCODE_x, 'x', "x", true}, + {"y", KEYCODE_y, 'y', "y", true}, + {"z", KEYCODE_z, 'z', "z", true}, + {"DELETE", KEYCODE_DELETE, 0, "Del", false}, + + // Numeric keypad + {"KP0", KEYCODE_KP0, 0, "KP0", false}, + {"KP1", KEYCODE_KP1, 0, "KP1", false}, + {"KP2", KEYCODE_KP2, 0, "KP2", false}, + {"KP3", KEYCODE_KP3, 0, "KP3", false}, + {"KP4", KEYCODE_KP4, 0, "KP4", false}, + {"KP5", KEYCODE_KP5, 0, "KP5", false}, + {"KP6", KEYCODE_KP6, 0, "KP6", false}, + {"KP7", KEYCODE_KP7, 0, "KP7", false}, + {"KP8", KEYCODE_KP8, 0, "KP8", false}, + {"KP9", KEYCODE_KP9, 0, "KP9", false}, + {"KP_PERIOD", KEYCODE_KP_PERIOD, 0, "KP.", false}, + {"KP_DIVIDE", KEYCODE_KP_DIVIDE, 0, "KP/", false}, + {"KP_MULTIPLY", KEYCODE_KP_MULTIPLY, 0, "KP*", false}, + {"KP_MINUS", KEYCODE_KP_MINUS, 0, "KP-", false}, + {"KP_PLUS", KEYCODE_KP_PLUS, 0, "KP+", false}, + {"KP_ENTER", KEYCODE_KP_ENTER, 0, "KP Enter", false}, + {"KP_EQUALS", KEYCODE_KP_EQUALS, 0, "KP=", false}, + + // Arrows + Home/End pad + {"UP", KEYCODE_UP, 0, "Up", false}, + {"DOWN", KEYCODE_DOWN, 0, "Down", false}, + {"RIGHT", KEYCODE_RIGHT, 0, "Right", false}, + {"LEFT", KEYCODE_LEFT, 0, "Left", false}, + {"INSERT", KEYCODE_INSERT, 0, "Insert", false}, + {"HOME", KEYCODE_HOME, 0, "Home", false}, + {"END", KEYCODE_END, 0, "End", false}, + {"PAGEUP", KEYCODE_PAGEUP, 0, "PgUp", false}, + {"PAGEDOWN", KEYCODE_PAGEDOWN, 0, "PgDn", false}, + + // Function keys + {"F1", KEYCODE_F1, ASCII_F1, "F1", false}, + {"F2", KEYCODE_F2, ASCII_F2, "F2", false}, + {"F3", KEYCODE_F3, ASCII_F3, "F3", false}, + {"F4", KEYCODE_F4, ASCII_F4, "F4", false}, + {"F5", KEYCODE_F5, ASCII_F5, "F5", false}, + {"F6", KEYCODE_F6, ASCII_F6, "F6", false}, + {"F7", KEYCODE_F7, ASCII_F7, "F7", false}, + {"F8", KEYCODE_F8, ASCII_F8, "F8", false}, + {"F9", KEYCODE_F9, ASCII_F9, "F9", false}, + {"F10", KEYCODE_F10, ASCII_F10, "F10", false}, + {"F11", KEYCODE_F11, ASCII_F11, "F11", false}, + {"F12", KEYCODE_F12, ASCII_F12, "F12", false}, + {"F13", KEYCODE_F13, 0, "F13", false}, + {"F14", KEYCODE_F14, 0, "F14", false}, + {"F15", KEYCODE_F15, 0, "F15", false}, + + // Miscellaneous function keys + {"HELP", KEYCODE_HELP, 0, "Help", false}, + {"PRINT", KEYCODE_PRINT, 0, "Print", false}, + {"SYSREQ", KEYCODE_SYSREQ, 0, "SysRq", false}, + {"BREAK", KEYCODE_BREAK, 0, "Break", false}, + {"MENU", KEYCODE_MENU, 0, "Menu", false}, + // Power Macintosh power key + {"POWER", KEYCODE_POWER, 0, "Power", false}, + // Some european keyboards + {"EURO", KEYCODE_EURO, 0, "Euro", false}, + // Atari keyboard has Undo + {"UNDO", KEYCODE_UNDO, 0, "Undo", false}, + {0, KEYCODE_INVALID, 0, 0, false} +}; + +static const ModifierTableEntry defaultModifiers[] = { + { 0, "", "", false }, + { KBD_CTRL, "C+", "Ctrl+", false }, + { KBD_ALT, "A+", "Alt+", false }, + { KBD_SHIFT, "", "", true }, + { KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", false }, + { KBD_SHIFT | KBD_CTRL, "S+C+", "Shift+Ctrl+", true }, + { KBD_SHIFT | KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", true }, + { 0, 0, 0, false } +}; + +HardwareInputSet::HardwareInputSet(bool useDefault, const KeyTableEntry *keys, const ModifierTableEntry *modifiers) { + if (useDefault) + addHardwareInputs(defaultKeys, defaultModifiers); + if (keys) + addHardwareInputs(keys, modifiers ? modifiers : defaultModifiers); } HardwareInputSet::~HardwareInputSet() { List::const_iterator it; - for (it = _inputs.begin(); it != _inputs.end(); it++) + for (it = _inputs.begin(); it != _inputs.end(); ++it) delete *it; } void HardwareInputSet::addHardwareInput(const HardwareInput *input) { - checkForInput(input); + assert(input); + + debug(8, "Adding hardware input [%s][%s]", input->id.c_str(), input->description.c_str()); + + removeHardwareInput(input); + _inputs.push_back(input); } const HardwareInput *HardwareInputSet::findHardwareInput(String id) const { List::const_iterator it; - for (it = _inputs.begin(); it != _inputs.end(); it++) { + for (it = _inputs.begin(); it != _inputs.end(); ++it) { if ((*it)->id == id) return (*it); } @@ -57,7 +212,7 @@ const HardwareInput *HardwareInputSet::findHardwareInput(String id) const { const HardwareInput *HardwareInputSet::findHardwareInput(const KeyState& keystate) const { List::const_iterator it; - for (it = _inputs.begin(); it != _inputs.end(); it++) { + for (it = _inputs.begin(); it != _inputs.end(); ++it) { if ((*it)->key == keystate) return (*it); } @@ -92,14 +247,23 @@ void HardwareInputSet::addHardwareInputs(const KeyTableEntry keys[], const Modif } } -void HardwareInputSet::checkForInput(const HardwareInput *input) { +void HardwareInputSet::addHardwareInputs(const KeyTableEntry keys[]) { + addHardwareInputs(keys, defaultModifiers); +} + +void HardwareInputSet::removeHardwareInput(const HardwareInput *input) { + if (!input) + return; + List::iterator it; - for (it = _inputs.begin(); it != _inputs.end(); it++) { - if ((*it)->id == input->id) - error("Error adding HardwareInput '%s' - id of %s already in use!", input->description.c_str(), input->id.c_str()); - else if ((*it)->key == input->key) - error("Error adding HardwareInput '%s' - key already in use!", input->description.c_str()); + for (it = _inputs.begin(); it != _inputs.end(); ++it) { + const HardwareInput *entry = (*it); + if (entry->id == input->id || entry->key == input->key) { + debug(7, "Removing hardware input [%s] (%s) because it matches [%s] (%s)", entry->id.c_str(), entry->description.c_str(), input->id.c_str(), input->description.c_str()); + delete entry; + _inputs.erase(it); + } } } diff --git a/backends/keymapper/hardware-input.h b/backends/keymapper/hardware-input.h index eb165e7b8b..9396765bbe 100644 --- a/backends/keymapper/hardware-input.h +++ b/backends/keymapper/hardware-input.h @@ -85,12 +85,11 @@ public: /** * Add hardware input keys to the set out of key and modifier tables. - * @param keys table of available keys - * @param modifiers table of available modifiers + * @param useDefault auto-add the built-in default inputs + * @param keys table of available keys + * @param modifiers table of available modifiers */ - HardwareInputSet(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]); - - HardwareInputSet() { } + HardwareInputSet(bool useDefault = false, const KeyTableEntry keys[] = 0, const ModifierTableEntry modifiers[] = 0); virtual ~HardwareInputSet(); @@ -100,13 +99,9 @@ public: const HardwareInput *findHardwareInput(const KeyState& keystate) const; - const List &getHardwareInputs() const { - return _inputs; - } + const List &getHardwareInputs() const { return _inputs; } - uint size() const { - return _inputs.size(); - } + uint size() const { return _inputs.size(); } /** * Add hardware inputs to the set out of key and modifier tables. @@ -115,9 +110,16 @@ public: */ void addHardwareInputs(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]); -private: + /** + * Add hardware inputs to the set out of a key table. + * The default modifiers are applied to the key entries + * @param keys table of available keys + */ + void addHardwareInputs(const KeyTableEntry keys[]); - void checkForInput(const HardwareInput *input); + void removeHardwareInput(const HardwareInput *input); + +private: List _inputs; }; diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp index 719902ef20..bda4cd47da 100644 --- a/backends/keymapper/keymapper.cpp +++ b/backends/keymapper/keymapper.cpp @@ -69,8 +69,8 @@ void Keymapper::registerHardwareInputSet(HardwareInputSet *inputs) { error("Hardware input set already registered"); if (!inputs) { - warning("No hardware input are supplied"); - return; + warning("No hardware input were defined, using defaults"); + inputs = new HardwareInputSet(true); } _hardwareInputs = inputs; diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index 5e8b6e16a7..d1cdbc96c0 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -183,7 +183,7 @@ void OSystem_SDL_Maemo::setupIcon() { #ifdef ENABLE_KEYMAPPER Common::HardwareInputSet *OSystem_SDL_Maemo::getHardwareInputSet() { - return new Common::HardwareInputSet(Common::maemoKeys, Common::maemoModifiers); + return new Common::HardwareInputSet(false, Common::maemoKeys, Common::maemoModifiers); } Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() { diff --git a/backends/platform/sdl/hardwarekeys.cpp b/backends/platform/sdl/hardwarekeys.cpp deleted file mode 100644 index 0b73bfa467..0000000000 --- a/backends/platform/sdl/hardwarekeys.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#include "backends/platform/sdl/sdl.h" -#include "backends/keymapper/keymapper.h" -#include "common/keyboard.h" - -#ifdef ENABLE_KEYMAPPER - -using namespace Common; - -static const KeyTableEntry sdlKeys[] = { - {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", false}, - {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", false}, - {"CLEAR", KEYCODE_CLEAR, 0, "Clear", false}, - {"RETURN", KEYCODE_RETURN, ASCII_RETURN, "Return", false}, - {"PAUSE", KEYCODE_PAUSE, 0, "Pause", false}, - {"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", false}, - {"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", false}, - {"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", false}, - {"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", false}, - {"HASH", KEYCODE_HASH, '#', "#", false}, - {"DOLLAR", KEYCODE_DOLLAR, '$', "$", false}, - {"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", false}, - {"QUOTE", KEYCODE_QUOTE, '\'', "'", false}, - {"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", false}, - {"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", false}, - {"ASTERISK", KEYCODE_ASTERISK, '*', "*", false}, - {"PLUS", KEYCODE_PLUS, '+', "+", false}, - {"COMMA", KEYCODE_COMMA, ',', ",", false}, - {"MINUS", KEYCODE_MINUS, '-', "-", false}, - {"PERIOD", KEYCODE_PERIOD, '.', ".", false}, - {"SLASH", KEYCODE_SLASH, '/', "/", false}, - {"0", KEYCODE_0, '0', "0", false}, - {"1", KEYCODE_1, '1', "1", false}, - {"2", KEYCODE_2, '2', "2", false}, - {"3", KEYCODE_3, '3', "3", false}, - {"4", KEYCODE_4, '4', "4", false}, - {"5", KEYCODE_5, '5', "5", false}, - {"6", KEYCODE_6, '6', "6", false}, - {"7", KEYCODE_7, '7', "7", false}, - {"8", KEYCODE_8, '8', "8", false}, - {"9", KEYCODE_9, '9', "9", false}, - {"COLON", KEYCODE_COLON, ':', ":", false}, - {"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", false}, - {"LESS", KEYCODE_LESS, '<', "<", false}, - {"EQUALS", KEYCODE_EQUALS, '=', "=", false}, - {"GREATER", KEYCODE_GREATER, '>', ">", false}, - {"QUESTION", KEYCODE_QUESTION, '?', "?", false}, - {"AT", KEYCODE_AT, '@', "@", false}, - - {"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", false}, - {"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", false}, - {"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", false}, - {"CARET", KEYCODE_CARET, '^', "^", false}, - {"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", false}, - {"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", false}, - {"a", KEYCODE_a, 'a', "a", true}, - {"b", KEYCODE_b, 'b', "b", true}, - {"c", KEYCODE_c, 'c', "c", true}, - {"d", KEYCODE_d, 'd', "d", true}, - {"e", KEYCODE_e, 'e', "e", true}, - {"f", KEYCODE_f, 'f', "f", true}, - {"g", KEYCODE_g, 'g', "g", true}, - {"h", KEYCODE_h, 'h', "h", true}, - {"i", KEYCODE_i, 'i', "i", true}, - {"j", KEYCODE_j, 'j', "j", true}, - {"k", KEYCODE_k, 'k', "k", true}, - {"l", KEYCODE_l, 'l', "l", true}, - {"m", KEYCODE_m, 'm', "m", true}, - {"n", KEYCODE_n, 'n', "n", true}, - {"o", KEYCODE_o, 'o', "o", true}, - {"p", KEYCODE_p, 'p', "p", true}, - {"q", KEYCODE_q, 'q', "q", true}, - {"r", KEYCODE_r, 'r', "r", true}, - {"s", KEYCODE_s, 's', "s", true}, - {"t", KEYCODE_t, 't', "t", true}, - {"u", KEYCODE_u, 'u', "u", true}, - {"v", KEYCODE_v, 'v', "v", true}, - {"w", KEYCODE_w, 'w', "w", true}, - {"x", KEYCODE_x, 'x', "x", true}, - {"y", KEYCODE_y, 'y', "y", true}, - {"z", KEYCODE_z, 'z', "z", true}, - {"DELETE", KEYCODE_DELETE, 0, "Del", false}, - - // Numeric keypad - {"KP0", KEYCODE_KP0, 0, "KP0", false}, - {"KP1", KEYCODE_KP1, 0, "KP1", false}, - {"KP2", KEYCODE_KP2, 0, "KP2", false}, - {"KP3", KEYCODE_KP3, 0, "KP3", false}, - {"KP4", KEYCODE_KP4, 0, "KP4", false}, - {"KP5", KEYCODE_KP5, 0, "KP5", false}, - {"KP6", KEYCODE_KP6, 0, "KP6", false}, - {"KP7", KEYCODE_KP7, 0, "KP7", false}, - {"KP8", KEYCODE_KP8, 0, "KP8", false}, - {"KP9", KEYCODE_KP9, 0, "KP9", false}, - {"KP_PERIOD", KEYCODE_KP_PERIOD, 0, "KP.", false}, - {"KP_DIVIDE", KEYCODE_KP_DIVIDE, 0, "KP/", false}, - {"KP_MULTIPLY", KEYCODE_KP_MULTIPLY, 0, "KP*", false}, - {"KP_MINUS", KEYCODE_KP_MINUS, 0, "KP-", false}, - {"KP_PLUS", KEYCODE_KP_PLUS, 0, "KP+", false}, - {"KP_ENTER", KEYCODE_KP_ENTER, 0, "KP Enter", false}, - {"KP_EQUALS", KEYCODE_KP_EQUALS, 0, "KP=", false}, - - // Arrows + Home/End pad - {"UP", KEYCODE_UP, 0, "Up", false}, - {"DOWN", KEYCODE_DOWN, 0, "Down", false}, - {"RIGHT", KEYCODE_RIGHT, 0, "Right", false}, - {"LEFT", KEYCODE_LEFT, 0, "Left", false}, - {"INSERT", KEYCODE_INSERT, 0, "Insert", false}, - {"HOME", KEYCODE_HOME, 0, "Home", false}, - {"END", KEYCODE_END, 0, "End", false}, - {"PAGEUP", KEYCODE_PAGEUP, 0, "PgUp", false}, - {"PAGEDOWN", KEYCODE_PAGEDOWN, 0, "PgDn", false}, - - // Function keys - {"F1", KEYCODE_F1, ASCII_F1, "F1", false}, - {"F2", KEYCODE_F2, ASCII_F2, "F2", false}, - {"F3", KEYCODE_F3, ASCII_F3, "F3", false}, - {"F4", KEYCODE_F4, ASCII_F4, "F4", false}, - {"F5", KEYCODE_F5, ASCII_F5, "F5", false}, - {"F6", KEYCODE_F6, ASCII_F6, "F6", false}, - {"F7", KEYCODE_F7, ASCII_F7, "F7", false}, - {"F8", KEYCODE_F8, ASCII_F8, "F8", false}, - {"F9", KEYCODE_F9, ASCII_F9, "F9", false}, - {"F10", KEYCODE_F10, ASCII_F10, "F10", false}, - {"F11", KEYCODE_F11, ASCII_F11, "F11", false}, - {"F12", KEYCODE_F12, ASCII_F12, "F12", false}, - {"F13", KEYCODE_F13, 0, "F13", false}, - {"F14", KEYCODE_F14, 0, "F14", false}, - {"F15", KEYCODE_F15, 0, "F15", false}, - - // Miscellaneous function keys - {"HELP", KEYCODE_HELP, 0, "Help", false}, - {"PRINT", KEYCODE_PRINT, 0, "Print", false}, - {"SYSREQ", KEYCODE_SYSREQ, 0, "SysRq", false}, - {"BREAK", KEYCODE_BREAK, 0, "Break", false}, - {"MENU", KEYCODE_MENU, 0, "Menu", false}, - // Power Macintosh power key - {"POWER", KEYCODE_POWER, 0, "Power", false}, - // Some european keyboards - {"EURO", KEYCODE_EURO, 0, "Euro", false}, - // Atari keyboard has Undo - {"UNDO", KEYCODE_UNDO, 0, "Undo", false}, - {0, KEYCODE_INVALID, 0, 0, false} -}; - -static const ModifierTableEntry sdlModifiers[] = { - { 0, "", "", false }, - { KBD_CTRL, "C+", "Ctrl+", false }, - { KBD_ALT, "A+", "Alt+", false }, - { KBD_SHIFT, "", "", true }, - { KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", false }, - { KBD_SHIFT | KBD_CTRL, "S+C+", "Shift+Ctrl+", true }, - { KBD_SHIFT | KBD_CTRL | KBD_ALT, "C+A+", "Ctrl+Alt+", true }, - { 0, 0, 0, false } -}; - -Common::HardwareInputSet *OSystem_SDL::getHardwareInputSet() { - return new HardwareInputSet(sdlKeys, sdlModifiers); -} -#endif diff --git a/backends/platform/sdl/module.mk b/backends/platform/sdl/module.mk index f1afe37349..98a8265301 100644 --- a/backends/platform/sdl/module.mk +++ b/backends/platform/sdl/module.mk @@ -1,7 +1,6 @@ MODULE := backends/platform/sdl MODULE_OBJS := \ - hardwarekeys.o \ main.o \ sdl.o diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 51a7b2f577..f05207b482 100644 --- a/backends/platform/sdl/sdl.h +++ b/backends/platform/sdl/sdl.h @@ -57,9 +57,6 @@ public: #if defined(USE_TASKBAR) virtual void engineInit(); virtual void engineDone(); -#endif -#ifdef ENABLE_KEYMAPPER - virtual Common::HardwareInputSet *getHardwareInputSet(); #endif virtual void quit(); virtual void fatalError(); -- cgit v1.2.3 From 657206bc5b840006ea9f98767ade937f9fc0fab0 Mon Sep 17 00:00:00 2001 From: Tarek Soliman Date: Tue, 28 Feb 2012 06:39:09 -0600 Subject: MAEMO: Define only special keys to Keymapper Also get rid of static tables in headers. --- backends/platform/maemo/maemo-keys.h | 139 ----------------------------------- backends/platform/maemo/maemo.cpp | 14 +++- 2 files changed, 12 insertions(+), 141 deletions(-) delete mode 100644 backends/platform/maemo/maemo-keys.h (limited to 'backends') diff --git a/backends/platform/maemo/maemo-keys.h b/backends/platform/maemo/maemo-keys.h deleted file mode 100644 index ae3a746229..0000000000 --- a/backends/platform/maemo/maemo-keys.h +++ /dev/null @@ -1,139 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -#if defined(MAEMO) -#if defined(ENABLE_KEYMAPPER) - -#ifndef PLATFORM_SDL_MAEMO_KEYS_H -#define PLATFORM_SDL_MAEMO_KEYS_H - -#include "common/keyboard.h" - -#include "backends/keymapper/hardware-input.h" - -namespace Common { - -static const ModifierTableEntry maemoModifiers[] = { - { 0, "", "", false }, - { KBD_CTRL, "C+", "Ctrl+", false }, - { KBD_SHIFT, "", "", true }, - { KBD_SHIFT | KBD_CTRL, "S+C+", "Shift+Ctrl+", true }, - { 0, 0, 0, false } -}; - -static const KeyTableEntry maemoKeys[] = { - {"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", false}, - {"TAB", KEYCODE_TAB, ASCII_TAB, "Tab", false}, - {"CLEAR", KEYCODE_CLEAR, 0, "Clear", false}, - {"RETURN", KEYCODE_RETURN, ASCII_RETURN, "MCenter", false}, - {"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", false}, - {"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", false}, - {"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", false}, - {"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", false}, - {"HASH", KEYCODE_HASH, '#', "#", false}, - {"DOLLAR", KEYCODE_DOLLAR, '$', "$", false}, - {"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", false}, - {"QUOTE", KEYCODE_QUOTE, '\'', "'", false}, - {"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", false}, - {"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", false}, - {"ASTERISK", KEYCODE_ASTERISK, '*', "*", false}, - {"PLUS", KEYCODE_PLUS, '+', "+", false}, - {"COMMA", KEYCODE_COMMA, ',', ",", false}, - {"MINUS", KEYCODE_MINUS, '-', "-", false}, - {"PERIOD", KEYCODE_PERIOD, '.', ".", false}, - {"SLASH", KEYCODE_SLASH, '/', "/", false}, - {"0", KEYCODE_0, '0', "0", false}, - {"1", KEYCODE_1, '1', "1", false}, - {"2", KEYCODE_2, '2', "2", false}, - {"3", KEYCODE_3, '3', "3", false}, - {"4", KEYCODE_4, '4', "4", false}, - {"5", KEYCODE_5, '5', "5", false}, - {"6", KEYCODE_6, '6', "6", false}, - {"7", KEYCODE_7, '7', "7", false}, - {"8", KEYCODE_8, '8', "8", false}, - {"9", KEYCODE_9, '9', "9", false}, - {"COLON", KEYCODE_COLON, ':', ":", false}, - {"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", false}, - {"LESS", KEYCODE_LESS, '<', "<", false}, - {"EQUALS", KEYCODE_EQUALS, '=', "=", false}, - {"GREATER", KEYCODE_GREATER, '>', ">", false}, - {"QUESTION", KEYCODE_QUESTION, '?', "?", false}, - {"AT", KEYCODE_AT, '@', "@", false}, - - {"LEFTBRACKET", KEYCODE_LEFTBRACKET, '[', "[", false}, - {"BACKSLASH", KEYCODE_BACKSLASH, '\\', "\\", false}, - {"RIGHTBRACKET", KEYCODE_RIGHTBRACKET, ']', "]", false}, - {"CARET", KEYCODE_CARET, '^', "^", false}, - {"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", false}, - {"BACKQUOTE", KEYCODE_BACKQUOTE, '`', "`", false}, - {"a", KEYCODE_a, 'a', "a", true}, - {"b", KEYCODE_b, 'b', "b", true}, - {"c", KEYCODE_c, 'c', "c", true}, - {"d", KEYCODE_d, 'd', "d", true}, - {"e", KEYCODE_e, 'e', "e", true}, - {"f", KEYCODE_f, 'f', "f", true}, - {"g", KEYCODE_g, 'g', "g", true}, - {"h", KEYCODE_h, 'h', "h", true}, - {"i", KEYCODE_i, 'i', "i", true}, - {"j", KEYCODE_j, 'j', "j", true}, - {"k", KEYCODE_k, 'k', "k", true}, - {"l", KEYCODE_l, 'l', "l", true}, - {"m", KEYCODE_m, 'm', "m", true}, - {"n", KEYCODE_n, 'n', "n", true}, - {"o", KEYCODE_o, 'o', "o", true}, - {"p", KEYCODE_p, 'p', "p", true}, - {"q", KEYCODE_q, 'q', "q", true}, - {"r", KEYCODE_r, 'r', "r", true}, - {"s", KEYCODE_s, 's', "s", true}, - {"t", KEYCODE_t, 't', "t", true}, - {"u", KEYCODE_u, 'u', "u", true}, - {"v", KEYCODE_v, 'v', "v", true}, - {"w", KEYCODE_w, 'w', "w", true}, - {"x", KEYCODE_x, 'x', "x", true}, - {"y", KEYCODE_y, 'y', "y", true}, - {"z", KEYCODE_z, 'z', "z", true}, - {"DELETE", KEYCODE_DELETE, 0, "Del", false}, - - {"KP_ENTER", KEYCODE_KP_ENTER, 0, "Enter", false}, - - // Arrows + Home/End pad - {"UP", KEYCODE_UP, 0, "Up", false}, - {"DOWN", KEYCODE_DOWN, 0, "Down", false}, - {"RIGHT", KEYCODE_RIGHT, 0, "Right", false}, - {"LEFT", KEYCODE_LEFT, 0, "Left", false}, - - // Function keys - {"MENU", KEYCODE_F11, 0, "Menu", false}, - {"HOME", KEYCODE_F12, 0, "Home", false}, - {"FULLSCREEN", KEYCODE_F13, 0, "FullScreen", false}, - {"ZOOMPLUS", KEYCODE_F14, 0, "Zoom+", false}, - {"ZOOMMINUS", KEYCODE_F15, 0, "Zoom-", false}, - - {0, KEYCODE_INVALID, 0, 0, false} -}; - -} // namespace Common - -#endif // ifndef PLATFORM_SDL_MAEMO_KEYS_H - -#endif // if defined(ENABLE_KEYMAPPER) -#endif // if defined(MAEMO) diff --git a/backends/platform/maemo/maemo.cpp b/backends/platform/maemo/maemo.cpp index d1cdbc96c0..e296d4787c 100644 --- a/backends/platform/maemo/maemo.cpp +++ b/backends/platform/maemo/maemo.cpp @@ -28,7 +28,6 @@ #include "common/config-manager.h" #include "backends/platform/maemo/maemo.h" -#include "backends/platform/maemo/maemo-keys.h" #include "backends/events/maemosdl/maemosdl-events.h" #include "backends/graphics/maemosdl/maemosdl-graphics.h" #include "backends/keymapper/keymapper.h" @@ -181,9 +180,20 @@ void OSystem_SDL_Maemo::setupIcon() { // http://bugzilla.libsdl.org/show_bug.cgi?id=586 } +static const Common::KeyTableEntry maemoKeys[] = { + // Function keys + {"MENU", Common::KEYCODE_F11, 0, "Menu", false}, + {"HOME", Common::KEYCODE_F12, 0, "Home", false}, + {"FULLSCREEN", Common::KEYCODE_F13, 0, "FullScreen", false}, + {"ZOOMPLUS", Common::KEYCODE_F14, 0, "Zoom+", false}, + {"ZOOMMINUS", Common::KEYCODE_F15, 0, "Zoom-", false}, + + {0, Common::KEYCODE_INVALID, 0, 0, false} +}; + #ifdef ENABLE_KEYMAPPER Common::HardwareInputSet *OSystem_SDL_Maemo::getHardwareInputSet() { - return new Common::HardwareInputSet(false, Common::maemoKeys, Common::maemoModifiers); + return new Common::HardwareInputSet(true, maemoKeys); } Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() { -- cgit v1.2.3 From aad85d957c86ec77f7974e983dbbdb40a4aa4f4c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 29 Feb 2012 19:02:17 +0100 Subject: IPHONE: Fall back to CLUT8 in case a non-supported screen mode is set up. This makes the iPhone backend conform with the 16bpp API and thus no longer causes assertions to fail in case the client code tries to set up an unsupported game screen format. --- backends/platform/iphone/osys_main.cpp | 2 +- backends/platform/iphone/osys_main.h | 3 +++ backends/platform/iphone/osys_video.mm | 12 +++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/osys_main.cpp b/backends/platform/iphone/osys_main.cpp index f3e0d97b97..9a33cd8968 100644 --- a/backends/platform/iphone/osys_main.cpp +++ b/backends/platform/iphone/osys_main.cpp @@ -60,7 +60,7 @@ OSystem_IPHONE::OSystem_IPHONE() : _screenOrientation(kScreenOrientationFlippedLandscape), _mouseClickAndDragEnabled(false), _gestureStartX(-1), _gestureStartY(-1), _fullScreenIsDirty(false), _fullScreenOverlayIsDirty(false), _mouseDirty(false), _timeSuspended(0), _lastDragPosX(-1), _lastDragPosY(-1), _screenChangeCount(0), - _mouseCursorPaletteEnabled(false) { + _mouseCursorPaletteEnabled(false), _gfxTransactionError(kTransactionSuccess) { _queuedInputEvent.type = Common::EVENT_INVALID; _touchpadModeEnabled = !iPhone_isHighResDevice(); _fsFactory = new POSIXFilesystemFactory(); diff --git a/backends/platform/iphone/osys_main.h b/backends/platform/iphone/osys_main.h index 5d0f60c34c..b443e22f56 100644 --- a/backends/platform/iphone/osys_main.h +++ b/backends/platform/iphone/osys_main.h @@ -65,6 +65,9 @@ protected: Graphics::Surface _framebuffer; + // For signaling that screen format set up might have failed. + TransactionError _gfxTransactionError; + // For use with the game texture uint16 _gamePalette[256]; // For use with the mouse texture diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index 2b5e78bd35..6f80a6cba3 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -84,6 +84,13 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm // to the texture buffer to avoid an additional copy step. [g_iPhoneViewInstance performSelectorOnMainThread:@selector(createScreenTexture) withObject:nil waitUntilDone: YES]; + // In case the client code tries to set up a non supported mode, we will + // fall back to CLUT8 and set the transaction error accordingly. + if (format && format->bytesPerPixel != 1 && *format != _videoContext->screenTexture.format) { + format = 0; + _gfxTransactionError = kTransactionFormatNotSupported; + } + if (!format || format->bytesPerPixel == 1) { _framebuffer.create(width, height, Graphics::PixelFormat::createFormatCLUT8()); } else { @@ -92,7 +99,6 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm format->rLoss, format->gLoss, format->bLoss, format->aLoss, format->rShift, format->gShift, format->bShift, format->aShift); #endif - assert(_videoContext->screenTexture.format == *format); // We directly draw on the screen texture in hi-color mode. Thus // we copy over its settings here and just replace the width and // height to avoid any problems. @@ -107,6 +113,7 @@ void OSystem_IPHONE::initSize(uint width, uint height, const Graphics::PixelForm } void OSystem_IPHONE::beginGFXTransaction() { + _gfxTransactionError = kTransactionSuccess; } OSystem::TransactionError OSystem_IPHONE::endGFXTransaction() { @@ -114,8 +121,7 @@ OSystem::TransactionError OSystem_IPHONE::endGFXTransaction() { updateOutputSurface(); [g_iPhoneViewInstance performSelectorOnMainThread:@selector(setGraphicsMode) withObject:nil waitUntilDone: YES]; - // TODO: Can we return better error codes? - return kTransactionSuccess; + return _gfxTransactionError; } void OSystem_IPHONE::updateOutputSurface() { -- cgit v1.2.3 From dec6082590a16e1b440f66a78724521cc85c6cf4 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 5 Mar 2012 20:44:41 +0100 Subject: IPHONE: Prefix all global variables with "g_". --- backends/platform/iphone/iphone_main.mm | 10 +++--- backends/platform/iphone/iphone_video.mm | 52 ++++++++++++++++---------------- 2 files changed, 31 insertions(+), 31 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_main.mm b/backends/platform/iphone/iphone_main.mm index 20406e6342..e76ffe866e 100644 --- a/backends/platform/iphone/iphone_main.mm +++ b/backends/platform/iphone/iphone_main.mm @@ -41,12 +41,12 @@ void iphone_main(int argc, char *argv[]); - (void)didRotate:(NSNotification *)notification; @end -static int gArgc; -static char **gArgv; +static int g_argc; +static char **g_argv; int main(int argc, char **argv) { - gArgc = argc; - gArgv = argv; + g_argc = argc; + g_argv = argv; NSAutoreleasePool *autoreleasePool = [ [NSAutoreleasePool alloc] init @@ -69,7 +69,7 @@ int main(int argc, char **argv) { - (void)mainLoop:(id)param { [[NSAutoreleasePool alloc] init]; - iphone_main(gArgc, gArgv); + iphone_main(g_argc, g_argv); exit(0); } diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 04aaf59b21..1c86a208b8 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -28,17 +28,17 @@ #include "graphics/colormasks.h" iPhoneView *g_iPhoneViewInstance = nil; -static int _fullWidth; -static int _fullHeight; +static int g_fullWidth; +static int g_fullHeight; -static int _needsScreenUpdate = 0; +static int g_needsScreenUpdate = 0; -static UITouch *_firstTouch = NULL; -static UITouch *_secondTouch = NULL; +static UITouch *g_firstTouch = NULL; +static UITouch *g_secondTouch = NULL; #if 0 -static long lastTick = 0; -static int frames = 0; +static long g_lastTick = 0; +static int g_frames = 0; #endif #define printOpenGLError() printOglError(__FILE__, __LINE__) @@ -57,13 +57,13 @@ int printOglError(const char *file, int line) { } bool iPhone_isHighResDevice() { - return _fullHeight > 480; + return g_fullHeight > 480; } void iPhone_updateScreen() { //printf("Mouse: (%i, %i)\n", mouseX, mouseY); - if (!_needsScreenUpdate) { - _needsScreenUpdate = 1; + if (!g_needsScreenUpdate) { + g_needsScreenUpdate = 1; [g_iPhoneViewInstance performSelectorOnMainThread:@selector(updateSurface) withObject:nil waitUntilDone: NO]; } } @@ -142,7 +142,7 @@ const char *iPhone_getDocumentsDir() { glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, _viewRenderbuffer); printOpenGLError(); // Retrieve the render buffer size. This *should* match the frame size, - // i.e. _fullWidth and _fullHeight. + // i.e. g_fullWidth and g_fullHeight. glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &_renderBufferWidth); printOpenGLError(); glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &_renderBufferHeight); printOpenGLError(); @@ -185,8 +185,8 @@ const char *iPhone_getDocumentsDir() { } } - _fullWidth = (int)frame.size.width; - _fullHeight = (int)frame.size.height; + g_fullWidth = (int)frame.size.width; + g_fullHeight = (int)frame.size.height; g_iPhoneViewInstance = self; @@ -247,15 +247,15 @@ const char *iPhone_getDocumentsDir() { - (void)drawRect:(CGRect)frame { #if 0 - if (lastTick == 0) { - lastTick = time(0); + if (g_lastTick == 0) { + g_lastTick = time(0); } - frames++; - if (time(0) > lastTick) { - lastTick = time(0); - printf("FPS: %i\n", frames); - frames = 0; + g_frames++; + if (time(0) > g_lastTick) { + g_lastTick = time(0); + printf("FPS: %i\n", g_frames); + g_frames = 0; } #endif } @@ -289,10 +289,10 @@ const char *iPhone_getDocumentsDir() { } - (void)updateSurface { - if (!_needsScreenUpdate) { + if (!g_needsScreenUpdate) { return; } - _needsScreenUpdate = 0; + g_needsScreenUpdate = 0; glClear(GL_COLOR_BUFFER_BIT); printOpenGLError(); @@ -685,7 +685,7 @@ const char *iPhone_getDocumentsDir() { if (![self getMouseCoords:point eventX:&x eventY:&y]) return; - _firstTouch = touch; + g_firstTouch = touch; [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseDown], @"type", @@ -703,7 +703,7 @@ const char *iPhone_getDocumentsDir() { if (![self getMouseCoords:point eventX:&x eventY:&y]) return; - _secondTouch = touch; + g_secondTouch = touch; [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseSecondDown], @"type", @@ -722,7 +722,7 @@ const char *iPhone_getDocumentsDir() { int x, y; for (UITouch *touch in touches) { - if (touch == _firstTouch) { + if (touch == g_firstTouch) { CGPoint point = [touch locationInView:self]; if (![self getMouseCoords:point eventX:&x eventY:&y]) return; @@ -735,7 +735,7 @@ const char *iPhone_getDocumentsDir() { nil ] ]; - } else if (touch == _secondTouch) { + } else if (touch == g_secondTouch) { CGPoint point = [touch locationInView:self]; if (![self getMouseCoords:point eventX:&x eventY:&y]) return; -- cgit v1.2.3 From 323899d70baaf76a9ad51713f9c0f36f5c8d3def Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 5 Mar 2012 20:46:45 +0100 Subject: IPOHNE: Move touch related global variables to iPhoneView. --- backends/platform/iphone/iphone_video.h | 3 +++ backends/platform/iphone/iphone_video.mm | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.h b/backends/platform/iphone/iphone_video.h index 55a4acb7c7..1405fe35f1 100644 --- a/backends/platform/iphone/iphone_video.h +++ b/backends/platform/iphone/iphone_video.h @@ -67,6 +67,9 @@ GLfloat _mouseScaleX, _mouseScaleY; int _scaledShakeOffsetY; + + UITouch *_firstTouch; + UITouch *_secondTouch; } - (id)initWithFrame:(struct CGRect)frame; diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 1c86a208b8..5b8d28e819 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -33,9 +33,6 @@ static int g_fullHeight; static int g_needsScreenUpdate = 0; -static UITouch *g_firstTouch = NULL; -static UITouch *g_secondTouch = NULL; - #if 0 static long g_lastTick = 0; static int g_frames = 0; @@ -197,6 +194,9 @@ const char *iPhone_getDocumentsDir() { _scaledShakeOffsetY = 0; + _firstTouch = NULL; + _secondTouch = NULL; + _gameScreenVertCoords[0] = _gameScreenVertCoords[1] = _gameScreenVertCoords[2] = _gameScreenVertCoords[3] = _gameScreenVertCoords[4] = _gameScreenVertCoords[5] = @@ -685,7 +685,7 @@ const char *iPhone_getDocumentsDir() { if (![self getMouseCoords:point eventX:&x eventY:&y]) return; - g_firstTouch = touch; + _firstTouch = touch; [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseDown], @"type", @@ -703,7 +703,7 @@ const char *iPhone_getDocumentsDir() { if (![self getMouseCoords:point eventX:&x eventY:&y]) return; - g_secondTouch = touch; + _secondTouch = touch; [self addEvent: [[NSDictionary alloc] initWithObjectsAndKeys: [NSNumber numberWithInt:kInputMouseSecondDown], @"type", @@ -722,7 +722,7 @@ const char *iPhone_getDocumentsDir() { int x, y; for (UITouch *touch in touches) { - if (touch == g_firstTouch) { + if (touch == _firstTouch) { CGPoint point = [touch locationInView:self]; if (![self getMouseCoords:point eventX:&x eventY:&y]) return; @@ -735,7 +735,7 @@ const char *iPhone_getDocumentsDir() { nil ] ]; - } else if (touch == g_secondTouch) { + } else if (touch == _secondTouch) { CGPoint point = [touch locationInView:self]; if (![self getMouseCoords:point eventX:&x eventY:&y]) return; -- cgit v1.2.3 From 62f59389a48fc8676329170c92ea7709ce5d9acb Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Mon, 5 Mar 2012 21:27:18 +0100 Subject: IPHONE: Send dealloc message to iPhoneView's superclass at the end of dealloc. --- backends/platform/iphone/iphone_video.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends') diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 5b8d28e819..5b78237ff7 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -234,8 +234,6 @@ const char *iPhone_getDocumentsDir() { } - (void)dealloc { - [super dealloc]; - if (_keyboardView != nil) { [_keyboardView dealloc]; } @@ -243,6 +241,8 @@ const char *iPhone_getDocumentsDir() { _videoContext.screenTexture.free(); _videoContext.overlayTexture.free(); _videoContext.mouseTexture.free(); + + [super dealloc]; } - (void)drawRect:(CGRect)frame { -- cgit v1.2.3