// Copyright (C) 2002-2011 Nikolaus Gebhardt // Copyright (C) 2016-2017 Dawid Gan // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h #ifndef __C_IRR_DEVICE_ANDROID_H_INCLUDED__ #define __C_IRR_DEVICE_ANDROID_H_INCLUDED__ #include "IrrCompileConfig.h" #ifdef _IRR_COMPILE_WITH_ANDROID_DEVICE_ #include #include #include #include "CIrrDeviceStub.h" #include "IrrlichtDevice.h" #include "IImagePresenter.h" #include "ICursorControl.h" namespace irr { class CIrrDeviceAndroid : public CIrrDeviceStub, video::IImagePresenter { public: //! constructor CIrrDeviceAndroid(const SIrrlichtCreationParameters& param); //! destructor virtual ~CIrrDeviceAndroid(); virtual bool run(); virtual void yield(); virtual void sleep(u32 timeMs, bool pauseTimer=false); virtual void setWindowCaption(const wchar_t* text); virtual void setWindowClass(const char* text) {} virtual bool present(video::IImage* surface, void* windowId, core::rect* srcClip); virtual bool isWindowActive() const; virtual bool isWindowFocused() const; virtual bool isWindowMinimized() const; virtual void closeDevice(); virtual void setResizable( bool resize=false ); virtual void minimizeWindow(); virtual void maximizeWindow(); virtual void restoreWindow(); virtual E_DEVICE_TYPE getType() const; virtual bool activateAccelerometer(float updateInterval); virtual bool deactivateAccelerometer(); virtual bool isAccelerometerActive(); virtual bool isAccelerometerAvailable(); virtual bool activateGyroscope(float updateInterval); virtual bool deactivateGyroscope(); virtual bool isGyroscopeActive(); virtual bool isGyroscopeAvailable(); class CCursorControl : public gui::ICursorControl { public: CCursorControl() : CursorPos(core::position2d(0, 0)) {} virtual void setVisible(bool visible) {} virtual bool isVisible() const {return false;} virtual void setPosition(const core::position2d &pos) { setPosition(pos.X, pos.Y); } virtual void setPosition(f32 x, f32 y) { CursorPos.X = x; CursorPos.Y = y; } virtual void setPosition(const core::position2d &pos) { setPosition(pos.X, pos.Y); } virtual void setPosition(s32 x, s32 y) { CursorPos.X = x; CursorPos.Y = y; } virtual const core::position2d& getPosition() { return CursorPos; } virtual core::position2d getRelativePosition() { return core::position2d(0, 0); } virtual void setReferenceRect(core::rect* rect=0) {} private: core::position2d CursorPos; }; private: android_app* Android; ASensorManager* SensorManager; ASensorEventQueue* SensorEventQueue; const ASensor* Accelerometer; const ASensor* Gyroscope; static bool IsPaused; static bool IsFocused; static bool IsStarted; static bool IsClosing; bool IsMousePressed; video::SExposedVideoData ExposedVideoData; core::array KeyMap; void createDriver(); void createKeyMap(); void createVideoModeList(); void getKeyChar(SEvent& event); video::SExposedVideoData& getExposedVideoData(); static void handleAndroidCommand(android_app* app, int32_t cmd); static s32 handleInput(android_app* app, AInputEvent* event); }; } // end namespace irr #endif // _IRR_COMPILE_WITH_ANDROID_DEVICE_ #endif // __C_IRR_DEVICE_ANDROID_H_INCLUDED__