Compare commits
5 Commits
v1.1.0
...
aea9c334e0
| Author | SHA1 | Date | |
|---|---|---|---|
|
aea9c334e0
|
|||
|
e53cddb030
|
|||
|
8832ba2227
|
|||
|
7bd6993b59
|
|||
|
8717f425f4
|
@@ -34,49 +34,7 @@ endif ()
|
|||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/liberty/cmake)
|
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/liberty/cmake)
|
||||||
|
include (IconUtils)
|
||||||
# TODO(p): Shove this into IconUtils.cmake.
|
|
||||||
function (icon_to_iconset_size name svg size iconset outputs)
|
|
||||||
math (EXPR _size2x "${size} * 2")
|
|
||||||
set (_dimensions "${size}x${size}")
|
|
||||||
set (_png1x "${iconset}/icon_${_dimensions}.png")
|
|
||||||
set (_png2x "${iconset}/icon_${_dimensions}@2x.png")
|
|
||||||
set (${outputs} "${_png1x};${_png2x}" PARENT_SCOPE)
|
|
||||||
|
|
||||||
set (_find_program_REQUIRE)
|
|
||||||
if (NOT ${CMAKE_VERSION} VERSION_LESS 3.18.0)
|
|
||||||
set (_find_program_REQUIRE REQUIRED)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
find_program (rsvg_convert_EXECUTABLE rsvg-convert ${_find_program_REQUIRE})
|
|
||||||
add_custom_command (OUTPUT "${_png1x}" "${_png2x}"
|
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory "${iconset}"
|
|
||||||
COMMAND ${rsvg_convert_EXECUTABLE} "--output=${_png1x}"
|
|
||||||
"--width=${size}" "--height=${size}" -- "${svg}"
|
|
||||||
COMMAND ${rsvg_convert_EXECUTABLE} "--output=${_png2x}"
|
|
||||||
"--width=${_size2x}" "--height=${_size2x}" -- "${svg}"
|
|
||||||
DEPENDS "${svg}"
|
|
||||||
COMMENT "Generating ${name} ${_dimensions} icons" VERBATIM)
|
|
||||||
endfunction ()
|
|
||||||
function (icon_to_icns svg output_basename output)
|
|
||||||
get_filename_component (_name "${output_basename}" NAME_WE)
|
|
||||||
set (_iconset "${PROJECT_BINARY_DIR}/${_name}.iconset")
|
|
||||||
set (_icon "${PROJECT_BINARY_DIR}/${output_basename}")
|
|
||||||
set (${output} "${_icon}" PARENT_SCOPE)
|
|
||||||
|
|
||||||
set (_icon_png_list)
|
|
||||||
foreach (_icon_size 16 32 128 256 512)
|
|
||||||
icon_to_iconset_size ("${_name}" "${svg}"
|
|
||||||
"${_icon_size}" "${_iconset}" _icon_pngs)
|
|
||||||
list (APPEND _icon_png_list ${_icon_pngs})
|
|
||||||
endforeach ()
|
|
||||||
add_custom_command (OUTPUT "${_icon}"
|
|
||||||
COMMAND iconutil -c icns -o "${_icon}" "${_iconset}"
|
|
||||||
DEPENDS ${_icon_png_list}
|
|
||||||
COMMENT "Generating ${_name} icon" VERBATIM)
|
|
||||||
set_source_files_properties ("${_icon}" PROPERTIES
|
|
||||||
MACOSX_PACKAGE_LOCATION Resources)
|
|
||||||
endfunction ()
|
|
||||||
|
|
||||||
find_package (PkgConfig REQUIRED)
|
find_package (PkgConfig REQUIRED)
|
||||||
pkg_check_modules (libusb libusb-1.0)
|
pkg_check_modules (libusb libusb-1.0)
|
||||||
@@ -138,7 +96,6 @@ endif ()
|
|||||||
if (WITH_HIDAPI AND WIN32)
|
if (WITH_HIDAPI AND WIN32)
|
||||||
list (APPEND targets_gui eizoctltray)
|
list (APPEND targets_gui eizoctltray)
|
||||||
|
|
||||||
include (IconUtils)
|
|
||||||
set (icon_png_list)
|
set (icon_png_list)
|
||||||
foreach (icon_size 16 32 48)
|
foreach (icon_size 16 32 48)
|
||||||
icon_to_png (eizoctltray ${PROJECT_SOURCE_DIR}/eizoctltray.svg
|
icon_to_png (eizoctltray ${PROJECT_SOURCE_DIR}/eizoctltray.svg
|
||||||
@@ -181,25 +138,34 @@ endif ()
|
|||||||
|
|
||||||
# Generate documentation from help output
|
# Generate documentation from help output
|
||||||
if (NOT WIN32 AND NOT CMAKE_CROSSCOMPILING)
|
if (NOT WIN32 AND NOT CMAKE_CROSSCOMPILING)
|
||||||
find_program (HELP2MAN_EXECUTABLE help2man)
|
set (HELP2ADOC "${PROJECT_SOURCE_DIR}/liberty/tools/help2adoc.awk")
|
||||||
if (NOT HELP2MAN_EXECUTABLE)
|
set (ASCIIMAN "${PROJECT_SOURCE_DIR}/liberty/tools/asciiman.awk")
|
||||||
message (FATAL_ERROR "help2man not found")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
foreach (target ${targets})
|
foreach (target ${targets})
|
||||||
set (page_output "${PROJECT_BINARY_DIR}/${target}.1")
|
set (page_adoc "${PROJECT_BINARY_DIR}/${target}.1.adoc")
|
||||||
list (APPEND project_MAN_PAGES "${page_output}")
|
set (page_roff "${PROJECT_BINARY_DIR}/${target}.1")
|
||||||
add_custom_command (OUTPUT ${page_output}
|
list (APPEND project_MAN_PAGES "${page_roff}")
|
||||||
COMMAND ${HELP2MAN_EXECUTABLE} -N
|
|
||||||
"${PROJECT_BINARY_DIR}/${target}" -o ${page_output}
|
# $<TARGET_FILE:tgt> could be used, if we didn't have to escape it.
|
||||||
DEPENDS ${target}
|
string (REPLACE "\\" "\\\\"
|
||||||
COMMENT "Generating man page for ${target}" VERBATIM)
|
target_path "${PROJECT_BINARY_DIR}/${target}")
|
||||||
|
add_custom_command (OUTPUT "${page_adoc}"
|
||||||
|
COMMAND env LC_ALL=C awk -f "${HELP2ADOC}"
|
||||||
|
-v "Target=${target_path}" > "${page_adoc}"
|
||||||
|
DEPENDS "${target}" "${HELP2ADOC}"
|
||||||
|
COMMENT "Generating AsciiDoc man page for ${target}" VERBATIM)
|
||||||
|
add_custom_command (OUTPUT "${page_roff}"
|
||||||
|
COMMAND env LC_ALL=C awk -f "${ASCIIMAN}"
|
||||||
|
"${page_adoc}" > "${page_roff}"
|
||||||
|
DEPENDS "${page_adoc}" "${ASCIIMAN}"
|
||||||
|
COMMENT "Generating roff man page for ${target}" VERBATIM)
|
||||||
endforeach ()
|
endforeach ()
|
||||||
|
|
||||||
add_custom_target (docs ALL DEPENDS ${project_MAN_PAGES})
|
add_custom_target (docs ALL DEPENDS ${project_MAN_PAGES})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
# The files to be installed
|
# The files to be installed
|
||||||
|
if (NOT WIN32)
|
||||||
include (GNUInstallDirs)
|
include (GNUInstallDirs)
|
||||||
|
|
||||||
# These should be accessible by users, but need to touch system devices.
|
# These should be accessible by users, but need to touch system devices.
|
||||||
@@ -213,13 +179,17 @@ install (TARGETS ${targets} DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|||||||
${SETUID})
|
${SETUID})
|
||||||
install (TARGETS ${targets_gui} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install (TARGETS ${targets_gui} DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||||
|
|
||||||
foreach (page ${project_MAN_PAGES})
|
foreach (page ${project_MAN_PAGES})
|
||||||
string (REGEX MATCH "\\.([0-9])$" manpage_suffix "${page}")
|
string (REGEX MATCH "\\.([0-9])$" manpage_suffix "${page}")
|
||||||
install (FILES "${page}"
|
install (FILES "${page}"
|
||||||
DESTINATION "${CMAKE_INSTALL_MANDIR}/man${CMAKE_MATCH_1}")
|
DESTINATION "${CMAKE_INSTALL_MANDIR}/man${CMAKE_MATCH_1}")
|
||||||
endforeach ()
|
endforeach ()
|
||||||
|
|
||||||
|
set (CPACK_SET_DESTDIR TRUE)
|
||||||
|
else ()
|
||||||
|
install (TARGETS ${targets} ${targets_gui} DESTINATION .)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# CPack
|
# CPack
|
||||||
set (CPACK_PACKAGE_VENDOR "Premysl Eric Janouch")
|
set (CPACK_PACKAGE_VENDOR "Premysl Eric Janouch")
|
||||||
set (CPACK_PACKAGE_CONTACT "Přemysl Eric Janouch <p@janouch.name>")
|
set (CPACK_PACKAGE_CONTACT "Přemysl Eric Janouch <p@janouch.name>")
|
||||||
@@ -232,5 +202,4 @@ set (CPACK_SOURCE_GENERATOR "TGZ;ZIP")
|
|||||||
set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git;/build;/CMakeLists.txt.user")
|
set (CPACK_SOURCE_IGNORE_FILES "/\\\\.git;/build;/CMakeLists.txt.user")
|
||||||
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}")
|
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${PROJECT_VERSION}")
|
||||||
|
|
||||||
set (CPACK_SET_DESTDIR TRUE)
|
|
||||||
include (CPack)
|
include (CPack)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ https://git.janouch.name/p/usb-drivers/releases[the Releases page on Gitea].
|
|||||||
Building
|
Building
|
||||||
--------
|
--------
|
||||||
Build dependencies:
|
Build dependencies:
|
||||||
CMake, pkg-config, liberty (included), help2man +
|
CMake, pkg-config, liberty (included) +
|
||||||
Runtime dependencies:
|
Runtime dependencies:
|
||||||
libusb-1.0 (elksmart-comm, razer-bw-te-ctl), hidapi >= 0.14 (eizoctl)
|
libusb-1.0 (elksmart-comm, razer-bw-te-ctl), hidapi >= 0.14 (eizoctl)
|
||||||
|
|
||||||
|
|||||||
@@ -73,10 +73,17 @@ var (
|
|||||||
fmtIn, fmtOut, fmtReset string
|
fmtIn, fmtOut, fmtReset string
|
||||||
)
|
)
|
||||||
|
|
||||||
func decodeSubreport(data []byte) string {
|
func decodeSubreport(id byte, data []byte) string {
|
||||||
if len(data) < 6 {
|
critical := isCriticalSubreport(id)
|
||||||
|
if len(data) < 6 || critical && len(data) < 8 {
|
||||||
return fmt.Sprintf("%x", data)
|
return fmt.Sprintf("%x", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var cs uint16
|
||||||
|
if critical {
|
||||||
|
data, cs = data[2:], le.Uint16(data[0:2])
|
||||||
|
}
|
||||||
|
|
||||||
usage := uint32(le.Uint16(data[:2]))<<16 | uint32(le.Uint16(data[2:4]))
|
usage := uint32(le.Uint16(data[:2]))<<16 | uint32(le.Uint16(data[2:4]))
|
||||||
filtered := make([]byte, len(data)-6)
|
filtered := make([]byte, len(data)-6)
|
||||||
for i, b := range data[6:] {
|
for i, b := range data[6:] {
|
||||||
@@ -86,8 +93,17 @@ func decodeSubreport(data []byte) string {
|
|||||||
filtered[i] = b
|
filtered[i] = b
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("<> %08x %04x %x %s", usage, le.Uint16(data[4:6]),
|
if critical {
|
||||||
data[6:], string(filtered))
|
return fmt.Sprintf("<> %08x %04x=%04x %x %s",
|
||||||
|
usage, cs, le.Uint16(data[4:6]), data[6:], string(filtered))
|
||||||
|
} else if usage == 0xff0000f1 {
|
||||||
|
// No idea what this is, but it follows the format.
|
||||||
|
return fmt.Sprintf("<> %08x %04x %s",
|
||||||
|
usage, le.Uint16(data[4:6]), decodeMP(data[6:]))
|
||||||
|
} else {
|
||||||
|
return fmt.Sprintf("<> %08x %04x %x %s",
|
||||||
|
usage, le.Uint16(data[4:6]), data[6:], string(filtered))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeResult(data []byte) string {
|
func decodeResult(data []byte) string {
|
||||||
@@ -131,6 +147,14 @@ func isGetSubreport(id byte) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isCriticalSubreport(id byte) bool {
|
||||||
|
switch id {
|
||||||
|
case 11, 12, 13, 14:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func isSubreport(id byte) bool {
|
func isSubreport(id byte) bool {
|
||||||
return isSetSubreport(id) || isGetSubreport(id)
|
return isSetSubreport(id) || isGetSubreport(id)
|
||||||
}
|
}
|
||||||
@@ -143,7 +167,7 @@ func processInterrupt(p *Packet) {
|
|||||||
if *raw {
|
if *raw {
|
||||||
fmt.Printf("%s INT %02x %x\n", p.addr(), data[0], data[1:])
|
fmt.Printf("%s INT %02x %x\n", p.addr(), data[0], data[1:])
|
||||||
} else if isSubreport(data[0]) {
|
} else if isSubreport(data[0]) {
|
||||||
fmt.Printf("%s INT %s\n", p.addr(), decodeSubreport(data[1:]))
|
fmt.Printf("%s INT %s\n", p.addr(), decodeSubreport(data[0], data[1:]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +187,7 @@ func processControl(p *Packet) {
|
|||||||
fmt.Printf("%s IN SR %x\n", p.addr(), data[5:])
|
fmt.Printf("%s IN SR %x\n", p.addr(), data[5:])
|
||||||
} else if isGetSubreport(data[0]) {
|
} else if isGetSubreport(data[0]) {
|
||||||
fmt.Printf("%s IN %s%s%s\n", p.addr(),
|
fmt.Printf("%s IN %s%s%s\n", p.addr(),
|
||||||
fmtIn, decodeSubreport(data[1:]), fmtReset)
|
fmtIn, decodeSubreport(data[0], data[1:]), fmtReset)
|
||||||
} else if data[0] == 6 {
|
} else if data[0] == 6 {
|
||||||
fmt.Printf("%s IN PC %04x\n", p.addr(), le.Uint16(data[1:]))
|
fmt.Printf("%s IN PC %04x\n", p.addr(), le.Uint16(data[1:]))
|
||||||
} else if data[0] == 7 {
|
} else if data[0] == 7 {
|
||||||
@@ -172,6 +196,8 @@ func processControl(p *Packet) {
|
|||||||
fmt.Printf("%s IN ID %s %s\n", p.addr(), data[1:9], data[9:])
|
fmt.Printf("%s IN ID %s %s\n", p.addr(), data[1:9], data[9:])
|
||||||
} else if data[0] == 9 {
|
} else if data[0] == 9 {
|
||||||
fmt.Printf("%s IN MP %s\n", p.addr(), decodeMP(data[1:]))
|
fmt.Printf("%s IN MP %s\n", p.addr(), decodeMP(data[1:]))
|
||||||
|
} else if data[0] == 10 {
|
||||||
|
fmt.Printf("%s IN CS %04x\n", p.addr(), le.Uint16(data[1:]))
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("%s IN %02x %x\n", p.addr(), data[0], data[1:])
|
fmt.Printf("%s IN %02x %x\n", p.addr(), data[0], data[1:])
|
||||||
}
|
}
|
||||||
@@ -180,7 +206,9 @@ func processControl(p *Packet) {
|
|||||||
fmt.Printf("%s OUT %02x %x\n", p.addr(), data[0], data[1:])
|
fmt.Printf("%s OUT %02x %x\n", p.addr(), data[0], data[1:])
|
||||||
} else if isSetSubreport(data[0]) {
|
} else if isSetSubreport(data[0]) {
|
||||||
fmt.Printf("%s OUT %s%s%s\n", p.addr(),
|
fmt.Printf("%s OUT %s%s%s\n", p.addr(),
|
||||||
fmtOut, decodeSubreport(data[1:]), fmtReset)
|
fmtOut, decodeSubreport(data[0], data[1:]), fmtReset)
|
||||||
|
} else if data[0] == 10 {
|
||||||
|
fmt.Printf("%s OUT CS %04x\n", p.addr(), le.Uint16(data[1:]))
|
||||||
} else if data[0] != 1 && !isGetSubreport(data[0]) {
|
} else if data[0] != 1 && !isGetSubreport(data[0]) {
|
||||||
fmt.Printf("%s OUT %02x %x\n", p.addr(), data[0], data[1:])
|
fmt.Printf("%s OUT %02x %x\n", p.addr(), data[0], data[1:])
|
||||||
}
|
}
|
||||||
|
|||||||
2
liberty
2
liberty
Submodule liberty updated: 492815c8fc...9268fb8eba
Reference in New Issue
Block a user