Rename SC_MOD_* to SC_SHORTCUT_MOD_*

This will avoid conflicts with new SC_MOD_* constants.
This commit is contained in:
Romain Vimont 2021-12-28 15:24:15 +01:00
parent cd5891fee6
commit d540c72e7c
5 changed files with 29 additions and 28 deletions

View file

@ -1118,7 +1118,7 @@ parse_log_level(const char *s, enum sc_log_level *log_level) {
} }
// item is a list of mod keys separated by '+' (e.g. "lctrl+lalt") // item is a list of mod keys separated by '+' (e.g. "lctrl+lalt")
// returns a bitwise-or of SC_MOD_* constants (or 0 on error) // returns a bitwise-or of SC_SHORTCUT_MOD_* constants (or 0 on error)
static unsigned static unsigned
parse_shortcut_mods_item(const char *item, size_t len) { parse_shortcut_mods_item(const char *item, size_t len) {
unsigned mod = 0; unsigned mod = 0;
@ -1136,17 +1136,17 @@ parse_shortcut_mods_item(const char *item, size_t len) {
((sizeof(literal)-1 == len) && !memcmp(literal, s, len)) ((sizeof(literal)-1 == len) && !memcmp(literal, s, len))
if (STREQ("lctrl", item, key_len)) { if (STREQ("lctrl", item, key_len)) {
mod |= SC_MOD_LCTRL; mod |= SC_SHORTCUT_MOD_LCTRL;
} else if (STREQ("rctrl", item, key_len)) { } else if (STREQ("rctrl", item, key_len)) {
mod |= SC_MOD_RCTRL; mod |= SC_SHORTCUT_MOD_RCTRL;
} else if (STREQ("lalt", item, key_len)) { } else if (STREQ("lalt", item, key_len)) {
mod |= SC_MOD_LALT; mod |= SC_SHORTCUT_MOD_LALT;
} else if (STREQ("ralt", item, key_len)) { } else if (STREQ("ralt", item, key_len)) {
mod |= SC_MOD_RALT; mod |= SC_SHORTCUT_MOD_RALT;
} else if (STREQ("lsuper", item, key_len)) { } else if (STREQ("lsuper", item, key_len)) {
mod |= SC_MOD_LSUPER; mod |= SC_SHORTCUT_MOD_LSUPER;
} else if (STREQ("rsuper", item, key_len)) { } else if (STREQ("rsuper", item, key_len)) {
mod |= SC_MOD_RSUPER; mod |= SC_SHORTCUT_MOD_RSUPER;
} else { } else {
LOGE("Unknown modifier key: %.*s " LOGE("Unknown modifier key: %.*s "
"(must be one of: lctrl, rctrl, lalt, ralt, lsuper, rsuper)", "(must be one of: lctrl, rctrl, lalt, ralt, lsuper, rsuper)",

View file

@ -13,24 +13,24 @@ enum sc_action {
#define SC_SDL_SHORTCUT_MODS_MASK (KMOD_CTRL | KMOD_ALT | KMOD_GUI) #define SC_SDL_SHORTCUT_MODS_MASK (KMOD_CTRL | KMOD_ALT | KMOD_GUI)
static inline uint16_t static inline uint16_t
to_sdl_mod(unsigned mod) { to_sdl_mod(unsigned shortcut_mod) {
uint16_t sdl_mod = 0; uint16_t sdl_mod = 0;
if (mod & SC_MOD_LCTRL) { if (shortcut_mod & SC_SHORTCUT_MOD_LCTRL) {
sdl_mod |= KMOD_LCTRL; sdl_mod |= KMOD_LCTRL;
} }
if (mod & SC_MOD_RCTRL) { if (shortcut_mod & SC_SHORTCUT_MOD_RCTRL) {
sdl_mod |= KMOD_RCTRL; sdl_mod |= KMOD_RCTRL;
} }
if (mod & SC_MOD_LALT) { if (shortcut_mod & SC_SHORTCUT_MOD_LALT) {
sdl_mod |= KMOD_LALT; sdl_mod |= KMOD_LALT;
} }
if (mod & SC_MOD_RALT) { if (shortcut_mod & SC_SHORTCUT_MOD_RALT) {
sdl_mod |= KMOD_RALT; sdl_mod |= KMOD_RALT;
} }
if (mod & SC_MOD_LSUPER) { if (shortcut_mod & SC_SHORTCUT_MOD_LSUPER) {
sdl_mod |= KMOD_LGUI; sdl_mod |= KMOD_LGUI;
} }
if (mod & SC_MOD_RSUPER) { if (shortcut_mod & SC_SHORTCUT_MOD_RSUPER) {
sdl_mod |= KMOD_RGUI; sdl_mod |= KMOD_RGUI;
} }
return sdl_mod; return sdl_mod;

View file

@ -22,7 +22,7 @@ const struct scrcpy_options scrcpy_options_default = {
.tunnel_host = 0, .tunnel_host = 0,
.tunnel_port = 0, .tunnel_port = 0,
.shortcut_mods = { .shortcut_mods = {
.data = {SC_MOD_LALT, SC_MOD_LSUPER}, .data = {SC_SHORTCUT_MOD_LALT, SC_SHORTCUT_MOD_LSUPER},
.count = 2, .count = 2,
}, },
.max_size = 0, .max_size = 0,

View file

@ -55,12 +55,12 @@ enum sc_key_inject_mode {
#define SC_MAX_SHORTCUT_MODS 8 #define SC_MAX_SHORTCUT_MODS 8
enum sc_shortcut_mod { enum sc_shortcut_mod {
SC_MOD_LCTRL = 1 << 0, SC_SHORTCUT_MOD_LCTRL = 1 << 0,
SC_MOD_RCTRL = 1 << 1, SC_SHORTCUT_MOD_RCTRL = 1 << 1,
SC_MOD_LALT = 1 << 2, SC_SHORTCUT_MOD_LALT = 1 << 2,
SC_MOD_RALT = 1 << 3, SC_SHORTCUT_MOD_RALT = 1 << 3,
SC_MOD_LSUPER = 1 << 4, SC_SHORTCUT_MOD_LSUPER = 1 << 4,
SC_MOD_RSUPER = 1 << 5, SC_SHORTCUT_MOD_RSUPER = 1 << 5,
}; };
struct sc_shortcut_mods { struct sc_shortcut_mods {

View file

@ -129,25 +129,26 @@ static void test_parse_shortcut_mods(void) {
ok = sc_parse_shortcut_mods("lctrl", &mods); ok = sc_parse_shortcut_mods("lctrl", &mods);
assert(ok); assert(ok);
assert(mods.count == 1); assert(mods.count == 1);
assert(mods.data[0] == SC_MOD_LCTRL); assert(mods.data[0] == SC_SHORTCUT_MOD_LCTRL);
ok = sc_parse_shortcut_mods("lctrl+lalt", &mods); ok = sc_parse_shortcut_mods("lctrl+lalt", &mods);
assert(ok); assert(ok);
assert(mods.count == 1); assert(mods.count == 1);
assert(mods.data[0] == (SC_MOD_LCTRL | SC_MOD_LALT)); assert(mods.data[0] == (SC_SHORTCUT_MOD_LCTRL | SC_SHORTCUT_MOD_LALT));
ok = sc_parse_shortcut_mods("rctrl,lalt", &mods); ok = sc_parse_shortcut_mods("rctrl,lalt", &mods);
assert(ok); assert(ok);
assert(mods.count == 2); assert(mods.count == 2);
assert(mods.data[0] == SC_MOD_RCTRL); assert(mods.data[0] == SC_SHORTCUT_MOD_RCTRL);
assert(mods.data[1] == SC_MOD_LALT); assert(mods.data[1] == SC_SHORTCUT_MOD_LALT);
ok = sc_parse_shortcut_mods("lsuper,rsuper+lalt,lctrl+rctrl+ralt", &mods); ok = sc_parse_shortcut_mods("lsuper,rsuper+lalt,lctrl+rctrl+ralt", &mods);
assert(ok); assert(ok);
assert(mods.count == 3); assert(mods.count == 3);
assert(mods.data[0] == SC_MOD_LSUPER); assert(mods.data[0] == SC_SHORTCUT_MOD_LSUPER);
assert(mods.data[1] == (SC_MOD_RSUPER | SC_MOD_LALT)); assert(mods.data[1] == (SC_SHORTCUT_MOD_RSUPER | SC_SHORTCUT_MOD_LALT));
assert(mods.data[2] == (SC_MOD_LCTRL | SC_MOD_RCTRL | SC_MOD_RALT)); assert(mods.data[2] == (SC_SHORTCUT_MOD_LCTRL | SC_SHORTCUT_MOD_RCTRL |
SC_SHORTCUT_MOD_RALT));
ok = sc_parse_shortcut_mods("", &mods); ok = sc_parse_shortcut_mods("", &mods);
assert(!ok); assert(!ok);