void UpdateCurrentInputFrame() { var digitalControlStates = this.platform.hid_GetDigitalControlStates (); var analogControlStates = this.platform.hid_GetAnalogControlStates (); var binaryControlStates = this.platform.hid_GetBinaryControlStates (); var pressedCharacters = this.platform.hid_GetPressedCharacters (); var activeTouches = this.platform.hid_GetActiveTouches (); RawTouch mouseTouch = null; if (mouseGeneratesTouches) { Boolean mouseDownLastFrame = inputFrame.BinaryControlStates.Contains (BinaryControlIdentifier.Mouse_Left); Boolean mouseDownThisFrame = binaryControlStates.Contains (BinaryControlIdentifier.Mouse_Left); if (digitalControlStates.ContainsKey (DigitalControlIdentifier.Mouse_X) && digitalControlStates.ContainsKey (DigitalControlIdentifier.Mouse_Y)) { Single mouseX = digitalControlStates [DigitalControlIdentifier.Mouse_X]; Single mouseY = digitalControlStates [DigitalControlIdentifier.Mouse_Y]; if (!mouseDownLastFrame && mouseDownThisFrame) { currentMouseTouchId = "mouse" + Guid.NewGuid ().ToString (); mouseTouch = new RawTouch { Id = currentMouseTouchId, Position = new Vector2 (mouseX, mouseY), Phase = TouchPhase.JustPressed }; } else if (mouseDownLastFrame && mouseDownThisFrame) { mouseTouch = new RawTouch { Id = currentMouseTouchId, Position = new Vector2 (mouseX, mouseY), Phase = TouchPhase.Active }; } else if (mouseDownLastFrame && !mouseDownThisFrame) { mouseTouch = new RawTouch { Id = currentMouseTouchId, Position = new Vector2 (mouseX, mouseY), Phase = TouchPhase.JustReleased }; } } } inputFrame.DigitalControlStates.Clear (); inputFrame.AnalogControlStates.Clear (); inputFrame.PressedCharacters.Clear (); inputFrame.ActiveTouches.Clear (); inputFrame.BinaryControlStates.Clear (); if (mouseTouch != null) inputFrame.ActiveTouches.Add (mouseTouch); digitalControlStates.Keys .ToList () .ForEach (k => inputFrame.DigitalControlStates.Add (k, digitalControlStates [k])); analogControlStates.Keys .ToList () .ForEach (k => inputFrame.AnalogControlStates.Add (k, analogControlStates [k])); binaryControlStates .ToList () .ForEach (k => inputFrame.BinaryControlStates.Add (k)); pressedCharacters .ToList () .ForEach (k => inputFrame.PressedCharacters.Add (k)); activeTouches .ToList () .ForEach (k => inputFrame.ActiveTouches.Add (k)); }
void UpdateRawTouches() { foreach (var iOSTouchHandle in iOSTouches.Keys) { var p = iOSTouches [iOSTouchHandle].Phase; var l = iOSTouches [iOSTouchHandle].Location; if (!intermediateTouchMap.ContainsKey (iOSTouchHandle)) { var r = new RawTouch (); r.Id = new Guid ().ToString (); r.Phase = EnumConverter.ToCorPrimitiveType(p); r.Position = GetTouchPos(l); intermediateTouchMap.Add (iOSTouchHandle, r); } else { var rt = intermediateTouchMap [iOSTouchHandle]; rt.Phase = EnumConverter.ToCorPrimitiveType(p); rt.Position = GetTouchPos(l); } } var toRemove = new List <Int32> (); foreach (var iOSTouchHandle in intermediateTouchMap.Keys) { if (!iOSTouches.ContainsKey (iOSTouchHandle)) toRemove.Add (iOSTouchHandle); } foreach (var key in toRemove) intermediateTouchMap.Remove (key); }