Skip to content

Commit

Permalink
It almost compiles
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaldaien committed Sep 30, 2023
1 parent 65bb08c commit c0a201d
Show file tree
Hide file tree
Showing 24 changed files with 385 additions and 136 deletions.
2 changes: 2 additions & 0 deletions include/imgui/imconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@
#define IM_MSVC_RUNTIME_CHECKS_OFF __pragma(runtime_checks("",off)) __pragma(check_stack(off)) __pragma(strict_gs_check(push,off))
#define IM_MSVC_RUNTIME_CHECKS_RESTORE __pragma(runtime_checks("",restore)) __pragma(check_stack()) __pragma(strict_gs_check(pop))

#include <SpecialK/utility.h>

// ImVec2: 2D vector used to store positions, sizes etc. [Compile-time configurable type]
// This is a frequently used type in the API. Consider using IM_VEC2_CLASS_EXTRA to create implicit cast from/to our preferred type.
IM_MSVC_RUNTIME_CHECKS_OFF
Expand Down
5 changes: 4 additions & 1 deletion include/imgui/imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ namespace ImGui
// Parameters stacks (shared)
IMGUI_API void PushFont(ImFont* font); // use NULL as a shortcut to push default font
IMGUI_API void PopFont();
//IMGUI_API void PushStyleColor(ImGuiCol idx, ImU32 col); // modify a style color. always use this if you modify the style after NewFrame().
IMGUI_API void PushStyleColor(ImGuiCol idx, ImU32 col); // modify a style color. always use this if you modify the style after NewFrame().
IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4& col);
IMGUI_API void PopStyleColor(int count = 1);
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val); // modify a style float variable. always use this if you modify the style after NewFrame().
Expand Down Expand Up @@ -3069,6 +3069,9 @@ namespace ImGui
#else
static inline ImGuiKey GetKeyIndex(ImGuiKey key) { IM_ASSERT(key >= ImGuiKey_NamedKey_BEGIN && key < ImGuiKey_NamedKey_END && "ImGuiKey and native_index was merged together and native_index is disabled by IMGUI_DISABLE_OBSOLETE_KEYIO. Please switch to ImGuiKey."); return key; }
#endif

// XXX: Special K Addition
IMGUI_API bool IsNavDragging (int stick_no, float lock_threshold);
}

#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
Expand Down
233 changes: 197 additions & 36 deletions include/imgui/imgui_user.inl
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,8 @@ ImGui_WndProcHandler ( HWND hWnd, UINT msg,

static POINTS last_pos;

ImGuiContext* SK_GImDefaultContext (void);

bool
MessageProc ( const HWND& hWnd,
const UINT& msg,
Expand Down Expand Up @@ -1831,15 +1833,13 @@ SK_ImGui_PollGamepad_EndFrame (XINPUT_STATE& state)
io.KeyCtrl = Ctrl;

bToggleNav |=
( SK_ImGui_Visible &&
io.KeysDown [VK_CAPITAL] &&
io.KeysDownDuration [VK_CAPITAL] == 0.0f );
( SK_ImGui_Visible &&
ImGui::IsKeyPressed (ImGuiKey_CapsLock, false) );

bToggleVis |=
( io.KeyCtrl &&
io.KeyShift &&
io.KeysDown [VK_BACK] &&
io.KeysDownDuration [VK_BACK] == 0.0f );
( io.KeyCtrl &&
io.KeyShift &&
ImGui::IsKeyPressed (ImGuiKey_Backspace, false) );
}

bool bUseGamepad =
Expand Down Expand Up @@ -2302,12 +2302,10 @@ SK_ImGui_PollGamepad (void)
if (io.NavActive)
{
io.NavInputs [ImGuiNavInput_FocusPrev] +=
(io.KeyCtrl && io.KeyShift && io.KeysDown [VK_TAB] &&
io.KeysDownDuration [VK_TAB] == 0.0f) ? 1.0f : 0.0f;

(io.KeyCtrl && io.KeyShift && ImGui::IsKeyPressed (ImGuiKey_Tab, false))
? 1.0f : 0.0f;
io.NavInputs [ImGuiNavInput_FocusNext] +=
(io.KeyCtrl && io.KeysDown [VK_TAB] &&
io.KeysDownDuration [VK_TAB] == 0.0f) ? 1.0f : 0.0f;
(io.KeyCtrl && ImGui::IsKeyPressed (ImGuiKey_Tab, false)) ? 1.0f : 0.0f;
}


Expand All @@ -2319,6 +2317,8 @@ SK_ImGui_PollGamepad (void)

static ULONG64 last_toggle = 0ULL;

/// FIXME
#if 0
if ( ( io.NavInputs [ImGuiNavInput_TweakSlow] != 0.0f &&
io.NavInputs [ImGuiNavInput_TweakFast] != 0.0f ) &&
( io.NavInputsDownDuration [ImGuiNavInput_TweakSlow] == 0.0f ||
Expand All @@ -2330,6 +2330,7 @@ SK_ImGui_PollGamepad (void)
last_toggle = SK_GetFramesDrawn ();
}
}
#endif
}


