Index: configure =================================================================== --- configure (revision 54149) +++ configure (working copy) @@ -931,6 +931,11 @@ _host_cpu=arm _host_alias=arm-oe-linux-androideabi ;; +androidsdl) + _host_os=androidsdl + _host_cpu=arm + _host_alias=arm-eabi + ;; arm-riscos) _host_os=riscos _host_cpu=arm @@ -1205,9 +1210,9 @@ if test -n "$_host"; then # In cross-compiling mode, we cannot run the result - eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO.o -c tmp_cxx_compiler.cpp" 2> /dev/null && cc_check_clean tmp_cxx_compiler.cpp + eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO.o -c tmp_cxx_compiler.cpp" && cc_check_clean tmp_cxx_compiler.cpp else - eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO$HOSTEXEEXT tmp_cxx_compiler.cpp" 2> /dev/null && eval "$TMPO$HOSTEXEEXT 2> /dev/null" && cc_check_clean tmp_cxx_compiler.cpp + eval "$1 $CXXFLAGS $LDFLAGS -o $TMPO$HOSTEXEEXT tmp_cxx_compiler.cpp" && eval "$TMPO$HOSTEXEEXT 2> /dev/null" && cc_check_clean tmp_cxx_compiler.cpp fi } @@ -1433,6 +1438,11 @@ _unix=yes _seq_midi=no ;; + androidsdl) + CXXFLAGS="$CXXFLAGS -Os" + _unix=yes + _seq_midi=no + ;; beos*) DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE" # Needs -lbind -lsocket for the timidity MIDI driver @@ -1571,6 +1581,12 @@ _port_mk="backends/platform/android/android.mk" _seq_midi=no ;; + androidsdl) + DEFINES="$DEFINES -DANDROID" + _unix=yes + _need_memalign=yes + _seq_midi=no + ;; arm-linux|arm*-linux-gnueabi|arm-*-linux) _unix=yes _need_memalign=yes @@ -2112,7 +2128,7 @@ LIBS += -ldl ' ;; - linux*|android) + linux*|android|androidsdl) _def_plugin=' #define PLUGIN_PREFIX "lib" #define PLUGIN_SUFFIX ".so" @@ -2778,7 +2794,7 @@ case $_host_os in # newlib-based system include files suppress non-C89 function # declarations under __STRICT_ANSI__ - amigaos* | android | ds | dreamcast | gamecube | mingw* | n64 | psp | wii | wince ) + amigaos* | android | androidsdl | ds | dreamcast | gamecube | mingw* | n64 | psp | wii | wince ) CXXFLAGS="$CXXFLAGS -W -Wno-unused-parameter" ;; *) @@ -2799,7 +2815,7 @@ # Some platforms use certain GNU extensions in header files case $_host_os in -android | gamecube | psp | wii) +android | androidsdl | gamecube | psp | wii ) ;; *) CXXFLAGS="$CXXFLAGS -pedantic" Index: backends/platform/sdl/events.cpp =================================================================== --- backends/platform/sdl/events.cpp (revision 54149) +++ backends/platform/sdl/events.cpp (working copy) @@ -47,6 +47,9 @@ #define JOY_BUT_SPACE 4 #define JOY_BUT_F5 5 +#ifdef ANDROID +static int _lastEventFromKbdMouse = 0; +#endif @@ -347,8 +350,26 @@ return true; } +#ifdef ANDROID +static void MoveMouseWithArrowKeys(SDL_Event &ev, int x, int y) +{ + if( _lastEventFromKbdMouse && abs( ev.button.x - x ) < 50 && abs( ev.button.y - y ) < 50 ) + { + ev.button.x = x; + ev.button.y = y; + } + else + _lastEventFromKbdMouse = 0; +} +#endif + bool OSystem_SDL::handleMouseMotion(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_MOUSEMOVE; + +#ifdef ANDROID + MoveMouseWithArrowKeys(ev, _km.x, _km.y); +#endif + fillMouseEvent(event, ev.motion.x, ev.motion.y); setMousePos(event.mouse.x, event.mouse.y); @@ -373,6 +394,10 @@ else return false; +#ifdef ANDROID + MoveMouseWithArrowKeys(ev, _km.x, _km.y); +#endif + fillMouseEvent(event, ev.button.x, ev.button.y); return true; @@ -389,6 +414,11 @@ #endif else return false; + +#ifdef ANDROID + MoveMouseWithArrowKeys(ev, _km.x, _km.y); +#endif + fillMouseEvent(event, ev.button.x, ev.button.y); return true; @@ -569,5 +599,38 @@ event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); } #endif + +#ifdef ANDROID + if (ev.key.keysym.sym == SDLK_LEFT || ev.key.keysym.sym == SDLK_RIGHT || ev.key.keysym.sym == SDLK_UP || ev.key.keysym.sym == SDLK_DOWN) { + + if (ev.key.keysym.sym == SDLK_LEFT || ev.key.keysym.sym == SDLK_RIGHT) { + if (ev.type == SDL_KEYDOWN) { + _km.x_vel = (ev.key.keysym.sym == SDLK_LEFT ? -1 : 1); + _km.x_down_count = 1; + } else { + _km.x_vel = 0; + _km.x_down_count = 0; + } + } + + if (ev.key.keysym.sym == SDLK_UP || ev.key.keysym.sym == SDLK_DOWN) { + if (ev.type == SDL_KEYDOWN) { + _km.y_vel = (ev.key.keysym.sym == SDLK_UP ? -1 : 1); + _km.y_down_count = 1; + } else { + _km.y_vel = 0; + _km.y_down_count = 0; + } + } + + event.type = Common::EVENT_MOUSEMOVE; + fillMouseEvent(event, _km.x, _km.y); + setMousePos(event.mouse.x, event.mouse.y); + _lastEventFromKbdMouse = 1; + + return true; + } +#endif + return false; }