diff --git a/legacy/elementary/config/default/base.src b/legacy/elementary/config/default/base.src index 10866d3e1a..dad2675d86 100644 --- a/legacy/elementary/config/default/base.src +++ b/legacy/elementary/config/default/base.src @@ -880,6 +880,41 @@ group "Elm_Config" struct { } } } + group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Elm_Player"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "space"; + value "action" string: "play"; + value "params" string: ""; + } + } + } group "Elm_Config_Bindings_Widget" struct { value "name" string: "Elm_Scroller"; group "key_bindings" list { diff --git a/legacy/elementary/config/mobile/base.src b/legacy/elementary/config/mobile/base.src index 50bd082756..76226d6c38 100644 --- a/legacy/elementary/config/mobile/base.src +++ b/legacy/elementary/config/mobile/base.src @@ -884,6 +884,41 @@ group "Elm_Config" struct { } } } + group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Elm_Player"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "space"; + value "action" string: "play"; + value "params" string: ""; + } + } + } group "Elm_Config_Bindings_Widget" struct { value "name" string: "Elm_Scroller"; group "key_bindings" list { diff --git a/legacy/elementary/config/standard/base.src b/legacy/elementary/config/standard/base.src index bd7a1625c2..7c0a1a095f 100644 --- a/legacy/elementary/config/standard/base.src +++ b/legacy/elementary/config/standard/base.src @@ -881,6 +881,41 @@ group "Elm_Config" struct { } } } + group "Elm_Config_Bindings_Widget" struct { + value "name" string: "Elm_Player"; + group "key_bindings" list { + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Left"; + value "action" string: "move"; + value "params" string: "left"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "KP_Right"; + value "action" string: "move"; + value "params" string: "right"; + } + group "Elm_Config_Binding_Key" struct { + value "context" int: 0; + value "key" string: "space"; + value "action" string: "play"; + value "params" string: ""; + } + } + } group "Elm_Config_Bindings_Widget" struct { value "name" string: "Elm_Scroller"; group "key_bindings" list { diff --git a/legacy/elementary/src/lib/elc_player.c b/legacy/elementary/src/lib/elc_player.c index 0bf2b79f78..36fe2d3001 100644 --- a/legacy/elementary/src/lib/elc_player.c +++ b/legacy/elementary/src/lib/elc_player.c @@ -54,19 +54,22 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = { { NULL, NULL } }; -EOLIAN static Eina_Bool -_elm_player_elm_widget_event(Eo *obj, Elm_Player_Data *sd, Evas_Object *src, Evas_Callback_Type type, void *event_info) +static Eina_Bool _key_action_move(Evas_Object *obj, const char *params); +static Eina_Bool _key_action_play(Evas_Object *obj, const char *params); + +static const Elm_Action key_actions[] = { + {"move", _key_action_move}, + {"play", _key_action_play}, + {NULL, NULL} +}; + +static Eina_Bool +_key_action_move(Evas_Object *obj, const char *params) { - Evas_Event_Key_Down *ev = event_info; - (void) src; + ELM_PLAYER_DATA_GET(obj, sd); + const char *dir = params; - if (elm_widget_disabled_get(obj)) return EINA_FALSE; - if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE; - if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE; - if (!sd->video) return EINA_FALSE; - - if ((!strcmp(ev->key, "Left")) || - ((!strcmp(ev->key, "KP_Left")) && (!ev->string))) + if (!strcmp(dir, "left")) { double current, last; @@ -78,11 +81,8 @@ _elm_player_elm_widget_event(Eo *obj, Elm_Player_Data *sd, Evas_Object *src, Eva current -= last / 100; elm_video_play_position_set(sd->video, current); } - - goto success; } - else if ((!strcmp(ev->key, "Right")) || - ((!strcmp(ev->key, "KP_Right")) && (!ev->string))) + else if (!strcmp(dir, "right")) { double current, last; @@ -95,22 +95,39 @@ _elm_player_elm_widget_event(Eo *obj, Elm_Player_Data *sd, Evas_Object *src, Eva if (current < 0) current = 0; elm_video_play_position_set(sd->video, current); } - - goto success; } - else if (!strcmp(ev->key, "space")) - { - if (elm_video_is_playing_get(sd->video)) - elm_video_pause(sd->video); - else - elm_video_play(sd->video); + else return EINA_FALSE; - goto success; - } + return EINA_TRUE; +} - return EINA_FALSE; +static Eina_Bool +_key_action_play(Evas_Object *obj, const char *params EINA_UNUSED) +{ + ELM_PLAYER_DATA_GET(obj, sd); + + if (elm_video_is_playing_get(sd->video)) + elm_video_pause(sd->video); + else + elm_video_play(sd->video); + + return EINA_TRUE; +} + +EOLIAN static Eina_Bool +_elm_player_elm_widget_event(Eo *obj, Elm_Player_Data *sd, Evas_Object *src, Evas_Callback_Type type, void *event_info) +{ + Evas_Event_Key_Down *ev = event_info; + (void) src; + + if (elm_widget_disabled_get(obj)) return EINA_FALSE; + if (type != EVAS_CALLBACK_KEY_DOWN) return EINA_FALSE; + if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return EINA_FALSE; + if (!sd->video) return EINA_FALSE; + + if (!_elm_config_key_binding_call(obj, ev, key_actions)) + return EINA_FALSE; -success: ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; return EINA_TRUE; }