You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Kivy下无法校准触摸屏:树莓派Egalax触控屏边缘按钮无法触及

Hey there! Let's fix that annoying edge-button touch issue with your Raspberry Pi + Egalax touchscreen setup. I’ve dealt with similar problems before, so here’s a step-by-step calibration plan tailored to your setup:

Calibration Solutions for Egalax Touchscreen Edge Input Issues

1. Start with the Official Egalax Calibration Tool

Egalax screens come with a dedicated calibration utility that’s usually the quickest fix, especially for edge alignment:

  • Open a terminal and run: sudo egalax-calibrator (if it’s not installed first, run sudo apt install egalax-calibrator)
  • Follow the on-screen prompts to tap all calibration points, especially the ones at the extreme edges—this is likely where your previous y-axis flip missed fine-tuning edge coordinates
  • After calibration, restart the touch service to apply changes: sudo systemctl restart egalax-touchscreen

2. Manual Coordinate Adjustment with xinput

If the official tool doesn’t nail it, we can tweak the coordinate mapping directly via xinput for precision:

  1. First, find your touch device’s ID:
    xinput list
    
    Look for a device named something like "EETI eGalax Touch Screen" and note its ID (e.g., 10)
  2. Check your current transformation matrix (you’ll see the y-axis flip you applied here):
    xinput list-props <DEVICE_ID> | grep "Coordinate Transformation Matrix"
    
    A standard matrix is 1 0 0 0 1 0 0 0 1; your flipped y-axis version is probably 1 0 0 0 -1 1 0 0 1
  3. Fine-tune edge offsets:
    If your edge taps are registering too far inward, adjust the offset values in the matrix. For example:
    • If the left edge is unresponsive, tweak the 3rd value (x-offset) to -0.02
    • If the bottom edge is off, adjust the 6th value (y-offset) to 1.02
      Run this command to test (replace <DEVICE_ID> with your actual ID):
    xinput set-prop <DEVICE_ID> "Coordinate Transformation Matrix" 1 0 -0.02 0 -1 1.02 0 0 1
    
    Adjust the offset values in small increments (±0.01 to ±0.05) and test edge taps each time until they line up perfectly
  4. Save the settings permanently:
    Create a config file in /usr/share/X11/xorg.conf.d/ named 99-egalax-calibration.conf with this content (replace the matrix with your working values):
    Section "InputClass"
        Identifier "Egalax Touch Screen"
        MatchProduct "EETI eGalax Touch Screen"
        Driver "libinput"
        Option "TransformationMatrix" "1 0 -0.02 0 -1 1.02 0 0 1"
    EndSection
    
    Reboot your Pi to make the changes stick

3. Kivy-Specific Input Calibration

If system-level calibration is solid but Kivy still isn’t registering edge taps correctly, adjust the app’s input settings:

  • In your Kivy app’s main.py, add this at the start to tweak calibration:
    from kivy.config import Config
    # Disable mouse emulation if needed
    Config.set('input', 'mouse', 'mouse,multitouch_on_demand')
    # Replace <YOUR_TOUCH_DEVICE_NAME> with the name from xinput list
    Config.set('input', '<YOUR_TOUCH_DEVICE_NAME>', 'mtdev,calibration=0.02,0.02,-0.02,-0.02')
    
    The calibration values follow the format: x_min_offset, y_min_offset, x_max_offset, y_max_offset—adjust based on your test results
  • Alternatively, edit the global Kivy config file at ~/.kivy/config.ini under the [input] section to apply this to all Kivy apps:
    <YOUR_TOUCH_DEVICE_NAME> = mtdev,calibration=0.02,0.02,-0.02,-0.02
    

4. Verify Your Calibration

After each adjustment:

  • Keep the cursor enabled and use your stylus to tap the problematic edge button—check if the cursor lands exactly on the button
  • Repeat tweaks until every edge input registers correctly

内容的提问来源于stack exchange,提问作者Superleggera

火山引擎 最新活动