2007-11-13 08:06:15 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined(IPHONE_BACKEND)
|
|
|
|
|
|
|
|
#include <CoreGraphics/CGDirectDisplay.h>
|
|
|
|
#include <CoreSurface/CoreSurface.h>
|
2007-11-15 23:42:00 +00:00
|
|
|
#include <AudioToolbox/AudioQueue.h>
|
2007-11-13 08:06:15 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
|
|
|
|
#include "common/system.h"
|
|
|
|
#include "common/scummsys.h"
|
|
|
|
#include "common/util.h"
|
|
|
|
#include "common/rect.h"
|
|
|
|
#include "common/events.h"
|
|
|
|
|
|
|
|
#include "base/main.h"
|
|
|
|
|
|
|
|
#include "backends/saves/default/default-saves.h"
|
|
|
|
#include "backends/timer/default/default-timer.h"
|
|
|
|
#include "backends/intern.h"
|
|
|
|
#include "sound/mixer.h"
|
2007-11-19 22:29:02 +00:00
|
|
|
#include "gui/message.h"
|
2007-11-13 08:06:15 +00:00
|
|
|
|
|
|
|
#include "osys_iphone.h"
|
|
|
|
#include "iphone_common.h"
|
|
|
|
|
|
|
|
const OSystem::GraphicsMode OSystem_IPHONE::s_supportedGraphicsModes[] = {
|
|
|
|
{0, 0, 0}
|
|
|
|
};
|
|
|
|
|
2007-11-13 21:21:17 +00:00
|
|
|
AQCallbackStruct OSystem_IPHONE::s_AudioQueue;
|
|
|
|
SoundProc OSystem_IPHONE::s_soundCallback = NULL;
|
|
|
|
void *OSystem_IPHONE::s_soundParam = NULL;
|
|
|
|
|
2007-11-13 08:06:15 +00:00
|
|
|
OSystem_IPHONE::OSystem_IPHONE() :
|
|
|
|
_savefile(NULL), _mixer(NULL), _timer(NULL), _offscreen(NULL),
|
|
|
|
_overlayVisible(false), _overlayBuffer(NULL), _fullscreen(NULL),
|
|
|
|
_mouseHeight(0), _mouseWidth(0), _mouseBuf(NULL), _lastMouseTap(0),
|
2007-11-18 17:58:53 +00:00
|
|
|
_secondaryTapped(false), _lastSecondaryTap(0), _landscapeMode(true),
|
2007-11-19 22:29:02 +00:00
|
|
|
_needEventRestPeriod(false), _mouseClickAndDragEnabled(false),
|
|
|
|
_gestureStartX(-1), _gestureStartY(-1)
|
2007-11-13 08:06:15 +00:00
|
|
|
{
|
|
|
|
_queuedInputEvent.type = (Common::EventType)0;
|
|
|
|
}
|
|
|
|
|
|
|
|
OSystem_IPHONE::~OSystem_IPHONE() {
|
2007-11-14 23:19:09 +00:00
|
|
|
AudioQueueDispose(s_AudioQueue.queue, true);
|
|
|
|
|
2007-11-13 08:06:15 +00:00
|
|
|
delete _savefile;
|
|
|
|
delete _mixer;
|
|
|
|
delete _timer;
|
|
|
|
delete _offscreen;
|
|
|
|
delete _fullscreen;
|
|
|
|
}
|
|
|
|
|
2007-11-14 23:19:09 +00:00
|
|
|
int OSystem_IPHONE::timerHandler(int t)
|
|
|
|
{
|
|
|
|
DefaultTimerManager *tm = (DefaultTimerManager *)g_system->getTimerManager();
|
|
|
|
tm->handler();
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
2007-11-13 08:06:15 +00:00
|
|
|
void OSystem_IPHONE::initBackend() {
|
|
|
|
_savefile = new DefaultSaveFileManager();
|
|
|
|
_mixer = new Audio::Mixer();
|
|
|
|
_timer = new DefaultTimerManager();
|
|
|
|
|
|
|
|
gettimeofday(&_startTime, NULL);
|
|
|
|
|
2007-11-14 23:19:09 +00:00
|
|
|
setSoundCallback(Audio::Mixer::mixCallback, _mixer);
|
|
|
|
setTimerCallback(&OSystem_IPHONE::timerHandler, 10);
|
|
|
|
|
2007-11-13 08:06:15 +00:00
|
|
|
OSystem::initBackend();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OSystem_IPHONE::hasFeature(Feature f) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::setFeatureState(Feature f, bool enable) {
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OSystem_IPHONE::getFeatureState(Feature f) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
const OSystem::GraphicsMode* OSystem_IPHONE::getSupportedGraphicsModes() const {
|
|
|
|
return s_supportedGraphicsModes;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int OSystem_IPHONE::getDefaultGraphicsMode() const {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OSystem_IPHONE::setGraphicsMode(const char *mode) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OSystem_IPHONE::setGraphicsMode(int mode) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int OSystem_IPHONE::getGraphicsMode() const {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::initSize(uint width, uint height) {
|
|
|
|
//printf("initSize(%i, %i)\n", width, height);
|
|
|
|
|
|
|
|
_screenWidth = width;
|
|
|
|
_screenHeight = height;
|
|
|
|
|
|
|
|
if (_offscreen)
|
|
|
|
free(_offscreen);
|
|
|
|
|
|
|
|
_offscreen = (byte *)malloc(width * height);
|
|
|
|
bzero(_offscreen, width * height);
|
|
|
|
|
|
|
|
if (_overlayBuffer)
|
|
|
|
free(_overlayBuffer);
|
|
|
|
|
|
|
|
int fullSize = _screenWidth * _screenHeight * sizeof(OverlayColor);
|
|
|
|
_overlayBuffer = (OverlayColor *)malloc(fullSize);
|
|
|
|
clearOverlay();
|
|
|
|
|
2007-11-20 19:42:41 +00:00
|
|
|
if (_fullscreen)
|
2007-11-13 08:06:15 +00:00
|
|
|
free(_fullscreen);
|
2007-11-20 19:42:41 +00:00
|
|
|
|
2007-11-13 08:06:15 +00:00
|
|
|
_fullscreen = (uint16 *)malloc(fullSize);
|
|
|
|
bzero(_fullscreen, fullSize);
|
|
|
|
|
2007-11-17 21:26:03 +00:00
|
|
|
if (_landscapeMode)
|
|
|
|
iPhone_initSurface(height, width, true);
|
|
|
|
else
|
|
|
|
iPhone_initSurface(width, height, false);
|
|
|
|
|
2007-11-15 23:42:00 +00:00
|
|
|
_dirtyRects.push_back(Common::Rect(0, 0, width, height));
|
2007-11-13 08:06:15 +00:00
|
|
|
_mouseVisible = false;
|
2007-11-20 19:42:41 +00:00
|
|
|
updateScreen();
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int16 OSystem_IPHONE::getHeight() {
|
|
|
|
return _screenHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 OSystem_IPHONE::getWidth() {
|
|
|
|
return _screenWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::setPalette(const byte *colors, uint start, uint num) {
|
|
|
|
//printf("setPalette()\n");
|
|
|
|
const byte *b = colors;
|
|
|
|
|
2007-11-19 22:29:02 +00:00
|
|
|
for (uint i = start; i < start + num; ++i) {
|
2007-11-13 08:06:15 +00:00
|
|
|
_palette[i] = RGBToColor(b[0], b[1], b[2]);
|
|
|
|
b += 4;
|
|
|
|
}
|
2007-11-15 23:42:00 +00:00
|
|
|
|
|
|
|
_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::grabPalette(byte *colors, uint start, uint num) {
|
|
|
|
//printf("grabPalette()\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) {
|
2007-11-15 23:42:00 +00:00
|
|
|
//printf("copyRectToScreen(%i, %i, %i, %i)\n", x, y, w, h);
|
2007-11-13 08:06:15 +00:00
|
|
|
//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;
|
|
|
|
|
2007-11-15 23:42:00 +00:00
|
|
|
_dirtyRects.push_back(Common::Rect(x, y, x + w + 1, y + h + 1));
|
|
|
|
|
2007-11-13 08:06:15 +00:00
|
|
|
byte *dst = _offscreen + y * _screenWidth + x;
|
2007-11-20 19:42:41 +00:00
|
|
|
if (_screenWidth == pitch && pitch == w)
|
2007-11-13 08:06:15 +00:00
|
|
|
memcpy(dst, buf, h * w);
|
2007-11-20 19:42:41 +00:00
|
|
|
else {
|
2007-11-13 08:06:15 +00:00
|
|
|
do {
|
|
|
|
memcpy(dst, buf, w);
|
|
|
|
buf += pitch;
|
|
|
|
dst += _screenWidth;
|
|
|
|
} while (--h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-15 23:42:00 +00:00
|
|
|
void OSystem_IPHONE::addDirtyRect(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 || h <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_dirtyRects.push_back(Common::Rect(x, y, x + w, y + h));
|
|
|
|
}
|
2007-11-17 21:26:03 +00:00
|
|
|
|
2007-11-13 08:06:15 +00:00
|
|
|
void OSystem_IPHONE::updateScreen() {
|
2007-11-17 21:26:03 +00:00
|
|
|
//printf("updateScreen(): %i dirty rects.\n", _dirtyRects.size());
|
2007-11-13 08:06:15 +00:00
|
|
|
|
2007-11-20 19:42:41 +00:00
|
|
|
if (_dirtyRects.size() == 0)
|
2007-11-15 23:42:00 +00:00
|
|
|
return;
|
2007-11-17 21:26:03 +00:00
|
|
|
|
2007-11-20 19:42:41 +00:00
|
|
|
if (_landscapeMode)
|
2007-11-17 21:26:03 +00:00
|
|
|
internUpdateScreen<true>();
|
2007-11-20 19:42:41 +00:00
|
|
|
else
|
|
|
|
internUpdateScreen<false>();
|
2007-11-17 21:26:03 +00:00
|
|
|
|
|
|
|
iPhone_updateScreen();
|
|
|
|
}
|
2007-11-13 08:06:15 +00:00
|
|
|
|
2007-11-17 21:26:03 +00:00
|
|
|
template <bool landscapeMode>
|
|
|
|
void OSystem_IPHONE::internUpdateScreen() {
|
|
|
|
Common::Rect mouseRect(_mouseX - _mouseHotspotX, _mouseY - _mouseHotspotY, _mouseX + _mouseWidth - _mouseHotspotX, _mouseY + _mouseHeight - _mouseHotspotY);
|
2007-11-15 23:42:00 +00:00
|
|
|
|
|
|
|
while (_dirtyRects.size()) {
|
2007-11-17 21:26:03 +00:00
|
|
|
Common::Rect dirtyRect = _dirtyRects.remove_at(_dirtyRects.size() - 1);
|
2007-11-15 23:42:00 +00:00
|
|
|
//printf("Drawing: (%i, %i) -> (%i, %i)\n", dirtyRect.left, dirtyRect.top, dirtyRect.right, dirtyRect.bottom);
|
|
|
|
int row;
|
|
|
|
if (_overlayVisible) {
|
|
|
|
for (int x = dirtyRect.left; x < dirtyRect.right - 1; x++) {
|
2007-11-17 21:26:03 +00:00
|
|
|
if (landscapeMode) {
|
|
|
|
row = (_screenWidth - x - 1) * _screenHeight;
|
|
|
|
for (int y = dirtyRect.top; y < dirtyRect.bottom; y++)
|
|
|
|
_fullscreen[row + y] = _overlayBuffer[y * _screenWidth + x];
|
|
|
|
} else {
|
|
|
|
for (int y = dirtyRect.top; y < dirtyRect.bottom; y++)
|
|
|
|
_fullscreen[y * _screenWidth + x] = _overlayBuffer[y * _screenWidth + x];
|
2007-11-15 23:42:00 +00:00
|
|
|
}
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
2007-11-15 23:42:00 +00:00
|
|
|
} else {
|
|
|
|
for (int x = dirtyRect.left; x < dirtyRect.right - 1; x++) {
|
2007-11-17 21:26:03 +00:00
|
|
|
if (landscapeMode) {
|
|
|
|
row = (_screenWidth - x - 1) * _screenHeight;
|
|
|
|
for (int y = dirtyRect.top; y < dirtyRect.bottom; y++)
|
|
|
|
_fullscreen[row + y] = _palette[_offscreen[y * _screenWidth + x]];
|
|
|
|
} else {
|
|
|
|
for (int y = dirtyRect.top; y < dirtyRect.bottom; y++)
|
|
|
|
_fullscreen[y * _screenWidth + x] = _palette[_offscreen[y * _screenWidth + x]];
|
2007-11-15 23:42:00 +00:00
|
|
|
}
|
|
|
|
}
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
|
2007-11-15 23:42:00 +00:00
|
|
|
//draw mouse on top
|
|
|
|
int mx, my;
|
|
|
|
if (_mouseVisible && dirtyRect.intersects(mouseRect)) {
|
|
|
|
for (uint x = 0; x < _mouseWidth - 1; x++) {
|
2007-11-17 21:26:03 +00:00
|
|
|
mx = _mouseX + x - _mouseHotspotX;
|
2007-11-15 23:42:00 +00:00
|
|
|
row = (_screenWidth - mx - 1) * _screenHeight;
|
|
|
|
if (mx >= 0 && mx < _screenWidth) {
|
|
|
|
|
|
|
|
for (uint y = 0; y < _mouseHeight; ++y) {
|
|
|
|
if (_mouseBuf[y * _mouseWidth + x] != _mouseKeyColour) {
|
2007-11-17 21:26:03 +00:00
|
|
|
my = _mouseY + y - _mouseHotspotY;
|
|
|
|
|
|
|
|
if (my >= 0 && my < _screenHeight) {
|
|
|
|
if (landscapeMode)
|
|
|
|
_fullscreen[row + my] = _palette[_mouseBuf[y * _mouseWidth + x]];
|
|
|
|
else
|
|
|
|
_fullscreen[my * _screenWidth + mx] = _palette[_mouseBuf[y * _mouseWidth + x]];
|
|
|
|
}
|
2007-11-15 23:42:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
}
|
2007-11-15 23:42:00 +00:00
|
|
|
|
|
|
|
uint16 *surface = iPhone_getSurface();
|
|
|
|
if (dirtyRect.right == _screenWidth && dirtyRect.bottom == _screenHeight) {
|
|
|
|
memcpy(surface, _fullscreen, _screenWidth * _screenHeight * 2);
|
|
|
|
} else {
|
|
|
|
for (int x = dirtyRect.left; x < dirtyRect.right - 1; x++) {
|
2007-11-17 21:26:03 +00:00
|
|
|
if (landscapeMode) {
|
|
|
|
row = (_screenWidth - x - 1) * _screenHeight;
|
|
|
|
for (int y = dirtyRect.top; y < dirtyRect.bottom; y++)
|
|
|
|
surface[row + y] = _fullscreen[row + y];
|
|
|
|
} else {
|
|
|
|
for (int y = dirtyRect.top; y < dirtyRect.bottom; y++)
|
|
|
|
surface[y * _screenWidth + x] = _fullscreen[y * _screenWidth + x];
|
2007-11-15 23:42:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Graphics::Surface *OSystem_IPHONE::lockScreen() {
|
|
|
|
//printf("lockScreen()\n");
|
|
|
|
|
|
|
|
_framebuffer.pixels = _offscreen;
|
|
|
|
_framebuffer.w = _screenWidth;
|
|
|
|
_framebuffer.h = _screenHeight;
|
|
|
|
_framebuffer.pitch = _screenWidth;
|
|
|
|
_framebuffer.bytesPerPixel = 1;
|
|
|
|
|
|
|
|
return &_framebuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::unlockScreen() {
|
|
|
|
//printf("unlockScreen()\n");
|
2007-11-15 23:42:00 +00:00
|
|
|
_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
|
2007-11-13 08:06:15 +00:00
|
|
|
updateScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::setShakePos(int shakeOffset) {
|
2007-11-15 23:42:00 +00:00
|
|
|
printf("setShakePos(%i)\n", shakeOffset);
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::showOverlay() {
|
|
|
|
//printf("showOverlay()\n");
|
|
|
|
_overlayVisible = true;
|
2007-11-17 21:26:03 +00:00
|
|
|
_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::hideOverlay() {
|
|
|
|
//printf("hideOverlay()\n");
|
|
|
|
_overlayVisible = false;
|
2007-11-17 21:26:03 +00:00
|
|
|
_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::clearOverlay() {
|
|
|
|
//printf("clearOverlay()\n");
|
|
|
|
bzero(_overlayBuffer, _screenWidth * _screenHeight * sizeof(OverlayColor));
|
2007-11-17 21:26:03 +00:00
|
|
|
_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::grabOverlay(OverlayColor *buf, int pitch) {
|
|
|
|
//printf("grabOverlay()\n");
|
|
|
|
int h = _screenHeight;
|
|
|
|
OverlayColor *src = _overlayBuffer;
|
|
|
|
|
|
|
|
do {
|
|
|
|
memcpy(buf, src, _screenWidth * sizeof(OverlayColor));
|
|
|
|
src += _screenWidth;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2007-11-20 19:42:41 +00:00
|
|
|
if (w > _screenWidth - x)
|
2007-11-13 08:06:15 +00:00
|
|
|
w = _screenWidth - x;
|
|
|
|
|
2007-11-20 19:42:41 +00:00
|
|
|
if (h > _screenHeight - y)
|
2007-11-13 08:06:15 +00:00
|
|
|
h = _screenHeight - y;
|
|
|
|
|
|
|
|
if (w <= 0 || h <= 0)
|
|
|
|
return;
|
|
|
|
|
2007-11-15 23:42:00 +00:00
|
|
|
_dirtyRects.push_back(Common::Rect(x, y, x + w + 1, y + h + 1));
|
|
|
|
|
2007-11-13 08:06:15 +00:00
|
|
|
OverlayColor *dst = _overlayBuffer + (y * _screenWidth + x);
|
2007-11-20 19:42:41 +00:00
|
|
|
if (_screenWidth == pitch && pitch == w)
|
2007-11-13 08:06:15 +00:00
|
|
|
memcpy(dst, buf, h * w * sizeof(OverlayColor));
|
2007-11-20 19:42:41 +00:00
|
|
|
else {
|
2007-11-13 08:06:15 +00:00
|
|
|
do {
|
|
|
|
memcpy(dst, buf, w * sizeof(OverlayColor));
|
|
|
|
buf += pitch;
|
|
|
|
dst += _screenWidth;
|
|
|
|
} while (--h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 OSystem_IPHONE::getOverlayHeight() {
|
|
|
|
return _screenHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
int16 OSystem_IPHONE::getOverlayWidth() {
|
|
|
|
return _screenWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OSystem_IPHONE::showMouse(bool visible) {
|
|
|
|
bool last = _mouseVisible;
|
|
|
|
_mouseVisible = visible;
|
2007-11-17 21:26:03 +00:00
|
|
|
dirtyMouseCursor();
|
2007-11-13 08:06:15 +00:00
|
|
|
return last;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::warpMouse(int x, int y) {
|
|
|
|
//printf("warpMouse()\n");
|
2007-11-15 23:42:00 +00:00
|
|
|
|
2007-11-17 21:26:03 +00:00
|
|
|
dirtyMouseCursor();
|
2007-11-13 08:06:15 +00:00
|
|
|
_mouseX = x;
|
|
|
|
_mouseY = y;
|
2007-11-17 21:26:03 +00:00
|
|
|
dirtyMouseCursor();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::dirtyMouseCursor() {
|
|
|
|
addDirtyRect(_mouseX - _mouseHotspotX, _mouseY - _mouseHotspotY, _mouseX + _mouseWidth - _mouseHotspotX + 1, _mouseY + _mouseHeight - _mouseHotspotY + 1);
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::setMouseCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor, int cursorTargetScale) {
|
2007-11-17 21:26:03 +00:00
|
|
|
//printf("setMouseCursor(%i, %i)\n", hotspotX, hotspotY);
|
|
|
|
|
|
|
|
dirtyMouseCursor();
|
2007-11-13 08:06:15 +00:00
|
|
|
|
|
|
|
if (_mouseBuf != NULL && (_mouseWidth != w || _mouseHeight != h)) {
|
|
|
|
free(_mouseBuf);
|
|
|
|
_mouseBuf = NULL;
|
|
|
|
}
|
|
|
|
|
2007-11-20 19:42:41 +00:00
|
|
|
if (_mouseBuf == NULL)
|
2007-11-13 08:06:15 +00:00
|
|
|
_mouseBuf = (byte *)malloc(w * h);
|
|
|
|
|
|
|
|
_mouseWidth = w;
|
|
|
|
_mouseHeight = h;
|
|
|
|
|
|
|
|
_mouseHotspotX = hotspotX;
|
|
|
|
_mouseHotspotY = hotspotY;
|
|
|
|
|
|
|
|
_mouseKeyColour = keycolor;
|
|
|
|
|
|
|
|
memcpy(_mouseBuf, buf, w * h);
|
2007-11-20 19:42:41 +00:00
|
|
|
|
2007-11-17 21:26:03 +00:00
|
|
|
dirtyMouseCursor();
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool OSystem_IPHONE::pollEvent(Common::Event &event) {
|
|
|
|
//printf("pollEvent()\n");
|
|
|
|
|
2007-11-14 23:19:09 +00:00
|
|
|
long curTime = getMillis();
|
|
|
|
|
|
|
|
if (_timerCallback && (curTime >= _timerCallbackNext)) {
|
2007-11-18 01:14:20 +00:00
|
|
|
_timerCallback(_timerCallbackTimer);
|
2007-11-14 23:19:09 +00:00
|
|
|
_timerCallbackNext = curTime + _timerCallbackTimer;
|
|
|
|
}
|
|
|
|
|
2007-11-18 17:58:53 +00:00
|
|
|
if (_needEventRestPeriod) {
|
|
|
|
// Workaround: Some engines can't handle mouse-down and mouse-up events
|
|
|
|
// appearing right after each other, without a call returning no input in between.
|
|
|
|
_needEventRestPeriod = false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-11-13 08:06:15 +00:00
|
|
|
if (_queuedInputEvent.type != (Common::EventType)0) {
|
|
|
|
event = _queuedInputEvent;
|
|
|
|
_queuedInputEvent.type = (Common::EventType)0;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int eventType;
|
|
|
|
float xUnit, yUnit;
|
|
|
|
|
|
|
|
if (iPhone_fetchEvent(&eventType, &xUnit, &yUnit)) {
|
2007-11-17 21:26:03 +00:00
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
if (_landscapeMode) {
|
|
|
|
x = (int)((1.0 - yUnit) * _screenWidth);
|
|
|
|
y = (int)(xUnit * _screenHeight);
|
|
|
|
} else {
|
|
|
|
x = (int)(xUnit * _screenWidth);
|
|
|
|
y = (int)(yUnit * _screenHeight);
|
|
|
|
}
|
2007-11-13 08:06:15 +00:00
|
|
|
|
|
|
|
switch ((InputEvent)eventType) {
|
|
|
|
case kInputMouseDown:
|
|
|
|
//printf("Mouse down at (%u, %u)\n", x, y);
|
2007-11-19 22:29:02 +00:00
|
|
|
|
2007-11-15 23:42:00 +00:00
|
|
|
warpMouse(x, y);
|
2007-11-19 22:29:02 +00:00
|
|
|
if (_mouseClickAndDragEnabled) {
|
|
|
|
event.type = Common::EVENT_LBUTTONDOWN;
|
|
|
|
event.mouse.x = _mouseX;
|
|
|
|
event.mouse.y = _mouseY;
|
|
|
|
} else {
|
|
|
|
_lastMouseDown = curTime;
|
|
|
|
return false;
|
|
|
|
}
|
2007-11-13 08:06:15 +00:00
|
|
|
break;
|
|
|
|
case kInputMouseUp:
|
|
|
|
//printf("Mouse up at (%u, %u)\n", x, y);
|
|
|
|
|
2007-11-19 22:29:02 +00:00
|
|
|
if (_mouseClickAndDragEnabled) {
|
|
|
|
event.type = Common::EVENT_LBUTTONUP;
|
2007-11-13 08:06:15 +00:00
|
|
|
event.mouse.x = _mouseX;
|
|
|
|
event.mouse.y = _mouseY;
|
|
|
|
} else {
|
2007-11-19 22:29:02 +00:00
|
|
|
if (curTime - _lastMouseDown < 250) {
|
|
|
|
event.type = Common::EVENT_LBUTTONDOWN;
|
|
|
|
event.mouse.x = _mouseX;
|
|
|
|
event.mouse.y = _mouseY;
|
|
|
|
|
|
|
|
_queuedInputEvent.type = Common::EVENT_LBUTTONUP;
|
|
|
|
_queuedInputEvent.mouse.x = _mouseX;
|
|
|
|
_queuedInputEvent.mouse.y = _mouseY;
|
|
|
|
_lastMouseTap = curTime;
|
|
|
|
_needEventRestPeriod = true;
|
2007-11-20 19:42:41 +00:00
|
|
|
} else
|
2007-11-19 22:29:02 +00:00
|
|
|
return false;
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case kInputMouseDragged:
|
|
|
|
//printf("Mouse dragged at (%u, %u)\n", x, y);
|
|
|
|
if (_secondaryTapped) {
|
2007-11-19 22:29:02 +00:00
|
|
|
// if (_gestureStartX == -1 || _gestureStartY == -1) {
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
|
2007-11-13 08:06:15 +00:00
|
|
|
int vecX = (x - _gestureStartX);
|
|
|
|
int vecY = (y - _gestureStartY);
|
|
|
|
int lengthSq = vecX * vecX + vecY * vecY;
|
|
|
|
//printf("Lengthsq: %u\n", lengthSq);
|
|
|
|
|
2007-11-19 22:29:02 +00:00
|
|
|
if (lengthSq > 15000) { // Long enough gesture to react upon.
|
2007-11-13 08:06:15 +00:00
|
|
|
_gestureStartX = x;
|
|
|
|
_gestureStartY = y;
|
|
|
|
|
|
|
|
float vecLength = sqrt(lengthSq);
|
|
|
|
float vecXNorm = vecX / vecLength;
|
|
|
|
float vecYNorm = vecY / vecLength;
|
|
|
|
|
|
|
|
//printf("Swipe vector: (%.2f, %.2f)\n", vecXNorm, vecYNorm);
|
|
|
|
|
|
|
|
if (vecXNorm > -0.50 && vecXNorm < 0.50 && vecYNorm > 0.75) {
|
|
|
|
// Swipe down
|
|
|
|
event.type = Common::EVENT_KEYDOWN;
|
|
|
|
_queuedInputEvent.type = Common::EVENT_KEYUP;
|
|
|
|
|
|
|
|
event.kbd.flags = _queuedInputEvent.kbd.flags = 0;
|
|
|
|
event.kbd.keycode = _queuedInputEvent.kbd.keycode = Common::KEYCODE_F5;
|
2007-11-18 17:58:53 +00:00
|
|
|
event.kbd.ascii = _queuedInputEvent.kbd.ascii = Common::ASCII_F5;
|
|
|
|
_needEventRestPeriod = true;
|
2007-11-13 08:06:15 +00:00
|
|
|
} else if (vecXNorm > -0.50 && vecXNorm < 0.50 && vecYNorm < -0.75) {
|
|
|
|
// Swipe up
|
2007-11-19 22:29:02 +00:00
|
|
|
_mouseClickAndDragEnabled = !_mouseClickAndDragEnabled;
|
|
|
|
GUI::TimedMessageDialog dialog("Toggling mouse-click-and-drag mode.", 1500);
|
|
|
|
dialog.runModal();
|
2007-11-13 08:06:15 +00:00
|
|
|
} else if (vecXNorm > 0.75 && vecYNorm > -0.5 && vecYNorm < 0.5) {
|
|
|
|
// Swipe right
|
2007-11-19 22:29:02 +00:00
|
|
|
// _secondaryTapped = !_secondaryTapped;
|
|
|
|
// _gestureStartX = x;
|
|
|
|
// _gestureStartY = y;
|
|
|
|
//
|
|
|
|
// GUI::TimedMessageDialog dialog("Forcing toggle of pressed state.", 1500);
|
|
|
|
// dialog.runModal();
|
2007-11-13 08:06:15 +00:00
|
|
|
return false;
|
|
|
|
} else if (vecXNorm < -0.75 && vecYNorm > -0.5 && vecYNorm < 0.5) {
|
|
|
|
// Swipe left
|
|
|
|
return false;
|
2007-11-20 19:42:41 +00:00
|
|
|
} else
|
2007-11-13 08:06:15 +00:00
|
|
|
return false;
|
2007-11-20 19:42:41 +00:00
|
|
|
} else
|
|
|
|
return false;
|
2007-11-13 08:06:15 +00:00
|
|
|
} else {
|
|
|
|
event.type = Common::EVENT_MOUSEMOVE;
|
|
|
|
event.mouse.x = x;
|
|
|
|
event.mouse.y = y;
|
2007-11-19 22:29:02 +00:00
|
|
|
warpMouse(x, y);
|
|
|
|
}
|
2007-11-13 08:06:15 +00:00
|
|
|
break;
|
|
|
|
case kInputMouseSecondToggled:
|
|
|
|
_secondaryTapped = !_secondaryTapped;
|
2007-11-18 01:14:20 +00:00
|
|
|
printf("Mouse second at (%u, %u). State now %s.\n", x, y, _secondaryTapped ? "on" : "off");
|
2007-11-13 08:06:15 +00:00
|
|
|
if (_secondaryTapped) {
|
|
|
|
_lastSecondaryDown = curTime;
|
|
|
|
_gestureStartX = x;
|
|
|
|
_gestureStartY = y;
|
|
|
|
return false;
|
|
|
|
} else if (curTime - _lastSecondaryDown < 250 ) {
|
|
|
|
if (curTime - _lastSecondaryTap < 250 && !_overlayVisible) {
|
|
|
|
event.type = Common::EVENT_KEYDOWN;
|
|
|
|
_queuedInputEvent.type = Common::EVENT_KEYUP;
|
|
|
|
|
|
|
|
event.kbd.flags = _queuedInputEvent.kbd.flags = 0;
|
|
|
|
event.kbd.keycode = _queuedInputEvent.kbd.keycode = Common::KEYCODE_ESCAPE;
|
2007-11-18 17:58:53 +00:00
|
|
|
event.kbd.ascii = _queuedInputEvent.kbd.ascii = Common::ASCII_ESCAPE;
|
|
|
|
_needEventRestPeriod = true;
|
2007-11-13 08:06:15 +00:00
|
|
|
_lastSecondaryTap = 0;
|
|
|
|
} else {
|
|
|
|
event.type = Common::EVENT_RBUTTONDOWN;
|
|
|
|
event.mouse.x = _mouseX;
|
|
|
|
event.mouse.y = _mouseY;
|
|
|
|
_queuedInputEvent.type = Common::EVENT_RBUTTONUP;
|
|
|
|
_queuedInputEvent.mouse.x = _mouseX;
|
|
|
|
_queuedInputEvent.mouse.y = _mouseY;
|
|
|
|
_lastSecondaryTap = curTime;
|
2007-11-18 17:58:53 +00:00
|
|
|
_needEventRestPeriod = true;
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
2007-11-20 19:42:41 +00:00
|
|
|
} else
|
2007-11-13 08:06:15 +00:00
|
|
|
return false;
|
|
|
|
break;
|
2007-11-17 21:26:03 +00:00
|
|
|
case kInputOrientationChanged:
|
|
|
|
bool newModeIsLandscape = (int)xUnit != 1;
|
|
|
|
//printf("Orientation: %i", (int)xUnit);
|
|
|
|
if (_landscapeMode != newModeIsLandscape) {
|
|
|
|
_landscapeMode = newModeIsLandscape;
|
2007-11-20 19:42:41 +00:00
|
|
|
if (_landscapeMode)
|
2007-11-17 21:26:03 +00:00
|
|
|
iPhone_initSurface(_screenHeight, _screenWidth, true);
|
2007-11-20 19:42:41 +00:00
|
|
|
else
|
2007-11-17 21:26:03 +00:00
|
|
|
iPhone_initSurface(_screenWidth, _screenHeight, false);
|
2007-11-20 19:42:41 +00:00
|
|
|
|
2007-11-17 21:26:03 +00:00
|
|
|
_dirtyRects.push_back(Common::Rect(0, 0, _screenWidth, _screenHeight));
|
|
|
|
}
|
|
|
|
break;
|
2007-11-18 17:58:53 +00:00
|
|
|
case kInputKeyPressed:
|
|
|
|
int keyPressed = (int)xUnit;
|
|
|
|
int ascii = keyPressed;
|
|
|
|
//printf("key: %i\n", keyPressed);
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
event.type = Common::EVENT_KEYDOWN;
|
|
|
|
_queuedInputEvent.type = Common::EVENT_KEYUP;
|
|
|
|
|
|
|
|
event.kbd.flags = _queuedInputEvent.kbd.flags = 0;
|
|
|
|
event.kbd.keycode = _queuedInputEvent.kbd.keycode = (Common::KeyCode)keyPressed;
|
|
|
|
event.kbd.ascii = _queuedInputEvent.kbd.ascii = ascii;
|
|
|
|
_needEventRestPeriod = true;
|
|
|
|
break;
|
|
|
|
|
2007-11-13 08:06:15 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 OSystem_IPHONE::getMillis() {
|
|
|
|
//printf("getMillis()\n");
|
|
|
|
|
|
|
|
struct timeval currentTime;
|
|
|
|
gettimeofday(¤tTime, NULL);
|
|
|
|
return (uint32)(((currentTime.tv_sec - _startTime.tv_sec) * 1000) +
|
|
|
|
((currentTime.tv_usec - _startTime.tv_usec) / 1000));
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::delayMillis(uint msecs) {
|
2007-11-15 23:42:00 +00:00
|
|
|
//printf("delayMillis(%d)\n", msecs);
|
2007-11-13 08:06:15 +00:00
|
|
|
usleep(msecs * 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
OSystem::MutexRef OSystem_IPHONE::createMutex(void) {
|
2007-11-14 23:19:09 +00:00
|
|
|
//pthread_mutex_t *mutex = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));
|
|
|
|
//pthread_mutex_init(mutex, NULL);
|
|
|
|
//return (MutexRef)mutex;
|
|
|
|
return NULL;
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::lockMutex(MutexRef mutex) {
|
2007-11-14 23:19:09 +00:00
|
|
|
//pthread_mutex_lock((pthread_mutex_t *) mutex);
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::unlockMutex(MutexRef mutex) {
|
2007-11-14 23:19:09 +00:00
|
|
|
//pthread_mutex_unlock((pthread_mutex_t *) mutex);
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::deleteMutex(MutexRef mutex) {
|
2007-11-14 23:19:09 +00:00
|
|
|
//pthread_mutex_destroy((pthread_mutex_t *) mutex);
|
|
|
|
//free(mutex);
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
|
2007-11-13 21:21:17 +00:00
|
|
|
void OSystem_IPHONE::AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB) {
|
|
|
|
//printf("AQBufferCallback()\n");
|
|
|
|
if (s_AudioQueue.frameCount > 0 && s_soundCallback != NULL) {
|
|
|
|
outQB->mAudioDataByteSize = 4 * s_AudioQueue.frameCount;
|
|
|
|
s_soundCallback(s_soundParam, (byte *)outQB->mAudioData, outQB->mAudioDataByteSize);
|
|
|
|
AudioQueueEnqueueBuffer(inQ, outQB, 0, NULL);
|
2007-11-20 19:42:41 +00:00
|
|
|
} else
|
2007-11-13 21:21:17 +00:00
|
|
|
AudioQueueStop(s_AudioQueue.queue, false);
|
|
|
|
}
|
|
|
|
|
2007-11-13 08:06:15 +00:00
|
|
|
bool OSystem_IPHONE::setSoundCallback(SoundProc proc, void *param) {
|
2007-11-13 21:21:17 +00:00
|
|
|
//printf("setSoundCallback()\n");
|
|
|
|
s_soundCallback = proc;
|
|
|
|
s_soundParam = param;
|
|
|
|
|
|
|
|
s_AudioQueue.dataFormat.mSampleRate = AUDIO_SAMPLE_RATE;
|
|
|
|
s_AudioQueue.dataFormat.mFormatID = kAudioFormatLinearPCM;
|
|
|
|
s_AudioQueue.dataFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
|
|
|
|
s_AudioQueue.dataFormat.mBytesPerPacket = 4;
|
|
|
|
s_AudioQueue.dataFormat.mFramesPerPacket = 1;
|
|
|
|
s_AudioQueue.dataFormat.mBytesPerFrame = 4;
|
|
|
|
s_AudioQueue.dataFormat.mChannelsPerFrame = 2;
|
|
|
|
s_AudioQueue.dataFormat.mBitsPerChannel = 16;
|
|
|
|
s_AudioQueue.frameCount = WAVE_BUFFER_SIZE;
|
|
|
|
|
|
|
|
if (AudioQueueNewOutput(&s_AudioQueue.dataFormat, AQBufferCallback, &s_AudioQueue, 0, kCFRunLoopCommonModes, 0, &s_AudioQueue.queue)) {
|
|
|
|
printf("Couldn't set the AudioQueue callback!\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32 bufferBytes = s_AudioQueue.frameCount * s_AudioQueue.dataFormat.mBytesPerFrame;
|
|
|
|
|
|
|
|
for (int i = 0; i < AUDIO_BUFFERS; i++) {
|
|
|
|
if (AudioQueueAllocateBuffer(s_AudioQueue.queue, bufferBytes, &s_AudioQueue.buffers[i])) {
|
|
|
|
printf("Error allocating AudioQueue buffer!\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
AQBufferCallback(&s_AudioQueue, s_AudioQueue.queue, s_AudioQueue.buffers[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
AudioQueueSetParameter(s_AudioQueue.queue, kAudioQueueParam_Volume, 1.0);
|
|
|
|
if (AudioQueueStart(s_AudioQueue.queue, NULL)) {
|
|
|
|
printf("Error starting the AudioQueue!\n");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-11-13 08:06:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::clearSoundCallback() {
|
2007-11-17 21:26:03 +00:00
|
|
|
debug("clearSoundCallback()\n");
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int OSystem_IPHONE::getOutputSampleRate() const {
|
2007-11-13 21:21:17 +00:00
|
|
|
return AUDIO_SAMPLE_RATE;
|
2007-11-13 08:06:15 +00:00
|
|
|
}
|
|
|
|
|
2007-11-14 23:19:09 +00:00
|
|
|
void OSystem_IPHONE::setTimerCallback(TimerProc callback, int interval) {
|
|
|
|
//printf("setTimerCallback()\n");
|
|
|
|
|
|
|
|
if (callback != NULL) {
|
|
|
|
_timerCallbackTimer = interval;
|
|
|
|
_timerCallbackNext = getMillis() + interval;
|
|
|
|
_timerCallback = callback;
|
2007-11-20 19:42:41 +00:00
|
|
|
} else
|
2007-11-14 23:19:09 +00:00
|
|
|
_timerCallback = NULL;
|
|
|
|
}
|
|
|
|
|
2007-11-13 08:06:15 +00:00
|
|
|
void OSystem_IPHONE::quit() {
|
|
|
|
}
|
|
|
|
|
|
|
|
void OSystem_IPHONE::setWindowCaption(const char *caption) {
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::SaveFileManager *OSystem_IPHONE::getSavefileManager() {
|
|
|
|
assert(_savefile);
|
|
|
|
return _savefile;
|
|
|
|
}
|
|
|
|
|
|
|
|
Audio::Mixer *OSystem_IPHONE::getMixer() {
|
|
|
|
assert(_mixer);
|
|
|
|
return _mixer;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::TimerManager *OSystem_IPHONE::getTimerManager() {
|
|
|
|
assert(_timer);
|
|
|
|
return _timer;
|
|
|
|
}
|
|
|
|
|
|
|
|
OSystem *OSystem_IPHONE_create() {
|
|
|
|
return new OSystem_IPHONE();
|
|
|
|
}
|
|
|
|
|
|
|
|
void iphone_main(int argc, char *argv[]) {
|
2007-11-17 21:26:03 +00:00
|
|
|
|
|
|
|
// Redirect stdout and stderr if we're launching from the Springboard.
|
|
|
|
if (argc == 2 && strcmp(argv[1], "--launchedFromSB") == 0) {
|
|
|
|
FILE *newfp = fopen("/tmp/scummvm.log", "a");
|
|
|
|
if (newfp != NULL) {
|
|
|
|
fclose(stdout);
|
|
|
|
fclose(stderr);
|
|
|
|
*stdout = *newfp;
|
|
|
|
*stderr = *newfp;
|
|
|
|
setbuf(stdout, NULL);
|
|
|
|
setbuf(stderr, NULL);
|
|
|
|
|
|
|
|
//extern int gDebugLevel;
|
|
|
|
//gDebugLevel = 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-13 08:06:15 +00:00
|
|
|
g_system = OSystem_IPHONE_create();
|
|
|
|
assert(g_system);
|
|
|
|
|
|
|
|
// Invoke the actual ScummVM main entry point:
|
|
|
|
scummvm_main(argc, argv);
|
|
|
|
g_system->quit(); // TODO: Consider removing / replacing this!
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|