Beispiel #1
0
        public void HandleInput(KeyCombination keyPress, MouseData mouse)
        {
            var boundActions = GetActionsFromBoundKey(keyPress);

            if (_activitySystem.Count > 0)
            {
                IActivity inputActivity = _activitySystem.GetActivityAcceptingInput();

                if (inputActivity != null && ((inputActivity as GameplayActivity)?.Running ?? true))
                {
                    if (boundActions.Any())
                    {
                        foreach (var action in boundActions)
                        {
                            inputActivity.HandleAction(_systemContainer, action);
                        }
                    }
                    else
                    {
                        inputActivity.HandleAction(_systemContainer, null);
                    }

                    if (keyPress != null)
                    {
                        inputActivity.HandleKeyboard(_systemContainer, keyPress);
                    }

                    if (mouse != null)
                    {
                        inputActivity.HandleMouse(_systemContainer, mouse);
                    }
                }
            }
        }
Beispiel #2
0
    public string save(string file_name, List <MouseData> dataLists)
    {
        Debug.Log("Get JSON");

        int dataSize = dataLists.Count;

        MouseData[] MouseArray = new MouseData[dataSize];

        for (int i = 0; i < dataSize; i++)
        {
            MouseArray[i]             = new MouseData();
            MouseArray[i].mTime       = dataLists[i].mTime;
            MouseArray[i].logicalTime = dataLists[i].logicalTime;
            MouseArray[i].positionX   = dataLists[i].positionX;
            MouseArray[i].positionY   = dataLists[i].positionY;
            MouseArray[i].positionZ   = dataLists[i].positionZ;
        }

        string mouseJson = JsonHelper.ToJson(MouseArray, true);

        Debug.Log(MouseArray);
        Debug.Log(mouseJson);

        file_name = file_name + ".json";
        return(WriteFile(file_name, mouseJson));
    }
Beispiel #3
0
        private void _MouseMove(object sender, InputDevice.MouseControlEventArgs e)
        {
            if (Focused)
            {
                Cursor.Position = new Point(Location.X + Width / 2, Location.Y + Height / 2);
            }

            if (Mouses.ContainsKey(e.DeviceData.Info.deviceHandle))
            {
                // convert to absolute mouse cooridnates
                MouseData Current = Mouses[e.DeviceData.Info.deviceHandle];
                Current.PosX += e.DeltaX;
                Current.PosY += e.DeltaY;

                if (Current.PosX < 0)
                {
                    Current.PosX = 0;
                }
                if (Current.PosY < 0)
                {
                    Current.PosY = 0;
                }
                if (Current.PosX >= Canvas.Width)
                {
                    Current.PosX = Canvas.Width - 1;
                }
                if (Current.PosY >= Canvas.Height)
                {
                    Current.PosY = Canvas.Height - 1;
                }
            }
        }
Beispiel #4
0
        private void ProcessMouse(MouseData data)
        {
            ivec2 delta = data.Location - data.PreviousLocation;

            if (settings.InvertX)
            {
                delta.x *= -1;
            }

            if (!settings.InvertY)
            {
                delta.y *= -1;
            }

            var sensitivity = settings.MouseSensitivity / AimDivisor;

            pitch += delta.y * sensitivity;
            pitch  = Utilities.Clamp(pitch, -maxPitch, maxPitch);
            yaw   += delta.x * sensitivity;

            if (yaw >= Constants.TwoPi)
            {
                yaw -= Constants.TwoPi;
            }
            else if (yaw <= -Constants.TwoPi)
            {
                yaw += Constants.TwoPi;
            }
        }
Beispiel #5
0
 public override void HandleMouse(ISystemContainer systemContainer, MouseData mouse)
 {
     if (mouse.IsLeftClick)
     {
         Close();
     }
 }
        public override ActionEventData HandleMouse(MouseData mouse, IDataRogueControlRenderer renderer, ISystemContainer systemContainer)
        {
            if (mouse.IsLeftClick)
            {
                var mapEditor = systemContainer.ActivitySystem.MapEditorActivity;

                var command = renderer.StringFromMouseData(this, systemContainer, mouse);

                if (command == "Primary Cell")
                {
                    mapEditor.ShowChangePrimaryCellDialogue();
                }

                if (command == "Secondary Cell")
                {
                    mapEditor.ShowChangeSecondaryCellDialogue();
                }

                if (command == "Default Cell")
                {
                    mapEditor.ShowChangeDefaultCellDialogue();
                }
            }

            return(null);
        }
	//키 버퍼에 추가.(입력지연 이상의 정보는 무시하고 false를 반환).
	public bool EnqueueMouseData()
	{
		//PlayerInfo info = PlayerInfo.GetInstance();
		//int playerId = info.GetPlayerId();
		int playerId = 0;

		if (mouseInputBuffer[playerId].Count >= bufferNum)
		{
			// 입력지연 이상의 정보는 받지않습니다. 
			++noSyncCount;
			if (noSyncCount >= bufferNum)
			{
				//Debug.Log("Resend inputbuffer data.");
				noSyncCount = 0;
				return true;
			}

			return false;
		}

		// 키 입력을 가져와서 키 버퍼에 추가.
		sendFrame++;
		//MouseData mouseData = m_inputManager.GetMouseData(playerId);

		MouseData mouseData = m_inputManager.GetLocalMouseData();
		mouseData.frame = sendFrame;
		mouseInputBuffer[playerId].Add(mouseData);
		//Debug.Log("Set mouse data[" + sendFrame +"]");

		return true;
	}
