protected override void _initialize(ParameterList args) { // Find the WINDOW parameter var parameter = args.Find((p) => { return(p.first.ToLower() == "window"); }); if (parameter != null) { var window = parameter.second; if (window is IntPtr) { _hwnd = (IntPtr)window; } } if (_hwnd != IntPtr.Zero) { _window = Control.FromChildHandle(_hwnd); } KeyboardInfo keyboardInfo = new KeyboardInfo(); keyboardInfo.Vendor = this.InputSystemName; keyboardInfo.Id = 0; _unusedDevices.Add(keyboardInfo); MouseInfo mouseInfo = new MouseInfo(); mouseInfo.Vendor = this.InputSystemName; mouseInfo.Id = 0; _unusedDevices.Add(mouseInfo); }
private void GlobalEventService_KeyUpEvent(object sender, KeyboardInfo e) { EventManager?.Add(new Event("KeyUp", new EventArgument("Key", e.Key), new EventArgument("AltKey", e.AltKey), new EventArgument("ShiftKey", e.ShiftKey), new EventArgument("CtrlKey", e.CtrlKey))); }
public override bool ProcessKeyboard(KeyboardInfo info) { if (info.KeysPressed.Contains(AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.I))) { if (!inventoryConsole.IsVisible) { inventoryConsole.Show(); } else { inventoryConsole.Hide(); } } if (info.KeysPressed.Contains(AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.P))) { if (!characterStatusConsole.IsVisible) { characterStatusConsole.Show(); } else { characterStatusConsole.Hide(); } } if (!characterStatusConsole.ProcessKeyboard(info) && !inventoryConsole.ProcessKeyboard(info)) { return(dungeonViewConsole.ProcessKeyboard(info)); } return(true); }
/// <summary> /// Reads keystrokes until an ENTER key is encountered, returning the string of chars /// recieved prior to ENTER being pressed. Any chars received after ENTER and before /// this is processed will be lost. /// </summary> /// <returns>String with characters received prior to ENTER.</returns> public static string ReadLineFromKeyboard() { string ret = null; KeyboardInfo keyInfo = SadConsole.Engine.Keyboard; // loop through looking for ENTER key for (int i = 0; i < keyInfo.KeysReleased.Count; i++) { // if not enter, add to list of receved keystrokes if (keyInfo.KeysReleased[i].XnaKey != Keys.Enter) { InputKeys.Append(keyInfo.KeysReleased[i].Character); } // ENTER pressed, process recieved keys and clear the buffer else { ret = InputKeys.ToString(); InputKeys.Clear(); } } return(ret); }
void timer_Tick(object sender, EventArgs e) { var left = KeyboardInfo.GetKeyState(Keys.Left); var right = KeyboardInfo.GetKeyState(Keys.Right); var up = KeyboardInfo.GetKeyState(Keys.Up); var down = KeyboardInfo.GetKeyState(Keys.Down); if (left.IsPressed) { ball.MoveLeft(); this.Invalidate(); } if (right.IsPressed) { ball.MoveRight(); this.Invalidate(); } if (up.IsPressed) { ball.MoveUp(); this.Invalidate(); } if (down.IsPressed) { ball.MoveDown(); this.Invalidate(); } }
public Boolean KeyRelease(KeyboardInfo keyboardInfo) { Boolean isRequested = false; if (ConnectionInfo != null && ConnectionInfo.CurrentServer.IsConnected) { byte[] packet = null; SocketAsyncEventArgs socketArg = new SocketAsyncEventArgs(); PacketInfo packetInfo = new PacketInfo(); packetInfo.AccessCode = ConnectionInfo.CurrentServer.AccessCode; packetInfo.PacketType = PacketTypes.Keyboard; packetInfo.DeviceType = DeviceTypes.Keyboard; packetInfo.KeyboardInfo = keyboardInfo; packet = PacketUtils.MakeClientPacket(packetInfo); socketArg.SetBuffer(packet, 0, packet.Length); socketArg.RemoteEndPoint = ConnectionInfo.CurrentServer.UdpIPEndPoint; UdpSocket udpSocket = new UdpSocket(); isRequested = udpSocket.SendToAsync(socketArg); //데이터 사용량 누적 if (socketArg.BytesTransferred > 0) { AppLoader.CellularDataUtil.SumUsageCellularData(socketArg.BytesTransferred); } } return(isRequested); }
private async void GlobalEventService_KeyUpEvent(object sender, KeyboardInfo e) { if (ShortcutKey.HasValue && ShortcutKey.IsMatch(e.Key, e.AltKey, e.CtrlKey, e.ShiftKey)) { await InvokeAsync(async() => await Click.InvokeAsync(new MouseEventArgs()).ConfigureAwait(true)).ConfigureAwait(true); } }
private void ProcessAlphaNumericKeypress(Keys key) { char c = KeyboardInfo.KeyToChar(key); if (c != char.MinValue) { this.Text += c; } }
public override bool ProcessKeyboard(KeyboardInfo info) { if (!this.gameOver) { if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Down)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.S))) { this.MovePlayerBy(new Point(0, 1), info); } else if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Up)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.W))) { this.MovePlayerBy(new Point(0, -1), info); } if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Right)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.D))) { this.MovePlayerBy(new Point(1, 0), info); } else if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Left)) || info.KeysPressed.Contains(AsciiKey.Get(Keys.A))) { this.MovePlayerBy(new Point(-1, 0), info); } else if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Space))) { this.MovePlayerBy(new Point(0, 0), info); } if (info.KeysPressed.Contains(AsciiKey.Get(Keys.Space))) { var switches = this.objects.Where(o => o.Data is Switch); var player = this.objects.Single(o => o.Data is Player); foreach (var s in switches) { if ((Math.Abs(s.Position.X - player.Position.X) + Math.Abs(s.Position.Y - player.Position.Y)) <= 1) { (s.Data as Switch).Flip(); this.currentMap.FlipSwitches(); foreach (var w in switches) { w.RenderCells[0].ActualForeground = new Color(s.Data.Colour.R, s.Data.Colour.G, s.Data.Colour.B); } showMessageCallback("You flip the switch."); } } } } else { if (info.KeysPressed.Any()) { Game.Stop(); } } return(false); }
public override bool ProcessKeyboard(KeyboardInfo info) { if (info.IsKeyReleased(Keys.Space)) { Renderer = _renderer == oldRenderer ? cachedRenderer : oldRenderer; TextSurface.Tint = _renderer == oldRenderer ? Color.Transparent : new Color(255, 255, 255, 70); } return(false); }
public override bool ProcessKeyboard(KeyboardInfo info) { // If the space key is pressed, run the fade if (info.IsKeyReleased(Keys.Space)) { startFade = true; } // Do not pass the keyboard input to the child consoles, eat it. return(true); }
public KeyboardInfo ToKeyboardInfo() { KeyboardInfo ki = new KeyboardInfo(); ki.AltKey = IsAltKey; ki.ControlKey = IsControlKey; ki.WindowKey = IsWindowKey; ki.ShiftKey = IsShiftKey; ki.ImeKey = ImeKey; ki.KeyCode1 = KeyCode; return(ki); }
private async void GlobalEventService_KeyUpEvent(object sender, KeyboardInfo e) { foreach (var item in Items) { if (item.ShortcutKey.IsMatch(e.Key, e.AltKey, e.CtrlKey, e.ShiftKey)) { await InvokeAsync(async() => await OnClick(item.GetKeyOrText()).ConfigureAwait(true)).ConfigureAwait(true); break; } } }
private void HandleKeyboardState() { Keys[] pressedKeys = KeyboardInfo.GetPressedKeys(); if (pressedKeys.Count() > 0) { foreach (Keys key in pressedKeys) { EventManager.PushEvent( new UIEvent(new EventDetails("keyboard", EventType.KeyPress), key)); } } }
public override bool ProcessKeyboard(KeyboardInfo info) { Point newPosition = Point.Zero; if (info.IsKeyReleased(Keys.Up)) { PlayerControlComponent p = ComponentManager.GetComponent <PlayerControlComponent>(0); p.SetAction(new MoveAction(EntityManager.Player, new Point(0, -1), 10)); } else if (info.IsKeyReleased(Keys.Down)) { PlayerControlComponent p = ComponentManager.GetComponent <PlayerControlComponent>(0); p.SetAction(new MoveAction(EntityManager.Player, new Point(0, 1), 10)); } else if (info.IsKeyReleased(Keys.Left)) { PlayerControlComponent p = ComponentManager.GetComponent <PlayerControlComponent>(0); p.SetAction(new MoveAction(EntityManager.Player, new Point(-1, 0), 10)); } else if (info.IsKeyReleased(Keys.Right)) { PlayerControlComponent p = ComponentManager.GetComponent <PlayerControlComponent>(EntityManager.Player); p.SetAction(new MoveAction(EntityManager.Player, new Point(1, 0), 10)); } else if (info.IsKeyReleased(Keys.C)) { PlayerControlComponent p = ComponentManager.GetComponent <PlayerControlComponent>(EntityManager.Player); p.SetAction(new CloseAction(EntityManager.Player)); } //else if ( info.IsKeyReleased( Keys.Left ) ) //{ // newPosition.X -= 1; // keyHit = true; //} //else if ( info.IsKeyReleased( Keys.Right ) ) //{ // newPosition.X += 1; // keyHit = true; //} //// Test location //if ( keyHit ) //{ // Map.MoveActor( GameConstants.player, newPosition ); // //UpdatePlayerView(); //} return(false); }
private static void PrintDevice(DeviceInfo device) { WriteLine($"Device: 0x{device.Handle.ToString("X")} Type: {device.Type} Name: {device.Name}"); WriteLine(device switch { KeyboardInfo kbd => $" Total keys: {kbd.TotalKeyCount}, Function Keys: {kbd.FunctionKeyCount}, Indicators: {kbd.IndicatorCount}, " + $"Type: {kbd.KeyboardType:x}-{kbd.Subtype:x}, Mode: {kbd.KeyboardMode:x}", MouseInfo mouse => $" Id: {mouse.Id:x}, Buttons: {mouse.ButtonCount}, Sample rate: {mouse.SampleRate}, HWheel: {mouse.HasHorizontalWheel}", HidInfo hid => $" Vendor: {hid.VendorId:x}, Product: {hid.ProductId:x}, Version: {hid.VersionNumber}, Usage page: {hid.UsagePage}, Usage: {hid.Usage}", _ => "" });
static Engine() { Keyboard = new KeyboardInfo(); Mouse = new MouseInfo(); UseKeyboard = true; UseMouse = true; ProcessMouseWhenOffScreen = false; _cellEffects = new List <Type>(); GameTimeUpdate = new GameTime(); GameTimeDraw = new GameTime(); }
public override bool ProcessKeyboard(KeyboardInfo info) { if (info.KeysPressed.Count == 0) { return(false); } if (KeysToMovement.ContainsKey(info.KeysPressed[0].XnaKey)) { DungeonConsole.MovePlayerBy(KeysToMovement[info.KeysPressed[0].XnaKey]); } return(false); }
private void _enumerateDevices() { KeyboardInfo keyboardInfo = new KeyboardInfo(); keyboardInfo.Vendor = this.InputSystemName; keyboardInfo.Id = 0; _unusedDevices.Add(keyboardInfo); MouseInfo mouseInfo = new MouseInfo(); mouseInfo.Vendor = this.InputSystemName; mouseInfo.Id = 0; _unusedDevices.Add(mouseInfo); }
/// <summary> /// Updates the elements. /// </summary> public void Update(GameTime gameTime, Vector2 mousePosition) { MouseInfo.Update(); KeyboardInfo.Update(); foreach (BaseElement element in this.elements) { element.Update(gameTime); } this.UpdateHoveredElement(); if (this.hoveredElement != null) { if (MouseInfo.LeftMouseClicked) { this.hoveredElement.LeftClick(); } if (MouseInfo.MouseWheelScrolledUp) { this.hoveredElement.MouseWheelScrollUp(); } if (MouseInfo.MouseWheelScrolledDown) { this.hoveredElement.MouseWheelScrollDown(); } if (MouseInfo.LeftMouseClicked) { this.heldElement = this.GetDraggableElement(); } } if (MouseInfo.LeftMouseDragged) { if (this.heldElement != null && this.heldElement.Draggable) { Vector2 delta = MouseInfo.Position - MouseInfo.PreviousPosition; Vector2 newPosition = this.heldElement.GetPosition() + delta; this.heldElement?.Move(newPosition); } } if (MouseInfo.LeftMouseReleased) { this.heldElement = null; } }
protected override void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.Escape) || gameManager.ReadyToExit) { Exit(); } // TODO: Add your update logic here MouseInfo.Update(); KeyboardInfo.Update(); gameManager.Update(); base.Update(gameTime); }
public override bool ProcessKeyboard(KeyboardInfo info) { foreach (var tool in ToolsPanel.ToolsListBox.Items.Cast <ITool>()) { foreach (var key in info.KeysPressed) { if (key.Character == tool.Hotkey) { ToolsPanel.ToolsListBox.SelectedItem = tool; return(true); } } } return(false); }
private void _enumerateDevices() { var keyboardInfo = new KeyboardInfo(); keyboardInfo.Vendor = InputSystemName; keyboardInfo.Id = 0; this._unusedDevices.Add(keyboardInfo); var mouseInfo = new MouseInfo(); mouseInfo.Vendor = InputSystemName; mouseInfo.Id = 0; this._unusedDevices.Add(mouseInfo); foreach (MDI.DeviceInstance device in this.directInput.GetDevices(MDI.DeviceClass.GameControl, MDI.DeviceEnumerationFlags.AttachedOnly)) { //if ( device.Type == MDI.DeviceType.Joystick || device.Type == MDI.DeviceType.Gamepad || // device.Type == MDI.DeviceType.FirstPerson || device.Type == MDI.DeviceType.Driving || // device.Type == MDI.DeviceType.Flight ) //{ var joystickInfo = new JoystickInfo(); joystickInfo.IsXInput = false; joystickInfo.ProductGuid = device.ProductGuid; joystickInfo.DeviceId = device.InstanceGuid; joystickInfo.Vendor = device.ProductName; joystickInfo.Id = this._joystickCount++; this._unusedDevices.Add(joystickInfo); //} } try { var controllers = new[] { new SXI.Controller(SXI.UserIndex.One), new SXI.Controller(SXI.UserIndex.Two), new SXI.Controller(SXI.UserIndex.Three), new SXI.Controller(SXI.UserIndex.Four) }; foreach (var controller in controllers) { if (controller.IsConnected) { DirectXJoystick.CheckXInputDevices(_unusedDevices); } } } catch (DllNotFoundException) { } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } this.userInterface.Update(gameTime, MouseInfo.Position); if (KeyboardInfo.IsKeyPressed(Keys.Enter)) { this.userInterface.Reload(); this.userInterface.Initialise(); } base.Update(gameTime); }
private void AddKeyboardKey(KeyboardInfo info, int row, int col) { Key lKey = new Key(); lKey.Value = new ChangeKeyboardKeyValue(info.fullPath); lKey.SharedSizeGroup = "KeyboardKey"; lKey.Text = info.keyboardName; if (info.symbolString != null) { Geometry geom = (Geometry)this.Resources[info.symbolString]; if (null != geom) { lKey.SymbolGeometry = geom; } } this.AddKey(lKey, row, col); }
public DirectXKeyboard(InputManager creator, DirectInput directInput, bool buffered, CooperativeLevel coopSettings) { Creator = creator; this._directInput = directInput; IsBuffered = buffered; this._coopSettings = coopSettings; Type = InputType.Keyboard; EventListener = null; this._kbInfo = (KeyboardInfo)((DirectXInputManager)Creator).CaptureDevice <Keyboard>(); if (this._kbInfo == null) { throw new Exception("No devices match requested type."); } log.Debug("DirectXKeyboard device created."); }
public override bool ProcessKeyboard(KeyboardInfo info) { if (info.IsKeyReleased(Keys.C)) { backIndex++; if (backIndex == backgroundcycle.Length) { backIndex = 0; } var theme = Theme; theme.FillStyle.Background = backgroundcycle[backIndex]; Theme = theme; } return(base.ProcessKeyboard(info)); }
public override bool ProcessKeyboard(KeyboardInfo info) { //TODO: Have this use Colored strings and make it so an item of type Equipment is equippable.(or unequippable) if (this.IsVisible) { if (info.KeysPressed.Contains(AsciiKey.Get(Keys.J))) { DropMode = DropMode == true ? false : true; } foreach (var k in inventory.inventory) { if (info.KeysPressed.Contains(AsciiKey.Get((Keys)((int)char.ToUpper(k.Key))))) { if (DropMode) { SadConsole.Consoles.Window.Prompt(GetItemMessage(k), "Drop", "Cancel", (r) => { drop_prompt(r, k.Value); }); } else { switch (k.Value.GetComponent <Item>(ComponentType.Item).ItemType) { case ItemType.Food: SadConsole.Consoles.Window.Prompt(GetItemMessage(k), "Eat", "Cancel", (r) => { food_prompt(r, k.Value); }); break; case ItemType.Equipment: SadConsole.Consoles.Window.Prompt(GetItemMessage(k), "Equip/UnEquip", "Cancel", (r) => { equipment_prompt(r, k.Value); }); break; case ItemType.Potion: SadConsole.Consoles.Window.Prompt(GetItemMessage(k), "Drink", "Cancel", (r) => { potion_prompt(r, k.Value); }); break; default: break; } } } } } return(base.ProcessKeyboard(info)); }
/// <summary> /// Reads all keystrokes since last time called. Used when ENTER is not needed or "Press Any Key" /// type prompt is in use. /// </summary> /// <returns>String with characters since last time called.</returns> public static string ReadAnyKeyFromKeyboard() { string ret = null; KeyboardInfo keyInfo = SadConsole.Engine.Keyboard; // loop through building string for (int i = 0; i < keyInfo.KeysReleased.Count; i++) { InputKeys.Append(keyInfo.KeysReleased[i].Character); } if (InputKeys.Length > 0) { ret = InputKeys.ToString(); InputKeys.Clear(); } return(ret); }
public override bool ProcessKeyboard(KeyboardInfo info) { if (info.KeysPressed.Contains(AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.Down))) { ViewConsole.MovePlayerBy(new Point(0, 1)); } else if (info.KeysPressed.Contains(AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.Up))) { ViewConsole.MovePlayerBy(new Point(0, -1)); } else if (info.KeysPressed.Contains(AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.Right))) { ViewConsole.MovePlayerBy(new Point(1, 0)); } else if (info.KeysPressed.Contains(AsciiKey.Get(Microsoft.Xna.Framework.Input.Keys.Left))) { ViewConsole.MovePlayerBy(new Point(-1, 0)); } return(false); }
void ShowKeyboardInfos() { _keyboardInfosProperty = serializedObject.FindProperty("_keyboardInfos"); if (AddFoldOut(_keyboardInfosProperty, "Keyboards".ToGUIContent())) { KeyboardInfo[] keyboardInfos = _inputSystem.GetKeyboardInfos(); KeyboardInfo keyboardInfo = keyboardInfos.Last(); keyboardInfo.SetUniqueName("default", "", keyboardInfos); serializedObject.Update(); } if (_keyboardInfosProperty.isExpanded) { EditorGUI.indentLevel += 1; for (int i = 0; i < _keyboardInfosProperty.arraySize; i++) { _currentKeyboardInfo = _inputSystem.GetKeyboardInfos()[i]; _currentKeyboardInfoProperty = _keyboardInfosProperty.GetArrayElementAtIndex(i); BeginBox(); if (DeleteFoldOut(_keyboardInfosProperty, i, _currentKeyboardInfo.Name.ToGUIContent(), CustomEditorStyles.BoldFoldout)) break; ShowKeyboardInfo(); EndBox(); } Separator(); EditorGUI.indentLevel -= 1; } }