diff options
author | Mikkel Oscar Lyderik <mikkeloscar@gmail.com> | 2016-01-06 16:59:54 +0100 |
---|---|---|
committer | Mikkel Oscar Lyderik <mikkeloscar@gmail.com> | 2016-01-08 03:03:40 +0100 |
commit | dffacea831b6e7277920e885984d9c7c9b281d6c (patch) | |
tree | 197d392dce35d14db34f903f45a086722ee6fbdc /common/util.c | |
parent | 320c2915b0aeb4bbecb753bf00091e24905c5652 (diff) |
Add function for getting list of modifier names.
Get an array of modifier names from modifier masks.
Diffstat (limited to 'common/util.c')
-rw-r--r-- | common/util.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/common/util.c b/common/util.c index b5037d35..243f90a8 100644 --- a/common/util.c +++ b/common/util.c @@ -51,3 +51,17 @@ const char *get_modifier_name_by_mask(uint32_t modifier) { return NULL; } + +int get_modifier_names(const char **names, uint32_t modifier_masks) { + int length = 0; + int i; + for (i = 0; i < (int)(sizeof(modifiers) / sizeof(struct modifier_key)); ++i) { + if ((modifier_masks & modifiers[i].mod) != 0) { + names[length] = modifiers[i].name; + ++length; + modifier_masks ^= modifiers[i].mod; + } + } + + return length; +} |