Beispiel #8
0
 public void OnMouseEnter(MouseData mouseData)
 {
     if (Renderable != null)
     {
         Renderable.Color = Color01.green;
     }
 }
Beispiel #9
0
        public virtual void HandleMouse(ISystemContainer systemContainer, MouseData mouse)
        {
            if (systemContainer.ActivitySystem.HasActivity(this))
            {
                var mouseOverControl = GetMouseOverControl(systemContainer, mouse);

                if (mouseOverControl != null)
                {
                    if (mouseOverControl.CanHandleMouse)
                    {
                        var renderer = systemContainer.RendererSystem.Renderer.GetRendererFor(mouseOverControl);

                        var action = mouseOverControl.HandleMouse(mouse, renderer, systemContainer);
                        if (action != null)
                        {
                            systemContainer.EventSystem.Try(EventType.Action, systemContainer.PlayerSystem.Player, action);
                        }
                    }

                    if (mouse.IsLeftClick)
                    {
                        mouseOverControl.Click(mouseOverControl, new PositionEventHandlerArgs(mouse.X, mouse.Y));
                    }
                }
            }
        }
Beispiel #10
0
 public void OnMouseExit(MouseData mouseData)
 {
     if (Renderable != null)
     {
         Renderable.Color = Color01.white;
     }
 }
Beispiel #11
0
    //===================================================
    /*!
       	@brief		ピースの移動&入れ替え

        @param		MouseData	マウスのデータ
       	@date		2013/01/20
       	@author		Daichi Horio
      */
    //===================================================
    public bool MoveUpdate(MouseData mouseData)
    {
        GameObject obj = TouchUpdate(mouseData.pos);

        // 他のピースに触れたら選択しているピースと位置入れ替え
        if (obj != null)
        {
            PieceObject p = obj.GetComponent<PieceObject>();
            if (p.GetState() == 0)
            {
                ReplacePiece(mNowSelectPiece, p);
                mRouteQueue.Enqueue(p.PicecPosition);
            }
        }

        if (mouseData.up || mNowSelectPiece.transform.position.y > (PieceSize * Height))
        {
            mRouteQueue.Enqueue(mNowSelectPiece.PicecPosition);
            mNowSelectPiece.Relese();
            mNowSelectPiece = null;
            return true;
        }

        return false;
    }
Beispiel #12
0
        void RawDevice_RawInput(object sender, RawInputEventArgs e)
        {
            if (e.Handle != IntPtr.Zero)
            {
                MouseData  data       = (MouseData)e.GetRawData();
                CursorData cursorData = deviceList[e.Handle];

                MouseButtonState oldState = cursorData.ButtonState;
                MouseButtonState newState = data.ButtonState;

                double x = cursorData.X + data.X;
                double y = cursorData.Y + data.Y;

                if (newState == MouseButtonState.LeftDown)
                {
                    OnMouseDown(e.Handle, x, y, cursorData.X, cursorData.Y);
                }
                else if (newState == MouseButtonState.LeftUp)
                {
                    OnMouseUp(e.Handle, x, y, cursorData.X, cursorData.Y);
                }
                else if (oldState == MouseButtonState.LeftDown)
                {
                    OnMouseMove(e.Handle, x, y, cursorData.X, cursorData.Y);
                }

                if (newState != MouseButtonState.None)
                {
                    cursorData.ButtonState = newState;
                }
                dispatcher.Invoke(DispatcherPriority.Normal, (Action) delegate { cursorData.SetPosition(x, y); });
            }
        }
Beispiel #13
0
        public override void HandleMouse(ISystemContainer systemContainer, MouseData mouse)
        {
            if (mouse.MouseActive)
            {
                var controlsUnderMouse = MouseControlHelper.GetControlsUnderMouse(mouse, Controls);
                controlsUnderMouse = controlsUnderMouse.Where(c => c.GetType() != typeof(BackgroundControl));

                foreach (var control in controlsUnderMouse)
                {
                    if (control is MenuItem)
                    {
                        Menu.SelectedItem = control as MenuItem;
                    }

                    if (mouse.IsLeftClick)
                    {
                        if (control is MenuItem)
                        {
                            Menu.Select();
                        }

                        if (control is MenuActionsControl)
                        {
                            Menu.NextAction();
                        }
                    }
                }
            }
        }
        private IEntity GetHoveredCell(ISystemContainer systemContainer, MouseData mouse)
        {
            var mouseOverControl = GetMouseOverControl(systemContainer, mouse);

            var cellDisplay = mouseOverControl as MenuEntityControl;

            return(cellDisplay?.Entity);
        }
Beispiel #15
0
        // /////////////////////////////////////////////////////////////////////////////////
        #endregion
        #region Protected Methods
        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Called by the framework when a mouse button is pressed while over this button.
        /// Base method creates and starts the schedules for the emit cycle.
        /// </summary>
        /// <param name="mouseData"></param>
        protected override void OnMouseButtonDown(MouseData mouseData)
        {
            base.OnMouseButtonDown(mouseData);

            if (mouseData.MouseButton == MouseButton.LeftButton)
            {
                DoStartEmitting();
            }
        }