Expand Down Expand Up @@ -2444,7 +2445,7 @@ ImGui::PlotCEx ( ImGuiPlotType, const char* label,

RenderFrame ( frame_bb.Min,
frame_bb.Max,
GetStyleColorVec4 (ImGuiCol_FrameBg),
ImColor (GetStyleColorVec4 (ImGuiCol_FrameBg)),
true,
style.FrameRounding );

Expand Down Expand Up @@ -2657,6 +2658,122 @@ SK_ImGui_FallbackTrackMouseEvent (POINT& cursor_pos)
ImGui::GetIO ().MousePos = ImVec2 (-FLT_MAX, -FLT_MAX);
}

// There is no distinct VK_xxx for keypad enter, instead it is VK_RETURN + KF_EXTENDED, we assign it an arbitrary value to make code more readable (VK_ codes go up to 255)
#define IM_VK_KEYPAD_ENTER (VK_RETURN + 256)

// Map VK_xxx to ImGuiKey_xxx.
static ImGuiKey ImGui_ImplWin32_VirtualKeyToImGuiKey (WPARAM wParam)
{
switch (wParam)
{
case VK_TAB: return ImGuiKey_Tab;
case VK_LEFT: return ImGuiKey_LeftArrow;
case VK_RIGHT: return ImGuiKey_RightArrow;
case VK_UP: return ImGuiKey_UpArrow;
case VK_DOWN: return ImGuiKey_DownArrow;
case VK_PRIOR: return ImGuiKey_PageUp;
case VK_NEXT: return ImGuiKey_PageDown;
case VK_HOME: return ImGuiKey_Home;
case VK_END: return ImGuiKey_End;
case VK_INSERT: return ImGuiKey_Insert;
case VK_DELETE: return ImGuiKey_Delete;
case VK_BACK: return ImGuiKey_Backspace;
case VK_SPACE: return ImGuiKey_Space;
case VK_RETURN: return ImGuiKey_Enter;
case VK_ESCAPE: return ImGuiKey_Escape;
case VK_OEM_7: return ImGuiKey_Apostrophe;
case VK_OEM_COMMA: return ImGuiKey_Comma;
case VK_OEM_MINUS: return ImGuiKey_Minus;
case VK_OEM_PERIOD: return ImGuiKey_Period;
case VK_OEM_2: return ImGuiKey_Slash;
case VK_OEM_1: return ImGuiKey_Semicolon;
case VK_OEM_PLUS: return ImGuiKey_Equal;
case VK_OEM_4: return ImGuiKey_LeftBracket;
case VK_OEM_5: return ImGuiKey_Backslash;
case VK_OEM_6: return ImGuiKey_RightBracket;
case VK_OEM_3: return ImGuiKey_GraveAccent;
case VK_CAPITAL: return ImGuiKey_CapsLock;
case VK_SCROLL: return ImGuiKey_ScrollLock;
case VK_NUMLOCK: return ImGuiKey_NumLock;
case VK_SNAPSHOT: return ImGuiKey_PrintScreen;
case VK_PAUSE: return ImGuiKey_Pause;
case VK_NUMPAD0: return ImGuiKey_Keypad0;
case VK_NUMPAD1: return ImGuiKey_Keypad1;
case VK_NUMPAD2: return ImGuiKey_Keypad2;
case VK_NUMPAD3: return ImGuiKey_Keypad3;
case VK_NUMPAD4: return ImGuiKey_Keypad4;
case VK_NUMPAD5: return ImGuiKey_Keypad5;
case VK_NUMPAD6: return ImGuiKey_Keypad6;
case VK_NUMPAD7: return ImGuiKey_Keypad7;
case VK_NUMPAD8: return ImGuiKey_Keypad8;
case VK_NUMPAD9: return ImGuiKey_Keypad9;
case VK_DECIMAL: return ImGuiKey_KeypadDecimal;
case VK_DIVIDE: return ImGuiKey_KeypadDivide;
case VK_MULTIPLY: return ImGuiKey_KeypadMultiply;
case VK_SUBTRACT: return ImGuiKey_KeypadSubtract;
case VK_ADD: return ImGuiKey_KeypadAdd;
case IM_VK_KEYPAD_ENTER: return ImGuiKey_KeypadEnter;
case VK_LSHIFT: return ImGuiKey_LeftShift;
case VK_LCONTROL: return ImGuiKey_LeftCtrl;
case VK_LMENU: return ImGuiKey_LeftAlt;
case VK_LWIN: return ImGuiKey_LeftSuper;
case VK_RSHIFT: return ImGuiKey_RightShift;
case VK_RCONTROL: return ImGuiKey_RightCtrl;
case VK_RMENU: return ImGuiKey_RightAlt;
case VK_RWIN: return ImGuiKey_RightSuper;
case VK_APPS: return ImGuiKey_Menu;
case '0': return ImGuiKey_0;
case '1': return ImGuiKey_1;
case '2': return ImGuiKey_2;
case '3': return ImGuiKey_3;
case '4': return ImGuiKey_4;
case '5': return ImGuiKey_5;
case '6': return ImGuiKey_6;
case '7': return ImGuiKey_7;
case '8': return ImGuiKey_8;
case '9': return ImGuiKey_9;
case 'A': return ImGuiKey_A;
case 'B': return ImGuiKey_B;
case 'C': return ImGuiKey_C;
case 'D': return ImGuiKey_D;
case 'E': return ImGuiKey_E;
case 'F': return ImGuiKey_F;
case 'G': return ImGuiKey_G;
case 'H': return ImGuiKey_H;
case 'I': return ImGuiKey_I;
case 'J': return ImGuiKey_J;
case 'K': return ImGuiKey_K;
case 'L': return ImGuiKey_L;
case 'M': return ImGuiKey_M;
case 'N': return ImGuiKey_N;
case 'O': return ImGuiKey_O;
case 'P': return ImGuiKey_P;
case 'Q': return ImGuiKey_Q;
case 'R': return ImGuiKey_R;
case 'S': return ImGuiKey_S;
case 'T': return ImGuiKey_T;
case 'U': return ImGuiKey_U;
case 'V': return ImGuiKey_V;
case 'W': return ImGuiKey_W;
case 'X': return ImGuiKey_X;
case 'Y': return ImGuiKey_Y;
case 'Z': return ImGuiKey_Z;
case VK_F1: return ImGuiKey_F1;
case VK_F2: return ImGuiKey_F2;
case VK_F3: return ImGuiKey_F3;
case VK_F4: return ImGuiKey_F4;
case VK_F5: return ImGuiKey_F5;
case VK_F6: return ImGuiKey_F6;
case VK_F7: return ImGuiKey_F7;
case VK_F8: return ImGuiKey_F8;
case VK_F9: return ImGuiKey_F9;
case VK_F10: return ImGuiKey_F10;
case VK_F11: return ImGuiKey_F11;
case VK_F12: return ImGuiKey_F12;
default: return ImGuiKey_None;
}
}


