summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-07-20 21:13:37 +0100
committerAidan MacDonald <amachronic@protonmail.com>2021-07-20 21:30:55 +0100
commit966e210e6d699ba69c0f72a2661b0f6204293247 (patch)
tree72e969af704c35137e065da8696b9472e1297a1e
parent740a50687f67f3684e4b5698f8f30e3adebb8f6e (diff)
downloadrockbox-966e210e6d.tar.gz
rockbox-966e210e6d.tar.bz2
rockbox-966e210e6d.zip
Small fixes to kbd_create_layout
- Make the argument const since it's not actually mutated - Actually return the size of the buffer used since this is what it was supposed to do (although no existing callers cared anyway) Change-Id: I0802071cf63d4af419f427ff54adca50b14918ad
-rw-r--r--apps/plugins/lib/kbd_helper.c8
-rw-r--r--apps/plugins/lib/kbd_helper.h2
2 files changed, 7 insertions, 3 deletions
diff --git a/apps/plugins/lib/kbd_helper.c b/apps/plugins/lib/kbd_helper.c
index e3a844a993..f99282575d 100644
--- a/apps/plugins/lib/kbd_helper.c
+++ b/apps/plugins/lib/kbd_helper.c
@@ -34,11 +34,12 @@
* success returns size of buffer used
* failure returns 0
*/
-int kbd_create_layout(char *layout, unsigned short *buf, int bufsz)
+int kbd_create_layout(const char *layout, unsigned short *buf, int bufsz)
{
unsigned short *pbuf;
const unsigned char *p = layout;
int len = 0;
+ int total_len = 0;
pbuf = buf;
while (*p && (pbuf - buf + (ptrdiff_t) sizeof(unsigned short)) < bufsz)
{
@@ -47,6 +48,7 @@ int kbd_create_layout(char *layout, unsigned short *buf, int bufsz)
{
*pbuf = len;
pbuf += len+1;
+ total_len += len + 1;
len = 0;
}
else
@@ -57,7 +59,9 @@ int kbd_create_layout(char *layout, unsigned short *buf, int bufsz)
{
*pbuf = len;
pbuf[len+1] = 0xFEFF; /* mark end of characters */
- return len + 1;
+ total_len += len + 1;
+ return total_len * sizeof(unsigned short);
}
+
return 0;
}
diff --git a/apps/plugins/lib/kbd_helper.h b/apps/plugins/lib/kbd_helper.h
index 90443cbf3f..ee2ce7551c 100644
--- a/apps/plugins/lib/kbd_helper.h
+++ b/apps/plugins/lib/kbd_helper.h
@@ -22,6 +22,6 @@
#define KBD_HELPER_H
/* create a custom keyboard layout for kbd_input */
-int kbd_create_layout(char *layout, unsigned short *buf, int bufsz);
+int kbd_create_layout(const char *layout, unsigned short *buf, int bufsz);
#endif /* KBD_HELPER_H */