mc 1.9
[vg.git] / src / vg / vg_input.h
index 8c43550e0e074ec908ca6a99d594cf4392dc9f47..4818d52ab099c3aa10813e93104522cdc00f7eb9 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2021 Harry Godden (hgn) - All Rights Reserved
+/* Copyright (C) 2021-2022 Harry Godden (hgn) - All Rights Reserved */
 
-static inline float vg_get_axis( const char *axis ) __attribute__((unused));
-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));
+static inline float vg_get_axis( const char *axis );
+static inline int vg_get_button( const char *button );
+static inline int vg_get_button_down( const char *button );
+static inline int vg_get_button_up( const char *button );
 
 enum vg_button_state
 {
@@ -13,13 +13,12 @@ enum vg_button_state
        k_button_state_none = 0
 };
 
-// Input
-// ===========================================================================================================
 GLFWgamepadstate vg_gamepad;
 int                    vg_gamepad_ready = 0;
 const char *vg_gamepad_name = NULL;
 int                    vg_gamepad_id;
 
+/* TODO: Fix this... */
 enum EInputMode
 {
        k_EInputMode_pc,
@@ -34,6 +33,7 @@ static struct axis_binding
        {
                int positive;
                int bind;
+      int axis;
        };
        int negative;
        
@@ -68,9 +68,9 @@ static inline float vg_get_axis( const char *axis )
 
 static inline struct button_binding *vg_get_button_ptr( const char *button )
 {
-       for( int i = 0; i < vg_list_size( vg_button_binds ); i ++ )
+       for( int i=0; i<vg_list_size(vg_button_binds); i ++ )
        {
-               if( !strcmp( button, vg_button_binds[i].name ) )
+               if( !strcmp(button,vg_button_binds[i].name) )
                {
                        return vg_button_binds + i;
                }
@@ -99,34 +99,30 @@ static inline int vg_get_button_up( const char *button )
 
 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;
+       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 )
 {
-       vg_static_assert( GLFW_MOUSE_BUTTON_LAST < GLFW_KEY_SPACE, "GLFW: Mouse has too many buttons" );
+       vg_static_assert( GLFW_MOUSE_BUTTON_LAST < GLFW_KEY_SPACE, 
+         "GLFW: Mouse has too many buttons" );
        return id > GLFW_MOUSE_BUTTON_LAST;
 }
 
-// Mouse AND Keyboard get button press
 int get_button_cross_device( int const id )
 {
        if( key_is_keyboard( id ) )
-       {
                return glfwGetKey( vg_window, id );
-       }
        else
-       {
                return glfwGetMouseButton( vg_window, id ) == GLFW_PRESS;
-       }
 }
 
 void vg_update_inputs(void)
 {
-       // Update button inputs
+       /* Update button inputs */
        for( int i = 0; i < vg_list_size( vg_button_binds ); i ++ )
        {
                struct button_binding *binding = vg_button_binds + i;
@@ -142,7 +138,7 @@ void vg_update_inputs(void)
                }
        }
        
-       // Update axis inputs
+       /* Update axis inputs */
        for( int i = 0; i < vg_list_size( vg_axis_binds ); i ++ )
        {
                struct axis_binding *binding = vg_axis_binds + i;