void EndTransaction(string transactionKey, string type, bool rightController) { string transactionID; if (pendingTransactions.TryGetValue(transactionKey, out transactionID)) { Vector3 pos = CognitiveVR_Manager.GetControllerPosition(rightController); new CustomEvent("cvr.input").SetProperty("type", type).SetProperty("device", rightController ? "right controller" : "left controller").SetProperty("state", "end").Send(pos); pendingTransactions.Remove(transactionID); } }
void BeginTransaction(string transactionKey, string type, bool rightController) { Vector3 pos = CognitiveVR_Manager.GetControllerPosition(rightController); string transactionID = Util.GetUniqueId(); var inTransaction = new CustomEvent("cvr.input"); inTransaction.SetProperty("type", type).SetProperty("device", rightController?"right controller": "left controller").SetProperty("state", "begin"); inTransaction.Send(pos); if (!pendingTransactions.ContainsKey(transactionKey)) { pendingTransactions.Add(transactionKey, transactionID); } }
private void CognitiveVR_Manager_OnTick() { bool hit; #if CVR_STEAMVR if (CognitiveVR_Manager.GetController(false) != null) #endif { Vector3 pos = CognitiveVR_Manager.GetControllerPosition(false); hit = Physics.CheckSphere(pos, 0.1f, CollisionLayerMask); if (hit && string.IsNullOrEmpty(controller0GUID)) { Util.logDebug("controller collision"); controller0GUID = Util.GetUniqueId(); new CustomEvent("cvr.collision").SetProperty("device", "left controller").SetProperty("state", "begin").Send(); } else if (!hit && !string.IsNullOrEmpty(controller0GUID)) { new CustomEvent("cvr.collision").SetProperty("device", "left controller").SetProperty("state", "end").Send(); controller0GUID = string.Empty; } } #if CVR_STEAMVR if (CognitiveVR_Manager.GetController(true) != null) #endif { Vector3 pos = CognitiveVR_Manager.GetControllerPosition(true); hit = Physics.CheckSphere(pos, 0.1f, CollisionLayerMask); if (hit && string.IsNullOrEmpty(controller1GUID)) { Util.logDebug("controller collision"); controller1GUID = Util.GetUniqueId(); new CustomEvent("cvr.collision").SetProperty("device", "right controller").SetProperty("state", "begin").Send(); } else if (!hit && !string.IsNullOrEmpty(controller1GUID)) { new CustomEvent("cvr.collision").SetProperty("device", "right controller").SetProperty("state", "end").Send(); controller1GUID = string.Empty; } } }
private void OnPadClicked(object sender, ClickedEventArgs e) { var padTransaction = new CustomEvent("cvr.input"); CognitiveVR_Manager.ControllerInfo cont = CognitiveVR_Manager.GetControllerInfo((int)e.controllerIndex); if (cont == null) { return; } Vector3 pos = CognitiveVR_Manager.GetControllerPosition(cont.isRight); padTransaction.SetProperties(new Dictionary <string, object> { { "type", "pad" }, { "device", cont.isRight?"right controller":"left controller" }, { "x", e.padX }, { "y", e.padY } }); padTransaction.Send(pos); }