@@ -10,6 +10,9 @@ use std::collections::HashMap;
1010use std:: io:: Write ;
1111use std:: sync:: Arc ;
1212
13+ use crate :: device:: DeviceModel ;
14+ use crate :: embedded_assets:: get_uinput_module_data;
15+
1316pub type OptionMap = HashMap < String , String > ;
1417
1518pub fn svg_to_bitmap ( svg_data : & str , width : u32 , height : u32 ) -> Result < Vec < Vec < bool > > > {
@@ -89,6 +92,16 @@ pub fn option_or_env_fallback(
8992
9093pub fn setup_uinput ( ) -> Result < ( ) > {
9194 debug ! ( "Checking for uinput module" ) ;
95+
96+ // Use DeviceModel to detect the device type
97+ let device_model = DeviceModel :: detect ( ) ;
98+ info ! ( "Device model detected: {}" , device_model. name( ) ) ;
99+
100+ if device_model == DeviceModel :: Remarkable2 {
101+ info ! ( "Device is Remarkable2, skipping uinput module check and installation" ) ;
102+ return Ok ( ( ) ) ;
103+ }
104+
92105 // Check if uinput module is loaded by looking at the lsmod output
93106 let output = std:: process:: Command :: new ( "lsmod" )
94107 . output ( )
@@ -105,8 +118,7 @@ pub fn setup_uinput() -> Result<()> {
105118 }
106119
107120 let img_version = std:: env:: var ( "IMG_VERSION" . to_string ( ) )
108- . unwrap ( )
109- . to_string ( ) ;
121+ . unwrap_or_default ( ) ;
110122
111123 if img_version. is_empty ( ) {
112124 return Ok ( ( ) ) ;
@@ -118,10 +130,12 @@ pub fn setup_uinput() -> Result<()> {
118130 . collect :: < Vec < & str > > ( )
119131 . join ( "." ) ;
120132
121- let target_module_filename = format ! ( "rmpp/uinput-{short_version}.ko" ) ;
133+ // let target_module_filename = format!("rmpp/uinput-{short_version}.ko");
122134
123- let uinput_module_asset = crate :: AssetUtils :: get ( target_module_filename. as_str ( ) ) . unwrap ( ) ;
124- let raw_uinput_module_data = uinput_module_asset. data . as_ref ( ) ;
135+ // Use the function from embedded_assets module to get the module data
136+ let uinput_module_data = get_uinput_module_data ( & short_version)
137+ . expect ( & format ! ( "Uinput module for version {} not found" , short_version) ) ;
138+ let raw_uinput_module_data = uinput_module_data. as_slice ( ) ;
125139 let mut uinput_module_file = std:: fs:: File :: create ( "/tmp/uinput.ko" ) ?;
126140 uinput_module_file. write_all ( raw_uinput_module_data) ?;
127141 uinput_module_file. flush ( ) ?;
0 commit comments