Table of Contents

Struct SensorEvent

Namespace
Sdl3Sharp.Events
Assembly
Sdl3Sharp.dll

Represents an event that occurs when a sensor is being updated

public struct SensorEvent : ICommonEvent<SensorEvent>, ICommonEvent, ISpanFormattable, IFormattable
Implements
Inherited Members

Remarks

Associated EventTypes:

Properties

Data

Gets or sets the data from the sensor

public ReadOnlySpan<float> Data { readonly get; set; }

Property Value

ReadOnlySpan<float>

The data from the sensor, as a span of six float values

Remarks

Notice that this property always returns a ReadOnlySpan<T>. If you want to modify the data, you can either set the entire event data by setting this property from a different span, or modify the individual Data0, Data1, …, and Data5 properties.

Notice that when setting this property, the given values of the given span will be copied into the event data. That means you can assign spans that are larger than six elements, in which case only the first six elements will be copied. If you try to assign a span that is smaller than six elements, this property will throw an ArgumentException.

Exceptions

ArgumentException

When setting this property, the length of the given value argument is less than 6

Data0

Gets or sets the first data value from the sensor

public float Data0 { readonly get; set; }

Property Value

float

The first data value from the sensor

Remarks

The value of this property is the same as Data[0].

If you want to retrieve the entire event data from the sensor at once, consider using the Data property instead.

Data1

Gets or sets the second data value from the sensor

public float Data1 { readonly get; set; }

Property Value

float

The second data value from the sensor

Remarks

The value of this property is the same as Data[1].

If you want to retrieve the entire event data from the sensor at once, consider using the Data property instead.

Data2

Gets or sets the third data value from the sensor

public float Data2 { readonly get; set; }

Property Value

float

The third data value from the sensor

Remarks

The value of this property is the same as Data[2].

If you want to retrieve the entire event data from the sensor at once, consider using the Data property instead.

Data3

Gets or sets the fourth data value from the sensor

public float Data3 { readonly get; set; }

Property Value

float

The fourth data value from the sensor

Remarks

The value of this property is the same as Data[3].

If you want to retrieve the entire event data from the sensor at once, consider using the Data property instead.

Data4

Gets or sets the fifth data value from the sensor

public float Data4 { readonly get; set; }

Property Value

float

The fifth data value from the sensor

Remarks

The value of this property is the same as Data[4].

If you want to retrieve the entire event data from the sensor at once, consider using the Data property instead.

Data5

Gets or sets the sixth data value from the sensor

public float Data5 { readonly get; set; }

Property Value

float

The sixth data value from the sensor

Remarks

The value of this property is the same as Data[5].

If you want to retrieve the entire event data from the sensor at once, consider using the Data property instead.

SensorId

Gets or sets the sensor device ID for the Sensor being updated

public uint SensorId { readonly get; set; }

Property Value

uint

The sensor device ID for the Sensor being updated

SensorTimestamp

Gets or sets the timestamp of the sensor reading

public ulong SensorTimestamp { readonly get; set; }

Property Value

ulong

The timestamp of the sensor reading, in nanoseconds

Remarks

The value of this property is not necessarily synchronized with the system's clock.

Timestamp

Gets or sets the timestamp of the current event

public ulong Timestamp { readonly get; set; }

Property Value

ulong

The timestamp of the current event, in nanoseconds in nanoseconds since the initialization of SDL

Remarks

The value of this property usually describes the time passed, in nanoseconds since the initialization of SDL. It can be properly populated by using NanosecondTicks.

Type

Gets or sets the type of the current event

public EventType Type { readonly get; set; }

Property Value

EventType

The type of the current event

Remarks

When setting this property, the value must be GamepadSensorUpdated. Otherwise, it will lead the property to throw an ArgumentException!

Exceptions

ArgumentException

When setting this property, the value was GamepadSensorUpdated

Methods

ToString()

Returns the fully qualified type name of this instance.

public override readonly string ToString()

Returns

string

The fully qualified type name.

ToString(IFormatProvider?)

Formats the value of the current instance using the specified format.

public readonly string ToString(IFormatProvider? formatProvider)

Parameters

formatProvider IFormatProvider

The provider to use to format the value.

-or-

A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.

Returns

string

The value of the current instance in the specified format.

ToString(string?)

Formats the value of the current instance using the specified format.

public readonly string ToString(string? format)

Parameters

format string

The format to use.

-or-

A null reference (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.

Returns

string

The value of the current instance in the specified format.

ToString(string?, IFormatProvider?)

Formats the value of the current instance using the specified format.

public readonly string ToString(string? format, IFormatProvider? formatProvider)

Parameters

format string

The format to use.

-or-

A null reference (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.

formatProvider IFormatProvider

The provider to use to format the value.

-or-

A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.

Returns

string

The value of the current instance in the specified format.

TryFormat(Span<char>, out int, ReadOnlySpan<char>, IFormatProvider?)

Tries to format the value of the current instance into the provided span of characters.

public readonly bool TryFormat(Span<char> destination, out int charsWritten, ReadOnlySpan<char> format = default, IFormatProvider? provider = null)

Parameters

destination Span<char>

The span in which to write this instance's value formatted as a span of characters.

charsWritten int

When this method returns, contains the number of characters that were written in destination.

format ReadOnlySpan<char>

A span containing the characters that represent a standard or custom format string that defines the acceptable format for destination.

provider IFormatProvider

An optional object that supplies culture-specific formatting information for destination.

Returns

bool

true if the formatting was successful; otherwise, false.

Operators

explicit operator SensorEvent(in Event)

Converts a general Event to an event of type SensorEvent

public static explicit operator SensorEvent(in Event @event)

Parameters

event Event

The general Event to convert to an event of type SensorEvent

Returns

SensorEvent

Remarks

The Type of the given event must be SensorUpdated. Otherwise, it will lead the method to throw an ArgumentException!

Exceptions

ArgumentException

The Type of the given event was not SensorUpdated

implicit operator Event(in SensorEvent)

Converts an event of type SensorEvent to a general Event

public static implicit operator Event(in SensorEvent @event)

Parameters

event SensorEvent

The event of type SensorEvent to convert to a general Event

Returns

Event

Remarks

This conversion usually requires the event to be copied into a new general Event structure. Note: This can impact performance!