Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b26ad41da7 | ||
|
|
bc84a130a4 | ||
|
|
3c663e1c0f | ||
|
|
05ef36545c | ||
|
|
ac32280a43 | ||
|
|
93c49ae446 | ||
|
|
15d40b6d16 | ||
|
|
c520d9f0e7 |
@@ -30,8 +30,8 @@ enum sc_mod {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum sc_action {
|
enum sc_action {
|
||||||
SC_ACTION_DOWN, // key or button pressed
|
SC_ACTION_DOWN = 1, // key or button pressed
|
||||||
SC_ACTION_UP, // key or button released
|
SC_ACTION_UP = 2, // key or button released
|
||||||
};
|
};
|
||||||
|
|
||||||
enum sc_keycode {
|
enum sc_keycode {
|
||||||
|
|||||||
+42
-29
@@ -174,72 +174,85 @@ input_manager_init(struct input_manager *im, struct controller *controller,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
send_keycode(struct controller *controller, enum android_keycode keycode,
|
send_keycode(struct controller *controller, enum android_keycode keycode,
|
||||||
enum sc_action action, const char *name) {
|
int actions, const char *name) {
|
||||||
// send DOWN event
|
// send DOWN event
|
||||||
struct control_msg msg;
|
struct control_msg msg;
|
||||||
msg.type = CONTROL_MSG_TYPE_INJECT_KEYCODE;
|
msg.type = CONTROL_MSG_TYPE_INJECT_KEYCODE;
|
||||||
msg.inject_keycode.action = action == SC_ACTION_DOWN
|
|
||||||
? AKEY_EVENT_ACTION_DOWN
|
|
||||||
: AKEY_EVENT_ACTION_UP;
|
|
||||||
msg.inject_keycode.keycode = keycode;
|
msg.inject_keycode.keycode = keycode;
|
||||||
msg.inject_keycode.metastate = 0;
|
msg.inject_keycode.metastate = 0;
|
||||||
msg.inject_keycode.repeat = 0;
|
msg.inject_keycode.repeat = 0;
|
||||||
|
|
||||||
if (!controller_push_msg(controller, &msg)) {
|
if (actions & SC_ACTION_DOWN) {
|
||||||
LOGW("Could not request 'inject %s'", name);
|
msg.inject_keycode.action = AKEY_EVENT_ACTION_DOWN;
|
||||||
return;
|
if (!controller_push_msg(controller, &msg)) {
|
||||||
|
LOGW("Could not request 'inject %s (DOWN)'", name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (actions & SC_ACTION_UP) {
|
||||||
|
msg.inject_keycode.action = AKEY_EVENT_ACTION_UP;
|
||||||
|
if (!controller_push_msg(controller, &msg)) {
|
||||||
|
LOGW("Could not request 'inject %s (UP)'", name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
action_home(struct controller *controller, enum sc_action action) {
|
action_home(struct controller *controller, int actions) {
|
||||||
send_keycode(controller, AKEYCODE_HOME, action, "HOME");
|
send_keycode(controller, AKEYCODE_HOME, actions, "HOME");
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
action_back(struct controller *controller, enum sc_action action) {
|
action_back(struct controller *controller, int actions) {
|
||||||
send_keycode(controller, AKEYCODE_BACK, action, "BACK");
|
send_keycode(controller, AKEYCODE_BACK, actions, "BACK");
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
action_app_switch(struct controller *controller, enum sc_action action) {
|
action_app_switch(struct controller *controller, int actions) {
|
||||||
send_keycode(controller, AKEYCODE_APP_SWITCH, action, "APP_SWITCH");
|
send_keycode(controller, AKEYCODE_APP_SWITCH, actions, "APP_SWITCH");
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
action_power(struct controller *controller, enum sc_action action) {
|
action_power(struct controller *controller, int actions) {
|
||||||
send_keycode(controller, AKEYCODE_POWER, action, "POWER");
|
send_keycode(controller, AKEYCODE_POWER, actions, "POWER");
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
action_volume_up(struct controller *controller, enum sc_action action) {
|
action_volume_up(struct controller *controller, int actions) {
|
||||||
send_keycode(controller, AKEYCODE_VOLUME_UP, action, "VOLUME_UP");
|
send_keycode(controller, AKEYCODE_VOLUME_UP, actions, "VOLUME_UP");
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
action_volume_down(struct controller *controller, enum sc_action action) {
|
action_volume_down(struct controller *controller, int actions) {
|
||||||
send_keycode(controller, AKEYCODE_VOLUME_DOWN, action, "VOLUME_DOWN");
|
send_keycode(controller, AKEYCODE_VOLUME_DOWN, actions, "VOLUME_DOWN");
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
action_menu(struct controller *controller, enum sc_action action) {
|
action_menu(struct controller *controller, int actions) {
|
||||||
send_keycode(controller, AKEYCODE_MENU, action, "MENU");
|
send_keycode(controller, AKEYCODE_MENU, actions, "MENU");
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn the screen on if it was off, press BACK otherwise
|
// turn the screen on if it was off, press BACK otherwise
|
||||||
// If the screen is off, it is turned on only on ACTION_DOWN
|
// If the screen is off, it is turned on only on ACTION_DOWN
|
||||||
static void
|
static void
|
||||||
press_back_or_turn_screen_on(struct controller *controller,
|
press_back_or_turn_screen_on(struct controller *controller, int actions) {
|
||||||
enum sc_action action) {
|
|
||||||
struct control_msg msg;
|
struct control_msg msg;
|
||||||
msg.type = CONTROL_MSG_TYPE_BACK_OR_SCREEN_ON;
|
msg.type = CONTROL_MSG_TYPE_BACK_OR_SCREEN_ON;
|
||||||
msg.back_or_screen_on.action = action == SC_ACTION_DOWN
|
|
||||||
? AKEY_EVENT_ACTION_DOWN
|
|
||||||
: AKEY_EVENT_ACTION_UP;
|
|
||||||
|
|
||||||
if (!controller_push_msg(controller, &msg)) {
|
if (actions & SC_ACTION_DOWN) {
|
||||||
LOGW("Could not request 'press back or turn screen on'");
|
msg.back_or_screen_on.action = AKEY_EVENT_ACTION_DOWN;
|
||||||
return;
|
if (!controller_push_msg(controller, &msg)) {
|
||||||
|
LOGW("Could not request 'press back or turn screen on'");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (actions & SC_ACTION_UP) {
|
||||||
|
msg.back_or_screen_on.action = AKEY_EVENT_ACTION_UP;
|
||||||
|
if (!controller_push_msg(controller, &msg)) {
|
||||||
|
LOGW("Could not request 'press back or turn screen on'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user