Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/libdof.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,24 @@ jobs:
cp build/Release/dof_static.lib tmp
cp build/Release/dof_test_s.exe tmp
cp build/Release/dof_test.exe tmp
cp build/Release/ledwiz_test.exe tmp
cp build/Release/pacled64_test.exe tmp
else
ARTIFACT_PATH="libdof-${{ needs.version.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz"
if [[ "${{ matrix.platform }}" == "macos" ]]; then
cp build/libdof.a tmp
cp -a build/*.dylib tmp
cp build/dof_test_s tmp
cp build/dof_test tmp
cp build/ledwiz_test tmp
cp build/pacled64_test tmp
elif [[ "${{ matrix.platform }}" == "linux" ]]; then
cp build/libdof.a tmp
cp -a build/*.{so,so.*} tmp
cp build/dof_test_s tmp
cp build/dof_test tmp
cp build/ledwiz_test tmp
cp build/pacled64_test tmp
elif [[ "${{ matrix.platform }}" == "ios" || "${{ matrix.platform }}" == "ios-simulator" || "${{ matrix.platform }}" == "tvos" ]]; then
cp build/libdof.a tmp
cp -a build/*.dylib tmp
Expand Down
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ libdof is a C++ port of the C# DirectOutput Framework achieving 1:1 corresponden
- **DudesCab**: hidapi HID multi-part messages
- **DMX**: UDP ArtNet broadcast port 6454
- **PinOne**: Named pipes with Base64 encoding over text
- **LedWiz**: HIDAPI 9-byte packets (SBA: `[0x00, 0x40, bank0-3, globalSpeed, 0, 0]`, PBA: 4 chunks of `[0x00, bright1-8]` with 0-49 PWM range, ZebsBoards VID 0x20A0 supported)
- **PAC Controllers**: libusb control transfers (PacLed64: individual LED intensity with 0-based numbering, PacDrive: 16-bit LED bitmask, PacUIO: via PacDriveSingleton)

### Linux Serial Port Handling (Critical)
Expand Down
72 changes: 70 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ if(BUILD_SHARED)

if(PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux")
add_executable(dof_test
src/test.cpp
src/tools/dof_test.cpp
)
target_link_libraries(dof_test PUBLIC dof_shared)

Expand Down Expand Up @@ -399,7 +399,7 @@ if(BUILD_STATIC)

if(PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux")
add_executable(dof_test_s
src/test.cpp
src/tools/dof_test.cpp
)

if(PLATFORM STREQUAL "win")
Expand Down Expand Up @@ -462,3 +462,71 @@ if(BUILD_STATIC)
endif()
endif()
endif()

if(PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux")
add_executable(ledwiz_test
src/tools/ledwiz_test.cpp
)

target_include_directories(ledwiz_test PRIVATE
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/third-party/include
)

if(PLATFORM STREQUAL "win")
target_link_directories(ledwiz_test PUBLIC
third-party/build-libs/${PLATFORM}/${ARCH}
third-party/runtime-libs/${PLATFORM}/${ARCH}
)
if(ARCH STREQUAL "x64")
target_link_libraries(ledwiz_test PUBLIC hidapi64)
else()
target_link_libraries(ledwiz_test PUBLIC hidapi)
endif()
elseif(PLATFORM STREQUAL "macos")
target_link_directories(ledwiz_test PUBLIC
third-party/runtime-libs/${PLATFORM}/${ARCH}
)
target_link_libraries(ledwiz_test PUBLIC hidapi)
elseif(PLATFORM STREQUAL "linux")
target_link_directories(ledwiz_test PUBLIC
third-party/runtime-libs/${PLATFORM}/${ARCH}
)
target_link_libraries(ledwiz_test PUBLIC hidapi-hidraw)
endif()

endif()

if(PLATFORM STREQUAL "win" OR PLATFORM STREQUAL "macos" OR PLATFORM STREQUAL "linux")
add_executable(pacled64_test
src/tools/pacled64_test.cpp
)

target_include_directories(pacled64_test PRIVATE
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/third-party/include
)

if(PLATFORM STREQUAL "win")
target_link_directories(pacled64_test PUBLIC
third-party/build-libs/${PLATFORM}/${ARCH}
third-party/runtime-libs/${PLATFORM}/${ARCH}
)
if(ARCH STREQUAL "x64")
target_link_libraries(pacled64_test PUBLIC libusb64-1.0)
else()
target_link_libraries(pacled64_test PUBLIC libusb-1.0)
endif()
elseif(PLATFORM STREQUAL "macos")
target_link_directories(pacled64_test PUBLIC
third-party/runtime-libs/${PLATFORM}/${ARCH}
)
target_link_libraries(pacled64_test PUBLIC usb-1.0)
elseif(PLATFORM STREQUAL "linux")
target_link_directories(pacled64_test PUBLIC
third-party/runtime-libs/${PLATFORM}/${ARCH}
)
target_link_libraries(pacled64_test PUBLIC usb-1.0)
endif()

endif()
2 changes: 1 addition & 1 deletion include/DOF/DOF.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#define LIBDOF_VERSION_MAJOR 0 // X Digits
#define LIBDOF_VERSION_MINOR 4 // Max 2 Digits
#define LIBDOF_VERSION_PATCH 4 // Max 2 Digits
#define LIBDOF_VERSION_PATCH 5 // Max 2 Digits

#define _LIBDOF_STR(x) #x
#define LIBDOF_STR(x) _LIBDOF_STR(x)
Expand Down
40 changes: 14 additions & 26 deletions src/cab/out/lw/LedWiz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void LedWiz::AllOff()
if (m_fp)
{
std::vector<uint8_t> buf = { 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
WriteUSB("ALL OFF", buf);
WriteUSB(buf);
}
}

Expand Down Expand Up @@ -219,49 +219,37 @@ void LedWiz::UpdateOutputs(const std::vector<uint8_t>& newOutputValues)
}
}

WriteUSB("SBA", sbaCmd);
WriteUSB(sbaCmd);

for (int startOutput = 0; startOutput < 32; startOutput += 8)
for (int ofs = 0; ofs < 32; ofs += 8)
{
std::vector<uint8_t> pbaCmd = { 0x00, static_cast<uint8_t>(0x20 + (startOutput / 8)), 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
std::vector<uint8_t> pbaCmd = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

for (int i = 0; i < 8 && (startOutput + i) < static_cast<int>(newOutputValues.size()); ++i)
for (int i = 0; i < 8; ++i)
{
pbaCmd[2 + i] = static_cast<uint8_t>((newOutputValues[startOutput + i] * 48) / 255);
int outputIndex = ofs + i;
if (outputIndex < static_cast<int>(newOutputValues.size()))
{
pbaCmd[1 + i] = static_cast<uint8_t>((newOutputValues[outputIndex] * 49) / 255);
}
}

WriteUSB(StringExtensions::Build("PBA{0}", std::to_string(startOutput / 8)), pbaCmd);
WriteUSB(pbaCmd);
}

m_oldOutputValues = newOutputValues;
}
}

bool LedWiz::WriteUSB(const std::string& desc, const std::vector<uint8_t>& data)
bool LedWiz::WriteUSB(const std::vector<uint8_t>& data)
{
if (!m_fp || data.empty())
return false;

std::vector<std::string> hexBytes;
for (uint8_t b : data)
{
char hexStr[4];
snprintf(hexStr, sizeof(hexStr), "%02X", b);
hexBytes.push_back(std::string(hexStr));
}
std::string hexString;
for (size_t i = 0; i < hexBytes.size(); ++i)
{
if (i > 0)
hexString += ", ";
hexString += hexBytes[i];
}
Log::Instrumentation("LedWiz", StringExtensions::Build("LedWiz Write {0} : {1}", desc, hexString));

int result = hid_write(m_fp, data.data(), data.size());
if (result < 0)
{
Log::Write(StringExtensions::Build("LedWiz USB write failed for {0}: {1}", desc, hid_error(m_fp) ? reinterpret_cast<const char*>(hid_error(m_fp)) : "Unknown error"));
Log::Write(StringExtensions::Build("LedWiz {0} WriteUSB failed after retries", std::to_string(m_number)));
return false;
}

Expand Down Expand Up @@ -297,7 +285,7 @@ void LedWiz::FindDevices()
}
else if (curDev->vendor_id == 0x20A0)
{
std::regex zebsPattern("(?i)zebsboards");
std::regex zebsPattern("zebsboards", std::regex::ECMAScript | std::regex::icase);
if (std::regex_search(manufacturerName, zebsPattern))
{
ok = true;
Expand Down
2 changes: 1 addition & 1 deletion src/cab/out/lw/LedWiz.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class LedWiz : public OutputControllerCompleteBase

static std::string GetDeviceProductName(hid_device_info* dev);
static std::string GetDeviceManufacturerName(hid_device_info* dev);
bool WriteUSB(const std::string& desc, const std::vector<uint8_t>& data);
bool WriteUSB(const std::vector<uint8_t>& data);

int m_number;
int m_minCommandIntervalMs;
Expand Down
File renamed without changes.
Loading