Skip to content

Commit 6ae136d

Browse files
Implement unregistering events (#10)
1 parent 780af62 commit 6ae136d

7 files changed

Lines changed: 23 additions & 0 deletions

File tree

EasyOpenVRSingleton.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
using System;
2+
using System.Collections.Generic;
13
using System.ComponentModel;
24
using System.Diagnostics;
35
using System.Drawing;
6+
using System.IO;
47
using System.Runtime.InteropServices;
58
using System.Text;
69
using EasyOpenVR.Extensions;
@@ -387,6 +390,19 @@ public void RegisterEvents(EVREventType[] types, Action<VREvent_t> action)
387390
}
388391
}
389392

393+
public void UnregisterEvent(EVREventType type)
394+
{
395+
UnregisterEvents(new EVREventType[1] { type });
396+
}
397+
398+
public void UnregisterEvents(EVREventType[] types)
399+
{
400+
foreach (var t in types)
401+
{
402+
if (_events.ContainsKey(t)) _events.Remove(t);
403+
}
404+
}
405+
390406
/// <summary>Load new events and match them against registered events types, trigger actions.</summary>
391407
public void UpdateEvents(bool debugUnhandledEvents = false)
392408
{

Extensions/HmdMatrix34Extensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using EasyOpenVR.Utils;
23
using Valve.VR;
34

Extensions/HmdVector3Extensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using Valve.VR;
23

34
namespace EasyOpenVR.Extensions;

Utils/BitmapUtils.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Drawing;
23
using System.Drawing.Imaging;
34
using System.Runtime.InteropServices;

Utils/EasingUtils.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System;
2+
13
namespace EasyOpenVR.Utils;
24

35
/**

Utils/GeneralUtils.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using EasyOpenVR.Data;
23
using EasyOpenVR.Extensions;
34
using Valve.VR;

Utils/UnityUtils.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using Valve.VR;
23

34
namespace EasyOpenVR.Utils;

0 commit comments

Comments
 (0)