private void OnKeyDown(ref SDL.SDL_Event Event) { if (KeyDown != null) { KeyDown(this, ref Event); } }
private void OnLastEvent(ref SDL.SDL_Event Event) { if (LastEvent != null) { LastEvent(this, ref Event); } }
private void OnJoyButtonDown(ref SDL.SDL_Event Event) { if (JoyButtonDown != null) { JoyButtonDown(this, ref Event); } }
private void OnJoyDeviceRemoved(ref SDL.SDL_Event Event) { if (JoyDeviceRemoved != null) { JoyDeviceRemoved(this, ref Event); } }
private void OnDropFile(ref SDL.SDL_Event Event) { if (DropFile != null) { DropFile(this, ref Event); } }
private void OnFingerUp(ref SDL.SDL_Event Event) { if (FingerUp != null) { FingerUp(this, ref Event); } }
public MouseMotionEventArgs(SDL.SDL_Event rawEvent) : base(rawEvent) { RawTimeStamp = rawEvent.motion.timestamp; WindowID = rawEvent.motion.windowID; MouseDeviceID = rawEvent.motion.which; RelativeToWindowX = rawEvent.motion.x; RelativeToWindowY = rawEvent.motion.y; RelativeToLastMotionEventX = rawEvent.motion.xrel; RelativeToLastMotionEventY = rawEvent.motion.yrel; List <MouseButtonCode> buttonsPressed = new List <MouseButtonCode>(); if (SDL.SDL_BUTTON(rawEvent.motion.state) == SDL.SDL_BUTTON_LEFT) { buttonsPressed.Add(MouseButtonCode.Left); } if (SDL.SDL_BUTTON(rawEvent.motion.state) == SDL.SDL_BUTTON_MIDDLE) { buttonsPressed.Add(MouseButtonCode.Middle); } if (SDL.SDL_BUTTON(rawEvent.motion.state) == SDL.SDL_BUTTON_RIGHT) { buttonsPressed.Add(MouseButtonCode.Right); } if (SDL.SDL_BUTTON(rawEvent.motion.state) == SDL.SDL_BUTTON_X1) { buttonsPressed.Add(MouseButtonCode.X1); } if (SDL.SDL_BUTTON(rawEvent.motion.state) == SDL.SDL_BUTTON_X2) { buttonsPressed.Add(MouseButtonCode.X2); } MouseButtonsPressed = buttonsPressed; }
private void OnDollarGesture(ref SDL.SDL_Event Event) { if (DollarGesture != null) { DollarGesture(this, ref Event); } }
private void HandleMouseButtonEvent(SDL.SDL_Event e) { bool isDown = false; eMouseButton button = eMouseButton.Any; if (e.type == SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN) { isDown = true; } if (e.button.button == SDL.SDL_BUTTON_LEFT) { button = eMouseButton.Left; } else if (e.button.button == SDL.SDL_BUTTON_MIDDLE) { button = eMouseButton.Middle; } else if (e.button.button == SDL.SDL_BUTTON_RIGHT) { button = eMouseButton.Right; } _input.MouseBindings.UpdateAndDispatchMouseButton(button, isDown); }
public virtual void HandleEvent(SDL.SDL_Event e) { if (e.type == SDL.SDL_EventType.SDL_QUIT) { IsAlive = false; } }
public static void HandleEvent(SDL.SDL_Event inputEvent) { _mouseMotionEvent = new SDL.SDL_MouseMotionEvent(); _mouseWheelDirection = 0; switch (inputEvent.type) { case SDL.SDL_EventType.SDL_KEYDOWN: _keysDown.Add(inputEvent.key.keysym.sym); break; case SDL.SDL_EventType.SDL_KEYUP: RemoveKey(inputEvent.key.keysym.sym); break; case SDL.SDL_EventType.SDL_MOUSEBUTTONDOWN: _mouseButtonsDown.Add(inputEvent.button.button); break; case SDL.SDL_EventType.SDL_MOUSEBUTTONUP: RemoveMouseButton(inputEvent.button.button); break; case SDL.SDL_EventType.SDL_MOUSEMOTION: _mouseMotionEvent = inputEvent.motion; break; case SDL.SDL_EventType.SDL_MOUSEWHEEL: _mouseWheelDirection = (int)inputEvent.wheel.direction; break; } }
static void ProcessKeyEvent(Sdl2NativeWindow window, SDL.SDL_Event ev) { bool key_pressed = ev.key.state == SDL.SDL_PRESSED; var key = ev.key.keysym; window.keyboard.SetKey(TranslateKey(key.scancode), (uint)key.scancode, key_pressed); }
static void ProcessButtonEvent(Sdl2NativeWindow window, SDL.SDL_Event ev) { bool button_pressed = ev.button.state == SDL.SDL_PRESSED; // We need MouseUp events to be reported even if they occur // outside the window. SetWindowGrab ensures we get them. if (window.CursorVisible) { SDL.SDL_SetWindowGrab(window.window.Handle, button_pressed ? SDL.SDL_bool.SDL_TRUE : SDL.SDL_bool.SDL_FALSE); } switch (ev.button.button) { case (byte)SDL.SDL_BUTTON_LEFT: window.mouse[MouseButton.Left] = button_pressed; break; case (byte)SDL.SDL_BUTTON_MIDDLE: window.mouse[MouseButton.Middle] = button_pressed; break; case (byte)SDL.SDL_BUTTON_RIGHT: window.mouse[MouseButton.Right] = button_pressed; break; case (byte)SDL.SDL_BUTTON_X1: window.mouse[MouseButton.Button1] = button_pressed; break; case (byte)SDL.SDL_BUTTON_X2: window.mouse[MouseButton.Button2] = button_pressed; break; } }
internal static void ProcessKeyBoardEvents(ref Params gVar, SDL.SDL_Event e) { bool quit = false; var playerBody = gVar.Entity[0].Body; //var playerVel = entity[0].Body.GetLinearVelocityFromWorldPoint(entity[0].Body.GetWorldCenter()); switch (e.type) { case SDL.SDL_EventType.SDL_QUIT: quit = true; break; case SDL.SDL_EventType.SDL_KEYDOWN: switch (e.key.keysym.sym) { case SDL.SDL_Keycode.SDLK_LEFT: // increase left velocity playerBody.SetLinearVelocity(new Vector2(-29.0f, 0.0f)); break; case SDL.SDL_Keycode.SDLK_RIGHT: playerBody.SetLinearVelocity(new Vector2(+29.0f, 0.0f)); break; case SDL.SDL_Keycode.SDLK_q: quit = true; break; } break; case SDL.SDL_EventType.SDL_KEYUP: switch (e.key.keysym.sym) { case SDL.SDL_Keycode.SDLK_LEFT: // increase left velocity playerBody.SetLinearVelocity(new Vector2(0.0f, 0.0f)); break; case SDL.SDL_Keycode.SDLK_RIGHT: playerBody.SetLinearVelocity(new Vector2(0.0f, 0.0f)); break; case SDL.SDL_Keycode.SDLK_SPACE: Vector2 bulletPos = new Vector2(); bulletPos = playerBody.GetWorldCenter(); bulletPos.Y = bulletPos.Y + 1.0f; CreateEntity(ref gVar, bulletPos, 0.1f, 0.1f, Behavior.Bullet); gVar.BulletCount++; gVar.Entity[gVar.Entity.Count - 1].Body.SetLinearVelocity(new Vector2(0.0f, 35.0f)); break; } break; } if (quit == true) { CleanUp(ref gVar); } }
static uint SetupTimerCallback(UInt32 interval, IntPtr?param) { var managedMethod = new ManagedTypeSignature(CallBack); Delegate untypedManagedMethod = (Delegate)managedMethod; IntPtr intPtr = Marshal.GetFunctionPointerForDelegate(untypedManagedMethod); SDL.SDL_Event @event = new SDL.SDL_Event(); SDL.SDL_UserEvent userevent = new SDL.SDL_UserEvent { /* In this example, our callback pushes a function * into the queue, and causes our callback to be called again at the * same interval: */ type = (uint)SDL.SDL_EventType.SDL_USEREVENT, code = 0, data1 = intPtr }; if (param.HasValue) { userevent.data2 = param.Value; } @event.type = SDL.SDL_EventType.SDL_USEREVENT; @event.user = userevent; SDL.SDL_PushEvent(ref @event); return(interval); }
private void OnControllerDeviceMoved(ref SDL.SDL_Event Event) { if (ControllerDeviceMoved != null) { ControllerDeviceMoved(this, ref Event); } }
public static void HandleKeyUp(SDL.SDL_Event event_) { if (event_.key.repeat == 0) { scancodesReleased[(int)event_.key.keysym.scancode] = true; } }
private void OnDollarRecord(ref SDL.SDL_Event Event) { if (DollarRecord != null) { DollarRecord(this, ref Event); } }
private void HandleEvent(SDL.SDL_Event e, bool down) { if (controller == null) { return; } if (e.cdevice.which != controller.Index && e.jdevice.which != controller.Index) { return; } if (controller.IsGameController) { var button = SDL.SDL_GameControllerGetBindForButton(controller.game_controller, (SDL.SDL_GameControllerButton)index).button; if (e.cbutton.button == button) { pressed = this.down != down && down; released = this.down != down && !down; this.down = down; } } else { if (e.jbutton.button == index) { pressed = this.down != down && down; released = this.down != down && !down; this.down = down; } } }
private void OnFingerMotion(ref SDL.SDL_Event Event) { if (FingerMotion != null) { FingerMotion(this, ref Event); } }
//Takes key presses and adjusts the dot's velocity public void handleEvent(SDL.SDL_Event e) { //If a key was pressed if (e.type == SDL.SDL_EventType.SDL_KEYDOWN && e.key.repeat == 0) { //Adjust the velocity switch (e.key.keysym.sym) { case SDL.SDL_Keycode.SDLK_UP: mVelY -= DOT_VEL; break; case SDL.SDL_Keycode.SDLK_DOWN: mVelY += DOT_VEL; break; case SDL.SDL_Keycode.SDLK_LEFT: mVelX -= DOT_VEL; break; case SDL.SDL_Keycode.SDLK_RIGHT: mVelX += DOT_VEL; break; } } //If a key was released else if (e.type == SDL.SDL_EventType.SDL_KEYUP && e.key.repeat == 0) { //Adjust the velocity switch (e.key.keysym.sym) { case SDL.SDL_Keycode.SDLK_UP: mVelY += DOT_VEL; break; case SDL.SDL_Keycode.SDLK_DOWN: mVelY -= DOT_VEL; break; case SDL.SDL_Keycode.SDLK_LEFT: mVelX += DOT_VEL; break; case SDL.SDL_Keycode.SDLK_RIGHT: mVelX -= DOT_VEL; break; } } }
private void OnFirstEvent(ref SDL.SDL_Event Event) { if (FirstEvent != null) { FirstEvent(this, ref Event); } }
/// <summary>Raises an event handler with arguments parsed from the SDL event parameter. /// This method does nothing if there are no event subscribers. /// </summary> /// <param name="eventHandler"></param> /// <param name="rawEvent"></param> /// <typeparam name="T"></typeparam> private void RaiseEvent <T>(EventHandler <T> eventHandler, SDL.SDL_Event rawEvent) where T : EventArgs { var eventArgs = CreateEventArgs <T>(rawEvent); RaiseEvent(eventHandler, eventArgs); }
private void OnJoyButtonUp(ref SDL.SDL_Event Event) { if (JoyButtonUp != null) { JoyButtonUp(this, ref Event); } }
private void OnClipBoardUpdate(ref SDL.SDL_Event Event) { if (ClipBoardUpdate != null) { ClipBoardUpdate(this, ref Event); } }
private void OnJoyHatMotion(ref SDL.SDL_Event Event) { if (JoyHatMotion != null) { JoyHatMotion(this, ref Event); } }
private void OnControllerAxisMotion(ref SDL.SDL_Event Event) { if (ControllerAxisMotion != null) { ControllerAxisMotion(this, ref Event); } }
private void OnKeyUp(ref SDL.SDL_Event Event) { if (KeyUp != null) { KeyUp(this, ref Event); } }
private void OnControllerButtonUp(ref SDL.SDL_Event Event) { if (ControllerButtonUp != null) { ControllerButtonUp(this, ref Event); } }
private void OnMouseButtonUp(ref SDL.SDL_Event Event) { if (MouseButtonUp != null) { MouseButtonUp(this, ref Event); } }
public void Close() { lock (sync) { if (Exists) { Debug.Print("SDL2 destroying window {0}", window.Handle); SDL.SDL_Event e = new SDL.SDL_Event(); e.type = SDL.SDL_EventType.SDL_WINDOWEVENT; e.window.windowEvent = SDL.SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE; e.window.windowID = window_id; lock (SDL.Sync) { SDL.SDL_PushEvent(ref e); } } } }