123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- using AOT;
- using EZXR.Glass.Core;
- using EZXR.Glass.SixDof;
- using UnityEngine;
- namespace EZXR.Glass.Inputs
- {
- public enum HandleKeyCode
- {
- Home = 301,
- Return = 300,
- Primary = 303,
- Secondary = 302,
- Rocker = 304,
- Trigger = 305,
- Grid = 306
- }
- [ScriptExecutionOrder(-50)]
- public class HandleControllerSession : MonoBehaviour
- {
-
- [StructLayout(LayoutKind.Sequential)]
- private struct HandControllerResult
- {
- [MarshalAs(UnmanagedType.ByValArray, SizeConst = 7)]
- public float[] pose;
- public float is_3dof;
- public double timestamp;
- public int controllerId;
- }
- private static HandleControllerSession instance;
- public static HandleControllerSession Instance
- {
- get
- {
- return instance;
- }
- }
- public static Pose controllerPose_left = new Pose();
- public static Pose controllerPose_right = new Pose();
- private HandControllerResult controllerLeftResult = new HandControllerResult();
- private HandControllerResult controllerRightResult = new HandControllerResult();
- private Action<HandType, bool> bindingEventCallback;
- private Action<HandType, bool> connectEventCallback;
- private Action<HandType, HandleKeyCode, bool> buttonEventCallback;
- private Action<HandType, Vector2> axis2DEventCallback;
- private Action<HandType, HandleKeyCode, bool> holdEventCallback;
- private Action<HandType, bool> silenceEventCallback;
- private Action<HandType, int> trackingStateEventCallback;
- private Action<HandType, bool> upgradeOTAEventCallback;
- private Action<bool> serverReconnectEventCallback;
-
- private delegate void ControllerBindEventCallback(int value);
- private delegate void ControllerConnectEventCallback(bool connected, int controllerId);
- private delegate void ControllerButtonEventCallback(int keycode, int state, int controllerId);
- private delegate void ControllerAxis2DEventCallback(int x, int y, int controllerId);
- private delegate void ControllerHoldEventCallback(int keycode, bool isHeld, int controllerId);
- private delegate void ControllerSilenceEventCallback(bool sleepless, int controllerId);
- private delegate void ControllerHxrctUpdateCallback(int status, int controllerId);
-
- private delegate void ControllerServerReconnectedCallback(bool connected);
- private struct ControllerBindEventUserData { public int status; public bool changed; }
- private struct ControllerConnectEventUserData { public bool connected; public int controllerId; public bool changed; }
- private struct ControllerButtonEventUserData { public int keycode; public int state; public int controllerId; public bool changed; }
- private struct ControllerAxis2DEventUserData { public int x; public int y; public int controllerId; public bool changed; }
- private struct ControllerHoldEventUserData { public int keycode; public bool isHeld; public int controllerId; public bool changed; }
- private struct ControllerSilenceEventUserData { public bool sleepless; public int controllerId; public bool changed; }
- private struct ControllerHxrctUpdateUserData { public int status; public int controllerId; public bool changed; }
- private struct ControllerServerReconnectedUserData { public bool connected; public bool changed; }
- private static ControllerBindEventUserData bindEventUserData;
- private static ControllerConnectEventUserData connectEventUserData;
- private static ControllerButtonEventUserData buttonEventUserData;
- private static ControllerAxis2DEventUserData axis2DEventUserData;
- private static ControllerHoldEventUserData holdEventUserData;
- private static ControllerSilenceEventUserData silenceEventUserData;
- private static ControllerHxrctUpdateUserData hxrctUpdateUserData;
- private static ControllerServerReconnectedUserData serverReconnectedUserData;
-
- private static bool isRegisterActive;
- private void Awake()
- {
- instance = this;
- controllerLeftResult.controllerId = -1;
- controllerRightResult.controllerId = -1;
- controllerLeftResult.pose = new float[7];
- controllerRightResult.pose = new float[7];
- controllerLeftResult.is_3dof = -1;
- controllerRightResult.is_3dof = -1;
- RegisterNativeAPI();
-
- Debug.Log("HandleControllerSession Awake");
- }
- private void OnApplicationPause(bool pause)
- {
-
-
- if (!pause)
- {
- RegisterNativeAPI();
- Debug.Log("HandleControllerSession OnApplicationResume, successfully register Events(8)");
- }
- else
- {
- UnregisterNativeAPI();
- Debug.Log("HandleControllerSession OnApplicationPause, successfully unregister Events(8)");
- }
- }
- private void OnDestroy()
- {
- UnregisterNativeAPI();
- Debug.Log("HandleControllerSession, destroy register Events(8)");
- }
- private void RegisterNativeAPI()
- {
- if (isRegisterActive) return;
- isRegisterActive = true;
- NativeAPI.registerControllerBondChangeCallback(OnControllerBindEventCallback);
- NativeAPI.registerControllerConnectEventCallback(OnControllerConnectEventCallback);
- NativeAPI.registerControllerTouchEvent(OnControllerButtonEventCallback);
- NativeAPI.registerControllerRockerTouchEvent(OnControllerAxis2DEventCallback);
- NativeAPI.registerControllerTouchChangeEventCallback(OnControllerHoldEventCallback);
- NativeAPI.registerControllerSleepChangeCallback(OnControllerSilenceEventCallback);
- NativeAPI.registerControllerHxrctUpdateCallback(OnControllerHxrctUpdateCallback);
-
-
- NativeTracking.RegisterConnectChangedCallback(OnControllerServerReconnectedCallback);
- Debug.Log("HandleControllerSession RegisterNativeAPI, successfully register Events(8)");
- }
- private void UnregisterNativeAPI()
- {
- isRegisterActive = false;
- NativeAPI.registerControllerBondChangeCallback(null);
- NativeAPI.registerControllerConnectEventCallback(null);
- NativeAPI.registerControllerTouchEvent(null);
- NativeAPI.registerControllerRockerTouchEvent(null);
- NativeAPI.registerControllerTouchChangeEventCallback(null);
- NativeAPI.registerControllerSleepChangeCallback(null);
- NativeAPI.registerControllerHxrctUpdateCallback(null);
-
-
- NativeTracking.UnregisterConnectChangedCallback(OnControllerServerReconnectedCallback);
- Debug.Log("HandleControllerSession UnregisterNativeAPI, successfully unregister Events(8)");
- }
-
- private void Update()
- {
-
- }
-
-
-
- public void InitRegistration(Action<HandType, bool> bindingEventCallback,
- Action<HandType, bool> connectEventCallback,
- Action<HandType, HandleKeyCode, bool> buttonEventCallback,
- Action<HandType, Vector2> axis2DEventCallback,
- Action<HandType, HandleKeyCode, bool> holdEventCallback,
- Action<HandType, bool> silenceEventCallback,
- Action<HandType, int> trackingStateEventCallback)
- {
- this.bindingEventCallback = bindingEventCallback;
- this.connectEventCallback = connectEventCallback;
- this.buttonEventCallback = buttonEventCallback;
- this.axis2DEventCallback = axis2DEventCallback;
- this.holdEventCallback = holdEventCallback;
- this.silenceEventCallback = silenceEventCallback;
- this.trackingStateEventCallback = trackingStateEventCallback;
- }
-
-
-
-
- public void InitOTARegistration(Action<HandType, bool> upgradeOTAEventCallback)
- {
- this.upgradeOTAEventCallback = upgradeOTAEventCallback;
- }
-
-
-
-
- public void InitServerReconnectRegistration(Action<bool> serverReconnectEventCallback)
- {
- this.serverReconnectEventCallback = serverReconnectEventCallback;
- }
-
-
-
-
-
- public bool BindHandle(int controllerId)
- {
-
- NativeAPI.ClearBond(controllerId);
-
- return NativeAPI.bondController(controllerId) >= 0;
- }
-
-
-
-
-
- public bool UnbindHandle(int controllerId)
- {
-
- return NativeAPI.ClearBond(controllerId) >= 0;
- }
-
-
-
-
-
- public bool GetBindState(HandType handType)
- {
- int value = NativeAPI.GetControllerBondState();
- if (handType == HandType.Left)
- {
- if ((value & 0x0F) == 0x00) return false;
- if ((value & 0x0F) == 0x04) return true;
- }
- else
- {
- if ((value & 0xF0) == 0x00) return false;
- if ((value & 0xF0) == 0x40) return true;
- }
- Debug.Log($"HandleControllerSession, GetBindState Exception: {value}");
- return false;
- }
-
-
-
-
-
- public bool GetConnectState(int controllerId)
- {
-
- return NativeAPI.GetControllerConnectState(controllerId) > 0;
- }
-
-
-
-
-
- public float GetPowerStats(int controllerId)
- {
-
- return NativeAPI.GetControllerBattery(controllerId) / 6.0f;
- }
-
-
-
-
-
-
- public bool VibrateHandle(int controllerId, int level, int time)
- {
-
- return NativeAPI.vibrateController(controllerId, level, time) >= 0;
- }
-
-
-
-
- public bool ChangeControllerType(int type)
- {
- if (SessionManager.Instance && SessionManager.Instance.IsInited)
- {
- NativeAPI.changeControllerType(type);
- return true;
- }
- return false;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public string GetControllerDeviceSN(int controllerId)
- {
- string sn = Marshal.PtrToStringAnsi(NativeAPI.getControllerMac(controllerId));
- Debug.Log($"HandleControllerSession, GetControllerDeviceSN: {sn}");
- return sn;
- }
-
-
-
-
-
- public int GetOTAVersion(int controllerId)
- {
- return NativeAPI.ControllerClient_GetCtrlVersion(controllerId);
- }
-
-
-
-
- public int GetHostOTAVersion()
- {
- return NativeAPI.ControllerClient_GetVersion();
- }
-
-
-
-
-
-
- public bool UpgradeOTA(int controllerId, string package)
- {
-
- Debug.Log($"HandleControllerSession, UpgradeOTA: controllerId = {controllerId}, package = {package}," +
- $"result = {NativeAPI.updateHxrct(package, controllerId)}");
- return true;
- }
-
-
-
-
-
- public bool UpgradeHostOTA(string package)
- {
-
- Debug.Log($"HandleControllerSession, UpgradeHostOTA: package = {package}," +
- $"result = {NativeAPI.ControllerHxrUpgradeHost(package)}");
- return true;
- }
-
-
-
- public void UpdateHandlePose()
- {
- if (ARFrame.SessionStatus == EZVIOState.EZVIOCameraState_Tracking)
- {
-
- var translation = HMDPoseTracker.Instance.transform.position;
- var quaternion = HMDPoseTracker.Instance.transform.rotation;
-
- if (HMDPoseTracker.Instance.UseLocalPose)
- {
- translation = HMDPoseTracker.Instance.transform.localPosition;
- quaternion = HMDPoseTracker.Instance.transform.localRotation;
- }
- var originHeadPose = new float[]
- {
- translation.x, translation.y,translation.z,
- quaternion.x, quaternion.y, quaternion.z, quaternion.w
- };
-
-
-
-
- float left_is_3dof = controllerLeftResult.is_3dof, right_is_3dof = controllerRightResult.is_3dof;
- if (NativeAPI.getControllerResultWithHead(ref controllerLeftResult, ref controllerRightResult, originHeadPose, originHeadPose.Length))
- {
- #if UNITY_EDITOR
- var left_position = Vector3.zero;
- var left_rotation = Quaternion.identity;
- var right_position = Vector3.zero;
- var right_rotation = Quaternion.identity;
- #else
- var left_position = new Vector3(controllerLeftResult.pose[0], controllerLeftResult.pose[1], controllerLeftResult.pose[2]);
- var left_rotation = new Quaternion(controllerLeftResult.pose[4], controllerLeftResult.pose[5], controllerLeftResult.pose[6], controllerLeftResult.pose[3]);
- var right_position = new Vector3(controllerRightResult.pose[0], controllerRightResult.pose[1], controllerRightResult.pose[2]);
- var right_rotation = new Quaternion(controllerRightResult.pose[4], controllerRightResult.pose[5], controllerRightResult.pose[6], controllerRightResult.pose[3]);
- #endif
- controllerPose_left.position = left_position;
- controllerPose_left.rotation = left_rotation;
-
-
- controllerPose_right.position = right_position;
- controllerPose_right.rotation = right_rotation;
-
-
- if (left_is_3dof != controllerLeftResult.is_3dof)
- {
- Debug.Log($"HandleControllerSession, controllerLeftResult is_3dof changed to: {controllerLeftResult.is_3dof}");
- trackingStateEventCallback?.Invoke(HandType.Left, (int)controllerLeftResult.is_3dof);
- }
- if (right_is_3dof != controllerRightResult.is_3dof)
- {
- Debug.Log($"HandleControllerSession, controllerRightResult is_3dof changed to: {controllerRightResult.is_3dof}");
- trackingStateEventCallback?.Invoke(HandType.Right, (int)controllerRightResult.is_3dof);
- }
- }
- }
- }
-
-
-
- public void UpdateHandleCallback()
- {
- if (bindEventUserData.changed)
- {
- bindEventUserData.changed = false;
- bool status = false;
- bool valid_left = false;
- int value = bindEventUserData.status;
- if ((value & 0x0F) == 0x00) { valid_left = true; status = false; }
- if ((value & 0x0F) == 0x04) { valid_left = true; status = true; }
- Debug.Log($"HandleControllerSession, UpdateHandleCallback bindingEventCallback: handType = Left, valid = {valid_left}, status = {status}");
- if (valid_left) HandleControllerSession.Instance.bindingEventCallback(HandType.Left, status);
- bool valid_right = false;
- if ((value & 0xF0) == 0x00) { valid_right = true; status = false; }
- if ((value & 0xF0) == 0x40) { valid_right = true; status = true; }
- Debug.Log($"HandleControllerSession, UpdateHandleCallback bindingEventCallback: handType = Right, valid = {valid_right}, status = {status}");
- if (valid_right) HandleControllerSession.Instance.bindingEventCallback(HandType.Right, status);
- }
- if (connectEventUserData.changed)
- {
- connectEventUserData.changed = false;
- var connected = connectEventUserData.connected;
- var controllerId = connectEventUserData.controllerId;
- Debug.Log($"HandleControllerSession, UpdateHandleCallback connectEventCallback: connected = {connected}, controllerId = {controllerId}");
- HandleControllerSession.Instance.connectEventCallback((HandType)controllerId, connected);
- }
- if (buttonEventUserData.changed)
- {
- buttonEventUserData.changed = false;
- var controllerId = buttonEventUserData.controllerId;
- var keycode = buttonEventUserData.keycode;
- var state = buttonEventUserData.state;
-
- HandleControllerSession.Instance.buttonEventCallback((HandType)controllerId, (HandleKeyCode)keycode, state > 0);
- }
- if (axis2DEventUserData.changed)
- {
- axis2DEventUserData.changed = false;
- var x = axis2DEventUserData.x;
- var y = axis2DEventUserData.y;
- var controllerId = axis2DEventUserData.controllerId;
-
- float axis_x = x < 8 ? Mathf.Lerp(-1, 0, x / 8.0f) : Mathf.Lerp(0, 1, (x - 8) / (15.0f - 8.0f));
- float axis_y = y < 8 ? Mathf.Lerp(-1, 0, y / 8.0f) : Mathf.Lerp(0, 1, (y - 8) / (15.0f - 8.0f));
- HandleControllerSession.Instance.axis2DEventCallback((HandType)controllerId, new Vector2(axis_x, axis_y));
- }
- if (holdEventUserData.changed)
- {
- holdEventUserData.changed = false;
- var keycode = holdEventUserData.keycode;
- var isHeld = holdEventUserData.isHeld;
- var controllerId = holdEventUserData.controllerId;
-
- HandleControllerSession.Instance.holdEventCallback((HandType)controllerId, (HandleKeyCode)keycode, isHeld);
- }
- if (silenceEventUserData.changed)
- {
- silenceEventUserData.changed = false;
- var sleepless = silenceEventUserData.sleepless;
- var controllerId = silenceEventUserData.controllerId;
-
- HandleControllerSession.Instance.silenceEventCallback((HandType)controllerId, !sleepless);
- }
- if (hxrctUpdateUserData.changed)
- {
- hxrctUpdateUserData.changed = false;
- var status = hxrctUpdateUserData.status;
- var controllerId = hxrctUpdateUserData.controllerId;
- Debug.Log($"HandleControllerSession, UpdateHandleCallback upgradeOTAEventCallback: status = {status}, controllerId = {controllerId}");
- HandleControllerSession.Instance.upgradeOTAEventCallback((HandType)controllerId, status == 0);
- }
- if (serverReconnectedUserData.changed)
- {
- serverReconnectedUserData.changed = false;
- Debug.Log($"HandleControllerSession, UpdateHandleCallback serverReconnectEventCallback: connected = {serverReconnectedUserData.connected}");
- HandleControllerSession.Instance.serverReconnectEventCallback(serverReconnectedUserData.connected);
- }
- }
-
- [MonoPInvokeCallback(typeof(ControllerBindEventCallback))]
- private static void OnControllerBindEventCallback(int value)
- {
-
- bindEventUserData.changed = true;
- bindEventUserData.status = value;
-
- }
-
- [MonoPInvokeCallback(typeof(ControllerConnectEventCallback))]
- private static void OnControllerConnectEventCallback(bool connected, int controllerId)
- {
-
- connectEventUserData.changed = true;
- connectEventUserData.connected = connected;
- connectEventUserData.controllerId = controllerId;
-
- }
-
-
-
-
- [MonoPInvokeCallback(typeof(ControllerButtonEventCallback))]
- private static void OnControllerButtonEventCallback(int keycode, int state, int controllerId)
- {
-
- buttonEventUserData.changed = true;
- buttonEventUserData.keycode = keycode;
- buttonEventUserData.state = state;
- buttonEventUserData.controllerId = controllerId;
-
- }
-
-
-
- [MonoPInvokeCallback(typeof(ControllerAxis2DEventCallback))]
- private static void OnControllerAxis2DEventCallback(int x, int y, int controllerId)
- {
-
- axis2DEventUserData.changed = true;
- axis2DEventUserData.x = x;
- axis2DEventUserData.y = y;
- axis2DEventUserData.controllerId = controllerId;
-
- }
-
-
-
-
- [MonoPInvokeCallback(typeof(ControllerAxis2DEventCallback))]
- private static void OnControllerHoldEventCallback(int keycode, bool isHeld, int controllerId)
- {
-
- holdEventUserData.changed = true;
- holdEventUserData.keycode = keycode;
- holdEventUserData.isHeld = isHeld;
- holdEventUserData.controllerId = controllerId;
-
- }
-
-
-
- [MonoPInvokeCallback(typeof(ControllerSilenceEventCallback))]
- private static void OnControllerSilenceEventCallback(bool sleepless, int controllerId)
- {
-
- silenceEventUserData.changed = true;
- silenceEventUserData.sleepless = sleepless;
- silenceEventUserData.controllerId = controllerId;
-
- }
-
-
-
- [MonoPInvokeCallback(typeof(ControllerHxrctUpdateCallback))]
- private static void OnControllerHxrctUpdateCallback(int status, int controllerId)
- {
-
- hxrctUpdateUserData.changed = true;
- hxrctUpdateUserData.status = status;
- hxrctUpdateUserData.controllerId = controllerId;
- Debug.Log($"HandleControllerSession, OnControllerHxrctUpdateCallback hxrctUpdateUserData: changed = {hxrctUpdateUserData.changed}, status = {hxrctUpdateUserData.status}, controllerId = {hxrctUpdateUserData.controllerId}");
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- [MonoPInvokeCallback(typeof(Action<bool>))]
- private static void OnControllerServerReconnectedCallback(bool connected)
- {
-
- serverReconnectedUserData.changed = true;
- serverReconnectedUserData.connected = connected;
- Debug.Log($"HandleControllerSession, OnControllerServerReconnectedCallback serverReconnectedUserData: changed = {serverReconnectedUserData.changed}, connected = {serverReconnectedUserData.connected}");
- }
- private partial struct NativeAPI
- {
- #if !UNITY_EDITOR
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern bool getControllerResultWithHead(ref HandControllerResult controllerLeftResult, ref HandControllerResult controllerRightResult, float[] headpose, int headposeSize);
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern void registerControllerTouchEvent(ControllerButtonEventCallback callback);
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern void registerControllerRockerTouchEvent(ControllerAxis2DEventCallback callback);
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern void registerControllerTouchChangeEventCallback(ControllerHoldEventCallback callback);
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern void registerControllerBondChangeCallback(ControllerBindEventCallback callback);
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern void registerControllerConnectEventCallback(ControllerConnectEventCallback callback);
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern void registerControllerSleepChangeCallback(ControllerSilenceEventCallback callback);
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern void registerControllerHxrctUpdateCallback(ControllerHxrctUpdateCallback callback);
-
-
-
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern int bondController(int controllerId);
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern int ClearBond(int controllerId);
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern int GetControllerBondState();
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern int GetControllerConnectState(int controllerId);
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern int GetControllerBattery(int controllerId);
-
-
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern int vibrateController(int controllerId, int level, int time);
-
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern void changeControllerType(int type);
-
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern int getCurrentHandType();
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern IntPtr getControllerMac(int controllerId);
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern int ControllerClient_GetVersion();
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern int ControllerClient_GetCtrlVersion(int controllerId);
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern int ControllerHxrUpgradeHost(string path);
-
- [DllImport(NativeConsts.NativeLibrary)]
- public static extern int updateHxrct(string path, int controllerId);
-
-
-
-
-
-
-
-
-
- #else
- public static bool getControllerResultWithHead(ref HandControllerResult controllerLeftResult, ref HandControllerResult controllerRightResult, float[] headpose, int headposeSize)
- {
- return false;
- }
-
- public static void registerControllerTouchEvent(ControllerButtonEventCallback callback) { }
-
- public static void registerControllerRockerTouchEvent(ControllerAxis2DEventCallback callback) { }
-
- public static void registerControllerTouchChangeEventCallback(ControllerHoldEventCallback callback) { }
-
- public static void registerControllerBondChangeCallback(ControllerBindEventCallback callback) { }
-
- public static void registerControllerConnectEventCallback(ControllerConnectEventCallback callback) { }
-
- public static void registerControllerSleepChangeCallback(ControllerSilenceEventCallback callback) { }
-
-
-
- public static int bondController(int controllerId)
- {
- return -1;
- }
-
- public static int ClearBond(int controllerId)
- {
- return -1;
- }
-
- public static int GetControllerBondState()
- {
- return -1;
- }
-
- public static int GetControllerConnectState(int controllerId)
- {
- return -1;
- }
-
- public static int GetControllerBattery(int controllerId)
- {
- return -1;
- }
-
-
-
- public static int vibrateController(int controllerId, int level, int time)
- {
- return -1;
- }
-
-
- public static void changeControllerType(int type)
- {
- }
-
-
- public static int getCurrentHandType()
- {
- return -1;
- }
-
- public static IntPtr getControllerMac(int controllerId)
- {
- return IntPtr.Zero;
- }
-
- public static int ControllerClient_GetVersion()
- {
- return -1;
- }
-
- public static int ControllerClient_GetCtrlVersion(int controllerId)
- {
- return -1;
- }
-
- public static int ControllerHxrUpgradeHost(string path)
- {
- return -1;
- }
-
- public static int updateHxrct(string path, int controllerId)
- {
- return -1;
- }
-
- public static void registerControllerHxrctUpdateCallback(ControllerHxrctUpdateCallback callback) { }
-
-
-
-
-
-
-
-
-
-
-
- #endif
- }
- }
- }
|