/// <summary> /// Attempts to perform navigation as a result of the specified key press. /// </summary> /// <param name="view">The view for which to perform navigation.</param> /// <param name="device">The keyboard device that raised the key press event.</param> /// <param name="key">The key that was pressed.</param> /// <param name="ctrl">A value indicating whether the Ctrl modifier is active.</param> /// <param name="alt">A value indicating whether the Alt modifier is active.</param> /// <param name="shift">A value indicating whether the Shift modifier is active.</param> /// <param name="repeat">A value indicating whether this is a repeated key press.</param> /// <returns><c>true</c> if navigation was performed; otherwise, <c>false</c>.</returns> public static Boolean PerformNavigation(PresentationFoundationView view, KeyboardDevice device, Key key, Boolean ctrl, Boolean alt, Boolean shift, Boolean repeat) { Contract.Require(view, "view"); var element = (view.ElementWithFocus ?? view.LayoutRoot) as UIElement; if (element == null) return false; switch (key) { case Key.Tab: return PerformNavigation(view, element, shift ? FocusNavigationDirection.Previous : FocusNavigationDirection.Next, ctrl); case Key.Left: return PerformNavigation(view, element, FocusNavigationDirection.Left, false); case Key.Up: return PerformNavigation(view, element, FocusNavigationDirection.Up, false); case Key.Right: return PerformNavigation(view, element, FocusNavigationDirection.Right, false); case Key.Down: return PerformNavigation(view, element, FocusNavigationDirection.Down, false); } return false; }
KeyboardActivityArgs(KeyboardDevice keyboard, IntPtr windowHandle, KeyActivityType eventType, VirtualKeyCodes vKeyCode, KeyMasks masks, int scanCode, int repeatCount, bool extended, char aChar) { fKeyboard = keyboard; fWindowHandle = windowHandle; fEventType = eventType; m_VirtualKeyCode = vKeyCode; m_KeyMasks = masks; fKeyChar = aChar; fRepeatCount = repeatCount; m_OEMScanCode = scanCode; fIsExtended = extended; //int previousKeyState = ((int)fKeyFlags & 0x40000000) >> 30; //fKeyWasPreviouslyDown = (1 == previousKeyState); // Not used at the moment //int context = ((int)fKeyFlags & 0x20000000) >> 29; //int transitionState = (int)(((int)fKeyFlags & 0x100000000) >> 31); }
// Initializor============================================= public override void Initialize() { // Initialize the keyboard keyboard = Engine.Services.GetService<KeyboardDevice>(); mouseDevice = Engine.Services.GetService<MouseDevice>(); mouseDevice.ResetMouseAfterUpdate = false; // Initialize buttons Texture2D texture; hand = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\hand"), new Vector2(mouseDevice.State.X, mouseDevice.State.Y), this); texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuReturnBtn"); returnBtn = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 270), this); texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuMenuBtn"); menuBtn = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 320), this); texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuQuitBtn"); quitBtn = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 370), this); pauseText = new EntityText(Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24"), new Vector2((Engine.Viewport.Width / 2)-40, 200), "PAUSE", this); // Initialize the black texture black = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\black"), Vector2.Zero, this); black.Alpha = 0.4f; base.Initialize(); }
/// <inheritdoc/> protected override void OnGotKeyboardFocus(KeyboardDevice device, IInputElement oldFocus, IInputElement newFocus, ref RoutedEventData data) { if (PART_Input != null) { PART_Input.Focus(); } base.OnGotKeyboardFocus(device, oldFocus, newFocus, ref data); }
/// <inheritdoc/> protected override void OnPreviewGotKeyboardFocus(KeyboardDevice device, IInputElement oldFocus, IInputElement newFocus, ref RoutedEventData data) { if (!data.Handled && newFocus == this) { Select(); } base.OnPreviewGotKeyboardFocus(device, oldFocus, newFocus, ref data); }
/// <inheritdoc/> protected override void OnLostKeyboardFocus(KeyboardDevice device, IInputElement oldFocus, IInputElement newFocus, ref RoutedEventData data) { if (PART_Input != null) { PART_Input.InvalidateDisplayCache(TextBox.TextProperty); PART_Input.CaretIndex = 0; } base.OnLostKeyboardFocus(device, oldFocus, newFocus, ref data); }
public KeyEventArgs( KeyboardDevice keyboard, PresentationSource inputSource, int timestamp, Key key) : base(keyboard, timestamp) { this.Key = key; }
public KeyboardEvent(KeyboardDevice keyboard, KeyEventType eventType, VirtualKeyCodes keyData, int aKeyFlags, char aChar) { fKeyboard = keyboard; fEventType = eventType; fKeyData = keyData; fKeyFlags = aKeyFlags; fKeyChar = aChar; }
//public void Dispose() //{ //} public MouseController(PointingDeviceCollection pd, Dock d, ScrollBar sB, SystemState st, PhotoDisplay photoDisplay, StrokeBoxCollection s, KeyboardDevice key) { dock = d; sBar = sB; //pdCollection = pdc; strokeGroup = s; systemState = st; photoDisplayManager = photoDisplay; //rawInputForm_ = new RawInputForm(); pdCollection = pd; keyboard = key; }
/// <summary> /// Handles the <see cref="Keyboard.KeyDownEvent"/> attached event for the view's topmost <see cref="Grid"/> instance. /// </summary> /// <param name="dobj">The object that raised the event.</param> /// <param name="device">The <see cref="KeyboardDevice"/> that raised the event.</param> /// <param name="key">The <see cref="Key"/> value that represents the key that was pressed.</param> /// <param name="modifiers">A <see cref="ModifierKeys"/> value indicating which of the key modifiers are currently active.</param> /// <param name="data">The routed event metadata for this event invocation.</param> public void HandleKeyDown(DependencyObject dobj, KeyboardDevice device, Key key, ModifierKeys modifiers, ref RoutedEventData data) { switch (key) { case Key.AppControlBack: { owner.Ultraviolet.Host.Exit(); data.Handled = true; } break; } }
public KeyboardInputBinding(UltravioletContext uv, Key key) { Contract.Require(uv, nameof(uv)); if (!uv.GetInput().IsKeyboardSupported()) { throw new NotSupportedException(); } this.keyboard = uv.GetInput().GetKeyboard(); this.key = key; this.stringRepresentation = BuildStringRepresentation(); }
/// <summary> /// Initializes a new instance of the <see cref="KeyboardInputBinding"/> class. /// </summary> /// <param name="uv">The Ultraviolet context.</param> /// <param name="key">A <see cref="Key"/> value representing the binding's primary key.</param> /// <param name="control">A value indicating whether the binding requires the Control modifier.</param> /// <param name="alt">A value indicating whether the binding requires the Alt modifier.</param> /// <param name="shift">A value indicating whether the binding requires the Shift modifier.</param> public KeyboardInputBinding(UltravioletContext uv, Key key, Boolean control, Boolean alt, Boolean shift) { if (!uv.GetInput().IsKeyboardSupported()) { throw new NotSupportedException(); } this.keyboard = uv.GetInput().GetKeyboard(); this.key = key; this.control = control; this.alt = alt; this.shift = shift; this.stringRepresentation = BuildStringRepresentation(); }
// Initializor============================================= public override void Initialize() { // Initialize the keyboard keyboard = Engine.Services.GetService<KeyboardDevice>(); fade = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\black"), Vector2.Zero, this); // Initialize the GameOverText // Initialize the black texture background = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\intro"), Vector2.Zero, this); base.Initialize(); }
private void WindowKeyDown(object sender, KeyEventArgs e) { ViewModel.SetCtrlState(e.KeyboardDevice.IsKeyDown(Key.LeftCtrl)); switch (e.Key) { case Key.Z when e.KeyboardDevice.IsKeyDown(Key.LeftCtrl): if (e.KeyboardDevice.IsKeyDown(Key.LeftShift)) { ViewModel.Redo(); } else { ViewModel.Undo(); } break; case Key.LeftShift: ViewModel.SetShiftState(true); break; case Key.D1: ViewModel.SelectTool(SelectedTool.Silicon); break; case Key.D2: ViewModel.SelectTool(SelectedTool.Metal); break; case Key.D3: ViewModel.SelectTool(SelectedTool.AddOrDeleteVia); break; case Key.D4: ViewModel.SelectTool(SelectedTool.Selection); break; case Key.D5: ViewModel.SelectTool(SelectedTool.DeleteMetalOrSilicon); break; case Key.D6: ViewModel.SelectTool(SelectedTool.TopologyDebug); break; } }
public static void Initialize() { MouseDevice = new MouseDevice(); KeyboardDevice = new KeyboardDevice(); AvaloniaLocator.CurrentMutable .Bind <IRuntimePlatform>().ToSingleton <StandardRuntimePlatform>() .Bind <IClipboard>().ToTransient <Clipboard>() // TODO: what does this look like for iOS?? //.Bind<ISystemDialogImpl>().ToTransient<SystemDialogImpl>() .Bind <IStandardCursorFactory>().ToTransient <CursorFactory>() .Bind <IKeyboardDevice>().ToConstant(KeyboardDevice) .Bind <IMouseDevice>().ToConstant(MouseDevice) .Bind <IPlatformSettings>().ToSingleton <PlatformSettings>() .Bind <IPlatformThreadingInterface>().ToConstant(PlatformThreadingInterface.Instance) .Bind <IPlatformIconLoader>().ToSingleton <PlatformIconLoader>(); }
void ProcessKeyUp(MacOSKeyCode code) { Key key; Keymap.TryGetValue(code, out key); // Legacy keyboard API KeyboardDevice keyboard = InputDriver.Keyboard[0]; keyboard.SetKey(key, (uint)code, false); // Raise KeyUp for new keyboard API mKeyUpArgs.Key = key; mKeyDownArgs.Modifiers = keyboard.GetModifiers(); KeyUp(this, mKeyUpArgs); }
/// <inheritdoc/> protected override void OnKeyDown(KeyboardDevice device, Key key, ModifierKeys modifiers, ref RoutedEventData data) { switch (key) { case Key.Left: DecreaseSmall(); data.Handled = true; break; case Key.Right: IncreaseSmall(); data.Handled = true; break; } base.OnKeyDown(device, key, modifiers, ref data); }
protected override void LoadContent() { // Setup engine. We do this in the load method // so that we know graphics will be ready for use Engine.SetupEngine(graphics); // Setup Inputs MouseDevice mouse = new MouseDevice(); KeyboardDevice keyboard = new KeyboardDevice(); Engine.Services.AddService(typeof(MouseDevice), mouse); Engine.Services.AddService(typeof(KeyboardDevice), keyboard); // Add MenuScreen Engine.AddScreen(new IntroScreen("IntroScreen")); Trace.WriteLine(Engine.GameScreens[0].Name); }
public Machine(Form uiForm) { picDevice = new PIC8259(); vgaDevice = new VGA(); FloppyDrive = new Floppy(); dmaController = new DMAController(); keyboard = new KeyboardDevice(); ataDevice = new ATA(); if (SystemConfig.Machine.Floppies.Count > 0) { FloppyDrive.MountImage(SystemConfig.Machine.Floppies[0].Image); } switch (Settings.Default.graphics.ToUpper()) { case "XNA": gui = new XNAUI(uiForm, vgaDevice); break; case "SDL": gui = new SDLUI(uiForm, vgaDevice); break; } Application.Idle += new System.EventHandler(ApplicationIdle); gui.KeyDown += new EventHandler <UIntEventArgs>(GUIKeyDown); gui.KeyUp += new EventHandler <UIntEventArgs>(GUIKeyUp); gui.Init(); devices = new IDevice[] { FloppyDrive, new CMOS(ataDevice), new Misc(), new PIT8253(), picDevice, keyboard, dmaController, vgaDevice, ataDevice }; CPU = new CPU.CPU(); picDevice.Interrupt += PicDeviceInterrupt; SetupSystem(); CPU.IORead += CPUIORead; CPU.IOWrite += CPUIOWrite; }
private static void KeyboardMouseTest(MouseDevice mouse, KeyboardDevice keyboard) { Console.WriteLine("Wait for usbip..."); while (true) { Console.Write("."); if (mouse.Connected == true) { break; } Thread.Sleep(1000); } bool mouseMode = false; while (true) { Console.Write(((mouseMode == true) ? "Mouse" : "Keyboard") + "> "); string text = Console.ReadLine(); if (text == "quit") { break; } if (text == "--mode") { mouseMode ^= mouseMode; continue; } Thread.Sleep(2000); if (mouseMode == true) { mouse.SendText(text); } else { keyboard.SendText(text); } } }
public PresentationSource(UIElement rootElement, HtmlRenderElementFactory htmlRenderElementFactory, HtmlValueConverter converter, ImageElementContainer imageElementContainer, SvgDefinitionContainer svgDefinitionContainer) { this.RootElement = rootElement; this.converter = converter; RootElement.IsRootElement = true; MouseDevice = new MouseDevice(this); KeyboardDevice = new KeyboardDevice(this); window = Bridge.Html5.Window.Instance; MouseDevice.CursorChanged += (sender, e) => Bridge.Html5.Window.Document.Body.SetHtmlStyleProperty("cursor", converter.ToCursorString(MouseDevice.Cursor, htmlRenderElementFactory)); Bridge.Html5.Window.Document.Body.SetHtmlStyleProperty("cursor", converter.ToCursorString(MouseDevice.Cursor, htmlRenderElementFactory)); Bridge.Html5.Window.OnKeyDown = OnKeyDown; Bridge.Html5.Window.OnKeyUp = OnKeyUp; Bridge.Html5.Window.OnKeyPress = PreventKeyboardHandled; Bridge.Html5.Window.OnMouseMove = OnMouseMove; Bridge.Html5.Window.OnMouseDown = OnMouseDown; Bridge.Html5.Window.OnMouseUp = OnMouseUp; Bridge.Html5.Window.OnScroll = OnMouseWheel; Bridge.Html5.Window.OnFocus = e => MouseDevice.Activate(); Bridge.Html5.Window.OnBlur = e => MouseDevice.Deactivate(); Bridge.Html5.Window.OnResize = e => SetRootElementSize(); Bridge.Html5.Window.OnClick = PreventMouseHandled; Bridge.Html5.Window.OnContextMenu = PreventMouseHandled; Bridge.Html5.Window.AddEventListener("ondblclick", PreventMouseHandled); Bridge.Html5.Window.AddEventListener("wheel", OnMouseWheel); SetRootElementSize(); ((FrameworkElement)RootElement).Arrange(new Rect(window.InnerWidth, window.InnerHeight)); IHtmlRenderElement renderElement = ((IHtmlRenderElement)RootElement.GetRenderElement(htmlRenderElementFactory)); renderElement.Load(); Bridge.Html5.Window.Document.Body.Style.Overflow = Overflow.Hidden; Bridge.Html5.Window.Document.Body.AppendChild(imageElementContainer.HtmlElement); Bridge.Html5.Window.Document.Body.AppendChild(svgDefinitionContainer.HtmlElement); Bridge.Html5.Window.Document.Body.AppendChild(renderElement.HtmlElement); MouseDevice.Activate(); KeyboardDevice.Activate(); }
public override void Update(KeyboardDevice keyboard) { base.Update(keyboard); if (spikeCooldown-- < 0) { spikeCooldown = SPIKECOOLDOWN + (int)(rand.NextDouble() * 30); if (controller.direction == -1) { owner.AddEntity(new ShootingSpikeBallEntity(controller.direction), position.X - 8, position.Y + height / 2.0); } else { owner.AddEntity(new ShootingSpikeBallEntity(controller.direction), position.X + Block.BLOCK_WIDTH + 8, position.Y + height / 2.0); } } }
public void UpdateKeyboardState(KeyboardDevice currentKeyboard) { if (v8.IsDisposed) { return; } // Copy keyboard state //TODO: copy state quicker. Should be able to transfer over in O(1) InternalHandle[] keyboard = new InternalHandle[(int)Key.LastKey]; for (int i = 0; i < keyboard.Length; i++) { int k = currentKeyboard[(Key)i] ? 1 : 0; keyboard[i] = v8.CreateValue(k); } v8.GlobalObject.SetProperty("Keyboard", v8.CreateArray(keyboard)); }
public static void Register() { var instance = new BlazorWindowingPlatform(); Keyboard = new KeyboardDevice(); AvaloniaLocator.CurrentMutable .Bind <IClipboard>().ToSingleton <ClipboardStub>() .Bind <ICursorFactory>().ToSingleton <CursorFactoryStub>() .Bind <IKeyboardDevice>().ToConstant(Keyboard) .Bind <IPlatformSettings>().ToConstant(instance) .Bind <IPlatformThreadingInterface>().ToConstant(instance) .Bind <IRenderLoop>().ToConstant(new RenderLoop()) .Bind <IRenderTimer>().ToConstant(ManualTriggerRenderTimer.Instance) .Bind <ISystemDialogImpl>().ToSingleton <SystemDialogsStub>() .Bind <IWindowingPlatform>().ToConstant(instance) .Bind <IPlatformIconLoader>().ToSingleton <IconLoaderStub>() .Bind <PlatformHotkeyConfiguration>().ToSingleton <PlatformHotkeyConfiguration>(); }
/// <inheritdoc/> protected override void OnKeyDown(KeyboardDevice device, Key key, ModifierKeys modifiers, RoutedEventData data) { OnKeyDown_General(device, key, modifiers, data); if (!data.Handled) { if (IsDropDownOpen) { OnKeyDown_DropDownOpen(device, key, modifiers, data); } else { OnKeyDown_DropDownClosed(device, key, modifiers, data); } } base.OnKeyDown(device, key, modifiers, data); }
/// <summary> /// Raises the key event. /// </summary> /// <param name="element">The element.</param> /// <param name="key">The key.</param> /// <param name="keyboardDevice">The keyboard device.</param> private void RaiseKeyEvent(UIElement element, Key key, KeyboardDevice keyboardDevice) { PresentationSource presentationSource = PresentationSource.FromVisual(element); int timestamp = Environment.TickCount; KeyEventArgs args = new KeyEventArgs(keyboardDevice, presentationSource, timestamp, key); args.RoutedEvent = Keyboard.PreviewKeyDownEvent; element.RaiseEvent(args); args.RoutedEvent = Keyboard.KeyDownEvent; element.RaiseEvent(args); args.RoutedEvent = Keyboard.PreviewKeyUpEvent; element.RaiseEvent(args); args.RoutedEvent = Keyboard.KeyUpEvent; element.RaiseEvent(args); }
private bool IsModDown(KeyboardDevice keyboard) { bool down = true; down &= (Mods & ModifierKeys.Alt) == ModifierKeys.Alt == (keyboard.IsKeyDown(Key.LeftAlt) || keyboard.IsKeyDown(Key.RightAlt)); down &= (Mods & ModifierKeys.Control) == ModifierKeys.Control == (keyboard.IsKeyDown(Key.LeftCtrl) || keyboard.IsKeyDown(Key.RightCtrl)); down &= (Mods & ModifierKeys.Shift) == ModifierKeys.Shift == (keyboard.IsKeyDown(Key.LeftShift) || keyboard.IsKeyDown(Key.RightShift)); down &= (Mods & ModifierKeys.Windows) == ModifierKeys.Windows == (keyboard.IsKeyDown(Key.LWin) || keyboard.IsKeyDown(Key.RWin)); return(down); }
private void txtDate_SelectedDateChanged(object sender, SelectionChangedEventArgs e) { if (_isEnterPressed) { _isEnterPressed = false; var args = new KeyEventArgs(_lastKeyboardDevice, _lastInputSource, _lastTimestamp, Key.Enter) { RoutedEvent = UIElement.KeyDownEvent }; _lastKeyboardDevice = null; _lastInputSource = null; _lastTimestamp = -1; this.RaiseEvent(args); } }
public void getModifiers(KeyboardDevice ks) { if (ks[Key.RShift]) { myModifiers |= (int)Modifiers.RSHIFT; } if (ks[Key.RControl]) { myModifiers |= (int)Modifiers.RCTRL; } if (ks[Key.RAlt]) { myModifiers |= (int)Modifiers.RALT; } if (ks[Key.LShift]) { myModifiers |= (int)Modifiers.LSHIFT; } if (ks[Key.LControl]) { myModifiers |= (int)Modifiers.LCTRL; } if (ks[Key.LAlt]) { myModifiers |= (int)Modifiers.LALT; } //if (ks[Key.Command]) myModifiers |= (int)Modifiers.COMMMAND; if (ks[Key.NumLock]) { myModifiers |= (int)Modifiers.NUMLOCK; } if (ks[Key.CapsLock]) { myModifiers |= (int)Modifiers.CAPSLOCK; } if (ks[Key.LWin]) { myModifiers |= (int)Modifiers.LWIN; } if (ks[Key.RWin]) { myModifiers |= (int)Modifiers.RWIN; } }
public override void Update(KeyboardDevice keyboard) { PipeZone zone = GetUnderlyingZone(); if (zone == null) { if (hasConnected) { hasFinished = true; zone = GetUnderlyingZone(); } } else { hasConnected = true; if (!zone.IsDirection(direction)) { direction = zone.GetOneDirection(); } speed = zone.GetSpeed(); } Vec2d delta = PipeZone.GetVectorForDirection(direction); delta.SetLength(speed); if (direction == PipeDirection.SOUTH || direction == PipeDirection.NORTH) { double corr = GetXCorrection(); delta.X += Math.Min(Math.Abs(corr), Math.Abs(speed * PIPECORRECTION_SPEEDFACTOR)) * Math.Sign(corr); } if (direction == PipeDirection.EAST || direction == PipeDirection.WEST) { double corr = GetYCorrection(); delta.Y += Math.Min(Math.Abs(corr), Math.Abs(speed * PIPECORRECTION_SPEEDFACTOR)) * Math.Sign(corr); } ent.position += delta; ent.DoCollisions(); deltaCache = delta; }
public override void Update(KeyboardDevice keyboard) { angle += ANGLESPEED; if (angle >= 2 * Math.PI) { angle -= 2 * Math.PI; } Vec2d newpos = new Vec2d(standardPos); newpos.rotateAround(midPos, -angle); newpos -= 4; deltaCache = newpos - ent.position; ent.position = newpos; ent.DoCollisions(); }
//bool disposed; #region --- Constructors --- /// <summary> /// Constructs a new X11Input driver. Creates a hidden InputOnly window, child to /// the main application window, which selects input events and routes them to /// the device specific drivers (Keyboard, Mouse, Hid). /// </summary> /// <param name="attach">The window which the InputDriver will attach itself on.</param> public X11Input(IWindowInfo attach) { Debug.WriteLine("Initalizing X11 input driver."); Debug.Indent(); if (attach == null) { throw new ArgumentException("A valid parent window must be defined, in order to create an X11Input driver."); } //window = new X11WindowInfo(attach); X11WindowInfo window = (X11WindowInfo)attach; // Init mouse mouse.Description = "Default X11 mouse"; mouse.DeviceID = IntPtr.Zero; mouse.NumberOfButtons = 5; mouse.NumberOfWheels = 1; dummy_mice_list.Add(mouse); using (new XLock(window.Display)) { // Init keyboard API.DisplayKeycodes(window.Display, ref firstKeyCode, ref lastKeyCode); Debug.Print("First keycode: {0}, last {1}", firstKeyCode, lastKeyCode); IntPtr keysym_ptr = API.GetKeyboardMapping(window.Display, (byte)firstKeyCode, lastKeyCode - firstKeyCode + 1, ref keysyms_per_keycode); Debug.Print("{0} keysyms per keycode.", keysyms_per_keycode); keysyms = new IntPtr[(lastKeyCode - firstKeyCode + 1) * keysyms_per_keycode]; Marshal.PtrToStructure(keysym_ptr, keysyms); API.Free(keysym_ptr); KeyboardDevice kb = new KeyboardDevice(); keyboard.Description = "Default X11 keyboard"; keyboard.NumberOfKeys = lastKeyCode - firstKeyCode + 1; keyboard.DeviceID = IntPtr.Zero; dummy_keyboard_list.Add(keyboard); // Request that auto-repeat is only set on devices that support it physically. // This typically means that it's turned off for keyboards (which is what we want). // We prefer this method over XAutoRepeatOff/On, because the latter needs to // be reset before the program exits. bool supported; Functions.XkbSetDetectableAutoRepeat(window.Display, true, out supported); } Debug.Unindent(); }
public override void Update(KeyboardDevice keyboard) { base.Update(keyboard); if (Program.debugViewSwitch.Value && Program.debugCoinCheatSwitch.Value) { for (int i = 0; i < 10; i++) { AddCoin(); } } if (Program.debugViewSwitch.Value && Program.debugHPCheatSwitch.Value) { AddHead(); } timeCounter.Value = (int)timeWatch.Elapsed.TotalSeconds; }
public override void Update(KeyboardDevice keyboard) { DoGravitationalMovement(Vec2d.Zero); if (ent.IsOnCeiling()) { movementDelta.Y = Math.Min(movementDelta.Y, 0); } if (ent.IsOnGround()) { movementDelta.Y = Y_SPEED; } if ((direction == 1 && ent.IsCollidingRight()) || (direction == -1 && ent.IsCollidingLeft())) { ent.KillLater(); } }
/// <summary> /// Handles the <see cref="Keyboard.KeyDownEvent"/> attached event for the view's topmost <see cref="Grid"/> instance. /// </summary> /// <param name="dobj">The object that raised the event.</param> /// <param name="device">The <see cref="KeyboardDevice"/> that raised the event.</param> /// <param name="key">The <see cref="Key"/> value that represents the key that was pressed.</param> /// <param name="modifiers">A <see cref="ModifierKeys"/> value indicating which of the key modifiers are currently active.</param> /// <param name="data">The routed event metadata for this event invocation.</param> public void HandleKeyDown(DependencyObject dobj, KeyboardDevice device, Key key, ModifierKeys modifiers, ref RoutedEventData data) { switch (key) { case Key.Escape: { Modal.ShowDialogAsync(escMenuDialog).ContinueWith(HandleEscMenuDialogResult); data.Handled = true; } break; case Key.AppControlBack: { ReturnToMainMenu(); data.Handled = true; } break; } }
/// <summary> /// Handles the <see cref="Keyboard.KeyDownEvent"/> attached event for the view's topmost <see cref="Grid"/> instance. /// </summary> /// <param name="dobj">The object that raised the event.</param> /// <param name="device">The <see cref="KeyboardDevice"/> that raised the event.</param> /// <param name="key">The <see cref="Key"/> value that represents the key that was pressed.</param> /// <param name="modifiers">A <see cref="ModifierKeys"/> value indicating which of the key modifiers are currently active.</param> /// <param name="data">The routed event metadata for this event invocation.</param> public void HandleKeyDown(DependencyObject dobj, KeyboardDevice device, Key key, ModifierKeys modifiers, RoutedEventData data) { switch (key) { case Key.Escape: { Modal.ShowDialogAsync(escMenuDialog).ContinueWith(HandleEscMenuDialogResult); data.Handled = true; } break; case Key.AppControlBack: { ReturnToMainMenu(); data.Handled = true; } break; } }
public static void Register() { GlFeature ??= new EaglFeature(); Timer ??= new DisplayLinkTimer(); var keyboard = new KeyboardDevice(); AvaloniaLocator.CurrentMutable .Bind <IPlatformOpenGlInterface>().ToConstant(GlFeature) .Bind <ICursorFactory>().ToConstant(new CursorFactoryStub()) .Bind <IWindowingPlatform>().ToConstant(new WindowingPlatformStub()) .Bind <IClipboard>().ToConstant(new ClipboardImpl()) .Bind <IPlatformSettings>().ToConstant(new PlatformSettings()) .Bind <IPlatformIconLoader>().ToConstant(new PlatformIconLoaderStub()) .Bind <PlatformHotkeyConfiguration>().ToSingleton <PlatformHotkeyConfiguration>() .Bind <IRenderLoop>().ToSingleton <RenderLoop>() .Bind <IRenderTimer>().ToConstant(Timer) .Bind <IPlatformThreadingInterface>().ToConstant(new PlatformThreadingInterface()) .Bind <IKeyboardDevice>().ToConstant(keyboard); }
/// <inheritdoc/> protected override void OnKeyDown(KeyboardDevice device, Key key, ModifierKeys modifiers, RoutedEventData data) { var target = default(UIElement); switch (key) { case Key.Tab: if ((modifiers & ModifierKeys.Control) == ModifierKeys.Control) { if ((modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) { target = GetNextEnabledTabItem(SelectedIndex, -1); } else { target = GetNextEnabledTabItem(SelectedIndex, 1); } } break; case Key.Home: if (Items.Count > 0) { target = GetNextEnabledTabItem(Items.Count - 1, 1); } break; case Key.End: if (Items.Count > 0) { target = GetNextEnabledTabItem(0, -1); } break; } if (target != null && !target.IsFocused) { data.Handled = target.Focus(); } base.OnKeyDown(device, key, modifiers, data); }
public virtual void Update(KeyboardDevice keyboard) { for (int i = delayedActionList.Count - 1; i >= 0; i--) { if (delayedActionList[i].DecInvoke()) { delayedActionList.RemoveAt(i); } } BooleanKeySwitch.UpdateAll(keyboard); foreach (DynamicEntity e in GetCurrentEntityList()) { e.Update(keyboard); e.UpdateCollisionMapPosition(); } foreach (Block e in GetCurrentBlockList()) { e.Update(keyboard); } foreach (Trigger t in triggerList) { t.Update(keyboard); } foreach (DynamicEntity e in killList) { if (!RemoveEntity(e)) { Console.Error.WriteLine("Could not KillLater Entity: " + e); } } killList.Clear(); if (HUD != null) { HUD.Update(keyboard); } }
// Initializor============================================= public override void Initialize() { // Initialize the keyboard keyboard = Engine.Services.GetService<KeyboardDevice>(); mouseDevice = Engine.Services.GetService<MouseDevice>(); mouseDevice.ResetMouseAfterUpdate = false; Texture2D texture; Texture2D level_finish_bg=Engine.Content.Load<Texture2D>("Content\\Textures\\level_finish_bg"); hand = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\hand"), new Vector2(mouseDevice.State.X, mouseDevice.State.Y), this); // Initialize the Game Text string level="LEVEL " + GlobalVariables.level.ToString() + " COMPLETE"; titleText = new EntityText(Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24"), new Vector2((Engine.Viewport.Width / 2) - 20, 200), level, this); string score = "Score: " + GlobalVariables.score.ToString()+" points."; scoreText = new EntityText(Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24"), new Vector2((Engine.Viewport.Width / 2) - 120, 270), score, this); string money = "Money: " + GlobalVariables.money.ToString() + " Dirhams"; moneyText = new EntityText(Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24"), new Vector2((Engine.Viewport.Width / 2) - 120, 330), money, this); // Initialize the black texture texture = Engine.Content.Load<Texture2D>("Content\\Textures\\next_btn"); nextBtn = new Button(texture, new Vector2(475, 380), this); background = new Entity2D(level_finish_bg, Vector2.Zero, this); background.Alpha = 0f; background.Position = new Vector2((Engine.Viewport.Width / 2) - (background.Texture.Width / 2), (Engine.Viewport.Height / 2) - (background.Texture.Height / 2)); fade = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\black"), Vector2.Zero, this); fade.Alpha = 0.4f; base.Initialize(); }
static void Main(string[] args) { // Create memory and load the program and arguments (if present). _mem = new MemoryController(); if (args.Length >= 1) { _mem.LoadProgram(args[0], args.Skip(1)); } else if (args.Length == 1) { _mem.LoadProgram(args[0]); } InterruptHandler interruptHandler = new InterruptHandler(_mem); _mappedDevices = new List <IMemoryMappedDevice>(); // Create a memory mapped console device. ConsoleDevice consoleDevice = new ConsoleDevice(_mem, interruptHandler, 1048448, 128); _mappedDevices.Add(consoleDevice); KeyboardDevice keyboardDevice = new KeyboardDevice(_mem, interruptHandler, 1048319, 128); _mappedDevices.Add(keyboardDevice); DisplayDevices(_mem, _mappedDevices, interruptHandler); Console.WriteLine(); Console.WriteLine("Ready. Press enter to begin..."); Console.ReadLine(); Console.Clear(); // Start the keyboard device. keyboardDevice.StartDevice(); _mem.DebugWrite(); // Create the CPU and start it running. _cpu = new CPU(_mem, interruptHandler); _cpu.Run(); Console.ReadLine(); }
public void HotKeyManager_Should_Invoke_Event_Click_When_Command_Is_Null(string factoryName, Factory factory) { using (AvaloniaLocator.EnterScope()) { var styler = new Mock <Styler>(); var target = new KeyboardDevice(); var clickExecutedCount = 0; AvaloniaLocator.CurrentMutable .Bind <IWindowingPlatform>().ToConstant(new WindowingPlatformMock()) .Bind <IStyler>().ToConstant(styler.Object); var gesture = new KeyGesture(Key.A, KeyModifiers.Control); void Clickable_Click(object sender, Interactivity.RoutedEventArgs e) { clickExecutedCount++; } var root = new Window(); var element = factory(0, default, root) as InputElement;
private void OnPreProcessInput(object sender, PreProcessInputEventArgs e) { KeyboardDevice keyboard = InputManager.Current.PrimaryKeyboardDevice; ModifierKeys currentModifiers = keyboard.Modifiers; if (!((currentModifiers & ModifierKeys.Control) != 0 && (currentModifiers & ModifierKeys.Shift) != 0)) { return; } Visual directlyOver = Mouse.PrimaryDevice.DirectlyOver as Visual; if ((directlyOver == null) || directlyOver.IsDescendantOf(_crackRootVisual)) { return; } ViewModel.SelectItem(directlyOver); }
/// <summary> /// Handles the <see cref="Keyboard.PreviewKeyDownEvent"/> routed event. /// </summary> private static void HandlePreviewKeyDown(DependencyObject element, KeyboardDevice device, Key key, ModifierKeys modifiers, RoutedEventData data) { var numericUpDown = (NumericUpDown)element; if (numericUpDown.PART_Input == data.OriginalSource) { switch (key) { case Key.Up: numericUpDown.Value += numericUpDown.SmallChange; data.Handled = true; break; case Key.Down: numericUpDown.Value -= numericUpDown.SmallChange; data.Handled = true; break; } } }
public void TextInput_Should_Be_Sent_To_Focused_Element() { var target = new KeyboardDevice(); var focused = new Mock <IInputElement>(); var root = Mock.Of <IInputRoot>(); target.SetFocusedElement( focused.Object, NavigationMethod.Unspecified, KeyModifiers.None); target.ProcessRawEvent( new RawTextInputEventArgs( target, 0, root, "Foo")); focused.Verify(x => x.RaiseEvent(It.IsAny <TextInputEventArgs>())); }
public override void Update(KeyboardDevice keyboard) { if (standardY == Double.MinValue) { standardY = ent.position.Y; } floatpos++; if (floatpos >= floatDur) { floatpos -= floatDur; } double inc = Math.Sin((floatpos * 2 * Math.PI) / floatDur) * floatDist; ent.position.Y = standardY + inc; ent.DoCollisions(); }
private void CallControllerStack(KeyboardDevice keyboard) { if (controllerStack.Count != 0) { controllerStack.Peek().Update(keyboard); if (!controllerStack.Peek().IsActive()) { controllerStack.Pop(); if (HasController()) { controllerStack.Peek().OnReshow(); } } } else { Console.Out.WriteLine("ERROR: STACK IS EMPTY::" + GetType().Name); } }
public override void Initialize() { // Initialize the keyboard keyboard = Engine.Services.GetService<KeyboardDevice>(); mouseDevice = Engine.Services.GetService<MouseDevice>(); mouseDevice.ResetMouseAfterUpdate=false; // Initialize Components Texture2D texture; black = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\black"), Vector2.Zero, this); hand = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\hand"), new Vector2(mouseDevice.State.X, mouseDevice.State.Y), this); // Initialize Buttons texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuPlayBtn"); menuPlay = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 270), this); //texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuOptionsBtn"); //menuOptions = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 315), this); //texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuWhoBtn"); //menuWho = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 360), this); texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuQuitBtn"); menuQuit = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 325), this); texture = Engine.Content.Load<Texture2D>("Content\\Textures\\MenuTitle"); menuTitle = new Entity2D(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 155), this); texture=Engine.Content.Load<Texture2D>("Content\\Textures\\MenuBall"); menuBall = new Entity2D(texture, new Vector2(473,81), this); background = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\MenuBackground"), Vector2.Zero, this); base.Initialize(); }
public override void Initialize() { // Initialize the keyboard keyboard = Engine.Services.GetService<KeyboardDevice>(); // Initialize Components Texture2D texture; black = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\black"), Vector2.Zero, this); texture = Engine.Content.Load<Texture2D>("Content\\Textures\\loadingText"); loading = new Entity2D(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 493), this); texture = Engine.Content.Load<Texture2D>("Content\\Textures\\Press_ENTER"); pressEnter = new Entity2D(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 493), this); pressEnter.Visible = false; background = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\LoadScreen"), Vector2.Zero, this); base.Initialize(); }
// Initializor============================================= public override void Initialize() { // Initialize the keyboard keyboard = Engine.Services.GetService<KeyboardDevice>(); fade = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\black"), Vector2.Zero, this); // Initialize the GameOverText gameOverText = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\gameOver"), new Vector2((Engine.Viewport.Width / 2) - 40, (Engine.Viewport.Height / 2)), this); gameOverText.Position = new Vector2((Engine.Viewport.Width / 2) - (gameOverText.Texture.Width/2) , (Engine.Viewport.Height / 2) - (gameOverText.Texture.Height / 2)); // Initialize the black texture background = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\MenuBackground"), Vector2.Zero, this); GlobalVariables.speedFactor = 0.10f; GlobalVariables.level = 1; GlobalVariables.score = 0; GlobalVariables.resistance = 0; base.Initialize(); }
/// <summary> /// Invokes the <see cref="OnTextEditing"/> method. /// </summary> private static void OnTextEditingProxy(DependencyObject element, KeyboardDevice device, RoutedEventData data) { ((UIElement)element).OnTextEditing(device, data); }
/// <summary> /// Invokes the <see cref="OnKeyDown"/> method. /// </summary> private static void OnKeyDownProxy(DependencyObject element, KeyboardDevice device, Key key, ModifierKeys modifiers, RoutedEventData data) { ((UIElement)element).OnKeyDown(device, key, modifiers, data); }
/// <summary> /// Invokes the <see cref="OnKeyUp"/> method. /// </summary> private static void OnKeyUpProxy(DependencyObject element, KeyboardDevice device, Key key, RoutedEventData data) { ((UIElement)element).OnKeyUp(device, key, data); }
/// <summary> /// Invoked when a <see cref="Keyboard.TextEditingEvent"/> attached routed event occurs. /// </summary> /// <param name="device">The <see cref="KeyboardDevice"/> that raised the event.</param> /// <param name="data">The routed event metadata for this event invocation.</param> protected virtual void OnTextEditing(KeyboardDevice device, RoutedEventData data) { }
/// <summary> /// Invokes the <see cref="OnLostKeyboardFocus"/> method. /// </summary> private static void OnLostKeyboardFocusProxy(DependencyObject element, KeyboardDevice device, IInputElement oldFocus, IInputElement newFocus, RoutedEventData data) { ((UIElement)element).OnLostKeyboardFocus(device, oldFocus, newFocus, data); }
/// <summary> /// Invoked when a <see cref="Keyboard.TextInputEvent"/> attached routed event occurs. /// </summary> /// <param name="device">The <see cref="KeyboardDevice"/> that raised the event.</param> /// <param name="data">The routed event metadata for this event invocation.</param> protected virtual void OnTextInput(KeyboardDevice device, RoutedEventData data) { }
/// <summary> /// Invoked when a <see cref="Keyboard.KeyUpEvent"/> attached routed event occurs. /// </summary> /// <param name="device">The <see cref="KeyboardDevice"/> that raised the event.</param> /// <param name="key">The <see cref="Key"/> value that represents the key that was pressed.</param> /// <param name="data">The routed event metadata for this event invocation.</param> protected virtual void OnKeyUp(KeyboardDevice device, Key key, RoutedEventData data) { }
/// <summary> /// Invoked when a <see cref="Keyboard.KeyDownEvent"/> attached routed event occurs. /// </summary> /// <param name="device">The <see cref="KeyboardDevice"/> that raised the event.</param> /// <param name="key">The <see cref="Key"/> value that represents the key that was pressed.</param> /// <param name="modifiers">A <see cref="ModifierKeys"/> value indicating which of the key modifiers are currently active.</param> /// <param name="data">The routed event metadata for this event invocation.</param> protected virtual void OnKeyDown(KeyboardDevice device, Key key, ModifierKeys modifiers, RoutedEventData data) { }
/// <summary> /// Invoked when a <see cref="Keyboard.LostKeyboardFocusEvent"/> attached routed event occurs. /// </summary> /// <param name="device">The keyboard device that raised the event.</param> /// <param name="oldFocus">The element that previously had focus.</param> /// <param name="newFocus">The element that currently has focus.</param> /// <param name="data">The routed event metadata for this event invocation.</param> protected virtual void OnLostKeyboardFocus(KeyboardDevice device, IInputElement oldFocus, IInputElement newFocus, RoutedEventData data) { }
public KeyboardEventArgs(KeyboardDevice keyboard, int timestamp) : base(keyboard, timestamp) { }