コード例 #1
0
 public TkKeyboardState(OpenTK.Input.KeyboardState tkState)
 {
     if (tkState.IsAnyKeyDown)
     {
         Keys = all_keys.Where(tkState.IsKeyDown);
     }
 }
コード例 #2
0
        private void handleState(object sender, KeyboardKeyEventArgs e)
        {
            var state = e.Keyboard;

            if (state.Equals(lastState))
            {
                return;
            }

            lastState = state;

            PendingStates.Enqueue(new InputState {
                Keyboard = new TkKeyboardState(state)
            });
            FrameStatistics.Increment(StatisticsCounterType.KeyEvents);
        }
コード例 #3
0
            public TkKeyboardState(OpenTK.Input.KeyboardState tkState)
            {
                List <Key> keys = new List <Key>();

                if (tkState.IsAnyKeyDown)
                {
                    foreach (Key k in Enum.GetValues(typeof(Key)))
                    {
                        if (tkState.IsKeyDown(k))
                        {
                            keys.Add(k);
                        }
                    }
                }

                Keys = keys;
            }
コード例 #4
0
        public override bool Initialize(GameHost host)
        {
            host.InputThread.Scheduler.Add(scheduled = new ScheduledDelegate(delegate
            {
                var state = host.IsActive ? OpenTK.Input.Keyboard.GetState() : new OpenTK.Input.KeyboardState();

                if (state.Equals(lastState))
                {
                    return;
                }

                lastState = state;

                PendingStates.Enqueue(new InputState {
                    Keyboard = new TkKeyboardState(state)
                });

                FrameStatistics.Increment(StatisticsCounterType.KeyEvents);
            }, 0, 0));

            return(true);
        }