From 23e7d0ef19dc82e39f249a4cd65ec797a6c06aba Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sat, 30 Sep 2017 20:50:33 -0400 Subject: xworld: support diagonal buttons on Zen X-Fi Change-Id: Ia738ecd2a39c0c0772d6f939d549dd5d0eda055e --- apps/plugins/lib/keymaps.h | 11 +++++++++++ apps/plugins/xworld/resource.c | 2 +- apps/plugins/xworld/sys.c | 6 +++--- apps/plugins/xworld/sys.h | 6 ++++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/apps/plugins/lib/keymaps.h b/apps/plugins/lib/keymaps.h index 84041cacd7..2c54aebccb 100644 --- a/apps/plugins/lib/keymaps.h +++ b/apps/plugins/lib/keymaps.h @@ -68,12 +68,23 @@ #define BTN_RIGHT BUTTON_RIGHT #if (CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD) +#define BTN_HAVE_DIAGONAL #define BTN_UP_LEFT BUTTON_BACK #define BTN_UP_RIGHT BUTTON_PLAYPAUSE #define BTN_DOWN_LEFT BUTTON_BOTTOMLEFT #define BTN_DOWN_RIGHT BUTTON_BOTTOMRIGHT #endif +/* X-Fi doesn't have a separate *_PAD macro */ +#ifdef CREATIVE_ZENXFI +#define BTN_HAVE_DIAGONAL +#define BTN_DOWN_LEFT BUTTON_BOTTOMLEFT +#define BTN_DOWN_RIGHT BUTTON_BOTTOMRIGHT +#define BTN_UP_LEFT BUTTON_TOPLEFT +#define BTN_UP_RIGHT BUTTON_TOPRIGHT +#endif + + #if (CONFIG_KEYPAD == HM60X_PAD) #define BTN_FIRE BUTTON_POWER #define BTN_PAUSE BUTTON_SELECT diff --git a/apps/plugins/xworld/resource.c b/apps/plugins/xworld/resource.c index 4bd93f0616..29b875f9af 100644 --- a/apps/plugins/xworld/resource.c +++ b/apps/plugins/xworld/resource.c @@ -371,7 +371,7 @@ void res_allocMemBlock(struct Resource* res) { res->sys->membuf = res->_memPtrStart + ( MEM_BLOCK_SIZE + (4 * VID_PAGE_SIZE) + 320 * 200 * sizeof(fb_data)); res->sys->bytes_left = sz - (MEM_BLOCK_SIZE + (4 * VID_PAGE_SIZE) + 320 * 200 * sizeof(fb_data)); - debug(DBG_RES, "audiobuf is %d bytes in size", sz); + debug(DBG_RES, "audiobuf is %d bytes in size (%d bytes left)", sz, res->sys->bytes_left); res->_scriptBakPtr = res->_scriptCurPtr = res->_memPtrStart; res->_vidBakPtr = res->_vidCurPtr = res->_memPtrStart + MEM_BLOCK_SIZE - 0x800 * 16; //0x800 = 2048, so we have 32KB free for vidBack and vidCur diff --git a/apps/plugins/xworld/sys.c b/apps/plugins/xworld/sys.c index 1a3d47d307..a240c75924 100644 --- a/apps/plugins/xworld/sys.c +++ b/apps/plugins/xworld/sys.c @@ -63,7 +63,7 @@ static void sys_rotate_keymap(struct System* sys) sys->keymap.down = BTN_DOWN; sys->keymap.left = BTN_LEFT; sys->keymap.right = BTN_RIGHT; -#if (CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD) +#ifdef BTN_HAVE_DIAGONAL sys->keymap.upleft = BTN_UP_LEFT; sys->keymap.upright = BTN_UP_RIGHT; sys->keymap.downleft = BTN_DOWN_RIGHT; @@ -75,7 +75,7 @@ static void sys_rotate_keymap(struct System* sys) sys->keymap.down = BTN_LEFT; sys->keymap.left = BTN_UP; sys->keymap.right = BTN_DOWN; -#if (CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD) +#ifdef BTN_HAVE_DIAGONAL sys->keymap.upleft = BTN_UP_RIGHT; sys->keymap.upright = BTN_DOWN_RIGHT; sys->keymap.downleft = BTN_UP_LEFT; @@ -87,7 +87,7 @@ static void sys_rotate_keymap(struct System* sys) sys->keymap.down = BTN_RIGHT; sys->keymap.left = BTN_DOWN; sys->keymap.right = BTN_UP; -#if (CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD) +#ifdef BTN_HAVE_DIAGONAL sys->keymap.upleft = BTN_DOWN_LEFT; sys->keymap.upright = BTN_UP_LEFT; sys->keymap.downleft = BTN_DOWN_RIGHT; diff --git a/apps/plugins/xworld/sys.h b/apps/plugins/xworld/sys.h index ced1fd98cd..4b1ec9b13a 100644 --- a/apps/plugins/xworld/sys.h +++ b/apps/plugins/xworld/sys.h @@ -64,12 +64,14 @@ struct keymapping_t { int down; int left; int right; -#if (CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD) + + /* These aren't conditional, even if they aren't used (this is to + * prevent headers and source from having varying defintions of + * this structure, leading to memory corruption */ int upleft; int upright; int downleft; int downright; -#endif }; typedef void (*AudioCallback)(void *param, uint8_t *stream, int len); -- cgit v1.2.3