diff options
| author | Andreas Haas | 2016-09-15 19:30:35 +0200 |
|---|---|---|
| committer | Rémi Verschelde | 2016-10-09 17:16:19 +0200 |
| commit | e788ffff65ca65b6fd8dd84b3822d74e330d68c7 (patch) | |
| tree | 7e02d21c933955802cc263f92a62e6106809389f /core | |
| parent | 6a0d47f34cdbbcfcf19eaa79de410814c841ce21 (diff) | |
| download | godot-e788ffff65ca65b6fd8dd84b3822d74e330d68c7.tar.gz godot-e788ffff65ca65b6fd8dd84b3822d74e330d68c7.tar.zst godot-e788ffff65ca65b6fd8dd84b3822d74e330d68c7.zip | |
Diffstat (limited to 'core')
| -rw-r--r-- | core/input_map.cpp | 58 | ||||
| -rw-r--r-- | core/input_map.h | 1 | ||||
| -rw-r--r-- | core/os/input_event.cpp | 2 |
3 files changed, 1 insertions, 60 deletions
diff --git a/core/input_map.cpp b/core/input_map.cpp index 08ee8138a..37f4a2965 100644 --- a/core/input_map.cpp +++ b/core/input_map.cpp @@ -232,64 +232,6 @@ bool InputMap::event_is_action(const InputEvent& p_event, const StringName& p_ac return _find_event(E->get().inputs,p_event)!=NULL; } -bool InputMap::event_is_joy_motion_action_pressed(const InputEvent& p_event) const { - - ERR_FAIL_COND_V(p_event.type!=InputEvent::JOYSTICK_MOTION,false); - bool pressed=false; - - //this could be optimized by having a separate list of joymotions? - - for (Map<StringName, Action>::Element *A=input_map.front();A;A=A->next()) { - - for (List<InputEvent>::Element *E=A->get().inputs.front();E;E=E->next()) { - - const InputEvent& e=E->get(); - if(e.type!=p_event.type) - continue; - if (e.type!=InputEvent::KEY && e.device!=p_event.device) - continue; - - switch(p_event.type) { - - case InputEvent::KEY: { - - if (e.key.scancode==p_event.key.scancode && e.key.mod == p_event.key.mod) - return e.key.pressed; - - } break; - case InputEvent::JOYSTICK_BUTTON: { - - if (e.joy_button.button_index==p_event.joy_button.button_index) { - return e.joy_button.pressed; - } - - } break; - case InputEvent::MOUSE_BUTTON: { - - if (e.mouse_button.button_index==p_event.mouse_button.button_index) { - return e.mouse_button.pressed; - } - - } break; - case InputEvent::JOYSTICK_MOTION: { - - if (e.joy_motion.axis==p_event.joy_motion.axis) { - if ( - (e.joy_motion.axis_value * p_event.joy_motion.axis_value >0) && //same axis - ABS(e.joy_motion.axis_value)>0.5 && ABS(p_event.joy_motion.axis_value)>0.5 ) - pressed=true; - } - - } break; - } - - } - } - - return pressed; - -} - void InputMap::load_from_globals() { input_map.clear();; diff --git a/core/input_map.h b/core/input_map.h index dc5a91196..c46510ec0 100644 --- a/core/input_map.h +++ b/core/input_map.h @@ -70,7 +70,6 @@ public: const List<InputEvent> *get_action_list(const StringName& p_action); bool event_is_action(const InputEvent& p_event, const StringName& p_action) const; - bool event_is_joy_motion_action_pressed(const InputEvent& p_event) const; void load_from_globals(); diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp index 9d920724e..9982767be 100644 --- a/core/os/input_event.cpp +++ b/core/os/input_event.cpp @@ -204,7 +204,7 @@ bool InputEvent::is_pressed() const { case MOUSE_BUTTON: return mouse_button.pressed; case JOYSTICK_BUTTON: return joy_button.pressed; case SCREEN_TOUCH: return screen_touch.pressed; - case JOYSTICK_MOTION: return InputMap::get_singleton()->event_is_joy_motion_action_pressed(*this); + case JOYSTICK_MOTION: return ABS(joy_motion.axis_value) > 0.5; case ACTION: return action.pressed; default: {} } |
