diff options
Diffstat (limited to 'backends')
27 files changed, 340 insertions, 121 deletions
diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index f94171646a..0ca5bbb059 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -191,6 +191,8 @@ void SdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) { #endif if (mod & KMOD_CTRL) event.kbd.flags |= Common::KBD_CTRL; + if (mod & KMOD_META) + event.kbd.flags |= Common::KBD_META; // Sticky flags if (mod & KMOD_NUM) diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h index 2ba88c702b..ca4835126f 100644 --- a/backends/events/sdl/sdl-events.h +++ b/backends/events/sdl/sdl-events.h @@ -116,7 +116,7 @@ protected: //@} /** - * Assigns the mouse coords to the mouse event. Furthermore notify the + * Assigns the mouse coords to the mouse event. Furthermore notify the * graphics manager about the position change. */ virtual void processMouseEvent(Common::Event &event, int x, int y); diff --git a/backends/events/webossdl/webossdl-events.h b/backends/events/webossdl/webossdl-events.h index 99ed3105f8..1ba5c6fcbf 100644 --- a/backends/events/webossdl/webossdl-events.h +++ b/backends/events/webossdl/webossdl-events.h @@ -73,10 +73,10 @@ protected: // The current mouse position on the screen. int _curX, _curY; - + // The current screen dimensions int _screenX, _screenY; - + // The drag distance for linear gestures int _swipeDistX, _swipeDistY; @@ -107,7 +107,7 @@ protected: virtual bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event); virtual bool handleMouseMotion(SDL_Event &ev, Common::Event &event); virtual bool pollEvent(Common::Event &event); - + // Utility functions void calculateDimensions(); }; diff --git a/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp b/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp index f515343d3c..bd87c9fafd 100644 --- a/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp +++ b/backends/graphics/dinguxsdl/dinguxsdl-graphics.cpp @@ -479,7 +479,7 @@ void DINGUXSdlGraphicsManager::setFeatureState(OSystem::Feature f, bool enable) case OSystem::kFeatureCursorPalette: _cursorPaletteDisabled = !enable; blitCursor(); - break; + break; default: break; } diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp index 67041ae17b..fed02ef22e 100644 --- a/backends/graphics/openglsdl/openglsdl-graphics.cpp +++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp @@ -665,7 +665,7 @@ void OpenGLSdlGraphicsManager::notifyResize(const uint width, const uint height) void OpenGLSdlGraphicsManager::transformMouseCoordinates(Common::Point &point) { adjustMousePosition(point.x, point.y); } - + void OpenGLSdlGraphicsManager::notifyMousePos(Common::Point mouse) { setMousePosition(mouse.x, mouse.y); } diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp index 43c801287d..94262d0d92 100644 --- a/backends/midi/coreaudio.cpp +++ b/backends/midi/coreaudio.cpp @@ -172,10 +172,15 @@ int MidiDriver_CORE::open() { // Load custom soundfont, if specified if (ConfMan.hasKey("soundfont")) { - FSRef fsref; - FSSpec fsSpec; const char *soundfont = ConfMan.get("soundfont").c_str(); + // TODO: We should really check whether the file contains an + // actual soundfont... + +#if USE_DEPRECATED_COREAUDIO_API + // Before 10.5, we need to use kMusicDeviceProperty_SoundBankFSSpec + FSRef fsref; + FSSpec fsSpec; err = FSPathMakeRef ((const byte *)soundfont, &fsref, NULL); if (err == noErr) { @@ -183,8 +188,6 @@ int MidiDriver_CORE::open() { } if (err == noErr) { - // TODO: We should really check here whether the file contains an - // actual soundfont... err = AudioUnitSetProperty ( _synth, kMusicDeviceProperty_SoundBankFSSpec, kAudioUnitScope_Global, @@ -192,9 +195,27 @@ int MidiDriver_CORE::open() { &fsSpec, sizeof(fsSpec) ); } +#else + // kMusicDeviceProperty_SoundBankFSSpec is present on 10.6+, but broken + // kMusicDeviceProperty_SoundBankURL was added in 10.5 as a replacement + CFURLRef url = CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8 *)soundfont, strlen(soundfont), false); + + if (url) { + err = AudioUnitSetProperty ( + _synth, + kMusicDeviceProperty_SoundBankURL, kAudioUnitScope_Global, + 0, + &url, sizeof(url) + ); + + CFRelease(url); + } else { + warning("Failed to allocate CFURLRef from '%s'", soundfont); + } +#endif if (err != noErr) - warning("Failed loading custom sound font '%s' (error %ld)\n", soundfont, (long)err); + error("Failed loading custom sound font '%s' (error %ld)", soundfont, (long)err); } #ifdef COREAUDIO_DISABLE_REVERB diff --git a/backends/midi/sndio.cpp b/backends/midi/sndio.cpp index 21c9ea4fec..a065a658e1 100644 --- a/backends/midi/sndio.cpp +++ b/backends/midi/sndio.cpp @@ -81,7 +81,7 @@ void MidiDriver_Sndio::send(uint32 b) { if (!hdl) return; - buf[0] = b & 0xff; + buf[0] = b & 0xff; buf[1] = (b >> 8) & 0xff; buf[2] = (b >> 16) & 0xff; buf[3] = (b >> 24) & 0xff; @@ -101,7 +101,7 @@ void MidiDriver_Sndio::send(uint32 b) { void MidiDriver_Sndio::sysEx(const byte *msg, uint16 length) { if (!hdl) return; - + unsigned char buf[266]; assert(length + 2 <= ARRAYSIZE(buf)); diff --git a/backends/mixer/sdl13/sdl13-mixer.cpp b/backends/mixer/sdl13/sdl13-mixer.cpp index 84777c8bab..24d3434fde 100644 --- a/backends/mixer/sdl13/sdl13-mixer.cpp +++ b/backends/mixer/sdl13/sdl13-mixer.cpp @@ -69,13 +69,13 @@ void Sdl13MixerManager::init() { warning("Could not open audio device: %s", SDL_GetError()); _mixer = new Audio::MixerImpl(g_system, desired.freq); - assert(_mixer); + assert(_mixer); _mixer->setReady(false); } else { debug(1, "Output sample rate: %d Hz", _obtained.freq); _mixer = new Audio::MixerImpl(g_system, _obtained.freq); - assert(_mixer); + assert(_mixer); _mixer->setReady(true); startAudio(); diff --git a/backends/platform/android/android.h b/backends/platform/android/android.h index 4b13ca4b0f..5f2f40b726 100644 --- a/backends/platform/android/android.h +++ b/backends/platform/android/android.h @@ -234,7 +234,7 @@ private: int _fingersDown; void clipMouse(Common::Point &p); - void scaleMouse(Common::Point &p, int x, int y, bool deductDrawRect = true); + void scaleMouse(Common::Point &p, int x, int y, bool deductDrawRect = true, bool touchpadMode = false); void updateEventScale(); void disableCursorPalette(); diff --git a/backends/platform/android/android.mk b/backends/platform/android/android.mk index 9292a16595..0651fc796e 100644 --- a/backends/platform/android/android.mk +++ b/backends/platform/android/android.mk @@ -10,6 +10,7 @@ JAVA_FILES = \ ScummVMApplication.java \ ScummVMActivity.java \ EditableSurfaceView.java \ + MouseHelper.java \ Unpacker.java JAVA_FILES_PLUGIN = \ @@ -47,13 +48,7 @@ APKBUILDER = $(ANDROID_SDK)/tools/apkbuilder JAVAC ?= javac JAVACFLAGS = -source 1.5 -target 1.5 -# This is a bit silly. I want to compile against the 1.6 android.jar, -# to make the compiler check that I don't use something that requires -# a newer Android. However, in order to use android:installLocation, -# we need to give aapt a version >=8 android.jar - even though the -# result will work ok on 1.5+. -ANDROID_JAR = $(ANDROID_SDK)/platforms/android-4/android.jar -ANDROID_JAR8 = $(ANDROID_SDK)/platforms/android-8/android.jar +ANDROID_JAR = $(ANDROID_SDK)/platforms/android-14/android.jar PATH_BUILD = build.tmp PATH_BUILD_ASSETS = $(PATH_BUILD)/assets @@ -92,9 +87,9 @@ $(FILE_MANIFEST): $(FILE_MANIFEST_SRC) @$(MKDIR) -p $(@D) sed "s/@ANDROID_VERSIONCODE@/$(ANDROID_VERSIONCODE)/" < $< > $@ -$(SRC_GEN): $(FILE_MANIFEST) $(filter %.xml,$(RESOURCES)) $(ANDROID_JAR8) +$(SRC_GEN): $(FILE_MANIFEST) $(filter %.xml,$(RESOURCES)) $(ANDROID_JAR) @$(MKDIR) -p $(PATH_GEN_TOP) - $(AAPT) package -m -J $(PATH_GEN_TOP) -M $< -S $(PATH_RESOURCES) -I $(ANDROID_JAR8) + $(AAPT) package -m -J $(PATH_GEN_TOP) -M $< -S $(PATH_RESOURCES) -I $(ANDROID_JAR) $(PATH_CLASSES_MAIN)/%.class: $(PATH_GEN)/%.java $(SRC_GEN) @$(MKDIR) -p $(@D) @@ -127,7 +122,7 @@ $(PATH_STAGE_PREFIX).%/res/drawable/scummvm.png: $(PATH_RESOURCES)/drawable/scum @$(MKDIR) -p $(@D) $(CP) $< $@ -$(FILE_RESOURCES_MAIN): $(FILE_MANIFEST) $(RESOURCES) $(ANDROID_JAR8) $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) +$(FILE_RESOURCES_MAIN): $(FILE_MANIFEST) $(RESOURCES) $(ANDROID_JAR) $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(INSTALL) -d $(PATH_BUILD_ASSETS) $(INSTALL) -c -m 644 $(DIST_FILES_THEMES) $(DIST_FILES_ENGINEDATA) $(PATH_BUILD_ASSETS)/ work_dir=`pwd`; \ @@ -141,10 +136,10 @@ $(FILE_RESOURCES_MAIN): $(FILE_MANIFEST) $(RESOURCES) $(ANDROID_JAR8) $(DIST_FIL zip -r ../`basename $$i` *; \ done @$(RM) -rf $(PATH_BUILD_ASSETS)/tmp - $(AAPT) package -f -0 zip -M $< -S $(PATH_RESOURCES) -A $(PATH_BUILD_ASSETS) -I $(ANDROID_JAR8) -F $@ + $(AAPT) package -f -0 zip -M $< -S $(PATH_RESOURCES) -A $(PATH_BUILD_ASSETS) -I $(ANDROID_JAR) -F $@ -$(PATH_BUILD)/%/$(FILE_RESOURCES): $(PATH_BUILD)/%/AndroidManifest.xml $(PATH_STAGE_PREFIX).%/res/values/strings.xml $(PATH_STAGE_PREFIX).%/res/drawable/scummvm.png plugins/lib%.so $(ANDROID_JAR8) - $(AAPT) package -f -M $< -S $(PATH_STAGE_PREFIX).$*/res -I $(ANDROID_JAR8) -F $@ +$(PATH_BUILD)/%/$(FILE_RESOURCES): $(PATH_BUILD)/%/AndroidManifest.xml $(PATH_STAGE_PREFIX).%/res/values/strings.xml $(PATH_STAGE_PREFIX).%/res/drawable/scummvm.png plugins/lib%.so $(ANDROID_JAR) + $(AAPT) package -f -M $< -S $(PATH_STAGE_PREFIX).$*/res -I $(ANDROID_JAR) -F $@ # Package installer won't delete old libscummvm.so on upgrade so # replace it with a zero size file diff --git a/backends/platform/android/events.cpp b/backends/platform/android/events.cpp index 21d2344fa7..db1261e432 100644 --- a/backends/platform/android/events.cpp +++ b/backends/platform/android/events.cpp @@ -59,6 +59,11 @@ enum { JE_DOUBLE_TAP = 6, JE_MULTI = 7, JE_BALL = 8, + JE_LMB_DOWN = 9, + JE_LMB_UP = 10, + JE_RMB_DOWN = 11, + JE_RMB_UP = 12, + JE_MOUSE_MOVE = 13, JE_QUIT = 0x1000 }; @@ -272,7 +277,7 @@ void OSystem_Android::clipMouse(Common::Point &p) { } void OSystem_Android::scaleMouse(Common::Point &p, int x, int y, - bool deductDrawRect) { + bool deductDrawRect, bool touchpadMode) { const GLESBaseTexture *tex; if (_show_overlay) @@ -282,7 +287,7 @@ void OSystem_Android::scaleMouse(Common::Point &p, int x, int y, const Common::Rect &r = tex->getDrawRect(); - if (_touchpad_mode) { + if (touchpadMode) { x = x * 100 / _touchpad_scale; y = y * 100 / _touchpad_scale; } @@ -327,11 +332,16 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, } switch (arg2) { + + // special case. we'll only get it's up event case JKEYCODE_BACK: e.kbd.keycode = Common::KEYCODE_ESCAPE; e.kbd.ascii = Common::ASCII_ESCAPE; lockMutex(_event_queue_lock); + e.type = Common::EVENT_KEYDOWN; + _event_queue.push(e); + e.type = Common::EVENT_KEYUP; _event_queue.push(e); unlockMutex(_event_queue_lock); @@ -554,7 +564,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, } scaleMouse(e.mouse, arg3 - _touch_pt_scroll.x, - arg4 - _touch_pt_scroll.y, false); + arg4 - _touch_pt_scroll.y, false, true); e.mouse += _touch_pt_down; clipMouse(e.mouse); } else { @@ -652,7 +662,7 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, if (_touchpad_mode) { scaleMouse(e.mouse, arg1 - _touch_pt_dt.x, - arg2 - _touch_pt_dt.y, false); + arg2 - _touch_pt_dt.y, false, true); e.mouse += _touch_pt_down; clipMouse(e.mouse); @@ -757,6 +767,66 @@ void OSystem_Android::pushEvent(int type, int arg1, int arg2, int arg3, return; + case JE_MOUSE_MOVE: + e.type = Common::EVENT_MOUSEMOVE; + + scaleMouse(e.mouse, arg1, arg2); + clipMouse(e.mouse); + + lockMutex(_event_queue_lock); + _event_queue.push(e); + unlockMutex(_event_queue_lock); + + return; + + case JE_LMB_DOWN: + e.type = Common::EVENT_LBUTTONDOWN; + + scaleMouse(e.mouse, arg1, arg2); + clipMouse(e.mouse); + + lockMutex(_event_queue_lock); + _event_queue.push(e); + unlockMutex(_event_queue_lock); + + return; + + case JE_LMB_UP: + e.type = Common::EVENT_LBUTTONUP; + + scaleMouse(e.mouse, arg1, arg2); + clipMouse(e.mouse); + + lockMutex(_event_queue_lock); + _event_queue.push(e); + unlockMutex(_event_queue_lock); + + return; + + case JE_RMB_DOWN: + e.type = Common::EVENT_RBUTTONDOWN; + + scaleMouse(e.mouse, arg1, arg2); + clipMouse(e.mouse); + + lockMutex(_event_queue_lock); + _event_queue.push(e); + unlockMutex(_event_queue_lock); + + return; + + case JE_RMB_UP: + e.type = Common::EVENT_RBUTTONUP; + + scaleMouse(e.mouse, arg1, arg2); + clipMouse(e.mouse); + + lockMutex(_event_queue_lock); + _event_queue.push(e); + unlockMutex(_event_queue_lock); + + return; + case JE_QUIT: e.type = Common::EVENT_QUIT; diff --git a/backends/platform/android/org/scummvm/scummvm/MouseHelper.java b/backends/platform/android/org/scummvm/scummvm/MouseHelper.java new file mode 100644 index 0000000000..999815593f --- /dev/null +++ b/backends/platform/android/org/scummvm/scummvm/MouseHelper.java @@ -0,0 +1,129 @@ +package org.scummvm.scummvm; + +import android.view.InputDevice; +import android.view.MotionEvent; +import android.view.SurfaceView; +import android.view.View; + +/** + * Contains helper methods for mouse/hover events that were introduced in Android 4.0. + */ +public class MouseHelper { + private View.OnHoverListener _listener; + private ScummVM _scummvm; + private long _rmbGuardTime; + private boolean _rmbPressed; + private boolean _lmbPressed; + + /** + * Class initialization fails when this throws an exception. + * Checking hover availability is done on static class initialization for Android 1.6 compatibility. + */ + static { + try { + Class.forName("android.view.View$OnHoverListener"); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + /** + * Calling this forces class initialization + */ + public static void checkHoverAvailable() {} + + public MouseHelper(ScummVM scummvm) { + _scummvm = scummvm; + _listener = createListener(); + } + + private View.OnHoverListener createListener() { + return new View.OnHoverListener() { + @Override + public boolean onHover(View view, MotionEvent e) { + return onMouseEvent(e, true); + } + }; + } + + public void attach(SurfaceView main_surface) { + main_surface.setOnHoverListener(_listener); + } + + public static boolean isMouse(MotionEvent e) { + if (e == null) { + return false; + } + + InputDevice device = e.getDevice(); + + if (device == null) { + return false; + } + + int sources = device.getSources(); + + return ((sources & InputDevice.SOURCE_MOUSE) == InputDevice.SOURCE_MOUSE) || + ((sources & InputDevice.SOURCE_STYLUS) == InputDevice.SOURCE_STYLUS) || + ((sources & InputDevice.SOURCE_TOUCHPAD) == InputDevice.SOURCE_TOUCHPAD); + } + + public boolean onMouseEvent(MotionEvent e, boolean hover) { + _scummvm.pushEvent(ScummVMEvents.JE_MOUSE_MOVE, (int)e.getX(), (int)e.getY(), 0, 0, 0); + + int buttonState = e.getButtonState(); + + boolean lmbDown = (buttonState & MotionEvent.BUTTON_PRIMARY) == MotionEvent.BUTTON_PRIMARY; + + if (!hover && e.getAction() != MotionEvent.ACTION_UP && buttonState == 0) { + // On some device types, ButtonState is 0 even when tapping on the touchpad or using the stylus on the screen etc. + lmbDown = true; + } + + if (lmbDown) { + if (!_lmbPressed) { + // left mouse button was pressed just now + _scummvm.pushEvent(ScummVMEvents.JE_LMB_DOWN, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0); + } + + _lmbPressed = true; + } else { + if (_lmbPressed) { + // left mouse button was released just now + _scummvm.pushEvent(ScummVMEvents.JE_LMB_UP, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0); + } + + _lmbPressed = false; + } + + boolean rmbDown = (buttonState & MotionEvent.BUTTON_SECONDARY) == MotionEvent.BUTTON_SECONDARY; + if (rmbDown) { + if (!_rmbPressed) { + // right mouse button was pressed just now + _scummvm.pushEvent(ScummVMEvents.JE_RMB_DOWN, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0); + } + + _rmbPressed = true; + } else { + if (_rmbPressed) { + // right mouse button was released just now + _scummvm.pushEvent(ScummVMEvents.JE_RMB_UP, (int)e.getX(), (int)e.getY(), e.getButtonState(), 0, 0); + _rmbGuardTime = System.currentTimeMillis(); + } + + _rmbPressed = false; + } + + return true; + } + + /** + * Checks whether right mouse button is pressed or was pressed just previously. This is used to prevent sending + * extra back key on right mouse click which is the default behaviour in some platforms. + * + * @return true if right mouse button is (or was in the last 200ms) pressed + */ + public boolean getRmbGuard() { + return _rmbPressed || _rmbGuardTime + 200 > System.currentTimeMillis(); + } +} diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java index fbd6513761..34c6df3a3a 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java @@ -18,6 +18,18 @@ import java.io.File; public class ScummVMActivity extends Activity { + /* Establish whether the hover events are available */ + private static boolean _hoverAvailable; + + static { + try { + MouseHelper.checkHoverAvailable(); // this throws exception if we're on too old version + _hoverAvailable = true; + } catch (Throwable t) { + _hoverAvailable = false; + } + } + private class MyScummVM extends ScummVM { private boolean usingSmallScreen() { // Multiple screen sizes came in with Android 1.6. Have @@ -94,6 +106,7 @@ public class ScummVMActivity extends Activity { private MyScummVM _scummvm; private ScummVMEvents _events; + private MouseHelper _mouseHelper; private Thread _scummvm_thread; @Override @@ -151,7 +164,13 @@ public class ScummVMActivity extends Activity { "--savepath=" + savePath }); - _events = new ScummVMEvents(this, _scummvm); + Log.d(ScummVM.LOG_TAG, "Hover available: " + _hoverAvailable); + if (_hoverAvailable) { + _mouseHelper = new MouseHelper(_scummvm); + _mouseHelper.attach(main_surface); + } + + _events = new ScummVMEvents(this, _scummvm, _mouseHelper); main_surface.setOnKeyListener(_events); main_surface.setOnTouchListener(_events); diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java index 86227b9352..5f51ffac6c 100644 --- a/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java +++ b/backends/platform/android/org/scummvm/scummvm/ScummVMEvents.java @@ -2,7 +2,6 @@ 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; @@ -27,16 +26,23 @@ public class ScummVMEvents implements 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_LMB_DOWN = 9; + public static final int JE_LMB_UP = 10; + public static final int JE_RMB_DOWN = 11; + public static final int JE_RMB_UP = 12; + public static final int JE_MOUSE_MOVE = 13; public static final int JE_QUIT = 0x1000; final protected Context _context; final protected ScummVM _scummvm; final protected GestureDetector _gd; final protected int _longPress; + final protected MouseHelper _mouseHelper; - public ScummVMEvents(Context context, ScummVM scummvm) { + public ScummVMEvents(Context context, ScummVM scummvm, MouseHelper mouseHelper) { _context = context; _scummvm = scummvm; + _mouseHelper = mouseHelper; _gd = new GestureDetector(context, this); _gd.setOnDoubleTapListener(this); @@ -64,7 +70,7 @@ public class ScummVMEvents implements public void handleMessage(Message msg) { if (msg.what == MSG_MENU_LONG_PRESS) { InputMethodManager imm = (InputMethodManager) - _context.getSystemService(_context.INPUT_METHOD_SERVICE); + _context.getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); @@ -73,9 +79,30 @@ public class ScummVMEvents implements }; // OnKeyListener + @Override final public boolean onKey(View v, int keyCode, KeyEvent e) { final int action = e.getAction(); + if (keyCode == 238) { + // this (undocumented) event is sent when ACTION_HOVER_ENTER or ACTION_HOVER_EXIT occurs + return false; + } + + if (keyCode == KeyEvent.KEYCODE_BACK) { + if (action != KeyEvent.ACTION_UP) { + // only send event from back button on up event, since down event is sent on right mouse click and + // cannot be caught (thus rmb click would send escape key first) + return true; + } + + if (_mouseHelper != null) { + if (_mouseHelper.getRmbGuard()) { + // right mouse button was just clicked which sends an extra back button press + return true; + } + } + } + if (e.isSystem()) { // filter what we handle switch (keyCode) { @@ -160,7 +187,16 @@ public class ScummVMEvents implements } // OnTouchListener + @Override final public boolean onTouch(View v, MotionEvent e) { + if (_mouseHelper != null) { + boolean isMouse = MouseHelper.isMouse(e); + if (isMouse) { + // mouse button is pressed + return _mouseHelper.onMouseEvent(e, false); + } + } + final int action = e.getAction(); // constants from APIv5: @@ -177,11 +213,13 @@ public class ScummVMEvents implements } // OnGestureListener + @Override final public boolean onDown(MotionEvent e) { _scummvm.pushEvent(JE_DOWN, (int)e.getX(), (int)e.getY(), 0, 0, 0); return true; } + @Override final public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { //Log.d(ScummVM.LOG_TAG, String.format("onFling: %s -> %s (%.3f %.3f)", @@ -191,10 +229,12 @@ public class ScummVMEvents implements return true; } + @Override final public void onLongPress(MotionEvent e) { // disabled, interferes with drag&drop } + @Override final public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { _scummvm.pushEvent(JE_SCROLL, (int)e1.getX(), (int)e1.getY(), @@ -203,9 +243,11 @@ public class ScummVMEvents implements return true; } + @Override final public void onShowPress(MotionEvent e) { } + @Override final public boolean onSingleTapUp(MotionEvent e) { _scummvm.pushEvent(JE_TAP, (int)e.getX(), (int)e.getY(), (int)(e.getEventTime() - e.getDownTime()), 0, 0); @@ -214,10 +256,12 @@ public class ScummVMEvents implements } // OnDoubleTapListener + @Override final public boolean onDoubleTap(MotionEvent e) { return true; } + @Override final public boolean onDoubleTapEvent(MotionEvent e) { _scummvm.pushEvent(JE_DOUBLE_TAP, (int)e.getX(), (int)e.getY(), e.getAction(), 0, 0); @@ -225,6 +269,7 @@ public class ScummVMEvents implements return true; } + @Override final public boolean onSingleTapConfirmed(MotionEvent e) { return true; } diff --git a/backends/platform/bada/application.cpp b/backends/platform/bada/application.cpp index ba8e544983..e761649245 100644 --- a/backends/platform/bada/application.cpp +++ b/backends/platform/bada/application.cpp @@ -103,7 +103,7 @@ void BadaScummVM::pauseGame(bool pause) { if (pause && g_engine && !g_engine->isPaused()) { _appForm->pushKey(Common::KEYCODE_SPACE); } - + if (g_system) { ((BadaSystem *)g_system)->setMute(pause); } diff --git a/backends/platform/bada/sscanf.cpp b/backends/platform/bada/sscanf.cpp index b5e5b88cb5..aa846698f6 100644 --- a/backends/platform/bada/sscanf.cpp +++ b/backends/platform/bada/sscanf.cpp @@ -56,7 +56,7 @@ bool scanInt(const char **in, va_list *ap, int max) { bool err = false; if (end == *in || (max > 0 && (end - *in) > max)) { - err = true; + err = true; } else { *arg = (int)n; *in = end; diff --git a/backends/platform/iphone/iphone_video.mm b/backends/platform/iphone/iphone_video.mm index 7877bc6430..0bfae30fc7 100644 --- a/backends/platform/iphone/iphone_video.mm +++ b/backends/platform/iphone/iphone_video.mm @@ -161,9 +161,9 @@ const char *iPhone_getDocumentsDir() { - (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]; + if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { + if ([self respondsToSelector:@selector(setContentScaleFactor:)]) { + [self setContentScaleFactor:[[UIScreen mainScreen] scale]]; } } @@ -268,6 +268,11 @@ const char *iPhone_getDocumentsDir() { glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter); printOpenGLError(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter); printOpenGLError(); + // We use GL_CLAMP_TO_EDGE here to avoid artifacts when linear filtering + // is used. If we would not use this for example the cursor in Loom would + // have a line/border artifact on the right side of the covered rect. + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); printOpenGLError(); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); printOpenGLError(); } - (void)setGraphicsMode { @@ -476,7 +481,7 @@ const char *iPhone_getDocumentsDir() { else if (_videoContext.screenWidth == 640 && _videoContext.screenHeight == 400) adjustedHeight = 480; } - + float overlayPortraitRatio; if (_orientation == UIDeviceOrientationLandscapeLeft || _orientation == UIDeviceOrientationLandscapeRight) { diff --git a/backends/platform/iphone/osys_video.mm b/backends/platform/iphone/osys_video.mm index aa1856490f..ebe435cb25 100644 --- a/backends/platform/iphone/osys_video.mm +++ b/backends/platform/iphone/osys_video.mm @@ -353,7 +353,7 @@ void OSystem_IPHONE::copyRectToOverlay(const void *buf, int pitch, int x, int y, } byte *dst = (byte *)_videoContext->overlayTexture.getBasePtr(x, y); - do { + do { memcpy(dst, src, w * sizeof(uint16)); src += pitch; dst += _videoContext->overlayTexture.pitch; @@ -435,7 +435,7 @@ void OSystem_IPHONE::setCursorPalette(const byte *colors, uint start, uint num) for (uint i = start; i < start + num; ++i, colors += 3) _mouseCursorPalette[i] = Graphics::RGBToColor<Graphics::ColorMasks<5551> >(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; diff --git a/backends/platform/maemo/debian/rules b/backends/platform/maemo/debian/rules index 43a34399a3..c713403876 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/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/tony.dat dists/engine-data/toon.dat debian/scummvm/opt/scummvm/share install -m0644 -d debian/scummvm/usr/share/doc/scummvm install -m0644 AUTHORS COPYING COPYING.BSD COPYING.FREEFONT COPYING.LGPL COPYRIGHT NEWS README debian/scummvm/usr/share/doc/scummvm diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 639bd980f6..fb76c111f2 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -156,7 +156,7 @@ Common::String OSystem_MacOSX::getSystemLanguage() const { } CFRelease(preferredLocalizations); } - + } // Falback to POSIX implementation return OSystem_POSIX::getSystemLanguage(); diff --git a/backends/platform/sdl/macosx/macosx.h b/backends/platform/sdl/macosx/macosx.h index 4837e643b3..d9cb28b973 100644 --- a/backends/platform/sdl/macosx/macosx.h +++ b/backends/platform/sdl/macosx/macosx.h @@ -32,7 +32,7 @@ public: virtual bool hasFeature(Feature f); virtual bool displayLogFile(); - + virtual Common::String getSystemLanguage() const; virtual void initBackend(); diff --git a/backends/platform/sdl/main.cpp b/backends/platform/sdl/main.cpp deleted file mode 100644 index 040028079d..0000000000 --- a/backends/platform/sdl/main.cpp +++ /dev/null @@ -1,66 +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" - -// Several SDL based ports use a custom main, and hence do not want to compile -// of this file. The following "#if" ensures that. -#if !defined(POSIX) && \ - !defined(WIN32) && \ - !defined(MAEMO) && \ - !defined(__SYMBIAN32__) && \ - !defined(_WIN32_WCE) && \ - !defined(__amigaos4__) && \ - !defined(DINGUX) && \ - !defined(CAANOO) && \ - !defined(LINUXMOTO) && \ - !defined(SAMSUNGTV) && \ - !defined(PLAYSTATION3) && \ - !defined(OPENPANDORA) - -#include "backends/platform/sdl/sdl.h" -#include "backends/plugins/sdl/sdl-provider.h" -#include "base/main.h" - -int main(int argc, char *argv[]) { - - // Create our OSystem instance - g_system = new OSystem_SDL(); - assert(g_system); - - // Pre initialize the backend - ((OSystem_SDL *)g_system)->init(); - -#ifdef DYNAMIC_MODULES - PluginManager::instance().addPluginProvider(new SDLPluginProvider()); -#endif - - // Invoke the actual ScummVM main entry point: - int res = scummvm_main(argc, argv); - - // Free OSystem - delete (OSystem_SDL *)g_system; - - return res; -} - -#endif diff --git a/backends/platform/sdl/module.mk b/backends/platform/sdl/module.mk index 98a8265301..a17a326889 100644 --- a/backends/platform/sdl/module.mk +++ b/backends/platform/sdl/module.mk @@ -1,7 +1,6 @@ MODULE := backends/platform/sdl MODULE_OBJS := \ - main.o \ sdl.o ifdef POSIX diff --git a/backends/taskbar/win32/mingw-compat.h b/backends/taskbar/win32/mingw-compat.h index 55105407c6..f6151936f1 100644 --- a/backends/taskbar/win32/mingw-compat.h +++ b/backends/taskbar/win32/mingw-compat.h @@ -70,7 +70,7 @@ DECLARE_INTERFACE_(IPropertyStore, IUnknown) { STDMETHOD (GetValue) (REFPROPERTYKEY key, PROPVARIANT *pv) PURE; STDMETHOD (SetValue) (REFPROPERTYKEY key, REFPROPVARIANT propvar) PURE; STDMETHOD (Commit) (void) PURE; - + private: ~IPropertyStore(); }; @@ -137,7 +137,7 @@ DECLARE_INTERFACE_(ITaskbarList3, IUnknown) { STDMETHOD (SetOverlayIcon) (THIS_ HWND hwnd, HICON hIcon, LPCWSTR pszDescription) PURE; STDMETHOD (SetThumbnailTooltip) (THIS_ HWND hwnd, LPCWSTR pszTip) PURE; STDMETHOD (SetThumbnailClip) (THIS_ HWND hwnd, RECT *prcClip) PURE; - + private: ~ITaskbarList3(); }; diff --git a/backends/timer/bada/timer.cpp b/backends/timer/bada/timer.cpp index b7daf02b49..e41ecd4864 100644 --- a/backends/timer/bada/timer.cpp +++ b/backends/timer/bada/timer.cpp @@ -49,7 +49,7 @@ bool TimerSlot::OnStart() { AppLog("failed to start timer"); return false; } - + AppLog("started timer %d", _interval); return true; } @@ -57,7 +57,7 @@ bool TimerSlot::OnStart() { void TimerSlot::OnStop() { AppLog("timer stopped"); if (_timer) { - _timer->Cancel(); + _timer->Cancel(); delete _timer; _timer = NULL; } diff --git a/backends/timer/bada/timer.h b/backends/timer/bada/timer.h index f6ae4517c7..826064d7ff 100644 --- a/backends/timer/bada/timer.h +++ b/backends/timer/bada/timer.h @@ -51,7 +51,7 @@ public: BadaTimerManager(); ~BadaTimerManager(); - bool installTimerProc(TimerProc proc, int32 interval, void *refCon, + bool installTimerProc(TimerProc proc, int32 interval, void *refCon, const Common::String &id); void removeTimerProc(TimerProc proc); diff --git a/backends/timer/default/default-timer.cpp b/backends/timer/default/default-timer.cpp index 9cd803f148..9f56d58b12 100644 --- a/backends/timer/default/default-timer.cpp +++ b/backends/timer/default/default-timer.cpp @@ -156,7 +156,7 @@ void DefaultTimerManager::removeTimerProc(TimerProc callback) { } // We need to remove all names referencing the timer proc here. - // + // // Else we run into troubles, when the client code removes and readds timer // callbacks. // |