void
SK_ImGui_User_NewFrame (void)
Expand Down Expand Up @@ -2684,27 +2801,71 @@ SK_ImGui_User_NewFrame (void)

delta = 0.0;

io.KeyMap [ImGuiKey_Tab] = VK_TAB;
io.KeyMap [ImGuiKey_LeftArrow] = VK_LEFT;
io.KeyMap [ImGuiKey_RightArrow] = VK_RIGHT;
io.KeyMap [ImGuiKey_UpArrow] = VK_UP;
io.KeyMap [ImGuiKey_DownArrow] = VK_DOWN;
io.KeyMap [ImGuiKey_PageUp] = VK_PRIOR;
io.KeyMap [ImGuiKey_PageDown] = VK_NEXT;
io.KeyMap [ImGuiKey_Home] = VK_HOME;
io.KeyMap [ImGuiKey_End] = VK_END;
io.KeyMap [ImGuiKey_Insert] = VK_INSERT;
io.KeyMap [ImGuiKey_Delete] = VK_DELETE;
io.KeyMap [ImGuiKey_Backspace] = VK_BACK;
io.KeyMap [ImGuiKey_Space] = VK_SPACE;
io.KeyMap [ImGuiKey_Enter] = VK_RETURN;
io.KeyMap [ImGuiKey_Escape] = VK_ESCAPE;
io.KeyMap [ImGuiKey_A] = 'A';
io.KeyMap [ImGuiKey_C] = 'C';
io.KeyMap [ImGuiKey_V] = 'V';
io.KeyMap [ImGuiKey_X] = 'X';
io.KeyMap [ImGuiKey_Y] = 'Y';
io.KeyMap [ImGuiKey_Z] = 'Z';
io.KeyMap [ImGuiKey_Tab] = VK_TAB;
io.KeyMap [ImGuiKey_LeftArrow] = VK_LEFT;
io.KeyMap [ImGuiKey_RightArrow] = VK_RIGHT;
io.KeyMap [ImGuiKey_UpArrow] = VK_UP;
io.KeyMap [ImGuiKey_DownArrow] = VK_DOWN;
io.KeyMap [ImGuiKey_PageUp] = VK_PRIOR;
io.KeyMap [ImGuiKey_PageDown] = VK_NEXT;
io.KeyMap [ImGuiKey_Home] = VK_HOME;
io.KeyMap [ImGuiKey_End] = VK_END;
io.KeyMap [ImGuiKey_Insert] = VK_INSERT;
io.KeyMap [ImGuiKey_Delete] = VK_DELETE;
io.KeyMap [ImGuiKey_Backspace] = VK_BACK;
io.KeyMap [ImGuiKey_Space] = VK_SPACE;
io.KeyMap [ImGuiKey_Enter] = VK_RETURN;
io.KeyMap [ImGuiKey_Escape] = VK_ESCAPE;
io.KeyMap [ImGuiKey_ScrollLock] = VK_SCROLL;
io.KeyMap [ImGuiKey_PrintScreen] = VK_PRINT;
io.KeyMap [ImGuiKey_Pause] = VK_PAUSE;
io.KeyMap [ImGuiKey_F1] = VK_F1;
io.KeyMap [ImGuiKey_F2] = VK_F2;
io.KeyMap [ImGuiKey_F3] = VK_F3;
io.KeyMap [ImGuiKey_F4] = VK_F4;
io.KeyMap [ImGuiKey_F5] = VK_F5;
io.KeyMap [ImGuiKey_F6] = VK_F6;
io.KeyMap [ImGuiKey_F7] = VK_F7;
io.KeyMap [ImGuiKey_F8] = VK_F8;
io.KeyMap [ImGuiKey_F9] = VK_F9;
io.KeyMap [ImGuiKey_F10] = VK_F10;
io.KeyMap [ImGuiKey_F11] = VK_F11;
io.KeyMap [ImGuiKey_F12] = VK_F12;
io.KeyMap [ImGuiKey_0] = '0';
io.KeyMap [ImGuiKey_1] = '1';
io.KeyMap [ImGuiKey_2] = '2';
io.KeyMap [ImGuiKey_3] = '3';
io.KeyMap [ImGuiKey_4] = '4';
io.KeyMap [ImGuiKey_5] = '5';
io.KeyMap [ImGuiKey_6] = '6';
io.KeyMap [ImGuiKey_7] = '7';
io.KeyMap [ImGuiKey_8] = '8';
io.KeyMap [ImGuiKey_9] = '9';
io.KeyMap [ImGuiKey_A] = 'A';
io.KeyMap [ImGuiKey_B] = 'B';
io.KeyMap [ImGuiKey_C] = 'C';
io.KeyMap [ImGuiKey_D] = 'D';
io.KeyMap [ImGuiKey_E] = 'E';
io.KeyMap [ImGuiKey_F] = 'F';
io.KeyMap [ImGuiKey_G] = 'G';
io.KeyMap [ImGuiKey_H] = 'H';
io.KeyMap [ImGuiKey_I] = 'I';
io.KeyMap [ImGuiKey_J] = 'J';
io.KeyMap [ImGuiKey_K] = 'K';
io.KeyMap [ImGuiKey_L] = 'L';
io.KeyMap [ImGuiKey_M] = 'M';
io.KeyMap [ImGuiKey_N] = 'N';
io.KeyMap [ImGuiKey_O] = 'O';
io.KeyMap [ImGuiKey_P] = 'P';
io.KeyMap [ImGuiKey_Q] = 'Q';
io.KeyMap [ImGuiKey_R] = 'R';
io.KeyMap [ImGuiKey_S] = 'S';
io.KeyMap [ImGuiKey_T] = 'T';
io.KeyMap [ImGuiKey_U] = 'U';
io.KeyMap [ImGuiKey_V] = 'V';
io.KeyMap [ImGuiKey_X] = 'X';
io.KeyMap [ImGuiKey_Y] = 'Y';
io.KeyMap [ImGuiKey_Z] = 'Z';
}

static auto ticks_per_sec =
Expand Down Expand Up @@ -2935,8 +3096,8 @@ SK_ImGui_User_NewFrame (void)
{
if ( io.KeyAlt &&
io.KeysDown [VK_F4 ] &&
( ( io.KeysDownDuration [VK_MENU] > 0.0f ) ^
( io.KeysDownDuration [VK_F4 ] > 0.0f ) ) )
( ImGui::IsKeyPressed (ImGuiKey_F4, false) ^
ImGui::IsKeyPressed (ImGuiKey_Menu, false) ) )
{
extern bool SK_ImGui_WantExit;
SK_ImGui_WantExit = true;
Expand Down
Loading

0 comments on commit c0a201d

Please sign in to comment.