Advertisement
dominus

Untitled

Jun 28th, 2021
1,525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.01 KB | None | 0 0
  1. diff --git a/exult.cc b/exult.cc
  2. index 104411b5..cc4f1789 100644
  3. --- a/exult.cc
  4. +++ b/exult.cc
  5. @@ -1446,6 +1446,17 @@ static void Handle_event(
  6.         }
  7.         break;
  8.     }
  9. +#ifdef __IPHONEOS__
  10. +   case SDL_FINGERDOWN: {
  11. +       if (Mouse::is_finger == false) {
  12. +           Mouse::is_finger = true;
  13. +           SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "1");
  14. +           SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "1");
  15. +           gwin->set_painted();
  16. +       }
  17. +       break;
  18. +   }
  19. +#endif
  20.     // two-finger scrolling of view port with SDL2.
  21.     case SDL_FINGERMOTION: {
  22.         if (!cheat() || !gwin->can_scroll_with_mouse()) break;
  23. @@ -1585,6 +1596,13 @@ static void Handle_event(
  24.     case SDL_MOUSEMOTION: {
  25.         int mx ;
  26.         int my;
  27. +#ifdef __IPHONEOS__
  28. +       if (event.motion.which != SDL_TOUCH_MOUSEID) {
  29. +           Mouse::is_finger = false;
  30. +           SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
  31. +           SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0");
  32. +       }
  33. +#endif
  34.         gwin->get_win()->screen_to_game(event.motion.x, event.motion.y, gwin->get_fastmouse(), mx, my);
  35.  
  36.         Mouse::mouse->move(mx, my);
  37. diff --git a/menulist.cc b/menulist.cc
  38. index 70a13368..152c6907 100644
  39. --- a/menulist.cc
  40. +++ b/menulist.cc
  41. @@ -20,6 +20,7 @@
  42.  #  include <config.h>
  43.  #endif
  44.  
  45. +#include <SDL.h>
  46.  #include "menulist.h"
  47.  #include "exult.h"
  48.  #include "font.h"
  49. @@ -309,6 +310,13 @@ int MenuList::handle_events(Game_window *gwin, Mouse *mouse) {
  50.             int gx;
  51.             int gy;
  52.             if (event.type == SDL_MOUSEMOTION) {
  53. +#ifdef __IPHONEOS__
  54. +               if (event.motion.which != SDL_TOUCH_MOUSEID) {
  55. +                   Mouse::is_finger = false;
  56. +                   SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "0");
  57. +                   SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "0");
  58. +               }
  59. +#endif
  60.                 gwin->get_win()->screen_to_game(event.motion.x, event.motion.y, gwin->get_fastmouse(), gx, gy);
  61.                 if (!mouse_updated) mouse->hide();
  62.                 mouse_updated = true;
  63. @@ -382,6 +390,15 @@ int MenuList::handle_events(Game_window *gwin, Mouse *mouse) {
  64.             } else if (event.type == SDL_QUIT) {
  65.                 return -1;
  66.             }
  67. +#ifdef __IPHONEOS__           
  68. +           else if (event.type == SDL_FINGERDOWN) {
  69. +               if (Mouse::is_finger == false) {
  70. +                   Mouse::is_finger = true;
  71. +                   SDL_SetHint(SDL_HINT_TOUCH_MOUSE_EVENTS, "1");
  72. +                   SDL_SetHint(SDL_HINT_MOUSE_TOUCH_EVENTS, "1");
  73. +               }
  74. +           }
  75. +#endif
  76.         }
  77.         if (mouse_updated) {
  78.             mouse->show();
  79. diff --git a/mouse.cc b/mouse.cc
  80. index ad8d848c..3c34fbb3 100644
  81. --- a/mouse.cc
  82. +++ b/mouse.cc
  83. @@ -41,9 +41,13 @@
  84.  using std::max;
  85.  #endif
  86.  
  87. +#ifdef __IPHONEOS__
  88. +bool Mouse::is_finger = true;
  89. +#endif
  90.  static inline bool should_hide_frame(int frame) {
  91.  #ifdef __IPHONEOS__
  92. -   return frame == 0 || (frame >=8 && frame <= 47);
  93. +   if (Mouse::is_finger)
  94. +       return frame == 0 || (frame >=8 && frame <= 47);
  95.  #else
  96.     ignore_unused_variable_warning(frame);
  97.     return false;
  98. diff --git a/mouse.h b/mouse.h
  99. index 0eaf7a38..1582ba96 100644
  100. --- a/mouse.h
  101. +++ b/mouse.h
  102. @@ -92,6 +92,9 @@ class Mouse {
  103.     };
  104.     int avatar_speed;
  105.  
  106. +#ifdef __IPHONEOS__
  107. +   static bool is_finger;
  108. +#endif
  109.     static bool mouse_update;
  110.     static Mouse *mouse;
  111.  
  112.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement