forked from Unity-Technologies/UnityCsReference
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputModule.bindings.cs
More file actions
64 lines (52 loc) · 2.75 KB
/
Copy pathInputModule.bindings.cs
File metadata and controls
64 lines (52 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License
using System;
using UnityEngine;
using UnityEngine.Bindings;
using UnityEngineInternal;
using Unity.Collections.LowLevel.Unsafe;
namespace UnityEngineInternal.Input
{
[NativeHeader("Modules/Input/Private/InputModuleBindings.h")]
[NativeHeader("Modules/Input/Private/InputInternal.h")]
[NativeConditional("ENABLE_NEW_INPUT_SYSTEM")]
public partial class NativeInputSystem
{
public static extern double zeroEventTime { get; }
public static extern bool hasDeviceDiscoveredCallback { set; }
// C# doesn't allow taking the address of a value type because of pinning requirements for the heap.
// And our bindings generator doesn't support overloading. So ugly code following here...
public unsafe static void SendInput<TInputEvent>(TInputEvent inputEvent)
where TInputEvent : struct
{
SendInput((IntPtr)UnsafeUtility.AddressOf<TInputEvent>(ref inputEvent));
}
public static extern void SendInput(IntPtr inputEvent);
unsafe public static bool SendOutput<TOutputEvent>(int deviceId, int type, TOutputEvent outputEvent)
where TOutputEvent : struct
{
return SendOutput(deviceId, type, UnsafeUtility.SizeOf<TOutputEvent>(), (IntPtr)UnsafeUtility.AddressOf(ref outputEvent));
}
public static extern bool SendOutput(int deviceId, int type, int sizeInBytes, IntPtr data);
// TODO: This was ported from the old bindings system, but it doesn't look needed.
public static string GetDeviceConfiguration(int deviceId) { return null; }
public static extern string GetControlConfiguration(int deviceId, int controlIndex);
public static void SetPollingFrequency(float hertz)
{
if (hertz < 1.0f)
throw new ArgumentException("Polling frequency cannot be less than 1Hz");
SetPollingFrequencyInternal(hertz);
}
private static extern void SetPollingFrequencyInternal(float hertz);
// The following APIs are not for normal use of the system as they do things
// that are normally done either by platform-specific backends or by the player
// loop. However, they can be used, for example, to drive the system from
// managed code during tests.
static extern void SendEvents();
static extern void Update(NativeInputUpdateType updateType);
static extern int ReportNewInputDevice(string descriptor);
static extern void ReportInputDeviceDisconnect(int nativeDeviceId);
static extern void ReportInputDeviceReconnect(int nativeDeviceId);
}
}