Beispiel #16
0
        private void AddData(MouseData newData)
        {
            if (newData.MouseRecordedTime != null)
            {
                dgvMouseData.Rows.Add(newData.MouseRecordedTime.ToString(), newData.MouseX.ToString(), newData.MouseY.ToString());
            }

            dgvMouseData.FirstDisplayedScrollingRowIndex = dgvMouseData.RowCount - 1;
        }
Beispiel #17
0
 private IntPtr MouseChanged(int nCode, IntPtr wParam, IntPtr lParam)
 {
     if (ScrollViewer.IsMouseOver && WM_MOUSEWHEEL == (int)wParam)
     {
         MouseData mouseData = (MouseData)Marshal.PtrToStructure(lParam, typeof(MouseData));
         ScrollViewer.ScrollToVerticalOffset(ScrollViewer.VerticalOffset - mouseData.Z / 200000.0);
     }
     return(CallNextHookEx(_handle, nCode, wParam, lParam));
 }
Beispiel #18
0
        public bool Raycast(MouseData mouse)
        {
            if (!HasRaycasting)
            {
                return(false);
            }

            return(Rect.Contains(mouse.position));
        }
Beispiel #19
0
 internal static void Initialize()
 {
     //Init devices
     Keyboard = new KeyboardData();
     Mouse = new MouseData();
     GamePads = new GamePadData[4];
     for (int i = 0; i < 4; i++)
         GamePads[i] = new GamePadData((PlayerIndex)i);
     VirtualInputs = new List<VirtualInput>();
 }
Beispiel #20
0
        // /////////////////////////////////////////////////////////////////////////////////

        // /////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Called by the framework when a mouse button is released while over this control.
        /// Base method removes the schedules for the emit cycle.
        /// </summary>
        /// <param name="mouseData"></param>
        protected override void OnMouseButtonUp(MouseData mouseData)
        {
            base.OnMouseButtonUp(mouseData);

            if (mouseData.MouseButton == MouseButton.LeftButton)
            {
                RemoveSchedule(EmitSchedule);
                RemoveSchedule(CountdownSchedule);
            }
        }
Beispiel #21
0
        public ManyMouseDispatcher(int number)
        {
            mouseDataSize = number;
            mouseData     = new MouseData[mouseDataSize];

            for (int i = 0; i < mouseDataSize; i++)
            {
                mouseData[i] = new MouseData();
            }
        }
        /// <summary>
        /// Public Constructor
        /// </summary>
        public Input(float heldThreshold)
        {
            m_Keys  = new Dictionary <Keys, KeyData>();
            m_Mouse = new MouseData();
            m_Mouse.mouseButtons = new bool[3];
            m_Mouse.downFor      = new float[3];
            HeldThreshold        = heldThreshold;

            XNAGame.Instance.UpdateEvent += Do;
        }
        public frmMouseHandle()
        {
            InitializeComponent();
            TopLevel = false;

            cbbHandle.DataSource    = MouseData.GetData().ToArray();
            cbbHandle.DisplayMember = "Name";
            cbbHandle.ValueMember   = "Value";
            chkIsPosition.Checked   = true;
        }
Beispiel #24
0
        /// Usually, to add a tooltip, we would set a Control's TooltTipText property to the desired text.  However,
        /// here we are adding a tooltip to the entire window, so this won't work.  Window's do not provide automatic
        /// tooltip support (probably because it is usually a bad idea).  Fortunately, adding tooltips
        /// to a window is fairly easy.  We just override OnMouseHoverBegin, and call ShowTooltip().  The framework
        /// handles closing the tooltip automatically when the mouse moves.
        protected override void OnMouseHoverBegin(MouseData mouseData)
        {
            base.OnMouseHoverBegin(mouseData);

            /// We only show the tooltip when the mouse pointer is at the same position as the player position.
            if (mouseData.Position == currentPos)
            {
                ShowTooltip("It's you!", mouseData.Position);
            }
        }
Beispiel #25
0
        static public void Initialize()
        {
            Keyboard = new KeyboardData();
            Mouse    = new MouseData();

            GamePads = new GamePadData[4];
            for (int i = 0; i < 4; i++)
            {
                GamePads[i] = new GamePadData((PlayerIndex)i);
            }
        }
Beispiel #26
0
        private Mouse CreateCursorMouse()
        {
            var initialPosition = Control.MousePosition;
            var mouseData       = new MouseData()
            {
                Position = initialPosition
            };
            var mouseInput    = Observable.FromEventPattern <MouseInputEventArgs>(typeof(Device), "MouseInput");
            var notifications = mouseInput.SelectMany <EventPattern <MouseInputEventArgs>, MouseNotification>(ep => GenerateCursorNotifications(mouseData, ep.EventArgs));

            return(new Mouse(notifications));
        }
Beispiel #27
0
 static internal void Initialize()
 {
     //Init devices
     Keyboard = new KeyboardData();
     Mouse    = new MouseData();
     GamePads = new GamePadData[4];
     for (int i = 0; i < 4; i++)
     {
         GamePads[i] = new GamePadData((PlayerIndex)i);
     }
     VirtualInputs = new List <VirtualInput>();
 }
