diff --git a/android/generate_assets.sh b/android/generate_assets.sh
index e759724d7..5225867e6 100755
--- a/android/generate_assets.sh
+++ b/android/generate_assets.sh
@@ -43,7 +43,8 @@ export RUN_OPTIMIZE_SCRIPT=0
export DECREASE_QUALITY=1
export CONVERT_TO_JPG=1
-export CONVERT_TO_JPG_BLACKLIST="data/karts/hexley/hexley_kart_diffuse.png"
+export CONVERT_TO_JPG_BLACKLIST="data/karts/hexley/hexley_kart_diffuse.png \
+ data/models/traffic_light.png"
export BLACKLIST_FILES="data/music/cocoa_river_fast.ogg2"
diff --git a/data/gui/init_android.stkgui b/data/gui/init_android.stkgui
new file mode 100644
index 000000000..c8b8cb1db
--- /dev/null
+++ b/data/gui/init_android.stkgui
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/data/gui/multitouch_settings.stkgui b/data/gui/multitouch_settings.stkgui
index 9704560a9..5c32cc738 100644
--- a/data/gui/multitouch_settings.stkgui
+++ b/data/gui/multitouch_settings.stkgui
@@ -35,7 +35,7 @@
-
+
diff --git a/data/shaders/sp_dynamic_night_bloom.frag b/data/shaders/sp_dynamic_night_bloom.frag
new file mode 100644
index 000000000..27b006fc1
--- /dev/null
+++ b/data/shaders/sp_dynamic_night_bloom.frag
@@ -0,0 +1,56 @@
+in vec3 bitangent;
+in vec4 color;
+in float hue_change;
+in vec3 normal;
+in vec3 tangent;
+in vec2 uv;
+uniform int is_during_day;
+
+layout(location = 0) out vec4 o_diffuse_color;
+layout(location = 1) out vec4 o_normal_color;
+
+#stk_include "utils/encode_normal.frag"
+#stk_include "utils/rgb_conversion.frag"
+#stk_include "utils/sp_texture_sampling.frag"
+
+void main()
+{
+ vec4 col = sampleTextureLayer0(uv);
+ if (hue_change > 0.0)
+ {
+ float mask = col.a;
+ vec3 old_hsv = rgbToHsv(col.rgb);
+ float mask_step = step(mask, 0.5);
+#if !defined(Advanced_Lighting_Enabled)
+ // For similar color
+ float saturation = mask * 1.825; // 2.5 * 0.5 ^ (1. / 2.2)
+#else
+ float saturation = mask * 2.5;
+#endif
+ vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(hue_change,
+ max(old_hsv.y, saturation)), vec2(mask_step, mask_step));
+ vec3 new_color = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
+ col = vec4(new_color.r, new_color.g, new_color.b, 1.0);
+ }
+
+ vec3 final_color = col.xyz * color.xyz;
+
+#if defined(Advanced_Lighting_Enabled)
+ vec4 layer_2 = sampleTextureLayer2(uv);
+ vec4 layer_3 = sampleTextureLayer3(uv);
+ o_diffuse_color = vec4(final_color, layer_2.z * (1.0f - float(is_during_day)));
+
+ vec3 tangent_space_normal = 2.0 * layer_3.xyz - 1.0;
+ vec3 frag_tangent = normalize(tangent);
+ vec3 frag_bitangent = normalize(bitangent);
+ vec3 frag_normal = normalize(normal);
+ mat3 t_b_n = mat3(frag_tangent, frag_bitangent, frag_normal);
+
+ vec3 world_normal = t_b_n * tangent_space_normal;
+
+ o_normal_color.xy = 0.5 * EncodeNormal(normalize(world_normal)) + 0.5;
+ o_normal_color.zw = layer_2.xy;
+#else
+ o_diffuse_color = vec4(final_color, 1.0);
+#endif
+}
diff --git a/data/shaders/sps_9_dynamicNightBloom.xml b/data/shaders/sps_9_dynamicNightBloom.xml
new file mode 100644
index 000000000..fa38286ba
--- /dev/null
+++ b/data/shaders/sps_9_dynamicNightBloom.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/irrlicht/include/Keycodes.h b/lib/irrlicht/include/Keycodes.h
index 568451baf..5b2f36afa 100644
--- a/lib/irrlicht/include/Keycodes.h
+++ b/lib/irrlicht/include/Keycodes.h
@@ -179,7 +179,27 @@ namespace irr
IRR_KEY_PA1 = 0xFD, // PA1 key
IRR_KEY_OEM_CLEAR = 0xFE, // Clear key
- IRR_KEY_CODES_COUNT = 0xFF // this is not a key, but the amount of keycodes there are.
+ IRR_KEY_BUTTON_LEFT = 0x100,
+ IRR_KEY_BUTTON_RIGHT = 0x101,
+ IRR_KEY_BUTTON_UP = 0x102,
+ IRR_KEY_BUTTON_DOWN = 0x103,
+ IRR_KEY_BUTTON_A = 0x104,
+ IRR_KEY_BUTTON_B = 0x105,
+ IRR_KEY_BUTTON_C = 0x106,
+ IRR_KEY_BUTTON_X = 0x107,
+ IRR_KEY_BUTTON_Y = 0x108,
+ IRR_KEY_BUTTON_Z = 0x109,
+ IRR_KEY_BUTTON_L1 = 0x10A,
+ IRR_KEY_BUTTON_R1 = 0x10B,
+ IRR_KEY_BUTTON_L2 = 0x10C,
+ IRR_KEY_BUTTON_R2 = 0x10D,
+ IRR_KEY_BUTTON_THUMBL = 0x10E,
+ IRR_KEY_BUTTON_THUMBR = 0x10F,
+ IRR_KEY_BUTTON_START = 0x110,
+ IRR_KEY_BUTTON_SELECT = 0x111,
+ IRR_KEY_BUTTON_MODE = 0x112,
+
+ IRR_KEY_CODES_COUNT = 0x113 // this is not a key, but the amount of keycodes there are.
};
} // end namespace irr
diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.cpp b/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.cpp
index e8277aec4..f717129ee 100644
--- a/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.cpp
+++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.cpp
@@ -16,11 +16,11 @@
namespace irr
{
- namespace video
- {
- IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params,
- video::SExposedVideoData& data, io::IFileSystem* io);
- }
+ namespace video
+ {
+ IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params,
+ video::SExposedVideoData& data, io::IFileSystem* io);
+ }
}
namespace irr
@@ -38,249 +38,266 @@ bool CIrrDeviceAndroid::IsStarted = false;
// have their default values on startup.
void CIrrDeviceAndroid::onCreate()
{
- IsPaused = true;
- IsFocused = false;
- IsStarted = false;
+ IsPaused = true;
+ IsFocused = false;
+ IsStarted = false;
}
//! constructor
CIrrDeviceAndroid::CIrrDeviceAndroid(const SIrrlichtCreationParameters& param)
- : CIrrDeviceStub(param),
- Accelerometer(0),
- Gyroscope(0),
- IsMousePressed(false),
- GamepadAxisX(0),
- GamepadAxisY(0)
+ : CIrrDeviceStub(param),
+ Accelerometer(0),
+ Gyroscope(0),
+ IsMousePressed(false),
+ GamepadAxisX(0),
+ GamepadAxisY(0),
+ DefaultOrientation(ORIENTATION_UNKNOWN)
{
- #ifdef _DEBUG
- setDebugName("CIrrDeviceAndroid");
- #endif
+ #ifdef _DEBUG
+ setDebugName("CIrrDeviceAndroid");
+ #endif
- Android = (android_app *)(param.PrivateData);
- assert(Android != NULL);
+ Android = (android_app *)(param.PrivateData);
+ assert(Android != NULL);
- Android->userData = this;
- Android->onAppCmd = handleAndroidCommand;
- Android->onInputEvent = handleInput;
-
- printConfig();
- createKeyMap();
+ Android->userData = this;
+ Android->onAppCmd = handleAndroidCommand;
+ Android->onInputEvent = handleInput;
+
+ printConfig();
+ createKeyMap();
- CursorControl = new CCursorControl();
-
- Close = Android->destroyRequested;
+ CursorControl = new CCursorControl();
+
+ Close = Android->destroyRequested;
- // It typically shouldn't happen, but just in case...
- if (Close)
- return;
+ // It typically shouldn't happen, but just in case...
+ if (Close)
+ return;
- SensorManager = ASensorManager_getInstance();
- SensorEventQueue = ASensorManager_createEventQueue(SensorManager,
- Android->looper, LOOPER_ID_USER, NULL, NULL);
+ SensorManager = ASensorManager_getInstance();
+ SensorEventQueue = ASensorManager_createEventQueue(SensorManager,
+ Android->looper, LOOPER_ID_USER, NULL, NULL);
- ANativeActivity_setWindowFlags(Android->activity,
- AWINDOW_FLAG_KEEP_SCREEN_ON |
- AWINDOW_FLAG_FULLSCREEN, 0);
+ ANativeActivity_setWindowFlags(Android->activity,
+ AWINDOW_FLAG_KEEP_SCREEN_ON |
+ AWINDOW_FLAG_FULLSCREEN, 0);
- os::Printer::log("Waiting for Android activity window to be created.", ELL_DEBUG);
+ os::Printer::log("Waiting for Android activity window to be created.", ELL_DEBUG);
- while (!IsStarted || !IsFocused || IsPaused)
- {
- s32 events = 0;
- android_poll_source* source = 0;
+ while (!IsStarted || !IsFocused || IsPaused)
+ {
+ s32 events = 0;
+ android_poll_source* source = 0;
- s32 id = ALooper_pollAll(-1, NULL, &events, (void**)&source);
+ s32 id = ALooper_pollAll(-1, NULL, &events, (void**)&source);
- if (id >=0 && source != NULL)
- {
- source->process(Android, source);
- }
- }
-
- assert(Android->window);
- os::Printer::log("Done", ELL_DEBUG);
-
- ExposedVideoData.OGLESAndroid.Window = Android->window;
+ if (id >=0 && source != NULL)
+ {
+ source->process(Android, source);
+ }
+ }
+
+ assert(Android->window);
+ os::Printer::log("Done", ELL_DEBUG);
+
+ ExposedVideoData.OGLESAndroid.Window = Android->window;
- createVideoModeList();
+ createVideoModeList();
- createDriver();
+ createDriver();
- if (VideoDriver)
- createGUIAndScene();
+ if (VideoDriver)
+ createGUIAndScene();
}
CIrrDeviceAndroid::~CIrrDeviceAndroid()
{
- Android->userData = NULL;
- Android->onAppCmd = NULL;
- Android->onInputEvent = NULL;
+ Android->userData = NULL;
+ Android->onAppCmd = NULL;
+ Android->onInputEvent = NULL;
}
void CIrrDeviceAndroid::printConfig()
{
- char language[3] = {};
- char country[3] = {};
- AConfiguration_getLanguage(Android->config, language);
- AConfiguration_getCountry(Android->config, country);
- int32_t mcc = AConfiguration_getMcc(Android->config);
- int32_t mnc = AConfiguration_getMnc(Android->config);
- int32_t orientation = AConfiguration_getOrientation(Android->config);
- int32_t touch = AConfiguration_getTouchscreen(Android->config);
- int32_t density = AConfiguration_getDensity(Android->config);
- int32_t keyboard = AConfiguration_getKeyboard(Android->config);
- int32_t navigation = AConfiguration_getNavigation(Android->config);
- int32_t keys_hidden = AConfiguration_getKeysHidden(Android->config);
- int32_t nav_hidden = AConfiguration_getNavHidden(Android->config);
- int32_t sdk_version = AConfiguration_getSdkVersion(Android->config);
- int32_t screen_size = AConfiguration_getScreenSize(Android->config);
- int32_t screen_long = AConfiguration_getScreenLong(Android->config);
- int32_t ui_mode_type = AConfiguration_getUiModeType(Android->config);
- int32_t ui_mode_night = AConfiguration_getUiModeNight(Android->config);
+ char language[3] = {};
+ char country[3] = {};
+ AConfiguration_getLanguage(Android->config, language);
+ AConfiguration_getCountry(Android->config, country);
+ int32_t mcc = AConfiguration_getMcc(Android->config);
+ int32_t mnc = AConfiguration_getMnc(Android->config);
+ int32_t orientation = AConfiguration_getOrientation(Android->config);
+ int32_t touch = AConfiguration_getTouchscreen(Android->config);
+ int32_t density = AConfiguration_getDensity(Android->config);
+ int32_t keyboard = AConfiguration_getKeyboard(Android->config);
+ int32_t navigation = AConfiguration_getNavigation(Android->config);
+ int32_t keys_hidden = AConfiguration_getKeysHidden(Android->config);
+ int32_t nav_hidden = AConfiguration_getNavHidden(Android->config);
+ int32_t sdk_version = AConfiguration_getSdkVersion(Android->config);
+ int32_t screen_size = AConfiguration_getScreenSize(Android->config);
+ int32_t screen_long = AConfiguration_getScreenLong(Android->config);
+ int32_t ui_mode_type = AConfiguration_getUiModeType(Android->config);
+ int32_t ui_mode_night = AConfiguration_getUiModeNight(Android->config);
- os::Printer::log("Android configuration: ", ELL_DEBUG);
- os::Printer::log(" country:", country != NULL ? country : "unknown", ELL_DEBUG);
- os::Printer::log(" density:", core::stringc(density).c_str(), ELL_DEBUG);
- os::Printer::log(" keyboard:", core::stringc(keyboard).c_str(), ELL_DEBUG);
- os::Printer::log(" keys_hidden:", core::stringc(keys_hidden).c_str(), ELL_DEBUG);
- os::Printer::log(" language:", language != NULL ? language : "unknown", ELL_DEBUG);
- os::Printer::log(" mcc:", core::stringc(mcc).c_str(), ELL_DEBUG);
- os::Printer::log(" mnc:", core::stringc(mnc).c_str(), ELL_DEBUG);
- os::Printer::log(" nav_hidden:", core::stringc(nav_hidden).c_str(), ELL_DEBUG);
- os::Printer::log(" navigation:", core::stringc(navigation).c_str(), ELL_DEBUG);
- os::Printer::log(" orientation:", core::stringc(orientation).c_str(), ELL_DEBUG);
- os::Printer::log(" screen_long:", core::stringc(screen_long).c_str(), ELL_DEBUG);
- os::Printer::log(" screen_size:", core::stringc(screen_size).c_str(), ELL_DEBUG);
- os::Printer::log(" sdk_version:", core::stringc(sdk_version).c_str(), ELL_DEBUG);
- os::Printer::log(" touch:", core::stringc(touch).c_str(), ELL_DEBUG);
- os::Printer::log(" ui_mode_type:", core::stringc(ui_mode_type).c_str(), ELL_DEBUG);
- os::Printer::log(" ui_mode_night:", core::stringc(ui_mode_night).c_str(), ELL_DEBUG);
+ os::Printer::log("Android configuration: ", ELL_DEBUG);
+ os::Printer::log(" country:", country != NULL ? country : "unknown", ELL_DEBUG);
+ os::Printer::log(" density:", core::stringc(density).c_str(), ELL_DEBUG);
+ os::Printer::log(" keyboard:", core::stringc(keyboard).c_str(), ELL_DEBUG);
+ os::Printer::log(" keys_hidden:", core::stringc(keys_hidden).c_str(), ELL_DEBUG);
+ os::Printer::log(" language:", language != NULL ? language : "unknown", ELL_DEBUG);
+ os::Printer::log(" mcc:", core::stringc(mcc).c_str(), ELL_DEBUG);
+ os::Printer::log(" mnc:", core::stringc(mnc).c_str(), ELL_DEBUG);
+ os::Printer::log(" nav_hidden:", core::stringc(nav_hidden).c_str(), ELL_DEBUG);
+ os::Printer::log(" navigation:", core::stringc(navigation).c_str(), ELL_DEBUG);
+ os::Printer::log(" orientation:", core::stringc(orientation).c_str(), ELL_DEBUG);
+ os::Printer::log(" screen_long:", core::stringc(screen_long).c_str(), ELL_DEBUG);
+ os::Printer::log(" screen_size:", core::stringc(screen_size).c_str(), ELL_DEBUG);
+ os::Printer::log(" sdk_version:", core::stringc(sdk_version).c_str(), ELL_DEBUG);
+ os::Printer::log(" touch:", core::stringc(touch).c_str(), ELL_DEBUG);
+ os::Printer::log(" ui_mode_type:", core::stringc(ui_mode_type).c_str(), ELL_DEBUG);
+ os::Printer::log(" ui_mode_night:", core::stringc(ui_mode_night).c_str(), ELL_DEBUG);
}
void CIrrDeviceAndroid::createVideoModeList()
{
- if (VideoModeList.getVideoModeCount() > 0)
- return;
-
- int width = ANativeWindow_getWidth(Android->window);
- int height = ANativeWindow_getHeight(Android->window);
-
- if (width > 0 && height > 0)
- {
- CreationParams.WindowSize.Width = width;
- CreationParams.WindowSize.Height = height;
- }
+ if (VideoModeList.getVideoModeCount() > 0)
+ return;
+
+ int width = ANativeWindow_getWidth(Android->window);
+ int height = ANativeWindow_getHeight(Android->window);
+
+ if (width > 0 && height > 0)
+ {
+ CreationParams.WindowSize.Width = width;
+ CreationParams.WindowSize.Height = height;
+ }
- core::dimension2d size = core::dimension2d(
- CreationParams.WindowSize.Width,
- CreationParams.WindowSize.Height);
+ core::dimension2d size = core::dimension2d(
+ CreationParams.WindowSize.Width,
+ CreationParams.WindowSize.Height);
- VideoModeList.addMode(size, 32);
- VideoModeList.setDesktop(32, size);
+ VideoModeList.addMode(size, 32);
+ VideoModeList.setDesktop(32, size);
}
void CIrrDeviceAndroid::createDriver()
{
- // Create the driver.
- switch(CreationParams.DriverType)
- {
- case video::EDT_OGLES2:
- #ifdef _IRR_COMPILE_WITH_OGLES2_
- VideoDriver = video::createOGLES2Driver(CreationParams, ExposedVideoData, FileSystem);
- #else
- os::Printer::log("No OpenGL ES 2.0 support compiled in.", ELL_ERROR);
- #endif
- break;
+ // Create the driver.
+ switch(CreationParams.DriverType)
+ {
+ case video::EDT_OGLES2:
+ #ifdef _IRR_COMPILE_WITH_OGLES2_
+ VideoDriver = video::createOGLES2Driver(CreationParams, ExposedVideoData, FileSystem);
+ #else
+ os::Printer::log("No OpenGL ES 2.0 support compiled in.", ELL_ERROR);
+ #endif
+ break;
- case video::EDT_NULL:
- VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
- break;
+ case video::EDT_NULL:
+ VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
+ break;
- default:
- os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR);
- break;
- }
+ default:
+ os::Printer::log("Unable to create video driver of unknown type.", ELL_ERROR);
+ break;
+ }
}
bool CIrrDeviceAndroid::run()
{
- os::Timer::tick();
-
- while (!Close)
- {
- s32 Events = 0;
- android_poll_source* Source = 0;
- bool should_run = (IsStarted && IsFocused && !IsPaused);
- s32 id = ALooper_pollAll(should_run ? 0 : -1, NULL, &Events,
- (void**)&Source);
+ os::Timer::tick();
+
+ while (!Close)
+ {
+ s32 Events = 0;
+ android_poll_source* Source = 0;
+ bool should_run = (IsStarted && IsFocused && !IsPaused);
+ s32 id = ALooper_pollAll(should_run ? 0 : -1, NULL, &Events,
+ (void**)&Source);
- if (id < 0)
- break;
+ if (id < 0)
+ break;
- if (Source)
- {
- Source->process(Android, Source);
- }
+ if (Source)
+ {
+ Source->process(Android, Source);
+ }
- // if a sensor has data, we'll process it now.
- if (id == LOOPER_ID_USER)
- {
- ASensorEvent event;
- while (ASensorEventQueue_getEvents(SensorEventQueue, &event, 1) > 0)
- {
- switch (event.type)
- {
- case ASENSOR_TYPE_ACCELEROMETER:
- SEvent accEvent;
- accEvent.EventType = EET_ACCELEROMETER_EVENT;
- accEvent.AccelerometerEvent.X = event.acceleration.x;
- accEvent.AccelerometerEvent.Y = event.acceleration.y;
- accEvent.AccelerometerEvent.Z = event.acceleration.z;
+ // if a sensor has data, we'll process it now.
+ if (id == LOOPER_ID_USER)
+ {
+ ASensorEvent event;
+ while (ASensorEventQueue_getEvents(SensorEventQueue, &event, 1) > 0)
+ {
+ switch (event.type)
+ {
+ case ASENSOR_TYPE_ACCELEROMETER:
+ SEvent accEvent;
+ accEvent.EventType = EET_ACCELEROMETER_EVENT;
+
+ if (DefaultOrientation == ORIENTATION_LANDSCAPE)
+ {
+ accEvent.AccelerometerEvent.X = event.acceleration.y;
+ accEvent.AccelerometerEvent.Y = -event.acceleration.x;
+ }
+ else
+ {
+ accEvent.AccelerometerEvent.X = event.acceleration.x;
+ accEvent.AccelerometerEvent.Y = event.acceleration.y;
+ }
+ accEvent.AccelerometerEvent.Z = event.acceleration.z;
+
+ if (accEvent.AccelerometerEvent.X < 0)
+ {
+ accEvent.AccelerometerEvent.X *= -1;
+ accEvent.AccelerometerEvent.Y *= -1;
+ accEvent.AccelerometerEvent.Z *= -1;
+ }
- postEventFromUser(accEvent);
- break;
+ postEventFromUser(accEvent);
+ break;
- case ASENSOR_TYPE_GYROSCOPE:
- SEvent gyroEvent;
- gyroEvent.EventType = EET_GYROSCOPE_EVENT;
- gyroEvent.GyroscopeEvent.X = event.vector.x;
- gyroEvent.GyroscopeEvent.Y = event.vector.y;
- gyroEvent.GyroscopeEvent.Z = event.vector.z;
+ case ASENSOR_TYPE_GYROSCOPE:
+ SEvent gyroEvent;
+ gyroEvent.EventType = EET_GYROSCOPE_EVENT;
+ gyroEvent.GyroscopeEvent.X = event.vector.x;
+ gyroEvent.GyroscopeEvent.Y = event.vector.y;
+ gyroEvent.GyroscopeEvent.Z = event.vector.z;
- postEventFromUser(gyroEvent);
- break;
- default:
- break;
- }
- }
- }
- }
+ postEventFromUser(gyroEvent);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
- return !Close;
+ return !Close;
}
void CIrrDeviceAndroid::yield()
{
- struct timespec ts = {0,1};
- nanosleep(&ts, NULL);
+ struct timespec ts = {0,1};
+ nanosleep(&ts, NULL);
}
void CIrrDeviceAndroid::sleep(u32 timeMs, bool pauseTimer)
{
- const bool wasStopped = Timer ? Timer->isStopped() : true;
+ const bool wasStopped = Timer ? Timer->isStopped() : true;
- struct timespec ts;
- ts.tv_sec = (time_t) (timeMs / 1000);
- ts.tv_nsec = (long) (timeMs % 1000) * 1000000;
+ struct timespec ts;
+ ts.tv_sec = (time_t) (timeMs / 1000);
+ ts.tv_nsec = (long) (timeMs % 1000) * 1000000;
- if (pauseTimer && !wasStopped)
- Timer->stop();
+ if (pauseTimer && !wasStopped)
+ Timer->stop();
- nanosleep(&ts, NULL);
+ nanosleep(&ts, NULL);
- if (pauseTimer && !wasStopped)
- Timer->start();
+ if (pauseTimer && !wasStopped)
+ Timer->start();
}
void CIrrDeviceAndroid::setWindowCaption(const wchar_t* text)
@@ -288,29 +305,29 @@ void CIrrDeviceAndroid::setWindowCaption(const wchar_t* text)
}
bool CIrrDeviceAndroid::present(video::IImage* surface, void* windowId,
- core::rect* srcClip)
+ core::rect* srcClip)
{
- return true;
+ return true;
}
bool CIrrDeviceAndroid::isWindowActive() const
{
- return (IsFocused && !IsPaused);
+ return (IsFocused && !IsPaused);
}
bool CIrrDeviceAndroid::isWindowFocused() const
{
- return IsFocused;
+ return IsFocused;
}
bool CIrrDeviceAndroid::isWindowMinimized() const
{
- return IsPaused;
+ return IsPaused;
}
void CIrrDeviceAndroid::closeDevice()
{
- Close = true;
+ Close = true;
}
void CIrrDeviceAndroid::setResizable(bool resize)
@@ -331,864 +348,941 @@ void CIrrDeviceAndroid::restoreWindow()
bool CIrrDeviceAndroid::moveWindow(int x, int y)
{
- return true;
+ return true;
}
bool CIrrDeviceAndroid::getWindowPosition(int* x, int* y)
{
- *x = 0;
- *y = 0;
- return true;
+ *x = 0;
+ *y = 0;
+ return true;
}
E_DEVICE_TYPE CIrrDeviceAndroid::getType() const
{
- return EIDT_ANDROID;
+ return EIDT_ANDROID;
}
void CIrrDeviceAndroid::handleAndroidCommand(android_app* app, int32_t cmd)
{
- CIrrDeviceAndroid* device = (CIrrDeviceAndroid *)app->userData;
- assert(device != NULL);
-
- switch (cmd)
- {
- case APP_CMD_SAVE_STATE:
- os::Printer::log("Android command APP_CMD_SAVE_STATE", ELL_DEBUG);
- break;
- case APP_CMD_INIT_WINDOW:
- os::Printer::log("Android command APP_CMD_INIT_WINDOW", ELL_DEBUG);
-
- device->getExposedVideoData().OGLESAndroid.Window = app->window;
-
- // If the Android app is resumed, we need to re-create EGL surface
- // to allow to draw something on it again.
- if (device->VideoDriver != NULL &&
- device->CreationParams.DriverType == video::EDT_OGLES2)
- {
- video::COGLES2Driver* driver = (video::COGLES2Driver*)(device->VideoDriver);
- driver->getEGLContext()->reloadEGLSurface(app->window);
- }
-
- IsStarted = true;
- break;
- case APP_CMD_TERM_WINDOW:
- os::Printer::log("Android command APP_CMD_TERM_WINDOW", ELL_DEBUG);
- IsStarted = false;
- break;
- case APP_CMD_GAINED_FOCUS:
- os::Printer::log("Android command APP_CMD_GAINED_FOCUS", ELL_DEBUG);
- IsFocused = true;
- break;
- case APP_CMD_LOST_FOCUS:
- os::Printer::log("Android command APP_CMD_LOST_FOCUS", ELL_DEBUG);
- IsFocused = false;
- break;
- case APP_CMD_DESTROY:
- os::Printer::log("Android command APP_CMD_DESTROY", ELL_DEBUG);
- device->Close = true;
- // Make sure that state variables are set to the default state
- // when the app is destroyed
- IsPaused = true;
- IsFocused = false;
- IsStarted = false;
- break;
- case APP_CMD_PAUSE:
- os::Printer::log("Android command APP_CMD_PAUSE", ELL_DEBUG);
- IsPaused = true;
- break;
- case APP_CMD_RESUME:
- os::Printer::log("Android command APP_CMD_RESUME", ELL_DEBUG);
- IsPaused = false;
- break;
- case APP_CMD_START:
- os::Printer::log("Android command APP_CMD_START", ELL_DEBUG);
- break;
- case APP_CMD_STOP:
- os::Printer::log("Android command APP_CMD_STOP", ELL_DEBUG);
- break;
- case APP_CMD_WINDOW_RESIZED:
- os::Printer::log("Android command APP_CMD_WINDOW_RESIZED", ELL_DEBUG);
- break;
- case APP_CMD_CONFIG_CHANGED:
- os::Printer::log("Android command APP_CMD_CONFIG_CHANGED", ELL_DEBUG);
- break;
- case APP_CMD_LOW_MEMORY:
- os::Printer::log("Android command APP_CMD_LOW_MEMORY", ELL_DEBUG);
- break;
- default:
- break;
- }
-
- SEvent event;
- event.EventType = EET_SYSTEM_EVENT;
- event.SystemEvent.EventType = ESET_ANDROID_CMD;
- event.SystemEvent.AndroidCmd.Cmd = cmd;
- device->postEventFromUser(event);
+ CIrrDeviceAndroid* device = (CIrrDeviceAndroid *)app->userData;
+ assert(device != NULL);
+
+ switch (cmd)
+ {
+ case APP_CMD_SAVE_STATE:
+ os::Printer::log("Android command APP_CMD_SAVE_STATE", ELL_DEBUG);
+ break;
+ case APP_CMD_INIT_WINDOW:
+ os::Printer::log("Android command APP_CMD_INIT_WINDOW", ELL_DEBUG);
+
+ device->getExposedVideoData().OGLESAndroid.Window = app->window;
+
+ // If the Android app is resumed, we need to re-create EGL surface
+ // to allow to draw something on it again.
+ if (device->VideoDriver != NULL &&
+ device->CreationParams.DriverType == video::EDT_OGLES2)
+ {
+ video::COGLES2Driver* driver = (video::COGLES2Driver*)(device->VideoDriver);
+ driver->getEGLContext()->reloadEGLSurface(app->window);
+ }
+
+ IsStarted = true;
+ break;
+ case APP_CMD_TERM_WINDOW:
+ os::Printer::log("Android command APP_CMD_TERM_WINDOW", ELL_DEBUG);
+ IsStarted = false;
+ break;
+ case APP_CMD_GAINED_FOCUS:
+ os::Printer::log("Android command APP_CMD_GAINED_FOCUS", ELL_DEBUG);
+ IsFocused = true;
+ break;
+ case APP_CMD_LOST_FOCUS:
+ os::Printer::log("Android command APP_CMD_LOST_FOCUS", ELL_DEBUG);
+ IsFocused = false;
+ break;
+ case APP_CMD_DESTROY:
+ os::Printer::log("Android command APP_CMD_DESTROY", ELL_DEBUG);
+ device->Close = true;
+ // Make sure that state variables are set to the default state
+ // when the app is destroyed
+ IsPaused = true;
+ IsFocused = false;
+ IsStarted = false;
+ break;
+ case APP_CMD_PAUSE:
+ os::Printer::log("Android command APP_CMD_PAUSE", ELL_DEBUG);
+ IsPaused = true;
+ break;
+ case APP_CMD_RESUME:
+ os::Printer::log("Android command APP_CMD_RESUME", ELL_DEBUG);
+ IsPaused = false;
+ break;
+ case APP_CMD_START:
+ os::Printer::log("Android command APP_CMD_START", ELL_DEBUG);
+ break;
+ case APP_CMD_STOP:
+ os::Printer::log("Android command APP_CMD_STOP", ELL_DEBUG);
+ break;
+ case APP_CMD_WINDOW_RESIZED:
+ os::Printer::log("Android command APP_CMD_WINDOW_RESIZED", ELL_DEBUG);
+ break;
+ case APP_CMD_CONFIG_CHANGED:
+ os::Printer::log("Android command APP_CMD_CONFIG_CHANGED", ELL_DEBUG);
+ break;
+ case APP_CMD_LOW_MEMORY:
+ os::Printer::log("Android command APP_CMD_LOW_MEMORY", ELL_DEBUG);
+ break;
+ default:
+ os::Printer::log("Android command: ", core::stringc(cmd).c_str(), ELL_DEBUG);
+ break;
+ }
+
+ SEvent event;
+ event.EventType = EET_SYSTEM_EVENT;
+ event.SystemEvent.EventType = ESET_ANDROID_CMD;
+ event.SystemEvent.AndroidCmd.Cmd = cmd;
+ device->postEventFromUser(event);
}
s32 CIrrDeviceAndroid::handleInput(android_app* app, AInputEvent* androidEvent)
{
- CIrrDeviceAndroid* device = (CIrrDeviceAndroid*)app->userData;
- assert(device != NULL);
-
- s32 status = 0;
-
- int32_t source = AInputEvent_getSource(androidEvent);
- int32_t type = AInputEvent_getType(androidEvent);
-
- if (source == AINPUT_SOURCE_GAMEPAD ||
- source == AINPUT_SOURCE_JOYSTICK ||
- source == AINPUT_SOURCE_DPAD)
- {
- status = device->handleGamepad(androidEvent);
- }
- else
- {
- switch (type)
- {
- case AINPUT_EVENT_TYPE_MOTION:
- {
- status = device->handleTouch(androidEvent);
- break;
- }
- case AINPUT_EVENT_TYPE_KEY:
- {
- status = device->handleKeyboard(androidEvent);
- break;
- }
- default:
- break;
- }
- }
+ CIrrDeviceAndroid* device = (CIrrDeviceAndroid*)app->userData;
+ assert(device != NULL);
+
+ s32 status = 0;
+
+ int32_t source = AInputEvent_getSource(androidEvent);
+ int32_t type = AInputEvent_getType(androidEvent);
+
+ if (source == AINPUT_SOURCE_GAMEPAD ||
+ source == AINPUT_SOURCE_JOYSTICK ||
+ source == AINPUT_SOURCE_DPAD)
+ {
+ status = device->handleGamepad(androidEvent);
+ }
+ else
+ {
+ switch (type)
+ {
+ case AINPUT_EVENT_TYPE_MOTION:
+ {
+ status = device->handleTouch(androidEvent);
+ break;
+ }
+ case AINPUT_EVENT_TYPE_KEY:
+ {
+ status = device->handleKeyboard(androidEvent);
+ break;
+ }
+ default:
+ break;
+ }
+ }
- return status;
+ return status;
}
s32 CIrrDeviceAndroid::handleTouch(AInputEvent* androidEvent)
{
- s32 status = 0;
-
- SEvent event;
- event.EventType = EET_TOUCH_INPUT_EVENT;
+ s32 status = 0;
+
+ SEvent event;
+ event.EventType = EET_TOUCH_INPUT_EVENT;
- s32 eventAction = AMotionEvent_getAction(androidEvent);
+ s32 eventAction = AMotionEvent_getAction(androidEvent);
#if 0
- // Useful for debugging. We might have to pass some of those infos on at some point.
- // but preferably device independent (so iphone can use same irrlicht flags).
- int32_t flags = AMotionEvent_getFlags(androidEvent);
- os::Printer::log("flags: ", core::stringc(flags).c_str(), ELL_DEBUG);
- int32_t metaState = AMotionEvent_getMetaState(androidEvent);
- os::Printer::log("metaState: ", core::stringc(metaState).c_str(), ELL_DEBUG);
- int32_t edgeFlags = AMotionEvent_getEdgeFlags(androidEvent);
- os::Printer::log("edgeFlags: ", core::stringc(flags).c_str(), ELL_DEBUG);
+ // Useful for debugging. We might have to pass some of those infos on at some point.
+ // but preferably device independent (so iphone can use same irrlicht flags).
+ int32_t flags = AMotionEvent_getFlags(androidEvent);
+ os::Printer::log("flags: ", core::stringc(flags).c_str(), ELL_DEBUG);
+ int32_t metaState = AMotionEvent_getMetaState(androidEvent);
+ os::Printer::log("metaState: ", core::stringc(metaState).c_str(), ELL_DEBUG);
+ int32_t edgeFlags = AMotionEvent_getEdgeFlags(androidEvent);
+ os::Printer::log("edgeFlags: ", core::stringc(flags).c_str(), ELL_DEBUG);
#endif
- bool touchReceived = true;
- bool simulate_mouse = false;
- core::position2d mouse_pos = core::position2d(0, 0);
+ bool touchReceived = true;
+ bool simulate_mouse = false;
+ core::position2d mouse_pos = core::position2d(0, 0);
- switch (eventAction & AMOTION_EVENT_ACTION_MASK)
- {
- case AMOTION_EVENT_ACTION_DOWN:
- case AMOTION_EVENT_ACTION_POINTER_DOWN:
- event.TouchInput.Event = ETIE_PRESSED_DOWN;
- break;
- case AMOTION_EVENT_ACTION_MOVE:
- event.TouchInput.Event = ETIE_MOVED;
- break;
- case AMOTION_EVENT_ACTION_UP:
- case AMOTION_EVENT_ACTION_POINTER_UP:
- case AMOTION_EVENT_ACTION_CANCEL:
- event.TouchInput.Event = ETIE_LEFT_UP;
- break;
- default:
- touchReceived = false;
- break;
- }
-
- if (touchReceived)
- {
- s32 count = 1;
- s32 idx = (eventAction & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >>
- AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
-
- // Process all touches for move action.
- if (event.TouchInput.Event == ETIE_MOVED)
- {
- count = AMotionEvent_getPointerCount(androidEvent);
- idx = 0;
- }
+ switch (eventAction & AMOTION_EVENT_ACTION_MASK)
+ {
+ case AMOTION_EVENT_ACTION_DOWN:
+ case AMOTION_EVENT_ACTION_POINTER_DOWN:
+ event.TouchInput.Event = ETIE_PRESSED_DOWN;
+ break;
+ case AMOTION_EVENT_ACTION_MOVE:
+ event.TouchInput.Event = ETIE_MOVED;
+ break;
+ case AMOTION_EVENT_ACTION_UP:
+ case AMOTION_EVENT_ACTION_POINTER_UP:
+ case AMOTION_EVENT_ACTION_CANCEL:
+ event.TouchInput.Event = ETIE_LEFT_UP;
+ break;
+ default:
+ touchReceived = false;
+ break;
+ }
+
+ if (touchReceived)
+ {
+ s32 count = 1;
+ s32 idx = (eventAction & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >>
+ AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
+
+ // Process all touches for move action.
+ if (event.TouchInput.Event == ETIE_MOVED)
+ {
+ count = AMotionEvent_getPointerCount(androidEvent);
+ idx = 0;
+ }
- for (s32 i = 0; i < count; ++i)
- {
- event.TouchInput.ID = AMotionEvent_getPointerId(androidEvent, i + idx);
- event.TouchInput.X = AMotionEvent_getX(androidEvent, i + idx);
- event.TouchInput.Y = AMotionEvent_getY(androidEvent, i + idx);
-
- if (event.TouchInput.ID >= 32)
- continue;
-
- TouchEventData& event_data = TouchEventsData[event.TouchInput.ID];
-
- // Don't send move event when nothing changed
- if (event_data.event == event.TouchInput.Event &&
- event_data.x == event.TouchInput.X &&
- event_data.y == event.TouchInput.Y)
- continue;
-
- event_data.event = event.TouchInput.Event;
- event_data.x = event.TouchInput.X;
- event_data.y = event.TouchInput.Y;
-
- postEventFromUser(event);
-
- if (event.TouchInput.ID == 0)
- {
- simulate_mouse = true;
- mouse_pos.X = event.TouchInput.X;
- mouse_pos.Y = event.TouchInput.Y;
- }
- }
+ for (s32 i = 0; i < count; ++i)
+ {
+ event.TouchInput.ID = AMotionEvent_getPointerId(androidEvent, i + idx);
+ event.TouchInput.X = AMotionEvent_getX(androidEvent, i + idx);
+ event.TouchInput.Y = AMotionEvent_getY(androidEvent, i + idx);
+
+ if (event.TouchInput.ID >= 32)
+ continue;
+
+ TouchEventData& event_data = TouchEventsData[event.TouchInput.ID];
+
+ // Don't send move event when nothing changed
+ if (event_data.event == event.TouchInput.Event &&
+ event_data.x == event.TouchInput.X &&
+ event_data.y == event.TouchInput.Y)
+ continue;
+
+ event_data.event = event.TouchInput.Event;
+ event_data.x = event.TouchInput.X;
+ event_data.y = event.TouchInput.Y;
+
+ postEventFromUser(event);
+
+ if (event.TouchInput.ID == 0)
+ {
+ simulate_mouse = true;
+ mouse_pos.X = event.TouchInput.X;
+ mouse_pos.Y = event.TouchInput.Y;
+ }
+ }
- status = 1;
- }
-
- // Simulate mouse event for first finger on multitouch device.
- // This allows to click on GUI elements.
- if (simulate_mouse)
- {
- CursorControl->setPosition(mouse_pos);
+ status = 1;
+ }
+
+ // Simulate mouse event for first finger on multitouch device.
+ // This allows to click on GUI elements.
+ if (simulate_mouse)
+ {
+ CursorControl->setPosition(mouse_pos);
- SEvent irrevent;
- bool send_event = true;
-
- switch (event.TouchInput.Event)
- {
- case ETIE_PRESSED_DOWN:
- irrevent.MouseInput.Event = EMIE_LMOUSE_PRESSED_DOWN;
- IsMousePressed = true;
- break;
- case ETIE_LEFT_UP:
- irrevent.MouseInput.Event = EMIE_LMOUSE_LEFT_UP;
- IsMousePressed = false;
- break;
- case ETIE_MOVED:
- irrevent.MouseInput.Event = EMIE_MOUSE_MOVED;
- break;
- default:
- send_event = false;
- break;
- }
-
- if (send_event)
- {
- irrevent.MouseInput.Control = false;
- irrevent.MouseInput.Shift = false;
- irrevent.MouseInput.ButtonStates = IsMousePressed ?
- irr::EMBSM_LEFT : 0;
- irrevent.EventType = EET_MOUSE_INPUT_EVENT;
- irrevent.MouseInput.X = mouse_pos.X;
- irrevent.MouseInput.Y = mouse_pos.Y;
+ SEvent irrevent;
+ bool send_event = true;
+
+ switch (event.TouchInput.Event)
+ {
+ case ETIE_PRESSED_DOWN:
+ irrevent.MouseInput.Event = EMIE_LMOUSE_PRESSED_DOWN;
+ IsMousePressed = true;
+ break;
+ case ETIE_LEFT_UP:
+ irrevent.MouseInput.Event = EMIE_LMOUSE_LEFT_UP;
+ IsMousePressed = false;
+ break;
+ case ETIE_MOVED:
+ irrevent.MouseInput.Event = EMIE_MOUSE_MOVED;
+ break;
+ default:
+ send_event = false;
+ break;
+ }
+
+ if (send_event)
+ {
+ irrevent.MouseInput.Control = false;
+ irrevent.MouseInput.Shift = false;
+ irrevent.MouseInput.ButtonStates = IsMousePressed ?
+ irr::EMBSM_LEFT : 0;
+ irrevent.EventType = EET_MOUSE_INPUT_EVENT;
+ irrevent.MouseInput.X = mouse_pos.X;
+ irrevent.MouseInput.Y = mouse_pos.Y;
- postEventFromUser(irrevent);
- }
- }
-
- return status;
+ postEventFromUser(irrevent);
+ }
+ }
+
+ return status;
}
s32 CIrrDeviceAndroid::handleKeyboard(AInputEvent* androidEvent)
{
- s32 status = 0;
+ s32 status = 0;
- bool ignore_event = false;
+ bool ignore_event = false;
- SEvent event;
- event.EventType = EET_KEY_INPUT_EVENT;
- event.KeyInput.Char = 0;
- event.KeyInput.PressedDown = false;
- event.KeyInput.Key = IRR_KEY_UNKNOWN;
+ SEvent event;
+ event.EventType = EET_KEY_INPUT_EVENT;
+ event.KeyInput.Char = 0;
+ event.KeyInput.PressedDown = false;
+ event.KeyInput.Key = IRR_KEY_UNKNOWN;
- int32_t keyCode = AKeyEvent_getKeyCode(androidEvent);
- int32_t keyAction = AKeyEvent_getAction(androidEvent);
- int32_t keyMetaState = AKeyEvent_getMetaState(androidEvent);
- int32_t keyRepeat = AKeyEvent_getRepeatCount(androidEvent);
- int32_t scanCode = AKeyEvent_getScanCode(androidEvent);
-
- if (keyAction == AKEY_EVENT_ACTION_DOWN)
- {
- event.KeyInput.PressedDown = true;
- }
- else if (keyAction == AKEY_EVENT_ACTION_UP)
- {
- event.KeyInput.PressedDown = false;
- }
- else if (keyAction == AKEY_EVENT_ACTION_MULTIPLE)
- {
- // TODO: Multiple duplicate key events have occurred in a row,
- // or a complex string is being delivered. The repeat_count
- // property of the key event contains the number of times the
- // given key code should be executed.
- // I guess this might necessary for more complicated i18n key input,
- // but don't see yet how to handle this correctly.
- }
+ int32_t keyCode = AKeyEvent_getKeyCode(androidEvent);
+ int32_t keyAction = AKeyEvent_getAction(androidEvent);
+ int32_t keyMetaState = AKeyEvent_getMetaState(androidEvent);
+ int32_t keyRepeat = AKeyEvent_getRepeatCount(androidEvent);
+ int32_t scanCode = AKeyEvent_getScanCode(androidEvent);
+
+ if (keyAction == AKEY_EVENT_ACTION_DOWN)
+ {
+ event.KeyInput.PressedDown = true;
+ }
+ else if (keyAction == AKEY_EVENT_ACTION_UP)
+ {
+ event.KeyInput.PressedDown = false;
+ }
+ else if (keyAction == AKEY_EVENT_ACTION_MULTIPLE)
+ {
+ // TODO: Multiple duplicate key events have occurred in a row,
+ // or a complex string is being delivered. The repeat_count
+ // property of the key event contains the number of times the
+ // given key code should be executed.
+ // I guess this might necessary for more complicated i18n key input,
+ // but don't see yet how to handle this correctly.
+ }
- event.KeyInput.Shift = (keyMetaState & AMETA_SHIFT_ON ||
- keyMetaState & AMETA_SHIFT_LEFT_ON ||
- keyMetaState & AMETA_SHIFT_RIGHT_ON);
+ event.KeyInput.Shift = (keyMetaState & AMETA_SHIFT_ON ||
+ keyMetaState & AMETA_SHIFT_LEFT_ON ||
+ keyMetaState & AMETA_SHIFT_RIGHT_ON);
- event.KeyInput.Control = (keyMetaState & AMETA_CTRL_ON ||
- keyMetaState & AMETA_CTRL_LEFT_ON ||
- keyMetaState & AMETA_CTRL_RIGHT_ON);
+ event.KeyInput.Control = (keyMetaState & AMETA_CTRL_ON ||
+ keyMetaState & AMETA_CTRL_LEFT_ON ||
+ keyMetaState & AMETA_CTRL_RIGHT_ON);
- event.KeyInput.SystemKeyCode = (u32)keyCode;
- event.KeyInput.Key = KeyMap[keyCode];
+ event.KeyInput.SystemKeyCode = (u32)keyCode;
+ event.KeyInput.Key = KeyMap[keyCode];
- if (event.KeyInput.Key > 0)
- {
- getKeyChar(event);
- }
-
- // If button doesn't return key code, then at least use device-specific
- // scan code, because it's better than nothing
- if (event.KeyInput.Key == 0)
- {
- event.KeyInput.Key = (EKEY_CODE)scanCode;
- }
+ if (event.KeyInput.Key > 0)
+ {
+ getKeyChar(event);
+ }
+
+ // If button doesn't return key code, then at least use device-specific
+ // scan code, because it's better than nothing
+ if (event.KeyInput.Key == 0)
+ {
+ event.KeyInput.Key = (EKEY_CODE)scanCode;
+ }
- // Handle an event when back button in pressed just like an escape key
- // and also avoid repeating the event to avoid some strange behaviour
- if (event.KeyInput.SystemKeyCode == AKEYCODE_BACK &&
- (event.KeyInput.PressedDown == false || keyRepeat > 0))
- {
- ignore_event = true;
- }
+ // Handle an event when back button in pressed just like an escape key
+ // and also avoid repeating the event to avoid some strange behaviour
+ if (event.KeyInput.SystemKeyCode == AKEYCODE_BACK &&
+ (event.KeyInput.PressedDown == false || keyRepeat > 0))
+ {
+ ignore_event = true;
+ }
- // Mark escape key and gamepad buttons as handled by application to avoid
- // receiving duplicated events
- if (event.KeyInput.SystemKeyCode == AKEYCODE_ESCAPE ||
- event.KeyInput.SystemKeyCode == AKEYCODE_BACK ||
- (event.KeyInput.SystemKeyCode >= AKEYCODE_BUTTON_A &&
- event.KeyInput.SystemKeyCode <= AKEYCODE_BUTTON_MODE))
- {
- status = 1;
- }
+ // Mark escape key and gamepad buttons as handled by application to avoid
+ // receiving duplicated events
+ if (event.KeyInput.SystemKeyCode == AKEYCODE_ESCAPE ||
+ event.KeyInput.SystemKeyCode == AKEYCODE_BACK ||
+ (event.KeyInput.SystemKeyCode >= AKEYCODE_BUTTON_A &&
+ event.KeyInput.SystemKeyCode <= AKEYCODE_BUTTON_MODE))
+ {
+ status = 1;
+ }
- if (!ignore_event)
- {
- postEventFromUser(event);
- }
+ if (!ignore_event)
+ {
+ postEventFromUser(event);
+ }
- return status;
+ return status;
}
s32 CIrrDeviceAndroid::handleGamepad(AInputEvent* androidEvent)
{
- s32 status = 0;
-
- int32_t type = AInputEvent_getType(androidEvent);
-
- switch (type)
- {
- case AINPUT_EVENT_TYPE_MOTION:
- {
- float axis_x = AMotionEvent_getAxisValue(androidEvent,
- AMOTION_EVENT_AXIS_HAT_X, 0);
+ s32 status = 0;
+
+ int32_t type = AInputEvent_getType(androidEvent);
+
+ switch (type)
+ {
+ case AINPUT_EVENT_TYPE_MOTION:
+ {
+ float axis_x = AMotionEvent_getAxisValue(androidEvent,
+ AMOTION_EVENT_AXIS_HAT_X, 0);
- if (axis_x == 0)
- {
- axis_x = AMotionEvent_getAxisValue(androidEvent,
- AMOTION_EVENT_AXIS_X, 0);
- }
-
- if (axis_x == 0)
- {
- axis_x = AMotionEvent_getAxisValue(androidEvent,
- AMOTION_EVENT_AXIS_Z, 0);
- }
+ if (axis_x == 0)
+ {
+ axis_x = AMotionEvent_getAxisValue(androidEvent,
+ AMOTION_EVENT_AXIS_X, 0);
+ }
+
+ if (axis_x == 0)
+ {
+ axis_x = AMotionEvent_getAxisValue(androidEvent,
+ AMOTION_EVENT_AXIS_Z, 0);
+ }
- float axis_y = AMotionEvent_getAxisValue(androidEvent,
- AMOTION_EVENT_AXIS_HAT_Y, 0);
-
- if (axis_y == 0)
- {
- axis_y = AMotionEvent_getAxisValue(androidEvent,
- AMOTION_EVENT_AXIS_Y, 0);
- }
-
- if (axis_y == 0)
- {
- axis_y = AMotionEvent_getAxisValue(androidEvent,
- AMOTION_EVENT_AXIS_RZ, 0);
- }
-
- SEvent event;
- event.EventType = EET_KEY_INPUT_EVENT;
- event.KeyInput.Char = 0;
- event.KeyInput.Shift = false;
- event.KeyInput.Control = false;
- event.KeyInput.SystemKeyCode = 0;
-
- float deadzone = 0.3f;
-
- axis_x = axis_x > deadzone || axis_x < -deadzone ? axis_x : 0;
- axis_y = axis_y > deadzone || axis_y < -deadzone ? axis_y : 0;
-
- if (axis_x != GamepadAxisX)
- {
- if (GamepadAxisX != 0)
- {
- event.KeyInput.PressedDown = false;
- event.KeyInput.Key = GamepadAxisX < 0 ? IRR_KEY_LEFT
- : IRR_KEY_RIGHT;
- postEventFromUser(event);
- }
-
- if (axis_x != 0)
- {
- event.KeyInput.PressedDown = true;
- event.KeyInput.Key = axis_x < 0 ? IRR_KEY_LEFT : IRR_KEY_RIGHT;
- postEventFromUser(event);
- }
-
- GamepadAxisX = axis_x;
- }
-
- if (axis_y != GamepadAxisY)
- {
- if (GamepadAxisY != 0)
- {
- event.KeyInput.PressedDown = false;
- event.KeyInput.Key = GamepadAxisY < 0 ? IRR_KEY_UP
- : IRR_KEY_DOWN;
- postEventFromUser(event);
- }
-
- if (axis_y != 0)
- {
- event.KeyInput.PressedDown = true;
- event.KeyInput.Key = axis_y < 0 ? IRR_KEY_UP : IRR_KEY_DOWN;
- postEventFromUser(event);
- }
-
- GamepadAxisY = axis_y;
- }
-
- status = 1;
+ float axis_y = AMotionEvent_getAxisValue(androidEvent,
+ AMOTION_EVENT_AXIS_HAT_Y, 0);
+
+ if (axis_y == 0)
+ {
+ axis_y = AMotionEvent_getAxisValue(androidEvent,
+ AMOTION_EVENT_AXIS_Y, 0);
+ }
+
+ if (axis_y == 0)
+ {
+ axis_y = AMotionEvent_getAxisValue(androidEvent,
+ AMOTION_EVENT_AXIS_RZ, 0);
+ }
+
+ SEvent event;
+ event.EventType = EET_KEY_INPUT_EVENT;
+ event.KeyInput.Char = 0;
+ event.KeyInput.Shift = false;
+ event.KeyInput.Control = false;
+ event.KeyInput.SystemKeyCode = 0;
+
+ float deadzone = 0.3f;
+
+ axis_x = axis_x > deadzone || axis_x < -deadzone ? axis_x : 0;
+ axis_y = axis_y > deadzone || axis_y < -deadzone ? axis_y : 0;
+
+ if (axis_x != GamepadAxisX)
+ {
+ if (GamepadAxisX != 0)
+ {
+ event.KeyInput.PressedDown = false;
+ event.KeyInput.Key = GamepadAxisX < 0 ? IRR_KEY_BUTTON_LEFT
+ : IRR_KEY_BUTTON_RIGHT;
+ postEventFromUser(event);
+ }
+
+ if (axis_x != 0)
+ {
+ event.KeyInput.PressedDown = true;
+ event.KeyInput.Key = axis_x < 0 ? IRR_KEY_BUTTON_LEFT
+ : IRR_KEY_BUTTON_RIGHT;
+ postEventFromUser(event);
+ }
+
+ GamepadAxisX = axis_x;
+ }
+
+ if (axis_y != GamepadAxisY)
+ {
+ if (GamepadAxisY != 0)
+ {
+ event.KeyInput.PressedDown = false;
+ event.KeyInput.Key = GamepadAxisY < 0 ? IRR_KEY_BUTTON_UP
+ : IRR_KEY_BUTTON_DOWN;
+ postEventFromUser(event);
+ }
+
+ if (axis_y != 0)
+ {
+ event.KeyInput.PressedDown = true;
+ event.KeyInput.Key = axis_y < 0 ? IRR_KEY_BUTTON_UP
+ : IRR_KEY_BUTTON_DOWN;
+ postEventFromUser(event);
+ }
+
+ GamepadAxisY = axis_y;
+ }
+
+ status = 1;
- break;
- }
- case AINPUT_EVENT_TYPE_KEY:
- {
- bool ignore = false;
-
- int32_t keyCode = AKeyEvent_getKeyCode(androidEvent);
- int32_t keyAction = AKeyEvent_getAction(androidEvent);
- int32_t keyRepeat = AKeyEvent_getRepeatCount(androidEvent);
- int32_t scanCode = AKeyEvent_getScanCode(androidEvent);
-
- if (keyRepeat == 0)
- {
- bool ignore_event = false;
-
- SEvent event;
- event.EventType = EET_KEY_INPUT_EVENT;
- event.KeyInput.Char = 0;
- event.KeyInput.PressedDown = (keyAction == AKEY_EVENT_ACTION_DOWN);
- event.KeyInput.Shift = false;
- event.KeyInput.Control = false;
- event.KeyInput.SystemKeyCode = (u32)keyCode;
- event.KeyInput.Key = KeyMap[keyCode];
-
- if (event.KeyInput.Key == 0)
- {
- event.KeyInput.Key = (EKEY_CODE)scanCode;
- }
-
- postEventFromUser(event);
- }
-
- status = 1;
- break;
- }
- default:
- break;
- }
-
- return status;
+ break;
+ }
+ case AINPUT_EVENT_TYPE_KEY:
+ {
+ bool ignore = false;
+
+ int32_t keyCode = AKeyEvent_getKeyCode(androidEvent);
+ int32_t keyAction = AKeyEvent_getAction(androidEvent);
+ int32_t keyRepeat = AKeyEvent_getRepeatCount(androidEvent);
+ int32_t scanCode = AKeyEvent_getScanCode(androidEvent);
+
+ if (keyRepeat == 0)
+ {
+ bool ignore_event = false;
+
+ SEvent event;
+ event.EventType = EET_KEY_INPUT_EVENT;
+ event.KeyInput.Char = 0;
+ event.KeyInput.PressedDown = (keyAction == AKEY_EVENT_ACTION_DOWN);
+ event.KeyInput.Shift = false;
+ event.KeyInput.Control = false;
+ event.KeyInput.SystemKeyCode = (u32)keyCode;
+ event.KeyInput.Key = KeyMap[keyCode];
+
+ if (event.KeyInput.Key == 0)
+ {
+ event.KeyInput.Key = (EKEY_CODE)scanCode;
+ }
+
+ postEventFromUser(event);
+ }
+
+ status = 1;
+ break;
+ }
+ default:
+ break;
+ }
+
+ return status;
}
video::SExposedVideoData& CIrrDeviceAndroid::getExposedVideoData()
{
- return ExposedVideoData;
+ return ExposedVideoData;
}
void CIrrDeviceAndroid::createKeyMap()
{
- KeyMap[AKEYCODE_UNKNOWN] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_SOFT_LEFT] = IRR_KEY_LBUTTON;
- KeyMap[AKEYCODE_SOFT_RIGHT] = IRR_KEY_RBUTTON;
- KeyMap[AKEYCODE_HOME] = IRR_KEY_HOME;
- KeyMap[AKEYCODE_BACK] = IRR_KEY_ESCAPE;
- KeyMap[AKEYCODE_CALL] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_ENDCALL] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_0] = IRR_KEY_0;
- KeyMap[AKEYCODE_1] = IRR_KEY_1;
- KeyMap[AKEYCODE_2] = IRR_KEY_2;
- KeyMap[AKEYCODE_3] = IRR_KEY_3;
- KeyMap[AKEYCODE_4] = IRR_KEY_4;
- KeyMap[AKEYCODE_5] = IRR_KEY_5;
- KeyMap[AKEYCODE_6] = IRR_KEY_6;
- KeyMap[AKEYCODE_7] = IRR_KEY_7;
- KeyMap[AKEYCODE_8] = IRR_KEY_8;
- KeyMap[AKEYCODE_9] = IRR_KEY_9;
- KeyMap[AKEYCODE_STAR] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_POUND] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_DPAD_UP] = IRR_KEY_UP;
- KeyMap[AKEYCODE_DPAD_DOWN] = IRR_KEY_DOWN;
- KeyMap[AKEYCODE_DPAD_LEFT] = IRR_KEY_LEFT;
- KeyMap[AKEYCODE_DPAD_RIGHT] = IRR_KEY_RIGHT;
- KeyMap[AKEYCODE_DPAD_CENTER] = IRR_KEY_RETURN;
- KeyMap[AKEYCODE_VOLUME_UP] = IRR_KEY_VOLUME_DOWN;
- KeyMap[AKEYCODE_VOLUME_DOWN] = IRR_KEY_VOLUME_UP;
- KeyMap[AKEYCODE_POWER] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_CAMERA] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_CLEAR] = IRR_KEY_CLEAR;
- KeyMap[AKEYCODE_A] = IRR_KEY_A;
- KeyMap[AKEYCODE_B] = IRR_KEY_B;
- KeyMap[AKEYCODE_C] = IRR_KEY_C;
- KeyMap[AKEYCODE_D] = IRR_KEY_D;
- KeyMap[AKEYCODE_E] = IRR_KEY_E;
- KeyMap[AKEYCODE_F] = IRR_KEY_F;
- KeyMap[AKEYCODE_G] = IRR_KEY_G;
- KeyMap[AKEYCODE_H] = IRR_KEY_H;
- KeyMap[AKEYCODE_I] = IRR_KEY_I;
- KeyMap[AKEYCODE_J] = IRR_KEY_J;
- KeyMap[AKEYCODE_K] = IRR_KEY_K;
- KeyMap[AKEYCODE_L] = IRR_KEY_L;
- KeyMap[AKEYCODE_M] = IRR_KEY_M;
- KeyMap[AKEYCODE_N] = IRR_KEY_N;
- KeyMap[AKEYCODE_O] = IRR_KEY_O;
- KeyMap[AKEYCODE_P] = IRR_KEY_P;
- KeyMap[AKEYCODE_Q] = IRR_KEY_Q;
- KeyMap[AKEYCODE_R] = IRR_KEY_R;
- KeyMap[AKEYCODE_S] = IRR_KEY_S;
- KeyMap[AKEYCODE_T] = IRR_KEY_T;
- KeyMap[AKEYCODE_U] = IRR_KEY_U;
- KeyMap[AKEYCODE_V] = IRR_KEY_V;
- KeyMap[AKEYCODE_W] = IRR_KEY_W;
- KeyMap[AKEYCODE_X] = IRR_KEY_X;
- KeyMap[AKEYCODE_Y] = IRR_KEY_Y;
- KeyMap[AKEYCODE_Z] = IRR_KEY_Z;
- KeyMap[AKEYCODE_COMMA] = IRR_KEY_COMMA;
- KeyMap[AKEYCODE_PERIOD] = IRR_KEY_PERIOD;
- KeyMap[AKEYCODE_ALT_LEFT] = IRR_KEY_MENU;
- KeyMap[AKEYCODE_ALT_RIGHT] = IRR_KEY_MENU;
- KeyMap[AKEYCODE_SHIFT_LEFT] = IRR_KEY_LSHIFT;
- KeyMap[AKEYCODE_SHIFT_RIGHT] = IRR_KEY_RSHIFT;
- KeyMap[AKEYCODE_TAB] = IRR_KEY_TAB;
- KeyMap[AKEYCODE_SPACE] = IRR_KEY_SPACE;
- KeyMap[AKEYCODE_SYM] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_EXPLORER] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_ENVELOPE] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_ENTER] = IRR_KEY_RETURN;
- KeyMap[AKEYCODE_DEL] = IRR_KEY_BACK;
- KeyMap[AKEYCODE_GRAVE] = IRR_KEY_OEM_3;
- KeyMap[AKEYCODE_MINUS] = IRR_KEY_MINUS;
- KeyMap[AKEYCODE_EQUALS] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_LEFT_BRACKET] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_RIGHT_BRACKET] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BACKSLASH] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_SEMICOLON] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_APOSTROPHE] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_SLASH] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_AT] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_NUM] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_HEADSETHOOK] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_FOCUS] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_PLUS] = IRR_KEY_PLUS;
- KeyMap[AKEYCODE_MENU] = IRR_KEY_MENU;
- KeyMap[AKEYCODE_NOTIFICATION] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_SEARCH] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_MEDIA_PLAY_PAUSE] = IRR_KEY_MEDIA_PLAY_PAUSE;
- KeyMap[AKEYCODE_MEDIA_STOP] = IRR_KEY_MEDIA_STOP;
- KeyMap[AKEYCODE_MEDIA_NEXT] = IRR_KEY_MEDIA_NEXT_TRACK;
- KeyMap[AKEYCODE_MEDIA_PREVIOUS] = IRR_KEY_MEDIA_PREV_TRACK;
- KeyMap[AKEYCODE_MEDIA_REWIND] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_MEDIA_FAST_FORWARD] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_MUTE] = IRR_KEY_VOLUME_MUTE;
- KeyMap[AKEYCODE_PAGE_UP] = IRR_KEY_PRIOR;
- KeyMap[AKEYCODE_PAGE_DOWN] = IRR_KEY_NEXT;
- KeyMap[AKEYCODE_PICTSYMBOLS] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_SWITCH_CHARSET] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_UNKNOWN] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_SOFT_LEFT] = IRR_KEY_LBUTTON;
+ KeyMap[AKEYCODE_SOFT_RIGHT] = IRR_KEY_RBUTTON;
+ KeyMap[AKEYCODE_HOME] = IRR_KEY_HOME;
+ KeyMap[AKEYCODE_BACK] = IRR_KEY_ESCAPE;
+ KeyMap[AKEYCODE_CALL] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_ENDCALL] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_0] = IRR_KEY_0;
+ KeyMap[AKEYCODE_1] = IRR_KEY_1;
+ KeyMap[AKEYCODE_2] = IRR_KEY_2;
+ KeyMap[AKEYCODE_3] = IRR_KEY_3;
+ KeyMap[AKEYCODE_4] = IRR_KEY_4;
+ KeyMap[AKEYCODE_5] = IRR_KEY_5;
+ KeyMap[AKEYCODE_6] = IRR_KEY_6;
+ KeyMap[AKEYCODE_7] = IRR_KEY_7;
+ KeyMap[AKEYCODE_8] = IRR_KEY_8;
+ KeyMap[AKEYCODE_9] = IRR_KEY_9;
+ KeyMap[AKEYCODE_STAR] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_POUND] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_DPAD_UP] = IRR_KEY_UP;
+ KeyMap[AKEYCODE_DPAD_DOWN] = IRR_KEY_DOWN;
+ KeyMap[AKEYCODE_DPAD_LEFT] = IRR_KEY_LEFT;
+ KeyMap[AKEYCODE_DPAD_RIGHT] = IRR_KEY_RIGHT;
+ KeyMap[AKEYCODE_DPAD_CENTER] = IRR_KEY_RETURN;
+ KeyMap[AKEYCODE_VOLUME_UP] = IRR_KEY_VOLUME_DOWN;
+ KeyMap[AKEYCODE_VOLUME_DOWN] = IRR_KEY_VOLUME_UP;
+ KeyMap[AKEYCODE_POWER] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_CAMERA] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_CLEAR] = IRR_KEY_CLEAR;
+ KeyMap[AKEYCODE_A] = IRR_KEY_A;
+ KeyMap[AKEYCODE_B] = IRR_KEY_B;
+ KeyMap[AKEYCODE_C] = IRR_KEY_C;
+ KeyMap[AKEYCODE_D] = IRR_KEY_D;
+ KeyMap[AKEYCODE_E] = IRR_KEY_E;
+ KeyMap[AKEYCODE_F] = IRR_KEY_F;
+ KeyMap[AKEYCODE_G] = IRR_KEY_G;
+ KeyMap[AKEYCODE_H] = IRR_KEY_H;
+ KeyMap[AKEYCODE_I] = IRR_KEY_I;
+ KeyMap[AKEYCODE_J] = IRR_KEY_J;
+ KeyMap[AKEYCODE_K] = IRR_KEY_K;
+ KeyMap[AKEYCODE_L] = IRR_KEY_L;
+ KeyMap[AKEYCODE_M] = IRR_KEY_M;
+ KeyMap[AKEYCODE_N] = IRR_KEY_N;
+ KeyMap[AKEYCODE_O] = IRR_KEY_O;
+ KeyMap[AKEYCODE_P] = IRR_KEY_P;
+ KeyMap[AKEYCODE_Q] = IRR_KEY_Q;
+ KeyMap[AKEYCODE_R] = IRR_KEY_R;
+ KeyMap[AKEYCODE_S] = IRR_KEY_S;
+ KeyMap[AKEYCODE_T] = IRR_KEY_T;
+ KeyMap[AKEYCODE_U] = IRR_KEY_U;
+ KeyMap[AKEYCODE_V] = IRR_KEY_V;
+ KeyMap[AKEYCODE_W] = IRR_KEY_W;
+ KeyMap[AKEYCODE_X] = IRR_KEY_X;
+ KeyMap[AKEYCODE_Y] = IRR_KEY_Y;
+ KeyMap[AKEYCODE_Z] = IRR_KEY_Z;
+ KeyMap[AKEYCODE_COMMA] = IRR_KEY_COMMA;
+ KeyMap[AKEYCODE_PERIOD] = IRR_KEY_PERIOD;
+ KeyMap[AKEYCODE_ALT_LEFT] = IRR_KEY_MENU;
+ KeyMap[AKEYCODE_ALT_RIGHT] = IRR_KEY_MENU;
+ KeyMap[AKEYCODE_SHIFT_LEFT] = IRR_KEY_LSHIFT;
+ KeyMap[AKEYCODE_SHIFT_RIGHT] = IRR_KEY_RSHIFT;
+ KeyMap[AKEYCODE_TAB] = IRR_KEY_TAB;
+ KeyMap[AKEYCODE_SPACE] = IRR_KEY_SPACE;
+ KeyMap[AKEYCODE_SYM] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_EXPLORER] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_ENVELOPE] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_ENTER] = IRR_KEY_RETURN;
+ KeyMap[AKEYCODE_DEL] = IRR_KEY_BACK;
+ KeyMap[AKEYCODE_GRAVE] = IRR_KEY_OEM_3;
+ KeyMap[AKEYCODE_MINUS] = IRR_KEY_MINUS;
+ KeyMap[AKEYCODE_EQUALS] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_LEFT_BRACKET] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_RIGHT_BRACKET] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BACKSLASH] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_SEMICOLON] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_APOSTROPHE] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_SLASH] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_AT] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_NUM] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_HEADSETHOOK] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_FOCUS] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_PLUS] = IRR_KEY_PLUS;
+ KeyMap[AKEYCODE_MENU] = IRR_KEY_MENU;
+ KeyMap[AKEYCODE_NOTIFICATION] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_SEARCH] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_MEDIA_PLAY_PAUSE] = IRR_KEY_MEDIA_PLAY_PAUSE;
+ KeyMap[AKEYCODE_MEDIA_STOP] = IRR_KEY_MEDIA_STOP;
+ KeyMap[AKEYCODE_MEDIA_NEXT] = IRR_KEY_MEDIA_NEXT_TRACK;
+ KeyMap[AKEYCODE_MEDIA_PREVIOUS] = IRR_KEY_MEDIA_PREV_TRACK;
+ KeyMap[AKEYCODE_MEDIA_REWIND] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_MEDIA_FAST_FORWARD] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_MUTE] = IRR_KEY_VOLUME_MUTE;
+ KeyMap[AKEYCODE_PAGE_UP] = IRR_KEY_PRIOR;
+ KeyMap[AKEYCODE_PAGE_DOWN] = IRR_KEY_NEXT;
+ KeyMap[AKEYCODE_PICTSYMBOLS] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_SWITCH_CHARSET] = IRR_KEY_UNKNOWN;
- // following look like controller inputs
- KeyMap[AKEYCODE_BUTTON_A] = IRR_KEY_RETURN;
- KeyMap[AKEYCODE_BUTTON_B] = IRR_KEY_ESCAPE;
- KeyMap[AKEYCODE_BUTTON_C] = IRR_KEY_2;
- KeyMap[AKEYCODE_BUTTON_X] = IRR_KEY_3;
- KeyMap[AKEYCODE_BUTTON_Y] = IRR_KEY_4;
- KeyMap[AKEYCODE_BUTTON_Z] = IRR_KEY_5;
- KeyMap[AKEYCODE_BUTTON_L1] = IRR_KEY_6;
- KeyMap[AKEYCODE_BUTTON_R1] = IRR_KEY_7;
- KeyMap[AKEYCODE_BUTTON_L2] = IRR_KEY_8;
- KeyMap[AKEYCODE_BUTTON_R2] = IRR_KEY_9;
- KeyMap[AKEYCODE_BUTTON_THUMBL] = IRR_KEY_RETURN;
- KeyMap[AKEYCODE_BUTTON_THUMBR] = IRR_KEY_RETURN;
- KeyMap[AKEYCODE_BUTTON_START] = IRR_KEY_RETURN;
- KeyMap[AKEYCODE_BUTTON_SELECT] = IRR_KEY_ESCAPE;
- KeyMap[AKEYCODE_BUTTON_MODE] = IRR_KEY_MENU;
+ // following look like controller inputs
+ KeyMap[AKEYCODE_BUTTON_A] = IRR_KEY_BUTTON_A;
+ KeyMap[AKEYCODE_BUTTON_B] = IRR_KEY_BUTTON_B;
+ KeyMap[AKEYCODE_BUTTON_C] = IRR_KEY_BUTTON_C;
+ KeyMap[AKEYCODE_BUTTON_X] = IRR_KEY_BUTTON_X;
+ KeyMap[AKEYCODE_BUTTON_Y] = IRR_KEY_BUTTON_Y;
+ KeyMap[AKEYCODE_BUTTON_Z] = IRR_KEY_BUTTON_Z;
+ KeyMap[AKEYCODE_BUTTON_L1] = IRR_KEY_BUTTON_L1;
+ KeyMap[AKEYCODE_BUTTON_R1] = IRR_KEY_BUTTON_R1;
+ KeyMap[AKEYCODE_BUTTON_L2] = IRR_KEY_BUTTON_L2;
+ KeyMap[AKEYCODE_BUTTON_R2] = IRR_KEY_BUTTON_R2;
+ KeyMap[AKEYCODE_BUTTON_THUMBL] = IRR_KEY_BUTTON_THUMBL;
+ KeyMap[AKEYCODE_BUTTON_THUMBR] = IRR_KEY_BUTTON_THUMBR;
+ KeyMap[AKEYCODE_BUTTON_START] = IRR_KEY_BUTTON_START;
+ KeyMap[AKEYCODE_BUTTON_SELECT] = IRR_KEY_BUTTON_SELECT;
+ KeyMap[AKEYCODE_BUTTON_MODE] = IRR_KEY_BUTTON_MODE;
- KeyMap[AKEYCODE_ESCAPE] = IRR_KEY_ESCAPE;
- KeyMap[AKEYCODE_FORWARD_DEL] = IRR_KEY_DELETE;
- KeyMap[AKEYCODE_CTRL_LEFT] = IRR_KEY_CONTROL;
- KeyMap[AKEYCODE_CTRL_RIGHT] = IRR_KEY_CONTROL;
- KeyMap[AKEYCODE_CAPS_LOCK] = IRR_KEY_CAPITAL;
- KeyMap[AKEYCODE_SCROLL_LOCK] = IRR_KEY_SCROLL;
- KeyMap[AKEYCODE_META_LEFT] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_META_RIGHT] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_FUNCTION] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_SYSRQ] = IRR_KEY_SNAPSHOT;
- KeyMap[AKEYCODE_BREAK] = IRR_KEY_PAUSE;
- KeyMap[AKEYCODE_MOVE_HOME] = IRR_KEY_HOME;
- KeyMap[AKEYCODE_MOVE_END] = IRR_KEY_END;
- KeyMap[AKEYCODE_INSERT] = IRR_KEY_INSERT;
- KeyMap[AKEYCODE_FORWARD] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_MEDIA_PLAY] = IRR_KEY_PLAY;
- KeyMap[AKEYCODE_MEDIA_PAUSE] = IRR_KEY_MEDIA_PLAY_PAUSE;
- KeyMap[AKEYCODE_MEDIA_CLOSE] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_MEDIA_EJECT] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_MEDIA_RECORD] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_F1] = IRR_KEY_F1;
- KeyMap[AKEYCODE_F2] = IRR_KEY_F2;
- KeyMap[AKEYCODE_F3] = IRR_KEY_F3;
- KeyMap[AKEYCODE_F4] = IRR_KEY_F4;
- KeyMap[AKEYCODE_F5] = IRR_KEY_F5;
- KeyMap[AKEYCODE_F6] = IRR_KEY_F6;
- KeyMap[AKEYCODE_F7] = IRR_KEY_F7;
- KeyMap[AKEYCODE_F8] = IRR_KEY_F8;
- KeyMap[AKEYCODE_F9] = IRR_KEY_F9;
- KeyMap[AKEYCODE_F10] = IRR_KEY_F10;
- KeyMap[AKEYCODE_F11] = IRR_KEY_F11;
- KeyMap[AKEYCODE_F12] = IRR_KEY_F12;
- KeyMap[AKEYCODE_NUM_LOCK] = IRR_KEY_NUMLOCK;
- KeyMap[AKEYCODE_NUMPAD_0] = IRR_KEY_NUMPAD0;
- KeyMap[AKEYCODE_NUMPAD_1] = IRR_KEY_NUMPAD1;
- KeyMap[AKEYCODE_NUMPAD_2] = IRR_KEY_NUMPAD2;
- KeyMap[AKEYCODE_NUMPAD_3] = IRR_KEY_NUMPAD3;
- KeyMap[AKEYCODE_NUMPAD_4] = IRR_KEY_NUMPAD4;
- KeyMap[AKEYCODE_NUMPAD_5] = IRR_KEY_NUMPAD5;
- KeyMap[AKEYCODE_NUMPAD_6] = IRR_KEY_NUMPAD6;
- KeyMap[AKEYCODE_NUMPAD_7] = IRR_KEY_NUMPAD7;
- KeyMap[AKEYCODE_NUMPAD_8] = IRR_KEY_NUMPAD8;
- KeyMap[AKEYCODE_NUMPAD_9] = IRR_KEY_NUMPAD9;
- KeyMap[AKEYCODE_NUMPAD_DIVIDE] = IRR_KEY_DIVIDE;
- KeyMap[AKEYCODE_NUMPAD_MULTIPLY] = IRR_KEY_MULTIPLY;
- KeyMap[AKEYCODE_NUMPAD_SUBTRACT] = IRR_KEY_SUBTRACT;
- KeyMap[AKEYCODE_NUMPAD_ADD] = IRR_KEY_ADD;
- KeyMap[AKEYCODE_NUMPAD_DOT] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_NUMPAD_COMMA] = IRR_KEY_COMMA;
- KeyMap[AKEYCODE_NUMPAD_ENTER] = IRR_KEY_RETURN;
- KeyMap[AKEYCODE_NUMPAD_EQUALS] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_NUMPAD_LEFT_PAREN] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_NUMPAD_RIGHT_PAREN] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_VOLUME_MUTE] = IRR_KEY_VOLUME_MUTE;
- KeyMap[AKEYCODE_INFO] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_CHANNEL_UP] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_CHANNEL_DOWN] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_ZOOM_IN] = IRR_KEY_ZOOM;
- KeyMap[AKEYCODE_ZOOM_OUT] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_TV] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_WINDOW] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_GUIDE] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_DVR] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BOOKMARK] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_CAPTIONS] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_SETTINGS] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_TV_POWER] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_TV_INPUT] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_STB_POWER] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_STB_INPUT] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_AVR_POWER] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_AVR_INPUT] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_PROG_RED] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_PROG_GREEN] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_PROG_YELLOW] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_PROG_BLUE] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_APP_SWITCH] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BUTTON_1] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BUTTON_2] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BUTTON_3] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BUTTON_4] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BUTTON_5] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BUTTON_6] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BUTTON_7] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BUTTON_8] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BUTTON_9] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BUTTON_10] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BUTTON_11] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BUTTON_12] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BUTTON_13] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BUTTON_14] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BUTTON_15] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BUTTON_16] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_LANGUAGE_SWITCH] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_MANNER_MODE] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_3D_MODE] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_CONTACTS] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_CALENDAR] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_MUSIC] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_CALCULATOR] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_ZENKAKU_HANKAKU] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_EISU] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_MUHENKAN] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_HENKAN] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_KATAKANA_HIRAGANA] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_YEN] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_RO] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_KANA] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_ASSIST] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BRIGHTNESS_DOWN] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_BRIGHTNESS_UP] = IRR_KEY_UNKNOWN;
- KeyMap[AKEYCODE_MEDIA_AUDIO_TRACK] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_ESCAPE] = IRR_KEY_ESCAPE;
+ KeyMap[AKEYCODE_FORWARD_DEL] = IRR_KEY_DELETE;
+ KeyMap[AKEYCODE_CTRL_LEFT] = IRR_KEY_CONTROL;
+ KeyMap[AKEYCODE_CTRL_RIGHT] = IRR_KEY_CONTROL;
+ KeyMap[AKEYCODE_CAPS_LOCK] = IRR_KEY_CAPITAL;
+ KeyMap[AKEYCODE_SCROLL_LOCK] = IRR_KEY_SCROLL;
+ KeyMap[AKEYCODE_META_LEFT] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_META_RIGHT] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_FUNCTION] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_SYSRQ] = IRR_KEY_SNAPSHOT;
+ KeyMap[AKEYCODE_BREAK] = IRR_KEY_PAUSE;
+ KeyMap[AKEYCODE_MOVE_HOME] = IRR_KEY_HOME;
+ KeyMap[AKEYCODE_MOVE_END] = IRR_KEY_END;
+ KeyMap[AKEYCODE_INSERT] = IRR_KEY_INSERT;
+ KeyMap[AKEYCODE_FORWARD] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_MEDIA_PLAY] = IRR_KEY_PLAY;
+ KeyMap[AKEYCODE_MEDIA_PAUSE] = IRR_KEY_MEDIA_PLAY_PAUSE;
+ KeyMap[AKEYCODE_MEDIA_CLOSE] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_MEDIA_EJECT] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_MEDIA_RECORD] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_F1] = IRR_KEY_F1;
+ KeyMap[AKEYCODE_F2] = IRR_KEY_F2;
+ KeyMap[AKEYCODE_F3] = IRR_KEY_F3;
+ KeyMap[AKEYCODE_F4] = IRR_KEY_F4;
+ KeyMap[AKEYCODE_F5] = IRR_KEY_F5;
+ KeyMap[AKEYCODE_F6] = IRR_KEY_F6;
+ KeyMap[AKEYCODE_F7] = IRR_KEY_F7;
+ KeyMap[AKEYCODE_F8] = IRR_KEY_F8;
+ KeyMap[AKEYCODE_F9] = IRR_KEY_F9;
+ KeyMap[AKEYCODE_F10] = IRR_KEY_F10;
+ KeyMap[AKEYCODE_F11] = IRR_KEY_F11;
+ KeyMap[AKEYCODE_F12] = IRR_KEY_F12;
+ KeyMap[AKEYCODE_NUM_LOCK] = IRR_KEY_NUMLOCK;
+ KeyMap[AKEYCODE_NUMPAD_0] = IRR_KEY_NUMPAD0;
+ KeyMap[AKEYCODE_NUMPAD_1] = IRR_KEY_NUMPAD1;
+ KeyMap[AKEYCODE_NUMPAD_2] = IRR_KEY_NUMPAD2;
+ KeyMap[AKEYCODE_NUMPAD_3] = IRR_KEY_NUMPAD3;
+ KeyMap[AKEYCODE_NUMPAD_4] = IRR_KEY_NUMPAD4;
+ KeyMap[AKEYCODE_NUMPAD_5] = IRR_KEY_NUMPAD5;
+ KeyMap[AKEYCODE_NUMPAD_6] = IRR_KEY_NUMPAD6;
+ KeyMap[AKEYCODE_NUMPAD_7] = IRR_KEY_NUMPAD7;
+ KeyMap[AKEYCODE_NUMPAD_8] = IRR_KEY_NUMPAD8;
+ KeyMap[AKEYCODE_NUMPAD_9] = IRR_KEY_NUMPAD9;
+ KeyMap[AKEYCODE_NUMPAD_DIVIDE] = IRR_KEY_DIVIDE;
+ KeyMap[AKEYCODE_NUMPAD_MULTIPLY] = IRR_KEY_MULTIPLY;
+ KeyMap[AKEYCODE_NUMPAD_SUBTRACT] = IRR_KEY_SUBTRACT;
+ KeyMap[AKEYCODE_NUMPAD_ADD] = IRR_KEY_ADD;
+ KeyMap[AKEYCODE_NUMPAD_DOT] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_NUMPAD_COMMA] = IRR_KEY_COMMA;
+ KeyMap[AKEYCODE_NUMPAD_ENTER] = IRR_KEY_RETURN;
+ KeyMap[AKEYCODE_NUMPAD_EQUALS] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_NUMPAD_LEFT_PAREN] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_NUMPAD_RIGHT_PAREN] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_VOLUME_MUTE] = IRR_KEY_VOLUME_MUTE;
+ KeyMap[AKEYCODE_INFO] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_CHANNEL_UP] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_CHANNEL_DOWN] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_ZOOM_IN] = IRR_KEY_ZOOM;
+ KeyMap[AKEYCODE_ZOOM_OUT] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_TV] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_WINDOW] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_GUIDE] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_DVR] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BOOKMARK] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_CAPTIONS] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_SETTINGS] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_TV_POWER] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_TV_INPUT] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_STB_POWER] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_STB_INPUT] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_AVR_POWER] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_AVR_INPUT] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_PROG_RED] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_PROG_GREEN] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_PROG_YELLOW] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_PROG_BLUE] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_APP_SWITCH] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BUTTON_1] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BUTTON_2] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BUTTON_3] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BUTTON_4] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BUTTON_5] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BUTTON_6] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BUTTON_7] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BUTTON_8] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BUTTON_9] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BUTTON_10] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BUTTON_11] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BUTTON_12] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BUTTON_13] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BUTTON_14] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BUTTON_15] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BUTTON_16] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_LANGUAGE_SWITCH] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_MANNER_MODE] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_3D_MODE] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_CONTACTS] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_CALENDAR] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_MUSIC] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_CALCULATOR] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_ZENKAKU_HANKAKU] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_EISU] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_MUHENKAN] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_HENKAN] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_KATAKANA_HIRAGANA] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_YEN] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_RO] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_KANA] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_ASSIST] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BRIGHTNESS_DOWN] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_BRIGHTNESS_UP] = IRR_KEY_UNKNOWN;
+ KeyMap[AKEYCODE_MEDIA_AUDIO_TRACK] = IRR_KEY_UNKNOWN;
}
void CIrrDeviceAndroid::getKeyChar(SEvent& event)
{
- // Handle ASCII chars
+ // Handle ASCII chars
- event.KeyInput.Char = 0;
+ event.KeyInput.Char = 0;
- // A-Z
- if (event.KeyInput.SystemKeyCode > 28 && event.KeyInput.SystemKeyCode < 55)
- {
- if (event.KeyInput.Shift)
- {
- event.KeyInput.Char = event.KeyInput.SystemKeyCode + 36;
- }
- else
- {
- event.KeyInput.Char = event.KeyInput.SystemKeyCode + 68;
- }
- }
+ // A-Z
+ if (event.KeyInput.SystemKeyCode > 28 && event.KeyInput.SystemKeyCode < 55)
+ {
+ if (event.KeyInput.Shift)
+ {
+ event.KeyInput.Char = event.KeyInput.SystemKeyCode + 36;
+ }
+ else
+ {
+ event.KeyInput.Char = event.KeyInput.SystemKeyCode + 68;
+ }
+ }
- // 0-9
- else if (event.KeyInput.SystemKeyCode > 6 && event.KeyInput.SystemKeyCode < 17)
- {
- event.KeyInput.Char = event.KeyInput.SystemKeyCode + 41;
- }
+ // 0-9
+ else if (event.KeyInput.SystemKeyCode > 6 && event.KeyInput.SystemKeyCode < 17)
+ {
+ event.KeyInput.Char = event.KeyInput.SystemKeyCode + 41;
+ }
- else if (event.KeyInput.SystemKeyCode == AKEYCODE_BACK)
- {
- event.KeyInput.Char = 8;
- }
- else if (event.KeyInput.SystemKeyCode == AKEYCODE_DEL)
- {
- event.KeyInput.Char = 8;
- }
- else if (event.KeyInput.SystemKeyCode == AKEYCODE_TAB)
- {
- event.KeyInput.Char = 9;
- }
- else if (event.KeyInput.SystemKeyCode == AKEYCODE_ENTER)
- {
- event.KeyInput.Char = 13;
- }
- else if (event.KeyInput.SystemKeyCode == AKEYCODE_SPACE)
- {
- event.KeyInput.Char = 32;
- }
- else if (event.KeyInput.SystemKeyCode == AKEYCODE_COMMA)
- {
- event.KeyInput.Char = 44;
- }
- else if (event.KeyInput.SystemKeyCode == AKEYCODE_PERIOD)
- {
- event.KeyInput.Char = 46;
- }
+ else if (event.KeyInput.SystemKeyCode == AKEYCODE_BACK)
+ {
+ event.KeyInput.Char = 8;
+ }
+ else if (event.KeyInput.SystemKeyCode == AKEYCODE_DEL)
+ {
+ event.KeyInput.Char = 8;
+ }
+ else if (event.KeyInput.SystemKeyCode == AKEYCODE_TAB)
+ {
+ event.KeyInput.Char = 9;
+ }
+ else if (event.KeyInput.SystemKeyCode == AKEYCODE_ENTER)
+ {
+ event.KeyInput.Char = 13;
+ }
+ else if (event.KeyInput.SystemKeyCode == AKEYCODE_SPACE)
+ {
+ event.KeyInput.Char = 32;
+ }
+ else if (event.KeyInput.SystemKeyCode == AKEYCODE_COMMA)
+ {
+ event.KeyInput.Char = 44;
+ }
+ else if (event.KeyInput.SystemKeyCode == AKEYCODE_PERIOD)
+ {
+ event.KeyInput.Char = 46;
+ }
+}
+
+int CIrrDeviceAndroid::getRotation()
+{
+ JavaVMAttachArgs args;
+ args.version = JNI_VERSION_1_6;
+ args.name = "NativeThread";
+ args.group = NULL;
+ JNIEnv* env;
+
+ if (Android->activity->vm->AttachCurrentThread(&env, &args) != JNI_OK)
+ {
+ os::Printer::log("Cannot find rotation.", ELL_DEBUG);
+ return 0;
+ }
+
+ jobject activity_obj = Android->activity->clazz;
+
+ jclass activity = env->GetObjectClass(activity_obj);
+ jclass context = env->FindClass("android/content/Context");
+ jclass window_manager = env->FindClass("android/view/WindowManager");
+ jclass display = env->FindClass("android/view/Display");
+
+ jmethodID get_system_service = env->GetMethodID(activity, "getSystemService",
+ "(Ljava/lang/String;)Ljava/lang/Object;");
+ jmethodID get_default_display = env->GetMethodID(window_manager,
+ "getDefaultDisplay",
+ "()Landroid/view/Display;");
+ jmethodID get_rotation = env->GetMethodID(display, "getRotation", "()I");
+
+ jfieldID window_service = env->GetStaticFieldID(context, "WINDOW_SERVICE",
+ "Ljava/lang/String;");
+
+ jobject window_service_obj = env->GetStaticObjectField(context, window_service);
+
+ jobject window_manager_obj = env->CallObjectMethod(activity_obj, get_system_service,
+ window_service_obj);
+
+ jobject display_obj = env->CallObjectMethod(window_manager_obj, get_default_display);
+
+ int rotation = env->CallIntMethod(display_obj, get_rotation);
+
+ env->DeleteLocalRef(activity);
+ env->DeleteLocalRef(context);
+ env->DeleteLocalRef(window_manager);
+ env->DeleteLocalRef(display);
+
+ Android->activity->vm->DetachCurrentThread();
+
+ return rotation;
+}
+
+DeviceOrientation CIrrDeviceAndroid::getDefaultOrientation()
+{
+ int rotation = getRotation();
+
+ int32_t orientation = AConfiguration_getOrientation(Android->config);
+
+ if (((rotation == 0 || rotation == 2) &&
+ orientation == ACONFIGURATION_ORIENTATION_LAND) ||
+ ((rotation == 1 || rotation == 3) &&
+ orientation == ACONFIGURATION_ORIENTATION_PORT))
+ {
+ return ORIENTATION_LANDSCAPE;
+ }
+ else
+ {
+ return ORIENTATION_PORTRAIT;
+ }
}
bool CIrrDeviceAndroid::activateAccelerometer(float updateInterval)
{
- if (!isAccelerometerAvailable())
- return false;
+ if (!isAccelerometerAvailable())
+ return false;
+
+ if (DefaultOrientation == ORIENTATION_UNKNOWN)
+ {
+ DefaultOrientation = getDefaultOrientation();
+ }
- ASensorEventQueue_enableSensor(SensorEventQueue, Accelerometer);
- ASensorEventQueue_setEventRate(SensorEventQueue, Accelerometer,
- (int32_t)(updateInterval*1000.f*1000.f)); // in microseconds
+ ASensorEventQueue_enableSensor(SensorEventQueue, Accelerometer);
+ ASensorEventQueue_setEventRate(SensorEventQueue, Accelerometer,
+ (int32_t)(updateInterval*1000.f*1000.f)); // in microseconds
- os::Printer::log("Activated accelerometer", ELL_DEBUG);
- return true;
+ os::Printer::log("Activated accelerometer", ELL_DEBUG);
+ return true;
}
bool CIrrDeviceAndroid::deactivateAccelerometer()
{
- if (!Accelerometer)
- return false;
+ if (!Accelerometer)
+ return false;
- ASensorEventQueue_disableSensor(SensorEventQueue, Accelerometer);
- Accelerometer = 0;
- os::Printer::log("Deactivated accelerometer", ELL_DEBUG);
- return true;
+ ASensorEventQueue_disableSensor(SensorEventQueue, Accelerometer);
+ Accelerometer = 0;
+ os::Printer::log("Deactivated accelerometer", ELL_DEBUG);
+ return true;
}
bool CIrrDeviceAndroid::isAccelerometerActive()
{
- return (Accelerometer != NULL);
+ return (Accelerometer != NULL);
}
bool CIrrDeviceAndroid::isAccelerometerAvailable()
{
- if (!Accelerometer)
- {
- Accelerometer = ASensorManager_getDefaultSensor(SensorManager,
- ASENSOR_TYPE_ACCELEROMETER);
- }
+ if (!Accelerometer)
+ {
+ Accelerometer = ASensorManager_getDefaultSensor(SensorManager,
+ ASENSOR_TYPE_ACCELEROMETER);
+ }
- return (Accelerometer != NULL);
+ return (Accelerometer != NULL);
}
bool CIrrDeviceAndroid::activateGyroscope(float updateInterval)
{
- if (!isGyroscopeAvailable())
- return false;
+ if (!isGyroscopeAvailable())
+ return false;
- ASensorEventQueue_enableSensor(SensorEventQueue, Gyroscope);
- ASensorEventQueue_setEventRate(SensorEventQueue, Gyroscope,
- (int32_t)(updateInterval*1000.f*1000.f)); // in microseconds
+ ASensorEventQueue_enableSensor(SensorEventQueue, Gyroscope);
+ ASensorEventQueue_setEventRate(SensorEventQueue, Gyroscope,
+ (int32_t)(updateInterval*1000.f*1000.f)); // in microseconds
- os::Printer::log("Activated gyroscope", ELL_DEBUG);
- return true;
+ os::Printer::log("Activated gyroscope", ELL_DEBUG);
+ return true;
}
bool CIrrDeviceAndroid::deactivateGyroscope()
{
- if (!Gyroscope)
- return false;
+ if (!Gyroscope)
+ return false;
- ASensorEventQueue_disableSensor(SensorEventQueue, Gyroscope);
- Gyroscope = 0;
- os::Printer::log("Deactivated gyroscope", ELL_DEBUG);
- return true;
+ ASensorEventQueue_disableSensor(SensorEventQueue, Gyroscope);
+ Gyroscope = 0;
+ os::Printer::log("Deactivated gyroscope", ELL_DEBUG);
+ return true;
}
bool CIrrDeviceAndroid::isGyroscopeActive()
{
- return (Gyroscope != NULL);
+ return (Gyroscope != NULL);
}
bool CIrrDeviceAndroid::isGyroscopeAvailable()
{
- if (!Gyroscope)
- {
- Gyroscope = ASensorManager_getDefaultSensor(SensorManager,
- ASENSOR_TYPE_GYROSCOPE);
- }
+ if (!Gyroscope)
+ {
+ Gyroscope = ASensorManager_getDefaultSensor(SensorManager,
+ ASENSOR_TYPE_GYROSCOPE);
+ }
- return (Gyroscope != NULL);
+ return (Gyroscope != NULL);
}
diff --git a/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h b/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h
index 62f87c042..33ce575b9 100644
--- a/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h
+++ b/lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h
@@ -23,125 +23,134 @@
namespace irr
{
+ enum DeviceOrientation
+ {
+ ORIENTATION_UNKNOWN,
+ ORIENTATION_PORTRAIT,
+ ORIENTATION_LANDSCAPE
+ };
+
+ class CIrrDeviceAndroid : public CIrrDeviceStub, video::IImagePresenter
+ {
+ public:
+ //! constructor
+ CIrrDeviceAndroid(const SIrrlichtCreationParameters& param);
- class CIrrDeviceAndroid : public CIrrDeviceStub, video::IImagePresenter
- {
- public:
- //! constructor
- CIrrDeviceAndroid(const SIrrlichtCreationParameters& param);
+ //! destructor
+ virtual ~CIrrDeviceAndroid();
- //! 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 bool moveWindow(int x, int y);
+ virtual bool getWindowPosition(int* x, int* y);
+ 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:
- 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 bool moveWindow(int x, int y);
- virtual bool getWindowPosition(int* x, int* y);
- 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;
+ };
+
+ static void onCreate();
- 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;
- };
-
- static void onCreate();
+ private:
+ android_app* Android;
+ ASensorManager* SensorManager;
+ ASensorEventQueue* SensorEventQueue;
+ const ASensor* Accelerometer;
+ const ASensor* Gyroscope;
- private:
- android_app* Android;
- ASensorManager* SensorManager;
- ASensorEventQueue* SensorEventQueue;
- const ASensor* Accelerometer;
- const ASensor* Gyroscope;
+ static bool IsPaused;
+ static bool IsFocused;
+ static bool IsStarted;
+
+ struct TouchEventData
+ {
+ int x;
+ int y;
+ ETOUCH_INPUT_EVENT event;
+
+ TouchEventData() : x(0), y(0), event(ETIE_COUNT) {};
+ };
+
+ TouchEventData TouchEventsData[32];
+ bool IsMousePressed;
+ float GamepadAxisX;
+ float GamepadAxisY;
+ DeviceOrientation DefaultOrientation;
- static bool IsPaused;
- static bool IsFocused;
- static bool IsStarted;
-
- struct TouchEventData
- {
- int x;
- int y;
- ETOUCH_INPUT_EVENT event;
-
- TouchEventData() : x(0), y(0), event(ETIE_COUNT) {};
- };
-
- TouchEventData TouchEventsData[32];
- bool IsMousePressed;
- float GamepadAxisX;
- float GamepadAxisY;
+ video::SExposedVideoData ExposedVideoData;
- video::SExposedVideoData ExposedVideoData;
+ std::map KeyMap;
+
+ void printConfig();
+ void createDriver();
+ void createKeyMap();
+ void createVideoModeList();
+ void getKeyChar(SEvent& event);
+ int getRotation();
+ DeviceOrientation getDefaultOrientation();
+ video::SExposedVideoData& getExposedVideoData();
+
+ static void handleAndroidCommand(android_app* app, int32_t cmd);
+ static s32 handleInput(android_app* app, AInputEvent* event);
- std::map KeyMap;
-
- void printConfig();
- 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);
-
- s32 handleTouch(AInputEvent* androidEvent);
- s32 handleKeyboard(AInputEvent* androidEvent);
- s32 handleGamepad(AInputEvent* androidEvent);
- };
+ s32 handleTouch(AInputEvent* androidEvent);
+ s32 handleKeyboard(AInputEvent* androidEvent);
+ s32 handleGamepad(AInputEvent* androidEvent);
+ };
} // end namespace irr
diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp
index ead7a1a73..a41b40690 100644
--- a/src/config/user_config.hpp
+++ b/src/config/user_config.hpp
@@ -468,10 +468,10 @@ namespace UserConfigParams
&m_multitouch_group,
"Draw steering wheel on right side.") );
- PARAM_PREFIX IntUserConfigParam m_multitouch_accelerometer
- PARAM_DEFAULT( IntUserConfigParam(0, "multitouch_accelerometer",
+ PARAM_PREFIX IntUserConfigParam m_multitouch_controls
+ PARAM_DEFAULT( IntUserConfigParam(0, "multitouch_controls",
&m_multitouch_group,
- "Accelerometer mode: 0 = off, 1 = tablet, 2 = phone"));
+ "Multitouch mode: 0 = undefined, 1 = steering wheel, 2 = accelerometer"));
PARAM_PREFIX FloatUserConfigParam m_multitouch_deadzone_center
PARAM_DEFAULT( FloatUserConfigParam(0.1f, "multitouch_deadzone_center",
diff --git a/src/graphics/graphics_restrictions.cpp b/src/graphics/graphics_restrictions.cpp
index 78c9caf4c..f7c1d50d8 100644
--- a/src/graphics/graphics_restrictions.cpp
+++ b/src/graphics/graphics_restrictions.cpp
@@ -200,6 +200,11 @@ public:
convertVersionString(s[2]);
return;
}
+ else if (s.size() == 5)
+ {
+ convertVersionString(s[4]);
+ return;
+ }
}
diff --git a/src/graphics/sp/sp_shader_manager.cpp b/src/graphics/sp/sp_shader_manager.cpp
index e4b491583..b484ee766 100644
--- a/src/graphics/sp/sp_shader_manager.cpp
+++ b/src/graphics/sp/sp_shader_manager.cpp
@@ -60,6 +60,13 @@ SPShaderManager::SPShaderManager()
ua->setValue(sp_wind_dir);
}
},
+ { "isDuringDayUniformAssigner", [](SPUniformAssigner* ua)
+ {
+ int is_during_day = Track::getCurrentTrack() ?
+ Track::getCurrentTrack()->getIsDuringDay() ? 1 : 0 : 0;
+ ua->setValue(is_during_day);
+ }
+ },
{ "zeroAlphaUniformAssigner", [](SPUniformAssigner* ua)
{
ua->setValue(0.0f);
diff --git a/src/guiengine/widgets/CGUIEditBox.cpp b/src/guiengine/widgets/CGUIEditBox.cpp
index 39dec5ff8..15f78603b 100644
--- a/src/guiengine/widgets/CGUIEditBox.cpp
+++ b/src/guiengine/widgets/CGUIEditBox.cpp
@@ -23,6 +23,10 @@
#include "../../../lib/irrlicht/include/IrrCompileConfig.h"
#include "../../../lib/irrlicht/source/Irrlicht/CIrrDeviceLinux.h"
+#ifdef ANDROID
+#include "../../../lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h"
+#endif
+
/*
todo:
optional scrollbars
@@ -1255,12 +1259,24 @@ bool CGUIEditBox::processMouse(const SEvent& event)
}
else if (!m_rtl)
{
+ bool use_screen_keyboard = UserConfigParams::m_screen_keyboard;
+
+ #ifdef ANDROID
+ int32_t keyboard = AConfiguration_getKeyboard(
+ global_android_app->config);
+
+ if (keyboard == ACONFIGURATION_KEYBOARD_QWERTY)
+ {
+ use_screen_keyboard = false;
+ }
+ #endif
+
if (!AbsoluteClippingRect.isPointInside(
core::position2d(event.MouseInput.X, event.MouseInput.Y)))
{
return false;
}
- else if (UserConfigParams::m_screen_keyboard)
+ else if (use_screen_keyboard)
{
CursorPos = Text.size();
setTextMarkers(CursorPos, CursorPos);
diff --git a/src/input/device_config.cpp b/src/input/device_config.cpp
index 04b6cc8ff..5e89a337e 100644
--- a/src/input/device_config.cpp
+++ b/src/input/device_config.cpp
@@ -20,6 +20,7 @@
#include "input/device_config.hpp"
#include "input/gamepad_config.hpp"
+#include "input/gamepad_android_config.hpp"
#include "input/keyboard_config.hpp"
#include "io/xml_node.hpp"
#include "utils/log.hpp"
@@ -47,6 +48,10 @@ DeviceConfig* DeviceConfig::create(const XMLNode *config)
{
device_config = new GamepadConfig();
}
+ else if(config->getName()=="gamepad_android")
+ {
+ device_config = new GamepadAndroidConfig();
+ }
else
{
Log::error("DeviceConfig", "Incorrect type: '%s'.",
diff --git a/src/input/device_config.hpp b/src/input/device_config.hpp
index 844eb6c01..bbc727c1e 100644
--- a/src/input/device_config.hpp
+++ b/src/input/device_config.hpp
@@ -95,6 +95,7 @@ public:
irr::core::stringw getMappingIdString (const PlayerAction action) const;
virtual irr::core::stringw getBindingAsString(const PlayerAction action) const;
virtual bool isGamePad() const = 0;
+ virtual bool isGamePadAndroid() const = 0;
virtual bool isKeyboard() const = 0;
virtual void save(std::ofstream& stream);
diff --git a/src/input/device_manager.cpp b/src/input/device_manager.cpp
index eb5f77d06..ebb2c5ea0 100644
--- a/src/input/device_manager.cpp
+++ b/src/input/device_manager.cpp
@@ -23,6 +23,7 @@
#include "config/user_config.hpp"
#include "graphics/irr_driver.hpp"
+#include "input/gamepad_android_config.hpp"
#include "input/gamepad_device.hpp"
#include "input/keyboard_device.hpp"
#include "input/multitouch_device.hpp"
@@ -80,8 +81,27 @@ bool DeviceManager::initialize()
if(UserConfigParams::logMisc())
Log::info("Device manager","No keyboard configuration exists, creating one.");
m_keyboard_configs.push_back(new KeyboardConfig());
+
created = true;
}
+
+#ifdef ANDROID
+ bool has_gamepad_android_config = false;
+
+ for (unsigned int i = 0; i < m_keyboard_configs.size(); i++)
+ {
+ if (m_keyboard_configs[i].isGamePadAndroid())
+ {
+ has_gamepad_android_config = true;
+ }
+ }
+
+ if (!has_gamepad_android_config)
+ {
+ m_keyboard_configs.push_back(new GamepadAndroidConfig());
+ created = true;
+ }
+#endif
const int keyboard_amount = m_keyboard_configs.size();
for (int n = 0; n < keyboard_amount; n++)
@@ -568,12 +588,13 @@ bool DeviceManager::load()
config->getName().c_str());
continue;
}
- if(config->getName()=="keyboard")
+ if (config->getName() == "keyboard" ||
+ config->getName() == "gamepad_android")
{
KeyboardConfig *kc = static_cast(device_config);
m_keyboard_configs.push_back(kc);
}
- else if (config->getName()=="gamepad")
+ else if (config->getName() == "gamepad")
{
GamepadConfig *gc = static_cast(device_config);
m_gamepad_configs.push_back(gc);
diff --git a/src/input/gamepad_android_config.cpp b/src/input/gamepad_android_config.cpp
new file mode 100644
index 000000000..d87296777
--- /dev/null
+++ b/src/input/gamepad_android_config.cpp
@@ -0,0 +1,145 @@
+//
+// SuperTuxKart - a fun racing game with go-kart
+// Copyright (C) 2010-2015 SuperTuxKart-Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#include "input/gamepad_android_config.hpp"
+#include "utils/translation.hpp"
+
+#include
+
+using namespace irr;
+
+GamepadAndroidConfig::GamepadAndroidConfig()
+{
+ setDefaultBinds();
+}
+
+// ----------------------------------------------------------------------------
+/** Saves the configuration to a file. It writes the name for a gamepad
+ * config, saves the device specific parameters, and calls
+ * DeviceConfig::save() to save the rest.
+ * \param stream The stream to save to.
+ */
+void GamepadAndroidConfig::save(std::ofstream& stream)
+{
+ stream << "\n\n";
+} // save
+
+// ----------------------------------------------------------------------------
+
+irr::core::stringw GamepadAndroidConfig::getBindingAsString(const PlayerAction action) const
+{
+ const Binding &b = getBinding(action);
+ int id = b.getId();
+
+ irr::core::stringw button_name;
+
+ switch (id)
+ {
+ case IRR_KEY_BUTTON_LEFT:
+ button_name = _C("input_key", "Left");
+ break;
+ case IRR_KEY_BUTTON_RIGHT:
+ button_name = _C("input_key", "Right");
+ break;
+ case IRR_KEY_BUTTON_UP:
+ button_name = _C("input_key", "Up");
+ break;
+ case IRR_KEY_BUTTON_DOWN:
+ button_name = _C("input_key", "Down");
+ break;
+ case IRR_KEY_BUTTON_A:
+ button_name = "A";
+ break;
+ case IRR_KEY_BUTTON_B:
+ button_name = "B";
+ break;
+ case IRR_KEY_BUTTON_C:
+ button_name = "C";
+ break;
+ case IRR_KEY_BUTTON_X:
+ button_name = "X";
+ break;
+ case IRR_KEY_BUTTON_Y:
+ button_name = "Y";
+ break;
+ case IRR_KEY_BUTTON_Z:
+ button_name = "Z";
+ break;
+ case IRR_KEY_BUTTON_L1:
+ button_name = "L1";
+ break;
+ case IRR_KEY_BUTTON_R1:
+ button_name = "R1";
+ break;
+ case IRR_KEY_BUTTON_L2:
+ button_name = "L2";
+ break;
+ case IRR_KEY_BUTTON_R2:
+ button_name = "R2";
+ break;
+ case IRR_KEY_BUTTON_THUMBL:
+ button_name = _C("input_key", "Thumb Left");
+ break;
+ case IRR_KEY_BUTTON_THUMBR:
+ button_name = _C("input_key", "Thumb Right");
+ break;
+ case IRR_KEY_BUTTON_START:
+ button_name = _C("input_key", "Start");
+ break;
+ case IRR_KEY_BUTTON_SELECT:
+ button_name = _C("input_key", "Select");
+ break;
+ case IRR_KEY_BUTTON_MODE:
+ button_name = _C("input_key", "Mode");
+ break;
+ default:
+ button_name = DeviceConfig::getBindingAsString(action);
+ break;
+ }
+
+ return button_name;
+}
+
+// ----------------------------------------------------------------------------
+
+void GamepadAndroidConfig::setDefaultBinds()
+{
+ setBinding(PA_NITRO, Input::IT_KEYBOARD, IRR_KEY_BUTTON_X);
+ setBinding(PA_ACCEL, Input::IT_KEYBOARD, IRR_KEY_BUTTON_UP);
+ setBinding(PA_BRAKE, Input::IT_KEYBOARD, IRR_KEY_BUTTON_DOWN);
+ setBinding(PA_STEER_LEFT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_LEFT);
+ setBinding(PA_STEER_RIGHT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_RIGHT);
+ setBinding(PA_DRIFT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_Y);
+ setBinding(PA_RESCUE, Input::IT_KEYBOARD, IRR_KEY_BUTTON_L1);
+ setBinding(PA_FIRE, Input::IT_KEYBOARD, IRR_KEY_BUTTON_A);
+ setBinding(PA_LOOK_BACK, Input::IT_KEYBOARD, IRR_KEY_BUTTON_R1);
+ setBinding(PA_PAUSE_RACE, Input::IT_KEYBOARD, IRR_KEY_BUTTON_B);
+
+ setBinding(PA_MENU_UP, Input::IT_KEYBOARD, IRR_KEY_BUTTON_UP);
+ setBinding(PA_MENU_DOWN, Input::IT_KEYBOARD, IRR_KEY_BUTTON_DOWN);
+ setBinding(PA_MENU_LEFT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_LEFT);
+ setBinding(PA_MENU_RIGHT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_RIGHT);
+ setBinding(PA_MENU_SELECT, Input::IT_KEYBOARD, IRR_KEY_BUTTON_A);
+ setBinding(PA_MENU_CANCEL, Input::IT_KEYBOARD, IRR_KEY_BUTTON_B);
+}
+
+//------------------------------------------------------------------------------
+
diff --git a/src/input/gamepad_android_config.hpp b/src/input/gamepad_android_config.hpp
new file mode 100644
index 000000000..324af98cf
--- /dev/null
+++ b/src/input/gamepad_android_config.hpp
@@ -0,0 +1,55 @@
+//
+// SuperTuxKart - a fun racing game with go-kart
+// Copyright (C) 2010-2015 SuperTuxKart-Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#ifndef HEADER_GAMEPAD_ANDROID_CONFIG_HPP
+#define HEADER_GAMEPAD_ANDROID_CONFIG_HPP
+
+#include "input/binding.hpp"
+#include "input/keyboard_config.hpp"
+#include "input/input.hpp"
+#include "utils/no_copy.hpp"
+#include "utils/cpp2011.hpp"
+
+#include
+
+/**
+ * \brief specialisation of DeviceConfig for android gamepad devices
+ * \ingroup config
+ */
+class GamepadAndroidConfig : public KeyboardConfig
+{
+
+public:
+
+ GamepadAndroidConfig();
+ virtual ~GamepadAndroidConfig() {}
+
+ virtual void setDefaultBinds();
+ virtual void save(std::ofstream& stream);
+ virtual irr::core::stringw getBindingAsString(const PlayerAction action) const;
+
+ // ------------------------------------------------------------------------
+ virtual bool isGamePad() const { return false; }
+ // ------------------------------------------------------------------------
+ virtual bool isGamePadAndroid() const { return true; }
+ // ------------------------------------------------------------------------
+ virtual bool isKeyboard() const { return true; }
+
+}; // class GamepadAndroidConfig
+
+#endif
diff --git a/src/input/gamepad_config.hpp b/src/input/gamepad_config.hpp
index b62c77d57..f056fc68a 100644
--- a/src/input/gamepad_config.hpp
+++ b/src/input/gamepad_config.hpp
@@ -105,6 +105,8 @@ public:
// ------------------------------------------------------------------------
virtual bool isGamePad() const OVERRIDE { return true; }
// ------------------------------------------------------------------------
+ virtual bool isGamePadAndroid() const OVERRIDE { return false; }
+ // ------------------------------------------------------------------------
virtual bool isKeyboard() const OVERRIDE { return false; }
}; // class GamepadConfig
diff --git a/src/input/input_manager.cpp b/src/input/input_manager.cpp
index 2c8c64932..4241cb182 100644
--- a/src/input/input_manager.cpp
+++ b/src/input/input_manager.cpp
@@ -109,7 +109,8 @@ void InputManager::handleStaticAction(int key, int value)
// When no players... a cutscene
if (race_manager->getNumPlayers() == 0 && world != NULL && value > 0 &&
- (key == IRR_KEY_SPACE || key == IRR_KEY_RETURN))
+ (key == IRR_KEY_SPACE || key == IRR_KEY_RETURN ||
+ key == IRR_KEY_BUTTON_A))
{
world->onFirePressed(NULL);
}
@@ -658,12 +659,17 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
{
action = PA_BEFORE_FIRST;
- if (button == IRR_KEY_UP) action = PA_MENU_UP;
- else if (button == IRR_KEY_DOWN) action = PA_MENU_DOWN;
- else if (button == IRR_KEY_LEFT) action = PA_MENU_LEFT;
- else if (button == IRR_KEY_RIGHT) action = PA_MENU_RIGHT;
- else if (button == IRR_KEY_SPACE) action = PA_MENU_SELECT;
- else if (button == IRR_KEY_RETURN) action = PA_MENU_SELECT;
+ if (button == IRR_KEY_UP) action = PA_MENU_UP;
+ else if (button == IRR_KEY_DOWN) action = PA_MENU_DOWN;
+ else if (button == IRR_KEY_LEFT) action = PA_MENU_LEFT;
+ else if (button == IRR_KEY_RIGHT) action = PA_MENU_RIGHT;
+ else if (button == IRR_KEY_SPACE) action = PA_MENU_SELECT;
+ else if (button == IRR_KEY_RETURN) action = PA_MENU_SELECT;
+ else if (button == IRR_KEY_BUTTON_UP) action = PA_MENU_DOWN;
+ else if (button == IRR_KEY_BUTTON_DOWN) action = PA_MENU_UP;
+ else if (button == IRR_KEY_BUTTON_LEFT) action = PA_MENU_LEFT;
+ else if (button == IRR_KEY_BUTTON_RIGHT) action = PA_MENU_RIGHT;
+ else if (button == IRR_KEY_BUTTON_A) action = PA_MENU_SELECT;
else if (button == IRR_KEY_TAB)
{
if (shift_mask)
@@ -676,7 +682,7 @@ void InputManager::dispatchInput(Input::InputType type, int deviceID,
}
}
- if (button == IRR_KEY_RETURN)
+ if (button == IRR_KEY_RETURN || button == IRR_KEY_BUTTON_A)
{
if (GUIEngine::ModalDialog::isADialogActive() &&
!GUIEngine::ScreenKeyboard::isActive())
@@ -1196,17 +1202,9 @@ EventPropagation InputManager::input(const SEvent& event)
float factor = UserConfigParams::m_multitouch_tilt_factor;
factor = std::max(factor, 0.1f);
-
- if (UserConfigParams::m_multitouch_accelerometer == 1)
- {
- button->axis_x = (float)-event.AccelerometerEvent.X / factor;
- device->handleControls(button);
- }
- else if (UserConfigParams::m_multitouch_accelerometer == 2)
- {
- button->axis_x = (float)event.AccelerometerEvent.Y / factor;
- device->handleControls(button);
- }
+ button->axis_x = (float)event.AccelerometerEvent.Y / factor;
+
+ device->handleControls(button);
}
}
}
diff --git a/src/input/keyboard_config.hpp b/src/input/keyboard_config.hpp
index 7d3dc264e..e43cc47ee 100644
--- a/src/input/keyboard_config.hpp
+++ b/src/input/keyboard_config.hpp
@@ -39,12 +39,14 @@ public:
KeyboardConfig();
virtual ~KeyboardConfig() {}
- void setDefaultBinds ();
+ virtual void setDefaultBinds();
virtual void save(std::ofstream& stream);
// ------------------------------------------------------------------------
virtual bool isGamePad() const { return false; }
// ------------------------------------------------------------------------
+ virtual bool isGamePadAndroid() const { return false; }
+ // ------------------------------------------------------------------------
virtual bool isKeyboard() const { return true; }
}; // class KeyboardConfig
diff --git a/src/input/multitouch_device.cpp b/src/input/multitouch_device.cpp
index 9d1c8e4eb..7ce754fcf 100644
--- a/src/input/multitouch_device.cpp
+++ b/src/input/multitouch_device.cpp
@@ -140,7 +140,7 @@ void MultitouchDevice::addButton(MultitouchButtonType type, int x, int y,
#ifdef ANDROID
if (button->type == MultitouchButtonType::BUTTON_STEERING)
{
- if (UserConfigParams::m_multitouch_accelerometer > 0 &&
+ if (UserConfigParams::m_multitouch_controls == 2 &&
!m_android_device->isAccelerometerActive())
{
m_android_device->activateAccelerometer(1.0f / 30);
diff --git a/src/main.cpp b/src/main.cpp
index 3bfc67b1d..68f75a0fb 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -228,6 +228,7 @@
#include "states_screens/register_screen.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/user_screen.hpp"
+#include "states_screens/dialogs/init_android_dialog.hpp"
#include "states_screens/dialogs/message_dialog.hpp"
#include "tracks/arena_graph.hpp"
#include "tracks/track.hpp"
@@ -1668,6 +1669,21 @@ int main(int argc, char *argv[] )
}
Log::warn("main", "Screen size is too small!");
}
+
+ #ifdef ANDROID
+ if (UserConfigParams::m_multitouch_controls == 0)
+ {
+ int32_t touch = AConfiguration_getTouchscreen(
+ global_android_app->config);
+
+ if (touch != ACONFIGURATION_TOUCHSCREEN_NOTOUCH)
+ {
+ InitAndroidDialog* init_android = new InitAndroidDialog(
+ 0.6f, 0.6f);
+ GUIEngine::DialogQueue::get()->pushDialog(init_android);
+ }
+ }
+ #endif
if (GraphicsRestrictions::isDisabled(
GraphicsRestrictions::GR_DRIVER_RECENT_ENOUGH))
@@ -1684,6 +1700,7 @@ int main(int argc, char *argv[] )
}
else if (!CVS->isGLSL())
{
+ #if !defined(ANDROID)
if (UserConfigParams::m_old_driver_popup)
{
#ifdef USE_GLES2
@@ -1700,6 +1717,7 @@ int main(int argc, char *argv[] )
/*from queue*/ true);
GUIEngine::DialogQueue::get()->pushDialog(dialog);
}
+ #endif
Log::warn("OpenGL", "OpenGL version is too old!");
}
}
diff --git a/src/modes/linear_world.cpp b/src/modes/linear_world.cpp
index 162fb0381..be8aaf176 100644
--- a/src/modes/linear_world.cpp
+++ b/src/modes/linear_world.cpp
@@ -286,8 +286,11 @@ void LinearWorld::newLap(unsigned int kart_index)
// Last lap message (kart_index's assert in previous block already)
if (raceHasLaps() && kart_info.m_race_lap+1 == lap_count)
{
- m_race_gui->addMessage(_("Final lap!"), kart,
+ if (lap_count > 1)
+ {
+ m_race_gui->addMessage(_("Final lap!"), kart,
3.0f, GUIEngine::getSkin()->getColor("font::normal"), true);
+ }
if(!m_last_lap_sfx_played && lap_count > 1)
{
if (UserConfigParams::m_music)
diff --git a/src/states_screens/dialogs/init_android_dialog.cpp b/src/states_screens/dialogs/init_android_dialog.cpp
new file mode 100644
index 000000000..d446d47dc
--- /dev/null
+++ b/src/states_screens/dialogs/init_android_dialog.cpp
@@ -0,0 +1,158 @@
+// SuperTuxKart - a fun racing game with go-kart
+// Copyright (C) 2014-2015 SuperTuxKart-Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include "states_screens/dialogs/init_android_dialog.hpp"
+
+#include "config/user_config.hpp"
+#include "graphics/irr_driver.hpp"
+#include "guiengine/widgets/check_box_widget.hpp"
+#include "guiengine/widgets/spinner_widget.hpp"
+#include "guiengine/widgets/ribbon_widget.hpp"
+#include "input/device_manager.hpp"
+#include "input/input_manager.hpp"
+#include "input/multitouch_device.hpp"
+#include "utils/translation.hpp"
+
+#ifdef ANDROID
+#include "../../../lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h"
+#endif
+
+#include
+
+
+using namespace GUIEngine;
+using namespace irr;
+using namespace irr::core;
+using namespace irr::gui;
+
+// -----------------------------------------------------------------------------
+
+InitAndroidDialog::InitAndroidDialog(const float w, const float h)
+ : ModalDialog(w, h)
+{
+}
+
+// -----------------------------------------------------------------------------
+
+InitAndroidDialog::~InitAndroidDialog()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void InitAndroidDialog::load()
+{
+ loadFromFile("init_android.stkgui");
+}
+
+// -----------------------------------------------------------------------------
+
+void InitAndroidDialog::beforeAddingWidgets()
+{
+ bool accelerometer_available = false;
+
+#ifdef ANDROID
+ CIrrDeviceAndroid* android_device = dynamic_cast(
+ irr_driver->getDevice());
+ assert(android_device != NULL);
+ accelerometer_available = android_device->isAccelerometerAvailable();
+#endif
+
+ if (!accelerometer_available)
+ {
+ RibbonWidget* control_type = getWidget("control_type");
+ assert(control_type != NULL);
+
+ int index = control_type->findItemNamed("accelerometer");
+ Widget* accelerometer = &control_type->getChildren()[index];
+ accelerometer->setActive(false);
+
+ if (UserConfigParams::m_multitouch_controls = 2)
+ {
+ UserConfigParams::m_multitouch_controls = 1;
+ }
+ }
+
+ updateValues();
+}
+
+// -----------------------------------------------------------------------------
+
+GUIEngine::EventPropagation InitAndroidDialog::processEvent(
+ const std::string& eventSource)
+{
+ if (eventSource == "close")
+ {
+ RibbonWidget* control_type = getWidget("control_type");
+ assert(control_type != NULL);
+
+ const std::string& selected = control_type->getSelectionIDString(
+ PLAYER_ID_GAME_MASTER);
+ int index = control_type->getSelection(PLAYER_ID_GAME_MASTER);
+ Widget* selected_widget = &control_type->getChildren()[index];
+
+ if (!selected_widget->isActivated())
+ return GUIEngine::EVENT_BLOCK;
+
+ if (selected == "steering_wheel")
+ {
+ UserConfigParams::m_multitouch_controls = 1;
+ }
+ else if (selected == "accelerometer")
+ {
+ UserConfigParams::m_multitouch_controls = 2;
+ }
+
+ user_config->saveConfig();
+
+ ModalDialog::dismiss();
+ return GUIEngine::EVENT_BLOCK;
+ }
+
+ return GUIEngine::EVENT_LET;
+} // processEvent
+
+// -----------------------------------------------------------------------------
+
+void InitAndroidDialog::updateValues()
+{
+ RibbonWidget* control_type = getWidget("control_type");
+ assert(control_type != NULL);
+
+ if (UserConfigParams::m_multitouch_controls == 2)
+ {
+ int id = control_type->findItemNamed("accelerometer");
+ control_type->setSelection(id, PLAYER_ID_GAME_MASTER);
+ }
+ else
+ {
+ int id = control_type->findItemNamed("steering_wheel");
+ control_type->setSelection(id, PLAYER_ID_GAME_MASTER);
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+bool InitAndroidDialog::onEscapePressed()
+{
+ UserConfigParams::m_multitouch_controls = 1;
+ user_config->saveConfig();
+ ModalDialog::dismiss();
+ return true;
+} // onEscapePressed
+
+// -----------------------------------------------------------------------------
diff --git a/src/states_screens/dialogs/init_android_dialog.hpp b/src/states_screens/dialogs/init_android_dialog.hpp
new file mode 100644
index 000000000..0fc10cff0
--- /dev/null
+++ b/src/states_screens/dialogs/init_android_dialog.hpp
@@ -0,0 +1,48 @@
+// SuperTuxKart - a fun racing game with go-kart
+// Copyright (C) 2014-2015 SuperTuxKart-Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 3
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+#ifndef HEADER_INIT_ANDROID_DIALOG_HPP
+#define HEADER_INIT_ANDROID_DIALOG_HPP
+
+#include "guiengine/modaldialog.hpp"
+
+/**
+ * \brief Dialog that allows the player to adjust multitouch steering settings
+ * \ingroup states_screens
+ */
+class InitAndroidDialog : public GUIEngine::ModalDialog
+{
+private:
+ void updateValues();
+
+public:
+ /**
+ * Creates a modal dialog with given percentage of screen width and height
+ */
+ InitAndroidDialog(const float percentWidth, const float percentHeight);
+ ~InitAndroidDialog();
+
+ virtual void beforeAddingWidgets();
+ virtual void load();
+ virtual bool onEscapePressed();
+
+ GUIEngine::EventPropagation processEvent(const std::string& eventSource);
+
+};
+
+#endif
diff --git a/src/states_screens/dialogs/multitouch_settings_dialog.cpp b/src/states_screens/dialogs/multitouch_settings_dialog.cpp
index 901fab343..0fb2cbe85 100644
--- a/src/states_screens/dialogs/multitouch_settings_dialog.cpp
+++ b/src/states_screens/dialogs/multitouch_settings_dialog.cpp
@@ -18,6 +18,7 @@
#include "states_screens/dialogs/multitouch_settings_dialog.hpp"
#include "config/user_config.hpp"
+#include "graphics/irr_driver.hpp"
#include "guiengine/widgets/check_box_widget.hpp"
#include "guiengine/widgets/spinner_widget.hpp"
#include "input/device_manager.hpp"
@@ -25,6 +26,10 @@
#include "input/multitouch_device.hpp"
#include "utils/translation.hpp"
+#ifdef ANDROID
+#include "../../../lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h"
+#endif
+
#include
@@ -51,16 +56,21 @@ MultitouchSettingsDialog::~MultitouchSettingsDialog()
void MultitouchSettingsDialog::beforeAddingWidgets()
{
- SpinnerWidget* accelerometer = getWidget("accelerometer");
- assert(accelerometer != NULL);
+ bool accelerometer_available = false;
+
+#ifdef ANDROID
+ CIrrDeviceAndroid* android_device = dynamic_cast(
+ irr_driver->getDevice());
+ assert(android_device != NULL);
+ accelerometer_available = android_device->isAccelerometerAvailable();
+#endif
- accelerometer->m_properties[PROP_WRAP_AROUND] = "true";
- accelerometer->clearLabels();
- accelerometer->addLabel(_("Disabled"));
- accelerometer->addLabel(_("Tablet"));
- accelerometer->addLabel(_("Phone"));
- accelerometer->m_properties[GUIEngine::PROP_MIN_VALUE] = "0";
- accelerometer->m_properties[GUIEngine::PROP_MAX_VALUE] = "2";
+ if (!accelerometer_available)
+ {
+ CheckBoxWidget* accelerometer = getWidget("accelerometer");
+ assert(accelerometer != NULL);
+ accelerometer->setActive(false);
+ }
updateValues();
}
@@ -94,10 +104,11 @@ GUIEngine::EventPropagation MultitouchSettingsDialog::processEvent(
assert(buttons_inv != NULL);
UserConfigParams::m_multitouch_inverted = buttons_inv->getState();
- SpinnerWidget* accelerometer = getWidget("accelerometer");
+ CheckBoxWidget* accelerometer = getWidget("accelerometer");
assert(accelerometer != NULL);
- UserConfigParams::m_multitouch_accelerometer = accelerometer->getValue();
+ UserConfigParams::m_multitouch_controls = accelerometer->
+ getState() ? 2 : 1;
MultitouchDevice* touch_device = input_manager->getDeviceManager()->
getMultitouchDevice();
@@ -118,7 +129,7 @@ GUIEngine::EventPropagation MultitouchSettingsDialog::processEvent(
UserConfigParams::m_multitouch_deadzone_edge.revertToDefaults();
UserConfigParams::m_multitouch_deadzone_center.revertToDefaults();
UserConfigParams::m_multitouch_mode.revertToDefaults();
- UserConfigParams::m_multitouch_accelerometer.revertToDefaults();
+ UserConfigParams::m_multitouch_controls.revertToDefaults();
updateValues();
@@ -154,9 +165,9 @@ void MultitouchSettingsDialog::updateValues()
assert(buttons_inv != NULL);
buttons_inv->setState(UserConfigParams::m_multitouch_inverted);
- SpinnerWidget* accelerometer = getWidget("accelerometer");
+ CheckBoxWidget* accelerometer = getWidget("accelerometer");
assert(accelerometer != NULL);
- accelerometer->setValue(UserConfigParams::m_multitouch_accelerometer);
+ accelerometer->setState(UserConfigParams::m_multitouch_controls == 2);
}
// -----------------------------------------------------------------------------
diff --git a/src/states_screens/options_screen_device.cpp b/src/states_screens/options_screen_device.cpp
index 94132a3f5..040507e4a 100644
--- a/src/states_screens/options_screen_device.cpp
+++ b/src/states_screens/options_screen_device.cpp
@@ -106,6 +106,11 @@ void OptionsScreenDevice::init()
delete_button->setLabel(label);
}
+ else if (m_config->isGamePadAndroid())
+ {
+ delete_button->setLabel(_("Delete Configuration"));
+ delete_button->setActive(false);
+ }
else
{
delete_button->setLabel(_("Delete Configuration"));
@@ -160,7 +165,11 @@ void OptionsScreenDevice::init()
// Disable deletion keyboard configurations
bool in_game = StateManager::get()->getGameState() == GUIEngine::INGAME_MENU;
- getWidget("delete")->setActive(!in_game);
+
+ if (in_game)
+ {
+ getWidget("delete")->setActive(false);
+ }
} // init
// -----------------------------------------------------------------------------
diff --git a/src/states_screens/options_screen_input.cpp b/src/states_screens/options_screen_input.cpp
index 92ea2599c..b86b00e79 100644
--- a/src/states_screens/options_screen_input.cpp
+++ b/src/states_screens/options_screen_input.cpp
@@ -89,15 +89,26 @@ void OptionsScreenInput::buildDeviceList()
for (int i=0; igetDeviceList()->getKeyboardConfig(i);
-
+ KeyboardConfig *config = device_manager->getKeyboardConfig(i);
+
std::ostringstream kbname;
kbname << "keyboard" << i;
const std::string internal_name = kbname.str();
-
- // since irrLicht's list widget has the nasty tendency to put the
- // icons very close to the text, I'm adding spaces to compensate.
- devices->addItem(internal_name, (core::stringw(" ") + _("Keyboard %i", i)).c_str(), 0 /* icon */);
+
+ if (config->isGamePadAndroid())
+ {
+ // since irrLicht's list widget has the nasty tendency to put the
+ // icons very close to the text, I'm adding spaces to compensate.
+ devices->addItem(internal_name, (core::stringw(" ") +
+ _("Gamepad")).c_str(), 1 /* icon */);
+ }
+ else
+ {
+ // since irrLicht's list widget has the nasty tendency to put the
+ // icons very close to the text, I'm adding spaces to compensate.
+ devices->addItem(internal_name, (core::stringw(" ") +
+ _("Keyboard %i", i)).c_str(), 0 /* icon */);
+ }
}
const int gpad_config_count = device_manager->getGamePadConfigAmount();
diff --git a/src/utils/translation.cpp b/src/utils/translation.cpp
index 39f7ca96a..ec4d43e71 100644
--- a/src/utils/translation.cpp
+++ b/src/utils/translation.cpp
@@ -45,6 +45,10 @@
#include "utils/constants.hpp"
#include "utils/log.hpp"
+#ifdef ANDROID
+#include "main_android.hpp"
+#endif
+
// set to 1 to debug i18n
#define TRANSLATE_VERBOSE 0
@@ -301,6 +305,24 @@ Translations::Translations() //: m_dictionary_manager("UTF-16")
"GetLocaleInfo tryname returns '%s'.", c);
if(c[0]) language += std::string("_")+c;
} // if c[0]
+
+#elif defined(ANDROID)
+ char p_language[3] = {};
+ AConfiguration_getLanguage(global_android_app->config, p_language);
+
+ if (p_language != NULL)
+ {
+ language += p_language;
+
+ char p_country[3] = {};
+ AConfiguration_getCountry(global_android_app->config, p_country);
+
+ if (p_country)
+ {
+ language += "_";
+ language += p_country;
+ }
+ }
#endif
} // neither LANGUAGE nor LANG defined