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, runsudo 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:
- First, find your touch device’s ID:
Look for a device named something like "EETI eGalax Touch Screen" and note its ID (e.g.,xinput list10) - Check your current transformation matrix (you’ll see the y-axis flip you applied here):
A standard matrix isxinput list-props <DEVICE_ID> | grep "Coordinate Transformation Matrix"1 0 0 0 1 0 0 0 1; your flipped y-axis version is probably1 0 0 0 -1 1 0 0 1 - 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):
Adjust the offset values in small increments (±0.01 to ±0.05) and test edge taps each time until they line up perfectlyxinput set-prop <DEVICE_ID> "Coordinate Transformation Matrix" 1 0 -0.02 0 -1 1.02 0 0 1 - If the left edge is unresponsive, tweak the 3rd value (x-offset) to
- Save the settings permanently:
Create a config file in/usr/share/X11/xorg.conf.d/named99-egalax-calibration.confwith this content (replace the matrix with your working values):
Reboot your Pi to make the changes stickSection "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
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:
Thefrom 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')calibrationvalues 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.iniunder 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




