Exemple #1
0
        private static void Main_KeyUp(object sender, KeyboardKeyEventArgs e)
        {
            var key = e.Key;

            KeyboardState.SetKeyState(key, false);
            var button = KeyboardMappings.FirstOrDefault(buttonKey => buttonKey.Value == key).Key ?? key.KeyToString();

            foreach (var dele in ButtonRelease?.GetInvocationList() ?? new Delegate[] { })
            {
                if ((bool)dele.DynamicInvoke(button))
                {
                    break;
                }
            }
        }
Exemple #2
0
        public static void Update()
        {
            if (FirstPlayer == -1)
            {
                return;
            }
            var oldStates = States;

            States = new InputStates
            {
                GamePadState = OpenTK.Input.GamePad.GetState(FirstPlayer),
                //KeyboardState = Keyboard.GetState()
            };
            foreach (string button in ButtonNames)
            {
                if (States.IsButtonDown(button, true))
                {
                    if (!oldStates.IsButtonDown(button, true))
                    {
                        foreach (var dele in ButtonPress?.GetInvocationList() ?? new Delegate[] { })
                        {
                            if ((bool)dele.DynamicInvoke(button))
                            {
                                break;
                            }
                        }
                    }
                }
                else if (oldStates.IsButtonDown(button, true))
                {
                    foreach (var dele in ButtonRelease?.GetInvocationList() ?? new Delegate[] { })
                    {
                        if ((bool)dele.DynamicInvoke(button))
                        {
                            break;
                        }
                    }
                }
            }
        }