Beispiel #28
0
        public void HandleMouse_NotActive_DoesNotChangeTarget()
        {
            var mouse = new MouseData()
            {
                MouseActive = false
            };

            _targetingActivity.HandleMouse(_systemContainer, mouse);

            _targetingActivity.CurrentTarget.Should().BeNull();
            _callbackHappened.Should().BeFalse();
        }
Beispiel #29
0
        protected override void OnMouseButtonUp(MouseData mouseData)
        {
            base.OnMouseButtonDown(mouseData);

            int index = MouseToIndex(mouseData);

            if (index >= 0 && index < List.Count())
            {
                var t = List.ElementAt(index);
                OnSelectItem(t);
            }
        }
Beispiel #30
0
        public void HandleMouseInput(MouseData mouse)
        {
            var x = mouse.X;
            var y = mouse.Y;

            if (_activitySystem.Peek() is GameplayActivity activity && _systemContainer.PlayerSystem.Player != null)
            {
                IUnifiedRenderer renderer = _systemContainer.RendererSystem.Renderer;
                var hoveredLocation       = renderer.GetGameplayMapCoordinateFromMousePosition(_systemContainer.RendererSystem.CameraPosition, x, y);

                SetHoveredLocation(hoveredLocation);
            }
        }
Beispiel #31
0
        public void MouseClicked(object Data, MultiDeviceInput.InputDevice.MouseControlEventArgs e)
        {
            MouseData CurrentMouse = Mouses.Find(n => n.Handle == e.DeviceData.Info.deviceHandle);

            if (CurrentMouse != null)
            {
                tbLastMouseName.Text = CurrentMouse.ToString();
            }
            else
            {
                tbLastMouseName.Text = "Unknown";
            }
        }
Beispiel #32
0
        /// <summary>
        /// Create a merged mouse device combining data from all the mice connected
        /// </summary>
        /// <param name="index">Index of the device</param>
        /// <returns></returns>
        protected override Mouse CreateMergedDevice(int index)
        {
            var initialPosition = Control.MousePosition;
            var mouseData       = new MouseData()
            {
                Position = initialPosition
            };
            var mouseInput    = Observable.FromEventPattern <MouseInputEventArgs>(typeof(Device), "MouseInput");
            var notifications = mouseInput
                                .SelectMany(ep => GenerateMouseNotifications(mouseData, ep.EventArgs));

            return(new Mouse(notifications));
        }
Beispiel #33
0
	public bool Serialize(MouseData packet)
	{
		// 각 요소를 차례로 시리얼라이즈합니다.
		bool ret = true;
		ret &= Serialize(packet.frame);	
		ret &= Serialize(packet.mouseButtonLeft);
		ret &= Serialize(packet.mouseButtonRight);
		ret &= Serialize(packet.mousePositionX);
		ret &= Serialize(packet.mousePositionY);
		ret &= Serialize(packet.mousePositionZ);
		
		return ret;
	}
        /// <summary>
        /// Add the new object to the queue for processing
        /// </summary>
        /// <param name="mouseData">object with new data</param>
        /// <returns>number of outstanding requests</returns>
        public int AddToQueue(MouseData mouseData)
        {
            //Make sure spot is available in the queue
            this.requestMouseData.WaitOne();

            lock (_threadLock)
            {
                dataQueue.Enqueue(mouseData);
            }

            //Increament the semaphore to indicate there is job to do
            int previousCount = handleRequests.Release();

            return previousCount;
        }
Beispiel #35
0
	public bool Deserialize(byte[] data, ref MouseData serialized)
	{
		// 데이터의 요소별로 디시리얼라이즈합니다.
		// 디시리얼라이즈할 데이터를 설정합니다.
		bool ret = SetDeserializedData(data);
		if (ret == false) {
			return false;
		}
		
		// 데이터의 요소별로 디시리얼라이즈합니다.
		ret &= Deserialize(ref serialized.frame);
		ret &= Deserialize(ref serialized.mouseButtonLeft);
		ret &= Deserialize(ref serialized.mouseButtonRight);
		ret &= Deserialize(ref serialized.mousePositionX);
		ret &= Deserialize(ref serialized.mousePositionY);
		ret &= Deserialize(ref serialized.mousePositionZ);
		
		return ret;
	}
