New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow actions to provide an analog value #16902
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ class InputMap : public Object { | |
|
||
struct Action { | ||
int id; | ||
float deadzone; | ||
List<Ref<InputEvent> > inputs; | ||
}; | ||
|
||
|
@@ -54,7 +55,7 @@ class InputMap : public Object { | |
|
||
mutable Map<StringName, Action> input_map; | ||
|
||
List<Ref<InputEvent> >::Element *_find_event(List<Ref<InputEvent> > &p_list, const Ref<InputEvent> &p_event, bool p_action_test = false) const; | ||
List<Ref<InputEvent> >::Element *_find_event(Action p_action, const Ref<InputEvent> &p_event, bool *p_pressed = NULL, float *p_strength = NULL) const; | ||
|
||
Array _get_action_list(const StringName &p_action); | ||
Array _get_actions(); | ||
|
@@ -67,15 +68,17 @@ class InputMap : public Object { | |
|
||
bool has_action(const StringName &p_action) const; | ||
List<StringName> get_actions() const; | ||
void add_action(const StringName &p_action); | ||
void add_action(const StringName &p_action, float p_deadzone = 0.5); | ||
void erase_action(const StringName &p_action); | ||
|
||
void action_set_deadzone(const StringName &p_action, float p_deadzone); | ||
void action_add_event(const StringName &p_action, const Ref<InputEvent> &p_event); | ||
bool action_has_event(const StringName &p_action, const Ref<InputEvent> &p_event); | ||
void action_erase_event(const StringName &p_action, const Ref<InputEvent> &p_event); | ||
|
||
const List<Ref<InputEvent> > *get_action_list(const StringName &p_action); | ||
bool event_is_action(const Ref<InputEvent> &p_event, const StringName &p_action) const; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again, add float *r_strength=NULL, bool *r_pressed=NULL as extra optional arguments to event_is_action instead of adding all the functions below. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't do that, this function is exposed to GDscript which does not handles pointers. |
||
bool event_get_action_status(const Ref<InputEvent> &p_event, const StringName &p_action, bool *p_pressed = NULL, float *p_strength = NULL) const; | ||
|
||
const Map<StringName, Action> &get_action_map() const; | ||
void load_from_globals(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably just move this to InputEvent::action_match(), and pass deadzone, *pressed and *sterngth as optional arguments there , so we dont harcode it here.
This would add more flexibility for future events, and we could also use deadzone for InputEventJoyButton, which has pressure too on some controllers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't seen any progress on this either on this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same problem as with event_is_action, since action_match is bound to GDscript I cannot use pointers in the function arguments. I could duplicate the function though, like with event_get_action_status().