1
0
mirror of synced 2024-12-18 09:15:54 +01:00
WACVR/Assets/Script/TouchManager/TouchManager.cs
xpeng d23ae3be82 il2cpp transition (this commit is still in mono)
fix ipc touch not working under il2cpp;
fix bat wont start under il2cpp;
2022-11-08 23:43:35 +01:00

43 lines
1.2 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.IO.Ports;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
public class TouchManager : MonoBehaviour
{
public static event Action touchDidChange;
static bool useIPCTouch = true;
void Start()
{
var widget = ConfigManager.GetConfigPanelWidget("UseIPCTouch");
var toggle = widget.GetComponent<Toggle>();
toggle.onValueChanged.AddListener((value) => {
useIPCTouch = value;
});
toggle.onValueChanged.Invoke(useIPCTouch);
}
IEnumerator TouchTest(bool State) //this is a touch test code
{
for (int i = 0; i < 240; i++)
{
SetTouch(i, true);
Debug.Log(i);
yield return new WaitForSeconds(0.05f);
SetTouch(i, false);
yield return new WaitForSeconds(0.05f);
}
}
public static void SetTouch(int Area, bool State) //set touch data 1-240
{
if (useIPCTouch)
IPCManager.SetTouch(Area, State); //send touch data to IPC
else
SerialManager.SetTouch(Area, State); //send touch data to Serial
touchDidChange?.Invoke();
}
}