Skip to content

Commit

Permalink
Backends: OSX: Add support for extra keys
Browse files Browse the repository at this point in the history
  • Loading branch information
thedmd committed Dec 12, 2021
1 parent 8e51f33 commit 7cf90e5
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions backends/imgui_impl_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,106 @@ bool ImGui_ImplOSX_Init()
io.KeyMap[ImGuiKey_Space] = 32;
io.KeyMap[ImGuiKey_Enter] = 13;
io.KeyMap[ImGuiKey_Escape] = 27;
#ifndef IMGUI_HAS_EXTRA_KEYS
io.KeyMap[ImGuiKey_KeyPadEnter] = 3;
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';
#else
io.KeyMap[ImGuiKey_Apostrophe] = '\''; // '
io.KeyMap[ImGuiKey_Comma] = ','; // ,
io.KeyMap[ImGuiKey_Minus] = '-'; // -
io.KeyMap[ImGuiKey_Period] = '.'; // .
io.KeyMap[ImGuiKey_Slash] = '/'; // /
io.KeyMap[ImGuiKey_Semicolon] = ';'; // ;
io.KeyMap[ImGuiKey_Equal] = '='; // =
io.KeyMap[ImGuiKey_LeftBracket] = '['; // [
io.KeyMap[ImGuiKey_Backslash] = '\\'; // \ (this text inhibit multiline comment caused by backlash)
io.KeyMap[ImGuiKey_RightBracket] = ']'; // ]
io.KeyMap[ImGuiKey_GraveAccent] = '`'; // `
io.KeyMap[ImGuiKey_CapsLock] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_ScrollLock] = NSScrollLockFunctionKey + offset_for_function_keys;
io.KeyMap[ImGuiKey_NumLock] = NSClearLineFunctionKey + offset_for_function_keys;
io.KeyMap[ImGuiKey_PrintScreen] = NSPrintScreenFunctionKey + offset_for_function_keys;
io.KeyMap[ImGuiKey_Pause] = NSPauseFunctionKey + offset_for_function_keys;
io.KeyMap[ImGuiKey_KeyPad0] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_KeyPad1] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_KeyPad2] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_KeyPad3] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_KeyPad4] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_KeyPad5] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_KeyPad6] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_KeyPad7] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_KeyPad8] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_KeyPad9] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_KeyPadDecimal] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_KeyPadDivide] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_KeyPadMultiply] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_KeyPadSubtract] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_KeyPadAdd] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_KeyPadEnter] = 3;
io.KeyMap[ImGuiKey_KeyPadEqual] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_LeftShift] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_LeftControl] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_LeftAlt] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_LeftSuper] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_RightShift] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_RightControl] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_RightAlt] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_RightSuper] = 0; // FIXME: not implemented
io.KeyMap[ImGuiKey_Menu] = NSMenuFunctionKey + offset_for_function_keys;
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_W] = 'W';
io.KeyMap[ImGuiKey_X] = 'X';
io.KeyMap[ImGuiKey_Y] = 'Y';
io.KeyMap[ImGuiKey_Z] = 'Z';
io.KeyMap[ImGuiKey_F1] = NSF1FunctionKey + offset_for_function_keys;
io.KeyMap[ImGuiKey_F2] = NSF2FunctionKey + offset_for_function_keys;
io.KeyMap[ImGuiKey_F3] = NSF3FunctionKey + offset_for_function_keys;
io.KeyMap[ImGuiKey_F4] = NSF4FunctionKey + offset_for_function_keys;
io.KeyMap[ImGuiKey_F5] = NSF5FunctionKey + offset_for_function_keys;
io.KeyMap[ImGuiKey_F6] = NSF6FunctionKey + offset_for_function_keys;
io.KeyMap[ImGuiKey_F7] = NSF7FunctionKey + offset_for_function_keys;
io.KeyMap[ImGuiKey_F8] = NSF8FunctionKey + offset_for_function_keys;
io.KeyMap[ImGuiKey_F9] = NSF9FunctionKey + offset_for_function_keys;
io.KeyMap[ImGuiKey_F10] = NSF10FunctionKey + offset_for_function_keys;
io.KeyMap[ImGuiKey_F11] = NSF11FunctionKey + offset_for_function_keys;
io.KeyMap[ImGuiKey_F12] = NSF12FunctionKey + offset_for_function_keys;
#endif // IMGUI_HAS_EXTRA_KEYS

// Load cursors. Some of them are undocumented.
g_MouseCursorHidden = false;
Expand Down

0 comments on commit 7cf90e5

Please sign in to comment.