[Scummvm-cvs-logs] SF.net SVN: scummvm: [29506] scummvm/trunk/backends/platform/iphone
vinterstum at users.sourceforge.net
vinterstum at users.sourceforge.net
Thu Nov 15 00:19:11 CET 2007
Revision: 29506
http://scummvm.svn.sourceforge.net/scummvm/?rev=29506&view=rev
Author: vinterstum
Date: 2007-11-14 15:19:09 -0800 (Wed, 14 Nov 2007)
Log Message:
-----------
iPhone: Implemented timers, and disabled mutexes (was causing deadlocks in SnM and COMI, for some reason
Modified Paths:
--------------
scummvm/trunk/backends/platform/iphone/iphone_video.m
scummvm/trunk/backends/platform/iphone/osys_iphone.cpp
scummvm/trunk/backends/platform/iphone/osys_iphone.h
Modified: scummvm/trunk/backends/platform/iphone/iphone_video.m
===================================================================
--- scummvm/trunk/backends/platform/iphone/iphone_video.m 2007-11-14 22:31:53 UTC (rev 29505)
+++ scummvm/trunk/backends/platform/iphone/iphone_video.m 2007-11-14 23:19:09 UTC (rev 29506)
@@ -242,6 +242,7 @@
- (void)mouseDragged:(GSEvent*)event
{
+ //printf("mouseDragged()\n");
struct CGPoint point = GSEventGetLocationInWindow(event);
[self addEvent:
[[NSDictionary alloc] initWithObjectsAndKeys:
Modified: scummvm/trunk/backends/platform/iphone/osys_iphone.cpp
===================================================================
--- scummvm/trunk/backends/platform/iphone/osys_iphone.cpp 2007-11-14 22:31:53 UTC (rev 29505)
+++ scummvm/trunk/backends/platform/iphone/osys_iphone.cpp 2007-11-14 23:19:09 UTC (rev 29506)
@@ -64,6 +64,8 @@
}
OSystem_IPHONE::~OSystem_IPHONE() {
+ AudioQueueDispose(s_AudioQueue.queue, true);
+
delete _savefile;
delete _mixer;
delete _timer;
@@ -71,15 +73,23 @@
delete _fullscreen;
}
+int OSystem_IPHONE::timerHandler(int t)
+{
+ DefaultTimerManager *tm = (DefaultTimerManager *)g_system->getTimerManager();
+ tm->handler();
+ return t;
+}
+
void OSystem_IPHONE::initBackend() {
_savefile = new DefaultSaveFileManager();
_mixer = new Audio::Mixer();
_timer = new DefaultTimerManager();
- setSoundCallback(Audio::Mixer::mixCallback, _mixer);
-
gettimeofday(&_startTime, NULL);
+ setSoundCallback(Audio::Mixer::mixCallback, _mixer);
+ setTimerCallback(&OSystem_IPHONE::timerHandler, 10);
+
OSystem::initBackend();
}
@@ -395,6 +405,14 @@
bool OSystem_IPHONE::pollEvent(Common::Event &event) {
//printf("pollEvent()\n");
+ long curTime = getMillis();
+
+ if (_timerCallback && (curTime >= _timerCallbackNext)) {
+ //printf("Time for a callback\n");
+ //_timerCallbackTimer = _timerCallback(_timerCallbackTimer);
+ _timerCallbackNext = curTime + _timerCallbackTimer;
+ }
+
if (_queuedInputEvent.type != (Common::EventType)0) {
event = _queuedInputEvent;
_queuedInputEvent.type = (Common::EventType)0;
@@ -408,8 +426,6 @@
int x = (int)((1.0 - yUnit) * _screenWidth);
int y = (int)(xUnit * _screenHeight);
- long curTime = getMillis();
-
switch ((InputEvent)eventType) {
case kInputMouseDown:
//printf("Mouse down at (%u, %u)\n", x, y);
@@ -482,7 +498,7 @@
event.kbd.flags = _queuedInputEvent.kbd.flags = 0;
event.kbd.keycode = _queuedInputEvent.kbd.keycode = Common::KEYCODE_1;
- event.kbd.ascii = _queuedInputEvent.kbd.ascii = 27;
+ event.kbd.ascii = _queuedInputEvent.kbd.ascii = '1';
} else if (vecXNorm > 0.75 && vecYNorm > -0.5 && vecYNorm < 0.5) {
// Swipe right
return false;
@@ -553,27 +569,28 @@
}
void OSystem_IPHONE::delayMillis(uint msecs) {
- //printf("delayMillis(%d)\n", msecs);
+ printf("delayMillis(%d)\n", msecs);
usleep(msecs * 1000);
}
OSystem::MutexRef OSystem_IPHONE::createMutex(void) {
- pthread_mutex_t *mutex = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));
- pthread_mutex_init(mutex, NULL);
- return (MutexRef)mutex;
+ //pthread_mutex_t *mutex = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));
+ //pthread_mutex_init(mutex, NULL);
+ //return (MutexRef)mutex;
+ return NULL;
}
void OSystem_IPHONE::lockMutex(MutexRef mutex) {
- pthread_mutex_lock((pthread_mutex_t *) mutex);
+ //pthread_mutex_lock((pthread_mutex_t *) mutex);
}
void OSystem_IPHONE::unlockMutex(MutexRef mutex) {
- pthread_mutex_unlock((pthread_mutex_t *) mutex);
+ //pthread_mutex_unlock((pthread_mutex_t *) mutex);
}
void OSystem_IPHONE::deleteMutex(MutexRef mutex) {
- pthread_mutex_destroy((pthread_mutex_t *) mutex);
- free(mutex);
+ //pthread_mutex_destroy((pthread_mutex_t *) mutex);
+ //free(mutex);
}
void OSystem_IPHONE::AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB) {
@@ -634,8 +651,20 @@
return AUDIO_SAMPLE_RATE;
}
+void OSystem_IPHONE::setTimerCallback(TimerProc callback, int interval) {
+ //printf("setTimerCallback()\n");
+
+ if (callback != NULL) {
+ _timerCallbackTimer = interval;
+ _timerCallbackNext = getMillis() + interval;
+ _timerCallback = callback;
+ } else {
+ _timerCallback = NULL;
+ }
+}
+
void OSystem_IPHONE::quit() {
- AudioQueueDispose(s_AudioQueue.queue, true);
+
}
void OSystem_IPHONE::setWindowCaption(const char *caption) {
Modified: scummvm/trunk/backends/platform/iphone/osys_iphone.h
===================================================================
--- scummvm/trunk/backends/platform/iphone/osys_iphone.h 2007-11-14 22:31:53 UTC (rev 29505)
+++ scummvm/trunk/backends/platform/iphone/osys_iphone.h 2007-11-14 23:19:09 UTC (rev 29506)
@@ -34,6 +34,7 @@
#define AUDIO_SAMPLE_RATE 44100
typedef void (*SoundProc)(void *param, byte *buf, int len);
+typedef int (*TimerProc)(int interval);
typedef struct AQCallbackStruct {
AudioQueueRef queue;
@@ -80,6 +81,10 @@
long _lastSecondaryTap;
int _gestureStartX, _gestureStartY;
+ int _timerCallbackNext;
+ int _timerCallbackTimer;
+ TimerProc _timerCallback;
+
public:
OSystem_IPHONE();
@@ -134,6 +139,7 @@
virtual bool setSoundCallback(SoundProc proc, void *param);
virtual void clearSoundCallback();
virtual int getOutputSampleRate() const;
+ virtual void setTimerCallback(TimerProc callback, int interval);
virtual void quit();
@@ -145,6 +151,7 @@
protected:
static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB);
+ static int timerHandler(int t);
};
#endif
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list