ScummVM API documentation
ios7_osys_main.h
1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef BACKENDS_PLATFORM_IOS7_IOS7_OSYS_MAIN_H
23#define BACKENDS_PLATFORM_IOS7_IOS7_OSYS_MAIN_H
24
25#include "graphics/surface.h"
26#include "backends/platform/ios7/ios7_common.h"
27#include "backends/modular-backend.h"
28#include "backends/keymapper/hardware-input.h"
29#include "common/events.h"
30#include "common/str.h"
31#include "common/ustr.h"
32#include "audio/mixer_intern.h"
33#include "backends/fs/posix/posix-fs-factory.h"
34#include "graphics/palette.h"
35
36#include <AudioToolbox/AudioQueue.h>
37
38#define AUDIO_BUFFERS 3
39#define WAVE_BUFFER_SIZE 2048
40#define AUDIO_SAMPLE_RATE 44100
41#define MAX_IOS7_SCUMMVM_LOG_FILESIZE_IN_BYTES (100*1024)
42
43typedef void (*SoundProc)(void *param, byte *buf, int len);
44typedef int (*TimerProc)(int interval);
45
47 AudioQueueRef queue;
48 uint32 frameCount;
49 AudioQueueBufferRef buffers[AUDIO_BUFFERS];
50 AudioStreamBasicDescription dataFormat;
51};
52
54protected:
55 static AQCallbackStruct s_AudioQueue;
56 static SoundProc s_soundCallback;
57 static void *s_soundParam;
58
59 Audio::MixerImpl *_mixer;
60
61 CFTimeInterval _startTime;
62
63 int _runningTasks;
64
65 long _lastMouseDown;
66 long _queuedEventTime;
67 Common::Event _queuedInputEvent;
68 TouchMode _currentTouchMode;
69 int _lastPadX;
70 int _lastPadY;
71
72 ScreenOrientation _screenOrientation;
73
74 Common::String _lastErrorMessage;
75
76 Common::String _chrootBasePath;
77
78public:
79
81 virtual ~OSystem_iOS7();
82
83 static OSystem_iOS7 *sharedInstance();
84
85 void initBackend() override;
86
87 void engineInit() override;
88 void engineDone() override;
89
90 void taskStarted(Task) override;
91 void taskFinished(Task) override;
92
93 void updateStartSettings(const Common::String &executable, Common::String &command, Common::StringMap &settings, Common::StringArray& additionalArgs) override;
94
95 bool hasFeature(Feature f) override;
96 void setFeatureState(Feature f, bool enable) override;
97 bool getFeatureState(Feature f) override;
98
99 TouchMode getCurrentTouchMode() const { return _currentTouchMode; };
100 void setCurrentTouchMode(TouchMode mode) { _currentTouchMode = mode; };
101
102#if TARGET_OS_IOS
103 void applyOrientationSettings();
104 void setSupportedScreenOrientation(ScreenOrientation screenOrientation);
105#endif
106 void applyTouchSettings(bool _3dMode, bool overlayShown);
107
108 uint createOpenGLContext();
109 void destroyOpenGLContext();
110 void refreshScreen() const;
111 int getScreenWidth() const;
112 int getScreenHeight() const;
113 float getSystemHiDPIScreenFactor() const;
114
115#if defined(USE_OPENGL) && defined(USE_GLAD)
116 void *getOpenGLProcAddress(const char *name) const override;
117#endif
118#if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
119 OpenGL::ContextType getOpenGLType() const override { return OpenGL::kContextGLES2; }
121#endif
122
123public:
124 bool pollEvent(Common::Event &event) override;
125 uint32 getMillis(bool skipRecord = false) override;
126 void delayMillis(uint msecs) override;
128
129 static void mixCallback(void *sys, byte *samples, int len);
130 virtual void setupMixer(void);
131 virtual void setTimerCallback(TimerProc callback, int interval);
132 void quit() override;
133
134 void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) override;
135 void getTimeAndDate(TimeDate &td, bool skipRecord = false) const override;
136
138
140
141 void startSoundsystem();
142 void stopSoundsystem();
143
145
146 void logMessage(LogMessageType::Type type, const char *message) override;
147 void fatalError() override;
148
149 bool hasTextInClipboard() override;
151 bool setTextInClipboard(const Common::U32String &text) override;
152
153 bool openUrl(const Common::String &url) override;
154 const char * const *buildHelpDialogData() override;
156
157 bool isConnectionLimited() override;
158 void virtualController(bool connect);
159 bool isiOSAppOnMac() const;
160
161 Common::Path getDefaultLogFileName() override { return Common::Path("/scummvm.log"); }
162
164 void applyBackendSettings() override;
165 void registerDefaultSettings(const Common::String &target) const override;
166
167protected:
168 void updateOutputSurface();
169 void updateTouchMode();
170 void setShowKeyboard(bool);
171 bool isKeyboardShown() const;
172
173 void suspendLoop();
174 void saveState();
175 void restoreState();
176 void clearState();
177 static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB);
178 static int timerHandler(int t);
179
180 bool handleEvent_swipe(Common::Event &event, int direction, int touches);
181 bool handleEvent_tap(Common::Event &event, UIViewTapDescription type, int touches);
182 bool handleEvent_longPress(Common::Event &event, UIViewLongPressDescription type, int touches);
183 void handleEvent_keyPressed(Common::Event &event, int keyPressed, int modifierFlags);
184 void handleEvent_orientationChanged(int orientation);
185 void handleEvent_touchModeChanged();
186 void handleEvent_applicationSuspended();
187 void handleEvent_applicationResumed();
188 void handleEvent_applicationSaveState();
189 void handleEvent_applicationRestoreState();
190 void handleEvent_applicationClearState();
191
192 bool handleEvent_touchBegan(Common::Event &event, int x, int y);
193 bool handleEvent_touchMoved(Common::Event &event, int x, int y);
194
195 void handleEvent_mouseLeftButtonDown(Common::Event &event, int x, int y);
196 void handleEvent_mouseLeftButtonUp(Common::Event &event, int x, int y);
197 void handleEvent_mouseRightButtonDown(Common::Event &event, int x, int y);
198 void handleEvent_mouseRightButtonUp(Common::Event &event, int x, int y);
199 void handleEvent_mouseDelta(Common::Event &event, int deltaX, int deltaY);
200 void handleEvent_mouseEvent(Common::Event &event, int relX, int relY);
201
202 void rebuildSurface();
203 float getMouseSpeed();
204};
205
206#endif
Definition: mixer.h:70
Definition: mixer_intern.h:58
Definition: base-backend.h:31
Definition: events.h:278
Definition: hardware-input.h:199
Definition: mutex.h:40
Definition: path.h:52
Definition: archive.h:330
Definition: str.h:59
Definition: ustr.h:57
Definition: object.h:60
Definition: widget.h:542
Definition: modular-backend.h:48
Definition: ios7_osys_main.h:53
bool pollEvent(Common::Event &event) override
bool getFeatureState(Feature f) override
void taskFinished(Task) override
Audio::Mixer * getMixer() override
const char *const * buildHelpDialogData() override
void applyBackendSettings() override
Common::HardwareInputSet * getHardwareInputSet() override
bool openUrl(const Common::String &url) override
void delayMillis(uint msecs) override
void engineDone() override
void fatalError() override
bool isConnectionLimited() override
void getTimeAndDate(TimeDate &td, bool skipRecord=false) const override
void initBackend() override
bool setTextInClipboard(const Common::U32String &text) override
Common::MutexInternal * createMutex() override
void updateStartSettings(const Common::String &executable, Common::String &command, Common::StringMap &settings, Common::StringArray &additionalArgs) override
Common::U32String getTextFromClipboard() override
void registerDefaultSettings(const Common::String &target) const override
void logMessage(LogMessageType::Type type, const char *message) override
uint32 getMillis(bool skipRecord=false) override
void addSysArchivesToSearchSet(Common::SearchSet &s, int priority=0) override
Common::String getSystemLanguage() const override
void engineInit() override
Common::Path getDefaultLogFileName() override
Definition: ios7_osys_main.h:161
bool hasTextInClipboard() override
void quit() override
Common::Path getDefaultConfigFileName() override
void taskStarted(Task) override
GUI::OptionsContainerWidget * buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override
void setFeatureState(Feature f, bool enable) override
bool hasFeature(Feature f) override
Task
Definition: system.h:348
Feature
Definition: system.h:415
virtual OpenGL::ContextType getOpenGLType() const
Definition: system.h:901
virtual Common::Array< uint > getSupportedAntiAliasingLevels() const
Definition: system.h:887
Type
Definition: log.h:33
Definition: ios7_osys_main.h:46
Definition: events.h:218
Definition: system.h:111