diff --git a/exult.cc b/exult.cc index 104411b5..cc4f1789 100644 --- a/exult.cc +++ b/exult.cc @@ -1446,6 +1446,17 @@ static void Handle_event( } break; } +#ifdef __IPHONEOS__ + case SDL_FINGERDOWN: { + if (Mouse::is_finger == false) { + Mouse::is_finger = true; + SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "1"); + SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "1"); + gwin->set_painted(); + } + break; + } +#endif // two-finger scrolling of view port with SDL2. case SDL_FINGERMOTION: { if (!cheat() || !gwin->can_scroll_with_mouse()) break; @@ -1585,6 +1596,13 @@ static void Handle_event( case SDL_MOUSEMOTION: { int mx ; int my; +#ifdef __IPHONEOS__ + if (event.motion.which != SDL_TOUCH_MOUSEID) { + Mouse::is_finger = false; + SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0"); + SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0"); + } +#endif gwin->get_win()->screen_to_game(event.motion.x, event.motion.y, gwin->get_fastmouse(), mx, my); Mouse::mouse->move(mx, my); diff --git a/menulist.cc b/menulist.cc index 70a13368..152c6907 100644 --- a/menulist.cc +++ b/menulist.cc @@ -20,6 +20,7 @@ # include #endif +#include #include "menulist.h" #include "exult.h" #include "font.h" @@ -309,6 +310,13 @@ int MenuList::handle_events(Game_window *gwin, Mouse *mouse) { int gx; int gy; if (event.type == SDL_MOUSEMOTION) { +#ifdef __IPHONEOS__ + if (event.motion.which != SDL_TOUCH_MOUSEID) { + Mouse::is_finger = false; + SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0"); + SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0"); + } +#endif gwin->get_win()->screen_to_game(event.motion.x, event.motion.y, gwin->get_fastmouse(), gx, gy); if (!mouse_updated) mouse->hide(); mouse_updated = true; @@ -382,6 +390,15 @@ int MenuList::handle_events(Game_window *gwin, Mouse *mouse) { } else if (event.type == SDL_QUIT) { return -1; } +#ifdef __IPHONEOS__ + else if (event.type == SDL_FINGERDOWN) { + if (Mouse::is_finger == false) { + Mouse::is_finger = true; + SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "1"); + SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "1"); + } + } +#endif } if (mouse_updated) { mouse->show(); diff --git a/mouse.cc b/mouse.cc index ad8d848c..3c34fbb3 100644 --- a/mouse.cc +++ b/mouse.cc @@ -41,9 +41,13 @@ using std::max; #endif +#ifdef __IPHONEOS__ +bool Mouse::is_finger = true; +#endif static inline bool should_hide_frame(int frame) { #ifdef __IPHONEOS__ - return frame == 0 || (frame >=8 && frame <= 47); + if (Mouse::is_finger) + return frame == 0 || (frame >=8 && frame <= 47); #else ignore_unused_variable_warning(frame); return false; diff --git a/mouse.h b/mouse.h index 0eaf7a38..1582ba96 100644 --- a/mouse.h +++ b/mouse.h @@ -92,6 +92,9 @@ class Mouse { }; int avatar_speed; +#ifdef __IPHONEOS__ + static bool is_finger; +#endif static bool mouse_update; static Mouse *mouse;