move mouse wakeup from SR to VG
[vg.git] / vg_input.c
index 3c138d0dad85b2e866153cbc3468e30c5340df51..c536c1f2ab2fd23446a2ca4778ef2ebc2a3f0d98 100644 (file)
@@ -210,10 +210,13 @@ void vg_process_inputs(void)
    vg_input.sdl_keys = SDL_GetKeyboardState( &count );
    vg_input.sdl_mouse = SDL_GetMouseState(NULL,NULL);
 
-   if( vg_input.display_input_method != k_input_method_kbm ){
+   if( vg_input.display_input_method != k_input_method_kbm )
+   {
       /* check for giving keyboard priority */
-      for( int i=0; i<count; i++ ){
-         if( vg_input.sdl_keys[i] ){
+      for( int i=0; i<count; i++ )
+      {
+         if( vg_input.sdl_keys[i] )
+         {
             vg_input.display_input_method = k_input_method_kbm;
             vg_info( "display_input: k_input_method_kbm (keyboard %d)\n", i );
             break;
@@ -226,9 +229,19 @@ void vg_process_inputs(void)
              SDL_BUTTON(SDL_BUTTON_MIDDLE)) )
       {
          vg_input.display_input_method = k_input_method_kbm;
-         vg_info( "display_input: k_input_method_kbm (mouse)\n" );
+         vg_info( "display_input: k_input_method_kbm (mouse click)\n" );
+      }
+
+      vg_input.hidden_mouse_travel += v2_length( vg.mouse_delta ); 
+      if( vg_input.hidden_mouse_travel > 64.0f )
+      {
+         vg_input.display_input_method = k_input_method_kbm;
+         vg_input.hidden_mouse_travel = 0.0f;
+         vg_info( "display_input: k_input_method_kbm (mouse move)\n" );
       }
    }
+   else
+      vg_input.hidden_mouse_travel = 0.0f;
 }
 
 void async_vg_input_init( void *payload, u32 size )
@@ -395,19 +408,19 @@ const char *controller_button_str( SDL_GameControllerButton button )
 {
    static const char *controller_glyphs[ SDL_CONTROLLER_BUTTON_MAX ][2] = {
                                              /* xbox/generic  playstation */
-      [ SDL_CONTROLLER_BUTTON_A ]            = { "\x1e\x85","\x1e\x82" },
-      [ SDL_CONTROLLER_BUTTON_B ]            = { "\x1e\x86","\x1e\x81" },
-      [ SDL_CONTROLLER_BUTTON_X ]            = { "\x1e\x83","\x1e\x7f" },
-      [ SDL_CONTROLLER_BUTTON_Y ]            = { "\x1e\x84","\x1e\x80" },
-      [ SDL_CONTROLLER_BUTTON_LEFTSTICK ]    = { "\x87",    "\x87" },
-      [ SDL_CONTROLLER_BUTTON_RIGHTSTICK ]   = { "\x8b",    "\x8b" },
-      [ SDL_CONTROLLER_BUTTON_LEFTSHOULDER ] = { "\x91",    "\x91" },
-      [ SDL_CONTROLLER_BUTTON_RIGHTSHOULDER ]= { "\x92",    "\x92" },
-      [ SDL_CONTROLLER_BUTTON_DPAD_LEFT ]    = { "\x1e\x93","\x1e\x93" },
-      [ SDL_CONTROLLER_BUTTON_DPAD_UP ]      = { "\x1e\x94","\x1e\x94" },
-      [ SDL_CONTROLLER_BUTTON_DPAD_RIGHT ]   = { "\x1e\x95","\x1e\x95" },
-      [ SDL_CONTROLLER_BUTTON_DPAD_DOWN ]    = { "\x1e\x96","\x1e\x96" },
-      [ SDL_CONTROLLER_BUTTON_GUIDE ]        = { "\x91",    "\x91" },
+      [ SDL_CONTROLLER_BUTTON_A ]            = { KGRN "\x06\x02\x85",KBLU "\x06\x02\x82" },
+      [ SDL_CONTROLLER_BUTTON_B ]            = { KRED "\x06\x02\x86",KRED "\x06\x02\x81" },
+      [ SDL_CONTROLLER_BUTTON_X ]            = { KBLU "\x06\x02\x83",KMAG "\x06\x02\x7f" },
+      [ SDL_CONTROLLER_BUTTON_Y ]            = { KYEL "\x06\x02\x84",KGRN "\x06\x02\x80" },
+      [ SDL_CONTROLLER_BUTTON_LEFTSTICK ]    = { "\x87","\x87" },
+      [ SDL_CONTROLLER_BUTTON_RIGHTSTICK ]   = { "\x8b","\x8b" },
+      [ SDL_CONTROLLER_BUTTON_LEFTSHOULDER ] = { "\x91","\x91" },
+      [ SDL_CONTROLLER_BUTTON_RIGHTSHOULDER ]= { "\x92","\x92" },
+      [ SDL_CONTROLLER_BUTTON_DPAD_LEFT ]    = { "\x93","\x93" },
+      [ SDL_CONTROLLER_BUTTON_DPAD_UP ]      = { "\x94","\x94" },
+      [ SDL_CONTROLLER_BUTTON_DPAD_RIGHT ]   = { "\x95","\x95" },
+      [ SDL_CONTROLLER_BUTTON_DPAD_DOWN ]    = { "\x96","\x96" },
+      [ SDL_CONTROLLER_BUTTON_GUIDE ]        = { "\x91","\x91" },
    };
 
    if( vg_input.display_input_type == SDL_CONTROLLER_TYPE_PS3 ||
@@ -438,14 +451,7 @@ void vg_keyboard_key_string( vg_str *str, u32 key, int special_glyphs )
 {
    if( (key >= SDLK_a) && (key <= SDLK_z) ){
       key = (key-SDLK_a)+(u32)'A';
-
-      if( special_glyphs ){
-         vg_strcatch( str, '\x1f' );
-         vg_strcatch( str, key );
-         vg_strcatch( str, ' ' );
-      }
-      else
-         vg_strcatch( str, key );
+      vg_strcatch( str, key );
    }
    else if( (key == SDLK_LSHIFT) || (key == SDLK_RSHIFT) )
       vg_strcat( str, special_glyphs? "\x9e": "shift" );
@@ -460,13 +466,13 @@ void vg_keyboard_key_string( vg_str *str, u32 key, int special_glyphs )
    else if( key == SDLK_ESCAPE ) 
       vg_strcat( str, special_glyphs? "\xa3": "escape" );
    else if( key == SDLK_RIGHT )
-      vg_strcat( str, special_glyphs? "\x1f\x95 ": "right" );
+      vg_strcat( str, special_glyphs? "\x95 ": "right" );
    else if( key == SDLK_LEFT )
-      vg_strcat( str, special_glyphs? "\x1f\x93 ": "left" );
+      vg_strcat( str, special_glyphs? "\x93 ": "left" );
    else if( key == SDLK_UP )
-      vg_strcat( str, special_glyphs? "\x1f\x94 ": "up" );
+      vg_strcat( str, special_glyphs? "\x94 ": "up" );
    else if( key == SDLK_DOWN )
-      vg_strcat( str, special_glyphs? "\x1f\x96 ": "down" );
+      vg_strcat( str, special_glyphs? "\x96 ": "down" );
    else {
       vg_strcat( str, "keyboard key #" );
       vg_strcati32( str, key );