Interface IGorgonRawInput
Raw Input functionality for keyboards, mice and human interface devices.
Inherited Members
Namespace: Gorgon.Input
Assembly: Gorgon.Input.dll
Syntax
public interface IGorgonRawInput : IDisposable
Remarks
This enables use of the Raw Input functionality provided by windows.
This object will allow for enumeration of multiple keyboard, mouse and human interface devices attached to the system and will allow an application to register these types of devices for use with the application.
The GorgonRawInput object will also coordinate WM_INPUT
messages and forward Raw Input data to an appropriate raw input device. This is done to allow multiple devices of the same
type (e.g. multiple mice) to be used individually.
Examples
The following code shows how to create a mouse device and register it with the GorgonRawInput object for use in an application:
private GorgonRawMouse _mouse;
private GorgonRawInput _rawInput;
private void CreateRawMouse(Control yourMainApplicationWindow)
{
// The 'yourMainApplicationWindow' is the primary window used by your application.
_rawInput = new GorgonRawInput(yourMainApplicationWindow);
_mouse = new GorgonRawMouse();
_rawInput.RegisterDevice(_mouse);
// Configure your mouse object for events here...
}
private void ApplicationShutDown()
{
// The device should be unregistered as soon as it's no longer needed.
_rawInput.UnregisterDevice(_mouse);
// Always dispose this object, otherwise message hooks may still persist and cause issues.
_rawInput.Dispose();
}
Methods
| Edit this page View SourceEnumerateHumanInterfaceDevices()
Function to retrieve a list of human interface devices (HID).
Declaration
IReadOnlyList<GorgonRawHIDInfo> EnumerateHumanInterfaceDevices()
Returns
Type | Description |
---|---|
IReadOnlyList<GorgonRawHIDInfo> | A read only list containing information about each human interface device. |
EnumerateKeyboards()
Function to retrieve a list of keyboards.
Declaration
IReadOnlyList<IGorgonKeyboardInfo> EnumerateKeyboards()
Returns
Type | Description |
---|---|
IReadOnlyList<IGorgonKeyboardInfo> | A read only list containing information about each keyboard. |
EnumerateMice()
Function to retrieve a list of mice.
Declaration
IReadOnlyList<IGorgonMouseInfo> EnumerateMice()
Returns
Type | Description |
---|---|
IReadOnlyList<IGorgonMouseInfo> | A read only list containing information about each mouse. |
RegisterDevice(IGorgonKeyboard, GorgonRawInputSettings?)
Function to register a keyboard device with the raw input provider.
Declaration
void RegisterDevice(IGorgonKeyboard device, GorgonRawInputSettings? settings = null)
Parameters
Type | Name | Description |
---|---|---|
IGorgonKeyboard | device | The keyboard device to register with the raw input provider. |
GorgonRawInputSettings? | settings | [Optional] Settings for the device type. |
Remarks
This will register the IGorgonMouse device with the application. For the very first device the Raw Input object will set up the registration for the keyboard. This enables an application to start receiving Raw Input messages from a keyboard.
The optional settings
parameter allows an application change how raw input handles the device being registered. It can be used to set up background input monitoring, or a
target window for raw input messages (which must be set if the background option is turned on). By default, there is no background message processing and no target window (messages go to
whichever window has focus).
Every call to this method should be paired with a call to UnregisterDevice(IGorgonKeyboard) when the keyboard is no longer needed.
RegisterDevice(IGorgonMouse, GorgonRawInputSettings?)
Function to register a mouse device with the raw input provider.
Declaration
void RegisterDevice(IGorgonMouse device, GorgonRawInputSettings? settings = null)
Parameters
Type | Name | Description |
---|---|---|
IGorgonMouse | device | The mouse device to register with the raw input provider. |
GorgonRawInputSettings? | settings | [Optional] Settings for the device type. |
Remarks
This will register the IGorgonMouse device with the application. For the very first device the Raw Input object will set up the registration for the mouse. This enables an application to start receiving Raw Input messages from a mouse.
The optional settings
parameter allows an application change how raw input handles the device being registered. It can be used to set up background input monitoring, or a
target window for raw input messages (which must be set if the background option is turned on). By default, there is no background message processing and no target window (messages go to
whichever window has focus).
Every call to this method should be paired with a call to UnregisterDevice(IGorgonMouse) when the mouse is no longer needed.
RegisterDevice(IGorgonRawHID, GorgonRawInputSettings?)
Function to register a HID with the raw input provider.
Declaration
void RegisterDevice(IGorgonRawHID device, GorgonRawInputSettings? settings = null)
Parameters
Type | Name | Description |
---|---|---|
IGorgonRawHID | device | The HID to register with the raw input provider. |
GorgonRawInputSettings? | settings | [Optional] Settings for the device type. |
Remarks
This will register the IGorgonMouse device with the application. For the very first device the Raw Input object will set up the registration for the HID. This enables an application to start receiving Raw Input messages from a HID.
The optional settings
parameter allows an application change how raw input handles the device being registered. It can be used to set up background input monitoring, or a
target window for raw input messages (which must be set if the background option is turned on). By default, there is no background message processing and no target window (messages go to
whichever window has focus).
Every call to this method should be paired with a call to UnregisterDevice(IGorgonRawHID) when the HID is no longer needed.
UnregisterDevice(IGorgonKeyboard)
Function to unregister a keyboard from the raw input provider.
Declaration
void UnregisterDevice(IGorgonKeyboard device)
Parameters
Type | Name | Description |
---|---|---|
IGorgonKeyboard | device | The keyboard to unregister from the raw input provider. |
Remarks
This will unregister a previously registered IGorgonKeyboard.
UnregisterDevice(IGorgonMouse)
Function to unregister a mouse from the raw input provider.
Declaration
void UnregisterDevice(IGorgonMouse device)
Parameters
Type | Name | Description |
---|---|---|
IGorgonMouse | device | The mouse to unregister from the raw input provider. |
Remarks
This will unregister a previously registered IGorgonMouse.
UnregisterDevice(IGorgonRawHID)
Function to unregister a HID from the raw input provider.
Declaration
void UnregisterDevice(IGorgonRawHID device)
Parameters
Type | Name | Description |
---|---|---|
IGorgonRawHID | device | The HID to unregister from the raw input provider. |
Remarks
This will unregister a previously registered IGorgonRawHID.