Beispiel #36
0
        public GameWindow()
        {
            InitializeComponent();
            Instance = this;
            Cursor.Hide();

            // Multi mouse input init
            InputDevice = new MultiDeviceInput.InputDevice(Handle);
            InputDevice.EnumerateDevices();
            InputDevice.MouseDown += new MultiDeviceInput.InputDevice.MouseEventHandler(_MouseDown);
            InputDevice.MouseMove += new MultiDeviceInput.InputDevice.MouseEventHandler(_MouseMove);
            InputDevice.MouseUp += new MultiDeviceInput.InputDevice.MouseEventHandler(_MouseUp);
            InputDevice.MouseWheel += new MultiDeviceInput.InputDevice.MouseEventHandler(_MouseWheel);

            foreach (var KvP in InputDevice.DeviceList)
            {
                MouseData NewMouse = new MouseData();
                NewMouse.PosX = Canvas.Width / 2;
                NewMouse.PosY = Canvas.Height / 2;
                NewMouse.Data = KvP.Value;
                Mouses.Add(KvP.Value.Info.deviceHandle, NewMouse);
            }
        }
        /// <summary>
        /// Processes the new data received from the queue and decodes the command to be sent
        /// </summary>
        /// <param name="inputData">new data object</param>
        /// <returns>result of the processing</returns>
        private int ProcessMouseInput(MouseData inputData)
        {
            int mouseResult = (int)ResultCodes.Success;

            do
            {
                if (inputData == null)
                {
                    mouseResult = (int)ResultCodes.OutOfMemory;
                    mouseLogger.Fatal("Error: The element removed from the Queue is NULL");
                    break;
                }

                if (inputData.MouseAction == (int)MouseButton.MOUSE_MOVE)
                {
                    mouseResult = SendMouseCommand(inputData.MouseAction, gameInfo.GetGameHandle(), inputData.XCoordinate , inputData.YCoordinate, inputData.KeyPersistance );
                    break;
                }

                if (inputData.MouseAction == (int)MouseButton.LEFT_MOUSE_BUTTON && !pressedClicks.Exists(value => value.Equals(inputData.MouseAction)))
                {
                    mouseResult = SendMouseCommand(inputData.MouseAction, gameInfo.GetGameHandle(), -1, -1, inputData.KeyPersistance);
                    break;
                }

                if (inputData.MouseAction == (int)MouseButton.RIGHT_MOUSE_BUTTON && !pressedClicks.Exists(value => value.Equals(inputData.MouseAction)))
                {
                    mouseResult = SendMouseCommand(inputData.MouseAction, gameInfo.GetGameHandle(), -1, -1, inputData.KeyPersistance);
                    break;
                }

                if (inputData.MouseAction == (int)MouseButton.LEFT_MOUSE_BUTTON && inputData.KeyPersistance == (int)MousePresistance.RELEASE)
                {
                    mouseResult = SendMouseCommand(inputData.MouseAction, gameInfo.GetGameHandle(), -1, -1, inputData.KeyPersistance);
                    break;
                }

                if (inputData.MouseAction == (int)MouseButton.RIGHT_MOUSE_BUTTON && inputData.KeyPersistance == (int)MousePresistance.RELEASE)
                {
                    mouseResult = SendMouseCommand(inputData.MouseAction, gameInfo.GetGameHandle(), -1, -1, inputData.KeyPersistance);
                    break;
                }

            } while (false);

            return mouseResult;
        }
Beispiel #38
0
 //동기화된 입력값 설정용.
 public void SetInputData(int id, MouseData data) {
     m_syncedInputs[id] = data;
 }
Beispiel #39
0
        void InputEvents_MouseMoved(MouseData md)
        {
            if (Visible && Enabled)
            {
                //check mouse
                bool mouseOver = (md.X >= PositionAndSize.Left) && (md.X <= PositionAndSize.Right) && (md.Y >= PositionAndSize.Top) && (md.Y <= PositionAndSize.Bottom);

                Hilited = (mouseOver || (CursorPos != -1));
                lastMouseOver = mouseOver;
            }
        }
Beispiel #40
0
        void InputEvents_MouseLeftChanged(MouseData md)
        {
            if (Visible && Enabled)
            {
                //check mouse
                bool mouseOver = (md.X >= PositionAndSize.Left) && (md.X <= PositionAndSize.Right) && (md.Y >= PositionAndSize.Top) && (md.Y <= PositionAndSize.Bottom);
                bool mlbtnClicked = (md.Left != md.old_Left) && !md.Left;

                if (mouseOver && mlbtnClicked && (CursorPos == -1))
                    CursorPos = Text.Length;
                if (!mouseOver && mlbtnClicked && (CursorPos != -1))
                {
                    CursorPos = -1;
                    FirstVisibleChar = 0;
                }
                Hilited = (mouseOver || (CursorPos != -1));
                lastMouseOver = mouseOver;
            }
        }
Beispiel #41
0
    /*! パズル部分の更新
        @param	nowState		現在の遷移
        @param	mouseData		マウスの入力データ
        @param	PuzzleState		遷移を返す
    */
    public PuzzleState SelfUpdate(PuzzleState nowState, MouseData mouseData)
    {
        switch (nowState)
        {
            case PuzzleState.NONE:
                break;

            // ピース選択
            case PuzzleState.SELECT:
                if (mTouchCon.SelectUpdate(mouseData))
                    nowState++;
                break;

            // ピース移動
            case PuzzleState.MOVE:
                if (mTouchCon.MoveUpdate(mouseData))
                    nowState = PuzzleState.JUDGE;
                break;

            // 消すかどうか判定
            case PuzzleState.JUDGE:
                // 何もそろってなければセレクトへ
                if(mJudgeCon.AllJudge() != null)
                    nowState = PuzzleState.DEATH;
                else
                    nowState = PuzzleState.SELECT;

                break;

            // 揃っているピースを消す
            case PuzzleState.DEATH:
                if (DeathUpdate())
                {
                    DownProcess();
                    nowState = PuzzleState.DOWN;
                }
                break;

            // 隙間を埋めるためにピースを落とす
            case PuzzleState.DOWN:
                if(mActivList.Count == 0 && mDeathList.Count == 0)
                    nowState = PuzzleState.JUDGE;

                break;
        }

        // 各ピースの更新
        PieceUpdate();

        return nowState;
    }
