/// <summary> /// Methode zum prüfen der Inputs für das Kamear zoomen /// </summary> private void event0() { //Tastatur Eingabe if (Input.GetKey(CameraZoomInKey)) { IInputListener obj = null; if (callback.TryGetValue(0, out obj)) { obj.callBack(0, -1); } } if (Input.GetKey(CameraZoomOutKey)) { IInputListener obj = null; if (callback.TryGetValue(0, out obj)) { obj.callBack(0, 1); } } //Mausrad prüfung if (Input.mouseScrollDelta.y != 0) { //Es wird versucht ein Listener für das Kamera Zoomen zu erhalten IInputListener obj = null; if (callback.TryGetValue(0, out obj)) { //Wenn es eine Kamera gibt die sich angemeldet hatt soll für diese Scrollen ausgefüht werden obj.callBack(0, (int)Input.mouseScrollDelta.y * (CameraZoomMouseInvert ? 1 : -1)); } } }
public void EnableListener(IInputListener listener) { if (disabledListeners.Contains(listener)) { disabledListeners.Remove(listener); } }
public static void SetListener(IInputListener listener) { if (s_input != null) { s_input.SetListenerInternal(listener); } }
public JoystickInfo(string name, Joysticks joystick, JoystickButton[] buttons, JoystickAxis[] axes, IInputListener[] listeners) : base(name, listeners) { _joystick = joystick; _buttons = new List<JoystickButton>(buttons); _axes = new List<JoystickAxis>(axes); }
public void Shutdown() { isShuttingDown = true; PlayerLoopSubscriptionController.Shutdown(); _inputListener = null; playerController = null; }
public void AddInputListener(IEntity pEntity) { //Create a temporary IEntity that stores pEntity IEntity tempEnt = pEntity; //Check if tempEnt is an IInputListener if (tempEnt is IInputListener) { //This retrieves the Id of temp ent to be stored. int tempID = tempEnt.eID; //Casts tempent as an IInputlistener IInputListener newInput = (IInputListener)tempEnt; //Intialise Input newInput.Initialize(tempID); //the new input gets placed inside an array _mInputs _mInputs.Add(newInput); if (newInput is IPlayerControler) { //cast the Input as anew IPlayerCollider IPlayerControler newPlayer = (IPlayerControler)newInput; //ad this to the Iplayer List _mPlayers.Add(newPlayer); } } }
protected ControllerInfo(string name, IInputListener[] listeners) { this.name = name; this.listeners = new List<IInputListener>(listeners); SetListeners(); }
public void OnFreamAsyn(SCFrameNotify frameAsyn) { if (!_isGameing) { return; } // 无操作的帧, 直接跑过去 if (_nextFrameSetp < frameAsyn.CurrentFrame) { TickerManager.Instance.DriveToTickCount(frameAsyn.CurrentFrame - 1); _nextFrameSetp = frameAsyn.CurrentFrame; } // 这个是我们需要的 if (_nextFrameSetp != frameAsyn.CurrentFrame) { return; } // 按按键 foreach (CSFrameNotify frameControlList in frameAsyn.Keys) { if (_inputListeners.ContainsKey(frameControlList.Uin)) { IInputListener listener = _inputListeners[frameControlList.Uin]; foreach (var con in frameControlList.Keys) { #region 解析按键 ushort key = (ushort)con; ushort type = (byte)(key & 0x3); key >>= 2; ushort value = (ushort)(key & 0x3FF); key >>= 10; key &= 0xF; #endregion if (key == InputDefine.DIRCTION_KEY) { float ang = value; if (CommonFunction.GreatOrEqualZero(ang - 180f)) { ang -= 360f; } listener.OnMove(ang, (MoveType)type); } else { if (type > 0) { listener.OnFunctionKeyDown(key); } else { listener.OnFunctionKeyUp(key); } } } } } _nextFrameSetp = frameAsyn.NextFrame; TickerManager.Instance.DriveToTickCount(_nextFrameSetp - 1); }
private InputListenerWrapper GetWrapper(IInputListener listener) { var activeListener = (from item in _listeners where item.IsAlive && Equals(item.Listener, listener) select item).FirstOrDefault(); return(activeListener); }
public InteractionsManager(IInputListener listener) { if (listener == null) throw new ArgumentNullException("listener"); Listener = listener; GestureRecognitionLatency = TimeSpan.FromMilliseconds(500); }
public void OnFrameAsyn(SCFrameNotify frameAsyn) { if (!_isGaming) { return; } //无操作的帧直接跑 if (_nextFrameStep < frameAsyn.CurrentFrame) { TickerManager.Instance.DriveToTickCount(frameAsyn.CurrentFrame - 1); _nextFrameStep = frameAsyn.CurrentFrame; } //当前帧判断内容 if (_nextFrameStep == frameAsyn.CurrentFrame) { //按键 foreach (var frameControlList in frameAsyn.Keys) { IInputListener listener = _inputListeners[frameControlList.Uin]; foreach (var con in frameControlList.Keys) { #region 解析按键 UInt16 key = (UInt16)con; //后两位是类型 up down UInt16 type = (Byte)(key & 0x3); key >>= 2; //值 0~2^10 范围 UInt16 value = (UInt16)(key & 0x3ff); key >>= 10; //自定义类型 key &= 0xf; #endregion if (key == InputDefine.DIRCTION_KEY) { float angle = value; if (CommonFunction.GreatOrEqualZero(angle - 180f)) { angle -= 360f; } listener.OnMove(angle, (MoveType)type); } else { if (type > 0) { listener.OnFunctionKeyDown(key); } else { listener.OnFunctionKeyUp(key); } } } } _nextFrameStep = frameAsyn.NextFrame; TickerManager.Instance.DriveToTickCount(_nextFrameStep - 1); } }
public KeyboardInfo(string name, KeyboardButton[] buttons, KeyboardAxis[] axes, IInputListener[] listeners) : base(name, listeners) { _buttons = new List<KeyboardButton>(buttons); _axes = new List<KeyboardAxis>(axes); BuildNameButtonDict(); BuildNameAxisDict(); }
/// <summary> /// Deregisters an InputListener. /// </summary> public void RemoveInputListener(IInputListener listener) { for (int i = 0; i < 4; i++) { if (inputListeners [i].Contains(listener)) { inputListeners [i].Remove(listener); } } }
public static void removeListener(IInputListener obj) { foreach (IInputListener item in mListeners) { if (item == obj) { mListeners.Remove(item); return; } } }
/// <summary> /// Registers an InputListener that listens to a specific Joystick. /// </summary> public void AddInputListener(IInputListener listener, string joystickName) { for (int i = 0; i < 4; i++) { string _joystickName = JOYSTICK_NAMES [i]; if (_joystickName == joystickName && !inputListeners [i].Contains(listener)) { inputListeners [i].Add(listener); return; } } }
// For 'Any input', just give it an empty string. public void AddInputListener(string inputName, IInputListener listener) { if (!mInputListeners.ContainsKey(inputName)) { mInputListeners.Add(inputName, new List <IInputListener>()); } if (!mInputListeners[inputName].Contains(listener)) { mInputListeners[inputName].Add(listener); } }
public void UnregisterListener(InputCategory category, IInputListener listener) { List <IInputListener> listenerList; if (m_CategoryInputListener.TryGetValue(category, out listenerList)) { listenerList.Remove(listener); } else { // TODO hans: handle errors } }
public bool Create(IInputListener listener, out IInputProvider provider) { try { provider = new KinectProvider(listener); return provider.Available; } catch { provider = null; return false; } }
public void RegisterListener(KeyCategory keyCategory, IInputListener listener) { List <IInputListener> listenerList; if (m_InputListener.TryGetValue(keyCategory, out listenerList)) { listenerList.Add(listener); } else { // TODO hans: handle errors } }
/// <summary> /// Methode zum prüfen der Inputs für das Kamear Bewegen /// </summary> private void event1() { //Tastatur Eingabe if (Input.GetKey(CamereMoveLKey)) { IInputListener obj = null; float[] param = { -1.0f, 0.0f }; if (callback.TryGetValue(1, out obj)) { obj.callBack(1, param); } } if (Input.GetKey(CamereMoveRKey)) { IInputListener obj = null; float[] param = { 1.0f, 0.0f }; if (callback.TryGetValue(1, out obj)) { obj.callBack(1, param); } } if (Input.GetKey(CamereMoveFKey)) { IInputListener obj = null; float[] param = { 0.0f, 1.0f }; if (callback.TryGetValue(1, out obj)) { obj.callBack(1, param); } } if (Input.GetKey(CamereMoveBKey)) { IInputListener obj = null; float[] param = { 0.0f, -1.0f }; if (callback.TryGetValue(1, out obj)) { obj.callBack(1, param); } } if (Input.GetMouseButton(CameraMoveMouseButton)) { IInputListener obj = null; float[] param = { mousePositionDelta.x, -mousePositionDelta.y }; if (callback.TryGetValue(1, out obj)) { obj.callBack(1, param); } } }
/// <summary> /// Methode zum prüfen der Inputs für das Kamear Bewegen /// </summary> private void event2() { //Tastatur Eingabe if (Input.GetKey(CamereRotateLKey)) { IInputListener obj = null; float[] param = { -1.0f, 0.0f }; if (callback.TryGetValue(2, out obj)) { obj.callBack(2, param); } } if (Input.GetKey(CamereRotateRKey)) { IInputListener obj = null; float[] param = { 1.0f, 0.0f }; if (callback.TryGetValue(2, out obj)) { obj.callBack(2, param); } } if (Input.GetKey(CamereRotateUKey)) { IInputListener obj = null; float[] param = { 0.0f, 1.0f }; if (callback.TryGetValue(2, out obj)) { obj.callBack(2, param); } } if (Input.GetKey(CamereRotateDKey)) { IInputListener obj = null; float[] param = { 0.0f, -1.0f }; if (callback.TryGetValue(2, out obj)) { obj.callBack(2, param); } } if (Input.GetMouseButton(CameraRotateMouseButton)) { IInputListener obj = null; float[] param = { mousePositionDelta.x, mousePositionDelta.y }; if (callback.TryGetValue(2, out obj)) { obj.callBack(2, param); } } }
public ClassicGameLauncher( IInputListener inputListener, ISentenceLoader sentenceLoader, ITimeService timeService, ITypingCalculator typingCalculator, ICommandInvoker commandInvoker, IGameRenderer gameRenderer) : base(inputListener) { _sentenceLoader = sentenceLoader; _timeService = timeService; _typingCalculator = typingCalculator; _commandInvoker = commandInvoker; _gameRenderer = gameRenderer; }
public MouseProvider(IInputListener listener) { if (listener == null) throw new ArgumentNullException("listener"); Listener = listener; Enabled = true; provider = new MousePositionProvider("left", this); providers = new IPositionProvider[] { provider }; actionsTimer = new Timer(delegate { ThreadFunction(); }, null, TimeSpan.Zero, TimeSpan.FromSeconds(1 / 30.0)); }
public static void RegisterListener(IInputListener newListener) { if (newListener != null && !InputManager.Instance.inputListeners.Contains(newListener)) { InputManager.Instance.inputListeners.Add(newListener); newListener.OnInputEnabled(); } else if (newListener == null) { Debug.LogError("InputManager: IInputListener a registrar es NULL."); } else { Debug.LogError("InputManager: Has intentado registrar un IInputListener que ya estaba suscrito previamente."); } }
public void Unregister(IInputListener listener) { if (PointerDownCalls.Contains(listener)) { PointerDownCalls.Remove(listener); } if (PointerUpCalls.Contains(listener)) { PointerUpCalls.Remove(listener); } if (PointerMoveCalls.Contains(listener)) { PointerMoveCalls.Remove(listener); } if (PointerClickCalls.Contains(listener)) { PointerClickCalls.Remove(listener); } if (PointerDoubleClickCalls.Contains(listener)) { PointerDoubleClickCalls.Remove(listener); } if (PointerHoldStartCalls.Contains(listener)) { PointerHoldStartCalls.Remove(listener); } if (PointerHoldUpdateCalls.Contains(listener)) { PointerHoldUpdateCalls.Remove(listener); } if (PointerHoldEndCalls.Contains(listener)) { PointerHoldEndCalls.Remove(listener); } if (PointerSwipeStartCalls.Contains(listener)) { PointerSwipeStartCalls.Remove(listener); } if (PointerSwipeUpdateCalls.Contains(listener)) { PointerSwipeUpdateCalls.Remove(listener); } if (PointerSwipeEndCalls.Contains(listener)) { PointerSwipeEndCalls.Remove(listener); } }
private void StartGame() { _view.gameObject.SetActive(true); var gameParams = new GameParams { BallSize = RandomUtils.GetRandomInRange(Model.BallSizeRange), BallColor = Model.RandomBallColorOnStart ? RandomUtils.GetRandomColor() : Model.BallColor, StartForce = Model.GetStartForce() }; _view.SetupBall(gameParams); var startPos = _view.Width / 2; _inputListener = Model.ControlType == ControlType.ControlPanels ? new ControlSideListener(_view.LeftSide, _view.RightSide, Model.PlatformSpeed) : (IInputListener) new PointerPositionListener(); _view.MovePlatforms(startPos); }
public void DeregisterListenerEvents(IInputListener listener) { if (listener is IMouseButtonStateListener mouseListener) { MouseButtonStateEventHandler -= mouseListener.HandleMouseButtonState; } if (listener is IScrollWheelListener scrollListener) { ScrollWheelEventHandler -= scrollListener.HandleScrollWheel; } if (listener is IHotKeyListener hotKeyListener) { HotKeyStateEventHandler -= hotKeyListener.HandleHotKeyState; } }
public static void UnregisterListener(IInputListener listenerToRemove) { if (listenerToRemove != null && InputManager.Instance.inputListeners.Contains(listenerToRemove)) { listenerToRemove.UpdateInput(PlayerInput.NullInput); listenerToRemove.OnInputDisabled(); InputManager.Instance.inputListeners.Remove(listenerToRemove); } else if (listenerToRemove == null) { Debug.LogError("InputManager: IInputListener a que se pretende des-registrar es NULL."); } else { Debug.LogError("InputManager: Has intentado des-registrar un IInputListener que no estaba suscrito previamente."); } }
public void HandleInput() { while (Terminal.HasInput()) { int input = Terminal.Read(); if (input == Terminal.TK_MOUSE_LEFT) { PaneBounds target = GetTopPaneBounds(MousePos()); IInputListener newFocus = target.Pane.Focus(MousePos()); _windowListeners[target] = newFocus; if (newFocus != _focus) { _focus.LoseFocus(); _focus = newFocus; } target.Pane.OnMouseClick(MousePos()); } else if (input == Terminal.TK_MOUSE_MOVE) { _windowListeners.Keys.Last().Pane.OnMouseMove(_mouseLast, MousePos()); _mouseLast = MousePos(); } else if (input < Terminal.TK_MOUSE_LEFT) // All key presses { if (_gameControlConsumer.Consume(input)) { continue; } if ((input & Terminal.TK_KEY_RELEASED) == Terminal.TK_KEY_RELEASED) { _focus.OnKeyUp(input); } else { _focus.OnKeyDown(input); } } } }
public void AddInputListener(IInputListener listener, bool remove) { if(remove) { this.MouseDown -= listener.OnMouseDown; this.MouseUp -= listener.OnMouseUp; this.MouseMove -= listener.OnMouseMoved; this.KeyDown -= listener.OnKeyDown; this.KeyUp -= listener.OnKeyUp; } else { this.MouseDown += listener.OnMouseDown; this.MouseUp += listener.OnMouseUp; this.MouseMove += listener.OnMouseMoved; this.KeyUp += listener.OnKeyUp; this.KeyDown += listener.OnKeyDown; } }
void SetListenerInternal(IInputListener listener) { #if UNITY_EDITOR if (Settings._verbose) { Debug.Log("Input listener: " + listener.GetType().ToString()); } #endif if (_listener != null) { _listener.OnControllLost(); } _listener = listener; if (_listener != null) { _listener.OnControllGained(); } }
//this method is resposnable for searching through the Entities and removing them if necessary protected void RemovalCheck() { //search through the entity array, foreach (IEntity tempEnt in _mEntArray) { //store the check value int checkval = tempEnt.eID; //if the entity requires a complete removal, remove it from all mgrs if (tempEnt.CompleteRemove) { _mSceneMgr.Remove(checkval); _mCollisionMgr.RemoveCollider(checkval); _mAIMgr.Remove(tempEnt); _mViewMgr.RemoveTarget(checkval); if (tempEnt is IInputListener) { IInputListener tempinput = (IInputListener)tempEnt; _mInputMgr.RemoveInputListener(tempinput.InputID); } _mEntArray.Remove(tempEnt); break; } //remove form the scene includign other managers but not the main game if (tempEnt.SceneRemove) { _mSceneMgr.Remove(checkval); _mCollisionMgr.RemoveCollider(checkval); _mAIMgr.Remove(tempEnt); if (tempEnt is IInputListener) { IInputListener tempinput = (IInputListener)tempEnt; _mInputMgr.RemoveInputListener(tempinput.InputID); } } } }
public void Handle(WindowEvent message) { if (message.OpenEvent) { _focus = message.Root.Focus(new Coord(0, 0)); _windowListeners.Add(new PaneBounds(message.Root, message.Bounds), _focus); } else { _windowListeners.Remove(new PaneBounds(message.Root, message.Bounds)); IInputListener newFocus = _windowListeners.Values.Last(); if (_focus != newFocus) { _focus.LoseFocus(); } _focus = _windowListeners.Values.Last(); } }
private void StartGame() { Debug.LogFormat("start network match, is host {0}", Model.IsHost); _view.gameObject.SetActive(true); if (Model.IsHost) { var gameParams = new GameParams { BallSize = RandomUtils.GetRandomInRange(Model.BallSizeRange), BallColor = Model.RandomBallColorOnStart ? RandomUtils.GetRandomColor() : Model.BallColor, StartForce = Model.GetStartForce() }; _view.SetupBall(gameParams); _service.SendGameParams(gameParams); } var startPos = _view.Width / 2; _inputListener = Model.ControlType == ControlType.ControlPanels ? new ControlSideListener(_view.LeftSide, _view.RightSide, Model.PlatformSpeed) : (IInputListener) new PointerPositionListener(); _view.MovePlatforms(startPos); _active = true; }
public async Task <string> RunInterfaceAsync(List <HistoryItem> history) { var historyToDisplay = history.Select(x => x.CmdLine).Distinct().ToList(); var control = Build(historyToDisplay); ConsoleManager.Setup(); ConsoleManager.Content = control; ConsoleManager.Resize(new ConsoleGUI.Space.Size(Console.WindowWidth, Console.WindowHeight)); ConsoleManager.AdjustWindowSize(); var inputListener = new IInputListener[] { this, listView, searchBox }; quit = false; while (!quit) { ConsoleManager.AdjustBufferSize(); ConsoleManager.ReadInput(inputListener); if (updateSearch) { updateSearch = false; var searchResults = historyToDisplay.Where(x => x.ToLowerInvariant().Contains(searchBox.Text.ToLowerInvariant())).ToList(); listView.Items = searchResults; } await Task.Delay(50); } return(listView.SelectedItem); }
private void FullRemove() { while (_mEntArray.Count > 0) { foreach (IEntity tempEnt in _mEntArray) { //store the check value int checkval = tempEnt.eID; _mSceneMgr.Remove(checkval); _mCollisionMgr.RemoveCollider(checkval); _mAIMgr.Remove(tempEnt); _mViewMgr.RemoveTarget(checkval); if (tempEnt is IInputListener) { IInputListener tempinput = (IInputListener)tempEnt; _mInputMgr.RemoveInputListener(tempinput.InputID); } _mEntArray.Remove(tempEnt); break; } } }
public void AddListener(IInputListener listener, int priority = 0) { foreach(ListenerData l in m_listeners) { // don't add duplicate listeners if(l.Listener == listener) { return; } } ListenerData ld = new ListenerData(); ld.Listener = listener; ld.Priority = priority; m_listeners.Add(ld); m_listeners.Sort( delegate(ListenerData p1, ListenerData p2) { return p1.Priority.CompareTo(p2.Priority); } ); }
public KinectProvider(IInputListener listener) { if (listener == null) throw new ArgumentNullException("listener"); Listener = listener; Enabled = true; Available = true; try { nui = new Runtime(); #if(RETRHOW_RUNTIME_EXCEPTION) try { nui.Initialize(RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking); } catch (InvalidOperationException) { throw new InvalidOperationException("Runtime initialization failed. Please make sure Kinect device is plugged in."); } try { nui.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex); } catch (InvalidOperationException) { throw new InvalidOperationException("Failed to open stream. Please make sure to specify a supported image type and resolution."); } #else nui.Initialize(RuntimeOptions.UseDepthAndPlayerIndex);// | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor); nui.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex); #endif nui.DepthFrameReady += new EventHandler<ImageFrameReadyEventArgs>(nui_DepthFrameReady); nui.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(nui_SkeletonFrameReady); leftHandProvider = new KinectPositionProvider("left", this); rightHandProvider = new KinectPositionProvider("right", this); providers = new KinectPositionProvider[] { rightHandProvider, leftHandProvider }; } catch { Available = false; } if (Available) { try { ImageProcessingEngine = new ImageProcessingEngine(320, 240, 4); KinectBlobsMatcher = new KinectBlobsMatcher(ImageProcessingEngine, 320 >> 1, 240 >> 1); } catch { KinectBlobsMatcher = null; ImageProcessingEngine = null; Available = false; } } }
public void SetListeners(IInputListener[] listeners) { this.listeners = new List<IInputListener>(listeners); SetListeners(); }
public void RemoveListeners(IInputListener[] listeners) { foreach (IInputListener listener in listeners) { RemoveListener(listener); } }
public void RemoveListener(IInputListener listener) { listeners.Remove(listener); }
public void AddListeners(IInputListener[] listeners) { foreach (IInputListener listener in listeners) { AddListener(listener); } }
public void AddListener(IInputListener listener) { if (!listeners.Contains(listener)) { listeners.Add(listener); } }
public void SubscribeInputListener(IInputListener inputListener) { this.inputListeners.Add(inputListener); }
public void UnregisterListener(IInputListener listener) { inputListeners.Remove (listener); }
public bool Create(IInputListener listener, out IInputProvider provider) { provider = new MouseProvider(listener); return true; }
public void SetListener(IInputListener listener) { this.listener = listener; }
public InputClient(TransportClient transport) { this.transport = transport; this.listener = null; this.active = false; }
public void AddListener(IInputListener listener) { this.listeners.Add(listener); }
public void RemoveListener(IInputListener listener) { foreach(ListenerData ld in m_listeners) { if(ld.Listener == listener) { m_listeners.Remove(ld); break; } } }
private void OnTouchHeld(Vector2 pressedPosition, Vector2 releasedPosition) { if(m_swipeStarted) { if(m_attachedListener != null) { m_attachedListener.OnSwipeMoved(pressedPosition, releasedPosition, GetHits(releasedPosition)); } } else if(CheckSwipe(pressedPosition, releasedPosition)) { m_swipeStarted = true; foreach(ListenerData ld in m_listeners) { if(ld.Listener.OnSwipeStarted(pressedPosition, releasedPosition, GetHits(releasedPosition))) { m_attachedListener = ld.Listener; break; } } } }
public void RegisterListener(IInputListener listener) { inputListeners.Clear (); inputListeners.Add (listener); }
// For 'Any input', just give it an empty string. public void AddInputListener(string inputName, IInputListener listener) { if (!mInputListeners.ContainsKey(inputName)) { mInputListeners.Add(inputName, new List<IInputListener>()); } if(!mInputListeners[inputName].Contains(listener)) { mInputListeners[inputName].Add(listener); } }
public void RegisterListener(IInputListener listener) { listeners.Add(listener); }
private void OnTouchPressed(Vector2 pressedPosition) { m_swipeStarted = false; m_attachedListener = null; List<GameObject> hits = GetHits(pressedPosition); foreach(ListenerData ld in m_listeners) { if(ld.Listener.OnPress(pressedPosition, hits)) { break; } } }
public void AddInputListener(IInputListener listener) { _listener = listener; }
public void AddInputListener(IInputListener listener) { AddKeyboardListener(listener); AddTouchListener(listener); }