Improve check-which-device-used.sh with clean table format and verbose option
- Added clean table format showing device name, ID, status, and event count - Color-coded output: green for active, red for inactive, yellow for not found - Added --verbose flag to show raw xinput output - Clear diagnosis section explaining what's happening - Specific recommendations based on detected configuration - Shows which device Paintstorm is actually using - Much easier to interpret results at a glance Usage: ./check-which-device-used.sh # Clean summary ./check-which-device-used.sh -v # Verbose with raw output
+201 −10 · 1 file changed
-
check-which-device-used.sh+201 −10
@@ -1,26 +1,217 @@ #!/bin/bash # Check which input device is actually receiving events +# Usage: ./check-which-device-used.sh [--verbose] + +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +BLUE='\033[0;34m' +BOLD='\033[1m' +NC='\033[0m' + +VERBOSE=false +if [[ "$1" == "--verbose" || "$1" == "-v" ]]; then + VERBOSE=true +fi echo "==========================================" -echo "Input Device Event Monitor" +echo "Tablet Device Activity Test" echo "==========================================" echo "" -echo "Available tablet devices:" +# Get device information +NATIVE_STYLUS=$(xinput list | grep -i "HUION.*Pen stylus" | grep -v "Virtual" | head -1) +NATIVE_STYLUS_ID=$(echo "$NATIVE_STYLUS" | grep -o 'id=[0-9]*' | cut -d= -f2) +NATIVE_STYLUS_NAME=$(echo "$NATIVE_STYLUS" | sed 's/.*↳ //' | sed 's/id=.*//' | xargs) + +VIRTUAL_STYLUS=$(xinput list | grep -i "OpenTabletDriver.*stylus" | head -1) +VIRTUAL_STYLUS_ID=$(echo "$VIRTUAL_STYLUS" | grep -o 'id=[0-9]*' | cut -d= -f2) +VIRTUAL_STYLUS_NAME=$(echo "$VIRTUAL_STYLUS" | sed 's/.*↳ //' | sed 's/id=.*//' | xargs) + +OTD_RUNNING=$(pgrep -x otd-daemon > /dev/null && echo "YES" || echo "NO") + +# Test devices +echo "Testing devices (move your pen for 5 seconds)..." echo "" -xinput list | grep -i -E "(huion|opentabletdriver|stylus|eraser)" | nl + +NATIVE_ACTIVE="N/A" +NATIVE_EVENTS=0 +VIRTUAL_ACTIVE="N/A" +VIRTUAL_EVENTS=0 + +if [ -n "$NATIVE_STYLUS_ID" ]; then + echo -n "Testing native device... " + NATIVE_OUTPUT=$(timeout 5 xinput test "$NATIVE_STYLUS_ID" 2>&1) + NATIVE_EVENTS=$(echo "$NATIVE_OUTPUT" | grep -c "motion" || echo "0") + + if [ "$NATIVE_EVENTS" -gt 0 ]; then + NATIVE_ACTIVE="ACTIVE" + echo -e "${GREEN}✓${NC}" + else + NATIVE_ACTIVE="INACTIVE" + echo -e "${RED}✗${NC}" + fi + + if [ "$VERBOSE" = true ]; then + echo " Raw output:" + echo "$NATIVE_OUTPUT" | head -10 | sed 's/^/ /' + echo "" + fi +fi + +if [ -n "$VIRTUAL_STYLUS_ID" ]; then + echo -n "Testing OTD virtual device... " + VIRTUAL_OUTPUT=$(timeout 5 xinput test "$VIRTUAL_STYLUS_ID" 2>&1) + VIRTUAL_EVENTS=$(echo "$VIRTUAL_OUTPUT" | grep -c "motion" || echo "0") + + if [ "$VIRTUAL_EVENTS" -gt 0 ]; then + VIRTUAL_ACTIVE="ACTIVE" + echo -e "${GREEN}✓${NC}" + else + VIRTUAL_ACTIVE="INACTIVE" + echo -e "${RED}✗${NC}" + fi + + if [ "$VERBOSE" = true ]; then + echo " Raw output:" + echo "$VIRTUAL_OUTPUT" | head -10 | sed 's/^/ /' + echo "" + fi +fi echo "" -echo "Testing which device receives events..." +echo "==========================================" +echo "RESULTS" +echo "==========================================" echo "" -echo "Move your pen on the tablet now (10 second test)..." + +# Print table header +printf "${BOLD}%-40s %-8s %-10s %-12s${NC}\n" "DEVICE" "ID" "STATUS" "EVENTS" +printf "%-40s %-8s %-10s %-12s\n" "----------------------------------------" "--------" "----------" "------------" + +# Native device row +if [ -n "$NATIVE_STYLUS_ID" ]; then + if [ "$NATIVE_ACTIVE" = "ACTIVE" ]; then + printf "${GREEN}%-40s %-8s %-10s %-12s${NC}\n" "${NATIVE_STYLUS_NAME:0:40}" "$NATIVE_STYLUS_ID" "$NATIVE_ACTIVE" "$NATIVE_EVENTS" + else + printf "${RED}%-40s %-8s %-10s %-12s${NC}\n" "${NATIVE_STYLUS_NAME:0:40}" "$NATIVE_STYLUS_ID" "$NATIVE_ACTIVE" "$NATIVE_EVENTS" + fi +else + printf "${YELLOW}%-40s %-8s %-10s %-12s${NC}\n" "Native Huion Device" "NOT FOUND" "N/A" "N/A" +fi + +# Virtual device row +if [ -n "$VIRTUAL_STYLUS_ID" ]; then + if [ "$VIRTUAL_ACTIVE" = "ACTIVE" ]; then + printf "${GREEN}%-40s %-8s %-10s %-12s${NC}\n" "${VIRTUAL_STYLUS_NAME:0:40}" "$VIRTUAL_STYLUS_ID" "$VIRTUAL_ACTIVE" "$VIRTUAL_EVENTS" + else + printf "${RED}%-40s %-8s %-10s %-12s${NC}\n" "${VIRTUAL_STYLUS_NAME:0:40}" "$VIRTUAL_STYLUS_ID" "$VIRTUAL_ACTIVE" "$VIRTUAL_EVENTS" + fi +else + printf "${YELLOW}%-40s %-8s %-10s %-12s${NC}\n" "OTD Virtual Device" "NOT FOUND" "N/A" "N/A" +fi + +echo "" +printf "%-40s ${BOLD}%-8s${NC}\n" "otd-daemon status:" "$OTD_RUNNING" +echo "" + +# Diagnosis +echo "==========================================" +echo "DIAGNOSIS" +echo "==========================================" +echo "" + +if [ "$NATIVE_ACTIVE" = "ACTIVE" ] && [ "$VIRTUAL_ACTIVE" != "ACTIVE" ]; then + echo -e "${GREEN}✓ Using Native Linux HID Driver${NC}" + echo "" + echo "Your tablet is working with the generic Linux HID driver." + echo "Paintstorm is reading from the native Huion device." + echo "" + echo -e "${BOLD}This is why pressure works WITHOUT otd-daemon.${NC}" + echo "" + echo "Recommendation:" + echo " • If everything works, you don't need OTD" + echo " • Only use OTD if you need custom curves, remapping, etc." + echo "" + +elif [ "$NATIVE_ACTIVE" != "ACTIVE" ] && [ "$VIRTUAL_ACTIVE" = "ACTIVE" ]; then + echo -e "${GREEN}✓ Using OpenTabletDriver Virtual Device${NC}" + echo "" + echo "OTD is running and has taken control of your tablet." + echo "The native device is inactive (OTD has exclusive hidraw access)." + echo "" + if [ -n "$NATIVE_STYLUS_ID" ]; then + echo -e "${YELLOW}⚠ PROBLEM:${NC} Native device still visible (id=$NATIVE_STYLUS_ID)" + echo " Paintstorm might try to use it, causing pressure to fail." + echo "" + echo -e "${BOLD}Solution:${NC}" + echo " xinput disable $NATIVE_STYLUS_ID" + echo " xinput disable $(xinput list | grep -i "HUION.*Pen eraser" | grep -v "Virtual" | grep -o 'id=[0-9]*' | cut -d= -f2)" + echo "" + echo "This forces Paintstorm to use the OTD virtual device." + else + echo "Native device is properly disabled. Paintstorm should work." + fi + echo "" + +elif [ "$NATIVE_ACTIVE" = "ACTIVE" ] && [ "$VIRTUAL_ACTIVE" = "ACTIVE" ]; then + echo -e "${YELLOW}⚠ BOTH Devices Are Active (Unusual)${NC}" + echo "" + echo "This is unexpected. Normally OTD takes exclusive access" + echo "to hidraw devices, making the native device inactive." + echo "" + echo "Possible causes:" + echo " • Multiple tablets connected" + echo " • OTD not configured for this specific tablet" + echo " • Unusual system configuration" + echo "" + +else + echo -e "${RED}✗ No Active Devices Detected${NC}" + echo "" + echo "Possible causes:" + echo " • Tablet not connected" + echo " • You didn't move the pen during the test" + echo " • Permission issues" + echo "" + echo "Try:" + echo " • Reconnect your tablet" + echo " • Run this script again: $0 --verbose" + echo " • Check permissions: ls -la /dev/hidraw*" + echo "" +fi + +# Show which device Paintstorm is likely using +echo "==========================================" +echo "WHICH DEVICE DOES PAINTSTORM USE?" +echo "==========================================" echo "" -# Monitor all tablet-related devices for 10 seconds -timeout 10 xinput test-xi2 --root 2>&1 | grep -A 5 -i -E "(huion|opentabletdriver|pressure|valuator)" || true +if [ "$NATIVE_ACTIVE" = "ACTIVE" ]; then + echo -e "Paintstorm is reading from: ${GREEN}${NATIVE_STYLUS_NAME}${NC} (id=$NATIVE_STYLUS_ID)" + echo "" + echo "This is the native Linux HID device." + if [ "$OTD_RUNNING" = "YES" ]; then + echo -e "${YELLOW}Note: OTD is running but Paintstorm is NOT using it!${NC}" + echo " This might explain why OTD features don't work." + fi +elif [ "$VIRTUAL_ACTIVE" = "ACTIVE" ]; then + echo -e "Paintstorm should be reading from: ${GREEN}${VIRTUAL_STYLUS_NAME}${NC} (id=$VIRTUAL_STYLUS_ID)" + echo "" + echo "This is the OTD virtual device." + if [ "$NATIVE_ACTIVE" = "INACTIVE" ]; then + echo "Native device is inactive, so Paintstorm has no choice." + else + echo -e "${YELLOW}Warning: Native device is still visible!${NC}" + echo " Paintstorm might use that instead." + fi +else + echo "Unable to determine which device Paintstorm uses." +fi echo "" -echo "Test complete." +echo "==========================================" +echo "" +echo "Run with --verbose flag to see raw xinput output:" +echo " $0 --verbose" echo "" -echo "If you saw 'Valuator' or 'pressure' events, the device is active." -echo "Note which device ID was shown in the output above."