mirror of
https://github.com/Rockbox/rockbox.git
synced 2026-04-11 16:37:45 -04:00
FS#13824 - In keyremap plugin in "test keymap" context is wrong
The context was supplied with context|flag but expected context x flag Also fixes a bug where the user export doesn't show the correct save location if changed -- it still saved properly anyway.. Change-Id: I061d63e15475d2cb73d070737dc18d56d7800472
This commit is contained in:
parent
72969fee7e
commit
314becf2ac
1 changed files with 30 additions and 7 deletions
|
|
@ -582,7 +582,7 @@ static void keyremap_save_user_keys(bool notify)
|
|||
rb->splashf(HZ *2, "Saved %s", buf);
|
||||
}
|
||||
|
||||
static int keyremap_export_current(char *filenamebuf, size_t bufsz)
|
||||
static int keyremap_export_current(char *filenamebuf, size_t bufsz, const char *filename)
|
||||
{
|
||||
filenamebuf[bufsz - 1] = '\0';
|
||||
int i, j;
|
||||
|
|
@ -596,7 +596,7 @@ static int keyremap_export_current(char *filenamebuf, size_t bufsz)
|
|||
logf("%s: Not enough entries", __func__);
|
||||
return 0;
|
||||
}
|
||||
int fd = rb->open(filenamebuf, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
int fd = rb->open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
|
||||
if (fd < 0)
|
||||
return -1;
|
||||
|
|
@ -657,7 +657,8 @@ fail:
|
|||
static void keyremap_export_user_keys(void)
|
||||
{
|
||||
const bool notify = true;
|
||||
char buf[MAX_PATH];
|
||||
static char fnamebuf[MAX_PATH];
|
||||
static char buf[MAX_PATH];
|
||||
int i = 0;
|
||||
do
|
||||
{
|
||||
|
|
@ -670,14 +671,13 @@ static void keyremap_export_user_keys(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (keyremap_export_current(buf, sizeof(buf)) <= 0)
|
||||
if (keyremap_export_current(fnamebuf, sizeof(fnamebuf), buf) <= 0)
|
||||
{
|
||||
if(notify)
|
||||
rb->splash(HZ *2, "Error Saving");
|
||||
}
|
||||
else if (notify)
|
||||
{
|
||||
rb->snprintf(buf, sizeof(buf), "%s/%s%d%s", "", KMFUSER, i, ".txt");
|
||||
rb->splashf(HZ *2, "Saved %s", buf);
|
||||
}
|
||||
}
|
||||
|
|
@ -1085,6 +1085,24 @@ fail:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int context_encode_flags(int context)
|
||||
{
|
||||
int enctx = (context & 0xFF) % LAST_ACTION_PLACEHOLDER; /* strip flags */
|
||||
/* takes a context | flag and converts it to context x flag */
|
||||
for (int i = ARRAYLEN(context_flags) - 1; i > 0; i--) /* don't check idx 0*/
|
||||
{
|
||||
/* convert context | flag to context x flag */
|
||||
if ((context & context_flags[i].flag) == context_flags[i].flag)
|
||||
{
|
||||
logf("found ctx flag %s", context_flags[i].name);
|
||||
enctx &= ~context_flags[i].flag;
|
||||
enctx += i * LAST_CONTEXT_PLACEHOLDER;
|
||||
}
|
||||
}
|
||||
logf("%s in: %x out: %x\n", __func__, context, enctx);
|
||||
return enctx;
|
||||
}
|
||||
|
||||
static int keyremap_load_file(const char *filename)
|
||||
{
|
||||
logf("keyremap: load %s", filename);
|
||||
|
|
@ -1118,7 +1136,8 @@ static int keyremap_load_file(const char *filename)
|
|||
}
|
||||
if ((entry.action_code & CONTEXT_REMAPPED) == CONTEXT_REMAPPED)
|
||||
{
|
||||
int context = (entry.action_code & ~CONTEXT_REMAPPED);
|
||||
int context = context_encode_flags(entry.action_code & ~CONTEXT_REMAPPED);
|
||||
#if 0
|
||||
for (int i = ARRAYLEN(context_flags) - 1; i > 0; i--) /* don't check idx 0*/
|
||||
{
|
||||
/* convert context | flag to context x flag */
|
||||
|
|
@ -1129,6 +1148,7 @@ static int keyremap_load_file(const char *filename)
|
|||
context += i * LAST_CONTEXT_PLACEHOLDER;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
int offset = entry.button_code;
|
||||
int entries = entry.pre_button_code;
|
||||
if (offset == 0 || entries <= 0)
|
||||
|
|
@ -1346,7 +1366,10 @@ static const char *test_keymap_name_cb(int selected_item, void* data,
|
|||
if (keytest.context >= 0)
|
||||
{
|
||||
if (selected_item == 0)
|
||||
rb->snprintf(buf, buf_len, "< %s >", ctx_name_and_flag(keytest.context));
|
||||
{
|
||||
int ctx = context_encode_flags(keytest.context);
|
||||
rb->snprintf(buf, buf_len, "< %s >", ctx_name_and_flag(ctx));
|
||||
}
|
||||
else if (selected_item == 1)
|
||||
{
|
||||
if (keytest.countdown >= 10)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue