Evidlo / remarkable_mouse

use your reMarkable as a graphics tablet
GNU General Public License v3.0
506 stars 48 forks source link

Support for older hardware #86

Open Esgeriath opened 11 months ago

Esgeriath commented 11 months ago

When I first lunched remouse I experienced massive but variable lag. Delay was fluctuating between barely noticeable and up to 2 seconds. I figured out that this was probably due to my old processor not being able to process input stream. I managed to get no lag with the cost of performance - I stopped processing 4 out of 5 mouse movements. Here's my code:

--- pynput.py   2023-10-13 10:30:57.464006570 +0200
+++ /home/esgeriath/.local/bin/pip/remarkable-mouse/lib/python3.11/site-packages/remarkable_mouse/pynput.py 2023-10-12 22:25:44.204987123 +0200
@@ -37,6 +37,7 @@
     x = y = 0

     stream = rm_inputs['pen']
+    counter = 0
     while True:
         try:
             data = stream.read(16)
@@ -61,6 +62,11 @@
                 mouse.release(Button.left)

         if codes[e_type][e_code] == 'SYN_REPORT':
+            if counter < 5:
+                counter += 1
+                continue
+
+            counter = 0
             mapped_x, mapped_y = remap(
                 x, y,
                 wacom_max_x, wacom_max_y,

Perhaps this could be added as a feature, with appropriate flag.