Beispiel #42
0
        private void RefreshMices_Click(object sender, EventArgs e)
        {
            lbMice.Items.Clear();
            Mouses.Clear();

            int ID = 1;
            int DeviceCount = InputDevice.EnumerateDevices();
            foreach (var KvP in InputDevice.DeviceList)
            {
                if (KvP.Value.Info.deviceType != "MOUSE") continue;

                MouseData NewMouse = new MouseData();
                NewMouse.ID = ID++;
                NewMouse.Handle = KvP.Value.Info.deviceHandle;
                NewMouse.Name = KvP.Value.Info.Name.Substring(KvP.Value.Info.Name.IndexOf(';') + 1);
                Mouses.Add(NewMouse);
                lbMice.Items.Add(NewMouse);
            }
        }
Beispiel #43
0
        void InputEvents_MouseMoved(MouseData md)
        {
            if (Visible && Enabled)
            {
                //check mouse
                bool mouseOver = (md.X >= PositionAndSize.Left) && (md.X <= PositionAndSize.Right) && (md.Y >= PositionAndSize.Top) && (md.Y <= PositionAndSize.Bottom);

                State = (mouseOver ? (md.Left ? UIButtonState.NormalPressed : UIButtonState.Hilite) : UIButtonState.Normal);
            }
        }
Beispiel #44
0
        void InputEvents_MouseLeftChangedOrRepeat(MouseData md)
        {
            if (Visible && Enabled)
            {
                btnMinus.InputEvents_MouseMovedLeftChangedOrLeftRepeated(md);
                if (btnMinus.Handled)
                    return;

                btnPlus.InputEvents_MouseMovedLeftChangedOrLeftRepeated(md);
                if (btnPlus.Handled)
                    return;

                thumb.InputEvents_MouseMovedLeftChangedOrRepeat(md);
                if (thumb.Handled)
                    return;

                //background handling
                bool mouseOver = ((md.X >= PositionAndSize.Left) && (md.X <= PositionAndSize.Right) && (md.Y >= PositionAndSize.Top) && (md.Y <= PositionAndSize.Bottom));

                if (mouseOver && md.Left)
                {
                    int scrollSpaceSize = (IsVertical ? PositionAndSize.Height - btnMinus.PositionAndSize.Height - btnPlus.PositionAndSize.Height
                                                      : PositionAndSize.Width - btnMinus.PositionAndSize.Width - btnPlus.PositionAndSize.Width);
                    int thumbLength = (int)(scrollSpaceSize * ((ValuesOnScreen + 0.5) / (double)(MaximalValue - MinimalValue + 1)));
                    if (thumbLength < (IsVertical ? Edges[0].Height + Edges[3].Height + 1 : Edges[1].Width + Edges[2].Width + 1))
                        thumbLength = (IsVertical ? Edges[0].Height + Edges[3].Height + 1 : Edges[1].Width + Edges[2].Width + 1);
                    int scrollPositionsSize = scrollSpaceSize - thumbLength;
                    double scrollPositionSize = scrollPositionsSize / (double)(MaximalValue - MinimalValue);
                    thumb.PositionAndSize = (IsVertical ? new Rectangle(PositionAndSize.X, btnMinus.PositionAndSize.Bottom + (int)((Value - MinimalValue) * scrollPositionSize), PositionAndSize.Width, thumbLength)
                                                        : new Rectangle(btnMinus.PositionAndSize.Right + (int)((Value - MinimalValue) * scrollPositionSize), PositionAndSize.Y, thumbLength, PositionAndSize.Height));
                    bool minusSide = (IsVertical ? (md.Y < thumb.PositionAndSize.Top) : (md.X < thumb.PositionAndSize.Left));
                    Value += (int)(minusSide ? Math.Floor(-(MaximalValue - MinimalValue + 1) / 10.0) : Math.Ceiling((MaximalValue - MinimalValue + 1) / 10.0));
                }

                Hilited = mouseOver;
            }
        }
Beispiel #45
0
        private void _MouseUp(object sender, InputDevice.MouseControlEventArgs e)
        {
            if (!Mouses.ContainsKey(e.DeviceData.Info.deviceHandle))
            {
                MouseData NewMouse = new MouseData();
                NewMouse.PosX = Canvas.Width / 2;
                NewMouse.PosY = Canvas.Height / 2;
                NewMouse.Data = e.DeviceData;
                Mouses.Add(e.DeviceData.Info.deviceHandle, NewMouse);
            }

            if (Mouses.ContainsKey(e.DeviceData.Info.deviceHandle) && e.LeftButton)
            {
                MouseEventButtonUpLeft(this, Mouses[e.DeviceData.Info.deviceHandle]);
            }
            else if (e.RightButton)
            {
                MouseEventButtonUpRight(this, Mouses[e.DeviceData.Info.deviceHandle]);
            }
        }
