Skip to content

Display and control your Android device

Rename SC_MOD_* to SC_SHORTCUT_MOD_*

Romain Vimontd540c72e7cbf
diff --git a/app/src/cli.c b/app/src/cli.c
index 5b727fff..ec53e5ec 100644
--- a/app/src/cli.c
+++ b/app/src/cli.c
@@ -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")
-// 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
parse_shortcut_mods_item(const char *item, size_t len) {
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))
if (STREQ("lctrl", item, key_len)) {
- mod |= SC_MOD_LCTRL;
+ mod |= SC_SHORTCUT_MOD_LCTRL;
} else if (STREQ("rctrl", item, key_len)) {
- mod |= SC_MOD_RCTRL;
+ mod |= SC_SHORTCUT_MOD_RCTRL;
} else if (STREQ("lalt", item, key_len)) {
- mod |= SC_MOD_LALT;
+ mod |= SC_SHORTCUT_MOD_LALT;
} else if (STREQ("ralt", item, key_len)) {
- mod |= SC_MOD_RALT;
+ mod |= SC_SHORTCUT_MOD_RALT;
} else if (STREQ("lsuper", item, key_len)) {
- mod |= SC_MOD_LSUPER;
+ mod |= SC_SHORTCUT_MOD_LSUPER;
} else if (STREQ("rsuper", item, key_len)) {
- mod |= SC_MOD_RSUPER;
+ mod |= SC_SHORTCUT_MOD_RSUPER;
} else {
LOGE("Unknown modifier key: %.*s "
"(must be one of: lctrl, rctrl, lalt, ralt, lsuper, rsuper)",
diff --git a/app/src/input_manager.c b/app/src/input_manager.c
index 7230414a..0688dcab 100644
--- a/app/src/input_manager.c
+++ b/app/src/input_manager.c
@@ -13,24 +13,24 @@ enum sc_action {
#define SC_SDL_SHORTCUT_MODS_MASK (KMOD_CTRL | KMOD_ALT | KMOD_GUI)
static inline uint16_t
-to_sdl_mod(unsigned mod) {
+to_sdl_mod(unsigned shortcut_mod) {
uint16_t sdl_mod = 0;
- if (mod & SC_MOD_LCTRL) {
+ if (shortcut_mod & SC_SHORTCUT_MOD_LCTRL) {
sdl_mod |= KMOD_LCTRL;
}
- if (mod & SC_MOD_RCTRL) {
+ if (shortcut_mod & SC_SHORTCUT_MOD_RCTRL) {
sdl_mod |= KMOD_RCTRL;
}
- if (mod & SC_MOD_LALT) {
+ if (shortcut_mod & SC_SHORTCUT_MOD_LALT) {
sdl_mod |= KMOD_LALT;
}
- if (mod & SC_MOD_RALT) {
+ if (shortcut_mod & SC_SHORTCUT_MOD_RALT) {
sdl_mod |= KMOD_RALT;
}
- if (mod & SC_MOD_LSUPER) {
+ if (shortcut_mod & SC_SHORTCUT_MOD_LSUPER) {
sdl_mod |= KMOD_LGUI;
}
- if (mod & SC_MOD_RSUPER) {
+ if (shortcut_mod & SC_SHORTCUT_MOD_RSUPER) {
sdl_mod |= KMOD_RGUI;
}
return sdl_mod;
diff --git a/app/src/options.c b/app/src/options.c
index 4860fa07..7a5b71af 100644
--- a/app/src/options.c
+++ b/app/src/options.c
@@ -22,7 +22,7 @@ const struct scrcpy_options scrcpy_options_default = {
.tunnel_host = 0,
.tunnel_port = 0,
.shortcut_mods = {
- .data = {SC_MOD_LALT, SC_MOD_LSUPER},
+ .data = {SC_SHORTCUT_MOD_LALT, SC_SHORTCUT_MOD_LSUPER},
.count = 2,
},
.max_size = 0,
diff --git a/app/src/options.h b/app/src/options.h
index 39703210..533f4a3b 100644
--- a/app/src/options.h
+++ b/app/src/options.h
@@ -55,12 +55,12 @@ enum sc_key_inject_mode {
#define SC_MAX_SHORTCUT_MODS 8
enum sc_shortcut_mod {
- SC_MOD_LCTRL = 1 << 0,
- SC_MOD_RCTRL = 1 << 1,
- SC_MOD_LALT = 1 << 2,
- SC_MOD_RALT = 1 << 3,
- SC_MOD_LSUPER = 1 << 4,
- SC_MOD_RSUPER = 1 << 5,
+ SC_SHORTCUT_MOD_LCTRL = 1 << 0,
+ SC_SHORTCUT_MOD_RCTRL = 1 << 1,
+ SC_SHORTCUT_MOD_LALT = 1 << 2,
+ SC_SHORTCUT_MOD_RALT = 1 << 3,
+ SC_SHORTCUT_MOD_LSUPER = 1 << 4,
+ SC_SHORTCUT_MOD_RSUPER = 1 << 5,
};
struct sc_shortcut_mods {
diff --git a/app/tests/test_cli.c b/app/tests/test_cli.c
index a29d5fdd..5ea54b7f 100644
--- a/app/tests/test_cli.c
+++ b/app/tests/test_cli.c
@@ -129,25 +129,26 @@ static void test_parse_shortcut_mods(void) {
ok = sc_parse_shortcut_mods("lctrl", &mods);
assert(ok);
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);
assert(ok);
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);
assert(ok);
assert(mods.count == 2);
- assert(mods.data[0] == SC_MOD_RCTRL);
- assert(mods.data[1] == SC_MOD_LALT);
+ assert(mods.data[0] == SC_SHORTCUT_MOD_RCTRL);
+ assert(mods.data[1] == SC_SHORTCUT_MOD_LALT);
ok = sc_parse_shortcut_mods("lsuper,rsuper+lalt,lctrl+rctrl+ralt", &mods);
assert(ok);
assert(mods.count == 3);
- assert(mods.data[0] == SC_MOD_LSUPER);
- assert(mods.data[1] == (SC_MOD_RSUPER | SC_MOD_LALT));
- assert(mods.data[2] == (SC_MOD_LCTRL | SC_MOD_RCTRL | SC_MOD_RALT));
+ assert(mods.data[0] == SC_SHORTCUT_MOD_LSUPER);
+ assert(mods.data[1] == (SC_SHORTCUT_MOD_RSUPER | SC_SHORTCUT_MOD_LALT));
+ assert(mods.data[2] == (SC_SHORTCUT_MOD_LCTRL | SC_SHORTCUT_MOD_RCTRL |
+ SC_SHORTCUT_MOD_RALT));
ok = sc_parse_shortcut_mods("", &mods);
assert(!ok);