diff options
author | William Wilgus <wilgus.william@gmail.com> | 2022-02-25 23:50:38 -0500 |
---|---|---|
committer | William Wilgus <wilgus.william@gmail.com> | 2022-02-26 00:40:42 -0500 |
commit | 6b360d8b0401bf3337b1b4f70e0bf630abdc421b (patch) | |
tree | 5a3766ffaf124d8d601c6ef08735e71e1445c3ce /apps/action.c | |
parent | 887249671ce2d39e0e75bcab87a1cecefde7406b (diff) | |
download | rockbox-6b360d8b0401bf3337b1b4f70e0bf630abdc421b.tar.gz rockbox-6b360d8b0401bf3337b1b4f70e0bf630abdc421b.zip |
action.c keyremap clean-up add logf to core_keymap.c
move the remap out of the loop and eliminate a status flag
Change-Id: I9ab841037a8ea7dff736b452ff55e8242084af82
Diffstat (limited to 'apps/action.c')
-rw-r--r-- | apps/action.c | 85 |
1 files changed, 45 insertions, 40 deletions
diff --git a/apps/action.c b/apps/action.c index 3a4cc2ff64..9ef10936f2 100644 --- a/apps/action.c +++ b/apps/action.c | |||
@@ -70,7 +70,6 @@ static action_last_t action_last = | |||
70 | .wait_for_release = false, | 70 | .wait_for_release = false, |
71 | 71 | ||
72 | #ifndef DISABLE_ACTION_REMAP | 72 | #ifndef DISABLE_ACTION_REMAP |
73 | .check_remap = false, | ||
74 | .core_keymap = NULL, | 73 | .core_keymap = NULL, |
75 | #endif | 74 | #endif |
76 | 75 | ||
@@ -590,12 +589,8 @@ static inline int get_next_context(const struct button_mapping *items, int i) | |||
590 | */ | 589 | */ |
591 | static inline void action_code_lookup(action_last_t *last, action_cur_t *cur) | 590 | static inline void action_code_lookup(action_last_t *last, action_cur_t *cur) |
592 | { | 591 | { |
593 | int action = ACTION_NONE; | 592 | int action, i; |
594 | int context = cur->context; | 593 | int context = cur->context; |
595 | int i = 0; | ||
596 | #ifndef DISABLE_ACTION_REMAP | ||
597 | last->check_remap = (last->core_keymap != NULL); | ||
598 | #endif | ||
599 | cur->is_prebutton = false; | 594 | cur->is_prebutton = false; |
600 | 595 | ||
601 | #ifdef HAVE_LOCKED_ACTIONS | 596 | #ifdef HAVE_LOCKED_ACTIONS |
@@ -605,49 +600,55 @@ static inline void action_code_lookup(action_last_t *last, action_cur_t *cur) | |||
605 | context |= CONTEXT_LOCKED; | 600 | context |= CONTEXT_LOCKED; |
606 | #endif | 601 | #endif |
607 | 602 | ||
608 | for(;;) | ||
609 | { | ||
610 | /* logf("context = %x",context); */ | ||
611 | #if (BUTTON_REMOTE != 0) | ||
612 | if ((cur->button & BUTTON_REMOTE) != 0) | ||
613 | { | ||
614 | context |= CONTEXT_REMOTE; | ||
615 | } | ||
616 | #endif | ||
617 | |||
618 | if ((context & CONTEXT_PLUGIN) && cur->get_context_map) | ||
619 | { | ||
620 | cur->items = cur->get_context_map(context); | ||
621 | } | ||
622 | #ifndef DISABLE_ACTION_REMAP | 603 | #ifndef DISABLE_ACTION_REMAP |
623 | else if(last->check_remap) /* attempt to look up the button in user supplied remap */ | 604 | bool check_remap = (last->core_keymap != NULL); |
605 | /* attempt to look up the button in user supplied remap */ | ||
606 | if(check_remap && (context & CONTEXT_PLUGIN) == 0) | ||
624 | { | 607 | { |
608 | #if 0 /*Disable the REMOTE context for remap for now (BUTTON_REMOTE != 0)*/ | ||
609 | if ((cur->button & BUTTON_REMOTE) != 0) | ||
610 | { | ||
611 | context |= CONTEXT_REMOTE; | ||
612 | } | ||
613 | #endif | ||
625 | cur->items = last->core_keymap; | 614 | cur->items = last->core_keymap; |
626 | i = 0; | 615 | i = 0; |
627 | action = ACTION_UNKNOWN; | 616 | action = ACTION_UNKNOWN; |
628 | /* check the lut at the beginning for the desired context */ | 617 | /* check the lut at the beginning for the desired context */ |
629 | while (cur->items[i].action_code != (int) CONTEXT_STOPSEARCHING) | 618 | while (cur->items[i].button_code != BUTTON_NONE) |
630 | { | 619 | { |
631 | if (cur->items[i].action_code == CORE_CONTEXT_REMAP(context)) | 620 | if (cur->items[i].action_code == CORE_CONTEXT_REMAP(context)) |
632 | { | 621 | { |
633 | i = cur->items[i].button_code; | 622 | i = cur->items[i].button_code; |
634 | action = action_code_worker(last, cur, &i); | 623 | action = action_code_worker(last, cur, &i); |
635 | break; | 624 | if (action != ACTION_UNKNOWN) |
625 | { | ||
626 | cur->action = action; | ||
627 | return; | ||
628 | } | ||
636 | } | 629 | } |
637 | i++; | 630 | i++; |
638 | } | 631 | } |
632 | } | ||
633 | #endif | ||
639 | 634 | ||
640 | if (action != ACTION_UNKNOWN) | 635 | i = 0; |
641 | break; | 636 | action = ACTION_NONE; |
642 | else | 637 | /* attempt to look up the button in the in-built keymaps */ |
643 | { | 638 | for(;;) |
644 | /* Not found -- fall through to inbuilt keymaps */ | 639 | { |
645 | i = 0; | 640 | /* logf("context = %x",context); */ |
646 | last->check_remap = false; | 641 | #if (BUTTON_REMOTE != 0) |
647 | cur->items = get_context_mapping(context); | 642 | if ((cur->button & BUTTON_REMOTE) != 0) |
648 | } | 643 | { |
644 | context |= CONTEXT_REMOTE; | ||
649 | } | 645 | } |
650 | #endif | 646 | #endif |
647 | |||
648 | if ((context & CONTEXT_PLUGIN) && cur->get_context_map) | ||
649 | { | ||
650 | cur->items = cur->get_context_map(context); | ||
651 | } | ||
651 | else | 652 | else |
652 | { | 653 | { |
653 | cur->items = get_context_mapping(context); | 654 | cur->items = get_context_mapping(context); |
@@ -1199,17 +1200,21 @@ int action_set_keymap(struct button_mapping* core_keymap, int count) | |||
1199 | if (count > 0 && core_keymap != NULL) /* saf-tey checks :) */ | 1200 | if (count > 0 && core_keymap != NULL) /* saf-tey checks :) */ |
1200 | { | 1201 | { |
1201 | int i = 0; | 1202 | int i = 0; |
1202 | if (core_keymap[count - 1].action_code != (int) CONTEXT_STOPSEARCHING || | 1203 | struct button_mapping* entry = &core_keymap[count - 1]; |
1203 | core_keymap[count - 1].button_code != BUTTON_NONE) /* check for sentinel at end*/ | 1204 | if (entry->action_code != (int) CONTEXT_STOPSEARCHING || |
1205 | entry->button_code != BUTTON_NONE) /* check for sentinel at end*/ | ||
1206 | { | ||
1204 | count = -1; | 1207 | count = -1; |
1208 | } | ||
1205 | 1209 | ||
1206 | /* check the lut at the beginning for invalid offsets */ | 1210 | while (count > 0 && /* check the lut at the beginning for invalid offsets */ |
1207 | while (count > 0 && core_keymap[i].action_code != (int) CONTEXT_STOPSEARCHING) | 1211 | (entry = &core_keymap[i])->action_code != (int) CONTEXT_STOPSEARCHING) |
1208 | { | 1212 | { |
1209 | if ((core_keymap[i].action_code & CONTEXT_REMAPPED) == CONTEXT_REMAPPED) | 1213 | |
1214 | if ((entry->action_code & CONTEXT_REMAPPED) == CONTEXT_REMAPPED) | ||
1210 | { | 1215 | { |
1211 | int firstbtn = core_keymap[i].button_code; | 1216 | int firstbtn = entry->button_code; |
1212 | int endpos = firstbtn + core_keymap[i].pre_button_code; | 1217 | int endpos = firstbtn + entry->pre_button_code; |
1213 | if (firstbtn > count || firstbtn < i || endpos > count) | 1218 | if (firstbtn > count || firstbtn < i || endpos > count) |
1214 | { | 1219 | { |
1215 | /* offset out of bounds */ | 1220 | /* offset out of bounds */ |
@@ -1217,7 +1222,7 @@ int action_set_keymap(struct button_mapping* core_keymap, int count) | |||
1217 | break; | 1222 | break; |
1218 | } | 1223 | } |
1219 | 1224 | ||
1220 | if (core_keymap[endpos].action_code != (int) CONTEXT_STOPSEARCHING) | 1225 | if (core_keymap[endpos].button_code != BUTTON_NONE) |
1221 | { | 1226 | { |
1222 | /* stop sentinel is not at end of action lut*/ | 1227 | /* stop sentinel is not at end of action lut*/ |
1223 | count = -3; | 1228 | count = -3; |