Skip to content

Instantly share code, notes, and snippets.

@gingerbeardman
Last active February 28, 2023 19:41
Show Gist options
  • Save gingerbeardman/1091702ecb21122508ba417ccb9b9ea8 to your computer and use it in GitHub Desktop.
Save gingerbeardman/1091702ecb21122508ba417ccb9b9ea8 to your computer and use it in GitHub Desktop.
Sony USB Jog Controller (PCVA-JC1)
#!/usr/bin/env zsh
# requirements: hidapitester, sendkeys
doPress() {
cur+="$1"
sendkeys send --delay 0 --initial-delay 0 -c "$1" # faster than osascript
}
hidapitester --vidpid 054C/00C4 -l 4 --open --read-input-forever --quiet \
| while read -r line; do
mask=`echo $line | grep '00$'`
if [[ ! -z $mask ]]; then
btn="0x${mask:0:2}"
dir="0x${mask:3:2}"
jog="0x${mask:6:2}"
cur=""
if (( (($btn >> 0) & 0x1) == 0x1 )) && doPress "A"
if (( (($btn >> 1) & 0x1) == 0x1 )) && doPress "B"
if (( (($btn >> 2) & 0x1) == 0x1 )) && doPress "C"
if (( (($btn >> 3) & 0x1) == 0x1 )) && doPress "D"
if (( (($btn >> 4) & 0x1) == 0x1 )) && doPress "E"
if (( (($btn >> 5) & 0x1) == 0x1 )) && doPress "F"
if (( (($dir >> 0) & 0x1) == 0x1 )) && doPress "P"
if (( (($dir >> 1) & 0x1) == 0x1 )) && doPress "U"
if (( (($dir >> 2) & 0x1) == 0x1 )) && doPress "D"
if (( (($dir >> 3) & 0x1) == 0x1 )) && doPress "L"
if (( (($dir >> 4) & 0x1) == 0x1 )) && doPress "R"
if (( $jog == 0x81 )) && doPress "<c:right>" #"→"
if (( $jog == 0xC1 )) && doPress "<c:left>" #"←"
if [[ -z $cur ]]; then
clear
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment