public static void ReleaseManager() { if (_manager != null) { lock (_locker) if (_manager != null) { _manager._axisEnumValues = null; _manager._getVJDAxisExist = null; _manager._getVJDButtonNumber = null; _manager._getVJDContPovNumber = null; _manager._getVJDDiscPovNumber = null; _manager._getVJDStatusFunc = null; _manager._hidUsagesEnumType = null; _manager._joystick = null; _manager._resetAll = null; _manager._VjdStatEnumType = null; _manager._vJoyInterfaceWrapAssembly = null; _manager._vJoyType = null; _manager.UnLoadContext(); _manager = null; } } }
public static void ReleaseManager() { if (_manager != null) { lock (_locker) if (_manager != null) { var inUse = _manager._controllers.Where(c => c?.HasRelinquished == false); if (inUse.Any()) { throw new InvalidOperationException($"Controllers with index ({string.Join(", ", inUse.Select(x => x.Id))}) are in use. Please relinquish first."); } _manager._axisEnumValues = null; _manager._getVJDAxisExist = null; _manager._getVJDButtonNumber = null; _manager._getVJDContPovNumber = null; _manager._getVJDDiscPovNumber = null; _manager._getVJDStatusFunc = null; _manager._hidUsagesEnumType = null; _manager._joystick = null; _manager._resetAll = null; _manager._acquireVJD = null; _manager._relinquishVJD = null; _manager._VjdStatEnumType = null; _manager._vJoyInterfaceWrapAssembly = null; _manager._vJoyType = null; _manager._controllers = null; _manager.UnloadContext(); _manager = null; } } }
public static VJoyControllerManager GetManager() { if (_manager == null) { lock (_locker) if (_manager == null) { _manager = new VJoyControllerManager(); } } return(_manager); }
public static VJoyControllerManager GetManager() { if (_manager == null) { lock (_locker) if (_manager == null) { _manager = new VJoyControllerManager(); alcWeakRef = new WeakReference(_manager._vJoyAssemblyLoadContext, trackResurrection: true); } } return(_manager); }
public VJoyController(uint id, VJoyControllerManager manager) { Id = id; _vJoyType = manager._vJoyType; _joystick = manager._joystick; _hidUsagesEnumType = manager._hidUsagesEnumType; _axisEnumValues = manager._axisEnumValues; // Check which axes are supported HasAxisX = manager.GetVJDAxisExist(id, USAGES.X); HasAxisY = manager.GetVJDAxisExist(id, USAGES.Y); HasAxisZ = manager.GetVJDAxisExist(id, USAGES.Z); HasAxisRx = manager.GetVJDAxisExist(id, USAGES.Rx); HasAxisRy = manager.GetVJDAxisExist(id, USAGES.Ry); HasAxisRz = manager.GetVJDAxisExist(id, USAGES.Rz); HasSlider0 = manager.GetVJDAxisExist(id, USAGES.Slider0); HasSlider1 = manager.GetVJDAxisExist(id, USAGES.Slider1); HasWheel = manager.GetVJDAxisExist(id, USAGES.Wheel); // Get the number of buttons and POV Hat switchessupported by this vJoy device ButtonCount = manager.GetVJDButtonNumber(id); ContPovCount = manager.GetVJDContPovNumber(id); DiscPovCount = manager.GetVJDDiscPovNumber(id); var args = new object[] { Id, _axisEnumValues[0], 0L }; var hasAxis = (bool)_vJoyType.GetMethod("GetVJDAxisMax").Invoke(_joystick, args); AxisMaxValue = hasAxis ? (long)args[2] : (long?)null; _reset = (Func <uint, bool>)_vJoyType.GetMethod("ResetVJD").CreateDelegate(typeof(Func <uint, bool>), _joystick); _reset(Id); _setBtn = (Func <bool, uint, uint, bool>)_vJoyType.GetMethod("SetBtn").CreateDelegate(typeof(Func <bool, uint, uint, bool>), _joystick); _setContPov = (Func <int, uint, uint, bool>)_vJoyType.GetMethod("SetContPov").CreateDelegate(typeof(Func <int, uint, uint, bool>), _joystick); _setDiscPov = (Func <int, uint, uint, bool>)_vJoyType.GetMethod("SetDiscPov").CreateDelegate(typeof(Func <int, uint, uint, bool>), _joystick); _relinquish = (Action <uint>)_vJoyType.GetMethod("RelinquishVJD").CreateDelegate(typeof(Action <uint>), _joystick); _resetButtons = (Func <uint, bool>)_vJoyType.GetMethod("ResetButtons").CreateDelegate(typeof(Func <uint, bool>), _joystick); _resetPovs = (Func <uint, bool>)_vJoyType.GetMethod("ResetPovs").CreateDelegate(typeof(Func <uint, bool>), _joystick); var funcType = typeof(Func <, , ,>).MakeGenericType(new Type[] { typeof(int), typeof(uint), _hidUsagesEnumType, typeof(bool) }); _setAxisFunc = _vJoyType.GetMethod("SetAxis").CreateDelegate(funcType, _joystick); }