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" 40 #include <android/log.h> 48 extern const char *android_log_tag;
50 #define _ANDROID_LOG(prio, fmt, args...) __android_log_print(prio, android_log_tag, fmt, ## args) 51 #define LOGD(fmt, args...) _ANDROID_LOG(ANDROID_LOG_DEBUG, fmt, ##args) 52 #define LOGI(fmt, args...) _ANDROID_LOG(ANDROID_LOG_INFO, fmt, ##args) 53 #define LOGW(fmt, args...) _ANDROID_LOG(ANDROID_LOG_WARN, fmt, ##args) 54 #define LOGE(fmt, args...) _ANDROID_LOG(ANDROID_LOG_ERROR, fmt, ##args) 56 #define MAX_ANDROID_SCUMMVM_LOG_FILESIZE_IN_BYTES (100*1024) 58 #ifdef ANDROID_DEBUG_ENTER 59 #define ENTER(fmt, args...) LOGD("%s(" fmt ")", __FUNCTION__, ##args) 61 #define ENTER(fmt, args...) do { } while (false) 64 #ifdef ANDROID_DEBUG_GL 65 extern void checkGlError(
const char *expr,
const char *file,
int line);
67 #ifdef ANDROID_DEBUG_GL_CALLS 68 #define GLCALLLOG(x, before) \ 71 LOGD("calling '%s' (%s:%d)", x, __FILE__, __LINE__); \ 73 LOGD("returned from '%s' (%s:%d)", x, __FILE__, __LINE__); \ 76 #define GLCALLLOG(x, before) do { } while (false) 81 GLCALLLOG(#x, true); \ 83 GLCALLLOG(#x, false); \ 84 checkGlError(#x, __FILE__, __LINE__); \ 87 #define GLTHREADCHECK \ 89 assert(dynamic_cast<OSystem_Android *>(g_system)->isRunningInMainThread()); \ 93 #define GLCALL(x) do { (x); } while (false) 94 #define GLTHREADCHECK do { } while (false) 97 void *androidGLgetProcAddress(
const char *name);
101 static const int kQueuedInputEventDelay = 50;
105 uint32 originTimeMillis;
108 uint32 referTimeMillis;
117 bool connectedTypeExecuted;
119 EventWithDelay() : originTimeMillis(0), referTimeMillis(0),
delayMillis(0), connectedType(Common::EVENT_INVALID), connectedTypeExecuted(
false) {
123 originTimeMillis = 0;
126 connectedType = Common::EVENT_INVALID;
127 connectedTypeExecuted =
false;
132 int _audio_sample_rate;
133 int _audio_buffer_size;
135 int _screen_changeid;
137 pthread_t _main_thread;
139 bool _timer_thread_exit;
140 pthread_t _timer_thread;
142 bool _audio_thread_exit;
143 pthread_t _audio_thread;
151 EventWithDelay _delayedMouseBtnUpEvent;
152 EventWithDelay _delayedMouseBtnDownEvent;
155 Common::Point _touch_pt_down, _touch_pt_scroll, _touch_pt_dt, _touch_pt_multi;
160 int _trackball_scale;
165 int _secondPointerId;
179 #if defined(USE_OPENGL) && defined(USE_GLAD) 181 mutable void *_gles2DL;
184 static void *timerThreadFunc(
void *arg);
185 static void *audioThreadFunc(
void *arg);
192 TOUCH_MODE_TOUCHPAD = 0,
193 TOUCH_MODE_MOUSE = 1,
194 TOUCH_MODE_GAMEPAD = 2,
199 SCREEN_ORIENTATION_UNSPECIFIED = 0xffffffff,
200 SCREEN_ORIENTATION_LANDSCAPE = 0,
201 SCREEN_ORIENTATION_PORTRAIT = 1
205 SHOW_ON_SCREEN_NONE = 0,
206 SHOW_ON_SCREEN_MENU = 1,
207 SHOW_ON_SCREEN_INPUT_MODE = 2,
208 SHOW_ON_SCREEN_ALL = 0xffffffff,
224 void pushEvent(
int type,
int arg1,
int arg2,
int arg3,
int arg4,
int arg5,
int arg6);
227 void pushDelayedTouchMouseBtnEvents();
230 void applyTouchSettings(
bool _3dMode,
bool overlayShown);
231 void setupTouchMode(
int oldValue,
int newValue);
233 void applyOrientationSettings();
235 void updateOnScreenControls();
249 uint32
getMillis(
bool skipRecord =
false)
override;
253 void quit()
override;
273 OpenGL::ContextType
getOpenGLType()
const override {
return OpenGL::kContextGLES2; }
274 #if defined(USE_OPENGL) && defined(USE_GLAD) 275 void *getOpenGLProcAddress(
const char *name)
const override;
278 #ifdef ANDROID_DEBUG_GL 279 bool isRunningInMainThread() {
return pthread_self() == _main_thread; }
bool setGraphicsMode(int mode, uint flags) override
void delayMillis(uint msecs) override
Definition: modular-backend.h:48
bool hasFeature(OSystem::Feature f) override
int getDefaultGraphicsMode() const 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
bool openUrl(const Common::String &url) override
EventType
Definition: events.h:49
uint32 getMillis(bool skipRecord=false) override
Feature
Definition: system.h:403
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
OpenGL::ContextType getOpenGLType() const override
Definition: android.h:273
Definition: archive.h:312
Common::U32String getTextFromClipboard() override
int getGraphicsMode() const override
virtual const char *const * buildHelpDialogData() override
const OSystem::GraphicsMode * getSupportedGraphicsModes() const 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
bool hasTextInClipboard() override
GUI::OptionsContainerWidget * buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override