X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=vg%2Fvg_input.h;h=62d4690a68e2acfa2673a6af7e7992959d42ca82;hb=3363633178b1eea582304742ad1202487af0feb1;hp=4d1ac0e31f68fbc1035ec26b2606df62165959d0;hpb=27f1751d523e9dee4ab00ec10666bbb3d8db74bc;p=fishladder.git diff --git a/vg/vg_input.h b/vg/vg_input.h index 4d1ac0e..62d4690 100644 --- a/vg/vg_input.h +++ b/vg/vg_input.h @@ -5,6 +5,14 @@ static inline int vg_get_button( const char *button ) __attribute__((unused)); static inline int vg_get_button_down( const char *button ) __attribute__((unused)); static inline int vg_get_button_up( const char *button ) __attribute__((unused)); +enum vg_button_state +{ + k_button_state_down = 1, + k_button_state_up = 3, + k_button_state_pressed = 2, + k_button_state_none = 0 +}; + // Input // =========================================================================================================== GLFWgamepadstate vg_gamepad; @@ -70,21 +78,31 @@ static inline struct button_binding *vg_get_button_ptr( const char *button ) } #pragma GCC diagnostic pop +static int vg_console_enabled(void); + static inline int vg_get_button( const char *button ) { - return vg_get_button_ptr( button )->value; + return vg_get_button_ptr( button )->value && !vg_console_enabled(); } static inline int vg_get_button_down( const char *button ) { struct button_binding *bind = vg_get_button_ptr( button ); - return bind->value & (bind->value ^ bind->prev); + return bind->value & (bind->value ^ bind->prev) && !vg_console_enabled(); } static inline int vg_get_button_up( const char *button ) { struct button_binding *bind = vg_get_button_ptr( button ); - return bind->prev & (bind->value ^ bind->prev); + return bind->prev & (bind->value ^ bind->prev) && !vg_console_enabled(); +} + +static inline enum vg_button_state vg_get_button_state( const char *button ) +{ + if( vg_get_button_down( button ) ) return k_button_state_down; + if( vg_get_button_up( button ) ) return k_button_state_up; + if( vg_get_button( button ) ) return k_button_state_pressed; + return k_button_state_none; } static inline int key_is_keyboard( int const id )