Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Support for remarkable paper pro #92

Open
danimateos opened this issue Oct 17, 2024 · 15 comments
Open

[Feature Request] Support for remarkable paper pro #92

danimateos opened this issue Oct 17, 2024 · 15 comments

Comments

@danimateos
Copy link

I got my remarkable paper pro yesterday and I love it... but I've realized that remarkable_mouse was a huge part of the value proposition of the remarkable 2 for me. I use as a digital whiteboard in lessons and it works great.

I've set up ssh access with the same key that I used for RM2 and it works fine.

when I try to use it as is with the RMPP I get the following error:

[dani@flecha:~] [base] % remouse --debug --key ~/.ssh/remarkable --address 10.11.99.1 
Debugging enabled...
Connecting to input '10.11.99.1'
Pen:/dev/input/event2
Touch:/dev/input/event2
Button:/dev/input/event0
Connected to 10.11.99.1
Chose monitor: Monitor(x=0, y=0, width=1680, height=1050, width_mm=None, height_mm=None, name=None, is_primary=True)
Screen size: (4240, 1050)
Chose monitor: Monitor(x=0, y=0, width=1680, height=1050, width_mm=None, height_mm=None, name=None, is_primary=True)
Traceback (most recent call last):
  File "/Users/dani/opt/mambaforge/bin/remouse", line 8, in <module>
    sys.exit(main())
  File "/Users/dani/opt/mambaforge/lib/python3.10/site-packages/remarkable_mouse/remarkable_mouse.py", line 170, in main
    read_tablet(
  File "/Users/dani/opt/mambaforge/lib/python3.10/site-packages/remarkable_mouse/pynput.py", line 49, in read_tablet
    if codes[e_type][e_code] == 'ABS_X':
KeyError: 65392

The KeyError is different in each run. I've gotten 220, 65392, and 29834 so far.

My naive hope is that it would be enough to update the codes.py dictionary... I have some Python experience so maybe I could help.

@Evidlo
Copy link
Owner

Evidlo commented Oct 17, 2024

Can you try again with the latest commit and this time with the --debug option? That should print out e_type, e_code, etc before the error occurs.

Those are also weirdly large numbers. The biggest e_type is 31 and e_code is 767. Those are defined by libevdev. Maybe the data isn't being unpacked correctly?

@danimateos
Copy link
Author

I cloned the repo and installed using python setup.py install. I got some fresh codes: 40898, 42550, 22872, 35596...

See below:

[dani@flecha:~/repos/remarkable_mouse] [remarkable_mouse] master 25s
± remouse --debug --key ~/.ssh/remarkable --address 10.11.99.1
Debugging enabled...
Connecting to input '10.11.99.1'
Pen:/dev/input/event2
Touch:/dev/input/event2
Button:/dev/input/event0
Connected to 10.11.99.1
Chose monitor: Monitor(x=0, y=0, width=1680, height=1050, width_mm=None, height_mm=None, name=None, is_primary=True)
Screen size: (1680, 1050)
Chose monitor: Monitor(x=0, y=0, width=1680, height=1050, width_mm=None, height_mm=None, name=None, is_primary=True)
Traceback (most recent call last):
  File "/Users/dani/opt/mambaforge/envs/remarkable_mouse/bin/remouse", line 33, in <module>
    sys.exit(load_entry_point('remarkable-mouse==7.1.1', 'console_scripts', 'remouse')())
  File "/Users/dani/opt/mambaforge/envs/remarkable_mouse/lib/python3.10/site-packages/remarkable_mouse-7.1.1-py3.10.egg/remarkable_mouse/remarkable_mouse.py", line 175, in main
  File "/Users/dani/opt/mambaforge/envs/remarkable_mouse/lib/python3.10/site-packages/remarkable_mouse-7.1.1-py3.10.egg/remarkable_mouse/pynput.py", line 49, in read_tablet
KeyError: 40898
[dani@flecha:~/repos/remarkable_mouse] [remarkable_mouse] master 8s 1
± remouse --debug --key ~/.ssh/remarkable --address 10.11.99.1
Debugging enabled...
Connecting to input '10.11.99.1'
Pen:/dev/input/event2
Touch:/dev/input/event2
Button:/dev/input/event0
Connected to 10.11.99.1
Chose monitor: Monitor(x=0, y=0, width=1680, height=1050, width_mm=None, height_mm=None, name=None, is_primary=True)
Screen size: (1680, 1050)
Chose monitor: Monitor(x=0, y=0, width=1680, height=1050, width_mm=None, height_mm=None, name=None, is_primary=True)
Traceback (most recent call last):
  File "/Users/dani/opt/mambaforge/envs/remarkable_mouse/bin/remouse", line 33, in <module>
    sys.exit(load_entry_point('remarkable-mouse==7.1.1', 'console_scripts', 'remouse')())
  File "/Users/dani/opt/mambaforge/envs/remarkable_mouse/lib/python3.10/site-packages/remarkable_mouse-7.1.1-py3.10.egg/remarkable_mouse/remarkable_mouse.py", line 175, in main
  File "/Users/dani/opt/mambaforge/envs/remarkable_mouse/lib/python3.10/site-packages/remarkable_mouse-7.1.1-py3.10.egg/remarkable_mouse/pynput.py", line 49, in read_tablet
KeyError: 42550
[dani@flecha:~/repos/remarkable_mouse] [remarkable_mouse] master 3s 1
± remouse --debug --key ~/.ssh/remarkable --address 10.11.99.1
Debugging enabled...
Connecting to input '10.11.99.1'
Pen:/dev/input/event2
Touch:/dev/input/event2
Button:/dev/input/event0
Connected to 10.11.99.1
Chose monitor: Monitor(x=0, y=0, width=1680, height=1050, width_mm=None, height_mm=None, name=None, is_primary=True)
Screen size: (1680, 1050)
Chose monitor: Monitor(x=0, y=0, width=1680, height=1050, width_mm=None, height_mm=None, name=None, is_primary=True)
Traceback (most recent call last):
  File "/Users/dani/opt/mambaforge/envs/remarkable_mouse/bin/remouse", line 33, in <module>
    sys.exit(load_entry_point('remarkable-mouse==7.1.1', 'console_scripts', 'remouse')())
  File "/Users/dani/opt/mambaforge/envs/remarkable_mouse/lib/python3.10/site-packages/remarkable_mouse-7.1.1-py3.10.egg/remarkable_mouse/remarkable_mouse.py", line 175, in main
  File "/Users/dani/opt/mambaforge/envs/remarkable_mouse/lib/python3.10/site-packages/remarkable_mouse-7.1.1-py3.10.egg/remarkable_mouse/pynput.py", line 49, in read_tablet
KeyError: 22872

@Evidlo
Copy link
Owner

Evidlo commented Oct 22, 2024

Can you log in to the tablet and run this command and paste the output here?

ls -l /dev/input/touchscreen0

Also in /dev/input there should be files like event0, event1, event2, ... that correspond to pen input, touch input, button input, etc.

For each one, can you do cat /dev/input/eventXXX to figure out what input it's associated with? It should show nothing until you touch the screen with stylus/finger or press a button (doesn't exist on rM pro?)

