make ipc config functional
This commit is contained in:
parent
99deee5ab6
commit
b4b1da9cab
@ -32532,7 +32532,6 @@ GameObject:
|
||||
- component: {fileID: 1748802425554287225}
|
||||
- component: {fileID: 1748802425554287222}
|
||||
- component: {fileID: 7308342869353410805}
|
||||
- component: {fileID: 7308342869353410806}
|
||||
m_Layer: 5
|
||||
m_Name: ConfigCanvas
|
||||
m_TagString: Untagged
|
||||
@ -34757,18 +34756,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: f0559825455822d48a37fc54c6dfd318, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &7308342869353410806
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1748802425554287228}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1f08f3c86e1b0ac4090e2ae9c18b8201, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1001 &8069494991214085012
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1,17 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ConfigBehavior : MonoBehaviour
|
||||
{
|
||||
public static ConfigBehavior instance;
|
||||
void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
public static void SaveFile()
|
||||
{
|
||||
instance.StopCoroutine(ConfigManager.SaveFileWait());
|
||||
instance.StartCoroutine(ConfigManager.SaveFileWait());
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f08f3c86e1b0ac4090e2ae9c18b8201
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -14,6 +14,9 @@ public class ConfigManager : MonoBehaviour
|
||||
private static bool hasInitialized = false;
|
||||
Config oldConfig;
|
||||
public static event Action onConfigChanged;
|
||||
private static float saverTimer = 0;
|
||||
private static bool isSavingConfig = false;
|
||||
private float saverDelay = 1.5f;
|
||||
void Awake()
|
||||
{
|
||||
onConfigChanged += EnsureInitialization;
|
||||
@ -26,10 +29,6 @@ public class ConfigManager : MonoBehaviour
|
||||
UpdateConfigPanel();
|
||||
AddListenerToWidget();
|
||||
onConfigChanged?.Invoke();
|
||||
}
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
public static void EnsureInitialization()
|
||||
{
|
||||
@ -60,16 +59,30 @@ public class ConfigManager : MonoBehaviour
|
||||
}
|
||||
public static void SaveFile()
|
||||
{
|
||||
if (ConfigBehavior.instance != null)
|
||||
ConfigBehavior.SaveFile();
|
||||
isSavingConfig = true;
|
||||
saverTimer = 0;
|
||||
Debug.Log("Saving config file");
|
||||
}
|
||||
public static IEnumerator SaveFileWait()
|
||||
public void saveFileWait()
|
||||
{
|
||||
yield return new WaitForSeconds(1.5f);
|
||||
File.WriteAllText(GetFileName(), JsonConvert.SerializeObject(config, Formatting.Indented));
|
||||
Debug.Log("Config file saved");
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (isSavingConfig)
|
||||
{
|
||||
saverTimer += Time.deltaTime;
|
||||
if (saverTimer >= saverDelay)
|
||||
{
|
||||
isSavingConfig = false;
|
||||
saverTimer = 0;
|
||||
saveFileWait();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TMP_Dropdown CaptureModeDropdown;
|
||||
private TMP_Dropdown CaptureFPSDropdown;
|
||||
private Toggle CaptureDesktopToggle;
|
||||
|
@ -9,9 +9,9 @@ public class LightManager : MonoBehaviour
|
||||
public List<GameObject> Lights = new List<GameObject>();
|
||||
List<Material> Materials = new List<Material>();
|
||||
[SerializeField]
|
||||
public bool isIPCIdle = true;
|
||||
private bool isIPCIdle = true;
|
||||
[SerializeField]
|
||||
public bool useIPCLighting = true;
|
||||
private bool useIPCLighting = true;
|
||||
static Texture2D RGBColor2D;
|
||||
|
||||
private IEnumerator[] coroutines = new IEnumerator[240];
|
||||
@ -36,7 +36,11 @@ public class LightManager : MonoBehaviour
|
||||
private void Update()
|
||||
{
|
||||
if (!useIPCLighting)
|
||||
{
|
||||
isIPCIdle = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (IPCManager.sharedBuffer != null)
|
||||
{
|
||||
GetTextureFromBytes(IPCManager.GetLightData());
|
||||
@ -80,9 +84,9 @@ public class LightManager : MonoBehaviour
|
||||
RGBColor2D.LoadRawTextureData(bytes);
|
||||
RGBColor2D.Apply();
|
||||
}
|
||||
public void UpdateLightFade(int Area, bool State)
|
||||
public void UpdateFadeLight(int Area, bool State)
|
||||
{
|
||||
if(!isIPCIdle || useIPCLighting)
|
||||
if(!isIPCIdle | useIPCLighting)
|
||||
return;
|
||||
|
||||
Area -= 1;
|
||||
|
@ -20,7 +20,7 @@ public class ColliderToTouch : MonoBehaviour
|
||||
_insideColliderCount += 1;
|
||||
TouchManager.SetTouch(Area, true);
|
||||
touchDidChange?.Invoke();
|
||||
LightManager.UpdateLightFade(Area, true);
|
||||
LightManager.UpdateFadeLight(Area, true);
|
||||
}
|
||||
|
||||
private void OnTriggerExit(Collider other)
|
||||
@ -31,7 +31,7 @@ public class ColliderToTouch : MonoBehaviour
|
||||
{
|
||||
TouchManager.SetTouch(Area, false);
|
||||
touchDidChange?.Invoke();
|
||||
LightManager.UpdateLightFade(Area, false);
|
||||
LightManager.UpdateFadeLight(Area, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,8 @@
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:476196b3fd6829e45b839eb138f356ed",
|
||||
"GUID:4b68ab8531bd5864db8bb4af74c61824"
|
||||
"GUID:4b68ab8531bd5864db8bb4af74c61824",
|
||||
"GUID:80de51a1f88203a4cb129a5922de311f"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
@ -7,7 +7,6 @@ using System.Linq;
|
||||
using UnityEngine;
|
||||
public class TouchManager : MonoBehaviour
|
||||
{
|
||||
|
||||
const byte CMD_GET_SYNC_BOARD_VER = 0xa0;
|
||||
const byte CMD_NEXT_READ = 0x72;
|
||||
const byte CMD_GET_UNIT_BOARD_VER = 0xa8;
|
||||
@ -36,10 +35,11 @@ public class TouchManager : MonoBehaviour
|
||||
byte[] SettingData_201 = new byte[3] {201, 0, 73};
|
||||
static byte[] TouchPackL = new byte[36];
|
||||
static byte[] TouchPackR = new byte[36];
|
||||
public static bool[] TouchPackAll = new bool[240];
|
||||
static bool[] TouchPackAll = new bool[240];
|
||||
bool StartUp = false;
|
||||
void Start()
|
||||
{
|
||||
ConfigManager.EnsureInitialization();
|
||||
try
|
||||
{
|
||||
ComL.Open();
|
||||
@ -49,7 +49,7 @@ public class TouchManager : MonoBehaviour
|
||||
{
|
||||
Console.WriteLine($"Failed to Open Serial Ports: {ex}");
|
||||
}
|
||||
//Debug.Log("Touch Serial Initializing..");
|
||||
Debug.Log("Touch Serial Initializing..");
|
||||
//Send touch update periodically to keep "read" alive
|
||||
_touchQueue = Queue.Synchronized(new Queue());
|
||||
_touchThread = new Thread(TouchThreadLoop);
|
||||
@ -85,8 +85,8 @@ public class TouchManager : MonoBehaviour
|
||||
ReadHead(ComL, 0);
|
||||
if (ComR.IsOpen)
|
||||
ReadHead(ComR, 1);
|
||||
if (Input.GetKeyDown(KeyCode.M)) //this is a touch test code
|
||||
StartCoroutine(TouchTest(true));
|
||||
//if (Input.GetKeyDown(KeyCode.M)) //this is a touch test code
|
||||
//StartCoroutine(TouchTest(true));
|
||||
if (Input.GetKeyDown(KeyCode.M) && StartUp)
|
||||
SendTouchState();
|
||||
}
|
||||
@ -101,6 +101,8 @@ public class TouchManager : MonoBehaviour
|
||||
// Debug.Log("Sending Right");
|
||||
SendTouch(ComR, TouchPackR);
|
||||
}
|
||||
if (ConfigManager.config.useIPCTouch)
|
||||
IPCManager.SetTouchData(TouchPackAll); //send touch data to IPC
|
||||
}
|
||||
|
||||
IEnumerator TouchTest(bool State) //this is a touch test code
|
||||
@ -223,30 +225,29 @@ public class TouchManager : MonoBehaviour
|
||||
Pack[34] = 0;
|
||||
return Pack;
|
||||
}
|
||||
void SendTouch(SerialPort Serial, byte[] Pack) //Send touch data
|
||||
void SendTouch(SerialPort Serial, byte[] Pack) //Send touch data to serial
|
||||
{
|
||||
if (StartUp)
|
||||
Serial.Write(GetTouchPack(Pack), 0, 36);
|
||||
}
|
||||
public static void SetTouch(int Area, bool State) //set touch data 0-239
|
||||
public static void SetTouch(int Area, bool State) //set touch data 1-240
|
||||
{
|
||||
Area -= 1;
|
||||
if (Area < 120)
|
||||
Area -= 1; //0-239
|
||||
if (Area < 120) //right side
|
||||
{
|
||||
TouchPackAll[Area + 120] = State;
|
||||
TouchPackAll[Area + 120] = State; //save R touch for IPC
|
||||
|
||||
Area += Area / 5 * 3 + 7;
|
||||
ByteHelper.SetBit(TouchPackR, Area, State);
|
||||
}
|
||||
else if (Area >= 120)
|
||||
else if (Area >= 120) //left side
|
||||
{
|
||||
TouchPackAll[Area - 120] = State;
|
||||
TouchPackAll[Area - 120] = State; //save L touch for IPC
|
||||
|
||||
Area -= 120;
|
||||
Area += Area / 5 * 3 + 7;
|
||||
ByteHelper.SetBit(TouchPackL, Area, State);
|
||||
}
|
||||
IPCManager.SetTouchData(TouchPackAll);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
LIBRARY mercuryio
|
||||
|
||||
EXPORTS
|
||||
mercury_io_get_api_version
|
||||
mercury_io_init
|
||||
mercury_io_poll
|
||||
mercury_io_get_opbtns
|
||||
mercury_io_get_gamebtns
|
||||
mercury_io_touch_init
|
||||
mercury_io_touch_start
|
||||
mercury_io_touch_set_leds
|
@ -1,70 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "mercuryhook/elisabeth.h"
|
||||
|
||||
enum {
|
||||
MERCURY_IO_OPBTN_TEST = 0x01,
|
||||
MERCURY_IO_OPBTN_SERVICE = 0x02,
|
||||
MERCURY_IO_OPBTN_COIN = 0x04,
|
||||
};
|
||||
|
||||
enum {
|
||||
MERCURY_IO_GAMEBTN_VOL_UP = 0x01,
|
||||
MERCURY_IO_GAMEBTN_VOL_DOWN = 0x02,
|
||||
};
|
||||
|
||||
typedef void (*mercury_io_touch_callback_t)(const bool *state);
|
||||
/* Get the version of the Wacca IO API that this DLL supports. This
|
||||
function should return a positive 16-bit integer, where the high byte is
|
||||
the major version and the low byte is the minor version (as defined by the
|
||||
Semantic Versioning standard).
|
||||
|
||||
The latest API version as of this writing is 0x0100. */
|
||||
|
||||
uint16_t mercury_io_get_api_version(void);
|
||||
|
||||
/* Initialize the IO DLL. This is the second function that will be called on
|
||||
your DLL, after mercury_io_get_api_version.
|
||||
|
||||
All subsequent calls to this API may originate from arbitrary threads.
|
||||
|
||||
Minimum API version: 0x0100 */
|
||||
|
||||
HRESULT mercury_io_init(void);
|
||||
|
||||
/* Send any queued outputs (of which there are currently none, though this may
|
||||
change in subsequent API versions) and retrieve any new inputs.
|
||||
|
||||
Minimum API version: 0x0100 */
|
||||
|
||||
HRESULT mercury_io_poll(void);
|
||||
|
||||
/* Get the state of the cabinet's operator buttons as of the last poll. See
|
||||
MERCURY_IO_OPBTN enum above: this contains bit mask definitions for button
|
||||
states returned in *opbtn. All buttons are active-high.
|
||||
|
||||
Minimum API version: 0x0100 */
|
||||
|
||||
void mercury_io_get_opbtns(uint8_t *opbtn);
|
||||
|
||||
/* Get the state of the cabinet's gameplay buttons as of the last poll. See
|
||||
MERCURY_IO_GAMEBTN enum above for bit mask definitions. Inputs are split into
|
||||
a left hand side set of inputs and a right hand side set of inputs: the bit
|
||||
mappings are the same in both cases.
|
||||
|
||||
All buttons are active-high, even though some buttons' electrical signals
|
||||
on a real cabinet are active-low.
|
||||
|
||||
Minimum API version: 0x0100 */
|
||||
|
||||
void mercury_io_get_gamebtns(uint8_t *gamebtn);
|
||||
|
||||
HRESULT mercury_io_touch_init(void);
|
||||
|
||||
void mercury_io_touch_start(mercury_io_touch_callback_t callback);
|
||||
|
||||
void mercury_io_touch_set_leds(struct led_data data);
|
Loading…
x
Reference in New Issue
Block a user