-
Notifications
You must be signed in to change notification settings - Fork 341
NEW: Add LocationSensor for Input System #2469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: im-parity/staging
Are you sure you want to change the base?
Changes from all commits
3625a0a
c0fc488
777eadd
5d4a284
66c5682
08d49df
f8f840b
e34417d
42c371c
4c9aef3
60caf6d
166cb55
fe5105e
2a473d8
59c65e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -115,5 +115,5 @@ Note: [`UnityEngine.TouchScreenKeyboard`](https://docs.unity3d.com/ScriptReferen | |||||
| [`Input.gyro.rotationRateUnbiased`](https://docs.unity3d.com/ScriptReference/Gyroscope-rotationRateUnbiased.html)|No corresponding API yet. | ||||||
| [`Input.gyro.updateInterval`](https://docs.unity3d.com/ScriptReference/Gyroscope-updateInterval.html)|[`Sensor.samplingFrequency`](xref:UnityEngine.InputSystem.Sensor)<br/>Example:<br/>`Gyroscope.current.samplingFrequency = 1.0f / updateInterval;`<br/><br/>__Notes__:<br/>[`samplingFrequency`](xref:UnityEngine.InputSystem.Sensor) is in Hz, not in seconds as [`updateInterval`](https://docs.unity3d.com/ScriptReference/Gyroscope-updateInterval.html), so you need to divide 1 by the value.<br/><br/>The new Input System replaces `UnityEngine.Gyroscope` with multiple separate sensor devices. Substitute [`Gyroscope`](xref:UnityEngine.InputSystem.Gyroscope) with other sensors in the sample as needed. See the notes for `Input.gyro` above for details. | ||||||
| [`Input.gyro.userAcceleration`](https://docs.unity3d.com/ScriptReference/Gyroscope-userAcceleration.html)|[`LinearAccelerationSensor.current.acceleration.ReadValue()`](xref:UnityEngine.InputSystem.LinearAccelerationSensor) | ||||||
| [`Input.location`](https://docs.unity3d.com/ScriptReference/Input-location.html)|No corresponding API yet. | ||||||
| [`Input.location`](https://docs.unity3d.com/ScriptReference/Input-location.html)|[`LocationSensor`](xref:UnityEngine.InputSystem.LocationSensor).<br/>Start/Stop:<br/>`InputSystem.EnableDevice(LocationSensor.current);`<br/>`InputSystem.DisableDevice(LocationSensor.current);`<br/>Read the last fix from the controls, for example `LocationSensor.current.latitude.ReadValue()` (also `longitude`, `altitude`, `horizontalAccuracy`, `verticalAccuracy`, `timestamp`).<br/>Query lifecycle and permission with [`LocationSensor.current.status`](xref:UnityEngine.InputSystem.LocationSensor.status) and [`LocationSensor.current.isEnabledByUser`](xref:UnityEngine.InputSystem.LocationSensor.isEnabledByUser).<br/>Set the requested accuracy and update-distance with `LocationSensor.current.Configure(accuracyInMeters, updateDistanceInMeters)`, or `LocationSensor.current.ResetConfiguration()` to revert to the project defaults [`InputSettings.locationAccuracy`](xref:UnityEngine.InputSystem.InputSettings.locationAccuracy) and [`InputSettings.locationDistanceThreshold`](xref:UnityEngine.InputSystem.InputSettings.locationDistanceThreshold).<br/>Note: on Android and iOS the location permission and usage description are auto-added to the build only when your code references `LocationSensor` directly; if you use it solely through an `.inputactions` binding, reference the type in code (for example `LocationSensor.current`) or add the permission and usage description manually. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| [`Input.GetAccelerationEvent`](https://docs.unity3d.com/ScriptReference/Input.GetAccelerationEvent.html)|See notes for `Input.accelerationEvents` above. | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| using System.Runtime.InteropServices; | ||
| using UnityEngine.InputSystem.Utilities; | ||
|
|
||
| namespace UnityEngine.InputSystem.LowLevel | ||
| { | ||
| /// <summary> | ||
| /// Command to set the desired accuracy and update-distance threshold of a <see cref="LocationSensor"/>. | ||
| /// </summary> | ||
| [StructLayout(LayoutKind.Explicit, Size = kSize)] | ||
| internal struct ConfigureLocationCommand : IInputDeviceCommandInfo | ||
| { | ||
| public static FourCC Type => new FourCC('L', 'C', 'F', 'G'); | ||
|
|
||
| internal const int kSize = InputDeviceCommand.kBaseCommandSize + sizeof(float) * 2; | ||
|
|
||
| [FieldOffset(0)] | ||
| public InputDeviceCommand baseCommand; | ||
|
|
||
| [FieldOffset(InputDeviceCommand.kBaseCommandSize)] | ||
| public float desiredAccuracyInMeters; | ||
|
|
||
| [FieldOffset(InputDeviceCommand.kBaseCommandSize + sizeof(float))] | ||
| public float updateDistanceInMeters; | ||
|
|
||
| public FourCC typeStatic => Type; | ||
|
|
||
| public static ConfigureLocationCommand Create(float desiredAccuracyInMeters, float updateDistanceInMeters) | ||
| { | ||
| return new ConfigureLocationCommand | ||
| { | ||
| baseCommand = new InputDeviceCommand(Type, kSize), | ||
| desiredAccuracyInMeters = desiredAccuracyInMeters, | ||
| updateDistanceInMeters = updateDistanceInMeters | ||
| }; | ||
| } | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| using System.Runtime.InteropServices; | ||
| using UnityEngine.InputSystem.Utilities; | ||
|
|
||
| namespace UnityEngine.InputSystem.LowLevel | ||
| { | ||
| /// <summary> | ||
| /// Command to query whether the user has granted OS-level permission for a <see cref="LocationSensor"/> to access location data. | ||
| /// </summary> | ||
| [StructLayout(LayoutKind.Explicit, Size = kSize)] | ||
| internal struct QueryLocationEnabledByUserCommand : IInputDeviceCommandInfo | ||
| { | ||
| public static FourCC Type => new FourCC('L', 'U', 'S', 'R'); | ||
|
|
||
| internal const int kSize = InputDeviceCommand.kBaseCommandSize + sizeof(bool); | ||
|
|
||
| [FieldOffset(0)] | ||
| public InputDeviceCommand baseCommand; | ||
|
|
||
| [FieldOffset(InputDeviceCommand.kBaseCommandSize)] | ||
| public bool enabledByUser; | ||
|
|
||
| public FourCC typeStatic => Type; | ||
|
|
||
| public static QueryLocationEnabledByUserCommand Create() | ||
| { | ||
| return new QueryLocationEnabledByUserCommand | ||
| { | ||
| baseCommand = new InputDeviceCommand(Type, kSize) | ||
| }; | ||
| } | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| using System.Runtime.InteropServices; | ||
| using UnityEngine.InputSystem.Utilities; | ||
|
|
||
| namespace UnityEngine.InputSystem.LowLevel | ||
| { | ||
| /// <summary> | ||
| /// Command to query the current status of a <see cref="LocationSensor"/>'s underlying platform location service. | ||
| /// </summary> | ||
| [StructLayout(LayoutKind.Explicit, Size = kSize)] | ||
| internal struct QueryLocationStatusCommand : IInputDeviceCommandInfo | ||
| { | ||
| public static FourCC Type => new FourCC('L', 'S', 'T', 'A'); | ||
|
|
||
| internal const int kSize = InputDeviceCommand.kBaseCommandSize + sizeof(int); | ||
|
|
||
| [FieldOffset(0)] | ||
| public InputDeviceCommand baseCommand; | ||
|
|
||
| // 0 Stopped, 1 Initializing, 2 Running, 3 Failed (matches LocationServiceStatus). | ||
| [FieldOffset(InputDeviceCommand.kBaseCommandSize)] | ||
| public int status; | ||
|
|
||
| public FourCC typeStatic => Type; | ||
|
|
||
| public static QueryLocationStatusCommand Create() | ||
| { | ||
| return new QueryLocationStatusCommand | ||
| { | ||
| baseCommand = new InputDeviceCommand(Type, kSize) | ||
| }; | ||
| } | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI @suearkinunity