1
0
mirror of synced 2024-12-19 09:45:54 +01:00
WACVR/Assets/Script/TouchManager/TouchManager.cs

43 lines
1.2 KiB
C#
Raw Normal View History

2022-05-16 23:38:40 +02:00
using System;
2022-05-22 06:32:20 +02:00
using System.Collections;
2022-05-16 23:38:40 +02:00
using System.Collections.Generic;
using System.Threading;
using System.IO.Ports;
2022-05-16 23:38:40 +02:00
using System.Linq;
using UnityEngine;
2022-11-05 01:32:17 +01:00
using UnityEngine.UI;
public class TouchManager : MonoBehaviour
2022-05-16 23:38:40 +02:00
{
public static event Action touchDidChange;
2022-11-05 01:32:17 +01:00
static bool useIPCTouch = true;
2022-05-16 23:38:40 +02:00
void Start()
{
2022-11-05 01:32:17 +01:00
var widget = ConfigManager.GetConfigPanelWidget("UseIPCTouch");
var toggle = widget.GetComponent<Toggle>();
toggle.onValueChanged.AddListener((value) => {
useIPCTouch = value;
});
toggle.onValueChanged.Invoke(useIPCTouch);
2022-05-16 23:38:40 +02:00
}
IEnumerator TouchTest(bool State) //this is a touch test code
2022-05-16 23:38:40 +02:00
{
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);
}
}
2022-10-05 22:47:49 +02:00
public static void SetTouch(int Area, bool State) //set touch data 1-240
2022-05-16 23:38:40 +02:00
{
2022-11-05 01:32:17 +01:00
if (useIPCTouch)
IPCManager.SetTouch(Area, State); //send touch data to IPC
else
SerialManager.SetTouch(Area, State); //send touch data to Serial
touchDidChange?.Invoke();
2022-05-22 06:32:20 +02:00
}
}