File tree 6 files changed +49
-0
lines changed
6 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ pub enum EcCommands {
60
60
FlashNotified = 0x3E01 ,
61
61
/// Change charge limit
62
62
ChargeLimitControl = 0x3E03 ,
63
+ DisablePs2Emulation = 0x3E08 ,
63
64
/// Get/Set Fingerprint LED brightness
64
65
FpLedLevelControl = 0x3E0E ,
65
66
/// 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 {
1048
1048
/// TODO: Use this
1049
1049
pub const EC_CHARGE_LIMIT_RESTORE : u8 = 0x7F ;
1050
1050
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
+
1051
1062
#[ repr( u8 ) ]
1052
1063
#[ derive( Debug , FromPrimitive ) ]
1053
1064
pub enum FpLedBrightnessLevel {
Original file line number Diff line number Diff line change @@ -596,6 +596,13 @@ impl CrosEc {
596
596
Ok ( ( kblight. duty / ( PWM_MAX_DUTY / 100 ) ) as u8 )
597
597
}
598
598
599
+ pub fn ps2_emulation_enable ( & self , enable : bool ) -> EcResult < ( ) > {
600
+ EcRequestDisablePs2Emulation {
601
+ disable : !enable as u8 ,
602
+ }
603
+ . send_command ( self )
604
+ }
605
+
599
606
pub fn fan_set_rpm ( & self , fan : Option < u32 > , rpm : u32 ) -> EcResult < ( ) > {
600
607
if let Some ( fan_idx) = fan {
601
608
EcRequestPwmSetFanTargetRpmV1 { rpm, fan_idx } . send_command ( self )
Original file line number Diff line number Diff line change @@ -188,6 +188,11 @@ struct ClapCli {
188
188
#[ arg( long, value_parser=maybe_hex:: <u64 >) ]
189
189
rgbkbd : Vec < u64 > ,
190
190
191
+ /// Enable/disable PS2 touchpad emulation
192
+ #[ clap( value_enum) ]
193
+ #[ arg( long) ]
194
+ ps2_enable : Option < bool > ,
195
+
191
196
/// Set tablet mode override
192
197
#[ clap( value_enum) ]
193
198
#[ arg( long) ]
@@ -393,6 +398,7 @@ pub fn parse(args: &[String]) -> Cli {
393
398
fp_brightness : args. fp_brightness ,
394
399
kblight : args. kblight ,
395
400
rgbkbd : args. rgbkbd ,
401
+ ps2_enable : args. ps2_enable ,
396
402
tablet_mode : args. tablet_mode ,
397
403
touchscreen_enable : args. touchscreen_enable ,
398
404
stylus_battery : args. stylus_battery ,
Original file line number Diff line number Diff line change @@ -182,6 +182,7 @@ pub struct Cli {
182
182
pub fp_brightness : Option < Option < u8 > > ,
183
183
pub kblight : Option < Option < u8 > > ,
184
184
pub rgbkbd : Vec < u64 > ,
185
+ pub ps2_enable : Option < bool > ,
185
186
pub tablet_mode : Option < TabletModeArg > ,
186
187
pub touchscreen_enable : Option < bool > ,
187
188
pub stylus_battery : bool ,
@@ -819,6 +820,8 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
819
820
} ) ;
820
821
ec. rgbkbd_set_color ( start_key, colors. collect ( ) ) . unwrap ( ) ;
821
822
}
823
+ } else if let Some ( enable) = args. ps2_enable {
824
+ print_err ( ec. ps2_emulation_enable ( enable) ) ;
822
825
} else if let Some ( None ) = args. kblight {
823
826
print ! ( "Keyboard backlight: " ) ;
824
827
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 {
95
95
fp_brightness : None ,
96
96
kblight : None ,
97
97
rgbkbd : vec ! [ ] ,
98
+ ps2_enable : None ,
98
99
tablet_mode : None ,
99
100
touchscreen_enable : None ,
100
101
stylus_battery : false ,
@@ -361,6 +362,26 @@ pub fn parse(args: &[String]) -> Cli {
361
362
println ! ( "--rgbkbd requires at least 2 arguments, the start key and an RGB value" ) ;
362
363
vec ! [ ]
363
364
}
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 ;
364
385
} else if arg == "--tablet-mode" {
365
386
cli. tablet_mode = if args. len ( ) > i + 1 {
366
387
let tablet_mode_arg = & args[ i + 1 ] ;
You can’t perform that action at this time.
0 commit comments