1
0
mirror of synced 2024-11-30 17:04:29 +01:00

fix not using serial touch issue

This commit is contained in:
xpeng 2023-08-22 20:01:26 +08:00
parent f422c7ad70
commit e0bccd72ea
4 changed files with 91 additions and 75 deletions

View File

@ -33,11 +33,11 @@ MonoBehaviour:
m_Name: HandTrackingFeature Android m_Name: HandTrackingFeature Android
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_enabled: 0 m_enabled: 0
nameUi: nameUi: Ultraleap Hand Tracking
version: version: 1.0.0
featureIdInternal: featureIdInternal: com.ultraleap.tracking.openxr.feature.handtracking
openxrExtensionStrings: openxrExtensionStrings: XR_EXT_hand_tracking XR_ULTRALEAP_hand_tracking_forearm
company: company: Ultraleap
priority: 0 priority: 0
required: 0 required: 0
metaPermissions: 1 metaPermissions: 1
@ -82,11 +82,11 @@ MonoBehaviour:
m_Name: RuntimeDebuggerOpenXRFeature Android m_Name: RuntimeDebuggerOpenXRFeature Android
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_enabled: 0 m_enabled: 0
nameUi: nameUi: Runtime Debugger
version: version: 1
featureIdInternal: featureIdInternal: com.unity.openxr.features.runtimedebugger
openxrExtensionStrings: openxrExtensionStrings:
company: company: Unity
priority: 0 priority: 0
required: 0 required: 0
cacheSize: 1048576 cacheSize: 1048576
@ -103,7 +103,18 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: b5a1f07dc5afe854f9f12a4194aca3fb, type: 3} m_Script: {fileID: 11500000, guid: b5a1f07dc5afe854f9f12a4194aca3fb, type: 3}
m_Name: Android m_Name: Android
m_EditorClassIdentifier: m_EditorClassIdentifier:
features: [] features:
- {fileID: -2759355098841077344}
- {fileID: 1242339343659939596}
- {fileID: -7791884441479556929}
- {fileID: 529299522121976043}
- {fileID: -2114470977307191787}
- {fileID: -2665317602316070962}
- {fileID: 1505799936249668369}
- {fileID: -1778638552271781925}
- {fileID: 7291351694695269871}
- {fileID: 7167600451737671974}
- {fileID: -5716994982038825123}
m_renderMode: 1 m_renderMode: 1
m_depthSubmissionMode: 0 m_depthSubmissionMode: 0
--- !u!114 &-4197090093912000502 --- !u!114 &-4197090093912000502
@ -181,11 +192,11 @@ MonoBehaviour:
m_Name: ConformanceAutomationFeature Android m_Name: ConformanceAutomationFeature Android
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_enabled: 0 m_enabled: 0
nameUi: nameUi: Conformance Automation
version: version: 0.0.1
featureIdInternal: featureIdInternal: com.unity.openxr.feature.conformance
openxrExtensionStrings: openxrExtensionStrings: XR_EXT_conformance_automation
company: company: Unity
priority: 0 priority: 0
required: 0 required: 0
--- !u!114 &-2665317602316070962 --- !u!114 &-2665317602316070962
@ -201,11 +212,11 @@ MonoBehaviour:
m_Name: MetaQuestTouchProControllerProfile Android m_Name: MetaQuestTouchProControllerProfile Android
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_enabled: 0 m_enabled: 0
nameUi: nameUi: Meta Quest Touch Pro Controller Profile
version: version: 0.0.1
featureIdInternal: featureIdInternal: com.unity.openxr.feature.input.metaquestpro
openxrExtensionStrings: openxrExtensionStrings: XR_FB_touch_controller_pro
company: company: Unity
priority: 0 priority: 0
required: 0 required: 0
--- !u!114 &-2114470977307191787 --- !u!114 &-2114470977307191787
@ -221,11 +232,11 @@ MonoBehaviour:
m_Name: MetaQuestFeature Android m_Name: MetaQuestFeature Android
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_enabled: 0 m_enabled: 0
nameUi: nameUi: Meta Quest Support
version: version: 1.0.0
featureIdInternal: featureIdInternal: com.unity.openxr.feature.metaquest
openxrExtensionStrings: openxrExtensionStrings: XR_OCULUS_android_initialize_loader
company: company: Unity
priority: 0 priority: 0
required: 0 required: 0
targetDevices: targetDevices:
@ -251,11 +262,11 @@ MonoBehaviour:
m_Name: MockRuntime Android m_Name: MockRuntime Android
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_enabled: 0 m_enabled: 0
nameUi: nameUi: Mock Runtime
version: version: 0.0.2
featureIdInternal: featureIdInternal: com.unity.openxr.feature.mockruntime
openxrExtensionStrings: openxrExtensionStrings: XR_UNITY_null_gfx XR_UNITY_android_present
company: company: Unity
priority: 0 priority: 0
required: 0 required: 0
ignoreValidationErrors: 0 ignoreValidationErrors: 0
@ -308,11 +319,11 @@ MonoBehaviour:
m_Name: KHRSimpleControllerProfile Android m_Name: KHRSimpleControllerProfile Android
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_enabled: 0 m_enabled: 0
nameUi: nameUi: Khronos Simple Controller Profile
version: version: 0.0.1
featureIdInternal: featureIdInternal: com.unity.openxr.feature.input.khrsimpleprofile
openxrExtensionStrings: openxrExtensionStrings:
company: company: Unity
priority: 0 priority: 0
required: 0 required: 0
--- !u!114 &587458779450762736 --- !u!114 &587458779450762736
@ -348,11 +359,11 @@ MonoBehaviour:
m_Name: EyeGazeInteraction Android m_Name: EyeGazeInteraction Android
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_enabled: 0 m_enabled: 0
nameUi: nameUi: Eye Gaze Interaction Profile
version: version: 0.0.1
featureIdInternal: featureIdInternal: com.unity.openxr.feature.input.eyetracking
openxrExtensionStrings: openxrExtensionStrings: XR_EXT_eye_gaze_interaction
company: company: Unity
priority: 0 priority: 0
required: 0 required: 0
--- !u!114 &1505799936249668369 --- !u!114 &1505799936249668369
@ -368,11 +379,11 @@ MonoBehaviour:
m_Name: MicrosoftHandInteraction Android m_Name: MicrosoftHandInteraction Android
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_enabled: 0 m_enabled: 0
nameUi: nameUi: Microsoft Hand Interaction Profile
version: version: 0.0.1
featureIdInternal: featureIdInternal: com.unity.openxr.feature.input.handtracking
openxrExtensionStrings: openxrExtensionStrings: XR_MSFT_hand_interaction
company: company: Unity
priority: 0 priority: 0
required: 0 required: 0
--- !u!114 &2249684173708023368 --- !u!114 &2249684173708023368
@ -557,11 +568,11 @@ MonoBehaviour:
m_Name: OculusTouchControllerProfile Android m_Name: OculusTouchControllerProfile Android
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_enabled: 0 m_enabled: 0
nameUi: nameUi: Oculus Touch Controller Profile
version: version: 0.0.1
featureIdInternal: featureIdInternal: com.unity.openxr.feature.input.oculustouch
openxrExtensionStrings: openxrExtensionStrings:
company: company: Unity
priority: 0 priority: 0
required: 0 required: 0
--- !u!114 &7291351694695269871 --- !u!114 &7291351694695269871
@ -577,11 +588,11 @@ MonoBehaviour:
m_Name: OculusQuestFeature Android m_Name: OculusQuestFeature Android
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_enabled: 0 m_enabled: 0
nameUi: nameUi: Oculus Quest Support
version: version: 1.0.0
featureIdInternal: featureIdInternal: com.unity.openxr.feature.oculusquest
openxrExtensionStrings: openxrExtensionStrings: XR_OCULUS_android_initialize_loader
company: company: Unity
priority: 0 priority: 0
required: 0 required: 0
targetQuest: 1 targetQuest: 1

View File

@ -24,11 +24,11 @@ public class ConfigManager : MonoBehaviour
{ {
onConfigChanged += EnsureInitialization; onConfigChanged += EnsureInitialization;
onConfigChanged += SaveFileWait; onConfigChanged += SaveFileWait;
EnsureInitialization();
} }
void Start() void Start()
{ {
EnsureInitialization();
AddListenerToWidget(ConfigPanelComponents); AddListenerToWidget(ConfigPanelComponents);
onConfigChanged?.Invoke(); onConfigChanged?.Invoke();
} }

View File

@ -93,8 +93,8 @@ public class SerialManager : MonoBehaviour
if (ComR.IsOpen) if (ComR.IsOpen)
ReadHead(ComR, 1); ReadHead(ComR, 1);
//following are touch test code //following are touch test code
//if (Input.GetKeyDown(KeyCode.M)) if (Input.GetKeyDown(KeyCode.M))
//StartCoroutine(TouchTest(true)); StartCoroutine(TouchTest(true));
//if (Input.GetKeyDown(KeyCode.M) && StartUp) //if (Input.GetKeyDown(KeyCode.M) && StartUp)
//SendTouchState(); //SendTouchState();
} }
@ -117,9 +117,12 @@ public class SerialManager : MonoBehaviour
{ {
SetTouch(i, true); SetTouch(i, true);
Debug.Log(i); Debug.Log(i);
yield return new WaitForSeconds(0.05f); PingTouchThread();
yield return new WaitForSeconds(0.03f);
SetTouch(i, false); SetTouch(i, false);
yield return new WaitForSeconds(0.05f); PingTouchThread();
yield return new WaitForSeconds(0.03f);
} }
} }
@ -145,34 +148,34 @@ public class SerialManager : MonoBehaviour
byte syncCheckSum = (byte)44; byte syncCheckSum = (byte)44;
syncbytes.Add(syncCheckSum); syncbytes.Add(syncCheckSum);
Serial.Write(syncbytes.ToArray(), 0, syncbytes.Count); Serial.Write(syncbytes.ToArray(), 0, syncbytes.Count);
//Debug.Log($"GET SYNC BOARD VER {side}"); Debug.Log($"GET SYNC BOARD VER {side}");
break; break;
case CMD_NEXT_READ: case CMD_NEXT_READ:
//Response: corresponding read bytes + checksum //Response: corresponding read bytes + checksum
StartUp = false; StartUp = false;
//Debug.Log($"Side {side} NEXT READ {Convert.ToByte(data[2])}"); Debug.Log($"Side {side} NEXT READ {Convert.ToByte(data[2])}");
switch (Convert.ToByte(data[2])) switch (Convert.ToByte(data[2]))
{ {
case 0x30: case 0x30:
var bytes = ByteHelper.ConvertStringToByteArray(read1); var bytes = ByteHelper.ConvertStringToByteArray(read1);
bytes.Add(ByteHelper.CalCheckSum(bytes.ToArray(), bytes.Count)); bytes.Add(ByteHelper.CalCheckSum(bytes.ToArray(), bytes.Count));
//Debug.Log("Read 1"); Debug.Log("Read 1");
Serial.Write(bytes.ToArray(), 0, bytes.Count); Serial.Write(bytes.ToArray(), 0, bytes.Count);
break; break;
case 0x31: case 0x31:
var bytes2 = ByteHelper.ConvertStringToByteArray(read2); var bytes2 = ByteHelper.ConvertStringToByteArray(read2);
bytes2.Add(ByteHelper.CalCheckSum(bytes2.ToArray(), bytes2.Count)); bytes2.Add(ByteHelper.CalCheckSum(bytes2.ToArray(), bytes2.Count));
//Debug.Log("Read 2"); Debug.Log("Read 2");
Serial.Write(bytes2.ToArray(), 0, bytes2.Count); Serial.Write(bytes2.ToArray(), 0, bytes2.Count);
break; break;
case 0x33: case 0x33:
var bytes3 = ByteHelper.ConvertStringToByteArray(read3); var bytes3 = ByteHelper.ConvertStringToByteArray(read3);
bytes3.Add(ByteHelper.CalCheckSum(bytes3.ToArray(), bytes3.Count)); bytes3.Add(ByteHelper.CalCheckSum(bytes3.ToArray(), bytes3.Count));
//Debug.Log("Read 3"); Debug.Log("Read 3");
Serial.Write(bytes3.ToArray(), 0, bytes3.Count); Serial.Write(bytes3.ToArray(), 0, bytes3.Count);
break; break;
default: default:
//Debug.Log("Extra Read"); Debug.Log("Extra Read");
break; break;
} }
break; break;
@ -189,34 +192,34 @@ public class SerialManager : MonoBehaviour
unitBytes.AddRange(ByteHelper.ConvertStringToByteArray(UNIT_BOARD_VER)); unitBytes.AddRange(ByteHelper.ConvertStringToByteArray(UNIT_BOARD_VER));
unitBytes.Add(unitCheckSum); unitBytes.Add(unitCheckSum);
Serial.Write(unitBytes.ToArray(), 0, unitBytes.Count); Serial.Write(unitBytes.ToArray(), 0, unitBytes.Count);
//Debug.Log($"GET UNIT BOARD VER {side}"); Debug.Log($"GET UNIT BOARD VER {side}");
break; break;
case CMD_MYSTERY1: case CMD_MYSTERY1:
StartUp = false; StartUp = false;
Serial.Write(SettingData_162, 0, 3); Serial.Write(SettingData_162, 0, 3);
//Debug.Log($"MYSTERY 1 SIDE {side}"); Debug.Log($"MYSTERY 1 SIDE {side}");
break; break;
case CMD_MYSTERY2: case CMD_MYSTERY2:
StartUp = false; StartUp = false;
Serial.Write(SettingData_148, 0, 3); Serial.Write(SettingData_148, 0, 3);
//Debug.Log($"MYSTERY 2 SIDE {side}"); Debug.Log($"MYSTERY 2 SIDE {side}");
break; break;
case CMD_START_AUTO_SCAN: case CMD_START_AUTO_SCAN:
Serial.Write(SettingData_201.ToArray(), 0, 3); Serial.Write(SettingData_201.ToArray(), 0, 3);
//Debug.Log($"START AUTO SCAN SIDE {side}"); Debug.Log($"START AUTO SCAN SIDE {side}");
StartUp = true; StartUp = true;
if (!_touchThread.IsAlive) if (!_touchThread.IsAlive)
_touchThread.Start(); _touchThread.Start();
break; break;
case CMD_BEGIN_WRITE: case CMD_BEGIN_WRITE:
// Debug.Log($"Begin Write For Side {side}"); Debug.Log($"Begin Write For Side {side}");
break; break;
case CMD_NEXT_WRITE: case CMD_NEXT_WRITE:
// Debug.Log($"Continue Write For Side {side}"); Debug.Log($"Continue Write For Side {side}");
break; break;
case 154: case 154:
StartUp = false; StartUp = false;
//Debug.Log("BAD"); Debug.Log("BAD");
break; break;
} }
} }
@ -241,13 +244,13 @@ public class SerialManager : MonoBehaviour
Area -= 1; //0-239 Area -= 1; //0-239
if (Area < 120) //right side if (Area < 120) //right side
{ {
Area += Area / 5 * 3 + 7; Area += Area / 5 * 3 + 8;
ByteHelper.SetBit(TouchPackR, Area, State); ByteHelper.SetBit(TouchPackR, Area, State);
} }
else if (Area >= 120) //left side else if (Area >= 120) //left side
{ {
Area -= 120; Area -= 120;
Area += Area / 5 * 3 + 7; Area += Area / 5 * 3 + 8;
ByteHelper.SetBit(TouchPackL, Area, State); ByteHelper.SetBit(TouchPackL, Area, State);
} }
} }

View File

@ -16,8 +16,9 @@ public class TouchManager : MonoBehaviour
var toggle = widget.GetComponent<Toggle>(); var toggle = widget.GetComponent<Toggle>();
toggle.onValueChanged.AddListener((value) => { toggle.onValueChanged.AddListener((value) => {
useIPCTouch = value; useIPCTouch = value;
Debug.Log("UseIPCTouch: " + value);
}); });
toggle.onValueChanged.Invoke(useIPCTouch); toggle.onValueChanged.Invoke(toggle.isOn);
} }
IEnumerator TouchTest(bool State) //this is a touch test code IEnumerator TouchTest(bool State) //this is a touch test code
@ -33,6 +34,7 @@ public class TouchManager : MonoBehaviour
} }
public static void SetTouch(int Area, bool State) //set touch data 1-240 public static void SetTouch(int Area, bool State) //set touch data 1-240
{ {
Debug.Log("SetTouch: " + Area + " " + State + " " + useIPCTouch);
if (useIPCTouch) if (useIPCTouch)
IPCManager.SetTouch(Area, State); //send touch data to IPC IPCManager.SetTouch(Area, State); //send touch data to IPC
else else