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/platform') 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/platform') 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/platform') 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/platform') 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 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/platform') 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 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/platform/android/events.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'backends/platform') 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 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/platform') 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 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/platform') 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/platform') 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/platform') 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/platform/sdl/win32/win32.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'backends/platform') 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(); } -- 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/platform') 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/platform') 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 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/platform') 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/platform/sdl/hardwarekeys.cpp | 50 ++-------------------------------- backends/platform/sdl/sdl.h | 5 ++++ 2 files changed, 8 insertions(+), 47 deletions(-) (limited to 'backends/platform') 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/platform') 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 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/platform') 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 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/platform/maemo/maemo-common.h | 5 +++++ backends/platform/maemo/maemo.cpp | 22 ++++++++++++++++++---- backends/platform/maemo/maemo.h | 5 ++++- 3 files changed, 27 insertions(+), 5 deletions(-) (limited to 'backends/platform') 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/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 ++ 8 files changed, 14 insertions(+), 20 deletions(-) (limited to 'backends/platform') 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/platform') 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/platform') 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 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/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 ++++++------ 24 files changed, 89 insertions(+), 89 deletions(-) (limited to 'backends/platform') 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); -- 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/platform') 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/platform/maemo/maemo-common.h | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'backends/platform') 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/platform/maemo/maemo-keys.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'backends/platform') 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 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/platform') 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 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/platform') 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/platform/maemo/maemo.cpp | 8 ++++++++ backends/platform/maemo/maemo.h | 2 ++ 2 files changed, 10 insertions(+) (limited to 'backends/platform') 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/platform') 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/platform') 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 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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 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/platform') 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/platform') 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/platform') 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 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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 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/platform') 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/platform') 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/platform') 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 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/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 +- 6 files changed, 246 insertions(+), 251 deletions(-) (limited to 'backends/platform') 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/platform') 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/platform') 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/platform') 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 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/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 +- 10 files changed, 19 insertions(+), 19 deletions(-) (limited to 'backends/platform') 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/platform/maemo/maemo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'backends/platform') 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/platform') 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 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/platform/maemo/maemo.cpp | 2 +- backends/platform/sdl/hardwarekeys.cpp | 181 --------------------------------- backends/platform/sdl/module.mk | 1 - backends/platform/sdl/sdl.h | 3 - 4 files changed, 1 insertion(+), 186 deletions(-) delete mode 100644 backends/platform/sdl/hardwarekeys.cpp (limited to 'backends/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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/platform') 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 From e618e6794ddcd528d157000c01e4f75dc6de3e2f Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Tue, 9 Aug 2011 21:02:32 +0200 Subject: JANITORIAL: Remove unnecessary empty default constructors/destructors. --- backends/platform/ps2/icon.h | 4 ---- backends/platform/psp/default_display_client.h | 4 ---- 2 files changed, 8 deletions(-) (limited to 'backends/platform') diff --git a/backends/platform/ps2/icon.h b/backends/platform/ps2/icon.h index bc614bf70b..3ad19910d3 100644 --- a/backends/platform/ps2/icon.h +++ b/backends/platform/ps2/icon.h @@ -22,10 +22,6 @@ class PS2Icon { public: - PS2Icon() {}; - - ~PS2Icon() {}; - uint16 decompressData(uint16 **data); void setup(mcIcon *icon); }; diff --git a/backends/platform/psp/default_display_client.h b/backends/platform/psp/default_display_client.h index e1cd8e7e72..721a7e6fea 100644 --- a/backends/platform/psp/default_display_client.h +++ b/backends/platform/psp/default_display_client.h @@ -65,9 +65,6 @@ protected: */ class Overlay : public DefaultDisplayClient { public: - Overlay() {} - ~Overlay() {} - void init(); bool allocate(); void setBytesPerPixel(uint32 size); @@ -85,7 +82,6 @@ public: memset(&_pixelFormat, 0, sizeof(_pixelFormat)); memset(&_frameBuffer, 0, sizeof(_frameBuffer)); } - ~Screen() {} void init(); bool allocate(); -- cgit v1.2.3 From 223794fb383637944c3b161c04ecc233a354c9ae Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sat, 17 Mar 2012 22:02:16 +0100 Subject: ALL: Make use of defined() for the preprocessor consistent. This does not change the use of defined for some NDS source files, since they seem to be (based on?) third party code. --- backends/platform/psp/psp_main.cpp | 2 +- backends/platform/psp/tests.cpp | 4 ++-- backends/platform/psp/tests.h | 2 +- backends/platform/psp/trace.h | 2 +- backends/platform/symbian/src/ScummApp.cpp | 10 +++++----- backends/platform/symbian/src/ScummApp.h | 6 +++--- backends/platform/symbian/src/SymbianActions.cpp | 4 ++-- backends/platform/symbian/src/portdefs.h | 2 +- 8 files changed, 16 insertions(+), 16 deletions(-) (limited to 'backends/platform') diff --git a/backends/platform/psp/psp_main.cpp b/backends/platform/psp/psp_main.cpp index f45000fea4..a83a5bae71 100644 --- a/backends/platform/psp/psp_main.cpp +++ b/backends/platform/psp/psp_main.cpp @@ -182,7 +182,7 @@ int main(void) { #endif /* unit/speed tests */ -#if defined (PSP_ENABLE_UNIT_TESTS) || defined (PSP_ENABLE_SPEED_TESTS) +#if defined(PSP_ENABLE_UNIT_TESTS) || defined(PSP_ENABLE_SPEED_TESTS) PSP_INFO_PRINT("running tests\n"); psp_tests(); sceKernelSleepThread(); // that's it. That's all we're doing diff --git a/backends/platform/psp/tests.cpp b/backends/platform/psp/tests.cpp index 4d326f30bd..5c5ebb7a80 100644 --- a/backends/platform/psp/tests.cpp +++ b/backends/platform/psp/tests.cpp @@ -25,7 +25,7 @@ #include "backends/platform/psp/tests.h" -#if defined (PSP_ENABLE_UNIT_TESTS) || defined (PSP_ENABLE_SPEED_TESTS) +#if defined(PSP_ENABLE_UNIT_TESTS) || defined(PSP_ENABLE_SPEED_TESTS) #include "common/scummsys.h" #include @@ -729,4 +729,4 @@ void psp_tests() { #endif } -#endif /* (PSP_ENABLE_UNIT_TESTS) || defined (PSP_ENABLE_SPEED_TESTS) */ +#endif /* (PSP_ENABLE_UNIT_TESTS) || defined(PSP_ENABLE_SPEED_TESTS) */ diff --git a/backends/platform/psp/tests.h b/backends/platform/psp/tests.h index 9d158812f9..3779cb6bb2 100644 --- a/backends/platform/psp/tests.h +++ b/backends/platform/psp/tests.h @@ -26,7 +26,7 @@ //#define PSP_ENABLE_UNIT_TESTS // run unit tests //#define PSP_ENABLE_SPEED_TESTS // run speed tests -#if defined (PSP_ENABLE_UNIT_TESTS) || defined (PSP_ENABLE_SPEED_TESTS) +#if defined(PSP_ENABLE_UNIT_TESTS) || defined(PSP_ENABLE_SPEED_TESTS) void psp_tests(); #endif diff --git a/backends/platform/psp/trace.h b/backends/platform/psp/trace.h index dda258f2cb..e27d06d8d3 100644 --- a/backends/platform/psp/trace.h +++ b/backends/platform/psp/trace.h @@ -32,7 +32,7 @@ /* Choose to print to file/screen/both */ #ifdef __PSP_PRINT_TO_FILE__ #define __PSP_PRINT__(format,...) PspDebugTrace(false, format, ## __VA_ARGS__) -#elif defined __PSP_PRINT_TO_FILE_AND_SCREEN__ +#elif defined(__PSP_PRINT_TO_FILE_AND_SCREEN__) #define __PSP_PRINT__(format,...) PspDebugTrace(true, format, ## __VA_ARGS__) #else /* default - print to screen */ #define __PSP_PRINT__(format,...) fprintf(stderr, format, ## __VA_ARGS__) diff --git a/backends/platform/symbian/src/ScummApp.cpp b/backends/platform/symbian/src/ScummApp.cpp index 405fb5c3c2..b952177f9a 100644 --- a/backends/platform/symbian/src/ScummApp.cpp +++ b/backends/platform/symbian/src/ScummApp.cpp @@ -24,7 +24,7 @@ #define _PAGESIZE_ 0x1000 -#if defined (__WINS__) && !defined (S60V3) && !defined (UIQ3) +#if defined(__WINS__) && !defined(S60V3) && !defined(UIQ3) extern "C" int _chkstk(int /*a*/) { _asm { push ecx @@ -62,7 +62,7 @@ _asm { #ifdef EPOC_AS_APP // this function is called automatically by the SymbianOS to deliver the new CApaApplication object -#if !defined (UIQ3) && !defined (S60V3) +#if !defined(UIQ3) && !defined(S60V3) EXPORT_C #endif CApaApplication* NewApplication() { @@ -70,7 +70,7 @@ CApaApplication* NewApplication() { return new CScummApp; } -#if defined (UIQ3) || defined (S60V3) +#if defined(UIQ3) || defined(S60V3) #include // E32Main() contains the program's start up code, the entry point for an EXE. GLDEF_C TInt E32Main() { @@ -80,7 +80,7 @@ GLDEF_C TInt E32Main() { #endif // EPOC_AS_APP -#if !defined (UIQ3) && !defined (S60V3) +#if !defined(UIQ3) && !defined(S60V3) GLDEF_C TInt E32Dll(TDllReason) { return KErrNone; } @@ -92,7 +92,7 @@ CScummApp::CScummApp() { CScummApp::~CScummApp() { } -#if defined (UIQ3) +#if defined(UIQ3) #include /** * Returns the resource id to be used to declare the views supported by this UIQ3 app diff --git a/backends/platform/symbian/src/ScummApp.h b/backends/platform/symbian/src/ScummApp.h index 0b9ebcdf53..00d03e6d7b 100644 --- a/backends/platform/symbian/src/ScummApp.h +++ b/backends/platform/symbian/src/ScummApp.h @@ -26,7 +26,7 @@ #include #include -#if defined (EPOC_AS_APP) && !defined (UIQ3) && !defined (S60V3) +#if defined(EPOC_AS_APP) && !defined(UIQ3) && !defined(S60V3) #include "ECompXL.h" #endif @@ -34,7 +34,7 @@ class CScummApp : public CSDLApp { public: CScummApp(); ~CScummApp(); -#if defined (UIQ3) +#if defined(UIQ3) /** * Returns the resource id to be used to declare the views supported by this UIQ3 app * @return TInt, resource id @@ -43,7 +43,7 @@ public: #endif TUid AppDllUid() const; void GetDataFolder(TDes& aDataFolder); -#if defined (EPOC_AS_APP) && !defined (UIQ3) && !defined (S60V3) +#if defined(EPOC_AS_APP) && !defined(UIQ3) && !defined(S60V3) TECompXL iECompXL; #endif }; diff --git a/backends/platform/symbian/src/SymbianActions.cpp b/backends/platform/symbian/src/SymbianActions.cpp index 5de386b1da..c47bd93772 100644 --- a/backends/platform/symbian/src/SymbianActions.cpp +++ b/backends/platform/symbian/src/SymbianActions.cpp @@ -58,9 +58,9 @@ const Common::String actionNames[] = { #ifdef UIQ static const int ACTIONS_DEFAULT[ACTION_LAST] = { SDLK_UP, SDLK_DOWN, SDLK_LEFT, SDLK_RIGHT, SDLK_F1, SDLK_F2, SDLK_F5, SDLK_PAGEDOWN, '9', 0, 0, SDLK_PAGEUP, 0, 0, 0, 0, 0, 0, 0}; -#elif defined (S60) +#elif defined(S60) const int ACTIONS_DEFAULT[ACTION_LAST] = { 0, 0, 0, 0, 0, 0, '*', '#', '9', 0, 0, 0, 0, 0, 0, 0, '0', 0, 0}; -#elif defined (S90) +#elif defined(S90) const int ACTIONS_DEFAULT[ACTION_LAST] = { SDLK_UP, SDLK_DOWN, SDLK_LEFT, SDLK_RIGHT, 0, 0, SDLK_MENU, SDLK_ESCAPE, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0 ,0}; #else const int ACTIONS_DEFAULT[ACTION_LAST] = { SDLK_UP, SDLK_DOWN, SDLK_LEFT, SDLK_RIGHT, SDLK_F1, SDLK_F2, SDLK_MENU, SDLK_ESCAPE, 0, 0, 0, 0, 0, 0, 0, 0, '1', 0 ,0}; diff --git a/backends/platform/symbian/src/portdefs.h b/backends/platform/symbian/src/portdefs.h index dd81080afe..1f9128a54f 100644 --- a/backends/platform/symbian/src/portdefs.h +++ b/backends/platform/symbian/src/portdefs.h @@ -125,7 +125,7 @@ typedef signed long int int32; PS2. http://gcc.gnu.org/ml/gcc-bugs/2004-01/msg01596.html might have found out the same problem there */ -#elif defined (__WINS__) // WINS +#elif defined(__WINS__) // WINS extern "C" int symbian_snprintf(char *text, size_t maxlen, const char *fmt, ...); extern "C" int symbian_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap); #define snprintf(buf,len,args...) symbian_snprintf(buf,len,args) -- cgit v1.2.3 From 9f827e339297306eed2d7b9a355eccd7d2ac0328 Mon Sep 17 00:00:00 2001 From: Christoph Mallon Date: Sat, 17 Mar 2012 18:00:58 +0100 Subject: JANITORIAL: Remove +x from files, which should not be executable. --- backends/platform/gph/caanoo-bundle.mk | 0 backends/platform/gph/gp2xwiz-bundle.mk | 0 backends/platform/openpandora/module.mk | 0 backends/platform/openpandora/op-bundle.mk | 0 backends/platform/sdl/macosx/appmenu_osx.h | 0 backends/platform/sdl/macosx/appmenu_osx.mm | 0 6 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 backends/platform/gph/caanoo-bundle.mk mode change 100755 => 100644 backends/platform/gph/gp2xwiz-bundle.mk mode change 100755 => 100644 backends/platform/openpandora/module.mk mode change 100755 => 100644 backends/platform/openpandora/op-bundle.mk mode change 100755 => 100644 backends/platform/sdl/macosx/appmenu_osx.h mode change 100755 => 100644 backends/platform/sdl/macosx/appmenu_osx.mm (limited to 'backends/platform') diff --git a/backends/platform/gph/caanoo-bundle.mk b/backends/platform/gph/caanoo-bundle.mk old mode 100755 new mode 100644 diff --git a/backends/platform/gph/gp2xwiz-bundle.mk b/backends/platform/gph/gp2xwiz-bundle.mk old mode 100755 new mode 100644 diff --git a/backends/platform/openpandora/module.mk b/backends/platform/openpandora/module.mk old mode 100755 new mode 100644 diff --git a/backends/platform/openpandora/op-bundle.mk b/backends/platform/openpandora/op-bundle.mk old mode 100755 new mode 100644 diff --git a/backends/platform/sdl/macosx/appmenu_osx.h b/backends/platform/sdl/macosx/appmenu_osx.h old mode 100755 new mode 100644 diff --git a/backends/platform/sdl/macosx/appmenu_osx.mm b/backends/platform/sdl/macosx/appmenu_osx.mm old mode 100755 new mode 100644 -- cgit v1.2.3