diff --git a/Unreal/Content/Project/BP/BP_SerialCom_v4_UE510_SPIE.uasset b/Unreal/Content/Project/BP/BP_SerialCom_v4_UE510_SPIE.uasset new file mode 100644 index 0000000..05948dc --- /dev/null +++ b/Unreal/Content/Project/BP/BP_SerialCom_v4_UE510_SPIE.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a79f564666a3451d7aeebb1eda05184616a687e54b94b0974f3d9158ba1fd268 +size 233888 diff --git a/Unreal/Content/SPIE/BP/BP_SPIE_Manager_Child.uasset b/Unreal/Content/SPIE/BP/BP_SPIE_Manager_Child.uasset index 25f512f..bab7eaa 100644 --- a/Unreal/Content/SPIE/BP/BP_SPIE_Manager_Child.uasset +++ b/Unreal/Content/SPIE/BP/BP_SPIE_Manager_Child.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:2e80f550415b8b1f1799bd1dbcc77376239be79796ccf0aad20b800d91120e51 -size 758775 +oid sha256:fdf6f0356069b9be5803e781f2d333f6fa6cacc08ffca5304b72277857188f5f +size 758427 diff --git a/Unreal/Content/SPIE/Maps/M_SPIE_Startup.umap b/Unreal/Content/SPIE/Maps/M_SPIE_Startup.umap index 1b8a567..d696239 100644 --- a/Unreal/Content/SPIE/Maps/M_SPIE_Startup.umap +++ b/Unreal/Content/SPIE/Maps/M_SPIE_Startup.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b0ff162767bd091f655d038a36ed3c5941b73d688b814ec3dc03cd2d2fc4b6f6 -size 174928 +oid sha256:52011c4a223bdc4a96fac9bbe4bd3a5e910b4660e959a01470c977273c5b7714 +size 177725 diff --git a/Unreal/Content/SPIE/Widgets/WBP_Spie_MicrophoneButton.uasset b/Unreal/Content/SPIE/Widgets/WBP_Spie_MicrophoneButton.uasset index 6ed02e2..3649f38 100644 --- a/Unreal/Content/SPIE/Widgets/WBP_Spie_MicrophoneButton.uasset +++ b/Unreal/Content/SPIE/Widgets/WBP_Spie_MicrophoneButton.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:7bc1175d3fcc1e5ddfea0eea926ec374724161a850ea4b670e616c4bf075ccce -size 384261 +oid sha256:12e1d7bcc1e4f20cf16f6cb9e09dc5a2484165bce343fc84cbbd33421ae36d01 +size 414491 diff --git a/Unreal/Content/Schema/Spie_Config.schema.json b/Unreal/Content/Schema/Spie_Config.schema.json index 7644e0c..6969e2a 100644 --- a/Unreal/Content/Schema/Spie_Config.schema.json +++ b/Unreal/Content/Schema/Spie_Config.schema.json @@ -21,6 +21,14 @@ "category": "SPIE Management Board" } }, + { + "ButtonSerialPort": + { + "type": "integer", + "default": 3, + "category": "SPIE Management Board" + } + }, { "AvatarInstance": { @@ -70,7 +78,7 @@ "SpieRecordButtonScale": { "type": "float", - "default": 1, + "default": 0.84999999999999998, "category": "Spie_ONE_VisualSetup" } }, @@ -101,7 +109,7 @@ "MicrofonMaxInputLevel": { "type": "float", - "default": 0.02, + "default": 0.050000000000000003, "category": "Spie_ONE_VisualSetup" } }, diff --git a/Unreal/Plugins/SerialCOM/Content/UE_BLUEPRINTS/BP_SerialCom_v4_UE510.uasset b/Unreal/Plugins/SerialCOM/Content/UE_BLUEPRINTS/BP_SerialCom_v4_UE510.uasset index 0706808..8880133 100644 --- a/Unreal/Plugins/SerialCOM/Content/UE_BLUEPRINTS/BP_SerialCom_v4_UE510.uasset +++ b/Unreal/Plugins/SerialCOM/Content/UE_BLUEPRINTS/BP_SerialCom_v4_UE510.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4c06bac00b9b5a4083503d2f88b8b37c91e9492de02a6bdc51c073b0640ff619 -size 209148 +oid sha256:63f4d65b71405e426b460ae0f6486fc03de943eec55a83743ad5136745737d06 +size 195216 diff --git a/Unreal/Plugins/SerialCOM/Content/UE_BLUEPRINTS/BP_SerialCom_v4_UE510_WithKeys.uasset b/Unreal/Plugins/SerialCOM/Content/UE_BLUEPRINTS/BP_SerialCom_v4_UE510_WithKeys.uasset new file mode 100644 index 0000000..bd3f152 --- /dev/null +++ b/Unreal/Plugins/SerialCOM/Content/UE_BLUEPRINTS/BP_SerialCom_v4_UE510_WithKeys.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:905f46425b2ee064cd939d362dd97d02ea97f236f12ff573ecdb32241bba9b31 +size 113183 diff --git a/Unreal/Source/SPIE_Avatar/SerialPortLibrary.cpp b/Unreal/Source/SPIE_Avatar/SerialPortLibrary.cpp new file mode 100644 index 0000000..f79b069 --- /dev/null +++ b/Unreal/Source/SPIE_Avatar/SerialPortLibrary.cpp @@ -0,0 +1,96 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "SerialPortLibrary.h" + +#if PLATFORM_WINDOWS +#include "Windows/AllowWindowsPlatformTypes.h" +#include +#include +#include "Windows/HideWindowsPlatformTypes.h" + +#pragma comment(lib, "setupapi.lib") +#endif + +TArray USerialPortLibrary::GetAvailableSerialPorts() +{ + TArray Ports; + +#if PLATFORM_WINDOWS + // Query registry for all COM ports + HKEY hKey; + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("HARDWARE\\DEVICEMAP\\SERIALCOMM"), + 0, KEY_READ, &hKey) == ERROR_SUCCESS) + { + DWORD Index = 0; + TCHAR ValueName[256]; + TCHAR ValueData[256]; + DWORD ValueNameSize = 256; + DWORD ValueDataSize = 256 * sizeof(TCHAR); + DWORD Type; + + while (RegEnumValue(hKey, Index++, ValueName, &ValueNameSize, + nullptr, &Type, (LPBYTE)ValueData, &ValueDataSize) == ERROR_SUCCESS) + { + Ports.Add(FString(ValueData)); + ValueNameSize = 256; + ValueDataSize = 256 * sizeof(TCHAR); + } + RegCloseKey(hKey); + } +#endif + + return Ports; +} + +TArray USerialPortLibrary::GetAvailableSerialPortsWithNames() +{ + TArray Ports; + +#if PLATFORM_WINDOWS + // Use SetupAPI to get port + friendly device name + HDEVINFO DeviceInfoSet = SetupDiGetClassDevs( + nullptr, TEXT("USB"), nullptr, + DIGCF_PRESENT | DIGCF_ALLCLASSES + ); + + if (DeviceInfoSet == INVALID_HANDLE_VALUE) + return Ports; + + SP_DEVINFO_DATA DeviceInfoData; + DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + + for (DWORD i = 0; SetupDiEnumDeviceInfo(DeviceInfoSet, i, &DeviceInfoData); i++) + { + TCHAR FriendlyName[256] = {}; + TCHAR PortName[256] = {}; + + // Get friendly name (e.g. "Arduino Uno (COM3)") + SetupDiGetDeviceRegistryProperty(DeviceInfoSet, &DeviceInfoData, + SPDRP_FRIENDLYNAME, nullptr, (PBYTE)FriendlyName, sizeof(FriendlyName), nullptr); + + // Get COM port from device registry key + HKEY DevKey = SetupDiOpenDevRegKey(DeviceInfoSet, &DeviceInfoData, + DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_READ); + + if (DevKey != INVALID_HANDLE_VALUE) + { + DWORD PortNameSize = sizeof(PortName); + RegQueryValueEx(DevKey, TEXT("PortName"), nullptr, + nullptr, (LPBYTE)PortName, &PortNameSize); + RegCloseKey(DevKey); + + if (wcslen(PortName) > 0 && wcslen(FriendlyName) > 0) + { + // Format: "COM3|Arduino Uno (COM3)" + FString Entry = FString::Printf(TEXT("%s|%s"), PortName, FriendlyName); + Ports.Add(Entry); + } + } + } + + SetupDiDestroyDeviceInfoList(DeviceInfoSet); +#endif + + return Ports; +} \ No newline at end of file diff --git a/Unreal/Source/SPIE_Avatar/SerialPortLibrary.h b/Unreal/Source/SPIE_Avatar/SerialPortLibrary.h new file mode 100644 index 0000000..e446039 --- /dev/null +++ b/Unreal/Source/SPIE_Avatar/SerialPortLibrary.h @@ -0,0 +1,15 @@ +#pragma once +#include "CoreMinimal.h" +#include "Kismet/BlueprintFunctionLibrary.h" +#include "SerialPortLibrary.generated.h" + +UCLASS() +class SPIE_AVATAR_API USerialPortLibrary : public UBlueprintFunctionLibrary +{ + GENERATED_BODY() +public: + UFUNCTION(BlueprintPure, Category = "Serial Port") + static TArray GetAvailableSerialPorts(); + UFUNCTION(BlueprintPure, Category = "Serial Port") + static TArray GetAvailableSerialPortsWithNames(); +};