For example, on my rM1 I get this when I run cat /dev/input/event2 and touch the screen with my finger:

[root@reMarkable ~] cat /dev/input/event2
�$g�9
     �$g�5
          �$g�6T�$g�:��$g�4�$g��$g��	5
�$g��	6U�$g��	:_�$g��	4�$g��	�$gf�	�$gf�	6W�$gf�	:H�$gf�	4�$gf�	�$g�X
9�����$g�X
�$g�&5��$g�&6��$g�&:��$g�&4�$g�&�$guM5��$guM:~�$guM4�$guM�$g'w5��$g'w:|�$g'w1�$g'w4�$g'w�$g5��$g6��$g:z�$g0�$g4�$g�$g��5��$g��6��$g��:w�$g��1	�$g��4�$g���$g��5��$g��6��$g��:p�$g���$g^5��$g^6��$g^:j�$g^�$g}J5��$g}J6��$g}J:a�$g}J�$g�t5��$g�t6��$g�t:1�$g�t0	�$g�t4�$g�t�$g�9�����$g�^C

@locallium
Copy link

Greetings, thought I would hop in since I am having the same issue.
Tried doing the latest instructions for the events, this is what I got:

event0 -> power on/off button
event1 -> pen attach/detach
event2 -> stylus interaction (hovering/writing)
event3 -> hand interaction (touching the screen)

