Interface IGorgonGamingDeviceDriver
The required functionality for a gaming device driver.
Namespace: Gorgon.Input
Assembly: Gorgon.Input.dll
Syntax
public interface IGorgonGamingDeviceDriver : IGorgonNamedObject, IDisposable
Remarks
A gaming device driver provides access to various gaming input devices like a joystick, game pad, etc... This allows for various input providers to be used when accessing these devices. For example, Gorgon comes with 2 drivers: One for XBOX controllers (via XInput), and one for generic joysticks/game pads (via Direct Input).
important
The XInput driver does not enumerate or use any other type of controllers other than XBox controllers, and the Direct Input driver purposely ignores XBox controllers so that only generic devices get enumerated. This is done because the XInput controller provides more features for the XBox controllers, and the mapping of the device interface (i.e. axes, POV, etc...) is not as straight forward.
These drivers are typically loaded as plug ins from a IGorgonGamingDeviceDriverFactory. The driver is responsible for enumerating the available devices that it supports, and will create instances of a IGorgonGamingDevice that represents the functionality of the gaming device as provided by the underlying native provider.
Because drivers may need to set up native resources for internal use, this interface implements IDisposable, and in order to avoid leakage of resource data, the Dispose() method must be called when done with the driver.
Examples
LoadPlugInAssemblies(string, string) The following shows how to load a IGorgonGamingDeviceDriver and enumerate the devices:
IReadOnlyList<GorgonGamingDeviceInfo> joysticks = null;
using (var assemblies = new GorgonPlugInAssemblyCache())
{
var plugInService = new GorgonPlugInService(assemblies);
var factory = new GorgonGamingDeviceDriverFactory(plugInService);
// Load the assembly for the XInput driver.
assemblies.Load(".\Gorgon.Input.XInput.dll");
// Get the correct driver from the plug ins via the factory.
IGorgonGamingDeviceDriver driver = factory.Load("Gorgon.Input.GorgonXInputDriver");
// Get connected devices only. You may change the parameter to false to retrieve all devices.
joysticks = driver.EnumerateGamingDevices(true);
foreach(IGorgonGamingDeviceInfo info in joysticks)
{
Console.WriteLine($"Controller: {info.Description}");
}
}
Properties
| Edit this page View SourceDescription
Property to return a description of the driver.
Declaration
string Description { get; }
Property Value
Type | Description |
---|---|
string |
Methods
| Edit this page View SourceCreateGamingDevice(IGorgonGamingDeviceInfo)
Function to create a GorgonGamingDevice object.
Declaration
IGorgonGamingDevice CreateGamingDevice(IGorgonGamingDeviceInfo gamingDeviceInfo)
Parameters
Type | Name | Description |
---|---|---|
IGorgonGamingDeviceInfo | gamingDeviceInfo | The IGorgonGamingDeviceInfo used to determine which device to associate with the resulting object. |
Returns
Type | Description |
---|---|
IGorgonGamingDevice | A GorgonGamingDevice representing the data from the physical device. |
Remarks
This will create a new instance of a IGorgonGamingDevice which will relay data from the physical device using the native provider.
Some devices may allocate native resources in order to communicate with the underlying native providers, and because of this, it is important to call the Dispose() method on the object when you are done with the object so that those resources may be freed.
CreateGamingDevices(bool)
Function to create all GorgonGamingDevice objects for this driver.
Declaration
IReadOnlyList<IGorgonGamingDevice> CreateGamingDevices(bool connectedOnly = false)
Parameters
Type | Name | Description |
---|---|---|
bool | connectedOnly | [Optional] true to only include connected gaming devices, false to include all devices. |
Returns
Type | Description |
---|---|
IReadOnlyList<IGorgonGamingDevice> | A list of of GorgonGamingDevice objects for this driver. |
Remarks
This will create an instance of IGorgonGamingDevice for all devices supported by the driver at one time and return a list containing those instances.
EnumerateGamingDevices(bool)
Function to enumerate the gaming devices supported by this driver.
Declaration
IReadOnlyList<IGorgonGamingDeviceInfo> EnumerateGamingDevices(bool connectedOnly = false)
Parameters
Type | Name | Description |
---|---|---|
bool | connectedOnly | [Optional] true to only enumerate devices that are connected, or false to enumerate all devices. |
Returns
Type | Description |
---|---|
IReadOnlyList<IGorgonGamingDeviceInfo> | A read only list of gaming device info values. |
Remarks
This will return only the devices supported by the driver. In some cases, the driver may not return a complete listing of all gaming devices attached to the system because the underlying provider may not support those device types.