@ -346,27 +346,26 @@ CODE
- You can ask questions and report issues at https : //github.com/ocornut/imgui/issues/787
- You can ask questions and report issues at https : //github.com/ocornut/imgui/issues/787
- The initial focus was to support game controllers , but keyboard is becoming increasingly and decently usable .
- The initial focus was to support game controllers , but keyboard is becoming increasingly and decently usable .
- Keyboard :
- Keyboard :
- Set io . ConfigFlags | = ImGuiConfigFlags_NavEnableKeyboard to enable .
- Application : Set io . ConfigFlags | = ImGuiConfigFlags_NavEnableKeyboard to enable .
NewFrame ( ) will automatically fill io . NavInputs [ ] based on your io . AddKeyEvent ( ) calls .
- Internally : NewFrame ( ) will automatically fill io . NavInputs [ ] based on backend' s io . AddKeyEvent ( ) calls .
- When keyboard navigation is active ( io . NavActive + ImGuiConfigFlags_NavEnableKeyboard ) , the io . WantCaptureKeyboard flag
- When keyboard navigation is active ( io . NavActive + ImGuiConfigFlags_NavEnableKeyboard ) ,
will be set . For more advanced uses , you may want to read from :
the io . WantCaptureKeyboard flag will be set . For more advanced uses , you may want to read from :
- io . NavActive : true when a window is focused and it doesn ' t have the ImGuiWindowFlags_NoNavInputs flag set .
- io . NavActive : true when a window is focused and it doesn ' t have the ImGuiWindowFlags_NoNavInputs flag set .
- io . NavVisible : true when the navigation cursor is visible ( and usually goes false when mouse is used ) .
- io . NavVisible : true when the navigation cursor is visible ( and usually goes false when mouse is used ) .
- or query focus information with e . g . IsWindowFocused ( ImGuiFocusedFlags_AnyWindow ) , IsItemFocused ( ) etc . functions .
- or query focus information with e . g . IsWindowFocused ( ImGuiFocusedFlags_AnyWindow ) , IsItemFocused ( ) etc . functions .
Please reach out if you think the game vs navigation input sharing could be improved .
Please reach out if you think the game vs navigation input sharing could be improved .
- Gamepad :
- Gamepad :
- Set io . ConfigFlags | = ImGuiConfigFlags_NavEnableGamepad to enable .
- Application : Set io . ConfigFlags | = ImGuiConfigFlags_NavEnableGamepad to enable .
- Backend : Set io . BackendFlags | = ImGuiBackendFlags_HasGamepad + fill the io . NavInputs [ ] fields before calling NewFrame ( ) .
- Backend : Set io . BackendFlags | = ImGuiBackendFlags_HasGamepad + call io . AddKeyEvent / AddKeyAnalogEvent ( ) with ImGuiKey_Gamepad_XXX keys .
Note that io . NavInputs [ ] is cleared by EndFrame ( ) .
For analog values ( 0.0f to 1.0f ) , backend is responsible to handling a dead - zone and rescaling inputs accordingly .
- See ' enum ImGuiNavInput_ ' in imgui . h for a description of inputs . For each entry of io . NavInputs [ ] , set the following values :
Backend code will probably need to transform your raw inputs ( such as e . g . remapping your 0.2 . .0 .9 raw input range to 0.0 . .1 .0 imgui range , etc . ) .
0.0f = not held . 1.0f = fully held . Pass intermediate 0.0f . .1 .0f values for analog triggers / sticks .
- Internally : NewFrame ( ) will automatically fill io . NavInputs [ ] based on backend ' s io . AddKeyEvent ( ) + io . AddKeyAnalogEvent ( ) calls .
- We use a simple > 0.0f test for activation testing , and won ' t attempt to test for a dead - zone .
- BEFORE 1.87 , BACKENDS USED TO WRITE DIRECTLY TO io . NavInputs [ ] . This is going to be obsoleted in the future . Please call io functions instead !
Your code will probably need to transform your raw inputs ( such as e . g . remapping your 0.2 . .0 .9 raw input range to 0.0 . .1 .0 imgui range , etc . ) .
- You can download PNG / PSD files depicting the gamepad controls for common controllers at : http : //dearimgui.org/controls_sheets
- You can download PNG / PSD files depicting the gamepad controls for common controllers at : http : //dearimgui.org/controls_sheets
- If you need to share inputs between your game and the imgui parts , the easiest approach is to go all - or - nothing , with a buttons combo
- If you need to share inputs between your game and the Dear ImGui interface , the easiest approach is to go all - or - nothing ,
to toggle the target . Please reach out if you think the game vs navigation input sharing could be improved .
with a buttons combo to toggle the target . Please reach out if you think the game vs navigation input sharing could be improved .
- Mouse :
- Mouse :
- PS4 users : Consider emulating a mouse cursor with DualShock4 touch pad or a spare analog stick as a mouse - emulation fallback .
- PS4 / PS5 users : Consider emulating a mouse cursor with DualShock4 touch pad or a spare analog stick as a mouse - emulation fallback .
- Consoles / Tablet / Phone users : Consider using a Synergy 1. x server ( on your PC ) + uSynergy . c ( on your console / tablet / phone app ) to share your PC mouse / keyboard .
- Consoles / Tablet / Phone users : Consider using a Synergy 1. x server ( on your PC ) + uSynergy . c ( on your console / tablet / phone app ) to share your PC mouse / keyboard .
- On a TV / console system where readability may be lower or mouse inputs may be awkward , you may want to set the ImGuiConfigFlags_NavEnableSetMousePos flag .
- On a TV / console system where readability may be lower or mouse inputs may be awkward , you may want to set the ImGuiConfigFlags_NavEnableSetMousePos flag .
Enabling ImGuiConfigFlags_NavEnableSetMousePos + ImGuiBackendFlags_HasSetMousePos instructs dear imgui to move your mouse cursor along with navigation movements .
Enabling ImGuiConfigFlags_NavEnableSetMousePos + ImGuiBackendFlags_HasSetMousePos instructs dear imgui to move your mouse cursor along with navigation movements .
@ -385,6 +384,8 @@ CODE
When you are not sure about an old symbol or function name , try using the Search / Find function of your IDE to look for comments or references in all imgui files .
When you are not sure about an old symbol or function name , try using the Search / Find function of your IDE to look for comments or references in all imgui files .
You can read releases logs https : //github.com/ocornut/imgui/releases for more details.
You can read releases logs https : //github.com/ocornut/imgui/releases for more details.
- 2022 / 01 / 20 ( 1.87 ) - inputs : reworded gamepad IO .
- Backend writing to io . NavInputs [ ] - > backend should call io . AddKeyEvent ( ) / io . AddKeyAnalogEvent ( ) with ImGuiKey_GamepadXXX values .
- 2022 / 01 / 19 ( 1.87 ) - sliders , drags : removed support for legacy arithmetic operators ( + , + - , * , / ) when inputing text . This doesn ' t break any api / code but a feature that used to be accessible by end - users ( which seemingly no one used ) .
- 2022 / 01 / 19 ( 1.87 ) - sliders , drags : removed support for legacy arithmetic operators ( + , + - , * , / ) when inputing text . This doesn ' t break any api / code but a feature that used to be accessible by end - users ( which seemingly no one used ) .
- 2022 / 01 / 17 ( 1.87 ) - inputs : reworked mouse IO .
- 2022 / 01 / 17 ( 1.87 ) - inputs : reworked mouse IO .
- Backend writing to io . MousePos - > backend should call io . AddMousePosEvent ( )
- Backend writing to io . MousePos - > backend should call io . AddMousePosEvent ( )
@ -1163,6 +1164,7 @@ ImGuiIO::ImGuiIO()
for ( int i = 0 ; i < IM_ARRAYSIZE ( KeysData ) ; i + + ) { KeysData [ i ] . DownDuration = KeysData [ i ] . DownDurationPrev = - 1.0f ; }
for ( int i = 0 ; i < IM_ARRAYSIZE ( KeysData ) ; i + + ) { KeysData [ i ] . DownDuration = KeysData [ i ] . DownDurationPrev = - 1.0f ; }
for ( int i = 0 ; i < IM_ARRAYSIZE ( NavInputsDownDuration ) ; i + + ) NavInputsDownDuration [ i ] = - 1.0f ;
for ( int i = 0 ; i < IM_ARRAYSIZE ( NavInputsDownDuration ) ; i + + ) NavInputsDownDuration [ i ] = - 1.0f ;
BackendUsingLegacyKeyArrays = ( ImS8 ) - 1 ;
BackendUsingLegacyKeyArrays = ( ImS8 ) - 1 ;
BackendUsingLegacyNavInputArray = true ; // assume using legacy array until proven wrong
}
}
// Pass in translated ASCII characters for text input.
// Pass in translated ASCII characters for text input.
@ -1255,7 +1257,8 @@ void ImGuiIO::ClearInputKeys()
// Queue a new key down/up event.
// Queue a new key down/up event.
// - ImGuiKey key: Translated key (as in, generally ImGuiKey_A matches the key end-user would use to emit an 'A' character)
// - ImGuiKey key: Translated key (as in, generally ImGuiKey_A matches the key end-user would use to emit an 'A' character)
// - bool down: Is the key down? use false to signify a key release.
// - bool down: Is the key down? use false to signify a key release.
void ImGuiIO : : AddKeyEvent ( ImGuiKey key , bool down )
// - float analog_value: 0.0f..1.0f
void ImGuiIO : : AddKeyAnalogEvent ( ImGuiKey key , bool down , float analog_value , ImGuiInputSource input_source )
{
{
//if (e->Down) { IMGUI_DEBUG_LOG("AddKeyEvent() Key='%s' %d, NativeKeycode = %d, NativeScancode = %d\n", ImGui::GetKeyName(e->Key), e->Down, e->NativeKeycode, e->NativeScancode); }
//if (e->Down) { IMGUI_DEBUG_LOG("AddKeyEvent() Key='%s' %d, NativeKeycode = %d, NativeScancode = %d\n", ImGui::GetKeyName(e->Key), e->Down, e->NativeKeycode, e->NativeScancode); }
if ( key = = ImGuiKey_None )
if ( key = = ImGuiKey_None )
@ -1263,6 +1266,7 @@ void ImGuiIO::AddKeyEvent(ImGuiKey key, bool down)
ImGuiContext & g = * GImGui ;
ImGuiContext & g = * GImGui ;
IM_ASSERT ( & g . IO = = this & & " Can only add events to current context. " ) ;
IM_ASSERT ( & g . IO = = this & & " Can only add events to current context. " ) ;
IM_ASSERT ( ImGui : : IsNamedKey ( key ) ) ; // Backend needs to pass a valid ImGuiKey_ constant. 0..511 values are legacy native key codes which are not accepted by this API.
IM_ASSERT ( ImGui : : IsNamedKey ( key ) ) ; // Backend needs to pass a valid ImGuiKey_ constant. 0..511 values are legacy native key codes which are not accepted by this API.
IM_ASSERT ( input_source = = ImGuiInputSource_Keyboard | | input_source = = ImGuiInputSource_Gamepad ) ;
// Verify that backend isn't mixing up using new io.AddKeyEvent() api and old io.KeysDown[] + io.KeyMap[] data.
// Verify that backend isn't mixing up using new io.AddKeyEvent() api and old io.KeysDown[] + io.KeyMap[] data.
# ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
# ifndef IMGUI_DISABLE_OBSOLETE_KEYIO
@ -1272,15 +1276,23 @@ void ImGuiIO::AddKeyEvent(ImGuiKey key, bool down)
IM_ASSERT ( KeyMap [ n ] = = - 1 & & " Backend needs to either only use io.AddKeyEvent(), either only fill legacy io.KeysDown[] + io.KeyMap[]. Not both! " ) ;
IM_ASSERT ( KeyMap [ n ] = = - 1 & & " Backend needs to either only use io.AddKeyEvent(), either only fill legacy io.KeysDown[] + io.KeyMap[]. Not both! " ) ;
BackendUsingLegacyKeyArrays = 0 ;
BackendUsingLegacyKeyArrays = 0 ;
# endif
# endif
if ( ImGui : : IsGamepadKey ( key ) )
BackendUsingLegacyNavInputArray = false ;
ImGuiInputEvent e ;
ImGuiInputEvent e ;
e . Type = ImGuiInputEventType_Key ;
e . Type = ImGuiInputEventType_Key ;
e . Source = ImGuiInputSource_Keyboard ;
e . Source = input_source ;
e . Key . Key = key ;
e . Key . Key = key ;
e . Key . Down = down ;
e . Key . Down = down ;
e . Key . AnalogValue = analog_value ;
g . InputEventsQueue . push_back ( e ) ;
g . InputEventsQueue . push_back ( e ) ;
}
}
void ImGuiIO : : AddKeyEvent ( ImGuiKey key , bool down , ImGuiInputSource input_source )
{
AddKeyAnalogEvent ( key , down , down ? 1.0f : 0.0f , input_source ) ;
}
// [Optional] Call after AddKeyEvent().
// [Optional] Call after AddKeyEvent().
// Specify native keycode, scancode + Specify index for legacy <1.87 IsKeyXXX() functions with native indices.
// Specify native keycode, scancode + Specify index for legacy <1.87 IsKeyXXX() functions with native indices.
// If you are writing a backend in 2022 or don't use IsKeyXXX() with native values that are not ImGuiKey values, you can avoid calling this.
// If you are writing a backend in 2022 or don't use IsKeyXXX() with native values that are not ImGuiKey values, you can avoid calling this.
@ -3355,7 +3367,7 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
if ( id )
if ( id )
{
{
g . ActiveIdIsAlive = id ;
g . ActiveIdIsAlive = id ;
g . ActiveIdSource = ( g . NavActivateId = = id | | g . NavActivateInputId = = id | | g . NavJustMovedToId = = id ) ? ImGuiInputSource_Nav : ImGuiInputSource_Mouse ;
g . ActiveIdSource = ( g . NavActivateId = = id | | g . NavActivateInputId = = id | | g . NavJustMovedToId = = id ) ? ( ImGuiInputSource ) ImGuiInputSource_Nav : ImGuiInputSource_Mouse ;
}
}
// Clear declaration of inputs claimed by the widget
// Clear declaration of inputs claimed by the widget
@ -3936,6 +3948,14 @@ static void ImGui::UpdateKeyboardInputs()
}
}
# endif
# endif
// Clear gamepad data if disabled
if ( ( io . BackendFlags & ImGuiBackendFlags_HasGamepad ) = = 0 )
for ( int i = ImGuiKey_Gamepad_BEGIN ; i < ImGuiKey_Gamepad_END ; i + + )
{
io . KeysData [ i - ImGuiKey_KeysData_OFFSET ] . Down = false ;
io . KeysData [ i - ImGuiKey_KeysData_OFFSET ] . AnalogValue = 0.0f ;
}
// Update keys
// Update keys
for ( int i = 0 ; i < IM_ARRAYSIZE ( io . KeysData ) ; i + + )
for ( int i = 0 ; i < IM_ARRAYSIZE ( io . KeysData ) ; i + + )
{
{
@ -7486,14 +7506,19 @@ static const char* const GKeyNames[] =
" Backslash " , " RightBracket " , " GraveAccent " , " CapsLock " , " ScrollLock " , " NumLock " , " PrintScreen " ,
" Backslash " , " RightBracket " , " GraveAccent " , " CapsLock " , " ScrollLock " , " NumLock " , " PrintScreen " ,
" Pause " , " Keypad0 " , " Keypad1 " , " Keypad2 " , " Keypad3 " , " Keypad4 " , " Keypad5 " , " Keypad6 " ,
" Pause " , " Keypad0 " , " Keypad1 " , " Keypad2 " , " Keypad3 " , " Keypad4 " , " Keypad5 " , " Keypad6 " ,
" Keypad7 " , " Keypad8 " , " Keypad9 " , " KeypadDecimal " , " KeypadDivide " , " KeypadMultiply " ,
" Keypad7 " , " Keypad8 " , " Keypad9 " , " KeypadDecimal " , " KeypadDivide " , " KeypadMultiply " ,
" KeypadSubtract " , " KeypadAdd " , " KeypadEnter " , " KeypadEqual "
" KeypadSubtract " , " KeypadAdd " , " KeypadEnter " , " KeypadEqual " ,
" GamepadStart " , " GamepadBack " , " GamepadFaceUp " , " GamepadFaceDown " , " GamepadFaceLeft " , " GamepadFaceRight " ,
" GamepadDpadUp " , " GamepadDpadDown " , " GamepadDpadLeft " , " GamepadDpadRight " ,
" GamepadL1 " , " GamepadR1 " , " GamepadL2 " , " GamepadR2 " , " GamepadL3 " , " GamepadR3 " ,
" GamepadLStickUp " , " GamepadLStickDown " , " GamepadLStickLeft " , " GamepadLStickRight " ,
" GamepadRStickUp " , " GamepadRStickDown " , " GamepadRStickLeft " , " GamepadRStickRight "
} ;
} ;
IM_STATIC_ASSERT ( ImGuiKey_NamedKey_COUNT = = IM_ARRAYSIZE ( GKeyNames ) ) ;
IM_STATIC_ASSERT ( ImGuiKey_NamedKey_COUNT = = IM_ARRAYSIZE ( GKeyNames ) ) ;
const char * ImGui : : GetKeyName ( ImGuiKey key )
const char * ImGui : : GetKeyName ( ImGuiKey key )
{
{
# ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
# ifdef IMGUI_DISABLE_OBSOLETE_KEYIO
IM_ASSERT ( IsNamedKey ( key ) & & " Support for user key indices was dropped in favor of ImGuiKey. Please update backend and user code. " ) ;
IM_ASSERT ( ( IsNamedKey ( key ) | | key = = ImGuiKey_None ) & & " Support for user key indices was dropped in favor of ImGuiKey. Please update backend and user code. " ) ;
# else
# else
if ( IsLegacyKey ( key ) )
if ( IsLegacyKey ( key ) )
{
{
@ -7782,12 +7807,13 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
IM_ASSERT ( e - > Key . Key ! = ImGuiKey_None ) ;
IM_ASSERT ( e - > Key . Key ! = ImGuiKey_None ) ;
const int keydata_index = ( e - > Key . Key - ImGuiKey_KeysData_OFFSET ) ;
const int keydata_index = ( e - > Key . Key - ImGuiKey_KeysData_OFFSET ) ;
ImGuiKeyData * keydata = & io . KeysData [ keydata_index ] ;
ImGuiKeyData * keydata = & io . KeysData [ keydata_index ] ;
if ( keydata - > Down ! = e - > Key . Down )
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
// Trickling Rule: Stop processing queued events if we got multiple action on the same button
if ( trickle_fast_inputs & & ( key_changed_mask . TestBit ( keydata_index ) | | text_inputed | | mouse_button_changed ! = 0 ) )
if ( trickle_fast_inputs & & keydata - > Down ! = e - > Key . Down & & ( key_changed_mask . TestBit ( keydata_index ) | | text_inputed | | mouse_button_changed ! = 0 ) )
break ;
break ;
keydata - > Down = e - > Key . Down ;
keydata - > Down = e - > Key . Down ;
keydata - > AnalogValue = e - > Key . AnalogValue ;
key_changed = true ;
key_changed = true ;
key_changed_mask . SetBit ( keydata_index ) ;
key_changed_mask . SetBit ( keydata_index ) ;
}
}
@ -7831,6 +7857,7 @@ void ImGui::UpdateInputEvents(bool trickle_fast_inputs)
}
}
// Record trail (for domain-specific applications wanting to access a precise trail)
// Record trail (for domain-specific applications wanting to access a precise trail)
//if (event_n != 0) IMGUI_DEBUG_LOG("Processed: %d / Remaining: %d\n", event_n, g.InputEventsQueue.Size - event_n);
for ( int n = 0 ; n < event_n ; n + + )
for ( int n = 0 ; n < event_n ; n + + )
g . InputEventsTrail . push_back ( g . InputEventsQueue [ n ] ) ;
g . InputEventsTrail . push_back ( g . InputEventsQueue [ n ] ) ;
@ -9986,18 +10013,35 @@ static void ImGui::NavUpdate()
io . WantSetMousePos = false ;
io . WantSetMousePos = false ;
//if (g.NavScoringDebugCount > 0) IMGUI_DEBUG_LOG("NavScoringDebugCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.NavScoringDebugCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest);
//if (g.NavScoringDebugCount > 0) IMGUI_DEBUG_LOG("NavScoringDebugCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.NavScoringDebugCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest);
// Update Gamepad->Nav inputs mapping
// Set input source as Gamepad when buttons are pressed (as some features differs when used with Gamepad vs Keyboard)
// Set input source as Gamepad when buttons are pressed (as some features differs when used with Gamepad vs Keyboard)
// (do it before we map Keyboard input!)
const bool nav_keyboard_active = ( io . ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard ) ! = 0 ;
const bool nav_gamepad_active = ( io . ConfigFlags & ImGuiConfigFlags_NavEnableGamepad ) ! = 0 & & ( io . BackendFlags & ImGuiBackendFlags_HasGamepad ) ! = 0 ;
const bool nav_gamepad_active = ( io . ConfigFlags & ImGuiConfigFlags_NavEnableGamepad ) ! = 0 & & ( io . BackendFlags & ImGuiBackendFlags_HasGamepad ) ! = 0 ;
if ( nav_gamepad_active & & g . NavInputSource ! = ImGuiInputSource_Gamepad )
if ( nav_gamepad_active & & g . IO . BackendUsingLegacyNavInputArray = = false )
{
{
if ( io . NavInputs [ ImGuiNavInput_Activate ] > 0.0f | | io . NavInputs [ ImGuiNavInput_Input ] > 0.0f | | io . NavInputs [ ImGuiNavInput_Cancel ] > 0.0f | | io . NavInputs [ ImGuiNavInput_Menu ] > 0.0f
for ( int n = 0 ; n < ImGuiNavInput_COUNT ; n + + )
| | io . NavInputs [ ImGuiNavInput_DpadLeft ] > 0.0f | | io . NavInputs [ ImGuiNavInput_DpadRight ] > 0.0f | | io . NavInputs [ ImGuiNavInput_DpadUp ] > 0.0f | | io . NavInputs [ ImGuiNavInput_DpadDown ] > 0.0f )
IM_ASSERT ( io . NavInputs [ n ] = = 0.0f & & " Backend needs to either only use io.AddKeyEvent()/io.AddKeyAnalogEvent(), either only fill legacy io.NavInputs[]. Not both! " ) ;
g . NavInputSource = ImGuiInputSource_Gamepad ;
# define NAV_MAP_KEY(_KEY, _NAV_INPUT, _ACTIVATE_NAV) do { io.NavInputs[_NAV_INPUT] = io.KeysData[_KEY - ImGuiKey_KeysData_OFFSET].AnalogValue; if (_ACTIVATE_NAV && io.NavInputs[_NAV_INPUT] > 0.0f) { g.NavInputSource = ImGuiInputSource_Gamepad; } } while (0)
NAV_MAP_KEY ( ImGuiKey_GamepadFaceDown , ImGuiNavInput_Activate , true ) ;
NAV_MAP_KEY ( ImGuiKey_GamepadFaceRight , ImGuiNavInput_Cancel , true ) ;
NAV_MAP_KEY ( ImGuiKey_GamepadFaceLeft , ImGuiNavInput_Menu , true ) ;
NAV_MAP_KEY ( ImGuiKey_GamepadFaceUp , ImGuiNavInput_Input , true ) ;
NAV_MAP_KEY ( ImGuiKey_GamepadDpadLeft , ImGuiNavInput_DpadLeft , true ) ;
NAV_MAP_KEY ( ImGuiKey_GamepadDpadRight , ImGuiNavInput_DpadRight , true ) ;
NAV_MAP_KEY ( ImGuiKey_GamepadDpadUp , ImGuiNavInput_DpadUp , true ) ;
NAV_MAP_KEY ( ImGuiKey_GamepadDpadDown , ImGuiNavInput_DpadDown , true ) ;
NAV_MAP_KEY ( ImGuiKey_GamepadL1 , ImGuiNavInput_FocusPrev , false ) ;
NAV_MAP_KEY ( ImGuiKey_GamepadR1 , ImGuiNavInput_FocusNext , false ) ;
NAV_MAP_KEY ( ImGuiKey_GamepadL1 , ImGuiNavInput_TweakSlow , false ) ;
NAV_MAP_KEY ( ImGuiKey_GamepadR1 , ImGuiNavInput_TweakFast , false ) ;
NAV_MAP_KEY ( ImGuiKey_GamepadLStickLeft , ImGuiNavInput_LStickLeft , false ) ;
NAV_MAP_KEY ( ImGuiKey_GamepadLStickRight , ImGuiNavInput_LStickRight , false ) ;
NAV_MAP_KEY ( ImGuiKey_GamepadLStickUp , ImGuiNavInput_LStickUp , false ) ;
NAV_MAP_KEY ( ImGuiKey_GamepadLStickDown , ImGuiNavInput_LStickDown , false ) ;
# undef NAV_MAP_KEY
}
}
// Update Keyboard->Nav inputs mapping
// Update Keyboard->Nav inputs mapping
const bool nav_keyboard_active = ( io . ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard ) ! = 0 ;
if ( nav_keyboard_active )
if ( nav_keyboard_active )
{
{
# define NAV_MAP_KEY(_KEY, _NAV_INPUT) do { if (IsKeyDown(_KEY)) { io.NavInputs[_NAV_INPUT] = 1.0f; g.NavInputSource = ImGuiInputSource_Keyboard; } } while (0)
# define NAV_MAP_KEY(_KEY, _NAV_INPUT) do { if (IsKeyDown(_KEY)) { io.NavInputs[_NAV_INPUT] = 1.0f; g.NavInputSource = ImGuiInputSource_Keyboard; } } while (0)