25 #include "backends/platform/android/portdefs.h" 26 #include "common/fs.h" 27 #include "common/archive.h" 28 #include "common/mutex.h" 29 #include "common/ustr.h" 30 #include "audio/mixer_intern.h" 31 #include "backends/modular-backend.h" 32 #include "backends/plugins/posix/posix-provider.h" 33 #include "backends/fs/posix/posix-fs-factory.h" 34 #include "backends/fs/posix/posix-fs-factory.h" 35 #include "backends/log/log.h" 36 #include "backends/platform/android/touchcontrols.h" 37 #include "engines/engine.h" 41 #include <android/log.h> 49 extern const char *android_log_tag;
51 #define _ANDROID_LOG(prio, fmt, args...) __android_log_print(prio, android_log_tag, fmt, ## args) 52 #define LOGD(fmt, args...) _ANDROID_LOG(ANDROID_LOG_DEBUG, fmt, ##args) 53 #define LOGI(fmt, args...) _ANDROID_LOG(ANDROID_LOG_INFO, fmt, ##args) 54 #define LOGW(fmt, args...) _ANDROID_LOG(ANDROID_LOG_WARN, fmt, ##args) 55 #define LOGE(fmt, args...) _ANDROID_LOG(ANDROID_LOG_ERROR, fmt, ##args) 57 #define MAX_ANDROID_SCUMMVM_LOG_FILESIZE_IN_BYTES (100*1024) 59 #ifdef ANDROID_DEBUG_ENTER 60 #define ENTER(fmt, args...) LOGD("%s(" fmt ")", __FUNCTION__, ##args) 62 #define ENTER(fmt, args...) do { } while (false) 65 #ifdef ANDROID_DEBUG_GL 66 extern void checkGlError(
const char *expr,
const char *file,
int line);
68 #ifdef ANDROID_DEBUG_GL_CALLS 69 #define GLCALLLOG(x, before) \ 72 LOGD("calling '%s' (%s:%d)", x, __FILE__, __LINE__); \ 74 LOGD("returned from '%s' (%s:%d)", x, __FILE__, __LINE__); \ 77 #define GLCALLLOG(x, before) do { } while (false) 82 GLCALLLOG(#x, true); \ 84 GLCALLLOG(#x, false); \ 85 checkGlError(#x, __FILE__, __LINE__); \ 88 #define GLTHREADCHECK \ 90 assert(dynamic_cast<OSystem_Android *>(g_system)->isRunningInMainThread()); \ 94 #define GLCALL(x) do { (x); } while (false) 95 #define GLTHREADCHECK do { } while (false) 98 void *androidGLgetProcAddress(
const char *name);
102 static const int kQueuedInputEventDelay = 50;
106 uint32 originTimeMillis;
109 uint32 referTimeMillis;
118 bool connectedTypeExecuted;
120 EventWithDelay() : originTimeMillis(0), referTimeMillis(0),
delayMillis(0), connectedType(Common::EVENT_INVALID), connectedTypeExecuted(
false) {
124 originTimeMillis = 0;
127 connectedType = Common::EVENT_INVALID;
128 connectedTypeExecuted =
false;
133 int _audio_sample_rate;
134 int _audio_buffer_size;
136 int _screen_changeid;
138 pthread_t _main_thread;
140 bool _timer_thread_exit;
141 pthread_t _timer_thread;
143 bool _audio_thread_exit;
144 pthread_t _audio_thread;
154 EventWithDelay _delayedMouseBtnUpEvent;
155 EventWithDelay _delayedMouseBtnDownEvent;
158 Common::Point _touch_pt_down, _touch_pt_scroll, _touch_pt_dt, _touch_pt_multi;
163 int _trackball_scale;
168 int _secondPointerId;
182 #if defined(USE_OPENGL) && defined(USE_GLAD) 184 mutable void *_gles2DL;
187 static void *timerThreadFunc(
void *arg);
188 static void *audioThreadFunc(
void *arg);
195 TOUCH_MODE_TOUCHPAD = 0,
196 TOUCH_MODE_MOUSE = 1,
197 TOUCH_MODE_GAMEPAD = 2,
202 SCREEN_ORIENTATION_UNSPECIFIED = 0xffffffff,
203 SCREEN_ORIENTATION_LANDSCAPE = 0,
204 SCREEN_ORIENTATION_PORTRAIT = 1
208 SHOW_ON_SCREEN_NONE = 0,
209 SHOW_ON_SCREEN_MENU = 1,
210 SHOW_ON_SCREEN_INPUT_MODE = 2,
211 SHOW_ON_SCREEN_ALL = 0xffffffff,
227 void setPause(
bool pause);
229 void pushEvent(
int type,
int arg1,
int arg2,
int arg3,
int arg4,
int arg5,
int arg6);
232 void pushDelayedTouchMouseBtnEvents();
235 void applyTouchSettings(
bool _3dMode,
bool overlayShown);
236 void setupTouchMode(
int oldValue,
int newValue);
238 void applyOrientationSettings();
240 void updateOnScreenControls();
254 uint32
getMillis(
bool skipRecord =
false)
override;
258 void quit()
override;
273 #if defined(USE_OPENGL_GAME) || defined(USE_OPENGL_SHADERS) 274 OpenGL::ContextType
getOpenGLType()
const override {
return OpenGL::kContextGLES2; }
277 #if defined(USE_OPENGL) && defined(USE_GLAD) 278 void *getOpenGLProcAddress(
const char *name)
const override;
281 #ifdef ANDROID_DEBUG_GL 282 bool isRunningInMainThread() {
return pthread_self() == _main_thread; }
void delayMillis(uint msecs) override
Definition: modular-backend.h:48
bool hasFeature(OSystem::Feature f) override
Common::KeymapperDefaultBindings * getKeymapperDefaultBindings() override
Common::Path getDefaultLogFileName() override
bool getFeatureState(OSystem::Feature f) override
void setWindowCaption(const Common::U32String &caption) override
Common::String getSystemLanguage() const override
virtual Common::Array< uint > getSupportedAntiAliasingLevels() const
Definition: system.h:867
bool openUrl(const Common::String &url) override
EventType
Definition: events.h:49
uint32 getMillis(bool skipRecord=false) override
Feature
Definition: system.h:405
bool isConnectionLimited() override
void logMessage(LogMessageType::Type type, const char *message) override
void engineInit() override
Common::Path getDefaultConfigFileName() override
void getTimeAndDate(TimeDate &td, bool skipRecord=false) const override
void applyBackendSettings() override
void setFeatureState(OSystem::Feature f, bool enable) override
void registerDefaultSettings(const Common::String &target) const override
void engineDone() override
void updateStartSettings(const Common::String &executable, Common::String &command, Common::StringMap &startSettings, Common::StringArray &additionalArgs) override
Common::HardwareInputSet * getHardwareInputSet() override
Definition: mixer_intern.h:58
void initBackend() override
Common::KeymapArray getGlobalKeymaps() override
virtual OpenGL::ContextType getOpenGLType() const
Definition: system.h:881
Definition: archive.h:330
Common::U32String getTextFromClipboard() override
virtual const char *const * buildHelpDialogData() override
bool setTextInClipboard(const Common::U32String &text) override
void addSysArchivesToSearchSet(Common::SearchSet &s, int priority=0) override
Definition: keymapper-defaults.h:32
bool pollEvent(Common::Event &event) override
Audio::Mixer * getMixer() override
Definition: touchcontrols.h:41
Common::MutexInternal * createMutex() override
Definition: android.h:100
bool hasTextInClipboard() override
GUI::OptionsContainerWidget * buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override