@ -7799,8 +7799,18 @@ static const char* GetInputSourceName(ImGuiInputSource source)
return input_source_names [ source ] ;
}
/*static void DebugLogInputEvent(const char* prefix, const ImGuiInputEvent* e)
{
if ( e - > Type = = ImGuiInputEventType_MousePos ) { IMGUI_DEBUG_LOG ( " %s: MousePos (%.1f %.1f) \n " , prefix , e - > MousePos . PosX , e - > MousePos . PosY ) ; return ; }
if ( e - > Type = = ImGuiInputEventType_MouseButton ) { IMGUI_DEBUG_LOG ( " %s: MouseButton %d %s \n " , prefix , e - > MouseButton . Button , e - > MouseButton . Down ? " Down " : " Up " ) ; return ; }
if ( e - > Type = = ImGuiInputEventType_MouseWheel ) { IMGUI_DEBUG_LOG ( " %s: MouseWheel (%.1f %.1f) \n " , prefix , e - > MouseWheel . WheelX , e - > MouseWheel . WheelY ) ; return ; }
if ( e - > Type = = ImGuiInputEventType_Key ) { IMGUI_DEBUG_LOG ( " %s: Key \" %s \" %s \n " , prefix , ImGui : : GetKeyName ( e - > Key . Key ) , e - > Key . Down ? " Down " : " Up " ) ; return ; }
if ( e - > Type = = ImGuiInputEventType_Text ) { IMGUI_DEBUG_LOG ( " %s: Text: %c (U+%08X) \n " , prefix , e - > Text . Char , e - > Text . Char ) ; return ; }
if ( e - > Type = = ImGuiInputEventType_Focus ) { IMGUI_DEBUG_LOG ( " %s: AppFocused %d \n " , prefix , e - > AppFocused . Focused ) ; return ; }
} */
// Process input queue
// We always call this with the value of 'bool g.IO.ConfigInputTrickleEventQueue'.
// - trickle_fast_inputs = false : process all events, turn into flattened input state (e.g. successive down/up/down/up will be lost)
// - trickle_fast_inputs = true : process as many events as possible (successive down/up/down/up will be trickled over several frames so nothing is lost) (new feature in 1.87)
void ImGui : : UpdateInputEvents ( bool trickle_fast_inputs )
@ -7808,7 +7818,12 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
ImGuiContext & g = * GImGui ;
ImGuiIO & io = g . IO ;
bool mouse_moved = false , mouse_wheeled = false , key_changed = false , text_inputed = false ;
// Only trickle chars<>key when working with InputText()
// FIXME: InputText() could parse event trail?
// FIXME: Could specialize chars<>keys trickling rules for control keys (those not typically associated to characters)
const bool trickle_interleaved_keys_and_text = ( trickle_fast_inputs & & g . WantTextInputNextFrame = = 1 ) ;
bool mouse_moved = false , mouse_wheeled = false , key_changed = false , text_inputted = false ;
int mouse_button_changed = 0x00 ;
ImBitArray < ImGuiKey_KeysData_SIZE > key_changed_mask ;
@ -7824,7 +7839,7 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
if ( io . MousePos . x ! = event_pos . x | | io . MousePos . y ! = event_pos . y )
{
// Trickling Rule: Stop processing queued events if we already handled a mouse button change
if ( trickle_fast_inputs & & ( mouse_button_changed ! = 0 | | mouse_wheeled | | key_changed | | text_input ed) )
if ( trickle_fast_inputs & & ( mouse_button_changed ! = 0 | | mouse_wheeled | | key_changed | | text_input t ed) )
break ;
io . MousePos = event_pos ;
mouse_moved = true ;
@ -7864,7 +7879,7 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
if ( keydata - > Down ! = e - > Key . Down | | keydata - > AnalogValue ! = e - > Key . AnalogValue )
{
// Trickling Rule: Stop processing queued events if we got multiple action on the same button
if ( trickle_fast_inputs & & keydata - > Down ! = e - > Key . Down & & ( key_changed_mask . TestBit ( keydata_index ) | | text_input ed | | mouse_button_changed ! = 0 ) )
if ( trickle_fast_inputs & & keydata - > Down ! = e - > Key . Down & & ( key_changed_mask . TestBit ( keydata_index ) | | text_input t ed | | mouse_button_changed ! = 0 ) )
break ;
keydata - > Down = e - > Key . Down ;
keydata - > AnalogValue = e - > Key . AnalogValue ;
@ -7891,11 +7906,12 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
else if ( e - > Type = = ImGuiInputEventType_Text )
{
// Trickling Rule: Stop processing queued events if keys/mouse have been interacted with
if ( trickle_fast_inputs & & ( key_changed | | mouse_button_changed ! = 0 | | mouse_moved | | mouse_wheeled ) )
if ( trickle_fast_inputs & & ( ( key_changed & & trickle_interleaved_keys_and_text ) | | mouse_button_changed ! = 0 | | mouse_moved | | mouse_wheeled ) )
break ;
unsigned int c = e - > Text . Char ;
io . InputQueueCharacters . push_back ( c < = IM_UNICODE_CODEPOINT_MAX ? ( ImWchar ) c : IM_UNICODE_CODEPOINT_INVALID ) ;
text_inputed = true ;
if ( trickle_interleaved_keys_and_text )
text_inputted = true ;
}
else if ( e - > Type = = ImGuiInputEventType_Focus )
{
@ -7914,6 +7930,11 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
for ( int n = 0 ; n < event_n ; n + + )
g . InputEventsTrail . push_back ( g . InputEventsQueue [ n ] ) ;
// [DEBUG]
/*if (event_n != 0)
for ( int n = 0 ; n < g . InputEventsQueue . Size ; n + + )
DebugLogInputEvent ( n < event_n ? " Processed " : " Remaining " , & g . InputEventsQueue [ n ] ) ; */
// Remaining events will be processed on the next frame
if ( event_n = = g . InputEventsQueue . Size )
g . InputEventsQueue . resize ( 0 ) ;