assorted
[vg.git] / src / vg / vg.h
index 61db7d6e0f83e802ee85f943f5932e84501de00b..77d27e2fb9f80553cacad4469608b79f82a4678d 100644 (file)
@@ -84,7 +84,9 @@ struct vg
        samples;
    float refresh_rate;
 
-   v2f mouse,
+   double mouse_pos[2];
+   v2f 
+       mouse_delta,
        mouse_wheel;
 
    /* Runtime */
@@ -122,6 +124,7 @@ struct vg
    int                               gamepad_ready;
    const char       *gamepad_name;
    int                               gamepad_id;
+   int               gamepad_use_trackpad_look;
 }
 VG_STATIC vg = { .time_rate = 1.0 };
 
@@ -332,8 +335,11 @@ VG_STATIC void vg_checkgl( const char *src_info )
 
 void vg_mouse_callback( GLFWwindow* ptrW, double xpos, double ypos )
 {
-   vg.mouse[0] = xpos;
-   vg.mouse[1] = ypos;
+   vg.mouse_delta[0] += xpos - vg.mouse_pos[0];
+   vg.mouse_delta[1] += ypos - vg.mouse_pos[1];
+
+   vg.mouse_pos[0] = xpos;
+   vg.mouse_pos[1] = ypos;
 }
 
 void vg_scroll_callback( GLFWwindow* ptrW, double xoffset, double yoffset )
@@ -498,7 +504,10 @@ VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name )
    
    glfwSetCharCallback( vg.window, console_proc_wchar );
    glfwSetKeyCallback( vg.window, console_proc_key );
-   glfwSetInputMode( vg.window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN );
+   glfwSetInputMode( vg.window, GLFW_CURSOR, GLFW_CURSOR_DISABLED );
+
+   if( glfwRawMouseMotionSupported() )
+      glfwSetInputMode( vg.window, GLFW_RAW_MOUSE_MOTION, GLFW_TRUE );
 
    if( !gladLoadGLLoader((GLADloadproc)glfwGetProcAddress) ) 
    {
@@ -529,7 +538,9 @@ VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name )
       if( glfwWindowShouldClose( vg.window ) )
          break;
 
-      v2_copy( (v2f){ 0.0f, 0.0f }, vg.mouse_wheel );
+      v2_zero( vg.mouse_wheel );
+      v2_zero( vg.mouse_delta );
+
       glfwPollEvents();
 
       vg.time_real_last = vg.time_real;
@@ -605,8 +616,9 @@ VG_STATIC void vg_enter( int argc, char *argv[], const char *window_name )
          vg.engine_stage = k_engine_stage_ui;
          {
             ui_begin( vg.window_x, vg.window_y );
-            ui_set_mouse( vg.mouse[0], vg.mouse[1], 
-                           vg_get_button_state( "primary" ) );
+
+            /* TODO */
+            ui_set_mouse( vg.mouse_pos[0], vg.mouse_pos[1], 0 );
             
             vg_profile_drawn( 
                   (struct vg_profile *[]){&vg_prof_update,&vg_prof_render}, 2,