@Evidlo
Copy link
Owner

Evidlo commented Oct 23, 2024

@locallium

Thanks. What about these commands:

cat /sys/class/input/event*/device/capabilities/ev
ls -l /dev/input/touchscreen0

Also there's going to be some more work ahead to figure out the new coordinate mappings for all these inputs

  • min/max values for X and Y for touch and stylus inputs
  • coordinates positions relative to screen (e.g. on rm1 and rm2 +X for the stylus is down (towards the charge port), but something different for the touch input)

Once the --debug option is working it should be straightforward to figure this stuff out.

@danimateos
Copy link
Author

Thanks @Evidlo and @locallium !

$ cat /sys/class/input/event*/device/capabilities/ev
3
21
b
b

$ ls -l /dev/input/touchscreen0
lrwxrwxrwx    1 root     root             6 Oct 17 12:39 /dev/input/touchscreen0 -> event2

I'm available to do the remaining work that you mention. Thanks a lot for the responsiveness!!

@Evidlo
Copy link
Owner

Evidlo commented Oct 25, 2024

I've added the rmpro branch which should let you connect to the tablet and at least move the cursor around. It looks like the pen/touch coordinate systems on the Pro are not the same as rm1/rm2. We need to know the new mapping (use the --debug flag).

For example rm1/rm2 looks like this:

       TABLET COORDINATES

        PEN          TOUCH
    +---------+   +---------+
    | X       |   |       Y |
    | |       |   |       | |
    | |       |   |       | |
    | +--- Y  |   |  X ---+ |
    |         |   |         |
    |---------|   |---------|
    | USB PORT|   | USB PORT|
    +---------+   +---------+

@locallium
Copy link

Thanks to both of you!

Installed the new branch, it did let me connect. Unfortunately, it does not move the cursor. Also it throws the following error just as soon as I touch the screen with my finger.

