mirror of
https://github.com/linux-msm/cdba.git
synced 2026-02-25 13:11:56 -08:00
Add special keys to allow triggering power and fastboot key presses from the cdba client. There is an option to send a short key "pulse" (press followed by release after 100ms) or to press/release keys separately: - ctrl+a -> o: Send power key pulse - ctrl+a -> O: Toggle power key (first use: press, next use: release) - ctrl+a -> f: Send fastboot key pulse - ctrl+a -> F: Toggle fastboot key (first use: press, next use: release) In most cases you want to send the "pulse" (short key press), so it's helpful to have this mapped to a single key. This avoids forgetting to release the key again after pressing it. The protocol between CDBA client and server is: (MSG_KEY_PRESS <key:u8, state:u8>) where key is either DEVICE_KEY_FASTBOOT (0) or DEVICE_KEY_POWER (1) and state is either KEY_PRESS_RELEASE (0), KEY_PRESS_PRESS (1) or KEY_PRESS_PULSE (2). The reason for implementing the "pulse" on the server side is that it's hard to guarantee the timing on the client side. We don't know exactly when the packets will arrive on the server. Also, "state" is a full byte anyway, so might as well use some of the extra bits. :-)
55 lines
792 B
C
55 lines
792 B
C
#ifndef __CDBA_H__
|
|
#define __CDBA_H__
|
|
|
|
#include <stdint.h>
|
|
|
|
#define __packed __attribute__((packed))
|
|
|
|
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
|
#define MAX(x, y) ((x) > (y) ? (x) : (y))
|
|
|
|
struct msg {
|
|
uint8_t type;
|
|
uint16_t len;
|
|
uint8_t data[];
|
|
} __packed;
|
|
|
|
enum {
|
|
MSG_SELECT_BOARD = 1,
|
|
MSG_CONSOLE,
|
|
MSG_HARDRESET,
|
|
MSG_POWER_ON,
|
|
MSG_POWER_OFF,
|
|
MSG_FASTBOOT_PRESENT,
|
|
MSG_FASTBOOT_DOWNLOAD,
|
|
MSG_FASTBOOT_BOOT,
|
|
MSG_STATUS_UPDATE,
|
|
MSG_VBUS_ON,
|
|
MSG_VBUS_OFF,
|
|
MSG_FASTBOOT_REBOOT,
|
|
MSG_SEND_BREAK,
|
|
MSG_LIST_DEVICES,
|
|
MSG_BOARD_INFO,
|
|
MSG_FASTBOOT_CONTINUE,
|
|
MSG_KEY_PRESS,
|
|
};
|
|
|
|
struct key_press {
|
|
uint8_t key;
|
|
uint8_t state;
|
|
} __packed;
|
|
|
|
enum {
|
|
DEVICE_KEY_FASTBOOT,
|
|
DEVICE_KEY_POWER,
|
|
DEVICE_KEY_COUNT
|
|
};
|
|
|
|
enum {
|
|
KEY_PRESS_RELEASE,
|
|
KEY_PRESS_PRESS,
|
|
KEY_PRESS_PULSE,
|
|
};
|
|
|
|
#endif
|