Beispiel #46
0
            public void InputEvents_MouseMovedLeftChangedOrRepeat(MouseData md)
            {
                Handled = false;

                if (Visible && Enabled)
                {
                    //check mouse
                    bool mouseOver = (md.X >= PositionAndSize.Left) && (md.X <= PositionAndSize.Right) && (md.Y >= PositionAndSize.Top) && (md.Y <= PositionAndSize.Bottom);

                    UIButtonState old_State = State;
                    State = (mouseOver ? (md.Left ? UIButtonState.NormalPressed
                                                  : UIButtonState.Hilite)
                                       : UIButtonState.Normal);
                    Handled = mouseOver;
                    if ((State == UIButtonState.NormalPressed) && (old_State == State) && (Parent.IsVertical ? (md.Y != md.old_Y) : (md.X != md.old_X)))
                    {
                        int scrollSpaceSize = (Parent.IsVertical ? Parent.PositionAndSize.Height - Parent.btnMinus.PositionAndSize.Height - Parent.btnPlus.PositionAndSize.Height
                                                             : Parent.PositionAndSize.Width - Parent.btnMinus.PositionAndSize.Width - Parent.btnPlus.PositionAndSize.Width);
                        int thumbLength = (int)(scrollSpaceSize * ((Parent.ValuesOnScreen + 0.5) / (double)(Parent.MaximalValue - Parent.MinimalValue + 1)));
                        if (thumbLength < (Parent.IsVertical ? Edges[0].Height + Edges[3].Height + 1 : Edges[1].Width + Edges[2].Width + 1))
                            thumbLength = (Parent.IsVertical ? Edges[0].Height + Edges[3].Height + 1 : Edges[1].Width + Edges[2].Width + 1);
                        int scrollPositionsSize = scrollSpaceSize - thumbLength;
                        double scrollPositionSize = scrollPositionsSize / (double)(Parent.MaximalValue - Parent.MinimalValue);
                        Vector2 DragDistance = new Vector2(md.X - Parent.btnMinus.PositionAndSize.Right - thumbLength / 4, md.Y - Parent.btnMinus.PositionAndSize.Bottom - thumbLength / 4);
                        Parent.Value = (int)(Parent.IsVertical ? Math.Truncate(DragDistance.Y / scrollPositionSize)
                                                               : Math.Truncate(DragDistance.X / scrollPositionSize));
                    }
                }
            }
Beispiel #47
0
        void InputEvents_MouseMoved(MouseData md)
        {
            if (Visible && Enabled)
            {
                Hilited = false;

                btnMinus.InputEvents_MouseMovedLeftChangedOrLeftRepeated(md);
                btnPlus.InputEvents_MouseMovedLeftChangedOrLeftRepeated(md);
                thumb.InputEvents_MouseMovedLeftChangedOrRepeat(md);

                if (btnMinus.Handled || btnPlus.Handled || thumb.Handled)
                    return;

                bool mouseOver = ((md.X >= PositionAndSize.Left) && (md.X <= PositionAndSize.Right) && (md.Y >= PositionAndSize.Top) && (md.Y <= PositionAndSize.Bottom));

                Hilited = mouseOver;
            }
        }
Beispiel #48
0
            public void InputEvents_MouseMovedLeftChangedOrLeftRepeated(MouseData md)
            {
                Handled = false;

                if (Visible && Enabled)
                {
                    //check mouse
                    bool mouseOver = (md.X >= PositionAndSize.Left) && (md.X <= PositionAndSize.Right) && (md.Y >= PositionAndSize.Top) && (md.Y <= PositionAndSize.Bottom);

                    State = (mouseOver ? (md.Left ? UIButtonState.NormalPressed
                                                  : UIButtonState.Hilite)
                                       : UIButtonState.Normal);
                    Handled = mouseOver;
                    if (State == UIButtonState.NormalPressed)
                        Parent.Value = Parent.Value + (IsPlusButton ? 1 : -1);
                }
            }
Beispiel #49
0
    //===================================================
    /*!
       	@brief		移動させるピースの選択

        @param		MouseData	マウスの座標データ
       	@date		2013/01/20
       	@author		Daichi Horio
      */
    //===================================================
    public bool SelectUpdate(MouseData mouseData)
    {
        GameObject obj = null;

        if (mouseData.down)
        {
            obj = TouchUpdate(mouseData.pos);
        }

        if (obj == null)
            return false;

        mNowSelectPiece = obj.GetComponent<PieceObject>();
        mNowSelectPiece.Catch();

        mRoot.ActivList = mNowSelectPiece;

        return true;
    }
Beispiel #50
0
	public bool Deserialize(byte[] data, ref InputData serialized)
	{
		// 디시리얼라이즈할 데이터를 설정합니다.
		bool ret = SetDeserializedData(data);
		if (ret == false) {
			return false;
		}
		
		// 데이터 요소별로 디시리얼라이즈합니다.
		ret &= Deserialize(ref serialized.count);
		ret &= Deserialize(ref serialized.flag);

		// 디시리얼라이즈 후의 버퍼 크기를 구합니다.
		MouseSerializer mouse = new MouseSerializer();
		MouseData md = new MouseData();
		mouse.Serialize(md);
		byte[] buf= mouse.GetSerializedData();
		int size = buf.Length;
		
		serialized.datum = new MouseData[serialized.count];
		for (int i = 0; i < serialized.count; ++i) {
			serialized.datum[i] = new MouseData();
		}
		
		for (int i = 0; i < serialized.count; ++i) {
			byte[] buffer = new byte[size];
			
			// mouseData의11프레임분의 데이터를 추출합니다.
			bool ans = Deserialize(ref buffer, size);
			if (ans == false) {
				return false;
			}

			ret &= mouse.Deserialize(buffer, ref md);
			if (ret == false) {
				return false;
			}
			
			serialized.datum[i] = md;
		}
		
		return ret;
	}
