Skip to content
TheChatArchiveThe Chat Archive
o3-mini· OpenAIHugging Face LMArena Human Preference 140K

seems a bit odd in 90 degrees (not widescreen) format. maybe it has to do with…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with chatgpt-4o-latest-20250326’s answer.
  1. User

    seems a bit odd in 90 degrees (not widescreen) format. maybe it has to do with resolution or ratio

  2. Assistant

    When you rotate your display, the default calibration matrices assume a square (normalized) coordinate system. If your display isn’t square (or if its logical coordinate space doesn’t match the physical one in the rotated state), the touchscreen mapping can seem off.

    For example, the simple 90° rotation matrix

    [  0  -1   1 ]
    [  1   0   0 ]
    [  0   0   1 ]
    

    works well if the coordinate space is square. But on a widescreen (or non-square) display the touchscreen input may need a slight adjustment to account for the aspect ratio.


    How to Adjust the Calibration Matrix for Non-Square Displays

    Let’s say your display’s native resolution in landscape mode is W×H. When you rotate the display 90° (to a portrait orientation), the effective areas change. In normalized coordinates, you need to scale the off-diagonal values by the ratios of height and width.

    A general recipe when rotating 90° is:

    • Use a matrix of the form:

      [   0      -H/W    1 ]
      [  W/H      0      0 ]
      [   0       0      1 ]
      

      Here,

      • H/W is the ratio of the original height to width
      • W/H is the ratio of width to height

    This scaling makes sure that the mapping from touch (which is reported in the physical dimensions of the sensor's active area) to the logical coordinate system remains correct.


    Example

    Assume your device in its native landscape mode has a resolution of 1920×1080. Then:

    • For 90° rotation:
      • Calculate:

      • H/W = 1080/1920 ≈ 0.5625
      • W/H = 1920/1080 ≈ 1.7778

      The calibration matrix becomes:

      [  0      -0.5625    1 ]
      [  1.7778    0       0 ]
      [   0        0       1 ]
      
    • For 270° (90° right), you’d similarly adjust the matrix (swapping signs and ratios appropriately). A common formula for 270° is:

      [  0      H/W      0 ]
      [ -W/H     0       1 ]
      [  0       0       1 ]
      

      Plugging in the numbers:

      [  0      0.5625   0 ]
      [ -1.7778  0       1 ]
      [  0       0       1 ]
      
    • For 180° inversion the correction is generally less sensitive to aspect ratio because both directions are inverted:

      [ -1  0   1 ]
      [  0 -1   1 ]
      [  0  0   1 ]
      

    Putting It Into Your Sway Config

    Replace <TOUCHSCREEN_DEVICE> below with your device’s name (found with swaymsg -t get_inputs).

    For a display with a resolution of 1920×1080, your Sway config might include manual shortcuts like this:

    # Normal orientation (0°)
    bindsym $mod+Shift+o exec "swaymsg output '*' transform normal; swaymsg input '<TOUCHSCREEN_DEVICE>' calibration_matrix 1 0 0 0 1 0 0 0 1"
    
    # Rotate screen 90° (portrait): adjust for aspect ratio (1920×1080 as an example)
    bindsym $mod+Shift+l exec "swaymsg output '*' transform 90; swaymsg input '<TOUCHSCREEN_DEVICE>' calibration_matrix 0 -0.5625 1 1.7778 0 0 0 0 1"
    
    # Rotate screen 270° (other portrait side)
    bindsym $mod+Shift+r exec "swaymsg output '*' transform 270; swaymsg input '<TOUCHSCREEN_DEVICE>' calibration_matrix 0 0.5625 0 -1.7778 0 1 0 0 1"
    
    # Inverted orientation (180°)
    bindsym $mod+Shift+i exec "swaymsg output '*' transform 180; swaymsg input '<TOUCHSCREEN_DEVICE>' calibration_matrix -1 0 1 0 -1 1 0 0 1"
    

    Note:

    • The above matrices for 90° and 270° are examples. Your touchscreen’s physical calibration might need fine-tuning.
    • If your device’s resolution is different from 1920×1080, recalculate the ratios:
      • For 90°: use [ 0, -(H/W), 1, (W/H), 0, 0, 0, 0, 1 ]
      • For 270°: adjust accordingly.

    Testing & Fine-Tuning

    1. After updating your configuration, reload Sway (typically with $mod+Shift+c).
    2. Test the touch input after invoking each shortcut.
    3. If the touch input still feels offset (for example, touches registering slightly off-target), you might need to adjust the translation component (the third value in the first or second row) by a small amount.

    Summary

    • Issue: A simple 90° rotation matrix assumes a square coordinate space, which doesn’t match a widescreen resolution.
    • Solution: Adjust the off-diagonal elements by the aspect ratio (H/W and W/H) to keep the touchscreen input aligned with the display.
    • Implementation: Modify your Sway keybindings to send both the output rotation and the adjusted calibration matrix commands.

    This should help you get a more accurate touchscreen calibration when you rotate your display on the fly.

  3. User

    i want everything in the config

  4. Assistant

    Below is a complete example snippet you can insert into your Sway configuration file (typically located at ~/.config/sway/config). This snippet defines key bindings that both rotate the display and update the touchscreen calibration on the fly. Replace the placeholder NAME_OF_TOUCH_DEVICE with the identifier for your touchscreen (you can get it from running swaymsg -t get_inputs).

    For example, if your device’s native landscape resolution is 1920×1080, and you want the following orientations:

    • 0° (normal): No rotation
    • 90° (portrait left):
      • Display transformed 90° clockwise
      • Adjust calibration with the aspect ratio factors
    • 270° (portrait right):
      • Display transformed 270° (or 90° counterclockwise)
      • Adjust calibration accordingly
    • 180° (inverted):
      • Display rotated 180°
      • Calibration matrix inverts both axes

    Below is the full config snippet:


    # --- Touchscreen and Display Orientation Shortcuts ---
    # Replace NAME_OF_TOUCH_DEVICE with your touchscreen's device name from:
    #    swaymsg -t get_inputs
    
    set $touch "NAME_OF_TOUCH_DEVICE"
    
    # Normal orientation (0°)
    bindsym $mod+Shift+o exec "swaymsg output '*' transform normal; swaymsg input '$touch' calibration_matrix 1 0 0 0 1 0 0 0 1"
    
    # Rotate screen 90° (portrait left)
    # For a 1920×1080 display, the aspect ratio factors are:
    #   H/W = 1080/1920 ≈ 0.5625 and W/H = 1920/1080 ≈ 1.7778
    # Calibration matrix:
    #   [  0    -0.5625    1 ]
    #   [ 1.7778   0       0 ]
    #   [  0       0       1 ]
    bindsym $mod+Shift+l exec "swaymsg output '*' transform 90; swaymsg input '$touch' calibration_matrix 0 -0.5625 1 1.7778 0 0 0 0 1"
    
    # Rotate screen 270° (portrait right)
    # Calibration matrix for 270° may be:
    #   [  0    0.5625   0 ]
    #   [ -1.7778   0     1 ]
    #   [  0       0     1 ]
    bindsym $mod+Shift+r exec "swaymsg output '*' transform 270; swaymsg input '$touch' calibration_matrix 0 0.5625 0 -1.7778 0 1 0 0 1"
    
    # Inverted orientation (180°)
    # Calibration matrix for 180° (inversion):
    #   [ -1   0    1 ]
    #   [  0  -1    1 ]
    #   [  0   0    1 ]
    bindsym $mod+Shift+i exec "swaymsg output '*' transform 180; swaymsg input '$touch' calibration_matrix -1 0 1 0 -1 1 0 0 1"
    

    Explanation

    • set $touch "NAME_OF_TOUCH_DEVICE"
      Define a variable for your touchscreen device.

    • Normal (0°):
      Uses the identity matrix so that the touch coordinates remain unchanged.

    • 90° (portrait left):
      The transformation matrix:

      • Swaps the axes.
      • Scales the matrix using the ratios:
        • -0.5625 (from H/W ≈ 1080/1920) for the X axis.
        • 1.7778 (from W/H ≈ 1920/1080) for the Y axis.
      • The translation components (the third numbers in the first and/or second rows) help re-map the coordinates to a [0, 1] range.
    • 270° (portrait right):
      Similar adjustments are made with opposite signs on the off-diagonals to remap the coordinates.

    • 180° (inverted):
      Both axes are flipped, hence the -1 scaling factors, with a translation of 1 to reposition back into the normalized space.

    Note:
    These matrices are based on a 1920×1080 resolution example. If your device has a different resolution or if you notice that the touch input is still slightly off, you may need to fine-tune these numbers.

    After updating your config, reload Sway (typically with $mod+Shift+c), and then use the shortcuts:

    • $mod+Shift+o for normal
    • $mod+Shift+l for 90° portrait (left)
    • $mod+Shift+r for 270° portrait (right)
    • $mod+Shift+i for inverted (180°)

    This configuration ensures that both your display rotation and touchscreen calibration update on the fly.

  5. User

    screen is 1920x1080

  6. Assistant

    Below is a complete Sway config snippet that assumes your display resolution is 1920×1080. Just replace NAME_OF_TOUCH_DEVICE with the exact identifier for your touchscreen device (see it via swaymsg -t get_inputs). This snippet defines keybindings that update both the screen rotation and the touchscreen calibration on the fly:

    # Define your touchscreen device name as a variable.
    # Replace NAME_OF_TOUCH_DEVICE with the identifier from `swaymsg -t get_inputs`
    set $touch "NAME_OF_TOUCH_DEVICE"
    
    # Normal orientation (0°)
    bindsym $mod+Shift+o exec "swaymsg output '*' transform normal; swaymsg input '$touch' calibration_matrix 1 0 0 0 1 0 0 0 1"
    
    # Rotate screen 90° (portrait left)
    # For a 1920x1080 screen:
    #    H/W = 1080/1920 ≈ 0.5625
    #    W/H = 1920/1080 ≈ 1.7778
    # Calibration matrix:
    #   [  0      -0.5625    1 ]
    #   [ 1.7778    0         0 ]
    #   [  0        0         1 ]
    bindsym $mod+Shift+l exec "swaymsg output '*' transform 90; swaymsg input '$touch' calibration_matrix 0 -0.5625 1 1.7778 0 0 0 0 1"
    
    # Rotate screen 270° (portrait right)
    # Calibration matrix for 270°:
    #   [   0     0.5625    0 ]
    #   [ -1.7778    0      1 ]
    #   [   0         0      1 ]
    bindsym $mod+Shift+r exec "swaymsg output '*' transform 270; swaymsg input '$touch' calibration_matrix 0 0.5625 0 -1.7778 0 1 0 0 1"
    
    # Inverted orientation (180°)
    # Calibration matrix for 180° (flipping both axes):
    #   [ -1   0   1 ]
    #   [  0  -1   1 ]
    #   [  0   0   1 ]
    bindsym $mod+Shift+i exec "swaymsg output '*' transform 180; swaymsg input '$touch' calibration_matrix -1 0 1 0 -1 1 0 0 1"
    

    Explanation

    • Output Transformation:
      Each keybinding uses swaymsg output '*' transform <angle> to set the desired rotation.

    • Touchscreen Calibration:
      The touchscreen input needs a separate calibration matrix so that its coordinate mapping matches the rotated display. The matrices here are designed for a screen of 1920×1080 pixels:

      • Normal (0°):
        Uses the identity matrix, so no re-mapping is required.

      • 90° (portrait left):
        The matrix

        [  0     -0.5625   1 ]
        [ 1.7778    0       0 ]
        [  0        0       1 ]
        

        swaps the axes and uses the aspect ratio factors (1080/1920 = 0.5625 and 1920/1080 = 1.7778) to remap touch coordinates.

      • 270° (portrait right):
        The matrix

        [    0    0.5625   0 ]
        [ -1.7778    0     1 ]
        [   0      0       1 ]
        

        rearranges the coordinates for the other portrait orientation.

      • 180° (inverted):
        This flips both axes while translating back into the normalized coordinate space.

    How to Use

    1. Place the snippet above into your ~/.config/sway/config.
    2. Replace NAME_OF_TOUCH_DEVICE with your touchscreen’s device name.
    3. Reload Sway (typically with $mod+Shift+c).
    4. Use the shortcuts:
      • $mod+Shift+o: Normal (0°)
      • $mod+Shift+l: Rotate to 90° (portrait left)
      • $mod+Shift+r: Rotate to 270° (portrait right)
      • $mod+Shift+i: Invert (180°)

    If you observe that the touchscreen input still feels a bit off, you might need to fine-tune the calibration matrix values slightly. The values provided here serve as a solid starting point for a 1920×1080 display.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.