2022-02-25 01:03:29 +00:00
|
|
|
# SP3tabletd
|
2022-02-17 15:01:34 +00:00
|
|
|
|
2022-02-25 01:03:29 +00:00
|
|
|
![Rust](https://img.shields.io/badge/rust-%23000000.svg?style=flat&logo=rust&logoColor=white)
|
|
|
|
![C++](https://img.shields.io/badge/c++-%2300599C.svg?style=flat&logo=c%2B%2B&logoColor=white)
|
|
|
|
![Linux](https://img.shields.io/badge/Linux-FCC624?style=flat&logo=linux&logoColor=black)
|
2022-02-25 01:07:06 +00:00
|
|
|
![X11](https://img.shields.io/badge/X11-FEC350?style=flat&logo=xdotorg&logoColor=black)
|
2022-02-25 01:03:29 +00:00
|
|
|
![Status](https://img.shields.io/badge/Status-Incomplete-red)
|
2022-02-17 15:01:34 +00:00
|
|
|
|
2022-02-25 01:03:29 +00:00
|
|
|
This is a re-write of my [Surface Pro 3
|
|
|
|
Autorotate](https://github.com/elfsternberg/surface3-scripts)
|
|
|
|
program. Note that what you have here is just part of the learning
|
|
|
|
curve.
|
2022-02-17 15:01:34 +00:00
|
|
|
|
2022-02-25 01:03:29 +00:00
|
|
|
This program autorotates the screen of a Microsoft Surface Pro 3 Tablet
|
|
|
|
running Linux. It correctly performs the autorotation for all major
|
|
|
|
pointer devices, including the stylus and eraser devices. It also
|
|
|
|
enables palm rejection (meaning you can rest your hand on the screen
|
|
|
|
while drawing) when the stylus and eraser devices are "in use" (which is
|
|
|
|
defined by the digitizer as "within approximately 4cm of the screen").
|
2022-02-17 15:01:34 +00:00
|
|
|
|
2022-02-25 01:03:29 +00:00
|
|
|
This program is written in Python 2, which is included in all major
|
|
|
|
Linux distributions by default. It has no additional dependencies.
|
|
|
|
|
|
|
|
It may run on other versions of the Microsoft Surface, but I haven't
|
|
|
|
tested it on anything other than my own Surface Pro 3.
|
|
|
|
|
|
|
|
## Progress
|
|
|
|
|
|
|
|
The intent of this exercise is to eventually
|
|
|
|
[RIIR](https://adventures.michaelfbryan.com/posts/how-to-riir/) the
|
|
|
|
code. Right now, I'm actively learning how the X11/XCB library works
|
|
|
|
to encode and transmit monitor and rotation information for the root
|
|
|
|
screen, so what you'll find in the [`src`](./src) tree is a C++
|
|
|
|
program where I'm slowly, one painful step at a time, figuring out how
|
|
|
|
to efficiently retrieve information from the X11 server and then send
|
|
|
|
commands to rotate the screen.
|
|
|
|
|
|
|
|
It's not enough to rotate the screen, and eventually I'm going to have
|
|
|
|
to figure out how to use XInput as well to map the pen/pointer device,
|
|
|
|
so that I can use [Gimp](https://www.gimp.org/) and
|
|
|
|
[Krita](https://krita.org/en/) effectively.
|
|
|
|
|
|
|
|
My only observation so far is that, after having a run in with
|
|
|
|
`std::unique_ptr`, the ergonomics of Rust make me very happy indeed.
|
|
|
|
I can only hope the Rust/XCB interface adheres close enough to the C
|
|
|
|
version that the port is trivial.
|
|
|
|
|
|
|
|
## Credits
|
|
|
|
|
|
|
|
The original geometry detection algorithms that this script will use
|
|
|
|
were written by [Ayko
|
|
|
|
Poel](https://github.com/AykoPoel/surface3-scripts). My contribution
|
|
|
|
consists of more robust device and device driver identification
|
|
|
|
algorithms for the stylus and eraser, and a general modernization of
|
|
|
|
the transform algorithm.
|
|
|
|
|
|
|
|
## Requirements
|
2022-02-17 15:01:34 +00:00
|
|
|
|
|
|
|
This code has been tested with gcc-7.3, and should work on any
|
|
|
|
C++17-compliant compiler with the relevant standard library, and
|
|
|
|
obviously X Windows.
|
|
|
|
|
2022-02-25 01:03:29 +00:00
|
|
|
## Building
|
2022-02-24 23:59:43 +00:00
|
|
|
|
2022-02-25 01:03:29 +00:00
|
|
|
From the base directory of the project (not that there's much there):
|
2022-02-24 23:59:43 +00:00
|
|
|
|
2022-02-25 01:03:29 +00:00
|
|
|
``` shell
|
|
|
|
$ mkdir build
|
|
|
|
$ cd build
|
|
|
|
$ cmake ..
|
|
|
|
$ make
|
|
|
|
```
|
2022-02-17 15:01:34 +00:00
|
|
|
|
2022-02-25 01:03:29 +00:00
|
|
|
## License
|
2022-02-17 15:01:34 +00:00
|
|
|
|
2022-02-25 01:03:29 +00:00
|
|
|
This XRandR experiment is Copyright [Elf
|
|
|
|
M. Sternberg](https://elfsternberg.com) (c) 2019, and licensed with
|
|
|
|
the Mozilla Public License vers. 2.0. A copy of the license file is
|
|
|
|
included in the root folder.
|
2022-02-17 15:01:34 +00:00
|
|
|
|
2022-02-25 01:03:29 +00:00
|
|
|
## Code of Conduct
|
2022-02-17 15:01:34 +00:00
|
|
|
|
2022-02-25 01:03:29 +00:00
|
|
|
Don't be a douchebag. That is all.
|