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 */