@@ -148,8 +148,25 @@ static int cdba_send_buf(int fd, int type, size_t len, const void *buf)
148148 return ret < 0 ? ret : 0 ;
149149}
150150
151+ static int cdba_send_key (int fd , int key , uint8_t state )
152+ {
153+ struct key_press press = {
154+ .key = key ,
155+ .state = state ,
156+ };
157+
158+ return cdba_send_buf (fd , MSG_KEY_PRESS , sizeof (press ), & press );
159+ }
160+
161+ static int cdba_toggle_key (int fd , int key , bool key_state [DEVICE_KEY_COUNT ])
162+ {
163+ key_state [key ] = !key_state [key ];
164+ return cdba_send_key (fd , key , key_state [key ]);
165+ }
166+
151167static int tty_callback (int * ssh_fds )
152168{
169+ static bool key_state [DEVICE_KEY_COUNT ];
153170 static const char ctrl_a = 0x1 ;
154171 static bool special ;
155172 char buf [32 ];
@@ -189,6 +206,18 @@ static int tty_callback(int *ssh_fds)
189206 case 'B' :
190207 cdba_send (ssh_fds [0 ], MSG_SEND_BREAK );
191208 break ;
209+ case 'o' :
210+ cdba_send_key (ssh_fds [0 ], DEVICE_KEY_POWER , KEY_PRESS_PULSE );
211+ break ;
212+ case 'O' :
213+ cdba_toggle_key (ssh_fds [0 ], DEVICE_KEY_POWER , key_state );
214+ break ;
215+ case 'f' :
216+ cdba_send_key (ssh_fds [0 ], DEVICE_KEY_FASTBOOT , KEY_PRESS_PULSE );
217+ break ;
218+ case 'F' :
219+ cdba_toggle_key (ssh_fds [0 ], DEVICE_KEY_FASTBOOT , key_state );
220+ break ;
192221 }
193222
194223 special = false;
0 commit comments