/// <summary> /// Collects the key events. Except in MacOS, this includes mouse events, which are part of Unity's KeyCode enum. /// /// In MacOS, UnityEPL uses a native plugin to achieve higher accuracy timestamping. /// </summary> private void CollectKeyEvents() { if (IsMacOS()) { int eventCount = CountKeyEvents(); if (eventCount >= 1) { int keyCode = PopKeyKeycode(); double timestamp = PopKeyTimestamp(); bool downState; keyDownStates.TryGetValue(keyCode, out downState); keyDownStates[keyCode] = !downState; ReportKey(keyCode, keyDownStates[keyCode], OSXTimestampToTimestamp(timestamp)); } } else { foreach (KeyCode keyCode in System.Enum.GetValues(typeof(KeyCode))) { if (Input.GetKeyDown(keyCode)) { ReportKey((int)keyCode, true, DataReporter.TimeStamp()); } if (Input.GetKeyUp(keyCode)) { ReportKey((int)keyCode, false, DataReporter.TimeStamp()); } } } }
private void CollectMousePosition() { Dictionary <string, object> dataDict = new Dictionary <string, object>(); dataDict.Add("position", Input.mousePosition); eventQueue.Enqueue(new DataPoint("mouse position", DataReporter.TimeStamp(), dataDict)); lastMousePositionReportFrame = Time.frameCount; }
public void Init() { if (Marshal.PtrToStringAuto(OpenUSB()) == "didn't open usb...") { im.ReportEvent("syncbox disconnected", null, DataReporter.TimeStamp()); } StopPulse(); Start(); }
////////// // Microphone testing states ////////// protected void DoRecordTest() { state.micTestIndex++; string file = System.IO.Path.Combine(manager.fileManager.SessionPath(), "microphone_test_" + DataReporter.TimeStamp().ToString("yyyy-MM-dd_HH_mm_ss") + ".wav"); state.recordTestPath = file; RecordTest(file); }
public override void SendMessage(string type, Dictionary <string, object> data) { DataPoint point = new DataPoint(type, DataReporter.TimeStamp(), data); string message = point.ToJSON(); UnityEngine.Debug.Log("Sent Message"); UnityEngine.Debug.Log(message); Byte[] bytes = System.Text.Encoding.UTF8.GetBytes(message); NetworkStream stream = GetWriteStream(); stream.Write(bytes, 0, bytes.Length); ReportMessage(message, true); }
private void Pulse() { if (!stopped) { // Send a pulse im.Do(new EventBase <string, Dictionary <string, object>, DateTime>(im.ReportEvent, "syncPulse", null, DataReporter.TimeStamp())); SyncPulse(); // Wait a random interval between min and max int timeBetweenPulses = (int)(TIME_BETWEEN_PULSES_MIN + (int)(InterfaceManager.rnd.NextDouble() * (TIME_BETWEEN_PULSES_MAX - TIME_BETWEEN_PULSES_MIN))); DoIn(new EventBase(Pulse), timeBetweenPulses); } }
private void ReportMessage(string message, bool sent) { Dictionary <string, object> messageDataDict = new Dictionary <string, object>(); messageDataDict.Add("message", message); messageDataDict.Add("sent", sent.ToString()); im.Do(new EventBase <string, Dictionary <string, object>, DateTime>(im.ReportEvent, "network", messageDataDict, DataReporter.TimeStamp())); }
private void ReportMessage(string message) { elemem.Do(new EventBase <string, DateTime>(elemem.HandleMessage, message, DataReporter.TimeStamp())); }