1. The BeamNG Team wishes everyone Happy Holidays!
    BeamNG team presence will be limited during the holiday season as we take the time off to rest and enjoy the holidays!
    There will be no mod support or mod approvals from 19th of December until 5th of January. Please expect delays during this period.
    We hope you enjoy the holidays too, see you in 2026!

Experimental *linux only* mouse driving with side scroll and shift

Discussion in 'Utilities and programming' started by pawelek von sttetin, Dec 23, 2025.

  1. pawelek von sttetin

    pawelek von sttetin
    Expand Collapse

    Joined:
    Sep 14, 2025
    Messages:
    24
    since driving with mouse is being treated in half‑hearted fashioni did some simple scripts for making driving with mouse more fun
    so first thing is:
    "when u drive with mouse with combo button u have to put ur mouse to specific location otherwise u may end up by dragging ur wheel to side extremum"
    so below is script that will always place ur mouse at bottom 25% and sideways 50% of screen when u press shift key:

    Code:
    #!/bin/bash
    KEYBAORD_ID=$(xinput --list | grep -i '↳ ITE Tech. Inc. ITE Device(8910) Keyboard' | awk '{print $8}' | sed 's/id=//' | sed 's/Keyboard//' | sed ':a;N;$!ba;s/\n/\x0/g')
    WIDTH=1920
    HEIGHT=1080
    WCISNIENIE=0
    
    while true; do
    line=$(timeout 0.1 xinput test-xi2 --root $KEYBAORD_ID | grep -E "(KeyPress)|detail:|valuators" | head -n 3)
    	#echo "$line"
    	if echo "$line" | grep -q "EVENT type 13 (RawKeyPress)"; then
    		WCISNIENIE=1
    	else
    		WCISNIENIE=0
    		continue
    	fi
    	if echo "$line" | grep -q "detail: 50" && ((WCISNIENIE==1)); then
    		X_COORD=$((WIDTH / 2))
    		Y_COORD=$(( (HEIGHT / 4) * 3))
    		xdotool mousemove $X_COORD $Y_COORD
    		WCISNIENIE=0
    	fi	
    done
    
    second thing is that sdl implemantation in beamng doesnt read side scroll input so it cant be bound to steering so below is a scipt that will move mouse pointer with side scroll left and right and with main scroll up and down:

    Code:
    #!/bin/bash
    ZCZYTUJEME=0
    ZCZYTUJEME_SHIFT=0
    MOUSE_ID=$(xinput list | grep -i "Logitech USB Receiver Mouse" | grep -o 'id=[0-9]*' | cut -d'=' -f2 | head -n 1)
    SENSITIVITY=20
    echo "$MOUSE_ID"
    while true; do
    line=$(timeout 0.05 xinput test-xi2 --root $MOUSE_ID | grep -E "(RawButtonRelease)|detail:|valuators" | head -n 3)
    	    if echo "$line" | grep -q "detail: 4"; then
    		#echo "# Scroll up"
    		xdotool mousemove_relative -- 0 -$SENSITIVITY
    	    elif echo "$line" | grep -q "detail: 5"; then
    		#echo "# Scroll down"
    		xdotool mousemove_relative -- 0 $SENSITIVITY
    	    fi
    	    if echo "$line" | grep -q "detail: 6"; then
    		#echo "# Scroll right"
    		xdotool mousemove_relative -- $SENSITIVITY 0
    	    elif echo "$line" | grep -q "detail: 7"; then
    		#echo "# Scroll left"
    		xdotool mousemove_relative -- -$SENSITIVITY 0
    	    fi
    done
    
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice