File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ pub enum EcCommands {
6060 FlashNotified = 0x3E01 ,
6161 /// Change charge limit
6262 ChargeLimitControl = 0x3E03 ,
63+ DisablePs2Emulation = 0x3E08 ,
6364 /// Get/Set Fingerprint LED brightness
6465 FpLedLevelControl = 0x3E0E ,
6566 /// Get information about the current chassis open/close status
Original file line number Diff line number Diff line change @@ -1048,6 +1048,17 @@ impl EcRequest<EcResponseChargeLimitControl> for EcRequestChargeLimitControl {
10481048/// TODO: Use this
10491049pub const EC_CHARGE_LIMIT_RESTORE : u8 = 0x7F ;
10501050
1051+ #[ repr( C , packed) ]
1052+ pub struct EcRequestDisablePs2Emulation {
1053+ pub disable : u8 ,
1054+ }
1055+
1056+ impl EcRequest < ( ) > for EcRequestDisablePs2Emulation {
1057+ fn command_id ( ) -> EcCommands {
1058+ EcCommands :: DisablePs2Emulation
1059+ }
1060+ }
1061+
10511062#[ repr( u8 ) ]
10521063#[ derive( Debug , FromPrimitive ) ]
10531064pub enum FpLedBrightnessLevel {
Original file line number Diff line number Diff line change @@ -596,6 +596,13 @@ impl CrosEc {
596596 Ok ( ( kblight. duty / ( PWM_MAX_DUTY / 100 ) ) as u8 )
597597 }
598598
599+ pub fn ps2_emulation_enable ( & self , enable : bool ) -> EcResult < ( ) > {
600+ EcRequestDisablePs2Emulation {
601+ disable : !enable as u8 ,
602+ }
603+ . send_command ( self )
604+ }
605+
599606 pub fn fan_set_rpm ( & self , fan : Option < u32 > , rpm : u32 ) -> EcResult < ( ) > {
600607 if let Some ( fan_idx) = fan {
601608 EcRequestPwmSetFanTargetRpmV1 { rpm, fan_idx } . send_command ( self )
Original file line number Diff line number Diff line change @@ -188,6 +188,11 @@ struct ClapCli {
188188 #[ arg( long, value_parser=maybe_hex:: <u64 >) ]
189189 rgbkbd : Vec < u64 > ,
190190
191+ /// Enable/disable PS2 touchpad emulation
192+ #[ clap( value_enum) ]
193+ #[ arg( long) ]
194+ ps2_enable : Option < bool > ,
195+
191196 /// Set tablet mode override
192197 #[ clap( value_enum) ]
193198 #[ arg( long) ]
@@ -393,6 +398,7 @@ pub fn parse(args: &[String]) -> Cli {
393398 fp_brightness : args. fp_brightness ,
394399 kblight : args. kblight ,
395400 rgbkbd : args. rgbkbd ,
401+ ps2_enable : args. ps2_enable ,
396402 tablet_mode : args. tablet_mode ,
397403 touchscreen_enable : args. touchscreen_enable ,
398404 stylus_battery : args. stylus_battery ,
Original file line number Diff line number Diff line change @@ -182,6 +182,7 @@ pub struct Cli {
182182 pub fp_brightness : Option < Option < u8 > > ,
183183 pub kblight : Option < Option < u8 > > ,
184184 pub rgbkbd : Vec < u64 > ,
185+ pub ps2_enable : Option < bool > ,
185186 pub tablet_mode : Option < TabletModeArg > ,
186187 pub touchscreen_enable : Option < bool > ,
187188 pub stylus_battery : bool ,
@@ -819,6 +820,8 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
819820 } ) ;
820821 ec. rgbkbd_set_color ( start_key, colors. collect ( ) ) . unwrap ( ) ;
821822 }
823+ } else if let Some ( enable) = args. ps2_enable {
824+ print_err ( ec. ps2_emulation_enable ( enable) ) ;
822825 } else if let Some ( None ) = args. kblight {
823826 print ! ( "Keyboard backlight: " ) ;
824827 if let Some ( percentage) = print_err ( ec. get_keyboard_backlight ( ) ) {
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ pub fn parse(args: &[String]) -> Cli {
9595 fp_brightness : None ,
9696 kblight : None ,
9797 rgbkbd : vec ! [ ] ,
98+ ps2_enable : None ,
9899 tablet_mode : None ,
99100 touchscreen_enable : None ,
100101 stylus_battery : false ,
@@ -361,6 +362,26 @@ pub fn parse(args: &[String]) -> Cli {
361362 println ! ( "--rgbkbd requires at least 2 arguments, the start key and an RGB value" ) ;
362363 vec ! [ ]
363364 }
365+ } else if arg == "--ps2-enable" {
366+ cli. ps2_enable = if args. len ( ) > i + 1 {
367+ let enable_arg = & args[ i + 1 ] ;
368+ if enable_arg == "true" {
369+ Some ( true )
370+ } else if enable_arg == "false" {
371+ Some ( false )
372+ } else {
373+ println ! (
374+ "Need to provide a value for --ps2-enable: '{}'. {}" ,
375+ args[ i + 1 ] ,
376+ "Must be `true` or `false`" ,
377+ ) ;
378+ None
379+ }
380+ } else {
381+ println ! ( "Need to provide a value for --tablet-mode. One of: `auto`, `tablet` or `laptop`" ) ;
382+ None
383+ } ;
384+ found_an_option = true ;
364385 } else if arg == "--tablet-mode" {
365386 cli. tablet_mode = if args. len ( ) > i + 1 {
366387 let tablet_mode_arg = & args[ i + 1 ] ;
You can’t perform that action at this time.
0 commit comments