Beispiel #1
0
        public static void Init()
        {
            if (_Initialized)
            {
                return;
            }
            _Initialized = true;

            ImGuiIO io = ImGui.GetIO();

            _Keys.Add(io.KeyMap[ImGuiKey.Tab]        = (int)Keys.Tab);
            _Keys.Add(io.KeyMap[ImGuiKey.LeftArrow]  = (int)Keys.Left);
            _Keys.Add(io.KeyMap[ImGuiKey.RightArrow] = (int)Keys.Right);
            _Keys.Add(io.KeyMap[ImGuiKey.UpArrow]    = (int)Keys.Up);
            _Keys.Add(io.KeyMap[ImGuiKey.DownArrow]  = (int)Keys.Down);
            _Keys.Add(io.KeyMap[ImGuiKey.PageUp]     = (int)Keys.PageUp);
            _Keys.Add(io.KeyMap[ImGuiKey.PageDown]   = (int)Keys.PageDown);
            _Keys.Add(io.KeyMap[ImGuiKey.Home]       = (int)Keys.Home);
            _Keys.Add(io.KeyMap[ImGuiKey.End]        = (int)Keys.End);
            _Keys.Add(io.KeyMap[ImGuiKey.Delete]     = (int)Keys.Delete);
            _Keys.Add(io.KeyMap[ImGuiKey.Backspace]  = (int)Keys.Back);
            _Keys.Add(io.KeyMap[ImGuiKey.Enter]      = (int)Keys.Enter);
            _Keys.Add(io.KeyMap[ImGuiKey.Escape]     = (int)Keys.Escape);
            _Keys.Add(io.KeyMap[ImGuiKey.A]          = (int)Keys.A);
            _Keys.Add(io.KeyMap[ImGuiKey.C]          = (int)Keys.C);
            _Keys.Add(io.KeyMap[ImGuiKey.V]          = (int)Keys.V);
            _Keys.Add(io.KeyMap[ImGuiKey.X]          = (int)Keys.X);
            _Keys.Add(io.KeyMap[ImGuiKey.Y]          = (int)Keys.Y);
            _Keys.Add(io.KeyMap[ImGuiKey.Z]          = (int)Keys.Z);

#if FNA
            TextInputEXT.TextInput += OnTextInput;
            io.SetGetClipboardTextFn(GetClipboardTextFn);
            io.SetSetClipboardTextFn(SetClipboardTextFn);
#endif
            // 1. Text input in XNA depends on the game's window. It thus can't be set up statically.
            // 2. ImGui already handles the Windows clipboard out of the box.

            // If no font added, add default font.
            if (io.FontAtlas.Fonts.Size == 0)
            {
                io.FontAtlas.AddDefaultFont();
            }
        }
Beispiel #2
0
        public static void Init()
        {
            if (_Initialized)
            {
                return;
            }
            _Initialized = true;

            ImGuiIO io = ImGui.GetIO();

            io.KeyMap[ImGuiKey.Tab]        = (int)SDL.SDL_Keycode.SDLK_TAB;
            io.KeyMap[ImGuiKey.LeftArrow]  = (int)SDL.SDL_Scancode.SDL_SCANCODE_LEFT;
            io.KeyMap[ImGuiKey.RightArrow] = (int)SDL.SDL_Scancode.SDL_SCANCODE_RIGHT;
            io.KeyMap[ImGuiKey.UpArrow]    = (int)SDL.SDL_Scancode.SDL_SCANCODE_UP;
            io.KeyMap[ImGuiKey.DownArrow]  = (int)SDL.SDL_Scancode.SDL_SCANCODE_DOWN;
            io.KeyMap[ImGuiKey.PageUp]     = (int)SDL.SDL_Scancode.SDL_SCANCODE_PAGEUP;
            io.KeyMap[ImGuiKey.PageDown]   = (int)SDL.SDL_Scancode.SDL_SCANCODE_PAGEDOWN;
            io.KeyMap[ImGuiKey.Home]       = (int)SDL.SDL_Scancode.SDL_SCANCODE_HOME;
            io.KeyMap[ImGuiKey.End]        = (int)SDL.SDL_Scancode.SDL_SCANCODE_END;
            io.KeyMap[ImGuiKey.Delete]     = (int)SDL.SDL_Keycode.SDLK_DELETE;
            io.KeyMap[ImGuiKey.Backspace]  = (int)SDL.SDL_Keycode.SDLK_BACKSPACE;
            io.KeyMap[ImGuiKey.Enter]      = (int)SDL.SDL_Keycode.SDLK_RETURN;
            io.KeyMap[ImGuiKey.Escape]     = (int)SDL.SDL_Keycode.SDLK_ESCAPE;
            io.KeyMap[ImGuiKey.A]          = (int)SDL.SDL_Keycode.SDLK_a;
            io.KeyMap[ImGuiKey.C]          = (int)SDL.SDL_Keycode.SDLK_c;
            io.KeyMap[ImGuiKey.V]          = (int)SDL.SDL_Keycode.SDLK_v;
            io.KeyMap[ImGuiKey.X]          = (int)SDL.SDL_Keycode.SDLK_x;
            io.KeyMap[ImGuiKey.Y]          = (int)SDL.SDL_Keycode.SDLK_y;
            io.KeyMap[ImGuiKey.Z]          = (int)SDL.SDL_Keycode.SDLK_z;

            io.SetGetClipboardTextFn((userData) => SDL.SDL_GetClipboardText());
            io.SetSetClipboardTextFn((userData, text) => SDL.SDL_SetClipboardText(text));

            // If no font added, add default font.
            if (io.FontAtlas.Fonts.Size == 0)
            {
                io.FontAtlas.AddDefaultFont();
            }
        }