kevinconway / remouseable

Use a reMarkable tablet as a mouse.
GNU General Public License v3.0
207 stars 12 forks source link

Pressure sensitivity #15

Open S0ulfire84 opened 3 years ago

S0ulfire84 commented 3 years ago

Hi! I just tried reMouseable in my computer and I was mind-blown, this works perfectly! Thanks for creating this!

I was wondering if you think it is possible to add pressure sensitivity support, so that it can be used with drawing programs that support it (Photoshop / Photopea, etc), since the reMarkable itself does have it.

Do you think it would work?

kevinconway commented 3 years ago

I'm glad you're enjoying the tool.

The short answer is: I think it's possible but too much work for me to do because I don't have a personal use for the feature.

The long answer is:

Unfortunately, pressure sensitivity and tilt are difficult to implement. Today, the tool works by consuming a stream of pen events from the Linux system on the tablet and translating some of them into mouse events on the computer. Each operating system has a different interface and different set of libraries that must be used to control the mouse. This project embeds some C code, copied from https://github.com/go-vgo/robotgo, that handles the OS specific mouse operations. Click, release, move, and drag are the only mouse operations that map to pen movement so it's not much code needed to support Windows, OSX, and Linux together. The limitation with this method is that the tool can only do what the mouse does and a mouse doesn't have tilt or pressure features.

To get non-mouse features the tool would need to communicate with the OS as a non-mouse device such as an actual pen device. Even though the remarkable tablet is doing exactly this internally, it's not easy or simple to mirror a pen device across computers. I've researched this idea a bit to see how it might be done and my best guess is that it is only made possible by implementing a custom device driver for each OS. That device driver would need to translate the Linux device events from the remarkable into OS specific hardware events that match up with that OS's expectations for a pen or wacom style tablet.

If you're using Linux then the Linux to Linux translation is possible. https://github.com/Evidlo/remarkable_mouse is a Python project that works almost identically to this one but also supports the full pen feature set on Linux when you use the --evdev flag. They're able to accomplish this because there is an open source Python module for creating Linux device drivers and the Linux device events coming from the remarkable are exactly the same ones the driver needs to emit. There is no equivalent Go module for creating Linux device drivers which is why I don't already have that feature. I would first have to port the Python code to Go. (Note that https://github.com/gvalkov/golang-evdev exists and was used for this project but it only supports reading from devices and not creating or writing to them).

There may be an easier way to accomplish what you're asking but this is all the information I've been able to find and learn on the subject. I don't, personally, have a use for the non-mouse features and the difficulty of implementing them is high enough that I'm unlikely to build this. If it actually requires a custom driver then I would think that it's a big enough project to be built on its own rather than as part of a much more simple mouse tool. Even so, I'll keep this issue open for discussion or to (maybe) inspire others to build the feature.

Resources for Windows:

Resources for OSX:

Resources for Linux:

Resources for cross platform: