private void MouseUp(Window32Msg.MouseOrigin origin, MouseButton arg1, MousePoint arg2) { MouseInputData data = new MouseInputData(); data.Get((int)arg1).Up = true; OriginType type = OriginType.U3D_2D_MOUSE; switch (origin) { case Window32Msg.MouseOrigin.PRO_MOUSE: type = PROIs3DShow ? OriginType.PRO_3D_MOUSE : OriginType.PRO_2D_MOUSE; break; case Window32Msg.MouseOrigin.PRO_TOUCH: type = PROIs3DShow ? OriginType.PRO_3D_TOUCH : OriginType.PRO_2D_TOUCH; break; case Window32Msg.MouseOrigin.U3D_MOUSE: type = U3dIs3DShow ? OriginType.U3D_3D_MOUSE : OriginType.U3D_2D_MOUSE; break; case Window32Msg.MouseOrigin.U3D_TOUCH: type = U3dIs3DShow ? OriginType.U3D_3D_TOUCH : OriginType.U3D_2D_TOUCH; break; } if (m_LogLevel <= Common.LogLevel.DEBUG) { Common.AppLog.AddFormat(Common.LogLevel.DEBUG, "GCInput.MouseUp", $"Button={arg1.ToString()} OriginType={type.ToString()} point={arg2.X} {arg2.Y}"); } m_msgList.Add(new MsgData(type, data, new API.SPoint(arg2.X, arg2.Y))); }
public List <IInputData> GetInputs() { var data = new List <IInputData>(); for (int i = 0; i < Input.touchCount; i++) { Touch touch = Input.GetTouch(i); InputDataState inputState; if (touch.phase == TouchPhase.Began) { inputState = InputDataState.PRESSED; } else if (touch.phase == TouchPhase.Ended) { inputState = InputDataState.RELEASED; } else { inputState = InputDataState.HOLD; } data.Add(MouseInputData.Get(i, inputState, touch.position)); } return(data); }
private void PROTouch(int dwFlags, int screenx, int screeny) { if (m_LogLevel <= Common.LogLevel.DEBUG) { Common.AppLog.AddFormat(Common.LogLevel.DEBUG, "GCInput.PROTouch", ""); } MouseInputData data = new MouseInputData(); data.Get(0).Down = IsTouchPressed(dwFlags); data.Get(0).Up = IsTouchReleased(dwFlags); if (PROIs3DShow) { API.SPoint out1, out2; TouchTransform.TouchPosition(m_projectorMonitorRect, new API.SPoint(screenx, screeny), out out1, out out2); m_msgList.Add(new MsgData(OriginType.PRO_3D_TOUCH, data, new API.SPoint(out1.x, out1.y))); } else { m_msgList.Add(new MsgData(OriginType.PRO_2D_TOUCH, data, new API.SPoint(screenx, screeny))); } }
public List <IInputData> GetInputs() { var data = new List <IInputData>(); if (Input.GetKey(KeyCode.RightArrow)) { data.Add(new ButtonInputData(InputButton.RIGHT, InputDataState.HOLD)); } else if (Input.GetKey(KeyCode.LeftArrow)) { data.Add(new ButtonInputData(InputButton.LEFT, InputDataState.HOLD)); } if (Input.GetKeyDown(KeyCode.DownArrow)) { data.Add(new ButtonInputData(InputButton.ROLL, InputDataState.PRESSED)); } if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.Space)) { data.Add(new ButtonInputData(InputButton.JUMP, InputDataState.PRESSED)); } else if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.Space)) { data.Add(new ButtonInputData(InputButton.JUMP, InputDataState.HOLD)); } else if (Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.Space)) { data.Add(new ButtonInputData(InputButton.JUMP, InputDataState.RELEASED)); } if (Input.GetMouseButtonDown(0)) { data.Add(MouseInputData.Get(0, InputDataState.PRESSED, Input.mousePosition)); } else if (Input.GetMouseButton(0)) { data.Add(MouseInputData.Get(0, InputDataState.HOLD, Input.mousePosition)); } else if (Input.GetMouseButtonUp(0)) { data.Add(MouseInputData.Get(0, InputDataState.RELEASED, Input.mousePosition)); } return(data); }
/// <summary> /// 处理消息 输出到帧数据 /// 调用顺序 : 窗口消息=>UI脚本调用输入值=>本脚本Update /// 为了同步状态数据和坐标数据帧 /// </summary> private void UpdateMsg() { m_curFrameInputData.Reset(); //目前没有去接收处理鼠标移动消息 if (m_msgList.Count == 0) { //没有消息: //3D主屏鼠标没有消息 => 没有按压状态改变 => 可能坐标改变 => 继续使用m_curFrameMouseScreenPosition //3D主屏触屏没有消息 => 没有任何变动 //投屏鼠标没有消息 => 没有按压状态改变 => 可能坐标改变 => 继续使用m_curFrameMouseScreenPosition //投屏触屏没有消息 => 没有任何变动 //2D主屏鼠标/触屏 => 更新原生Input状态 => 因为后面使用的也是原生Input.mousePosition if (m_curFrameOriginType == OriginType.U3D_2D_MOUSE || m_curFrameOriginType == OriginType.U3D_2D_TOUCH) { m_curFrameInputData.Get(0).Down = Input.GetMouseButtonDown(0); m_curFrameInputData.Get(1).Down = Input.GetMouseButtonDown(1); m_curFrameInputData.Get(2).Down = Input.GetMouseButtonDown(2); m_curFrameInputData.Get(0).Up = Input.GetMouseButtonUp(0); m_curFrameInputData.Get(1).Up = Input.GetMouseButtonUp(1); m_curFrameInputData.Get(2).Up = Input.GetMouseButtonUp(2); } return; } //可能最后使用的触屏位置 API.SPoint finalPoint = m_msgList[m_msgList.Count - 1].m_point; //过滤 OriginType finalType = m_msgList[m_msgList.Count - 1].m_type; for (int i = m_msgList.Count - 1; i >= 0; i--) { MsgData msg = m_msgList[i]; if (msg.m_type != finalType) { m_msgList.RemoveAt(i); } } MouseInputData finalInput = null; //合并按压数据 foreach (MsgData msg in m_msgList) { if (finalInput == null) { finalInput = msg.m_data; } else { finalInput.Combine(msg.m_data); } } m_msgList.Clear(); //这样干 至少编辑器里能兼容情况下原生输入 if (finalType == OriginType.U3D_2D_MOUSE || finalType == OriginType.U3D_2D_TOUCH) { finalInput.Get(0).Down = Input.GetMouseButtonDown(0); finalInput.Get(1).Down = Input.GetMouseButtonDown(1); finalInput.Get(2).Down = Input.GetMouseButtonDown(2); finalInput.Get(0).Up = Input.GetMouseButtonUp(0); finalInput.Get(1).Up = Input.GetMouseButtonUp(1); finalInput.Get(2).Up = Input.GetMouseButtonUp(2); } //数据源切换补充逻辑 if (m_curFrameOriginType != finalType) { bool pressed0 = m_recordDownInputData.IsPressedAndNoReleased(0); bool pressed1 = m_recordDownInputData.IsPressedAndNoReleased(1); bool pressed2 = m_recordDownInputData.IsPressedAndNoReleased(2); //补充一次释放 if (pressed0) { finalInput.Get(0).Up = true; } if (pressed1) { finalInput.Get(1).Up = true; } if (pressed2) { finalInput.Get(2).Up = true; } } //当前帧输出状态只要有释放状态 重新记录 if (finalInput.Get(0).Down) { m_recordDownInputData.Get(0).Down = true; } if (finalInput.Get(1).Down) { m_recordDownInputData.Get(1).Down = true; } if (finalInput.Get(2).Down) { m_recordDownInputData.Get(2).Down = true; } if (finalInput.Get(0).Up) { m_recordDownInputData.Get(0).Reset(); } if (finalInput.Get(1).Up) { m_recordDownInputData.Get(1).Reset(); } if (finalInput.Get(2).Up) { m_recordDownInputData.Get(2).Reset(); } //同步更新数据 m_curFrameInputData.CopyFrom(finalInput); m_curFrameOriginType = finalType; m_curFrameTouchPosition = finalPoint; if (m_LogLevel <= Common.LogLevel.DEBUG) { Common.AppLog.AddFormat(Common.LogLevel.DEBUG, "GCInput.UpdateMsg", $"curFrameOriginType={m_curFrameOriginType}"); Common.AppLog.AddFormat(Common.LogLevel.DEBUG, "GCInput.UpdateMsg", $"LeftDown={m_curFrameInputData.GetMouseButtonDown(0)} LeftUp={m_curFrameInputData.GetMouseButtonUp(0)}"); } }
public void Combine(MouseInputData data) { leftData.Combine(data.Get(leftData.Button)); rightData.Combine(data.Get(rightData.Button)); middleData.Combine(data.Get(middleData.Button)); }
public void CopyFrom(MouseInputData data) { leftData.CoypFrom(data.Get(leftData.Button)); rightData.CoypFrom(data.Get(rightData.Button)); middleData.CoypFrom(data.Get(middleData.Button)); }