Exemplo n.º 1
0
 public bool CurrentButtonDownEvent(object key)
 {
     if (!NewState.ContainsKey((uint)key))
     {
         return(false);
     }
     return(NewState[(uint)key]);
 }
Exemplo n.º 2
0
 public bool CurrentButtonUpEvent(object key)
 {
     if (!NewState.ContainsKey((uint)key))
     {
         return(true);
     }
     return(!NewState[(uint)key]);
 }
Exemplo n.º 3
0
            public void UpdateEvents(List <SDL2.SDL.SDL_Event> events)
            {
                OldMousePosition = new Vec2(CurrentMousePosition);
                OldWheelPosition = new Vec2(CurrentWheelPosition);
                OldState         = new Dictionary <uint, bool>(NewState);
                foreach (var e in events)
                {
                    if (e.type == SDL2.SDL.SDL_EventType.SDL_MOUSEWHEEL)
                    {
                        CurrentWheelPosition += new Vec2(e.wheel.x, e.wheel.y);
                    }
                    else if (e.type == SDL2.SDL.SDL_EventType.SDL_MOUSEMOTION)
                    {
                        CurrentMousePosition = new Vec2(e.motion.x, e.motion.y);
                    }

                    bool?state = null;
                    if (e.type == SDL2.SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN && e.key.repeat == 0)
                    {
                        state = true;
                    }
                    else if (e.type == SDL2.SDL.SDL_EventType.SDL_MOUSEBUTTONUP)
                    {
                        state = false;
                    }

                    if (state.HasValue)
                    {
                        if (!NewState.ContainsKey(e.button.button))
                        {
                            NewState.Add(e.button.button, state.Value);
                        }
                        else
                        {
                            NewState[e.button.button] = state.Value;
                        }
                    }
                }
            }