If the touch input feels "90 degrees wrong" in 90-degree mode, it means the touchscreen coordinate system is not being rotated correctly to match the screen's orientation. This is a common issue when the calibration matrix is not properly aligned with the screen's transformation. Essentially, the touchscreen is likely still operating in its original orientation (or a different one) while the screen has rotated.
🔍 Understanding the Problem
When you rotate the screen 90° left (using transform 90), the touchscreen needs to have its X and Y axes swapped and one of them inverted to match the new orientation. If the touch input feels "90 degrees wrong," it suggests that the calibration matrix is either:
- Not rotating the coordinates at all (stuck in the original orientation).
- Rotating the coordinates in the wrong direction (e.g., 90° right instead of left).
- Applying an incorrect transformation (e.g., a 180° rotation or no inversion).
✅ Fixing the Issue
Let's try a few calibration matrices to ensure the touchscreen coordinates are rotated correctly to match the screen's 90° left orientation. We'll also test the other orientations to ensure consistency.
Here’s an updated set of keybindings for your Sway config, with a corrected approach to the calibration matrices. We'll focus on getting the 90° left mode right first, then ensure the others are consistent.
Replace <TOUCHSCREEN> and <OUTPUT> as before.
# ─── Normal Orientation ───
bindsym $mod+Shift+o exec swaymsg output "<OUTPUT>" transform normal \
&& swaymsg input "<TOUCHSCREEN>" calibration_matrix 1 0 0 0 1 0 0 0 1
# ─── Rotate 90° Left ───
# Corrected: Swap X/Y and invert Y, no scaling
bindsym $mod+Shift+l exec swaymsg output "<OUTPUT>" transform 90 \
&& swaymsg input "<TOUCHSCREEN>" calibration_matrix 0 1 0 -1 0 1 0 0 1
# ─── Rotate 270° Right ───
# Corrected: Swap X/Y and invert X, no scaling
bindsym $mod+Shift+r exec swaymsg output "<OUTPUT>" transform 270 \
&& swaymsg input "<TOUCHSCREEN>" calibration_matrix 0 -1 1 1 0 0 0 0 1
# ─── Inverted Orientation ───
bindsym $mod+Shift+i exec swaymsg output "<OUTPUT>" transform 180 \
&& swaymsg input "<TOUCHSCREEN>" calibration_matrix -1 0 1 0 -1 1 0 0 1
🔎 Explanation of Changes
🛠️ Testing the Fix
- Reload Sway Config: Press
$mod+Shift+c to reload your config.
- Test 90° Left: Press
$mod+Shift+l to rotate the screen 90° left. Test touches in all areas of the screen (center, edges, corners). The touch should now align with the screen's orientation.
- Test Other Orientations: Try
$mod+Shift+r (270° right), $mod+Shift+o (normal), and $mod+Shift+i (inverted) to ensure they also work correctly.
🔄 If It's Still Wrong
If the touch is still "90 degrees wrong" after this change, it might mean the touchscreen's initial orientation is not what we expect (e.g., it might already be rotated or inverted by the driver). Here’s how to debug further:
-
Reset Calibration: Add a reset keybinding to test the raw touchscreen input:
bindsym $mod+Shift+z exec swaymsg input "<TOUCHSCREEN>" calibration_matrix 1 0 0 0 1 0 0 0 1
- Rotate the screen to 90° left (
$mod+Shift+l).
- Press
$mod+Shift+z to reset the calibration to identity.
- Touch the screen and note where the cursor appears relative to your finger. This will tell us the touchscreen's "raw" orientation.
-
Try Alternative Matrices: If the above matrix for 90° left doesn't work, try these alternatives to see if one matches your device's behavior:
# Alternative 1 for 90° Left: Swap X/Y, invert X
bindsym $mod+Shift+l exec swaymsg output "<OUTPUT>" transform 90 \
&& swaymsg input "<TOUCHSCREEN>" calibration_matrix -1 0 1 0 1 0 0 0 1
# Alternative 2 for 90° Left: Swap X/Y, no inversion
bindsym $mod+Shift+l exec swaymsg output "<OUTPUT>" transform 90 \
&& swaymsg input "<TOUCHSCREEN>" calibration_matrix 0 1 0 1 0 0 0 0 1
-
Debug with Tools: Use libinput debug-events or wev to see the raw touchscreen coordinates and how they map to the screen. This can help us determine the exact transformation needed.
📋 Next Steps
- Apply the updated config above and test.
- If it works, great! If not, let me know the results of the reset calibration test (
$mod+Shift+z) or describe how the touch is "wrong" (e.g., "I touch the top-left corner, but the cursor appears in the bottom-left").
- We can then fine-tune the matrix further or explore device-specific quirks.
This should get us much closer to a solution! 😊