mirror of
https://github.com/xemu-project/imgui.git
synced 2024-11-23 10:19:46 +00:00
Backends: OSX: Build fIx. Made GetKeyName() input tolerant. Internals: added GetNavInputName().
This commit is contained in:
parent
e8172fdfbc
commit
956e03009a
@ -603,9 +603,10 @@ bool ImGui_ImplOSX_HandleEvent(NSEvent* event, NSView* view)
|
||||
if ([event isARepeat])
|
||||
return io.WantCaptureKeyboard;
|
||||
|
||||
int key_code = (int)[event keyCode];
|
||||
ImGuiKey key = ImGui_ImplOSX_KeyCodeToImGuiKey(key_code);
|
||||
io.AddKeyEvent(key, event.type == NSEventTypeKeyDown);
|
||||
io.SetKeyEventNativeData(key, (int)[event keyCode], -1); // To support legacy indexing (<1.87 user code)
|
||||
io.SetKeyEventNativeData(key, key_code, -1); // To support legacy indexing (<1.87 user code)
|
||||
|
||||
return io.WantCaptureKeyboard;
|
||||
}
|
||||
|
14
imgui.cpp
14
imgui.cpp
@ -7435,6 +7435,8 @@ const char* ImGui::GetKeyName(ImGuiKey key)
|
||||
#endif
|
||||
if (key == ImGuiKey_None)
|
||||
return "None";
|
||||
if (!IsNamedKey(key))
|
||||
return "Unknown";
|
||||
|
||||
return GKeyNames[key - ImGuiKey_NamedKey_BEGIN];
|
||||
}
|
||||
@ -9717,6 +9719,18 @@ static ImVec2 ImGui::NavCalcPreferredRefPos()
|
||||
}
|
||||
}
|
||||
|
||||
const char* ImGui::GetNavInputName(ImGuiNavInput n)
|
||||
{
|
||||
static const char* names[] =
|
||||
{
|
||||
"Activate", "Cancel", "Input", "Menu", "DpadLeft", "DpadRight", "DpadUp", "DpadDown", "LStickLeft", "LStickRight", "LStickUp", "LStickDown",
|
||||
"FocusPrev", "FocusNext", "TweakSlow", "TweakFast", "KeyLeft", "KeyRight", "KeyUp", "KeyDown"
|
||||
};
|
||||
IM_ASSERT(IM_ARRAYSIZE(names) == ImGuiNavInput_COUNT);
|
||||
IM_ASSERT(n >= 0 && n < ImGuiNavInput_COUNT);
|
||||
return names[n];
|
||||
}
|
||||
|
||||
float ImGui::GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
|
5
imgui.h
5
imgui.h
@ -65,7 +65,7 @@ Index of this file:
|
||||
// Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
||||
#define IMGUI_VERSION "1.87 WIP"
|
||||
#define IMGUI_VERSION_NUM 18604
|
||||
#define IMGUI_VERSION_NUM 18605
|
||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||
#define IMGUI_HAS_TABLE
|
||||
|
||||
@ -1523,8 +1523,7 @@ enum ImGuiNavInput_
|
||||
ImGuiNavInput_KeyRight_, // Move right
|
||||
ImGuiNavInput_KeyUp_, // Move up
|
||||
ImGuiNavInput_KeyDown_, // Move down
|
||||
ImGuiNavInput_COUNT,
|
||||
ImGuiNavInput_InternalStart_ = ImGuiNavInput_KeyLeft_
|
||||
ImGuiNavInput_COUNT
|
||||
};
|
||||
|
||||
// Configuration flags stored in io.ConfigFlags. Set by user/application.
|
||||
|
@ -2577,6 +2577,7 @@ namespace ImGui
|
||||
IMGUI_API void NavMoveRequestCancel();
|
||||
IMGUI_API void NavMoveRequestApplyResult();
|
||||
IMGUI_API void NavMoveRequestTryWrapping(ImGuiWindow* window, ImGuiNavMoveFlags move_flags);
|
||||
IMGUI_API const char* GetNavInputName(ImGuiNavInput n);
|
||||
IMGUI_API float GetNavInputAmount(ImGuiNavInput n, ImGuiInputReadMode mode);
|
||||
IMGUI_API ImVec2 GetNavInputAmount2d(ImGuiNavDirSourceFlags dir_sources, ImGuiInputReadMode mode, float slow_factor = 0.0f, float fast_factor = 0.0f);
|
||||
IMGUI_API int CalcTypematicRepeatAmount(float t0, float t1, float repeat_delay, float repeat_rate);
|
||||
|
Loading…
Reference in New Issue
Block a user