Debugging enabled...
Connecting to input '10.11.99.1'
Password for '10.11.99.1':
Pen:/dev/input/event3
Touch:/dev/input/event2
Button:/dev/input/event0
Connected to 10.11.99.1
Chose monitor: Monitor(x=0, y=0, width=2560, height=1440, width_mm=597, height_mm=336, name='\\\\.\\DISPLAY1', is_primary=True)
Screen size: (5120, 1440)
Chose monitor: Monitor(x=0, y=0, width=2560, height=1440, width_mm=597, height_mm=336, name='\\\\.\\DISPLAY1', is_primary=True)
Traceback (most recent call last):
  File "C:\Users\lauri\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\lauri\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\lauri\AppData\Local\Programs\Python\Python310\Scripts\remouse.exe\__main__.py", line 7, in <module>
  File "C:\Users\lauri\AppData\Local\Programs\Python\Python310\lib\site-packages\remarkable_mouse\remarkable_mouse.py", line 175, in main
    read_tablet(
  File "C:\Users\lauri\AppData\Local\Programs\Python\Python310\lib\site-packages\remarkable_mouse\pynput.py", line 49, in read_tablet
    if codes[e_type][e_code] == 'ABS_X':
KeyError: 61892

I've noticed that the events are different, I'm not sure whether that changes anything, just something I've noticed 😅.
Running the previous command also outputs a different event from the one @danimateos had. Again, unsure whether that changes anything, but I just wanted to let you know.

$ ls -l /dev/input/touchscreen0
lrwxrwxrwx    1 root     root             6 Oct 25 23:07 /dev/input/touchscreen0 -> event3

@danimateos
Copy link
Author

Hi!

I checked out and installed the latest commit in the rmpro branch (click)
[dani@flecha:~] [base]
% cd repos/remarkable_mouse                                               ~ 11:10:21
[dani@flecha:~/repos/remarkable_mouse] [base] rmpro
± git pull                                         ~/repos/remarkable_mouse 11:10:24
Already up to date.
[dani@flecha:~/repos/remarkable_mouse] [base] rmpro 2s
± git checkout rmpro                               ~/repos/remarkable_mouse 11:10:35
Already on 'rmpro'
Your branch is up to date with 'origin/rmpro'.
[dani@flecha:~/repos/remarkable_mouse] [base] rmpro
± python setup.py install                          ~/repos/remarkable_mouse 11:10:38
running install
/Users/dani/opt/mambaforge/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/Users/dani/opt/mambaforge/lib/python3.10/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running bdist_egg
running egg_info
writing remarkable_mouse.egg-info/PKG-INFO
writing dependency_links to remarkable_mouse.egg-info/dependency_links.txt
writing entry points to remarkable_mouse.egg-info/entry_points.txt
writing requirements to remarkable_mouse.egg-info/requires.txt
writing top-level names to remarkable_mouse.egg-info/top_level.txt
reading manifest file 'remarkable_mouse.egg-info/SOURCES.txt'
adding license file 'LICENSE'
writing manifest file 'remarkable_mouse.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-11.0-arm64/egg
running install_lib
running build_py
creating build/bdist.macosx-11.0-arm64/egg
creating build/bdist.macosx-11.0-arm64/egg/remarkable_mouse
copying build/lib/remarkable_mouse/generate_codes.py -> build/bdist.macosx-11.0-arm64/egg/remarkable_mouse
copying build/lib/remarkable_mouse/version.py -> build/bdist.macosx-11.0-arm64/egg/remarkable_mouse
copying build/lib/remarkable_mouse/evdev.py -> build/bdist.macosx-11.0-arm64/egg/remarkable_mouse
copying build/lib/remarkable_mouse/codes.py -> build/bdist.macosx-11.0-arm64/egg/remarkable_mouse
copying build/lib/remarkable_mouse/__init__.py -> build/bdist.macosx-11.0-arm64/egg/remarkable_mouse
copying build/lib/remarkable_mouse/common.py -> build/bdist.macosx-11.0-arm64/egg/remarkable_mouse
copying build/lib/remarkable_mouse/pynput.py -> build/bdist.macosx-11.0-arm64/egg/remarkable_mouse
copying build/lib/remarkable_mouse/remarkable_mouse.py -> build/bdist.macosx-11.0-arm64/egg/remarkable_mouse
byte-compiling build/bdist.macosx-11.0-arm64/egg/remarkable_mouse/generate_codes.py to generate_codes.cpython-310.pyc
byte-compiling build/bdist.macosx-11.0-arm64/egg/remarkable_mouse/version.py to version.cpython-310.pyc
byte-compiling build/bdist.macosx-11.0-arm64/egg/remarkable_mouse/evdev.py to evdev.cpython-310.pyc
byte-compiling build/bdist.macosx-11.0-arm64/egg/remarkable_mouse/codes.py to codes.cpython-310.pyc
byte-compiling build/bdist.macosx-11.0-arm64/egg/remarkable_mouse/__init__.py to __init__.cpython-310.pyc
byte-compiling build/bdist.macosx-11.0-arm64/egg/remarkable_mouse/common.py to common.cpython-310.pyc
byte-compiling build/bdist.macosx-11.0-arm64/egg/remarkable_mouse/pynput.py to pynput.cpython-310.pyc
byte-compiling build/bdist.macosx-11.0-arm64/egg/remarkable_mouse/remarkable_mouse.py to remarkable_mouse.cpython-310.pyc
creating build/bdist.macosx-11.0-arm64/egg/EGG-INFO
copying remarkable_mouse.egg-info/PKG-INFO -> build/bdist.macosx-11.0-arm64/egg/EGG-INFO
copying remarkable_mouse.egg-info/SOURCES.txt -> build/bdist.macosx-11.0-arm64/egg/EGG-INFO
copying remarkable_mouse.egg-info/dependency_links.txt -> build/bdist.macosx-11.0-arm64/egg/EGG-INFO
copying remarkable_mouse.egg-info/entry_points.txt -> build/bdist.macosx-11.0-arm64/egg/EGG-INFO
copying remarkable_mouse.egg-info/requires.txt -> build/bdist.macosx-11.0-arm64/egg/EGG-INFO
copying remarkable_mouse.egg-info/top_level.txt -> build/bdist.macosx-11.0-arm64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/remarkable_mouse-7.1.1-py3.10.egg' and adding 'build/bdist.macosx-11.0-arm64/egg' to it
removing 'build/bdist.macosx-11.0-arm64/egg' (and everything under it)
Processing remarkable_mouse-7.1.1-py3.10.egg
Removing /Users/dani/opt/mambaforge/lib/python3.10/site-packages/remarkable_mouse-7.1.1-py3.10.egg
Copying remarkable_mouse-7.1.1-py3.10.egg to /Users/dani/opt/mambaforge/lib/python3.10/site-packages
remarkable-mouse 7.1.1 is already the active version in easy-install.pth
Installing remarkable-mouse script to /Users/dani/opt/mambaforge/bin
Installing remouse script to /Users/dani/opt/mambaforge/bin

Installed /Users/dani/opt/mambaforge/lib/python3.10/site-packages/remarkable_mouse-7.1.1-py3.10.egg
Processing dependencies for remarkable-mouse==7.1.1
Searching for screeninfo==0.8.1
Best match: screeninfo 0.8.1
Adding screeninfo 0.8.1 to easy-install.pth file

Using /Users/dani/opt/mambaforge/lib/python3.10/site-packages
Searching for pynput==1.7.6
Best match: pynput 1.7.6
Adding pynput 1.7.6 to easy-install.pth file

Using /Users/dani/opt/mambaforge/lib/python3.10/site-packages
Searching for libevdev==0.11
Best match: libevdev 0.11
Adding libevdev 0.11 to easy-install.pth file

Using /Users/dani/opt/mambaforge/lib/python3.10/site-packages
Searching for paramiko==3.1.0
Best match: paramiko 3.1.0
Adding paramiko 3.1.0 to easy-install.pth file

Using /Users/dani/opt/mambaforge/lib/python3.10/site-packages
Searching for pyobjc-framework-Cocoa==10.0
Best match: pyobjc-framework-Cocoa 10.0
Adding pyobjc-framework-Cocoa 10.0 to easy-install.pth file

Using /Users/dani/opt/mambaforge/lib/python3.10/site-packages
Searching for Cython==0.29.34
Best match: Cython 0.29.34
Adding Cython 0.29.34 to easy-install.pth file
Installing cygdb script to /Users/dani/opt/mambaforge/bin
Installing cython script to /Users/dani/opt/mambaforge/bin
Installing cythonize script to /Users/dani/opt/mambaforge/bin

Using /Users/dani/opt/mambaforge/lib/python3.10/site-packages
Searching for pyobjc-framework-Quartz==9.0.1
Best match: pyobjc-framework-Quartz 9.0.1
Adding pyobjc-framework-Quartz 9.0.1 to easy-install.pth file

Using /Users/dani/opt/mambaforge/lib/python3.10/site-packages
Searching for pyobjc-framework-ApplicationServices==9.0.1
Best match: pyobjc-framework-ApplicationServices 9.0.1
Adding pyobjc-framework-ApplicationServices 9.0.1 to easy-install.pth file

Using /Users/dani/opt/mambaforge/lib/python3.10/site-packages
Searching for six==1.16.0
Best match: six 1.16.0
Adding six 1.16.0 to easy-install.pth file

Using /Users/dani/opt/mambaforge/lib/python3.10/site-packages
Searching for PyNaCl==1.5.0
Best match: PyNaCl 1.5.0
Adding PyNaCl 1.5.0 to easy-install.pth file

Using /Users/dani/opt/mambaforge/lib/python3.10/site-packages
Searching for cryptography==41.0.4
Best match: cryptography 41.0.4
Adding cryptography 41.0.4 to easy-install.pth file

Using /Users/dani/opt/mambaforge/lib/python3.10/site-packages
Searching for bcrypt==4.0.1
Best match: bcrypt 4.0.1
Adding bcrypt 4.0.1 to easy-install.pth file

Using /Users/dani/opt/mambaforge/lib/python3.10/site-packages
Searching for pyobjc-core==10.0
Best match: pyobjc-core 10.0
Adding pyobjc-core 10.0 to easy-install.pth file

Using /Users/dani/opt/mambaforge/lib/python3.10/site-packages
Searching for cffi==1.16.0
Best match: cffi 1.16.0
Adding cffi 1.16.0 to easy-install.pth file

Using /Users/dani/opt/mambaforge/lib/python3.10/site-packages
Searching for pycparser==2.21
Best match: pycparser 2.21
Adding pycparser 2.21 to easy-install.pth file

Using /Users/dani/opt/mambaforge/lib/python3.10/site-packages
Finished processing dependencies for remarkable-mouse==7.1.1

Then, connected to the tablet and experimented a bit. Pen detach or finger touch don't seem to result in any reaction. Pen hover triggers a KeyError. The keys are high numbers, so far always above 4000 and below 65k.

I've got: 54003, 60124, 10755, 54520, 29203, 14673, 61016, 5351, 36373, 46999, 62710, 44749, 60108 and many more with no pattern that I can discern. Tried hovering over each corner and also could not tell any pattern.

Maybe we could capture the keyerror and log it to file so that we could generate many more keys to check statistically? I guess I could do that, will try to do it later today.

Click for details
[dani@flecha:~/repos/remarkable_mouse] [base] rmpro 4s 1
± remouse  --debug --key ~/.ssh/remarkable --address 10.11.99.1
Debugging enabled...
Connecting to input '10.11.99.1'
Pen:/dev/input/event2
Touch:/dev/input/event2
Button:/dev/input/event0
Connected to 10.11.99.1
Chose monitor: Monitor(x=0, y=0, width=1680, height=1050, width_mm=None, height_mm=None, name=None, is_primary=True)
Screen size: (1680, 1050)
Chose monitor: Monitor(x=0, y=0, width=1680, height=1050, width_mm=None, height_mm=None, name=None, is_primary=True)
Traceback (most recent call last):
  File "/Users/dani/opt/mambaforge/bin/remouse", line 33, in <module>
    sys.exit(load_entry_point('remarkable-mouse==7.1.1', 'console_scripts', 'remouse')())
  File "/Users/dani/opt/mambaforge/lib/python3.10/site-packages/remarkable_mouse/remarkable_mouse.py", line 170, in main
    read_tablet(
  File "/Users/dani/opt/mambaforge/lib/python3.10/site-packages/remarkable_mouse/pynput.py", line 49, in read_tablet
    if codes[e_type][e_code] == 'ABS_X':
KeyError: 54003
[dani@flecha:~/repos/remarkable_mouse] [base] rmpro 1
± remouse  --debug --key ~/.ssh/remarkable --address 10.11.99.1
Debugging enabled...
Connecting to input '10.11.99.1'
Pen:/dev/input/event2
Touch:/dev/input/event2
Button:/dev/input/event0
Connected to 10.11.99.1
Chose monitor: Monitor(x=0, y=0, width=1680, height=1050, width_mm=None, height_mm=None, name=None, is_primary=True)
Screen size: (1680, 1050)
Chose monitor: Monitor(x=0, y=0, width=1680, height=1050, width_mm=None, height_mm=None, name=None, is_primary=True)
Traceback (most recent call last):
  File "/Users/dani/opt/mambaforge/bin/remouse", line 33, in <module>
    sys.exit(load_entry_point('remarkable-mouse==7.1.1', 'console_scripts', 'remouse')())
  File "/Users/dani/opt/mambaforge/lib/python3.10/site-packages/remarkable_mouse/remarkable_mouse.py", line 170, in main
    read_tablet(
  File "/Users/dani/opt/mambaforge/lib/python3.10/site-packages/remarkable_mouse/pynput.py", line 49, in read_tablet
    if codes[e_type][e_code] == 'ABS_X':
KeyError: 60124
[dani@flecha:~/repos/remarkable_mouse] [base] rmpro 3s 1
± remouse  --debug --key ~/.ssh/remarkable --address 10.11.99.1
Debugging enabled...
Connecting to input '10.11.99.1'
Pen:/dev/input/event2
Touch:/dev/input/event2
Button:/dev/input/event0
Connected to 10.11.99.1
Chose monitor: Monitor(x=0, y=0, width=1680, height=1050, width_mm=None, height_mm=None, name=None, is_primary=True)
Screen size: (1680, 1050)
Chose monitor: Monitor(x=0, y=0, width=1680, height=1050, width_mm=None, height_mm=None, name=None, is_primary=True)
Traceback (most recent call last):
  File "/Users/dani/opt/mambaforge/bin/remouse", line 33, in <module>
    sys.exit(load_entry_point('remarkable-mouse==7.1.1', 'console_scripts', 'remouse')())
  File "/Users/dani/opt/mambaforge/lib/python3.10/site-packages/remarkable_mouse/remarkable_mouse.py", line 170, in main
    read_tablet(
  File "/Users/dani/opt/mambaforge/lib/python3.10/site-packages/remarkable_mouse/pynput.py", line 49, in read_tablet
    if codes[e_type][e_code] == 'ABS_X':
KeyError: 10755

Also run again the touchscreen ls to recheck:

[dani@flecha:~/repos/remarkable_mouse] [base] rmpro 8s 1
± ssh remarkable                                   ~/repos/remarkable_mouse 11:08:26
root@imx8mm-ferrari:~# ls -l /dev/input/touchscreen0
lrwxrwxrwx    1 root     root             6 Oct 17 12:39 /dev/input/touchscreen0 -> event2

@danimateos
Copy link
Author

I put a try/catch block inside the loop in read_tablet (see attached file) and redirected debug output. As long as it doesn't KeyError out, it recognizes the hover and moves the cursor! Then I did, in turn:

  • one full turn clockwise, starting and ending at the top left corner, hovering with the pen
  • one full turn clockwise, starting and ending at the top left corner, touching with the pen
  • one full turn clockwise, starting and ending at the top left corner, touching with the finger

The finger is not recognized.

pynput.py lines 77, 78

        except KeyError as e:
            log.debug(e)

debug logs.zip

@locallium
Copy link

Hello again! Thank you, @danimateos, very much for your contributions!

Updating the device fixed the touchscreen0 file, now I also get event2 and regarding that all works as it should (still getting KeyErrors on stylus interaction though).

Wanted to try your solution, but unfortunately I am having some issues. I don't really understand how exactly you incorporated the above code, I keep getting the Expected expression Pylance error, supposedly because it wants a try statement first. Anything else you've changed maybe?

Thanks!

@Evidlo
Copy link
Owner

Evidlo commented Oct 30, 2024

These errors are almost surely just because rm.pen_file is pointing to the wrong file in /dev/input/. For now I recommend

  1. hardcoding connect_rm to return reMarkablePro(client)
  2. editing the reMarkablePro class in common.py so that pen_file points to the right place.

I am currently working on detecting the right input files in a more robust way. In the meantime, the changes I suggested above should move things further along.

@Tiebe
Copy link

Tiebe commented Nov 7, 2024

@Evidlo

I did those steps, and while I do have the correct event files (checked using cat), I'm still getting errors. Using danimateos's steps works, although it misses clicks sometimes.

@Evidlo
Copy link
Owner

Evidlo commented Nov 10, 2024

I've wrapped the lookups in a try/except block. I'd really like to see the output of --debug now with the manually corrected input file paths.

[evan@blackbox remarkable_mouse] remouse --debug
Debugging enabled...
Connecting to input '10.11.99.1'
Detected reMarkable1
Pen:/dev/input/event0
Touch:/dev/input/event2
Button:/dev/input/event1
Connected to 10.11.99.1
Chose monitor: Monitor(x=0, y=0, width=1600, height=900, width_mm=309, height_mm=174, name='LVDS-1', is_primary=True)
Screen size: (1600, 900)
Chose monitor: Monitor(x=0, y=0, width=1600, height=900, width_mm=309, height_mm=174, name='LVDS-1', is_primary=True)
1731210050.756418 - EV_KEY    BTN_TOOL_PEN         1
1731210050.756418 - EV_ABS    ABS_X             1595
1731210050.756418 - EV_ABS    ABS_Y             7065
1731210050.756418 - EV_SYN    SYN_REPORT           0
1731210050.760058 - EV_ABS    ABS_X             1596
1731210050.760058 - EV_ABS    ABS_Y             7064
1731210050.760058 - EV_SYN    SYN_REPORT           0
1731210050.766462 - EV_ABS    ABS_X             1601
1731210050.766462 - EV_ABS    ABS_Y             7062
1731210050.766462 - EV_SYN    SYN_REPORT           0
1731210050.770096 - EV_ABS    ABS_X             1622
1731210050.770096 - EV_ABS    ABS_Y             7058
1731210050.770096 - EV_SYN    SYN_REPORT           0

Should also compare this to the output of evtest /dev/input/eventX (installable from toltec). Another person did this already and I don't see weirdly large evdev codes.

@locallium
Copy link

locallium commented Nov 11, 2024

Tried doing a clean Python update (supposed that something could have been wrong with the libraries), perhaps that could be the reason I am getting the following, though I have no idea:
Edit: No, the struct error does not seem to be caused by the reinstallation. I've installed an older commit of yours and it doesn't seem to throw one there.

Debugging enabled...
Connecting to input '10.11.99.1'
Password for '10.11.99.1':
Detected reMarkablePro
Pen:/dev/input/event2
Touch:/dev/input/event3
Button:/dev/input/event0
Connected to 10.11.99.1
Chose monitor: Monitor(x=0, y=0, width=2560, height=1440, width_mm=597, height_mm=336, name='\\\\.\\DISPLAY1', is_primary=True)
Screen size: (5120, 1440)
Chose monitor: Monitor(x=0, y=0, width=2560, height=1440, width_mm=597, height_mm=336, name='\\\\.\\DISPLAY1', is_primary=True)
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\lauri\AppData\Local\Programs\Python\Python313\Scripts\remouse.exe\__main__.py", line 7, in <module>
    sys.exit(main())
             ~~~~^^
  File "C:\Users\lauri\AppData\Local\Programs\Python\Python313\Lib\site-packages\remarkable_mouse\remarkable_mouse.py", line 175, in main
    read_tablet(
    ~~~~~~~~~~~^
        rm,
        ^^^
    ...<4 lines>...
        mode=args.mode,
        ^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\lauri\AppData\Local\Programs\Python\Python313\Lib\site-packages\remarkable_mouse\pynput.py", line 45, in read_tablet
    e_time, e_millis, e_type, e_code, e_value = struct.unpack('2IHHi', data)
                                                ~~~~~~~~~~~~~^^^^^^^^^^^^^^^
struct.error: unpack requires a buffer of 16 bytes

Completely no idea for the struct error, after some research - everything seems to be alright, the format and the input are both 16 bytes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants