Jump to content
  • 0

Cage Cursor not working on Linux


FalseMyrmidon

Question

2 answers to this question

Recommended Posts

  • 0

I made a quick hack that will force the game to grab the pointer and lock it to the window. To try it out, save this C code to a file (e.g. grab_pointer.c):

#define _GNU_SOURCE
#include <dlfcn.h>
#include <stdbool.h>
#include <X11/Xlib.h>

typedef int (*real_XNextEvent_t)(Display *display, XEvent *event_return);
real_XNextEvent_t real_XNextEvent;

int XNextEvent(Display *display, XEvent *event_return)
{
    static bool first_expose_done = false;
    XExposeEvent *ev;
    int ret;

    ret = real_XNextEvent(display, event_return);
    if (!first_expose_done && event_return->type == Expose) {
        ev = (XExposeEvent *)event_return;
        XGrabPointer(ev->display, ev->window, True, 0, GrabModeAsync, GrabModeAsync, ev->window, None, CurrentTime);
        first_expose_done = true;
    }
    return ret;
}

__attribute__((constructor)) void init(void)
{
    real_XNextEvent = dlsym(RTLD_NEXT, "XNextEvent");
}

Compile the file like this:

gcc -shared -fPIC -O3 -march=native -lX11 grab_pointer.c -o grab_pointer.so

This will create the shared object file grab_pointer.so.

 

Now you just need to "preload" this code when you run the game. At the command line, try this (changing the paths to the approriate locations):

LD_PRELOAD=/absolute/path/to/grab_pointer.so /path/to/Pillars\ of\ Eternity/start.sh

Or if you don't want to have to run that at the command line each time, you can edit the game's start.sh and add this line at the top (but after #!/bin/bash):

export LD_PRELOAD=/absolute/path/to/grab_pointer.so

Hope that works for you until Obsidian fixes the issue.

 

Link to comment
Share on other sites

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
Answer this question...

×   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.

Loading...
×
×
  • Create New...