← paintstorm-distrobox-legacy

Add simpler keyboard event test for tablet buttons

70d6c073033630066926db1877aeddf56e840f70 · Claude · Jan 24, 2026 12:03

User discovered tablet buttons trigger keyboard events that mess up the
xinput test script. This is because Huion tablets expose buttons as a
keyboard device (id=24 [slave keyboard]).

New script: test-tablet-keyboard-events.sh
- Specifically tests the keyboard device (id=24)
- Shows what keycodes the tablet buttons send
- Translates keycodes to key symbols (e.g., keycode 10 = a)
- Also tests pen buttons separately
- Provides clear next steps based on findings

This is actually good news - tablet buttons are already mapped to keys,
so they can be used directly in applications without any configuration.
If user wants different keys, they can remap with xmodmap.

+135 · 1 file changed

  • test-tablet-keyboard-events.sh +135 −0
diff --git a/test-tablet-keyboard-events.sh b/test-tablet-keyboard-events.sh
new file mode 100755
index 0000000..890a5c8
--- /dev/null
+++ b/test-tablet-keyboard-events.sh
@@ -0,0 +1,135 @@
+#!/bin/bash
+# Simple test to see what keyboard events tablet buttons send
+
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+YELLOW='\033[1;33m'
+BLUE='\033[0;34m'
+BOLD='\033[1m'
+NC='\033[0m'
+
+echo "=========================================="
+echo "Tablet Button Keyboard Event Test"
+echo "=========================================="
+echo ""
+
+# Find the keyboard device
+KEYBOARD_ID=$(xinput list | grep -i "HUION.*Tablet" | grep "keyboard" | grep -o 'id=[0-9]*' | cut -d= -f2)
+
+if [ -z "$KEYBOARD_ID" ]; then
+    echo -e "${RED}ERROR: Huion keyboard device not found${NC}"
+    exit 1
+fi
+
+echo -e "${GREEN}Found: HUION Huion Tablet_G930L (id=$KEYBOARD_ID)${NC}"
+echo ""
+echo "This device sends keyboard events when you press tablet buttons."
+echo ""
+echo "=========================================="
+echo "Testing: Press tablet buttons for 10 seconds"
+echo "=========================================="
+echo ""
+echo "Watch for 'key press' and 'key release' events."
+echo "The number after them is the keycode."
+echo ""
+echo "Starting in 3 seconds..."
+sleep 3
+echo ""
+
+# Capture output
+OUTPUT=$(timeout 10 xinput test "$KEYBOARD_ID" 2>&1)
+
+echo "$OUTPUT"
+
+echo ""
+echo "=========================================="
+echo "Analysis"
+echo "=========================================="
+echo ""
+
+if echo "$OUTPUT" | grep -q "key press"; then
+    echo -e "${GREEN}✓ Tablet buttons send keyboard events!${NC}"
+    echo ""
+
+    # Extract unique keycodes
+    KEYCODES=$(echo "$OUTPUT" | grep "key press" | awk '{print $3}' | sort -n | uniq)
+
+    echo "Detected keycodes:"
+    for keycode in $KEYCODES; do
+        # Try to get the key symbol
+        KEYSYM=$(xmodmap -pke | grep "keycode *$keycode " | sed 's/.*= //' | awk '{print $1}')
+        if [ -n "$KEYSYM" ]; then
+            echo "  Keycode $keycode = $KEYSYM"
+        else
+            echo "  Keycode $keycode = (unknown)"
+        fi
+    done
+
+    echo ""
+    echo "What this means:"
+    echo "  Your tablet buttons are ALREADY mapped to keyboard keys!"
+    echo "  You can use these keys directly in Paintstorm."
+    echo ""
+    echo "  Or remap them with xmodmap if you want different keys."
+else
+    echo -e "${YELLOW}No keyboard events detected.${NC}"
+    echo "Make sure you pressed the TABLET buttons (not pen buttons)."
+fi
+
+echo ""
+echo "=========================================="
+echo "Pen Buttons Test"
+echo "=========================================="
+echo ""
+
+PEN_ID=$(xinput list | grep -i "HUION.*Pen stylus" | grep -o 'id=[0-9]*' | cut -d= -f2)
+
+if [ -z "$PEN_ID" ]; then
+    echo "Pen device not found."
+    exit 0
+fi
+
+echo "Testing pen buttons (id=$PEN_ID)"
+echo "Press the buttons on your PEN for 5 seconds..."
+echo ""
+
+PEN_OUTPUT=$(timeout 5 xinput test "$PEN_ID" 2>&1)
+
+if echo "$PEN_OUTPUT" | grep -q "button press"; then
+    echo -e "${GREEN}✓ Pen button events detected!${NC}"
+    echo ""
+
+    PEN_BUTTONS=$(echo "$PEN_OUTPUT" | grep "button press" | awk '{print $3}' | sort -n | uniq)
+
+    echo "Pen buttons:"
+    for btn in $PEN_BUTTONS; do
+        echo "  Button $btn"
+    done
+
+    echo ""
+    echo "These can be remapped with xsetwacom (if it works)"
+    echo "or xbindkeys."
+else
+    echo -e "${YELLOW}No pen button presses detected.${NC}"
+    echo "You may need to press them during the test."
+fi
+
+echo ""
+echo "=========================================="
+echo "Summary"
+echo "=========================================="
+echo ""
+echo "Your Huion tablet uses a keyboard device for tablet buttons."
+echo "This is normal and actually convenient!"
+echo ""
+echo "Next steps:"
+echo ""
+echo "1. If you like the current key mappings, just use them!"
+echo ""
+echo "2. To remap tablet buttons to different keys:"
+echo "   Use xmodmap to remap the keycodes shown above"
+echo ""
+echo "3. To remap pen buttons:"
+echo "   Test if xsetwacom works: ./test-xsetwacom-compatibility.sh"
+echo "   Or use xbindkeys: ./configure-tablet-buttons.sh"
+echo ""