@@ -8,8 +8,8 @@ use std::time::Duration;
88use crate :: device:: DeviceModel ;
99
1010// Output dimensions remain the same for both devices
11- const REMARKABLE_WIDTH : u16 = 768 ;
12- const REMARKABLE_HEIGHT : u16 = 1024 ;
11+ const VIRTUAL_WIDTH : u16 = 768 ;
12+ const VIRTUAL_HEIGHT : u16 = 1024 ;
1313
1414// Event codes
1515const ABS_MT_SLOT : u16 = 47 ;
@@ -72,7 +72,7 @@ impl Touch {
7272 }
7373 if event. code ( ) == ABS_MT_TRACKING_ID {
7474 if event. value ( ) == -1 {
75- let ( x, y) = self . input_to_screen ( ( position_x, position_y) ) ;
75+ let ( x, y) = self . input_to_virtual ( ( position_x, position_y) ) ;
7676 debug ! ( "Touch release detected at ({}, {}) normalized ({}, {})" , position_x, position_y, x, y) ;
7777 if x > 700 && y < 25 {
7878 debug ! ( "Touch release in target zone!" ) ;
@@ -85,7 +85,7 @@ impl Touch {
8585 }
8686
8787 pub fn touch_start ( & mut self , xy : ( i32 , i32 ) ) -> Result < ( ) > {
88- let ( x, y) = self . screen_to_input ( xy) ;
88+ let ( x, y) = self . virtual_to_input ( xy) ;
8989 if let Some ( device) = & mut self . device {
9090 trace ! ( "touch_start at ({}, {})" , x, y) ;
9191 // sleep(Duration::from_millis(100));
@@ -119,7 +119,7 @@ impl Touch {
119119 }
120120
121121 pub fn goto_xy ( & mut self , xy : ( i32 , i32 ) ) -> Result < ( ) > {
122- let ( x, y) = self . screen_to_input ( xy) ;
122+ let ( x, y) = self . virtual_to_input ( xy) ;
123123 if let Some ( device) = & mut self . device {
124124 device. send_events ( & [
125125 InputEvent :: new ( EventType :: ABSOLUTE , ABS_MT_SLOT , 0 ) ,
@@ -157,10 +157,10 @@ impl Touch {
157157 }
158158 }
159159
160- fn screen_to_input ( & self , ( x, y) : ( i32 , i32 ) ) -> ( i32 , i32 ) {
160+ fn virtual_to_input ( & self , ( x, y) : ( i32 , i32 ) ) -> ( i32 , i32 ) {
161161 // Swap and normalize the coordinates
162- let x_normalized = x as f32 / REMARKABLE_WIDTH as f32 ;
163- let y_normalized = y as f32 / REMARKABLE_HEIGHT as f32 ;
162+ let x_normalized = x as f32 / VIRTUAL_WIDTH as f32 ;
163+ let y_normalized = y as f32 / VIRTUAL_HEIGHT as f32 ;
164164
165165 match self . device_model {
166166 DeviceModel :: RemarkablePaperPro => {
@@ -177,21 +177,21 @@ impl Touch {
177177 }
178178 }
179179
180- fn input_to_screen ( & self , ( x, y) : ( i32 , i32 ) ) -> ( i32 , i32 ) {
180+ fn input_to_virtual ( & self , ( x, y) : ( i32 , i32 ) ) -> ( i32 , i32 ) {
181181 // Swap and normalize the coordinates
182182 let x_normalized = x as f32 / self . screen_width ( ) as f32 ;
183183 let y_normalized = y as f32 / self . screen_height ( ) as f32 ;
184184
185185 match self . device_model {
186186 DeviceModel :: RemarkablePaperPro => {
187- let x_input = ( x_normalized * REMARKABLE_WIDTH as f32 ) as i32 ;
188- let y_input = ( y_normalized * REMARKABLE_HEIGHT as f32 ) as i32 ;
187+ let x_input = ( x_normalized * VIRTUAL_WIDTH as f32 ) as i32 ;
188+ let y_input = ( y_normalized * VIRTUAL_HEIGHT as f32 ) as i32 ;
189189 ( x_input, y_input)
190190 }
191191 _ => {
192192 // RM2 coordinate transformation
193- let x_input = ( x_normalized * REMARKABLE_WIDTH as f32 ) as i32 ;
194- let y_input = ( ( 1.0 - y_normalized) * REMARKABLE_HEIGHT as f32 ) as i32 ;
193+ let x_input = ( x_normalized * VIRTUAL_WIDTH as f32 ) as i32 ;
194+ let y_input = ( ( 1.0 - y_normalized) * VIRTUAL_HEIGHT as f32 ) as i32 ;
195195 ( x_input, y_input)
196196 }
197197 }
0 commit comments