diff options
author | norad <norad@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2011-03-28 15:19:49 +0000 |
---|---|---|
committer | norad <norad@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2011-03-28 15:19:49 +0000 |
commit | 1f9691c6ae69f626aa00b7e35623cc7786409f3b (patch) | |
tree | 703595f75c5bf9f895f06389c2ca7e759299f42d /navit/graphics/sdl | |
parent | 6b94c96739199b90b2b7b1ce06319503c440ccbc (diff) | |
download | navit-svn-1f9691c6ae69f626aa00b7e35623cc7786409f3b.tar.gz |
Patch:graphics/sdl:Reenable switching between landscape and portrait view using the accelerometer on WebOS>=2.0
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@4397 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/graphics/sdl')
-rw-r--r-- | navit/graphics/sdl/graphics_sdl.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/navit/graphics/sdl/graphics_sdl.c b/navit/graphics/sdl/graphics_sdl.c index 1b76a14b..b222f832 100644 --- a/navit/graphics/sdl/graphics_sdl.c +++ b/navit/graphics/sdl/graphics_sdl.c @@ -41,7 +41,7 @@ #ifdef USE_WEBOS # include "vehicle.h" # include <PDL.h> -//# define USE_WEBOS_ACCELEROMETER +# define USE_WEBOS_ACCELEROMETER #endif #define RASTER @@ -1588,10 +1588,14 @@ sdl_accelerometer_handler(void* param) int zAxis = SDL_JoystickGetAxis(gr->accelerometer, 2); char new_orientation; - if (xAxis < -15000 && yAxis > -7000 && yAxis < 7000) - new_orientation = WEBOS_ORIENTATION_LANDSCAPE; - else if (yAxis > 15000 && xAxis > -7000 && xAxis < 7000) - new_orientation = WEBOS_ORIENTATION_PORTRAIT; + if (zAxis > -30000) { + if (xAxis < -30000) + new_orientation = WEBOS_ORIENTATION_LANDSCAPE; + else if (yAxis > 30000) + new_orientation = WEBOS_ORIENTATION_PORTRAIT; + else + return; + } else return; @@ -1742,8 +1746,12 @@ static gboolean graphics_sdl_idle(void *data) #endif #ifdef USE_WEBOS_ACCELEROMETER - struct callback* accel_cb = callback_new_1(callback_cast(sdl_accelerometer_handler), gr); - struct event_timeout* accel_to = event_add_timeout(200, 1, accel_cb); + struct callback* accel_cb = NULL; + struct event_timeout* accel_to = NULL; + if (PDL_GetPDKVersion() > 100) { + accel_cb = callback_new_1(callback_cast(sdl_accelerometer_handler), gr); + accel_to = event_add_timeout(200, 1, accel_cb); + } #endif #ifdef USE_WEBOS unsigned int idle_tasks_idx=0; @@ -2087,8 +2095,10 @@ static gboolean graphics_sdl_idle(void *data) #endif #ifdef USE_WEBOS_ACCELEROMETER - event_remove_timeout(accel_to); - callback_destroy(accel_cb); + if (PDL_GetPDKVersion() > 100) { + event_remove_timeout(accel_to); + callback_destroy(accel_cb); + } #endif return TRUE; |