Jump to content

Invert mouse on right click


Recommended Posts

I can't seem to find any option to do this and can't see any threads suggesting it. As someone who prefers using an inverted Y-axis it's hard to play KSP because the look up/look down action is reversed to my usual preference - I have over 300 hours but avoid playing these days because it's difficult to switch mind-sets.

I suggest an option to invert the mouse Y axis whenever mouse-look is active, so when I pull back on the mouse the view goes to the sky, this should apply anywhere mouse look works (SPH, VAB, Orbit, EVA's, etc).

Link to comment
Share on other sites

  • 2 years later...
16 hours ago, EnigmaRaptor said:

Has this gotten no attention?

Considering nobody has said anything about it in 3 years, I'd say no. 

On 11/10/2015 at 3:35 AM, Zigzabal said:

I suggest an option to invert the mouse Y axis whenever mouse-look is active, so when I pull back on the mouse the view goes to the sky, this should apply anywhere mouse look works (SPH, VAB, Orbit, EVA's, etc).

The mouse controls are different in the VAB and SPH already, so asking the devs to normalize them is akin to herding cats. 

Link to comment
Share on other sites

  • 4 years later...

Ok, so this same problem prevented me from using KSP for years. A close friend had been nagging me to try it out, so I decided to buckle down and finally get this sorted.

I struggled to find a solution, but eventually realized that the easiest option would be to just brute force it by inverting the mouse whenever the right mouse button is held down system wide. (A dirty hack, but it's the best I could come up with).

First make sure you're running a modern version of Ubuntu or Debian (I've tested on 20.04 and Bookworm) and that you have Wayland disabled (I'm not sure what the Wayland replacement for xinput would be).

Then install xinput and gcc:

user@your-pc:~$ apt install xinput gcc

Now identify the event queue for your mouse:

user@your-pc:~$ cat /proc/bus/input/devices | grep -B4 mouse0

The output will be something like this:

N: Name="Logitech USB Optical Mouse"
P: Phys=usb-0000:00:14.0-10/input0
S: Sysfs=/devices/pci0000:00/0000:00:14.0/usb1/1-10/1-10:1.0/0003:046D:C077.0002/input/input5
U: Uniq=
H: Handlers=mouse0 event5 

Your mouse should always have "mouse0" as a handler, but what we need is the event queue number as well - since that is what we will be querying next. In this case it's event5.

Now you can cut and paste the following into a file called ksp_mouse_invert.c

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/input.h>

int main() {
    // initialize variables
    int fd;
    struct input_event ev;

    // Open the event device (replace /dev/input/event5 with your mouse)
    fd = open("/dev/input/event5", O_RDONLY);
    if (fd == -1) {
        perror("Failed to open event device");
        return -1;
    }

    // Event loop to check mouse input
    while (1) {
        ssize_t bytes = read(fd, &ev, sizeof(struct input_event));
	if (ev.code == 273) {
		if (ev.value == 1) { system( "xinput set-prop 10 \"Coordinate Transformation Matrix\" 1 0 0 0 -1 0 0 0 1" ); }
		if (ev.value == 0) { system( "xinput set-prop 10 \"Coordinate Transformation Matrix\" 1 0 0 0 1 0 0 0 1" ); }
	}
    }

    // Close the event device
    close(fd);

    return 0;
}

You should update the /dev/input/event5 to match whatever the event queue is for your mouse.

Now compile the program like this:

user@your-pc:~$ gcc ksp_mouse_invert.c -o ksp_mouse_invert

And finally run it with elevated privileges so it can connect to the event queue:

user@your-pc:~$ sudo ./ksp_mouse_invert

You'll have to leave the terminal window open/running with the inverter going while your using KSP.

Once you're done, you can just do the normal CTRL+C to terminate/exit.

Hopefully this will help other old timers like me who are used to inverted mice in 3d games.

I'm so excited to finally get into KSP - wish me luck :-)

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...