projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
removed experimental (Windows specific) drag and drop test code
[rocksndiamonds.git]
/
src
/
events.c
diff --git
a/src/events.c
b/src/events.c
index 0c5b2bc1354f5ad40477daa9ed5ccde37b3ff689..e770480d67a25c14b0b0e7f0bb3fd57172cba206 100644
(file)
--- a/
src/events.c
+++ b/
src/events.c
@@
-39,6
+39,8
@@
static int cursor_mode_last = CURSOR_DEFAULT;
static unsigned int special_cursor_delay = 0;
static unsigned int special_cursor_delay_value = 1000;
static unsigned int special_cursor_delay = 0;
static unsigned int special_cursor_delay_value = 1000;
+static boolean virtual_button_pressed = FALSE;
+
// forward declarations for internal use
static void HandleNoEvent(void);
// forward declarations for internal use
static void HandleNoEvent(void);
@@
-266,10
+268,6
@@
void HandleOtherEvents(Event *event)
HandleJoystickEvent(event);
break;
HandleJoystickEvent(event);
break;
- case SDL_SYSWMEVENT:
- HandleWindowManagerEvent(event);
- break;
-
default:
break;
}
default:
break;
}
@@
-722,6
+720,8
@@
static void HandleFingerEvent_VirtualButtons(FingerEvent *event)
"KEY_PRESSED");
int i;
"KEY_PRESSED");
int i;
+ virtual_button_pressed = (key_status == KEY_PRESSED && key != KSYM_UNDEFINED);
+
// for any touch input event, enable overlay buttons (if activated)
SetOverlayEnabled(TRUE);
// for any touch input event, enable overlay buttons (if activated)
SetOverlayEnabled(TRUE);
@@
-1452,9
+1452,15
@@
void HandleKeyEvent(KeyEvent *event)
// always map the "back" button to the "escape" key on Android devices
key = KSYM_Escape;
}
// always map the "back" button to the "escape" key on Android devices
key = KSYM_Escape;
}
+ else if (key == KSYM_Menu)
+ {
+ // the "menu" button can be used to toggle displaying virtual buttons
+ if (key_status == KEY_PRESSED)
+ SetOverlayEnabled(!GetOverlayEnabled());
+ }
else
{
else
{
- // for any
key event other than "back" button, disable overlay
buttons
+ // for any
other "real" key event, disable virtual
buttons
SetOverlayEnabled(FALSE);
}
#endif
SetOverlayEnabled(FALSE);
}
#endif
@@
-1512,11
+1518,6
@@
void HandleClientMessageEvent(ClientMessageEvent *event)
CloseAllAndExit(0);
}
CloseAllAndExit(0);
}
-void HandleWindowManagerEvent(Event *event)
-{
- SDLHandleWindowManagerEvent(event);
-}
-
void HandleButton(int mx, int my, int button, int button_nr)
{
static int old_mx = 0, old_my = 0;
void HandleButton(int mx, int my, int button, int button_nr)
{
static int old_mx = 0, old_my = 0;
@@
-1539,10
+1540,13
@@
void HandleButton(int mx, int my, int button, int button_nr)
#if defined(PLATFORM_ANDROID)
// when playing, only handle gadgets when using "follow finger" controls
// or when using touch controls in combination with the MM game engine
#if defined(PLATFORM_ANDROID)
// when playing, only handle gadgets when using "follow finger" controls
// or when using touch controls in combination with the MM game engine
+ // or when using gadgets that do not overlap with virtual buttons
handle_gadgets =
(game_status != GAME_MODE_PLAYING ||
level.game_engine_type == GAME_ENGINE_TYPE_MM ||
handle_gadgets =
(game_status != GAME_MODE_PLAYING ||
level.game_engine_type == GAME_ENGINE_TYPE_MM ||
- strEqual(setup.touch.control_type, TOUCH_CONTROL_FOLLOW_FINGER));
+ strEqual(setup.touch.control_type, TOUCH_CONTROL_FOLLOW_FINGER) ||
+ (strEqual(setup.touch.control_type, TOUCH_CONTROL_VIRTUAL_BUTTONS) &&
+ !virtual_button_pressed));
#endif
if (HandleGlobalAnimClicks(mx, my, button))
#endif
if (HandleGlobalAnimClicks(mx, my, button))
@@
-1778,11
+1782,14
@@
static void HandleKeysSpecial(Key key)
}
}
}
}
-
void HandleKeysDebug(Key key
)
+
boolean HandleKeysDebug(Key key, int key_status
)
{
#ifdef DEBUG
int i;
{
#ifdef DEBUG
int i;
+ if (key_status != KEY_PRESSED)
+ return FALSE;
+
if (game_status == GAME_MODE_PLAYING || !setup.debug.frame_delay_game_only)
{
boolean mod_key_pressed = ((GetKeyModState() & KMOD_Valid) != KMOD_None);
if (game_status == GAME_MODE_PLAYING || !setup.debug.frame_delay_game_only)
{
boolean mod_key_pressed = ((GetKeyModState() & KMOD_Valid) != KMOD_None);
@@
-1809,7
+1816,7
@@
void HandleKeysDebug(Key key)
else
Error(ERR_DEBUG, "frame delay == 0 ms (maximum speed)");
else
Error(ERR_DEBUG, "frame delay == 0 ms (maximum speed)");
-
break
;
+
return TRUE
;
}
}
}
}
}
}
@@
-1822,14
+1829,20
@@
void HandleKeysDebug(Key key)
Error(ERR_DEBUG, "debug mode %s",
(options.debug ? "enabled" : "disabled"));
Error(ERR_DEBUG, "debug mode %s",
(options.debug ? "enabled" : "disabled"));
+
+ return TRUE;
}
else if (key == KSYM_v)
{
Error(ERR_DEBUG, "currently using game engine version %d",
game.engine_version);
}
else if (key == KSYM_v)
{
Error(ERR_DEBUG, "currently using game engine version %d",
game.engine_version);
+
+ return TRUE;
}
}
#endif
}
}
#endif
+
+ return FALSE;
}
void HandleKey(Key key, int key_status)
}
void HandleKey(Key key, int key_status)
@@
-1856,6
+1869,9
@@
void HandleKey(Key key, int key_status)
int joy = 0;
int i;
int joy = 0;
int i;
+ if (HandleKeysDebug(key, key_status))
+ return; // do not handle already processed keys again
+
// map special keys (media keys / remote control buttons) to default keys
if (key == KSYM_PlayPause)
key = KSYM_space;
// map special keys (media keys / remote control buttons) to default keys
if (key == KSYM_PlayPause)
key = KSYM_space;
@@
-2198,8
+2214,6
@@
void HandleKey(Key key, int key_status)
return;
}
}
return;
}
}
-
- HandleKeysDebug(key);
}
void HandleNoEvent(void)
}
void HandleNoEvent(void)
@@
-2337,6
+2351,16
@@
void HandleJoystick(void)
return;
}
return;
}
+ if (newbutton && (game_status == GAME_MODE_PSEUDO_TYPENAME ||
+ anyTextGadgetActive()))
+ {
+ // leave name input in main menu or text input gadget
+ HandleKey(KSYM_Escape, KEY_PRESSED);
+ HandleKey(KSYM_Escape, KEY_RELEASED);
+
+ return;
+ }
+
if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
{
if (game_status == GAME_MODE_PLAYING)
if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
{
if (game_status == GAME_MODE_PLAYING)