From: Holger Schemel Date: Tue, 12 Jun 2018 20:03:51 +0000 (+0200) Subject: added event actions (by simulating keyboard input) for global animations X-Git-Tag: 4.1.1.0~129 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=1c9456dab9709209a2462afe72c65373a1294de5 added event actions (by simulating keyboard input) for global animations This change adds more event actions to the "anim_event_action" option for clickable global animations, this time adding simulated keyboard input by specifying a key symbol for the key to be simulated. For example, you can now use: global.anim_1.part_1.MAIN.anim_event: click global.anim_1.part_1.MAIN.anim_event_action: XK_Return When clicking this global animation (on the main menu screen), the currently selected/highlighted menu item will be chosen/executed. To get the key symbol/name for the key to be simulated, just choose the desired key as a keyboard shortcut in the setup menu (temporarily only) and look at the resulting entry in the file "setup.conf" in the game's configuration and personal data directory. --- diff --git a/src/anim.c b/src/anim.c index d81a0746..0a278aa3 100644 --- a/src/anim.c +++ b/src/anim.c @@ -14,6 +14,7 @@ #include "anim.h" #include "main.h" #include "tools.h" +#include "events.h" #include "screens.h" @@ -1452,7 +1453,8 @@ static boolean DoGlobalAnim_EventAction(struct GlobalAnimPartControlInfo *part) return FALSE; boolean action_executed = (DoGadgetAction(anim_event_action) || - DoScreenAction(anim_event_action)); + DoScreenAction(anim_event_action) || + DoKeysymAction(anim_event_action)); // check if further actions are allowed to be executed if (part->control_info.style & STYLE_MULTIPLE_ACTIONS) diff --git a/src/events.c b/src/events.c index 146689f6..0e899a5b 100644 --- a/src/events.c +++ b/src/events.c @@ -2496,3 +2496,18 @@ void HandleSpecialGameControllerKeys(Key key, int key_status) #endif #endif } + +boolean DoKeysymAction(int keysym) +{ + if (keysym < 0) + { + Key key = (Key)(-keysym); + + HandleKey(key, KEY_PRESSED); + HandleKey(key, KEY_RELEASED); + + return TRUE; + } + + return FALSE; +} diff --git a/src/events.h b/src/events.h index 83d869ad..9672029f 100644 --- a/src/events.h +++ b/src/events.h @@ -46,4 +46,6 @@ void HandleJoystick(); void HandleSpecialGameControllerButtons(Event *); void HandleSpecialGameControllerKeys(Key, int); +boolean DoKeysymAction(int); + #endif diff --git a/src/libgame/misc.c b/src/libgame/misc.c index fb265fab..6432523e 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -2819,6 +2819,14 @@ int get_anim_action_parameter_value(char *token) checked_free(gfx_token); } + if (result == -1) + { + Key key = getKeyFromX11KeyName(token); + + if (key != KSYM_UNDEFINED) + result = -(int)key; + } + if (result == -1) result = ANIM_EVENT_ACTION_NONE; @@ -2909,7 +2917,7 @@ int get_parameter_value(char *value_raw, char *suffix, int type) else if (strEqual(suffix, ".init_event_action") || strEqual(suffix, ".anim_event_action")) { - result = get_anim_action_parameter_value(value); + result = get_anim_action_parameter_value(value_raw); } else if (strEqual(suffix, ".class")) {