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;
|
2022-05-26 01:10:57 +02:00
|
|
|
using System.Threading;
|
2022-05-25 01:29:59 +02:00
|
|
|
using System.IO.Ports;
|
2022-05-16 23:38:40 +02:00
|
|
|
using System.Linq;
|
2022-05-25 01:29:59 +02:00
|
|
|
using UnityEngine;
|
2022-11-05 01:32:17 +01:00
|
|
|
using UnityEngine.UI;
|
2022-10-03 22:48:09 +02:00
|
|
|
public class TouchManager : MonoBehaviour
|
2022-05-16 23:38:40 +02:00
|
|
|
{
|
2022-11-08 23:43:35 +01: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
|
|
|
}
|
|
|
|
|
2022-05-23 23:31:33 +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)
|
2022-11-08 23:43:35 +01:00
|
|
|
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
|
|
|
}
|
2022-11-08 23:43:35 +01:00
|
|
|
}
|