示例#1
0
        private void showMouseButtonState(int x, int y, uint button)
        {
            var btnState = pge.GetMouse(button);

            string display = $"BTN {button} [Released:{btnState.Released}] [Pressed:{btnState.Pressed}] [Held: {btnState.Held}]";

            pge.DrawStringDecal(x, y, display, Pixel.BLACK);
        }
        private void UpdateImGuiInput(GameWindow wnd)
        {
            ImGuiIOPtr io = ImGui.GetIO();

            //MouseState mouseState = new MouseState();


            io.MouseDown[0] = pge.GetMouse(0).bHeld;
            io.MouseDown[1] = pge.GetMouse(1).bHeld;
            io.MouseDown[2] = pge.GetMouse(2).bHeld;
            var screenPoint = new Vector2i(pge.GetMousePos().x, pge.GetMousePos().y);
            var point       = screenPoint;

            io.MousePos = new System.Numerics.Vector2(point.X, point.Y);

            //KeyboardState KeyboardState = wnd.KeyboardState;


            foreach (olc.Key key in Enum.GetValues(typeof(olc.Key)))
            {
                if (key == Key.NONE)
                {
                    continue;
                }

                io.KeysDown[(int)key] = pge.GetKey(key).bHeld;
                bool shiftState = pge.GetKey(Key.SHIFT).bHeld;
                if (pge.GetKey(key).bPressed)
                {
                    switch (key)
                    {
                    case Key.A:
                    case Key.B:
                    case Key.C:
                    case Key.D:
                    case Key.E:
                    case Key.F:
                    case Key.G:
                    case Key.H:
                    case Key.I:
                    case Key.J:
                    case Key.K:
                    case Key.L:
                    case Key.M:
                    case Key.N:
                    case Key.O:
                    case Key.P:
                    case Key.Q:
                    case Key.R:
                    case Key.S:
                    case Key.T:
                    case Key.U:
                    case Key.V:
                    case Key.W:
                    case Key.X:
                    case Key.Y:
                    case Key.Z:
                    case Key.K0:
                    case Key.K1:
                    case Key.K2:
                    case Key.K3:
                    case Key.K4:
                    case Key.K5:
                    case Key.K6:
                    case Key.K7:
                    case Key.K8:
                    case Key.K9:
                    case Key.EQUALS:
                    case Key.SPACE:
                    case Key.COMMA:
                    case Key.MINUS:
                    case Key.PERIOD:

                        io.AddInputCharacter(GetInputChar(key, shiftState));
                        break;
                    }
                }
            }
            //io.AddInputCharacter(c);
            //}
            //{
            //    if (key == Keys.Unknown)
            //    {
            //        continue;
            //    }
            //    io.KeysDown[(int)key] = KeyboardState.IsKeyDown(key);
            //}

            //foreach (var c in PressedChars)
            //{
            //    io.AddInputCharacter(c);
            //}
            //  PressedChars.Clear();
            io.KeyCtrl  = pge.GetKey(Key.CTRL).bHeld;
            io.KeyAlt   = pge.GetKey(Key.OEM_1).bHeld | pge.GetKey(Key.OEM_2).bHeld; // no olc.key for this?
            io.KeyShift = pge.GetKey(Key.SHIFT).bHeld;
            io.KeySuper = pge.GetKey(Key.OEM_3).bHeld;                               // no olc.key for this? windows key?
        }