Beispiel #51
0
        void InputEvents_MouseMoved(MouseData md)
        {
            if (Visible && Enabled)
            {
                //check mouse
                bool mouseOver = (md.X >= PositionAndSize.Left) && (md.X <= PositionAndSize.Right) && (md.Y >= PositionAndSize.Top) && (md.Y <= PositionAndSize.Bottom);

                State = (mouseOver ? (((State == UIKeyPickerState.Selecting) || (State == UIKeyPickerState.SelectingHilite)) ? UIKeyPickerState.SelectingHilite : UIKeyPickerState.Hilite)
                                   : (((State == UIKeyPickerState.Selecting) || (State == UIKeyPickerState.SelectingHilite)) ? UIKeyPickerState.Selecting : UIKeyPickerState.Normal));
            }
        }
Beispiel #52
0
        void InputEvents_MouseLeftChanged(MouseData md)
        {
            if (Visible && Enabled)
            {
                //check mouse
                bool mouseOver = (md.X >= PositionAndSize.Left) && (md.X <= PositionAndSize.Right) && (md.Y >= PositionAndSize.Top) && (md.Y <= PositionAndSize.Bottom);
                bool mlbtnClicked = (md.Left != md.old_Left) && !md.Left;

                UIKeyPickerState oldState = State;
                switch(State)
                {
                    case UIKeyPickerState.Normal:
                        State = (mouseOver ? UIKeyPickerState.Hilite : UIKeyPickerState.Normal);
                        break;
                    case UIKeyPickerState.Hilite:
                        State = (mouseOver ? (mlbtnClicked ? UIKeyPickerState.SelectingHilite : UIKeyPickerState.Hilite) : UIKeyPickerState.Normal);
                        break;
                    case UIKeyPickerState.Selecting:
                        State = (mouseOver ? UIKeyPickerState.SelectingHilite : (mlbtnClicked ? UIKeyPickerState.Normal : UIKeyPickerState.Selecting));
                        break;
                    case UIKeyPickerState.SelectingHilite:
                        State = (mouseOver ? (mlbtnClicked ? UIKeyPickerState.Hilite : UIKeyPickerState.SelectingHilite) : UIKeyPickerState.Selecting);
                        break;
                }
                if (((oldState == UIKeyPickerState.Selecting) || (oldState == UIKeyPickerState.SelectingHilite)) &&
                   ((State == UIKeyPickerState.Normal) || (State == UIKeyPickerState.Hilite)))
                {
                    //key picking cancelled - refresh current key
                    SelectedKey = SelectedKey;
                }
                if (((State == UIKeyPickerState.Selecting) || (State == UIKeyPickerState.SelectingHilite)) &&
                   ((oldState == UIKeyPickerState.Normal) || (oldState == UIKeyPickerState.Hilite)))
                {
                    //key picking started - set request text
                    base.Text = "Press a key";
                }
            }
        }
Beispiel #53
0
        static void UpdateMouse(MouseData mouse, IOHIDValueRef val)
        {
            IOHIDElementRef elem = NativeMethods.IOHIDValueGetElement(val);
            int v_int = NativeMethods.IOHIDValueGetIntegerValue(val).ToInt32();
            //double v_physical = NativeMethods.IOHIDValueGetScaledValue(val, IOHIDValueScaleType.Physical);
            //double v_calbrated = NativeMethods.IOHIDValueGetScaledValue(val, IOHIDValueScaleType.Calibrated);
            HIDPage page = NativeMethods.IOHIDElementGetUsagePage(elem);
            int usage = NativeMethods.IOHIDElementGetUsage(elem);

            switch (page)
            {
                case HIDPage.GenericDesktop:
                    switch ((HIDUsageGD)usage)
                    {
                        case HIDUsageGD.X:
                            mouse.State.X += v_int;
                            break;

                        case HIDUsageGD.Y:
                            mouse.State.Y += v_int;
                            break;

                        case HIDUsageGD.Wheel:
                            mouse.State.SetScrollRelative(0, v_int);
                            break;
                    }
                    break;

                case HIDPage.Button:
                    mouse.State[OpenTK.Input.MouseButton.Left + usage - 1] = v_int == 1;
                    break;

                case HIDPage.Consumer:
                    switch ((HIDUsageCD)usage)
                    {
                        case HIDUsageCD.ACPan:
                            mouse.State.SetScrollRelative(v_int, 0);
                            break;
                    }
                    break;
            }
        }
Beispiel #54
0
        void InputEvents_MouseLeftChanged(MouseData md)
        {
            if (Visible && Enabled)
            {
                //check mouse
                bool mouseOver = (md.X >= PositionAndSize.Left) && (md.X <= PositionAndSize.Right) && (md.Y >= PositionAndSize.Top) && (md.Y <= PositionAndSize.Bottom);
                bool mlbtnClicked = (md.Left != md.old_Left) && !md.Left;

                State = (mouseOver ? (md.Left ? UIButtonState.NormalPressed : UIButtonState.Hilite) : UIButtonState.Normal);
                if (mouseOver && mlbtnClicked && (Action != null))
                    Action(this);
            }
        }