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 
43 typedef void (*SoundProc)(void *param, byte *buf, int len);
44 typedef int (*TimerProc)(int interval);
45 
47  AudioQueueRef queue;
48  uint32 frameCount;
49  AudioQueueBufferRef buffers[AUDIO_BUFFERS];
50  AudioStreamBasicDescription dataFormat;
51 };
52 
54 protected:
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 
78 public:
79 
80  OSystem_iOS7();
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  bool setGraphicsMode(int mode, uint flags) override;
100 
101  TouchMode getCurrentTouchMode() const { return _currentTouchMode; };
102  void setCurrentTouchMode(TouchMode mode) { _currentTouchMode = mode; };
103 
104 #if TARGET_OS_IOS
105  void applyOrientationSettings();
106  void setSupportedScreenOrientation(ScreenOrientation screenOrientation);
107 #endif
108  void applyTouchSettings(bool _3dMode, bool overlayShown);
109 
110  uint createOpenGLContext();
111  void destroyOpenGLContext();
112  void refreshScreen() const;
113  int getScreenWidth() const;
114  int getScreenHeight() const;
115  float getSystemHiDPIScreenFactor() const;
116 
117 #if defined(USE_OPENGL) && defined(USE_GLAD)
118  void *getOpenGLProcAddress(const char *name) const override;
119 #endif
120 #if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS)
121  OpenGL::ContextType getOpenGLType() const override { return OpenGL::kContextGLES2; }
122 #endif
123 
124 public:
125  bool pollEvent(Common::Event &event) override;
126  uint32 getMillis(bool skipRecord = false) override;
127  void delayMillis(uint msecs) override;
128  Common::MutexInternal *createMutex() override;
129 
130  static void mixCallback(void *sys, byte *samples, int len);
131  virtual void setupMixer(void);
132  virtual void setTimerCallback(TimerProc callback, int interval);
133  void quit() override;
134 
135  void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) override;
136  void getTimeAndDate(TimeDate &td, bool skipRecord = false) const override;
137 
138  Common::HardwareInputSet *getHardwareInputSet() override;
139 
140  Audio::Mixer *getMixer() override;
141 
142  void startSoundsystem();
143  void stopSoundsystem();
144 
145  Common::Path getDefaultConfigFileName() override;
146 
147  void logMessage(LogMessageType::Type type, const char *message) override;
148  void fatalError() override;
149 
150  bool hasTextInClipboard() override;
151  Common::U32String getTextFromClipboard() override;
152  bool setTextInClipboard(const Common::U32String &text) override;
153 
154  bool openUrl(const Common::String &url) override;
155  const char * const *buildHelpDialogData() override;
156  Common::String getSystemLanguage() const override;
157 
158  bool isConnectionLimited() override;
159  void virtualController(bool connect);
160  bool isiOSAppOnMac() const;
161 
162  virtual Common::Path getDefaultLogFileName() override { return Common::Path("/scummvm.log"); }
163 
164  virtual GUI::OptionsContainerWidget* buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
165  virtual void applyBackendSettings() override;
166  virtual void registerDefaultSettings(const Common::String &target) const override;
167 
168 protected:
169  void updateOutputSurface();
170  void updateTouchMode();
171  void setShowKeyboard(bool);
172  bool isKeyboardShown() const;
173 
174  void suspendLoop();
175  void saveState();
176  void restoreState();
177  void clearState();
178  static void AQBufferCallback(void *in, AudioQueueRef inQ, AudioQueueBufferRef outQB);
179  static int timerHandler(int t);
180 
181  bool handleEvent_swipe(Common::Event &event, int direction, int touches);
182  bool handleEvent_tap(Common::Event &event, UIViewTapDescription type, int touches);
183  bool handleEvent_longPress(Common::Event &event, UIViewLongPressDescription type, int touches);
184  void handleEvent_keyPressed(Common::Event &event, int keyPressed, int modifierFlags);
185  void handleEvent_orientationChanged(int orientation);
186  void handleEvent_touchModeChanged();
187  void handleEvent_applicationSuspended();
188  void handleEvent_applicationResumed();
189  void handleEvent_applicationSaveState();
190  void handleEvent_applicationRestoreState();
191  void handleEvent_applicationClearState();
192 
193  bool handleEvent_touchBegan(Common::Event &event, int x, int y);
194  bool handleEvent_touchMoved(Common::Event &event, int x, int y);
195 
196  void handleEvent_mouseLeftButtonDown(Common::Event &event, int x, int y);
197  void handleEvent_mouseLeftButtonUp(Common::Event &event, int x, int y);
198  void handleEvent_mouseRightButtonDown(Common::Event &event, int x, int y);
199  void handleEvent_mouseRightButtonUp(Common::Event &event, int x, int y);
200  void handleEvent_mouseDelta(Common::Event &event, int deltaX, int deltaY);
201  void handleEvent_mouseEvent(Common::Event &event, int relX, int relY);
202 
203  void rebuildSurface();
204  float getMouseSpeed();
205 };
206 
207 #endif
Definition: modular-backend.h:48
Definition: system.h:105
Definition: str.h:59
Feature
Definition: system.h:417
Definition: path.h:52
Task
Definition: system.h:350
Definition: ios7_osys_main.h:53
Definition: object.h:60
Definition: widget.h:528
Type
Definition: system.h:121
Definition: mixer_intern.h:58
Definition: mixer.h:59
Definition: ustr.h:57
Definition: archive.h:312
Definition: ios7_osys_main.h:46
Definition: events.h:198
Definition: hardware-input.h:199
Definition: base-backend.h:44
Definition: mutex.h:40
virtual Common::Path getDefaultLogFileName() override
Definition: ios7_osys_main.h:162