From 1a80b2a04a16f930e0d5cca4bdf322769d5a24f9 Mon Sep 17 00:00:00 2001 From: J08nY Date: Sat, 4 Jun 2016 17:55:09 +0200 Subject: Added InputMap.get_actions() get_actions() lists all actions in the InputMap. --- core/input_map.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'core/input_map.cpp') diff --git a/core/input_map.cpp b/core/input_map.cpp index 17e98902a..050623311 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -36,6 +36,7 @@ void InputMap::_bind_methods() { ObjectTypeDB::bind_method(_MD("has_action","action"),&InputMap::has_action); ObjectTypeDB::bind_method(_MD("get_action_id","action"),&InputMap::get_action_id); ObjectTypeDB::bind_method(_MD("get_action_from_id","id"),&InputMap::get_action_from_id); + ObjectTypeDB::bind_method(_MD("get_actions"),&InputMap::_get_actions); ObjectTypeDB::bind_method(_MD("add_action","action"),&InputMap::add_action); ObjectTypeDB::bind_method(_MD("erase_action","action"),&InputMap::erase_action); @@ -75,6 +76,35 @@ StringName InputMap::get_action_from_id(int p_id) const { return input_id_map[p_id]; } +Array InputMap::_get_actions() { + + Array ret; + List actions = get_actions(); + if(actions.empty()) + return ret; + + for(const List::Element *E=actions.front();E;E=E->next()) { + + ret.push_back(E->get()); + } + + return ret; +} + +List InputMap::get_actions() const { + + List actions = List(); + if(input_map.empty()){ + return actions; + } + + for (Map::Element *E=input_map.front();E;E=E->next()) { + actions.push_back(E->key()); + } + + return actions; +} + List::Element *InputMap::_find_event(List &p_list,const InputEvent& p_event) const { for (List::Element *E=p_list.front();E;E=E->next()) { -- cgit v1.2.3-70-g09d2