summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2018-11-05 13:01:55 +0100
committerSolomon Peachy <pizza@shaftnet.org>2020-04-06 18:15:41 +0200
commit180cef835bf40d0081895773aaa637ac926bb0ac (patch)
tree48c380d76c0ea40931cb5e863b40fc5dfa1ecba4
parentced3a20aacf26642ccc3ffd136f64247c67e5769 (diff)
downloadrockbox-180cef835b.tar.gz
rockbox-180cef835b.tar.bz2
rockbox-180cef835b.zip
xDuoo X3II and X20 port
Provided by Roman Stolyarov Integration, Refactoring, and Upstreaming by Solomon Peachy X3II confirmed working by forum tester, X20 is nearly identical. This includes bootloader, main firmware, and the flash image patcher. Eventual Todo: * Further refactor AGPTek Rocker & xduoo hiby bootloaders * Further refactor AGPTek Rocker & xduoo hosted platform code Change-Id: I34a674051d368efcc75d1d18c725971fe46c3eee
-rw-r--r--apps/SOURCES4
-rw-r--r--apps/bitmaps/native/SOURCES4
-rw-r--r--apps/bitmaps/native/hibyicon.130x130x16.bmpbin0 -> 51016 bytes
-rw-r--r--apps/keymaps/keymap-xduoox20.c213
-rw-r--r--apps/keymaps/keymap-xduoox3ii.c213
-rw-r--r--apps/plugins/battery_bench.c12
-rw-r--r--apps/plugins/blackjack.c32
-rw-r--r--apps/plugins/brickmania.c20
-rw-r--r--apps/plugins/calculator.c22
-rw-r--r--apps/plugins/calendar.c20
-rw-r--r--apps/plugins/chessbox/chessbox_pgn.h28
-rw-r--r--apps/plugins/chessclock.c20
-rw-r--r--apps/plugins/chip8.c16
-rw-r--r--apps/plugins/chopper.c10
-rw-r--r--apps/plugins/clix.c16
-rw-r--r--apps/plugins/cube.c20
-rw-r--r--apps/plugins/doom/i_video.c22
-rw-r--r--apps/plugins/fft/fft.c18
-rw-r--r--apps/plugins/flipit.c24
-rw-r--r--apps/plugins/fractals/fractal.h24
-rw-r--r--apps/plugins/goban/goban.h24
-rw-r--r--apps/plugins/imageviewer/imageviewer_button.h30
-rw-r--r--apps/plugins/invadrox.c14
-rw-r--r--apps/plugins/jewels.c20
-rw-r--r--apps/plugins/lib/keymaps.h16
-rw-r--r--apps/plugins/lib/pluginlib_actions.c30
-rw-r--r--apps/plugins/midi/midiplay.c16
-rw-r--r--apps/plugins/minesweeper.c26
-rw-r--r--apps/plugins/mp3_encoder.c13
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.c20
-rw-r--r--apps/plugins/mpegplayer/mpegplayer.c18
-rw-r--r--apps/plugins/oscilloscope.c29
-rw-r--r--apps/plugins/pacbox/pacbox.h19
-rw-r--r--apps/plugins/pegbox.c34
-rw-r--r--apps/plugins/pong.c16
-rw-r--r--apps/plugins/reversi/reversi-gui.h22
-rw-r--r--apps/plugins/rockblox.c24
-rw-r--r--apps/plugins/rockboy/rockboy.c20
-rw-r--r--apps/plugins/sliding_puzzle.c19
-rw-r--r--apps/plugins/snake.c16
-rw-r--r--apps/plugins/snake2.c18
-rw-r--r--apps/plugins/sokoban.c32
-rw-r--r--apps/plugins/solitaire.c38
-rw-r--r--apps/plugins/spacerocks.c18
-rw-r--r--apps/plugins/star.c32
-rw-r--r--apps/plugins/stopwatch.c16
-rw-r--r--apps/plugins/sudoku/sudoku.h28
-rw-r--r--apps/plugins/text_viewer/tv_button.h24
-rw-r--r--apps/plugins/vu_meter.c22
-rw-r--r--apps/plugins/wormlet.c18
-rw-r--r--apps/plugins/xobox.c18
-rw-r--r--apps/plugins/zxbox/keymaps.h16
-rw-r--r--apps/plugins/zxbox/zxbox_keyb.c18
-rw-r--r--bootloader/SOURCES2
-rw-r--r--bootloader/rocker_linux.c4
-rw-r--r--bootloader/xduoo_linux.c555
-rw-r--r--firmware/SOURCES38
-rw-r--r--firmware/asm/SOURCES2
-rw-r--r--firmware/drivers/audio/xduoolinux_codec.c122
-rw-r--r--firmware/export/audiohw.h2
-rw-r--r--firmware/export/config.h6
-rw-r--r--firmware/export/config/agptekrocker.h2
-rw-r--r--firmware/export/config/xduoox20.h126
-rw-r--r--firmware/export/config/xduoox3ii.h126
-rw-r--r--firmware/export/rbpaths.h2
-rw-r--r--firmware/export/xduoolinux_codec.h7
-rw-r--r--firmware/target/hosted/backlight-target.h (renamed from firmware/target/hosted/agptek/backlight-target.h)0
-rw-r--r--firmware/target/hosted/backlight-unix.c (renamed from firmware/target/hosted/agptek/backlight-agptek.c)0
-rw-r--r--firmware/target/hosted/filesystem-app.c6
-rw-r--r--firmware/target/hosted/rtc.c2
-rw-r--r--firmware/target/hosted/sdl/sim-ui-defines.h16
-rw-r--r--firmware/target/hosted/sysfs.c (renamed from firmware/target/hosted/agptek/sysfs.c)0
-rw-r--r--firmware/target/hosted/sysfs.h (renamed from firmware/target/hosted/agptek/sysfs.h)0
-rw-r--r--firmware/target/hosted/system-hosted.c (renamed from firmware/target/hosted/agptek/system-agptek.c)0
-rw-r--r--firmware/target/hosted/xduoo/adc-target.h0
-rw-r--r--firmware/target/hosted/xduoo/button-target.h46
-rw-r--r--firmware/target/hosted/xduoo/button-xduoo.c202
-rw-r--r--firmware/target/hosted/xduoo/debug-xduoo.c6
-rw-r--r--firmware/target/hosted/xduoo/lcd-target.h32
-rw-r--r--firmware/target/hosted/xduoo/lcd-xduoo.c140
-rw-r--r--firmware/target/hosted/xduoo/power-xduoo.c74
-rw-r--r--firmware/target/hosted/xduoo/power-xduoo.h31
-rw-r--r--firmware/target/hosted/xduoo/powermgmt-xduoo.c70
-rw-r--r--firmware/target/hosted/xduoo/system-target.h28
-rw-r--r--firmware/target/hosted/xduoo/usb-xduoo.c118
-rw-r--r--firmware/target/hosted/xduoo/xduoo.make52
-rwxr-xr-xtools/configure92
-rw-r--r--tools/root.make6
88 files changed, 3333 insertions, 44 deletions
diff --git a/apps/SOURCES b/apps/SOURCES
index 67fe678287..20e6fa9d2d 100644
--- a/apps/SOURCES
+++ b/apps/SOURCES
@@ -323,4 +323,8 @@ keymaps/keymap-dx50.c
keymaps/keymap-agptekrocker.c
#elif CONFIG_KEYPAD == XDUOO_X3_PAD
keymaps/keymap-xduoox3.c
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+keymaps/keymap-xduoox3ii.c
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+keymaps/keymap-xduoox20.c
#endif
diff --git a/apps/bitmaps/native/SOURCES b/apps/bitmaps/native/SOURCES
index ea726d4c07..f74f289214 100644
--- a/apps/bitmaps/native/SOURCES
+++ b/apps/bitmaps/native/SOURCES
@@ -48,6 +48,10 @@ toolsicon.130x130x16.bmp
hibyicon.70x70x16.bmp
rockboxicon.70x70x16.bmp
toolsicon.70x70x16.bmp
+#elif (defined(XDUOO_X3II) || defined(XDUOO_X20))
+hibyicon.130x130x16.bmp
+rockboxicon.130x130x16.bmp
+toolsicon.130x130x16.bmp
#endif
#endif
diff --git a/apps/bitmaps/native/hibyicon.130x130x16.bmp b/apps/bitmaps/native/hibyicon.130x130x16.bmp
new file mode 100644
index 0000000000..0c31b90e28
--- /dev/null
+++ b/apps/bitmaps/native/hibyicon.130x130x16.bmp
Binary files differ
diff --git a/apps/keymaps/keymap-xduoox20.c b/apps/keymaps/keymap-xduoox20.c
new file mode 100644
index 0000000000..3b1b01b7fa
--- /dev/null
+++ b/apps/keymaps/keymap-xduoox20.c
@@ -0,0 +1,213 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2018 by Roman Stolyarov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+/* Button Code Definitions for xDuoo X20 target */
+
+#include "config.h"
+#include "action.h"
+#include "button.h"
+#include "settings.h"
+
+/* {Action Code, Button code, Prereq button code } */
+
+/*
+ * The format of the list is as follows
+ * { Action Code, Button code, Prereq button code }
+ * if there's no need to check the previous button's value, use BUTTON_NONE
+ * Insert LAST_ITEM_IN_LIST at the end of each mapping
+ */
+static const struct button_mapping button_context_standard[] = {
+ { ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE },
+ { ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE },
+ { ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_STD_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
+ { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_HOME },
+ { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
+ { ACTION_STD_MENU, BUTTON_OPTION|BUTTON_REL, BUTTON_OPTION },
+
+ LAST_ITEM_IN_LIST
+}; /* button_context_standard */
+
+static const struct button_mapping button_context_wps[] = {
+ { ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
+ { ACTION_WPS_SKIPPREV, BUTTON_PREV|BUTTON_REL, BUTTON_PREV },
+ { ACTION_WPS_SEEKBACK, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_WPS_STOPSEEK, BUTTON_PREV|BUTTON_REL, BUTTON_PREV|BUTTON_REPEAT },
+ { ACTION_WPS_SKIPNEXT, BUTTON_NEXT|BUTTON_REL, BUTTON_NEXT },
+ { ACTION_WPS_SEEKFWD, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_WPS_STOPSEEK, BUTTON_NEXT|BUTTON_REL, BUTTON_NEXT|BUTTON_REPEAT },
+ { ACTION_WPS_VOLUP, BUTTON_VOL_UP, BUTTON_NONE },
+ { ACTION_WPS_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
+ { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_WPS_BROWSE, BUTTON_HOME|BUTTON_REL, BUTTON_HOME },
+ { ACTION_WPS_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
+ { ACTION_WPS_MENU, BUTTON_OPTION|BUTTON_REL, BUTTON_OPTION },
+ { ACTION_WPS_QUICKSCREEN, BUTTON_OPTION|BUTTON_REPEAT, BUTTON_OPTION },
+ { ACTION_WPS_HOTKEY, BUTTON_HOME|BUTTON_REPEAT, BUTTON_HOME },
+
+ LAST_ITEM_IN_LIST
+}; /* button_context_wps */
+
+static const struct button_mapping button_context_list[] = {
+ { ACTION_LIST_VOLUP, BUTTON_VOL_UP, BUTTON_NONE },
+ { ACTION_LIST_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
+ { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_list */
+
+/** Bookmark Screen **/
+static const struct button_mapping button_context_bmark[] = {
+ { ACTION_BMS_DELETE, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST)
+}; /* button_context_bmark */
+
+/** Keyboard **/
+static const struct button_mapping button_context_keyboard[] = {
+ { ACTION_KBD_LEFT, BUTTON_PREV, BUTTON_NONE },
+ { ACTION_KBD_LEFT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_KBD_RIGHT, BUTTON_NEXT, BUTTON_NONE },
+ { ACTION_KBD_RIGHT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_KBD_DOWN, BUTTON_OPTION, BUTTON_NONE },
+ { ACTION_KBD_DOWN, BUTTON_OPTION|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_KBD_CURSOR_LEFT, BUTTON_VOL_UP, BUTTON_NONE },
+ { ACTION_KBD_CURSOR_LEFT, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_KBD_CURSOR_RIGHT, BUTTON_VOL_DOWN, BUTTON_NONE },
+ { ACTION_KBD_CURSOR_RIGHT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_KBD_BACKSPACE, BUTTON_HOME, BUTTON_NONE },
+ { ACTION_KBD_BACKSPACE, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_KBD_SELECT, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
+ { ACTION_KBD_DONE, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
+ { ACTION_KBD_ABORT, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
+
+ LAST_ITEM_IN_LIST
+}; /* button_context_keyboard */
+
+/** Pitchscreen **/
+static const struct button_mapping button_context_pitchscreen[] = {
+ { ACTION_PS_INC_SMALL, BUTTON_VOL_UP, BUTTON_NONE },
+ { ACTION_PS_INC_BIG, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_PS_DEC_SMALL, BUTTON_VOL_DOWN, BUTTON_NONE },
+ { ACTION_PS_DEC_BIG, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_PS_NUDGE_LEFT, BUTTON_PREV, BUTTON_NONE },
+ { ACTION_PS_NUDGE_LEFTOFF, BUTTON_PREV|BUTTON_REL, BUTTON_NONE },
+ { ACTION_PS_NUDGE_RIGHT, BUTTON_NEXT, BUTTON_NONE },
+ { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_NEXT|BUTTON_REL, BUTTON_NONE },
+ { ACTION_PS_TOGGLE_MODE, BUTTON_PLAY|BUTTON_REL, BUTTON_NONE },
+ { ACTION_PS_RESET, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
+ { ACTION_PS_EXIT, BUTTON_HOME|BUTTON_REL, BUTTON_HOME },
+ { ACTION_PS_SLOWER, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_PS_FASTER, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_pitchscreen */
+
+/** Quickscreen **/
+static const struct button_mapping button_context_quickscreen[] = {
+ { ACTION_QS_TOP, BUTTON_VOL_UP, BUTTON_NONE },
+ { ACTION_QS_TOP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_QS_DOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
+ { ACTION_QS_DOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_QS_LEFT, BUTTON_PREV, BUTTON_NONE },
+ { ACTION_QS_LEFT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_QS_RIGHT, BUTTON_NEXT, BUTTON_NONE },
+ { ACTION_QS_RIGHT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_HOME },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_quickscreen */
+
+/** Settings - General Mappings **/
+static const struct button_mapping button_context_settings[] = {
+ { ACTION_SETTINGS_RESET, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
+ { ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE },
+ { ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE },
+ { ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
+ { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_HOME },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_settings */
+
+static const struct button_mapping button_context_settings_vol_is_inc[] = {
+ { ACTION_SETTINGS_INC, BUTTON_VOL_UP, BUTTON_NONE },
+ { ACTION_SETTINGS_INCREPEAT,BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_SETTINGS_DEC, BUTTON_VOL_DOWN, BUTTON_NONE },
+ { ACTION_SETTINGS_DECREPEAT,BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_settings_right_is_inc */
+
+/** Tree **/
+static const struct button_mapping button_context_tree[] = {
+ { ACTION_TREE_WPS, BUTTON_OPTION|BUTTON_REL, BUTTON_OPTION },
+ { ACTION_TREE_HOTKEY, BUTTON_HOME|BUTTON_REPEAT, BUTTON_HOME },
+ { ACTION_STD_MENU, BUTTON_OPTION|BUTTON_REPEAT, BUTTON_OPTION },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST)
+}; /* button_context_tree */
+
+/** Yes/No Screen **/
+static const struct button_mapping button_context_yesnoscreen[] = {
+ { ACTION_YESNO_ACCEPT, BUTTON_PLAY, BUTTON_NONE },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_settings_yesnoscreen */
+
+/* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */
+const struct button_mapping* get_context_mapping(int context)
+{
+ switch (context)
+ {
+ case CONTEXT_LIST:
+ return button_context_list;
+ case CONTEXT_STD:
+ return button_context_standard;
+ case CONTEXT_BOOKMARKSCREEN:
+ return button_context_bmark;
+ case CONTEXT_KEYBOARD:
+ return button_context_keyboard;
+ case CONTEXT_PITCHSCREEN:
+ return button_context_pitchscreen;
+ case CONTEXT_QUICKSCREEN:
+ return button_context_quickscreen;
+ case CONTEXT_SETTINGS:
+ return button_context_settings;
+ case CONTEXT_SETTINGS_TIME:
+ case CONTEXT_SETTINGS_COLOURCHOOSER:
+ case CONTEXT_SETTINGS_EQ:
+ case CONTEXT_SETTINGS_RECTRIGGER:
+ return button_context_settings_vol_is_inc;
+ case CONTEXT_TREE:
+ case CONTEXT_MAINMENU:
+ return button_context_tree;
+ case CONTEXT_WPS:
+ return button_context_wps;
+ case CONTEXT_YESNOSCREEN:
+ return button_context_yesnoscreen;
+ }
+ return button_context_standard;
+}
diff --git a/apps/keymaps/keymap-xduoox3ii.c b/apps/keymaps/keymap-xduoox3ii.c
new file mode 100644
index 0000000000..d30efaed2c
--- /dev/null
+++ b/apps/keymaps/keymap-xduoox3ii.c
@@ -0,0 +1,213 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2018 by Roman Stolyarov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+/* Button Code Definitions for xDuoo X3ii target */
+
+#include "config.h"
+#include "action.h"
+#include "button.h"
+#include "settings.h"
+
+/* {Action Code, Button code, Prereq button code } */
+
+/*
+ * The format of the list is as follows
+ * { Action Code, Button code, Prereq button code }
+ * if there's no need to check the previous button's value, use BUTTON_NONE
+ * Insert LAST_ITEM_IN_LIST at the end of each mapping
+ */
+static const struct button_mapping button_context_standard[] = {
+ { ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE },
+ { ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE },
+ { ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_STD_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
+ { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_HOME },
+ { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
+ { ACTION_STD_MENU, BUTTON_OPTION|BUTTON_REL, BUTTON_OPTION },
+
+ LAST_ITEM_IN_LIST
+}; /* button_context_standard */
+
+static const struct button_mapping button_context_wps[] = {
+ { ACTION_WPS_PLAY, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
+ { ACTION_WPS_SKIPPREV, BUTTON_PREV|BUTTON_REL, BUTTON_PREV },
+ { ACTION_WPS_SEEKBACK, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_WPS_STOPSEEK, BUTTON_PREV|BUTTON_REL, BUTTON_PREV|BUTTON_REPEAT },
+ { ACTION_WPS_SKIPNEXT, BUTTON_NEXT|BUTTON_REL, BUTTON_NEXT },
+ { ACTION_WPS_SEEKFWD, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_WPS_STOPSEEK, BUTTON_NEXT|BUTTON_REL, BUTTON_NEXT|BUTTON_REPEAT },
+ { ACTION_WPS_VOLUP, BUTTON_VOL_UP, BUTTON_NONE },
+ { ACTION_WPS_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
+ { ACTION_WPS_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_WPS_BROWSE, BUTTON_HOME|BUTTON_REL, BUTTON_HOME },
+ { ACTION_WPS_CONTEXT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
+ { ACTION_WPS_MENU, BUTTON_OPTION|BUTTON_REL, BUTTON_OPTION },
+ { ACTION_WPS_QUICKSCREEN, BUTTON_OPTION|BUTTON_REPEAT, BUTTON_OPTION },
+ { ACTION_WPS_HOTKEY, BUTTON_HOME|BUTTON_REPEAT, BUTTON_HOME },
+
+ LAST_ITEM_IN_LIST
+}; /* button_context_wps */
+
+static const struct button_mapping button_context_list[] = {
+ { ACTION_LIST_VOLUP, BUTTON_VOL_UP, BUTTON_NONE },
+ { ACTION_LIST_VOLUP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
+ { ACTION_LIST_VOLDOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_list */
+
+/** Bookmark Screen **/
+static const struct button_mapping button_context_bmark[] = {
+ { ACTION_BMS_DELETE, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST)
+}; /* button_context_bmark */
+
+/** Keyboard **/
+static const struct button_mapping button_context_keyboard[] = {
+ { ACTION_KBD_LEFT, BUTTON_PREV, BUTTON_NONE },
+ { ACTION_KBD_LEFT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_KBD_RIGHT, BUTTON_NEXT, BUTTON_NONE },
+ { ACTION_KBD_RIGHT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_KBD_DOWN, BUTTON_OPTION, BUTTON_NONE },
+ { ACTION_KBD_DOWN, BUTTON_OPTION|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_KBD_CURSOR_LEFT, BUTTON_VOL_UP, BUTTON_NONE },
+ { ACTION_KBD_CURSOR_LEFT, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_KBD_CURSOR_RIGHT, BUTTON_VOL_DOWN, BUTTON_NONE },
+ { ACTION_KBD_CURSOR_RIGHT, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_KBD_BACKSPACE, BUTTON_HOME, BUTTON_NONE },
+ { ACTION_KBD_BACKSPACE, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_KBD_SELECT, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
+ { ACTION_KBD_DONE, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_PLAY },
+ { ACTION_KBD_ABORT, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
+
+ LAST_ITEM_IN_LIST
+}; /* button_context_keyboard */
+
+/** Pitchscreen **/
+static const struct button_mapping button_context_pitchscreen[] = {
+ { ACTION_PS_INC_SMALL, BUTTON_VOL_UP, BUTTON_NONE },
+ { ACTION_PS_INC_BIG, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_PS_DEC_SMALL, BUTTON_VOL_DOWN, BUTTON_NONE },
+ { ACTION_PS_DEC_BIG, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_PS_NUDGE_LEFT, BUTTON_PREV, BUTTON_NONE },
+ { ACTION_PS_NUDGE_LEFTOFF, BUTTON_PREV|BUTTON_REL, BUTTON_NONE },
+ { ACTION_PS_NUDGE_RIGHT, BUTTON_NEXT, BUTTON_NONE },
+ { ACTION_PS_NUDGE_RIGHTOFF, BUTTON_NEXT|BUTTON_REL, BUTTON_NONE },
+ { ACTION_PS_TOGGLE_MODE, BUTTON_PLAY|BUTTON_REL, BUTTON_NONE },
+ { ACTION_PS_RESET, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
+ { ACTION_PS_EXIT, BUTTON_HOME|BUTTON_REL, BUTTON_HOME },
+ { ACTION_PS_SLOWER, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_PS_FASTER, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_pitchscreen */
+
+/** Quickscreen **/
+static const struct button_mapping button_context_quickscreen[] = {
+ { ACTION_QS_TOP, BUTTON_VOL_UP, BUTTON_NONE },
+ { ACTION_QS_TOP, BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_QS_DOWN, BUTTON_VOL_DOWN, BUTTON_NONE },
+ { ACTION_QS_DOWN, BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_QS_LEFT, BUTTON_PREV, BUTTON_NONE },
+ { ACTION_QS_LEFT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_QS_RIGHT, BUTTON_NEXT, BUTTON_NONE },
+ { ACTION_QS_RIGHT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_HOME },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_quickscreen */
+
+/** Settings - General Mappings **/
+static const struct button_mapping button_context_settings[] = {
+ { ACTION_SETTINGS_RESET, BUTTON_POWER|BUTTON_REL, BUTTON_POWER },
+ { ACTION_STD_PREV, BUTTON_PREV, BUTTON_NONE },
+ { ACTION_STD_PREVREPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_STD_NEXT, BUTTON_NEXT, BUTTON_NONE },
+ { ACTION_STD_NEXTREPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_STD_OK, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY },
+ { ACTION_STD_CANCEL, BUTTON_HOME|BUTTON_REL, BUTTON_HOME },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_settings */
+
+static const struct button_mapping button_context_settings_vol_is_inc[] = {
+ { ACTION_SETTINGS_INC, BUTTON_VOL_UP, BUTTON_NONE },
+ { ACTION_SETTINGS_INCREPEAT,BUTTON_VOL_UP|BUTTON_REPEAT, BUTTON_NONE },
+ { ACTION_SETTINGS_DEC, BUTTON_VOL_DOWN, BUTTON_NONE },
+ { ACTION_SETTINGS_DECREPEAT,BUTTON_VOL_DOWN|BUTTON_REPEAT, BUTTON_NONE },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_settings_right_is_inc */
+
+/** Tree **/
+static const struct button_mapping button_context_tree[] = {
+ { ACTION_TREE_WPS, BUTTON_OPTION|BUTTON_REL, BUTTON_OPTION },
+ { ACTION_TREE_HOTKEY, BUTTON_HOME|BUTTON_REPEAT, BUTTON_HOME },
+ { ACTION_STD_MENU, BUTTON_OPTION|BUTTON_REPEAT, BUTTON_OPTION },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST)
+}; /* button_context_tree */
+
+/** Yes/No Screen **/
+static const struct button_mapping button_context_yesnoscreen[] = {
+ { ACTION_YESNO_ACCEPT, BUTTON_PLAY, BUTTON_NONE },
+
+ LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
+}; /* button_context_settings_yesnoscreen */
+
+/* get_context_mapping returns a pointer to one of the above defined arrays depending on the context */
+const struct button_mapping* get_context_mapping(int context)
+{
+ switch (context)
+ {
+ case CONTEXT_LIST:
+ return button_context_list;
+ case CONTEXT_STD:
+ return button_context_standard;
+ case CONTEXT_BOOKMARKSCREEN:
+ return button_context_bmark;
+ case CONTEXT_KEYBOARD:
+ return button_context_keyboard;
+ case CONTEXT_PITCHSCREEN:
+ return button_context_pitchscreen;
+ case CONTEXT_QUICKSCREEN:
+ return button_context_quickscreen;
+ case CONTEXT_SETTINGS:
+ return button_context_settings;
+ case CONTEXT_SETTINGS_TIME:
+ case CONTEXT_SETTINGS_COLOURCHOOSER:
+ case CONTEXT_SETTINGS_EQ:
+ case CONTEXT_SETTINGS_RECTRIGGER:
+ return button_context_settings_vol_is_inc;
+ case CONTEXT_TREE:
+ case CONTEXT_MAINMENU:
+ return button_context_tree;
+ case CONTEXT_WPS:
+ return button_context_wps;
+ case CONTEXT_YESNOSCREEN:
+ return button_context_yesnoscreen;
+ }
+ return button_context_standard;
+}
diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c
index 21b2ce4963..f24ad579e8 100644
--- a/apps/plugins/battery_bench.c
+++ b/apps/plugins/battery_bench.c
@@ -298,6 +298,18 @@
#define BATTERY_ON_TXT "PLAY - start"
#define BATTERY_OFF_TXT "POWER"
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define BATTERY_ON BUTTON_PLAY
+#define BATTERY_OFF BUTTON_POWER
+#define BATTERY_ON_TXT "Play - start"
+#define BATTERY_OFF_TXT "POWER"
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define BATTERY_ON BUTTON_PLAY
+#define BATTERY_OFF BUTTON_POWER
+#define BATTERY_ON_TXT "Play - start"
+#define BATTERY_OFF_TXT "POWER"
+
#else
#error No keymap defined!
#endif
diff --git a/apps/plugins/blackjack.c b/apps/plugins/blackjack.c
index 52881f0af2..4511d3fad5 100644
--- a/apps/plugins/blackjack.c
+++ b/apps/plugins/blackjack.c
@@ -589,6 +589,38 @@ enum {
#define BJACK_RIGHT BUTTON_NEXT
#define BJACK_LEFT BUTTON_PREV
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define BJACK_SELECT_NAME "PLAY"
+#define BJACK_STAY_NAME "NEXT"
+#define BJACK_QUIT_NAME "POWER"
+#define BJACK_DOUBLE_NAME "PREV"
+#define BJACK_SELECT BUTTON_PLAY
+#define BJACK_QUIT BUTTON_POWER
+#define BJACK_MAX BUTTON_VOL_UP
+#define BJACK_MIN BUTTON_VOL_DOWN
+#define BJACK_STAY BUTTON_NEXT
+#define BJACK_DOUBLEDOWN BUTTON_PREV
+#define BJACK_UP BUTTON_HOME
+#define BJACK_DOWN BUTTON_OPTION
+#define BJACK_RIGHT BUTTON_NEXT
+#define BJACK_LEFT BUTTON_PREV
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define BJACK_SELECT_NAME "PLAY"
+#define BJACK_STAY_NAME "NEXT"
+#define BJACK_QUIT_NAME "POWER"
+#define BJACK_DOUBLE_NAME "PREV"
+#define BJACK_SELECT BUTTON_PLAY
+#define BJACK_QUIT BUTTON_POWER
+#define BJACK_MAX BUTTON_VOL_UP
+#define BJACK_MIN BUTTON_VOL_DOWN
+#define BJACK_STAY BUTTON_NEXT
+#define BJACK_DOUBLEDOWN BUTTON_PREV
+#define BJACK_UP BUTTON_HOME
+#define BJACK_DOWN BUTTON_OPTION
+#define BJACK_RIGHT BUTTON_NEXT
+#define BJACK_LEFT BUTTON_PREV
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define BJACK_SELECT_NAME "PLAY"
#define BJACK_STAY_NAME "NEXT"
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c
index f7c9f9adf2..c5d74bcf37 100644
--- a/apps/plugins/brickmania.c
+++ b/apps/plugins/brickmania.c
@@ -342,6 +342,26 @@ CONFIG_KEYPAD == SANSA_CONNECT_PAD
#define UP BUTTON_HOME
#define DOWN BUTTON_OPTION
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define QUIT BUTTON_POWER
+#define LEFT BUTTON_PREV
+#define RIGHT BUTTON_NEXT
+#define ALTLEFT BUTTON_VOL_DOWN
+#define ALTRIGHT BUTTON_VOL_UP
+#define SELECT BUTTON_PLAY
+#define UP BUTTON_HOME
+#define DOWN BUTTON_OPTION
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define QUIT BUTTON_POWER
+#define LEFT BUTTON_PREV
+#define RIGHT BUTTON_NEXT
+#define ALTLEFT BUTTON_VOL_DOWN
+#define ALTRIGHT BUTTON_VOL_UP
+#define SELECT BUTTON_PLAY
+#define UP BUTTON_HOME
+#define DOWN BUTTON_OPTION
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define QUIT BUTTON_POWER
#define LEFT BUTTON_HOME
diff --git a/apps/plugins/calculator.c b/apps/plugins/calculator.c
index a4a29ff6ac..be5087967c 100644
--- a/apps/plugins/calculator.c
+++ b/apps/plugins/calculator.c
@@ -536,6 +536,28 @@ F3: equal to "="
#define CALCULATOR_CALC (BUTTON_PLAY|BUTTON_REPEAT)
#define CALCULATOR_CLEAR (BUTTON_POWER|BUTTON_REPEAT)
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define CALCULATOR_LEFT BUTTON_PREV
+#define CALCULATOR_RIGHT BUTTON_NEXT
+#define CALCULATOR_UP BUTTON_HOME
+#define CALCULATOR_DOWN BUTTON_OPTION
+#define CALCULATOR_QUIT BUTTON_POWER
+#define CALCULATOR_INPUT_CALC_PRE (BUTTON_OPTION|BUTTON_REPEAT)
+#define CALCULATOR_INPUT (BUTTON_PLAY|BUTTON_REL)
+#define CALCULATOR_CALC (BUTTON_PLAY|BUTTON_REPEAT)
+#define CALCULATOR_CLEAR (BUTTON_POWER|BUTTON_REPEAT)
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define CALCULATOR_LEFT BUTTON_PREV
+#define CALCULATOR_RIGHT BUTTON_NEXT
+#define CALCULATOR_UP BUTTON_HOME
+#define CALCULATOR_DOWN BUTTON_OPTION
+#define CALCULATOR_QUIT BUTTON_POWER
+#define CALCULATOR_INPUT_CALC_PRE (BUTTON_OPTION|BUTTON_REPEAT)
+#define CALCULATOR_INPUT (BUTTON_PLAY|BUTTON_REL)
+#define CALCULATOR_CALC (BUTTON_PLAY|BUTTON_REPEAT)
+#define CALCULATOR_CLEAR (BUTTON_POWER|BUTTON_REPEAT)
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define CALCULATOR_LEFT BUTTON_HOME
#define CALCULATOR_RIGHT BUTTON_VOL_DOWN
diff --git a/apps/plugins/calendar.c b/apps/plugins/calendar.c
index 56f9bde193..af550685cc 100644
--- a/apps/plugins/calendar.c
+++ b/apps/plugins/calendar.c
@@ -423,6 +423,26 @@
#define CALENDAR_NEXT_MONTH BUTTON_VOL_UP
#define CALENDAR_PREV_MONTH BUTTON_VOL_DOWN
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define CALENDAR_QUIT BUTTON_POWER
+#define CALENDAR_SELECT BUTTON_PLAY
+#define CALENDAR_NEXT_WEEK BUTTON_OPTION
+#define CALENDAR_PREV_WEEK BUTTON_HOME
+#define CALENDAR_NEXT_DAY BUTTON_NEXT
+#define CALENDAR_PREV_DAY BUTTON_PREV
+#define CALENDAR_NEXT_MONTH BUTTON_VOL_UP
+#define CALENDAR_PREV_MONTH BUTTON_VOL_DOWN
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define CALENDAR_QUIT BUTTON_POWER
+#define CALENDAR_SELECT BUTTON_PLAY
+#define CALENDAR_NEXT_WEEK BUTTON_OPTION
+#define CALENDAR_PREV_WEEK BUTTON_HOME
+#define CALENDAR_NEXT_DAY BUTTON_NEXT
+#define CALENDAR_PREV_DAY BUTTON_PREV
+#define CALENDAR_NEXT_MONTH BUTTON_VOL_UP
+#define CALENDAR_PREV_MONTH BUTTON_VOL_DOWN
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define CALENDAR_QUIT BUTTON_POWER
#define CALENDAR_SELECT BUTTON_PLAY
diff --git a/apps/plugins/chessbox/chessbox_pgn.h b/apps/plugins/chessbox/chessbox_pgn.h
index 3c4d5357a5..9d37953c6f 100644
--- a/apps/plugins/chessbox/chessbox_pgn.h
+++ b/apps/plugins/chessbox/chessbox_pgn.h
@@ -572,6 +572,34 @@
#define CB_SCROLL_LEFT (BUTTON_PREV|BUTTON_REPEAT)
#define CB_SCROLL_RIGHT (BUTTON_NEXT|BUTTON_REPEAT)
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define CB_SELECT BUTTON_PLAY
+#define CB_UP BUTTON_HOME
+#define CB_DOWN BUTTON_OPTION
+#define CB_LEFT BUTTON_PREV
+#define CB_RIGHT BUTTON_NEXT
+#define CB_PLAY BUTTON_VOL_UP
+#define CB_LEVEL BUTTON_VOL_DOWN
+#define CB_MENU BUTTON_POWER
+#define CB_SCROLL_UP (BUTTON_HOME|BUTTON_REPEAT)
+#define CB_SCROLL_DOWN (BUTTON_OPTION|BUTTON_REPEAT)
+#define CB_SCROLL_LEFT (BUTTON_PREV|BUTTON_REPEAT)
+#define CB_SCROLL_RIGHT (BUTTON_NEXT|BUTTON_REPEAT)
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define CB_SELECT BUTTON_PLAY
+#define CB_UP BUTTON_HOME
+#define CB_DOWN BUTTON_OPTION
+#define CB_LEFT BUTTON_PREV
+#define CB_RIGHT BUTTON_NEXT
+#define CB_PLAY BUTTON_VOL_UP
+#define CB_LEVEL BUTTON_VOL_DOWN
+#define CB_MENU BUTTON_POWER
+#define CB_SCROLL_UP (BUTTON_HOME|BUTTON_REPEAT)
+#define CB_SCROLL_DOWN (BUTTON_OPTION|BUTTON_REPEAT)
+#define CB_SCROLL_LEFT (BUTTON_PREV|BUTTON_REPEAT)
+#define CB_SCROLL_RIGHT (BUTTON_NEXT|BUTTON_REPEAT)
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define CB_SELECT BUTTON_PLAY
#define CB_UP BUTTON_PREV
diff --git a/apps/plugins/chessclock.c b/apps/plugins/chessclock.c
index 6b07e1bab5..d93777860b 100644
--- a/apps/plugins/chessclock.c
+++ b/apps/plugins/chessclock.c
@@ -422,6 +422,26 @@
#define CHC_SETTINGS_OK BUTTON_PLAY
#define CHC_SETTINGS_CANCEL BUTTON_POWER
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define CHC_QUIT BUTTON_POWER
+#define CHC_STARTSTOP BUTTON_PLAY
+#define CHC_RESET BUTTON_OPTION
+#define CHC_MENU BUTTON_HOME
+#define CHC_SETTINGS_INC BUTTON_NEXT
+#define CHC_SETTINGS_DEC BUTTON_PREV
+#define CHC_SETTINGS_OK BUTTON_PLAY
+#define CHC_SETTINGS_CANCEL BUTTON_POWER
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define CHC_QUIT BUTTON_POWER
+#define CHC_STARTSTOP BUTTON_PLAY
+#define CHC_RESET BUTTON_OPTION
+#define CHC_MENU BUTTON_HOME
+#define CHC_SETTINGS_INC BUTTON_NEXT
+#define CHC_SETTINGS_DEC BUTTON_PREV
+#define CHC_SETTINGS_OK BUTTON_PLAY
+#define CHC_SETTINGS_CANCEL BUTTON_POWER
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define CHC_QUIT BUTTON_POWER
#define CHC_STARTSTOP BUTTON_PLAY
diff --git a/apps/plugins/chip8.c b/apps/plugins/chip8.c
index 58d80a2ccf..7c2be3f7e7 100644
--- a/apps/plugins/chip8.c
+++ b/apps/plugins/chip8.c
@@ -1291,6 +1291,22 @@ CONFIG_KEYPAD == MROBE500_PAD
#define CHIP8_KEY6 BUTTON_NEXT
#define CHIP8_KEY8 BUTTON_OPTION
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define CHIP8_OFF BUTTON_POWER
+#define CHIP8_KEY2 BUTTON_HOME
+#define CHIP8_KEY4 BUTTON_PREV
+#define CHIP8_KEY5 BUTTON_PLAY
+#define CHIP8_KEY6 BUTTON_NEXT
+#define CHIP8_KEY8 BUTTON_OPTION
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define CHIP8_OFF BUTTON_POWER
+#define CHIP8_KEY2 BUTTON_HOME
+#define CHIP8_KEY4 BUTTON_PREV
+#define CHIP8_KEY5 BUTTON_PLAY
+#define CHIP8_KEY6 BUTTON_NEXT
+#define CHIP8_KEY8 BUTTON_OPTION
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define CHIP8_OFF BUTTON_POWER
#define CHIP8_KEY2 BUTTON_NEXT
diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c
index 249cfe9715..71e24deb8f 100644
--- a/apps/plugins/chopper.c
+++ b/apps/plugins/chopper.c
@@ -214,6 +214,16 @@ CONFIG_KEYPAD == MROBE500_PAD
#define ACTION BUTTON_PLAY
#define ACTIONTEXT "PLAY"
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define QUIT BUTTON_POWER
+#define ACTION BUTTON_PLAY
+#define ACTIONTEXT "PLAY"
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define QUIT BUTTON_POWER
+#define ACTION BUTTON_PLAY
+#define ACTIONTEXT "PLAY"
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define QUIT BUTTON_POWER
#define ACTION BUTTON_PLAY
diff --git a/apps/plugins/clix.c b/apps/plugins/clix.c
index c6364b14b4..e80fdeab8b 100644
--- a/apps/plugins/clix.c
+++ b/apps/plugins/clix.c
@@ -284,6 +284,22 @@
#define CLIX_BUTTON_RIGHT BUTTON_NEXT
#define CLIX_BUTTON_CLICK BUTTON_PLAY
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define CLIX_BUTTON_QUIT BUTTON_POWER
+#define CLIX_BUTTON_UP BUTTON_HOME
+#define CLIX_BUTTON_DOWN BUTTON_OPTION
+#define CLIX_BUTTON_LEFT BUTTON_PREV
+#define CLIX_BUTTON_RIGHT BUTTON_NEXT
+#define CLIX_BUTTON_CLICK BUTTON_PLAY
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define CLIX_BUTTON_QUIT BUTTON_POWER
+#define CLIX_BUTTON_UP BUTTON_HOME
+#define CLIX_BUTTON_DOWN BUTTON_OPTION
+#define CLIX_BUTTON_LEFT BUTTON_PREV
+#define CLIX_BUTTON_RIGHT BUTTON_NEXT
+#define CLIX_BUTTON_CLICK BUTTON_PLAY
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define CLIX_BUTTON_QUIT BUTTON_POWER
#define CLIX_BUTTON_UP BUTTON_PREV
diff --git a/apps/plugins/cube.c b/apps/plugins/cube.c
index cad57f9ed6..78fd333773 100644
--- a/apps/plugins/cube.c
+++ b/apps/plugins/cube.c
@@ -423,6 +423,26 @@
#define CUBE_PAUSE BUTTON_HOME
#define CUBE_HIGHSPEED BUTTON_PLAY
+#elif (CONFIG_KEYPAD == XDUOO_X3II_PAD)
+#define CUBE_QUIT BUTTON_POWER
+#define CUBE_NEXT BUTTON_NEXT
+#define CUBE_PREV BUTTON_PREV
+#define CUBE_INC BUTTON_VOL_UP
+#define CUBE_DEC BUTTON_VOL_DOWN
+#define CUBE_MODE BUTTON_OPTION
+#define CUBE_PAUSE BUTTON_HOME
+#define CUBE_HIGHSPEED BUTTON_PLAY
+
+#elif (CONFIG_KEYPAD == XDUOO_X20_PAD)
+#define CUBE_QUIT BUTTON_POWER
+#define CUBE_NEXT BUTTON_NEXT
+#define CUBE_PREV BUTTON_PREV
+#define CUBE_INC BUTTON_VOL_UP
+#define CUBE_DEC BUTTON_VOL_DOWN
+#define CUBE_MODE BUTTON_OPTION
+#define CUBE_PAUSE BUTTON_HOME
+#define CUBE_HIGHSPEED BUTTON_PLAY
+
#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
#define CUBE_QUIT BUTTON_POWER
#define CUBE_NEXT BUTTON_NEXT
diff --git a/apps/plugins/doom/i_video.c b/apps/plugins/doom/i_video.c
index 41194670bf..9f367d7d76 100644
--- a/apps/plugins/doom/i_video.c
+++ b/apps/plugins/doom/i_video.c
@@ -566,6 +566,28 @@ void I_ShutdownGraphics(void)
#define DOOMBUTTON_ENTER BUTTON_PLAY
#define DOOMBUTTON_WEAPON BUTTON_VOL_UP
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define DOOMBUTTON_UP BUTTON_HOME
+#define DOOMBUTTON_DOWN BUTTON_OPTION
+#define DOOMBUTTON_LEFT BUTTON_PREV
+#define DOOMBUTTON_RIGHT BUTTON_NEXT
+#define DOOMBUTTON_SHOOT BUTTON_PLAY
+#define DOOMBUTTON_OPEN (BUTTON_HOME | BUTTON_POWER)
+#define DOOMBUTTON_ESC BUTTON_POWER
+#define DOOMBUTTON_ENTER BUTTON_PLAY
+#define DOOMBUTTON_WEAPON BUTTON_VOL_UP
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define DOOMBUTTON_UP BUTTON_HOME
+#define DOOMBUTTON_DOWN BUTTON_OPTION
+#define DOOMBUTTON_LEFT BUTTON_PREV
+#define DOOMBUTTON_RIGHT BUTTON_NEXT
+#define DOOMBUTTON_SHOOT BUTTON_PLAY
+#define DOOMBUTTON_OPEN (BUTTON_HOME | BUTTON_POWER)
+#define DOOMBUTTON_ESC BUTTON_POWER
+#define DOOMBUTTON_ENTER BUTTON_PLAY
+#define DOOMBUTTON_WEAPON BUTTON_VOL_UP
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define DOOMBUTTON_UP BUTTON_PREV
#define DOOMBUTTON_DOWN BUTTON_NEXT
diff --git a/apps/plugins/fft/fft.c b/apps/plugins/fft/fft.c
index d56e37f9e2..0f4e33759d 100644
--- a/apps/plugins/fft/fft.c
+++ b/apps/plugins/fft/fft.c
@@ -343,6 +343,24 @@ GREY_INFO_STRUCT
# define FFT_AMP_SCALE BUTTON_PLAY
# define FFT_QUIT BUTTON_POWER
+#elif (CONFIG_KEYPAD == XDUOO_X3II_PAD)
+# define FFT_PREV_GRAPH BUTTON_PREV
+# define FFT_NEXT_GRAPH BUTTON_NEXT
+# define FFT_ORIENTATION BUTTON_HOME
+# define FFT_FREQ_SCALE BUTTON_OPTION
+# define FFT_WINDOW (BUTTON_HOME|BUTTON_POWER)
+# define FFT_AMP_SCALE BUTTON_PLAY
+# define FFT_QUIT BUTTON_POWER
+
+#elif (CONFIG_KEYPAD == XDUOO_X20_PAD)
+# define FFT_PREV_GRAPH BUTTON_PREV
+# define FFT_NEXT_GRAPH BUTTON_NEXT
+# define FFT_ORIENTATION BUTTON_HOME
+# define FFT_FREQ_SCALE BUTTON_OPTION
+# define FFT_WINDOW (BUTTON_HOME|BUTTON_POWER)
+# define FFT_AMP_SCALE BUTTON_PLAY
+# define FFT_QUIT BUTTON_POWER
+
#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
# define FFT_PREV_GRAPH BUTTON_PREV
# define FFT_NEXT_GRAPH BUTTON_NEXT
diff --git a/apps/plugins/flipit.c b/apps/plugins/flipit.c
index c108939a95..7d1257ef94 100644
--- a/apps/plugins/flipit.c
+++ b/apps/plugins/flipit.c
@@ -494,6 +494,30 @@
#define FLIPIT_STEP_BY_STEP (BUTTON_HOME | BUTTON_PLAY)
#define FLIPIT_TOGGLE BUTTON_PLAY
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+
+#define FLIPIT_LEFT BUTTON_PREV
+#define FLIPIT_RIGHT BUTTON_NEXT
+#define FLIPIT_UP BUTTON_HOME
+#define FLIPIT_DOWN BUTTON_OPTION
+#define FLIPIT_QUIT BUTTON_POWER
+#define FLIPIT_SHUFFLE (BUTTON_HOME | BUTTON_PREV)
+#define FLIPIT_SOLVE (BUTTON_HOME | BUTTON_NEXT)
+#define FLIPIT_STEP_BY_STEP (BUTTON_HOME | BUTTON_PLAY)
+#define FLIPIT_TOGGLE BUTTON_PLAY
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+
+#define FLIPIT_LEFT BUTTON_PREV
+#define FLIPIT_RIGHT BUTTON_NEXT
+#define FLIPIT_UP BUTTON_HOME
+#define FLIPIT_DOWN BUTTON_OPTION
+#define FLIPIT_QUIT BUTTON_POWER
+#define FLIPIT_SHUFFLE (BUTTON_HOME | BUTTON_PREV)
+#define FLIPIT_SOLVE (BUTTON_HOME | BUTTON_NEXT)
+#define FLIPIT_STEP_BY_STEP (BUTTON_HOME | BUTTON_PLAY)
+#define FLIPIT_TOGGLE BUTTON_PLAY
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define FLIPIT_LEFT BUTTON_HOME
diff --git a/apps/plugins/fractals/fractal.h b/apps/plugins/fractals/fractal.h
index 5a56a39b13..679782d37a 100644
--- a/apps/plugins/fractals/fractal.h
+++ b/apps/plugins/fractals/fractal.h
@@ -496,6 +496,30 @@
#define FRACTAL_PRECISION_DEC (BUTTON_PLAY | BUTTON_PREV)
#define FRACTAL_RESET (BUTTON_HOME | BUTTON_POWER)
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define FRACTAL_QUIT BUTTON_POWER
+#define FRACTAL_UP BUTTON_HOME
+#define FRACTAL_DOWN BUTTON_OPTION
+#define FRACTAL_LEFT BUTTON_PREV
+#define FRACTAL_RIGHT BUTTON_NEXT
+#define FRACTAL_ZOOM_IN BUTTON_VOL_UP
+#define FRACTAL_ZOOM_OUT BUTTON_VOL_DOWN
+#define FRACTAL_PRECISION_INC (BUTTON_PLAY | BUTTON_NEXT)
+#define FRACTAL_PRECISION_DEC (BUTTON_PLAY | BUTTON_PREV)
+#define FRACTAL_RESET (BUTTON_HOME | BUTTON_POWER)
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define FRACTAL_QUIT BUTTON_POWER
+#define FRACTAL_UP BUTTON_HOME
+#define FRACTAL_DOWN BUTTON_OPTION
+#define FRACTAL_LEFT BUTTON_PREV
+#define FRACTAL_RIGHT BUTTON_NEXT
+#define FRACTAL_ZOOM_IN BUTTON_VOL_UP
+#define FRACTAL_ZOOM_OUT BUTTON_VOL_DOWN
+#define FRACTAL_PRECISION_INC (BUTTON_PLAY | BUTTON_NEXT)
+#define FRACTAL_PRECISION_DEC (BUTTON_PLAY | BUTTON_PREV)
+#define FRACTAL_RESET (BUTTON_HOME | BUTTON_POWER)
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define FRACTAL_QUIT BUTTON_POWER
#define FRACTAL_UP BUTTON_PREV
diff --git a/apps/plugins/goban/goban.h b/apps/plugins/goban/goban.h
index 9f03937078..e04b4c2447 100644
--- a/apps/plugins/goban/goban.h
+++ b/apps/plugins/goban/goban.h
@@ -464,6 +464,30 @@
#define GBN_BUTTON_CONTEXT BUTTON_PLAY | BUTTON_REPEAT
#define GBN_BUTTON_NEXT_VAR BUTTON_HOME | BUTTON_POWER
+#elif (CONFIG_KEYPAD == XDUOO_X3II_PAD)
+#define GBN_BUTTON_UP BUTTON_HOME
+#define GBN_BUTTON_DOWN BUTTON_OPTION
+#define GBN_BUTTON_LEFT BUTTON_PREV
+#define GBN_BUTTON_RIGHT BUTTON_NEXT
+#define GBN_BUTTON_RETREAT BUTTON_VOL_DOWN
+#define GBN_BUTTON_ADVANCE BUTTON_VOL_UP
+#define GBN_BUTTON_MENU BUTTON_POWER
+#define GBN_BUTTON_PLAY BUTTON_PLAY | BUTTON_REL
+#define GBN_BUTTON_CONTEXT BUTTON_PLAY | BUTTON_REPEAT
+#define GBN_BUTTON_NEXT_VAR BUTTON_HOME | BUTTON_POWER
+
+#elif (CONFIG_KEYPAD == XDUOO_X20_PAD)
+#define GBN_BUTTON_UP BUTTON_HOME
+#define GBN_BUTTON_DOWN BUTTON_OPTION
+#define GBN_BUTTON_LEFT BUTTON_PREV
+#define GBN_BUTTON_RIGHT BUTTON_NEXT
+#define GBN_BUTTON_RETREAT BUTTON_VOL_DOWN
+#define GBN_BUTTON_ADVANCE BUTTON_VOL_UP
+#define GBN_BUTTON_MENU BUTTON_POWER
+#define GBN_BUTTON_PLAY BUTTON_PLAY | BUTTON_REL
+#define GBN_BUTTON_CONTEXT BUTTON_PLAY | BUTTON_REPEAT
+#define GBN_BUTTON_NEXT_VAR BUTTON_HOME | BUTTON_POWER
+
#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
#define GBN_BUTTON_UP BUTTON_PREV
diff --git a/apps/plugins/imageviewer/imageviewer_button.h b/apps/plugins/imageviewer/imageviewer_button.h
index 5ffef12a62..e37febc76a 100644
--- a/apps/plugins/imageviewer/imageviewer_button.h
+++ b/apps/plugins/imageviewer/imageviewer_button.h
@@ -510,6 +510,36 @@
#define IMGVIEW_MENU BUTTON_POWER
#define IMGVIEW_SLIDE_SHOW (BUTTON_HOME|BUTTON_POWER)
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define IMGVIEW_ZOOM_PRE BUTTON_PLAY
+#define IMGVIEW_ZOOM_IN (BUTTON_PLAY | BUTTON_REL)
+#define IMGVIEW_ZOOM_OUT (BUTTON_PLAY | BUTTON_REPEAT)
+#define IMGVIEW_UP BUTTON_HOME
+#define IMGVIEW_DOWN BUTTON_OPTION
+#define IMGVIEW_LEFT BUTTON_PREV
+#define IMGVIEW_RIGHT BUTTON_NEXT
+#define IMGVIEW_NEXT BUTTON_VOL_UP
+#define IMGVIEW_NEXT_REPEAT (BUTTON_VOL_UP|BUTTON_REPEAT)
+#define IMGVIEW_PREVIOUS BUTTON_VOL_DOWN
+#define IMGVIEW_PREVIOUS_REPEAT (BUTTON_VOL_DOWN|BUTTON_REPEAT)
+#define IMGVIEW_MENU BUTTON_POWER
+#define IMGVIEW_SLIDE_SHOW (BUTTON_HOME|BUTTON_POWER)
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define IMGVIEW_ZOOM_PRE BUTTON_PLAY
+#define IMGVIEW_ZOOM_IN (BUTTON_PLAY | BUTTON_REL)
+#define IMGVIEW_ZOOM_OUT (BUTTON_PLAY | BUTTON_REPEAT)
+#define IMGVIEW_UP BUTTON_HOME
+#define IMGVIEW_DOWN BUTTON_OPTION
+#define IMGVIEW_LEFT BUTTON_PREV
+#define IMGVIEW_RIGHT BUTTON_NEXT
+#define IMGVIEW_NEXT BUTTON_VOL_UP
+#define IMGVIEW_NEXT_REPEAT (BUTTON_VOL_UP|BUTTON_REPEAT)
+#define IMGVIEW_PREVIOUS BUTTON_VOL_DOWN
+#define IMGVIEW_PREVIOUS_REPEAT (BUTTON_VOL_DOWN|BUTTON_REPEAT)
+#define IMGVIEW_MENU BUTTON_POWER
+#define IMGVIEW_SLIDE_SHOW (BUTTON_HOME|BUTTON_POWER)
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define IMGVIEW_ZOOM_PRE BUTTON_PLAY
#define IMGVIEW_ZOOM_IN (BUTTON_PLAY | BUTTON_REL)
diff --git a/apps/plugins/invadrox.c b/apps/plugins/invadrox.c
index d3feb236cc..8cf4d67f3e 100644
--- a/apps/plugins/invadrox.c
+++ b/apps/plugins/invadrox.c
@@ -272,6 +272,20 @@ CONFIG_KEYPAD == MROBE500_PAD
#define QUIT BUTTON_POWER
#define FIRE BUTTON_MENU
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+
+#define QUIT BUTTON_POWER
+#define LEFT BUTTON_HOME
+#define RIGHT BUTTON_VOL_DOWN
+#define FIRE BUTTON_VOL_UP
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+
+#define QUIT BUTTON_POWER
+#define LEFT BUTTON_HOME
+#define RIGHT BUTTON_VOL_DOWN
+#define FIRE BUTTON_VOL_UP
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define QUIT BUTTON_POWER
diff --git a/apps/plugins/jewels.c b/apps/plugins/jewels.c
index bc0bc73183..38121a480c 100644
--- a/apps/plugins/jewels.c
+++ b/apps/plugins/jewels.c
@@ -387,6 +387,26 @@ CONFIG_KEYPAD == MROBE500_PAD
#define HK_SELECT "PLAY"
#define HK_CANCEL "POWER"
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define JEWELS_UP BUTTON_HOME
+#define JEWELS_DOWN BUTTON_OPTION
+#define JEWELS_LEFT BUTTON_PREV
+#define JEWELS_RIGHT BUTTON_NEXT
+#define JEWELS_SELECT BUTTON_PLAY
+#define JEWELS_CANCEL BUTTON_POWER
+#define HK_SELECT "PLAY"
+#define HK_CANCEL "POWER"
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define JEWELS_UP BUTTON_HOME
+#define JEWELS_DOWN BUTTON_OPTION
+#define JEWELS_LEFT BUTTON_PREV
+#define JEWELS_RIGHT BUTTON_NEXT
+#define JEWELS_SELECT BUTTON_PLAY
+#define JEWELS_CANCEL BUTTON_POWER
+#define HK_SELECT "PLAY"
+#define HK_CANCEL "POWER"
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define JEWELS_UP BUTTON_PREV
#define JEWELS_DOWN BUTTON_NEXT
diff --git a/apps/plugins/lib/keymaps.h b/apps/plugins/lib/keymaps.h
index e240a0989e..e3de03f222 100644
--- a/apps/plugins/lib/keymaps.h
+++ b/apps/plugins/lib/keymaps.h
@@ -223,6 +223,22 @@
#define BTN_FIRE BUTTON_PLAY
#define BTN_PAUSE BUTTON_POWER
+#elif (CONFIG_KEYPAD == XDUOO_X3II_PAD)
+#define BTN_UP BUTTON_VOL_UP
+#define BTN_DOWN BUTTON_VOL_DOWN
+#define BTN_LEFT BUTTON_PREV
+#define BTN_RIGHT BUTTON_NEXT
+#define BTN_FIRE BUTTON_PLAY
+#define BTN_PAUSE BUTTON_POWER
+
+#elif (CONFIG_KEYPAD == XDUOO_X20_PAD)
+#define BTN_UP BUTTON_VOL_UP
+#define BTN_DOWN BUTTON_VOL_DOWN
+#define BTN_LEFT BUTTON_PREV
+#define BTN_RIGHT BUTTON_NEXT
+#define BTN_FIRE BUTTON_PLAY
+#define BTN_PAUSE BUTTON_POWER
+
#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
#define BTN_UP BUTTON_PREV
#define BTN_DOWN BUTTON_NEXT
diff --git a/apps/plugins/lib/pluginlib_actions.c b/apps/plugins/lib/pluginlib_actions.c
index 97b5a1e1bf..0834e020f4 100644
--- a/apps/plugins/lib/pluginlib_actions.c
+++ b/apps/plugins/lib/pluginlib_actions.c
@@ -237,6 +237,24 @@ const struct button_mapping pla_main_ctx[] =
{ PLA_DOWN_REPEAT, BUTTON_OPTION|BUTTON_REPEAT, BUTTON_NONE },
{ PLA_LEFT_REPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
{ PLA_RIGHT_REPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
+#elif (CONFIG_KEYPAD == XDUOO_X3II_PAD)
+ { PLA_UP, BUTTON_HOME, BUTTON_NONE },
+ { PLA_DOWN, BUTTON_OPTION, BUTTON_NONE },
+ { PLA_LEFT, BUTTON_PREV, BUTTON_NONE },
+ { PLA_RIGHT, BUTTON_NEXT, BUTTON_NONE },
+ { PLA_UP_REPEAT, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE },
+ { PLA_DOWN_REPEAT, BUTTON_OPTION|BUTTON_REPEAT, BUTTON_NONE },
+ { PLA_LEFT_REPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
+ { PLA_RIGHT_REPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
+#elif (CONFIG_KEYPAD == XDUOO_X20_PAD)
+ { PLA_UP, BUTTON_HOME, BUTTON_NONE },
+ { PLA_DOWN, BUTTON_OPTION, BUTTON_NONE },
+ { PLA_LEFT, BUTTON_PREV, BUTTON_NONE },
+ { PLA_RIGHT, BUTTON_NEXT, BUTTON_NONE },
+ { PLA_UP_REPEAT, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE },
+ { PLA_DOWN_REPEAT, BUTTON_OPTION|BUTTON_REPEAT, BUTTON_NONE },
+ { PLA_LEFT_REPEAT, BUTTON_PREV|BUTTON_REPEAT, BUTTON_NONE },
+ { PLA_RIGHT_REPEAT, BUTTON_NEXT|BUTTON_REPEAT, BUTTON_NONE },
#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
{ PLA_UP, BUTTON_PREV, BUTTON_NONE },
{ PLA_DOWN, BUTTON_NEXT, BUTTON_NONE },
@@ -480,6 +498,18 @@ const struct button_mapping pla_main_ctx[] =
{PLA_SELECT, BUTTON_PLAY, BUTTON_NONE},
{PLA_SELECT_REL, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY},
{PLA_SELECT_REPEAT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE},
+#elif (CONFIG_KEYPAD == XDUOO_X3II_PAD)
+ {PLA_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_POWER},
+ {PLA_EXIT, BUTTON_POWER|BUTTON_REPEAT, BUTTON_NONE},
+ {PLA_SELECT, BUTTON_PLAY, BUTTON_NONE},
+ {PLA_SELECT_REL, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY},
+ {PLA_SELECT_REPEAT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE},
+#elif (CONFIG_KEYPAD == XDUOO_X20_PAD)
+ {PLA_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_POWER},
+ {PLA_EXIT, BUTTON_POWER|BUTTON_REPEAT, BUTTON_NONE},
+ {PLA_SELECT, BUTTON_PLAY, BUTTON_NONE},
+ {PLA_SELECT_REL, BUTTON_PLAY|BUTTON_REL, BUTTON_PLAY},
+ {PLA_SELECT_REPEAT, BUTTON_PLAY|BUTTON_REPEAT, BUTTON_NONE},
#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
{PLA_CANCEL, BUTTON_POWER|BUTTON_REL, BUTTON_POWER},
{PLA_EXIT, BUTTON_POWER|BUTTON_REPEAT, BUTTON_NONE},
diff --git a/apps/plugins/midi/midiplay.c b/apps/plugins/midi/midiplay.c
index 8e867e5173..e6e2b4bf51 100644
--- a/apps/plugins/midi/midiplay.c
+++ b/apps/plugins/midi/midiplay.c
@@ -301,6 +301,22 @@
#define MIDI_VOL_DOWN BUTTON_VOL_DOWN
#define MIDI_PLAYPAUSE BUTTON_PLAY
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define MIDI_QUIT BUTTON_POWER
+#define MIDI_FFWD BUTTON_NEXT
+#define MIDI_REWIND BUTTON_PREV
+#define MIDI_VOL_UP BUTTON_VOL_UP
+#define MIDI_VOL_DOWN BUTTON_VOL_DOWN
+#define MIDI_PLAYPAUSE BUTTON_PLAY
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define MIDI_QUIT BUTTON_POWER
+#define MIDI_FFWD BUTTON_NEXT
+#define MIDI_REWIND BUTTON_PREV
+#define MIDI_VOL_UP BUTTON_VOL_UP
+#define MIDI_VOL_DOWN BUTTON_VOL_DOWN
+#define MIDI_PLAYPAUSE BUTTON_PLAY
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define MIDI_QUIT BUTTON_POWER
#define MIDI_FFWD BUTTON_VOL_DOWN
diff --git a/apps/plugins/minesweeper.c b/apps/plugins/minesweeper.c
index 956ba128d5..917f90dcd0 100644
--- a/apps/plugins/minesweeper.c
+++ b/apps/plugins/minesweeper.c
@@ -417,6 +417,32 @@ CONFIG_KEYPAD == MROBE500_PAD
# define MINESWP_DISCOVER2 BUTTON_VOL_UP
# define MINESWP_INFO (BUTTON_PLAY | BUTTON_OPTION)
+#elif (CONFIG_KEYPAD == XDUOO_X3II_PAD)
+# define MINESWP_LEFT BUTTON_PREV
+# define MINESWP_RIGHT BUTTON_NEXT
+# define MINESWP_UP BUTTON_HOME
+# define MINESWP_DOWN BUTTON_OPTION
+# define MINESWP_QUIT BUTTON_POWER
+# define MINESWP_TOGGLE_PRE BUTTON_PLAY
+# define MINESWP_TOGGLE (BUTTON_PLAY | BUTTON_REL)
+# define MINESWP_TOGGLE2 BUTTON_VOL_DOWN
+# define MINESWP_DISCOVER (BUTTON_PLAY | BUTTON_REPEAT)
+# define MINESWP_DISCOVER2 BUTTON_VOL_UP
+# define MINESWP_INFO (BUTTON_PLAY | BUTTON_OPTION)
+
+#elif (CONFIG_KEYPAD == XDUOO_X20_PAD)
+# define MINESWP_LEFT BUTTON_PREV
+# define MINESWP_RIGHT BUTTON_NEXT
+# define MINESWP_UP BUTTON_HOME
+# define MINESWP_DOWN BUTTON_OPTION
+# define MINESWP_QUIT BUTTON_POWER
+# define MINESWP_TOGGLE_PRE BUTTON_PLAY
+# define MINESWP_TOGGLE (BUTTON_PLAY | BUTTON_REL)
+# define MINESWP_TOGGLE2 BUTTON_VOL_DOWN
+# define MINESWP_DISCOVER (BUTTON_PLAY | BUTTON_REPEAT)
+# define MINESWP_DISCOVER2 BUTTON_VOL_UP
+# define MINESWP_INFO (BUTTON_PLAY | BUTTON_OPTION)
+
#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
# define MINESWP_LEFT BUTTON_HOME
# define MINESWP_RIGHT BUTTON_VOL_DOWN
diff --git a/apps/plugins/mp3_encoder.c b/apps/plugins/mp3_encoder.c
index d147120cd4..3b912ba606 100644
--- a/apps/plugins/mp3_encoder.c
+++ b/apps/plugins/mp3_encoder.c
@@ -2562,6 +2562,19 @@ CONFIG_KEYPAD == MROBE500_PAD
#define MP3ENC_DONE BUTTON_POWER
#define MP3ENC_SELECT BUTTON_PLAY
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define MP3ENC_PREV BUTTON_HOME
+#define MP3ENC_NEXT BUTTON_OPTION
+#define MP3ENC_DONE BUTTON_POWER
+#define MP3ENC_SELECT BUTTON_PLAY
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define MP3ENC_PREV BUTTON_HOME
+#define MP3ENC_NEXT BUTTON_OPTION
+#define MP3ENC_DONE BUTTON_POWER
+#define MP3ENC_SELECT BUTTON_PLAY
+
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define MP3ENC_PREV BUTTON_PREV
#define MP3ENC_NEXT BUTTON_NEXT
diff --git a/apps/plugins/mpegplayer/mpeg_settings.c b/apps/plugins/mpegplayer/mpeg_settings.c
index 8427db12b4..d5d7c7c019 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.c
+++ b/apps/plugins/mpegplayer/mpeg_settings.c
@@ -316,6 +316,26 @@ struct mpeg_settings settings;
#define MPEG_START_TIME_RIGHT2 BUTTON_VOL_DOWN
#define MPEG_START_TIME_EXIT BUTTON_POWER
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define MPEG_START_TIME_SELECT BUTTON_PLAY
+#define MPEG_START_TIME_LEFT BUTTON_PREV
+#define MPEG_START_TIME_RIGHT BUTTON_NEXT
+#define MPEG_START_TIME_UP BUTTON_HOME
+#define MPEG_START_TIME_DOWN BUTTON_OPTION
+#define MPEG_START_TIME_LEFT2 BUTTON_VOL_UP
+#define MPEG_START_TIME_RIGHT2 BUTTON_VOL_DOWN
+#define MPEG_START_TIME_EXIT BUTTON_POWER
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define MPEG_START_TIME_SELECT BUTTON_PLAY
+#define MPEG_START_TIME_LEFT BUTTON_PREV
+#define MPEG_START_TIME_RIGHT BUTTON_NEXT
+#define MPEG_START_TIME_UP BUTTON_HOME
+#define MPEG_START_TIME_DOWN BUTTON_OPTION
+#define MPEG_START_TIME_LEFT2 BUTTON_VOL_UP
+#define MPEG_START_TIME_RIGHT2 BUTTON_VOL_DOWN
+#define MPEG_START_TIME_EXIT BUTTON_POWER
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define MPEG_START_TIME_SELECT BUTTON_PLAY
#define MPEG_START_TIME_LEFT BUTTON_HOME
diff --git a/apps/plugins/mpegplayer/mpegplayer.c b/apps/plugins/mpegplayer/mpegplayer.c
index 39ea484ff2..eed1fab6d7 100644
--- a/apps/plugins/mpegplayer/mpegplayer.c
+++ b/apps/plugins/mpegplayer/mpegplayer.c
@@ -450,6 +450,24 @@ CONFIG_KEYPAD == SANSA_M200_PAD
#define MPEG_RW BUTTON_PREV
#define MPEG_FF BUTTON_NEXT
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define MPEG_MENU BUTTON_PLAY
+#define MPEG_STOP BUTTON_POWER
+#define MPEG_PAUSE BUTTON_HOME
+#define MPEG_VOLDOWN BUTTON_VOL_DOWN
+#define MPEG_VOLUP BUTTON_VOL_UP
+#define MPEG_RW BUTTON_PREV
+#define MPEG_FF BUTTON_NEXT
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define MPEG_MENU BUTTON_PLAY
+#define MPEG_STOP BUTTON_POWER
+#define MPEG_PAUSE BUTTON_HOME
+#define MPEG_VOLDOWN BUTTON_VOL_DOWN
+#define MPEG_VOLUP BUTTON_VOL_UP
+#define MPEG_RW BUTTON_PREV
+#define MPEG_FF BUTTON_NEXT
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define MPEG_MENU BUTTON_PLAY
#define MPEG_STOP BUTTON_POWER
diff --git a/apps/plugins/oscilloscope.c b/apps/plugins/oscilloscope.c
index f4711d4e0e..6702add139 100644
--- a/apps/plugins/oscilloscope.c
+++ b/apps/plugins/oscilloscope.c
@@ -518,6 +518,35 @@
#define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN
#define NEED_LASTBUTTON
+#elif (CONFIG_KEYPAD == XDUOO_X3II_PAD)
+#define OSCILLOSCOPE_QUIT BUTTON_POWER
+#define OSCILLOSCOPE_DRAWMODE_PRE BUTTON_PLAY
+#define OSCILLOSCOPE_DRAWMODE (BUTTON_PLAY | BUTTON_REL)
+#define OSCILLOSCOPE_ORIENTATION_PRE BUTTON_PLAY
+#define OSCILLOSCOPE_ORIENTATION (BUTTON_PLAY | BUTTON_REPEAT)
+#define OSCILLOSCOPE_ADVMODE BUTTON_HOME
+#define OSCILLOSCOPE_PAUSE BUTTON_OPTION
+#define OSCILLOSCOPE_SPEED_UP BUTTON_NEXT
+#define OSCILLOSCOPE_SPEED_DOWN BUTTON_PREV
+#define OSCILLOSCOPE_VOL_UP BUTTON_VOL_UP
+#define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN
+#define NEED_LASTBUTTON
+
+#elif (CONFIG_KEYPAD == XDUOO_X20_PAD)
+#define OSCILLOSCOPE_QUIT BUTTON_POWER
+#define OSCILLOSCOPE_DRAWMODE_PRE BUTTON_PLAY
+#define OSCILLOSCOPE_DRAWMODE (BUTTON_PLAY | BUTTON_REL)
+#define OSCILLOSCOPE_ORIENTATION_PRE BUTTON_PLAY
+#define OSCILLOSCOPE_ORIENTATION (BUTTON_PLAY | BUTTON_REPEAT)
+#define OSCILLOSCOPE_ADVMODE BUTTON_HOME
+#define OSCILLOSCOPE_PAUSE BUTTON_OPTION
+#define OSCILLOSCOPE_SPEED_UP BUTTON_NEXT
+#define OSCILLOSCOPE_SPEED_DOWN BUTTON_PREV
+#define OSCILLOSCOPE_VOL_UP BUTTON_VOL_UP
+#define OSCILLOSCOPE_VOL_DOWN BUTTON_VOL_DOWN
+#define NEED_LASTBUTTON
+
+
#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
#define OSCILLOSCOPE_QUIT BUTTON_POWER
#define OSCILLOSCOPE_DRAWMODE_PRE BUTTON_PLAY
diff --git a/apps/plugins/pacbox/pacbox.h b/apps/plugins/pacbox/pacbox.h
index 0e3de62dfa..78a171467a 100644
--- a/apps/plugins/pacbox/pacbox.h
+++ b/apps/plugins/pacbox/pacbox.h
@@ -364,6 +364,25 @@
#define PACMAN_1UP BUTTON_VOLUP
#define PACMAN_COIN BUTTON_VOLDOWN
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define PACMAN_UP BUTTON_PREV
+#define PACMAN_DOWN BUTTON_NEXT
+#define PACMAN_LEFT BUTTON_HOME
+#define PACMAN_RIGHT BUTTON_VOL_DOWN
+#define PACMAN_MENU BUTTON_POWER
+#define PACMAN_1UP BUTTON_VOL_UP
+#define PACMAN_COIN BUTTON_PLAY
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define PACMAN_UP BUTTON_PREV
+#define PACMAN_DOWN BUTTON_NEXT
+#define PACMAN_LEFT BUTTON_HOME
+#define PACMAN_RIGHT BUTTON_VOL_DOWN
+#define PACMAN_MENU BUTTON_POWER
+#define PACMAN_1UP BUTTON_VOL_UP
+#define PACMAN_COIN BUTTON_PLAY
+
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define PACMAN_UP BUTTON_PREV
#define PACMAN_DOWN BUTTON_NEXT
diff --git a/apps/plugins/pegbox.c b/apps/plugins/pegbox.c
index cc2e8e3f23..b638f2feeb 100644
--- a/apps/plugins/pegbox.c
+++ b/apps/plugins/pegbox.c
@@ -660,6 +660,40 @@ CONFIG_KEYPAD == MROBE500_PAD
#define LVL_UP_TEXT "VOL+"
#define LVL_DOWN_TEXT "VOL-"
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define PEGBOX_SELECT BUTTON_PLAY
+#define PEGBOX_QUIT BUTTON_POWER
+#define PEGBOX_RESTART (BUTTON_POWER | BUTTON_HOME)
+#define PEGBOX_LVL_UP BUTTON_VOL_UP
+#define PEGBOX_LVL_DOWN BUTTON_VOL_DOWN
+#define PEGBOX_UP BUTTON_HOME
+#define PEGBOX_DOWN BUTTON_OPTION
+#define PEGBOX_RIGHT BUTTON_NEXT
+#define PEGBOX_LEFT BUTTON_PREV
+
+#define SELECT_TEXT "PLAY"
+#define QUIT_TEXT "POWER"
+#define RESTART_TEXT "HOME"
+#define LVL_UP_TEXT "VOL+"
+#define LVL_DOWN_TEXT "VOL-"
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define PEGBOX_SELECT BUTTON_PLAY
+#define PEGBOX_QUIT BUTTON_POWER
+#define PEGBOX_RESTART (BUTTON_POWER | BUTTON_HOME)
+#define PEGBOX_LVL_UP BUTTON_VOL_UP
+#define PEGBOX_LVL_DOWN BUTTON_VOL_DOWN
+#define PEGBOX_UP BUTTON_HOME
+#define PEGBOX_DOWN BUTTON_OPTION
+#define PEGBOX_RIGHT BUTTON_NEXT
+#define PEGBOX_LEFT BUTTON_PREV
+
+#define SELECT_TEXT "PLAY"
+#define QUIT_TEXT "POWER"
+#define RESTART_TEXT "HOME"
+#define LVL_UP_TEXT "VOL+"
+#define LVL_DOWN_TEXT "VOL-"
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define PEGBOX_SELECT BUTTON_PLAY
#define PEGBOX_QUIT BUTTON_POWER
diff --git a/apps/plugins/pong.c b/apps/plugins/pong.c
index cb3006d7c4..3656a35fd2 100644
--- a/apps/plugins/pong.c
+++ b/apps/plugins/pong.c
@@ -317,6 +317,22 @@ CONFIG_KEYPAD == MROBE500_PAD
#define PONG_RIGHT_UP BUTTON_HOME
#define PONG_RIGHT_DOWN BUTTON_NEXT
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define PONG_QUIT BUTTON_POWER
+#define PONG_PAUSE BUTTON_PLAY
+#define PONG_LEFT_UP BUTTON_PREV
+#define PONG_LEFT_DOWN BUTTON_OPTION
+#define PONG_RIGHT_UP BUTTON_HOME
+#define PONG_RIGHT_DOWN BUTTON_NEXT
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define PONG_QUIT BUTTON_POWER
+#define PONG_PAUSE BUTTON_PLAY
+#define PONG_LEFT_UP BUTTON_PREV
+#define PONG_LEFT_DOWN BUTTON_OPTION
+#define PONG_RIGHT_UP BUTTON_HOME
+#define PONG_RIGHT_DOWN BUTTON_NEXT
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define PONG_QUIT BUTTON_POWER
#define PONG_PAUSE BUTTON_PREV
diff --git a/apps/plugins/reversi/reversi-gui.h b/apps/plugins/reversi/reversi-gui.h
index cba34d2814..4ec6bcb67b 100644
--- a/apps/plugins/reversi/reversi-gui.h
+++ b/apps/plugins/reversi/reversi-gui.h
@@ -339,6 +339,28 @@
#define REVERSI_BUTTON_MENU BUTTON_PLAY
#define REVERSI_BUTTON_MENU_LONGPRESS
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define REVERSI_BUTTON_QUIT BUTTON_POWER
+#define REVERSI_BUTTON_UP BUTTON_HOME
+#define REVERSI_BUTTON_DOWN BUTTON_OPTION
+#define REVERSI_BUTTON_LEFT BUTTON_PREV
+#define REVERSI_BUTTON_RIGHT BUTTON_NEXT
+#define REVERSI_BUTTON_MAKE_MOVE BUTTON_PLAY
+#define REVERSI_BUTTON_MAKE_MOVE_SHORTPRESS
+#define REVERSI_BUTTON_MENU BUTTON_PLAY
+#define REVERSI_BUTTON_MENU_LONGPRESS
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define REVERSI_BUTTON_QUIT BUTTON_POWER
+#define REVERSI_BUTTON_UP BUTTON_HOME
+#define REVERSI_BUTTON_DOWN BUTTON_OPTION
+#define REVERSI_BUTTON_LEFT BUTTON_PREV
+#define REVERSI_BUTTON_RIGHT BUTTON_NEXT
+#define REVERSI_BUTTON_MAKE_MOVE BUTTON_PLAY
+#define REVERSI_BUTTON_MAKE_MOVE_SHORTPRESS
+#define REVERSI_BUTTON_MENU BUTTON_PLAY
+#define REVERSI_BUTTON_MENU_LONGPRESS
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define REVERSI_BUTTON_QUIT BUTTON_POWER
#define REVERSI_BUTTON_UP BUTTON_PREV
diff --git a/apps/plugins/rockblox.c b/apps/plugins/rockblox.c
index 13eb593775..e2fedab200 100644
--- a/apps/plugins/rockblox.c
+++ b/apps/plugins/rockblox.c
@@ -492,6 +492,30 @@
#define ROCKBLOX_DROP (BUTTON_PLAY|BUTTON_REL)
#define ROCKBLOX_RESTART (BUTTON_PLAY|BUTTON_REPEAT)
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+
+#define ROCKBLOX_OFF BUTTON_POWER
+#define ROCKBLOX_ROTATE_CCW BUTTON_HOME
+#define ROCKBLOX_ROTATE_CCW2 BUTTON_VOL_DOWN
+#define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP
+#define ROCKBLOX_DOWN BUTTON_OPTION
+#define ROCKBLOX_LEFT BUTTON_PREV
+#define ROCKBLOX_RIGHT BUTTON_NEXT
+#define ROCKBLOX_DROP (BUTTON_PLAY|BUTTON_REL)
+#define ROCKBLOX_RESTART (BUTTON_PLAY|BUTTON_REPEAT)
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+
+#define ROCKBLOX_OFF BUTTON_POWER
+#define ROCKBLOX_ROTATE_CCW BUTTON_HOME
+#define ROCKBLOX_ROTATE_CCW2 BUTTON_VOL_DOWN
+#define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP
+#define ROCKBLOX_DOWN BUTTON_OPTION
+#define ROCKBLOX_LEFT BUTTON_PREV
+#define ROCKBLOX_RIGHT BUTTON_NEXT
+#define ROCKBLOX_DROP (BUTTON_PLAY|BUTTON_REL)
+#define ROCKBLOX_RESTART (BUTTON_PLAY|BUTTON_REPEAT)
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define ROCKBLOX_OFF BUTTON_POWER
diff --git a/apps/plugins/rockboy/rockboy.c b/apps/plugins/rockboy/rockboy.c
index 8886793ab7..f188dc1e24 100644
--- a/apps/plugins/rockboy/rockboy.c
+++ b/apps/plugins/rockboy/rockboy.c
@@ -433,6 +433,26 @@ static void setoptions (void)
options.SELECT = BUTTON_VOL_UP;
options.MENU = BUTTON_POWER;
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+ options.UP = BUTTON_PREV;
+ options.DOWN = BUTTON_NEXT;
+
+ options.A = BUTTON_HOME;
+ options.B = BUTTON_OPTION;
+ options.START = BUTTON_VOL_DOWN;
+ options.SELECT = BUTTON_VOL_UP;
+ options.MENU = BUTTON_POWER;
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+ options.UP = BUTTON_PREV;
+ options.DOWN = BUTTON_NEXT;
+
+ options.A = BUTTON_HOME;
+ options.B = BUTTON_OPTION;
+ options.START = BUTTON_VOL_DOWN;
+ options.SELECT = BUTTON_VOL_UP;
+ options.MENU = BUTTON_POWER;
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
options.UP = BUTTON_PREV;
options.DOWN = BUTTON_NEXT;
diff --git a/apps/plugins/sliding_puzzle.c b/apps/plugins/sliding_puzzle.c
index 0ea36c84b8..9b863906ce 100644
--- a/apps/plugins/sliding_puzzle.c
+++ b/apps/plugins/sliding_puzzle.c
@@ -340,6 +340,25 @@ CONFIG_KEYPAD == MROBE500_PAD
#define PUZZLE_SHUFFLE (BUTTON_HOME | BUTTON_POWER)
#define PUZZLE_PICTURE BUTTON_PLAY
+#elif (CONFIG_KEYPAD == XDUOO_X3II_PAD)
+#define PUZZLE_QUIT BUTTON_POWER
+#define PUZZLE_LEFT BUTTON_PREV
+#define PUZZLE_RIGHT BUTTON_NEXT
+#define PUZZLE_UP BUTTON_HOME
+#define PUZZLE_DOWN BUTTON_OPTION
+#define PUZZLE_SHUFFLE (BUTTON_HOME | BUTTON_POWER)
+#define PUZZLE_PICTURE BUTTON_PLAY
+
+#elif (CONFIG_KEYPAD == XDUOO_X20_PAD)
+#define PUZZLE_QUIT BUTTON_POWER
+#define PUZZLE_LEFT BUTTON_PREV
+#define PUZZLE_RIGHT BUTTON_NEXT
+#define PUZZLE_UP BUTTON_HOME
+#define PUZZLE_DOWN BUTTON_OPTION
+#define PUZZLE_SHUFFLE (BUTTON_HOME | BUTTON_POWER)
+#define PUZZLE_PICTURE BUTTON_PLAY
+
+
#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
#define PUZZLE_QUIT BUTTON_POWER
#define PUZZLE_LEFT BUTTON_HOME
diff --git a/apps/plugins/snake.c b/apps/plugins/snake.c
index 2518316bdd..ae1e4350ad 100644
--- a/apps/plugins/snake.c
+++ b/apps/plugins/snake.c
@@ -297,6 +297,22 @@ dir is the current direction of the snake - 0=up, 1=right, 2=down, 3=left;
#define SNAKE_DOWN BUTTON_OPTION
#define SNAKE_PLAYPAUSE BUTTON_PLAY
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define SNAKE_QUIT BUTTON_POWER
+#define SNAKE_LEFT BUTTON_PREV
+#define SNAKE_RIGHT BUTTON_NEXT
+#define SNAKE_UP BUTTON_HOME
+#define SNAKE_DOWN BUTTON_OPTION
+#define SNAKE_PLAYPAUSE BUTTON_PLAY
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define SNAKE_QUIT BUTTON_POWER
+#define SNAKE_LEFT BUTTON_PREV
+#define SNAKE_RIGHT BUTTON_NEXT
+#define SNAKE_UP BUTTON_HOME
+#define SNAKE_DOWN BUTTON_OPTION
+#define SNAKE_PLAYPAUSE BUTTON_PLAY
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define SNAKE_QUIT BUTTON_POWER
#define SNAKE_LEFT BUTTON_HOME
diff --git a/apps/plugins/snake2.c b/apps/plugins/snake2.c
index 9ea79504e4..a9f0942806 100644
--- a/apps/plugins/snake2.c
+++ b/apps/plugins/snake2.c
@@ -428,6 +428,24 @@ CONFIG_KEYPAD == MROBE500_PAD
#define SNAKE2_PLAYPAUSE BUTTON_PLAY
#define SNAKE2_PLAYPAUSE_TEXT "PLAY"
+#elif (CONFIG_KEYPAD == XDUOO_X3II_PAD)
+#define SNAKE2_LEFT BUTTON_PREV
+#define SNAKE2_RIGHT BUTTON_NEXT
+#define SNAKE2_UP BUTTON_HOME
+#define SNAKE2_DOWN BUTTON_OPTION
+#define SNAKE2_QUIT BUTTON_POWER
+#define SNAKE2_PLAYPAUSE BUTTON_PLAY
+#define SNAKE2_PLAYPAUSE_TEXT "PLAY"
+
+#elif (CONFIG_KEYPAD == XDUOO_X20_PAD)
+#define SNAKE2_LEFT BUTTON_PREV
+#define SNAKE2_RIGHT BUTTON_NEXT
+#define SNAKE2_UP BUTTON_HOME
+#define SNAKE2_DOWN BUTTON_OPTION
+#define SNAKE2_QUIT BUTTON_POWER
+#define SNAKE2_PLAYPAUSE BUTTON_PLAY
+#define SNAKE2_PLAYPAUSE_TEXT "PLAY"
+
#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
#define SNAKE2_LEFT BUTTON_HOME
#define SNAKE2_RIGHT BUTTON_VOL_DOWN
diff --git a/apps/plugins/sokoban.c b/apps/plugins/sokoban.c
index 17971ec4db..450c881d1e 100644
--- a/apps/plugins/sokoban.c
+++ b/apps/plugins/sokoban.c
@@ -667,6 +667,38 @@
#define BUTTON_SAVE BUTTON_PLAY
#define BUTTON_SAVE_NAME "PLAY"
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define SOKOBAN_LEFT BUTTON_PREV
+#define SOKOBAN_RIGHT BUTTON_NEXT
+#define SOKOBAN_UP BUTTON_HOME
+#define SOKOBAN_DOWN BUTTON_OPTION
+#define SOKOBAN_MENU BUTTON_POWER
+#define SOKOBAN_UNDO_PRE BUTTON_PLAY
+#define SOKOBAN_UNDO (BUTTON_PLAY | BUTTON_REL)
+#define SOKOBAN_REDO (BUTTON_POWER | BUTTON_PLAY)
+#define SOKOBAN_LEVEL_DOWN BUTTON_VOL_DOWN
+#define SOKOBAN_LEVEL_REPEAT (BUTTON_PLAY | BUTTON_NEXT)
+#define SOKOBAN_LEVEL_UP BUTTON_VOL_UP
+#define SOKOBAN_PAUSE BUTTON_PLAY
+#define BUTTON_SAVE BUTTON_PLAY
+#define BUTTON_SAVE_NAME "PLAY"
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define SOKOBAN_LEFT BUTTON_PREV
+#define SOKOBAN_RIGHT BUTTON_NEXT
+#define SOKOBAN_UP BUTTON_HOME
+#define SOKOBAN_DOWN BUTTON_OPTION
+#define SOKOBAN_MENU BUTTON_POWER
+#define SOKOBAN_UNDO_PRE BUTTON_PLAY
+#define SOKOBAN_UNDO (BUTTON_PLAY | BUTTON_REL)
+#define SOKOBAN_REDO (BUTTON_POWER | BUTTON_PLAY)
+#define SOKOBAN_LEVEL_DOWN BUTTON_VOL_DOWN
+#define SOKOBAN_LEVEL_REPEAT (BUTTON_PLAY | BUTTON_NEXT)
+#define SOKOBAN_LEVEL_UP BUTTON_VOL_UP
+#define SOKOBAN_PAUSE BUTTON_PLAY
+#define BUTTON_SAVE BUTTON_PLAY
+#define BUTTON_SAVE_NAME "PLAY"
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define SOKOBAN_LEFT BUTTON_HOME
#define SOKOBAN_RIGHT BUTTON_VOL_DOWN
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c
index 1ee79bb86a..dd4c8d3447 100644
--- a/apps/plugins/solitaire.c
+++ b/apps/plugins/solitaire.c
@@ -706,6 +706,44 @@ CONFIG_KEYPAD == MROBE500_PAD
# define HK_CUR2STACK "DBL PLAY"
# define HK_REM2STACK "NEXT"
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+# define SOL_QUIT BUTTON_POWER
+# define SOL_UP BUTTON_HOME
+# define SOL_DOWN BUTTON_OPTION
+# define SOL_LEFT BUTTON_PREV
+# define SOL_RIGHT BUTTON_NEXT
+# define SOL_MOVE_PRE BUTTON_PLAY
+# define SOL_MOVE (BUTTON_PLAY | BUTTON_REL)
+# define SOL_DRAW (BUTTON_POWER | BUTTON_REPEAT)
+# define SOL_REM2CUR BUTTON_VOL_DOWN
+# define SOL_CUR2STACK_PRE BUTTON_PLAY
+# define SOL_CUR2STACK (BUTTON_PLAY | BUTTON_REPEAT)
+# define SOL_REM2STACK BUTTON_VOL_UP
+# define HK_MOVE "PLAY"
+# define HK_DRAW "DBL HOME"
+# define HK_REM2CUR "PREV"
+# define HK_CUR2STACK "DBL PLAY"
+# define HK_REM2STACK "NEXT"
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+# define SOL_QUIT BUTTON_POWER
+# define SOL_UP BUTTON_HOME
+# define SOL_DOWN BUTTON_OPTION
+# define SOL_LEFT BUTTON_PREV
+# define SOL_RIGHT BUTTON_NEXT
+# define SOL_MOVE_PRE BUTTON_PLAY
+# define SOL_MOVE (BUTTON_PLAY | BUTTON_REL)
+# define SOL_DRAW (BUTTON_POWER | BUTTON_REPEAT)
+# define SOL_REM2CUR BUTTON_VOL_DOWN
+# define SOL_CUR2STACK_PRE BUTTON_PLAY
+# define SOL_CUR2STACK (BUTTON_PLAY | BUTTON_REPEAT)
+# define SOL_REM2STACK BUTTON_VOL_UP
+# define HK_MOVE "PLAY"
+# define HK_DRAW "DBL HOME"
+# define HK_REM2CUR "PREV"
+# define HK_CUR2STACK "DBL PLAY"
+# define HK_REM2STACK "NEXT"
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
# define SOL_QUIT BUTTON_POWER
# define SOL_UP BUTTON_PREV
diff --git a/apps/plugins/spacerocks.c b/apps/plugins/spacerocks.c
index 15d4039b4d..98c6d1a032 100644
--- a/apps/plugins/spacerocks.c
+++ b/apps/plugins/spacerocks.c
@@ -363,6 +363,24 @@
#define AST_RIGHT BUTTON_NEXT
#define AST_FIRE BUTTON_PLAY
+#elif (CONFIG_KEYPAD == XDUOO_X3II_PAD)
+#define AST_PAUSE BUTTON_VOL_UP
+#define AST_QUIT BUTTON_POWER
+#define AST_THRUST BUTTON_HOME
+#define AST_HYPERSPACE BUTTON_OPTION
+#define AST_LEFT BUTTON_PREV
+#define AST_RIGHT BUTTON_NEXT
+#define AST_FIRE BUTTON_PLAY
+
+#elif (CONFIG_KEYPAD == XDUOO_X20_PAD)
+#define AST_PAUSE BUTTON_VOL_UP
+#define AST_QUIT BUTTON_POWER
+#define AST_THRUST BUTTON_HOME
+#define AST_HYPERSPACE BUTTON_OPTION
+#define AST_LEFT BUTTON_PREV
+#define AST_RIGHT BUTTON_NEXT
+#define AST_FIRE BUTTON_PLAY
+
#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
#define AST_PAUSE BUTTON_PLAY
#define AST_QUIT BUTTON_POWER
diff --git a/apps/plugins/star.c b/apps/plugins/star.c
index fdf67bec4c..43036e2808 100644
--- a/apps/plugins/star.c
+++ b/apps/plugins/star.c
@@ -639,6 +639,38 @@
#define STAR_LEVEL_DOWN_NAME "PLAY + PREV"
#define STAR_LEVEL_REPEAT_NAME "PLAY + OPTION"
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define STAR_QUIT BUTTON_POWER
+#define STAR_LEFT BUTTON_PREV
+#define STAR_RIGHT BUTTON_NEXT
+#define STAR_UP BUTTON_HOME
+#define STAR_DOWN BUTTON_OPTION
+#define STAR_TOGGLE_CONTROL BUTTON_PLAY
+#define STAR_LEVEL_UP (BUTTON_PLAY | BUTTON_NEXT)
+#define STAR_LEVEL_DOWN (BUTTON_PLAY | BUTTON_PREV)
+#define STAR_LEVEL_REPEAT (BUTTON_PLAY | BUTTON_OPTION)
+#define STAR_TOGGLE_CONTROL_NAME "PLAY"
+#define STAR_QUIT_NAME "POWER"
+#define STAR_LEVEL_UP_NAME "PLAY + NEXT"
+#define STAR_LEVEL_DOWN_NAME "PLAY + PREV"
+#define STAR_LEVEL_REPEAT_NAME "PLAY + OPTION"
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define STAR_QUIT BUTTON_POWER
+#define STAR_LEFT BUTTON_PREV
+#define STAR_RIGHT BUTTON_NEXT
+#define STAR_UP BUTTON_HOME
+#define STAR_DOWN BUTTON_OPTION
+#define STAR_TOGGLE_CONTROL BUTTON_PLAY
+#define STAR_LEVEL_UP (BUTTON_PLAY | BUTTON_NEXT)
+#define STAR_LEVEL_DOWN (BUTTON_PLAY | BUTTON_PREV)
+#define STAR_LEVEL_REPEAT (BUTTON_PLAY | BUTTON_OPTION)
+#define STAR_TOGGLE_CONTROL_NAME "PLAY"
+#define STAR_QUIT_NAME "POWER"
+#define STAR_LEVEL_UP_NAME "PLAY + NEXT"
+#define STAR_LEVEL_DOWN_NAME "PLAY + PREV"
+#define STAR_LEVEL_REPEAT_NAME "PLAY + OPTION"
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define STAR_QUIT BUTTON_POWER
#define STAR_LEFT BUTTON_HOME
diff --git a/apps/plugins/stopwatch.c b/apps/plugins/stopwatch.c
index 5e83859d89..a806e4e830 100644
--- a/apps/plugins/stopwatch.c
+++ b/apps/plugins/stopwatch.c
@@ -321,6 +321,22 @@
#define STOPWATCH_SCROLL_UP BUTTON_HOME
#define STOPWATCH_SCROLL_DOWN BUTTON_OPTION
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define STOPWATCH_QUIT BUTTON_POWER
+#define STOPWATCH_START_STOP BUTTON_NEXT
+#define STOPWATCH_RESET_TIMER BUTTON_PREV
+#define STOPWATCH_LAP_TIMER BUTTON_PLAY
+#define STOPWATCH_SCROLL_UP BUTTON_HOME
+#define STOPWATCH_SCROLL_DOWN BUTTON_OPTION
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define STOPWATCH_QUIT BUTTON_POWER
+#define STOPWATCH_START_STOP BUTTON_NEXT
+#define STOPWATCH_RESET_TIMER BUTTON_PREV
+#define STOPWATCH_LAP_TIMER BUTTON_PLAY
+#define STOPWATCH_SCROLL_UP BUTTON_HOME
+#define STOPWATCH_SCROLL_DOWN BUTTON_OPTION
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define STOPWATCH_QUIT BUTTON_POWER
#define STOPWATCH_START_STOP BUTTON_NEXT
diff --git a/apps/plugins/sudoku/sudoku.h b/apps/plugins/sudoku/sudoku.h
index 62ec80dba8..2bee868de9 100644
--- a/apps/plugins/sudoku/sudoku.h
+++ b/apps/plugins/sudoku/sudoku.h
@@ -437,6 +437,34 @@
#define SUDOKU_BUTTON_MENU (BUTTON_POWER | BUTTON_REL)
#define SUDOKU_BUTTON_POSSIBLE (BUTTON_HOME | BUTTON_POWER)
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define SUDOKU_BUTTON_QUIT_PRE BUTTON_POWER
+#define SUDOKU_BUTTON_QUIT (BUTTON_POWER | BUTTON_REPEAT)
+#define SUDOKU_BUTTON_UP BUTTON_HOME
+#define SUDOKU_BUTTON_DOWN BUTTON_OPTION
+#define SUDOKU_BUTTON_LEFT BUTTON_PREV
+#define SUDOKU_BUTTON_RIGHT BUTTON_NEXT
+#define SUDOKU_BUTTON_TOGGLEBACK BUTTON_VOL_DOWN
+#define SUDOKU_BUTTON_TOGGLE BUTTON_VOL_UP
+#define SUDOKU_BUTTON_ALTTOGGLE BUTTON_PLAY
+#define SUDOKU_BUTTON_MENU_PRE BUTTON_POWER
+#define SUDOKU_BUTTON_MENU (BUTTON_POWER | BUTTON_REL)
+#define SUDOKU_BUTTON_POSSIBLE (BUTTON_HOME | BUTTON_POWER)
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define SUDOKU_BUTTON_QUIT_PRE BUTTON_POWER
+#define SUDOKU_BUTTON_QUIT (BUTTON_POWER | BUTTON_REPEAT)
+#define SUDOKU_BUTTON_UP BUTTON_HOME
+#define SUDOKU_BUTTON_DOWN BUTTON_OPTION
+#define SUDOKU_BUTTON_LEFT BUTTON_PREV
+#define SUDOKU_BUTTON_RIGHT BUTTON_NEXT
+#define SUDOKU_BUTTON_TOGGLEBACK BUTTON_VOL_DOWN
+#define SUDOKU_BUTTON_TOGGLE BUTTON_VOL_UP
+#define SUDOKU_BUTTON_ALTTOGGLE BUTTON_PLAY
+#define SUDOKU_BUTTON_MENU_PRE BUTTON_POWER
+#define SUDOKU_BUTTON_MENU (BUTTON_POWER | BUTTON_REL)
+#define SUDOKU_BUTTON_POSSIBLE (BUTTON_HOME | BUTTON_POWER)
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define SUDOKU_BUTTON_QUIT_PRE BUTTON_POWER
#define SUDOKU_BUTTON_QUIT (BUTTON_POWER | BUTTON_REPEAT)
diff --git a/apps/plugins/text_viewer/tv_button.h b/apps/plugins/text_viewer/tv_button.h
index da6453ff8d..6ee8f9bbf1 100644
--- a/apps/plugins/text_viewer/tv_button.h
+++ b/apps/plugins/text_viewer/tv_button.h
@@ -562,6 +562,30 @@
#define TV_LINE_DOWN BUTTON_OPTION
#define TV_BOOKMARK (BUTTON_OPTION | BUTTON_PLAY)
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define TV_QUIT BUTTON_POWER
+#define TV_SCROLL_UP BUTTON_VOL_UP
+#define TV_SCROLL_DOWN BUTTON_VOL_DOWN
+#define TV_SCREEN_LEFT BUTTON_PREV
+#define TV_SCREEN_RIGHT BUTTON_NEXT
+#define TV_MENU BUTTON_PLAY
+#define TV_AUTOSCROLL (BUTTON_POWER | BUTTON_HOME)
+#define TV_LINE_UP BUTTON_HOME
+#define TV_LINE_DOWN BUTTON_OPTION
+#define TV_BOOKMARK (BUTTON_OPTION | BUTTON_PLAY)
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define TV_QUIT BUTTON_POWER
+#define TV_SCROLL_UP BUTTON_VOL_UP
+#define TV_SCROLL_DOWN BUTTON_VOL_DOWN
+#define TV_SCREEN_LEFT BUTTON_PREV
+#define TV_SCREEN_RIGHT BUTTON_NEXT
+#define TV_MENU BUTTON_PLAY
+#define TV_AUTOSCROLL (BUTTON_POWER | BUTTON_HOME)
+#define TV_LINE_UP BUTTON_HOME
+#define TV_LINE_DOWN BUTTON_OPTION
+#define TV_BOOKMARK (BUTTON_OPTION | BUTTON_PLAY)
+
/* Xuelin 770/770c keys */
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define TV_QUIT BUTTON_POWER
diff --git a/apps/plugins/vu_meter.c b/apps/plugins/vu_meter.c
index eaa92d4b48..33ad38d72c 100644
--- a/apps/plugins/vu_meter.c
+++ b/apps/plugins/vu_meter.c
@@ -432,6 +432,28 @@
#define LABEL_MENU "PLAY"
#define LABEL_VOLUME "VOL UP/DN"
+#elif (CONFIG_KEYPAD == XDUOO_X3II_PAD)
+#define VUMETER_QUIT BUTTON_POWER
+#define VUMETER_HELP BUTTON_HOME
+#define VUMETER_MENU BUTTON_PLAY
+#define VUMETER_UP BUTTON_VOL_UP
+#define VUMETER_DOWN BUTTON_VOL_DOWN
+#define LABEL_HELP "HOME"
+#define LABEL_QUIT "POWER"
+#define LABEL_MENU "PLAY"
+#define LABEL_VOLUME "VOL UP/DN"
+
+#elif (CONFIG_KEYPAD == XDUOO_X20_PAD)
+#define VUMETER_QUIT BUTTON_POWER
+#define VUMETER_HELP BUTTON_HOME
+#define VUMETER_MENU BUTTON_PLAY
+#define VUMETER_UP BUTTON_VOL_UP
+#define VUMETER_DOWN BUTTON_VOL_DOWN
+#define LABEL_HELP "HOME"
+#define LABEL_QUIT "POWER"
+#define LABEL_MENU "PLAY"
+#define LABEL_VOLUME "VOL UP/DN"
+
#elif (CONFIG_KEYPAD == IHIFI_770_PAD)
#define VUMETER_QUIT BUTTON_POWER
#define VUMETER_HELP BUTTON_HOME
diff --git a/apps/plugins/wormlet.c b/apps/plugins/wormlet.c
index 9adfc97b81..d342511419 100644
--- a/apps/plugins/wormlet.c
+++ b/apps/plugins/wormlet.c
@@ -402,6 +402,24 @@ CONFIG_KEYPAD == MROBE500_PAD
#define BTN_QUIT BUTTON_POWER
#define BTN_STOPRESET (BUTTON_HOME | BUTTON_POWER)
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define BTN_DIR_UP BUTTON_HOME
+#define BTN_DIR_DOWN BUTTON_OPTION
+#define BTN_DIR_LEFT BUTTON_PREV
+#define BTN_DIR_RIGHT BUTTON_NEXT
+#define BTN_STARTPAUSE BUTTON_PLAY
+#define BTN_QUIT BUTTON_POWER
+#define BTN_STOPRESET (BUTTON_HOME | BUTTON_POWER)
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define BTN_DIR_UP BUTTON_HOME
+#define BTN_DIR_DOWN BUTTON_OPTION
+#define BTN_DIR_LEFT BUTTON_PREV
+#define BTN_DIR_RIGHT BUTTON_NEXT
+#define BTN_STARTPAUSE BUTTON_PLAY
+#define BTN_QUIT BUTTON_POWER
+#define BTN_STOPRESET (BUTTON_HOME | BUTTON_POWER)
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define BTN_DIR_UP BUTTON_PREV
#define BTN_DIR_DOWN BUTTON_NEXT
diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c
index 8acdf85015..9643641569 100644
--- a/apps/plugins/xobox.c
+++ b/apps/plugins/xobox.c
@@ -351,6 +351,24 @@ CONFIG_KEYPAD == MROBE500_PAD
#define DOWN BUTTON_OPTION
#define PAUSE BUTTON_PLAY
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+
+#define QUIT BUTTON_POWER
+#define LEFT BUTTON_PREV
+#define RIGHT BUTTON_NEXT
+#define UP BUTTON_HOME
+#define DOWN BUTTON_OPTION
+#define PAUSE BUTTON_PLAY
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+
+#define QUIT BUTTON_POWER
+#define LEFT BUTTON_PREV
+#define RIGHT BUTTON_NEXT
+#define UP BUTTON_HOME
+#define DOWN BUTTON_OPTION
+#define PAUSE BUTTON_PLAY
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define QUIT BUTTON_POWER
diff --git a/apps/plugins/zxbox/keymaps.h b/apps/plugins/zxbox/keymaps.h
index ce527c561e..53dd9e8d88 100644
--- a/apps/plugins/zxbox/keymaps.h
+++ b/apps/plugins/zxbox/keymaps.h
@@ -290,6 +290,22 @@
#define ZX_UP BUTTON_HOME
#define ZX_DOWN BUTTON_OPTION
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+#define ZX_SELECT BUTTON_PLAY
+#define ZX_MENU BUTTON_POWER
+#define ZX_LEFT BUTTON_PREV
+#define ZX_RIGHT BUTTON_NEXT
+#define ZX_UP BUTTON_HOME
+#define ZX_DOWN BUTTON_OPTION
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+#define ZX_SELECT BUTTON_PLAY
+#define ZX_MENU BUTTON_POWER
+#define ZX_LEFT BUTTON_PREV
+#define ZX_RIGHT BUTTON_NEXT
+#define ZX_UP BUTTON_HOME
+#define ZX_DOWN BUTTON_OPTION
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define ZX_SELECT BUTTON_PLAY
#define ZX_MENU BUTTON_POWER
diff --git a/apps/plugins/zxbox/zxbox_keyb.c b/apps/plugins/zxbox/zxbox_keyb.c
index b3f1ca70e8..4a26accc8a 100644
--- a/apps/plugins/zxbox/zxbox_keyb.c
+++ b/apps/plugins/zxbox/zxbox_keyb.c
@@ -287,6 +287,24 @@
#define KBD_UP BUTTON_HOME
#define KBD_DOWN BUTTON_OPTION
+#elif CONFIG_KEYPAD == XDUOO_X3II_PAD
+
+#define KBD_SELECT BUTTON_PLAY
+#define KBD_ABORT BUTTON_POWER
+#define KBD_LEFT BUTTON_PREV
+#define KBD_RIGHT BUTTON_NEXT
+#define KBD_UP BUTTON_HOME
+#define KBD_DOWN BUTTON_OPTION
+
+#elif CONFIG_KEYPAD == XDUOO_X20_PAD
+
+#define KBD_SELECT BUTTON_PLAY
+#define KBD_ABORT BUTTON_POWER
+#define KBD_LEFT BUTTON_PREV
+#define KBD_RIGHT BUTTON_NEXT
+#define KBD_UP BUTTON_HOME
+#define KBD_DOWN BUTTON_OPTION
+
#elif CONFIG_KEYPAD == IHIFI_770_PAD
#define KBD_SELECT BUTTON_PLAY
diff --git a/bootloader/SOURCES b/bootloader/SOURCES
index ce73724f69..82ddcb80b9 100644
--- a/bootloader/SOURCES
+++ b/bootloader/SOURCES
@@ -78,6 +78,8 @@ mpio_hd200_hd300.c
nwz_linux.c
#elif defined(AGPTEK_ROCKER)
rocker_linux.c
+#elif (defined(XDUOO_X3II) || defined(XDUOO_X20))
+xduoo_linux.c
#elif defined(RK27_GENERIC) || defined(HM60X) || defined(HM801) \
|| defined(MA9) || defined(MA9C) || defined(MA8) || defined(MA8C) \
|| defined(IHIFI760) || defined(IHIFI960) || defined(IHIFI800) \
diff --git a/bootloader/rocker_linux.c b/bootloader/rocker_linux.c
index cb0e5b66e5..80b3bfbab5 100644
--- a/bootloader/rocker_linux.c
+++ b/bootloader/rocker_linux.c
@@ -12,7 +12,7 @@
*
* Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
* and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
- *
+ *
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@@ -464,7 +464,7 @@ static int open_log(void)
return fd;
close(fd);
/* move file */
- rename("/mnt/sd_0/rockbox.log", "/mnt_sd0/rockbox.log.1");
+ rename("/mnt/sd_0/rockbox.log", "/mnt_sd_0/rockbox.log.1");
/* re-open the file, truncate in case the move was unsuccessful */
return open("/mnt/sd_0/rockbox.log", O_RDWR | O_CREAT | O_APPEND | O_TRUNC);
}
diff --git a/bootloader/xduoo_linux.c b/bootloader/xduoo_linux.c
new file mode 100644
index 0000000000..1071c6dc9b
--- /dev/null
+++ b/bootloader/xduoo_linux.c
@@ -0,0 +1,555 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ *
+ * Copyright (C) 2016 by Amaury Pouly
+ * 2018 by Marcin Bukat
+ * 2018 by Roman Stolyarov
+ *
+ * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
+ * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "system.h"
+#include "lcd.h"
+#include "backlight.h"
+#include "button-target.h"
+#include "button.h"
+#include "../kernel/kernel-internal.h"
+#include "core_alloc.h"
+#include "filesystem-app.h"
+#include "lcd.h"
+#include "font.h"
+#include "power.h"
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <sys/wait.h>
+#include <stdarg.h>
+#include "version.h"
+
+/* all images must have the following size */
+#define ICON_WIDTH 130
+#define ICON_HEIGHT 130
+
+/* images */
+#include "bitmaps/rockboxicon.h"
+#include "bitmaps/hibyicon.h"
+#include "bitmaps/toolsicon.h"
+
+/* don't issue an error when parsing the file for dependencies */
+#if defined(BMPWIDTH_rockboxicon) && (BMPWIDTH_rockboxicon != ICON_WIDTH || \
+ BMPHEIGHT_rockboxicon != ICON_HEIGHT)
+#error rockboxicon has the wrong resolution
+#endif
+#if defined(BMPWIDTH_hibyicon) && (BMPWIDTH_hibyicon != ICON_WIDTH || \
+ BMPHEIGHT_hibyicon != ICON_HEIGHT)
+#error hibyicon has the wrong resolution
+#endif
+#if defined(BMPWIDTH_toolsicon) && (BMPWIDTH_toolsicon != ICON_WIDTH || \
+ BMPHEIGHT_toolsicon != ICON_HEIGHT)
+#error toolsicon has the wrong resolution
+#endif
+
+#ifndef BUTTON_UP
+#define BUTTON_UP BUTTON_PREV
+#endif
+#ifndef BUTTON_DOWN
+#define BUTTON_DOWN BUTTON_NEXT
+#endif
+#ifndef BUTTON_ENTER
+#define BUTTON_ENTER BUTTON_PLAY
+#endif
+
+/* return icon y position (x is always centered) */
+static int get_icon_y(void)
+{
+ int h;
+ lcd_getstringsize("X", NULL, &h);
+ return ((LCD_HEIGHT - ICON_HEIGHT)/2) - h;
+}
+
+/* Important Note: this bootloader is carefully written so that in case of
+ * error, the OF is run. This seems like the safest option since the OF is
+ * always there and might do magic things. */
+
+enum boot_mode
+{
+ BOOT_ROCKBOX,
+ BOOT_TOOLS,
+ BOOT_OF,
+ BOOT_COUNT,
+ BOOT_USB, /* special */
+ BOOT_STOP, /* power down/suspend */
+};
+
+static void display_text_center(int y, const char *text)
+{
+ int width;
+ lcd_getstringsize(text, &width, NULL);
+ lcd_putsxy(LCD_WIDTH / 2 - width / 2, y, text);
+}
+
+static void display_text_centerf(int y, const char *format, ...)
+{
+ char buf[1024];
+ va_list ap;
+ va_start(ap, format);
+
+ vsnprintf(buf, sizeof(buf), format, ap);
+ display_text_center(y, buf);
+}
+
+/* get timeout before taking action if the user doesn't touch the device */
+static int get_inactivity_tmo(void)
+{
+#if defined(HAS_BUTTON_HOLD)
+ if(button_hold())
+ return 5 * HZ; /* Inactivity timeout when on hold */
+ else
+#endif
+ return 10 * HZ; /* Inactivity timeout when not on hold */
+}
+
+/* return action on idle timeout */
+static enum boot_mode inactivity_action(enum boot_mode cur_selection)
+{
+#if defined(HAS_BUTTON_HOLD)
+ if(button_hold())
+ return BOOT_STOP; /* power down/suspend */
+ else
+#endif
+ return cur_selection; /* return last choice */
+}
+
+/* we store the boot mode in a file in /tmp so we can reload it between 'boots'
+ * (since the mostly suspends instead of powering down) */
+static enum boot_mode load_boot_mode(enum boot_mode mode)
+{
+ int fd = open("/data/rb_bl_mode.txt", O_RDONLY);
+ if(fd >= 0)
+ {
+ read(fd, &mode, sizeof(mode));
+ close(fd);
+ }
+ return mode;
+}
+
+static void save_boot_mode(enum boot_mode mode)
+{
+ int fd = open("/data/rb_bl_mode.txt", O_RDWR | O_CREAT | O_TRUNC);
+ if(fd >= 0)
+ {
+ write(fd, &mode, sizeof(mode));
+ close(fd);
+ }
+}
+
+static enum boot_mode get_boot_mode(void)
+{
+ /* load previous mode, or start with rockbox if none */
+ enum boot_mode init_mode = load_boot_mode(BOOT_ROCKBOX);
+ /* wait for user action */
+ enum boot_mode mode = init_mode;
+ int last_activity = current_tick;
+#if defined(HAS_BUTTON_HOLD)
+ bool hold_status = button_hold();
+#endif
+ while(true)
+ {
+ /* on usb detect, return to usb
+ * FIXME this is a hack, we need proper usb detection */
+ if(power_input_status() & POWER_INPUT_USB_CHARGER)
+ {
+ /* save last choice */
+ save_boot_mode(mode);
+ return BOOT_USB;
+ }
+ /* inactivity detection */
+ int timeout = last_activity + get_inactivity_tmo();
+ if(TIME_AFTER(current_tick, timeout))
+ {
+ /* save last choice */
+ save_boot_mode(mode);
+ return inactivity_action(mode);
+ }
+ /* redraw */
+ lcd_clear_display();
+ /* display top text */
+#if defined(HAS_BUTTON_HOLD)
+ if(button_hold())
+ {
+ lcd_set_foreground(LCD_RGBPACK(255, 0, 0));
+ display_text_center(0, "ON HOLD!");
+ }
+ else
+#endif
+ {
+ lcd_set_foreground(LCD_RGBPACK(255, 201, 0));
+ display_text_center(0, "SELECT PLAYER");
+ }
+ lcd_set_foreground(LCD_RGBPACK(255, 201, 0));
+ /* display icon */
+ const struct bitmap *icon = (mode == BOOT_OF) ? &bm_hibyicon :
+ (mode == BOOT_ROCKBOX) ? &bm_rockboxicon : &bm_toolsicon;
+ lcd_bmp(icon, (LCD_WIDTH - ICON_WIDTH) / 2, get_icon_y());
+ /* display bottom description */
+ const char *desc = (mode == BOOT_OF) ? "HIBY PLAYER" :
+ (mode == BOOT_ROCKBOX) ? "ROCKBOX" : "TOOLS";
+
+ int desc_height;
+ lcd_getstringsize(desc, NULL, &desc_height);
+ display_text_center(LCD_HEIGHT - 3*desc_height, desc);
+
+ /* display arrows */
+ int arrow_width, arrow_height;
+ lcd_getstringsize("<", &arrow_width, &arrow_height);
+ int arrow_y = get_icon_y() + ICON_HEIGHT / 2 - arrow_height / 2;
+ lcd_putsxy(arrow_width / 2, arrow_y, "<");
+ lcd_putsxy(LCD_WIDTH - 3 * arrow_width / 2, arrow_y, ">");
+
+ lcd_set_foreground(LCD_RGBPACK(0, 255, 0));
+ display_text_centerf(LCD_HEIGHT - arrow_height * 3 / 2, "timeout in %d sec",
+ (timeout - current_tick + HZ - 1) / HZ);
+
+ lcd_update();
+
+ /* wait for a key */
+ int btn = button_get_w_tmo(HZ / 10);
+
+#if defined(HAS_BUTTON_HOLD)
+ /* record action, changing HOLD counts as action */
+ if(btn & BUTTON_MAIN || hold_status != button_hold())
+ last_activity = current_tick;
+
+ hold_status = button_hold();
+#else
+ if(btn & BUTTON_MAIN)
+ last_activity = current_tick;
+#endif
+ /* ignore release, allow repeat */
+ if(btn & BUTTON_REL)
+ continue;
+ if(btn & BUTTON_REPEAT)
+ btn &= ~BUTTON_REPEAT;
+ /* play -> stop loop and return mode */
+ if(btn == BUTTON_ENTER)
+ break;
+ /* left/right/up/down: change mode */
+ if(btn == BUTTON_UP || btn == BUTTON_VOL_UP)
+ mode = (mode + BOOT_COUNT - 1) % BOOT_COUNT;
+ if(btn == BUTTON_DOWN || btn == BUTTON_VOL_DOWN)
+ mode = (mode + 1) % BOOT_COUNT;
+ }
+
+ /* save mode */
+ save_boot_mode(mode);
+ return mode;
+}
+
+void error_screen(const char *msg)
+{
+ lcd_clear_display();
+ lcd_putsf(0, 0, msg);
+ lcd_update();
+}
+
+int choice_screen(const char *title, bool center, int nr_choices, const char *choices[])
+{
+ int choice = 0;
+ int max_len = 0;
+ int h;
+ lcd_getstringsize("x", NULL, &h);
+ for(int i = 0; i < nr_choices; i++)
+ {
+ int len = strlen(choices[i]);
+ if(len > max_len)
+ max_len = len;
+ }
+ char *buf = malloc(max_len + 10);
+ int top_y = 2 * h;
+ int nr_lines = (LCD_HEIGHT - top_y) / h;
+ while(true)
+ {
+ /* make sure choice is visible */
+ int offset = choice - nr_lines / 2;
+ if(offset < 0)
+ offset = 0;
+ lcd_clear_display();
+ /* display top text */
+ lcd_set_foreground(LCD_RGBPACK(255, 201, 0));
+ display_text_center(0, title);
+ int line = 0;
+ for(int i = 0; i < nr_choices && line < nr_lines; i++)
+ {
+ if(i < offset)
+ continue;
+ if(i == choice)
+ lcd_set_foreground(LCD_RGBPACK(255, 0, 0));
+ else
+ lcd_set_foreground(LCD_RGBPACK(255, 201, 0));
+ sprintf(buf, "%s", choices[i]);
+ if(center)
+ display_text_center(top_y + h * line, buf);
+ else
+ lcd_putsxy(0, top_y + h * line, buf);
+ line++;
+ }
+
+ lcd_update();
+
+ /* wait for a key */
+ int btn = button_get_w_tmo(HZ / 10);
+ /* ignore release, allow repeat */
+ if(btn & BUTTON_REL)
+ continue;
+ if(btn & BUTTON_REPEAT)
+ btn &= ~BUTTON_REPEAT;
+ /* play -> stop loop and return mode */
+ if(btn == BUTTON_ENTER)
+ {
+ free(buf);
+ return btn == BUTTON_ENTER ? choice : -1;
+ }
+ /* left/right/up/down: change mode */
+ if(btn == BUTTON_UP || btn == BUTTON_VOL_UP)
+ choice = (choice + nr_choices - 1) % nr_choices;
+ if(btn == BUTTON_DOWN || btn == BUTTON_VOL_DOWN)
+ choice = (choice + 1) % nr_choices;
+ }
+}
+
+void run_file(const char *name)
+{
+ char *dirname = "/mnt/sd_0/";
+ char *buf = malloc(strlen(dirname) + strlen(name) + 1);
+ sprintf(buf, "%s%s", dirname, name);
+
+ lcd_clear_display();
+ lcd_set_foreground(LCD_RGBPACK(255, 201, 0));
+ lcd_putsf(0, 0, "Running %s", name);
+ lcd_update();
+
+ pid_t pid = fork();
+ if(pid == 0)
+ {
+ execlp("sh", "sh", buf, NULL);
+ _exit(42);
+ }
+ int status;
+ waitpid(pid, &status, 0);
+ if(WIFEXITED(status))
+ {
+ lcd_set_foreground(LCD_RGBPACK(255, 201, 0));
+ lcd_putsf(0, 1, "program returned %d", WEXITSTATUS(status));
+ }
+ else
+ {
+ lcd_set_foreground(LCD_RGBPACK(255, 0, 0));
+ lcd_putsf(0, 1, "an error occured: %x", status);
+ }
+ lcd_set_foreground(LCD_RGBPACK(255, 0, 0));
+ lcd_putsf(0, 3, "Press any key or wait");
+ lcd_update();
+ /* wait a small time */
+ sleep(HZ);
+ /* ignore event */
+ while(button_get(false) != 0) {}
+ /* wait for any key or timeout */
+ button_get_w_tmo(4 * HZ);
+}
+
+void run_script_menu(void)
+{
+ const char **entries = NULL;
+ int nr_entries = 0;
+ DIR *dir = opendir("/mnt/sd_0");
+ struct dirent *ent;
+ while((ent = readdir(dir)))
+ {
+ if(ent->d_type != DT_REG)
+ continue;
+ entries = realloc(entries, (nr_entries + 1) * sizeof(const char *));
+ entries[nr_entries++] = strdup(ent->d_name);
+ }
+ closedir(dir);
+ int idx = choice_screen("RUN SCRIPT", false, nr_entries, entries);
+ if(idx >= 0)
+ run_file(entries[idx]);
+ for(int i = 0; i < nr_entries; i++)
+ free((char *)entries[i]);
+ free(entries);
+}
+
+static void adb(int start)
+{
+ pid_t pid = fork();
+ if(pid == 0)
+ {
+ execlp("/etc/init.d/K90adb", "K90adb", start ? "start" : "stop", NULL);
+ _exit(42);
+ }
+ int status;
+ waitpid(pid, &status, 0);
+#if 0
+ if(WIFEXITED(status))
+ {
+ lcd_set_foreground(LCD_RGBPACK(255, 201, 0));
+ lcd_putsf(0, 1, "program returned %d", WEXITSTATUS(status));
+ }
+ else
+ {
+ lcd_set_foreground(LCD_RGBPACK(255, 0, 0));
+ lcd_putsf(0, 1, "an error occured: %x", status);
+ }
+#endif
+}
+
+static void tools_screen(void)
+{
+ const char *choices[] = {"ADB start", "ADB stop", "Run script", "Restart", "Shutdown"};
+ int choice = choice_screen("TOOLS MENU", true, 5, choices);
+ if(choice == 0)
+ {
+ /* run service menu */
+ printf("Starting ADB service...\n");
+ fflush(stdout);
+ adb(1);
+ }
+ else if(choice == 1)
+ {
+ printf("Stopping ADB service...\n");
+ fflush(stdout);
+ adb(0);
+ }
+ else if(choice == 2)
+ {
+ run_script_menu();
+ }
+ else if(choice == 3)
+ system_reboot();
+ else if(choice == 4)
+ power_off();
+}
+
+#if 0
+/* open log file */
+static int open_log(void)
+{
+ /* open regular log file */
+ int fd = open("/mnt/sd_0/rockbox.log", O_RDWR | O_CREAT | O_APPEND);
+ /* get its size */
+ struct stat stat;
+ if(fstat(fd, &stat) != 0)
+ return fd; /* on error, don't do anything */
+ /* if file is too large, rename it and start a new log file */
+ if(stat.st_size < 1000000)
+ return fd;
+ close(fd);
+ /* move file */
+ rename("/mnt/sd_0/rockbox.log", "/mnt/sd_0/rockbox.log.1");
+ /* re-open the file, truncate in case the move was unsuccessful */
+ return open("/mnt/sd_0/rockbox.log", O_RDWR | O_CREAT | O_APPEND | O_TRUNC);
+}
+#endif
+
+int main(int argc, char **argv)
+{
+ (void) argc;
+ (void) argv;
+#if 0
+ /* redirect stdout and stderr to have error messages logged somewhere on the
+ * user partition */
+ int fd = open_log();
+ if(fd >= 0)
+ {
+ dup2(fd, fileno(stdout));
+ dup2(fd, fileno(stderr));
+ close(fd);
+ }
+ /* print version */
+ printf("Rockbox boot loader\n");
+ printf("Version: %s\n", rbversion);
+ printf("%s\n", MODEL_NAME);
+#endif
+
+ system_init();
+ core_allocator_init();
+ kernel_init();
+ paths_init();
+ lcd_init();
+ font_init();
+ button_init();
+ backlight_init();
+ backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
+
+ /* try to load the extra font we install on the device */
+ //int font_id = font_load("/usr/rockbox/fonts/20-Terminus-Bold.fnt");
+ //if(font_id >= 0)
+ // lcd_setfont(font_id);
+
+ /* run all tools menu */
+ while(true)
+ {
+ enum boot_mode mode = get_boot_mode();
+ if(mode == BOOT_USB || mode == BOOT_OF)
+ {
+#if 0
+ fflush(stdout);
+ fflush(stderr);
+ close(fileno(stdout));
+ close(fileno(stderr));
+#endif
+ /* for now the only way we have to trigger USB mode it to run the OF */
+ /* boot OF */
+ execvp("/usr/bin/hiby_player", argv);
+ error_screen("Cannot boot OF");
+ sleep(5 * HZ);
+ }
+ else if(mode == BOOT_TOOLS)
+ {
+ tools_screen();
+ }
+ else if(mode == BOOT_ROCKBOX)
+ {
+ fflush(stdout);
+#if defined(XDUOO_X3II)
+ system("/bin/cp /mnt/sd_0/.rockbox/rockbox.x3ii /tmp");
+ execl("/tmp/rockbox.x3ii", "rockbox.x3ii", NULL);
+#elif defined(XDUOO_X20)
+ system("/bin/cp /mnt/sd_0/.rockbox/rockbox.x20 /tmp");
+ execl("/tmp/rockbox.x20", "rockbox.x20", NULL);
+#endif
+ printf("execvp failed: %s\n", strerror(errno));
+ /* fallback to OF in case of failure */
+ error_screen("Cannot boot Rockbox");
+ sleep(5 * HZ);
+ }
+ else
+ {
+ printf("suspend\n");
+// nwz_power_suspend();
+ }
+ }
+ /* if we reach this point, everything failed, so return an error so that
+ * sysmgrd knows something is wrong */
+ return 1;
+}
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 89f4f52895..7be6010ab7 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -113,25 +113,37 @@ target/hosted/sonynwz/nvp-nwz.c
target/hosted/sonynwz/nwz-db.c
#endif
-#if defined(AGPTEK_ROCKER) && !defined(SIMULATOR)
+#if ((defined(AGPTEK_ROCKER) || defined(XDUOO_X3II) || defined(XDUOO_X20)) && !defined(SIMULATOR))
drivers/lcd-memframe.c
+target/hosted/alsa-controls.c
+target/hosted/pcm-alsa.c
target/hosted/backtrace-glibc.c
-target/hosted/kernel-unix.c
target/hosted/filesystem-unix.c
+target/hosted/kernel-unix.c
target/hosted/lc-unix.c
-target/hosted/alsa-controls.c
-target/hosted/pcm-alsa.c
-target/hosted/agptek/sysfs.c
-target/hosted/agptek/backlight-agptek.c
+target/hosted/sysfs.c
+target/hosted/backlight-unix.c
+target/hosted/system-hosted.c
+#endif
+
+#if defined(AGPTEK_ROCKER) && !defined(SIMULATOR)
target/hosted/agptek/button-agptek.c
target/hosted/agptek/debug-agptek.c
target/hosted/agptek/lcd-agptek.c
target/hosted/agptek/power-agptek.c
target/hosted/agptek/powermgmt-agptek.c
-target/hosted/agptek/system-agptek.c
target/hosted/agptek/usb-agptek.c
#endif
+#if ((defined(XDUOO_X3II)||defined(XDUOO_X20)) && !defined(SIMULATOR))
+target/hosted/xduoo/button-xduoo.c
+target/hosted/xduoo/debug-xduoo.c
+target/hosted/xduoo/lcd-xduoo.c
+target/hosted/xduoo/power-xduoo.c
+target/hosted/xduoo/powermgmt-xduoo.c
+target/hosted/xduoo/usb-xduoo.c
+#endif
+
#if defined(SAMSUNG_YPR0) && !defined(SIMULATOR)
drivers/adc-as3514.c
#if (CONFIG_RTC == RTC_AS3514)
@@ -502,6 +514,8 @@ target/hosted/alsa-controls.c
target/hosted/pcm-alsa.c
#elif defined(HAVE_ROCKER_CODEC) && !defined(SIMULATOR)
drivers/audio/rocker_codec.c
+#elif defined(HAVE_XDUOO_LINUX_CODEC) && !defined(SIMULATOR)
+drivers/audio/xduoolinux_codec.c
#elif defined(HAVE_SDL_AUDIO)
drivers/audio/sdl.c
#if CONFIG_CODEC == SWCODEC
@@ -584,7 +598,7 @@ target/arm/ipod/powermgmt-ipod-pcf.c
target/arm/pp/i2c-pp.c
#elif CONFIG_I2C == I2C_PNX0101
target/arm/pnx0101/i2c-pnx0101.c
-#elif CONFIG_I2C == I2C_TCC780X || CONFIG_I2C == I2C_TCC77X
+#elif CONFIG_I2C == I2C_TCC780X || CONFIG_I2C == I2C_TCC77X
target/arm/i2c-telechips.c
#elif CONFIG_I2C == I2C_S3C2440
target/arm/s3c2440/i2c-s3c2440.c
@@ -837,9 +851,9 @@ drivers/isp1583.c
target/arm/rk27xx/usb-drv-rk27xx.c
#endif
#else /* !defined(HAVE_USBSTACK) */
-#if CONFIG_USBOTG == USBOTG_ISP1362
+#if CONFIG_USBOTG == USBOTG_ISP1362
drivers/isp1362.c
-#elif CONFIG_USBOTG == USBOTG_M5636
+#elif CONFIG_USBOTG == USBOTG_M5636
drivers/m5636.c
#endif
#endif /* !defined(HAVE_USBSTACK) */
@@ -1415,7 +1429,7 @@ target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c
target/arm/pnx0101/iriver-ifp7xx/lcd-ifp7xx.c
target/arm/pnx0101/iriver-ifp7xx/power-ifp7xx.c
target/arm/pnx0101/iriver-ifp7xx/powermgmt-ifp7xx.c
-target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c
+target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c
#ifndef BOOTLOADER
target/arm/pnx0101/pcm-pnx0101.c
#endif /* BOOTLOADER */
@@ -1989,7 +2003,7 @@ target/hosted/ibasso/dx90/button-dx90.c
#ifdef WIN32
asm/mempcpy.c
target/hosted/filesystem-win32.c
-#else /* !WIN32 */
+#else /* !WIN32 */
target/hosted/filesystem-unix.c
#endif /* WIN32 */
target/hosted/sdl/load_code-sdl.c
diff --git a/firmware/asm/SOURCES b/firmware/asm/SOURCES
index eba5bd2cb6..085b6351a5 100644
--- a/firmware/asm/SOURCES
+++ b/firmware/asm/SOURCES
@@ -15,7 +15,7 @@ mempcpy.c
defined(CREATIVE_ZVx) || defined(SANSA_CONNECT) || defined(SANSA_FUZEPLUS) || \
defined(COWON_D2) || defined(MINI2440) || defined(SAMSUNG_YPR0) || \
defined(SAMSUNG_YPR1) || defined(DX50) || defined(DX90) || (defined(MROBE_500) && !defined(LCD_USE_DMA)) || \
- defined(CREATIVE_ZEN) || defined(CREATIVE_ZENXFI) || defined(SONY_NWZ_LINUX) || defined(AGPTEK_ROCKER)) && \
+ defined(CREATIVE_ZEN) || defined(CREATIVE_ZENXFI) || defined(SONY_NWZ_LINUX) || defined(AGPTEK_ROCKER) || defined(XDUOO_X3II) || defined(XDUOO_X20)) && \
!defined(SIMULATOR)
#if LCD_DEPTH >= 24
lcd-as-memframe-24bit.c
diff --git a/firmware/drivers/audio/xduoolinux_codec.c b/firmware/drivers/audio/xduoolinux_codec.c
new file mode 100644
index 0000000000..5db4902e5f
--- /dev/null
+++ b/firmware/drivers/audio/xduoolinux_codec.c
@@ -0,0 +1,122 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ *
+ * Copyright (c) 2018 Marcin Bukat
+ * Copyright (c) 2018 Roman Stolyarov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "config.h"
+#include "audio.h"
+#include "audiohw.h"
+#include "system.h"
+#include "kernel.h"
+#include "panic.h"
+#include "sysfs.h"
+#include "alsa-controls.h"
+
+static int fd_hw;
+
+static void hw_open(void)
+{
+ fd_hw = open("/dev/snd/controlC0", O_RDWR);
+ if(fd_hw < 0)
+ panicf("Cannot open '/dev/snd/controlC0'");
+}
+
+static void hw_close(void)
+{
+ close(fd_hw);
+}
+
+void audiohw_preinit(void)
+{
+ alsa_controls_init();
+ hw_open();
+}
+
+void audiohw_postinit(void)
+{
+ long int ps = 2; // headset
+ int status = 0;
+
+ const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state";
+ const char * const sysfs_hs_switch = "/sys/class/switch/headset/state";
+#ifdef XDUOO_X20
+ const char * const sysfs_bal_switch = "/sys/class/switch/balance/state";
+#endif
+
+#if defined(XDUOO_X3II)
+ alsa_controls_set_bool("AK4490 Soft Mute", true);
+#endif
+
+ sysfs_get_int(sysfs_lo_switch, &status);
+ if (status) ps = 1; // lineout
+
+ sysfs_get_int(sysfs_hs_switch, &status);
+ if (status) ps = 2; // headset
+
+#ifdef XDUOO_X20
+ sysfs_get_int(sysfs_bal_switch, &status);
+ if (status) ps = 3; // balance
+#endif
+
+ /* Output port switch */
+ alsa_controls_set_ints("Output Port Switch", 1, &ps);
+
+#if defined(XDUOO_X3II)
+ alsa_controls_set_bool("AK4490 Soft Mute", false);
+#endif
+}
+
+void audiohw_close(void)
+{
+ hw_close();
+ alsa_controls_close();
+}
+
+void audiohw_set_frequency(int fsel)
+{
+ (void)fsel;
+}
+
+void audiohw_set_volume(int vol_l, int vol_r)
+{
+ long int vol_l_hw = -vol_l/5;
+ long int vol_r_hw = -vol_r/5;
+
+ alsa_controls_set_ints("Left Playback Volume", 1, &vol_l_hw);
+ alsa_controls_set_ints("Right Playback Volume", 1, &vol_r_hw);
+}
+
+void audiohw_set_filter_roll_off(int value)
+{
+ /* 0 = fast (sharp);
+ 1 = slow;
+ 2 = fast2
+ 3 = slow2
+ 4 = NOS ? */
+ long int value_hw = value;
+#if defined(XDUOO_X3II)
+ alsa_controls_set_ints("AK4490 Digital Filter", 1, &value_hw);
+#elif defined(XDUOO_X20)
+ alsa_controls_set_ints("ES9018_K2M Digital Filter", 1, &value_hw);
+#else
+ (void)value;
+#endif
+}
diff --git a/firmware/export/audiohw.h b/firmware/export/audiohw.h
index 458fba3412..00bb15812d 100644
--- a/firmware/export/audiohw.h
+++ b/firmware/export/audiohw.h
@@ -224,6 +224,8 @@ struct sound_settings_info
#include "codec-dx90.h"
#elif defined(HAVE_ROCKER_CODEC)
#include "rocker_codec.h"
+#elif defined(HAVE_XDUOO_LINUX_CODEC)
+#include "rocker_codec.h"
#endif
/* convert caps into defines */
diff --git a/firmware/export/config.h b/firmware/export/config.h
index a41cceff59..c55d489c26 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -171,6 +171,8 @@
#define XDUOO_X3_PAD 66
#define IHIFI_770_PAD 67
#define IHIFI_800_PAD 68
+#define XDUOO_X3II_PAD 69
+#define XDUOO_X20_PAD 70
/* CONFIG_REMOTE_KEYPAD */
#define H100_REMOTE 1
@@ -624,6 +626,10 @@ Lyre prototype 1 */
#include "config/agptekrocker.h"
#elif defined(XDUOO_X3)
#include "config/xduoox3.h"
+#elif defined(XDUOO_X3II)
+#include "config/xduoox3ii.h"
+#elif defined(XDUOO_X20)
+#include "config/xduoox20.h"
#else
/* no known platform */
#endif
diff --git a/firmware/export/config/agptekrocker.h b/firmware/export/config/agptekrocker.h
index 172e079721..372287f4b5 100644
--- a/firmware/export/config/agptekrocker.h
+++ b/firmware/export/config/agptekrocker.h
@@ -3,7 +3,7 @@
*/
/* For Rolo and boot loader */
-#define MODEL_NUMBER 103//???
+#define MODEL_NUMBER 105
#define MODEL_NAME "Agptek Rocker"
diff --git a/firmware/export/config/xduoox20.h b/firmware/export/config/xduoox20.h
new file mode 100644
index 0000000000..d451ba31f4
--- /dev/null
+++ b/firmware/export/config/xduoox20.h
@@ -0,0 +1,126 @@
+/*
+ * This config file is for the xDuoo X20
+ */
+
+/* For Rolo and boot loader */
+#define MODEL_NUMBER 111
+
+#define MODEL_NAME "xDuoo X20"
+
+/* LCD dimensions */
+#define LCD_WIDTH 240
+#define LCD_HEIGHT 320
+/* sqrt(240^2 + 320^2) / 2.4 = 166 */
+#define LCD_DPI 166
+
+#ifndef SIMULATOR
+#define CONFIG_PLATFORM (PLATFORM_HOSTED)
+#endif
+
+/* define this if you have a bitmap LCD display */
+#define HAVE_LCD_BITMAP
+
+/* define this if you have a colour LCD */
+#define HAVE_LCD_COLOR
+
+#define HAVE_LCD_ENABLE
+
+/* Define this if the LCD can shut down */
+#define HAVE_LCD_SHUTDOWN
+
+/* define this if you want album art for this target */
+#define HAVE_ALBUMART
+
+/* define this to enable bitmap scaling */
+#define HAVE_BMP_SCALING
+
+/* define this to enable JPEG decoding */
+#define HAVE_JPEG
+
+/* define this if you have access to the quickscreen */
+#define HAVE_QUICKSCREEN
+
+/* define this if you would like tagcache to build on this target */
+#define HAVE_TAGCACHE
+
+#define LCD_DEPTH 32
+/* Check that but should not matter */
+#define LCD_PIXELFORMAT XRGB8888
+
+#define HAVE_BACKLIGHT
+#define HAVE_BACKLIGHT_BRIGHTNESS
+
+/* Main LCD backlight brightness range and defaults: the backlight driver
+ * has levels from 0 to 2555. But 0 is off so start at 1.
+ */
+#define MIN_BRIGHTNESS_SETTING 1
+#define MAX_BRIGHTNESS_SETTING 255
+#define DEFAULT_BRIGHTNESS_SETTING 70
+
+/* Which backlight fading type? */
+#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
+
+/* define this if you have a real-time clock */
+#define CONFIG_RTC APPLICATION
+
+/* The number of bytes reserved for loadable codecs */
+#define CODEC_SIZE 0x80000
+
+/* The number of bytes reserved for loadable plugins */
+#define PLUGIN_BUFFER_SIZE 0x100000
+
+/* Define this if you do software codec */
+#define CONFIG_CODEC SWCODEC
+
+#define HAVE_HEADPHONE_DETECTION
+
+/* KeyPad configuration for plugins */
+#define CONFIG_KEYPAD XDUOO_X20_PAD
+
+/* Define this if a programmable hotkey is mapped */
+#define HAVE_HOTKEY
+
+/* define this if the target has volume keys which can be used in the lists */
+#define HAVE_VOLUME_IN_LIST
+
+#ifndef SIMULATOR
+/* We have usb power and can detect usb but it is handled by Linux */
+#define HAVE_USB_POWER
+
+#endif
+
+#define CONFIG_BATTERY_MEASURE PERCENTAGE_MEASURE
+
+/* Linux controlls charging, we can monitor */
+#define CONFIG_CHARGING CHARGING_MONITOR
+
+/* define this if the hardware can be powered off while charging */
+#define HAVE_POWEROFF_WHILE_CHARGING
+
+/* same dimensions as gigabeats */
+#define CONFIG_LCD LCD_INGENIC_LINUX
+
+/* Define this if you have a software controlled poweroff */
+#define HAVE_SW_POWEROFF
+
+/* Define this to the CPU frequency */
+#define CPU_FREQ 504000000
+
+/* No special storage */
+#define CONFIG_STORAGE STORAGE_HOSTFS
+#define HAVE_STORAGE_FLUSH
+
+/* Battery */
+#define BATTERY_TYPES_COUNT 1
+
+/* Audio codec */
+#define HAVE_XDUOO_LINUX_CODEC
+
+/* We don't have hardware controls */
+#define HAVE_SW_TONE_CONTROLS
+
+/* Battery */
+#define BATTERY_CAPACITY_DEFAULT 2400 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 2400 /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 2400 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 0 /* capacity increment */
diff --git a/firmware/export/config/xduoox3ii.h b/firmware/export/config/xduoox3ii.h
new file mode 100644
index 0000000000..af63c4f97b
--- /dev/null
+++ b/firmware/export/config/xduoox3ii.h
@@ -0,0 +1,126 @@
+/*
+ * This config file is for the xDuoo X3ii
+ */
+
+/* For Rolo and boot loader */
+#define MODEL_NUMBER 110
+
+#define MODEL_NAME "xDuoo X3ii"
+
+/* LCD dimensions */
+#define LCD_WIDTH 240
+#define LCD_HEIGHT 320
+/* sqrt(240^2 + 320^2) / 2.4 = 166 */
+#define LCD_DPI 166
+
+#ifndef SIMULATOR
+#define CONFIG_PLATFORM (PLATFORM_HOSTED)
+#endif
+
+/* define this if you have a bitmap LCD display */
+#define HAVE_LCD_BITMAP
+
+/* define this if you have a colour LCD */
+#define HAVE_LCD_COLOR
+
+#define HAVE_LCD_ENABLE
+
+/* Define this if the LCD can shut down */
+#define HAVE_LCD_SHUTDOWN
+
+/* define this if you want album art for this target */
+#define HAVE_ALBUMART
+
+/* define this to enable bitmap scaling */
+#define HAVE_BMP_SCALING
+
+/* define this to enable JPEG decoding */
+#define HAVE_JPEG
+
+/* define this if you have access to the quickscreen */
+#define HAVE_QUICKSCREEN
+
+/* define this if you would like tagcache to build on this target */
+#define HAVE_TAGCACHE
+
+#define LCD_DEPTH 32
+/* Check that but should not matter */
+#define LCD_PIXELFORMAT XRGB8888
+
+#define HAVE_BACKLIGHT
+#define HAVE_BACKLIGHT_BRIGHTNESS
+
+/* Main LCD backlight brightness range and defaults: the backlight driver
+ * has levels from 0 to 2555. But 0 is off so start at 1.
+ */
+#define MIN_BRIGHTNESS_SETTING 1
+#define MAX_BRIGHTNESS_SETTING 255
+#define DEFAULT_BRIGHTNESS_SETTING 70
+
+/* Which backlight fading type? */
+#define CONFIG_BACKLIGHT_FADING BACKLIGHT_FADING_SW_SETTING
+
+/* define this if you have a real-time clock */
+#define CONFIG_RTC APPLICATION
+
+/* The number of bytes reserved for loadable codecs */
+#define CODEC_SIZE 0x80000
+
+/* The number of bytes reserved for loadable plugins */
+#define PLUGIN_BUFFER_SIZE 0x100000
+
+/* Define this if you do software codec */
+#define CONFIG_CODEC SWCODEC
+
+#define HAVE_HEADPHONE_DETECTION
+
+/* KeyPad configuration for plugins */
+#define CONFIG_KEYPAD XDUOO_X3II_PAD
+
+/* Define this if a programmable hotkey is mapped */
+#define HAVE_HOTKEY
+
+/* define this if the target has volume keys which can be used in the lists */
+#define HAVE_VOLUME_IN_LIST
+
+#ifndef SIMULATOR
+/* We have usb power and can detect usb but it is handled by Linux */
+#define HAVE_USB_POWER
+
+#endif
+
+#define CONFIG_BATTERY_MEASURE VOLTAGE_MEASURE
+
+/* Linux controlls charging, we can monitor */
+#define CONFIG_CHARGING CHARGING_MONITOR
+
+/* define this if the hardware can be powered off while charging */
+#define HAVE_POWEROFF_WHILE_CHARGING
+
+/* same dimensions as gigabeats */
+#define CONFIG_LCD LCD_INGENIC_LINUX
+
+/* Define this if you have a software controlled poweroff */
+#define HAVE_SW_POWEROFF
+
+/* Define this to the CPU frequency */
+#define CPU_FREQ 504000000
+
+/* No special storage */
+#define CONFIG_STORAGE STORAGE_HOSTFS
+#define HAVE_STORAGE_FLUSH
+
+/* Battery */
+#define BATTERY_TYPES_COUNT 1
+
+/* Audio codec */
+#define HAVE_XDUOO_LINUX_CODEC
+
+/* We don't have hardware controls */
+#define HAVE_SW_TONE_CONTROLS
+
+/* Battery */
+#define BATTERY_CAPACITY_DEFAULT 2000 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 2000 /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 2000 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 0 /* capacity increment */
diff --git a/firmware/export/rbpaths.h b/firmware/export/rbpaths.h
index 165dd37494..b95f1614eb 100644
--- a/firmware/export/rbpaths.h
+++ b/firmware/export/rbpaths.h
@@ -42,7 +42,7 @@
#if !defined(APPLICATION) || defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || \
defined(DX50) || defined(DX90) || defined(SONY_NWZ_LINUX) || \
- defined(AGPTEK_ROCKER)
+ defined(AGPTEK_ROCKER) || defined(XDUOO_X3II) || defined(XDUOO_X20)
#if defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1)
#define HOME_DIR "/mnt/media0"
diff --git a/firmware/export/xduoolinux_codec.h b/firmware/export/xduoolinux_codec.h
new file mode 100644
index 0000000000..ccd49f09aa
--- /dev/null
+++ b/firmware/export/xduoolinux_codec.h
@@ -0,0 +1,7 @@
+#ifndef __XDUOOLINUX_CODEC__
+#define __XDUOOLINUX_CODEC__
+
+#define AUDIOHW_CAPS (FILTER_ROLL_OFF_CAP)
+AUDIOHW_SETTING(VOLUME, "dB", 0, 1, -127, 0, -30)
+AUDIOHW_SETTING(FILTER_ROLL_OFF, "", 0, 1, 0, 4, 0)
+#endif
diff --git a/firmware/target/hosted/agptek/backlight-target.h b/firmware/target/hosted/backlight-target.h
index e3b8a7bd78..e3b8a7bd78 100644
--- a/firmware/target/hosted/agptek/backlight-target.h
+++ b/firmware/target/hosted/backlight-target.h
diff --git a/firmware/target/hosted/agptek/backlight-agptek.c b/firmware/target/hosted/backlight-unix.c
index 2f00787f72..2f00787f72 100644
--- a/firmware/target/hosted/agptek/backlight-agptek.c
+++ b/firmware/target/hosted/backlight-unix.c
diff --git a/firmware/target/hosted/filesystem-app.c b/firmware/target/hosted/filesystem-app.c
index d9fcd64e2d..b49412ea48 100644
--- a/firmware/target/hosted/filesystem-app.c
+++ b/firmware/target/hosted/filesystem-app.c
@@ -36,8 +36,7 @@
#include "rbpaths.h"
#include "logf.h"
-
-#if defined(AGPTEK_ROCKER) && !defined(BOOTLOADER)
+#if (defined(AGPTEK_ROCKER) || defined(XDUOO_X3II) || defined(XDUOO_X20)) && !defined(BOOTLOADER)
#define PIVOT_ROOT "/mnt/sd_0"
#endif
@@ -52,7 +51,8 @@ static const char rbhome[] = HOME_DIR;
#endif
#if !(defined(SAMSUNG_YPR0) || defined(SAMSUNG_YPR1) || defined(DX50) || \
- defined(SONY_NWZ_LINUX) || defined(DX90) || defined(AGPTEK_ROCKER)) && \
+ defined(SONY_NWZ_LINUX) || defined(DX90) || defined(AGPTEK_ROCKER) || \
+ defined(XDUOO_X3II) || defined(XDUOO_X20)) && \
!defined(__PCTOOL__)
/* Special dirs are user-accessible (and user-writable) dirs which take priority
* over the ones where Rockbox is installed to. Classic example would be
diff --git a/firmware/target/hosted/rtc.c b/firmware/target/hosted/rtc.c
index 178e797a8d..488531c77c 100644
--- a/firmware/target/hosted/rtc.c
+++ b/firmware/target/hosted/rtc.c
@@ -42,7 +42,7 @@ int rtc_read_datetime(struct tm *tm)
int rtc_write_datetime(const struct tm *tm)
{
-#if defined(AGPTEK_ROCKER) && !defined(WIN32)
+#if !defined(WIN32)
struct timeval tv;
struct tm *tm_time;
diff --git a/firmware/target/hosted/sdl/sim-ui-defines.h b/firmware/target/hosted/sdl/sim-ui-defines.h
index 99ae062595..1e96383682 100644
--- a/firmware/target/hosted/sdl/sim-ui-defines.h
+++ b/firmware/target/hosted/sdl/sim-ui-defines.h
@@ -521,6 +521,7 @@
#define UI_HEIGHT 380
#define UI_LCD_POSX 29
#define UI_LCD_POSY 25
+
#elif defined(XDUOO_X3)
#define UI_TITLE "xDuoo X3"
#define UI_WIDTH 192 /* width of GUI window */
@@ -528,6 +529,20 @@
#define UI_LCD_POSX 34
#define UI_LCD_POSY 73
+#elif defined(XDUOO_X3II)
+#define UI_TITLE "xDuoo X3ii"
+#define UI_WIDTH 322 /* width of GUI window */
+#define UI_HEIGHT 609 /* height of GUI window */
+#define UI_LCD_POSX 43
+#define UI_LCD_POSY 62
+
+#elif defined(XDUOO_X20)
+#define UI_TITLE "xDuoo X20"
+#define UI_WIDTH 322 /* width of GUI window */
+#define UI_HEIGHT 609 /* height of GUI window */
+#define UI_LCD_POSX 43
+#define UI_LCD_POSY 62
+
#elif defined(IHIFI770)
#define UI_TITLE "iHiFi 770"
#define UI_WIDTH 382 /* width of GUI window */
@@ -554,4 +569,3 @@
#endif
#endif /* #ifndef __UISDL_H__ */
-
diff --git a/firmware/target/hosted/agptek/sysfs.c b/firmware/target/hosted/sysfs.c
index 177f338911..177f338911 100644
--- a/firmware/target/hosted/agptek/sysfs.c
+++ b/firmware/target/hosted/sysfs.c
diff --git a/firmware/target/hosted/agptek/sysfs.h b/firmware/target/hosted/sysfs.h
index 639cc1c409..639cc1c409 100644
--- a/firmware/target/hosted/agptek/sysfs.h
+++ b/firmware/target/hosted/sysfs.h
diff --git a/firmware/target/hosted/agptek/system-agptek.c b/firmware/target/hosted/system-hosted.c
index 7f0949daf2..7f0949daf2 100644
--- a/firmware/target/hosted/agptek/system-agptek.c
+++ b/firmware/target/hosted/system-hosted.c
diff --git a/firmware/target/hosted/xduoo/adc-target.h b/firmware/target/hosted/xduoo/adc-target.h
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/firmware/target/hosted/xduoo/adc-target.h
diff --git a/firmware/target/hosted/xduoo/button-target.h b/firmware/target/hosted/xduoo/button-target.h
new file mode 100644
index 0000000000..6cca5c22a0
--- /dev/null
+++ b/firmware/target/hosted/xduoo/button-target.h
@@ -0,0 +1,46 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2018 by Roman Stolyarov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef _BUTTON_TARGET_H_
+#define _BUTTON_TARGET_H_
+
+#define HAS_BUTTON_HOLD
+
+/* Main unit's buttons */
+#define BUTTON_POWER 0x00000001
+#define BUTTON_HOME 0x00000002
+#define BUTTON_OPTION 0x00000004
+#define BUTTON_PREV 0x00000008
+#define BUTTON_NEXT 0x00000010
+#define BUTTON_PLAY 0x00000020
+#define BUTTON_VOL_UP 0x00000040
+#define BUTTON_VOL_DOWN 0x00000080
+
+#define BUTTON_LEFT 0
+#define BUTTON_RIGHT 0
+
+#define BUTTON_MAIN (BUTTON_POWER | BUTTON_HOME | BUTTON_OPTION | BUTTON_PREV | \
+ BUTTON_NEXT | BUTTON_PLAY | BUTTON_VOL_UP | BUTTON_VOL_DOWN)
+
+/* Software power-off */
+#define POWEROFF_BUTTON BUTTON_POWER
+#define POWEROFF_COUNT 25
+
+#endif /* _BUTTON_TARGET_H_ */
+
diff --git a/firmware/target/hosted/xduoo/button-xduoo.c b/firmware/target/hosted/xduoo/button-xduoo.c
new file mode 100644
index 0000000000..9fd1392b89
--- /dev/null
+++ b/firmware/target/hosted/xduoo/button-xduoo.c
@@ -0,0 +1,202 @@
+/***************************************************************************
+ * __________ __ ___
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2017 Marcin Bukat
+ * Copyright (C) 2018 Roman Stolyarov
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include <poll.h>
+//#include <dir.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <linux/input.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "sysfs.h"
+#include "button.h"
+#include "button-target.h"
+#include "panic.h"
+
+#include "kernel.h"
+#include "backlight.h"
+#include "backlight-target.h"
+
+static bool soft_hold = false;
+#ifndef BOOTLOADER
+static unsigned soft_hold_counter = 0;
+#define SOFT_HOLD_BUTTON BUTTON_POWER
+#define SOFT_HOLD_CNTMAX_1 (HZ)
+#define SOFT_HOLD_CNTMAX_2 (HZ*2)
+#endif
+
+#define NR_POLL_DESC 3
+static struct pollfd poll_fds[NR_POLL_DESC];
+
+static int button_map(int keycode)
+{
+ switch(keycode)
+ {
+ case KEY_BACK:
+ return BUTTON_HOME;
+
+ case KEY_MENU:
+ return BUTTON_OPTION;
+
+ case KEY_UP:
+ return BUTTON_PREV;
+
+ case KEY_DOWN:
+ return BUTTON_NEXT;
+
+ case KEY_ENTER:
+ return BUTTON_PLAY;
+
+ case KEY_VOLUMEUP:
+ return BUTTON_VOL_UP;
+
+ case KEY_VOLUMEDOWN:
+ return BUTTON_VOL_DOWN;
+
+ case KEY_POWER:
+ return BUTTON_POWER;
+
+ default:
+ return 0;
+ }
+}
+
+void button_init_device(void)
+{
+ const char * const input_devs[] = {
+ "/dev/input/event0",
+ "/dev/input/event1",
+ "/dev/input/event2"
+ };
+
+ for(int i = 0; i < NR_POLL_DESC; i++)
+ {
+ int fd = open(input_devs[i], O_RDWR);
+
+ if(fd < 0)
+ {
+ panicf("Cannot open input device: %s\n", input_devs[i]);
+ }
+
+ poll_fds[i].fd = fd;
+ poll_fds[i].events = POLLIN;
+ poll_fds[i].revents = 0;
+ }
+}
+
+int button_read_device(void)
+{
+ static int button_bitmap = 0;
+ struct input_event event;
+
+ /* check if there are any events pending and process them */
+ while(poll(poll_fds, NR_POLL_DESC, 0))
+ {
+ for(int i = 0; i < NR_POLL_DESC; i++)
+ {
+ /* read only if non-blocking */
+ if(poll_fds[i].revents & POLLIN)
+ {
+ int size = read(poll_fds[i].fd, &event, sizeof(event));
+ if(size == (int)sizeof(event))
+ {
+ int keycode = event.code;
+ /* event.value == 1 means press
+ * event.value == 0 means release
+ */
+ bool press = event.value ? true : false;
+
+ /* map linux event code to rockbox button bitmap */
+ if(press)
+ {
+ button_bitmap |= button_map(keycode);
+ }
+ else
+ {
+ button_bitmap &= ~button_map(keycode);
+ }
+ }
+ }
+ }
+ }
+
+#ifndef BOOTLOADER
+ if (button_bitmap == SOFT_HOLD_BUTTON) {
+ soft_hold_counter++;
+ if (soft_hold_counter == SOFT_HOLD_CNTMAX_1) {
+ soft_hold = !soft_hold;
+ backlight_hold_changed(soft_hold);
+ }
+ else
+ if (soft_hold_counter == SOFT_HOLD_CNTMAX_2) {
+ soft_hold = false;
+ backlight_hold_changed(soft_hold);
+ }
+ } else {
+ soft_hold_counter = 0;
+ }
+
+ if((soft_hold) && (button_bitmap != SOFT_HOLD_BUTTON)) {
+ return BUTTON_NONE;
+ }
+#endif
+
+ return button_bitmap;
+}
+
+bool headphones_inserted(void)
+{
+ int status = 0;
+ const char * const sysfs_lo_switch = "/sys/class/switch/lineout/state";
+ const char * const sysfs_hs_switch = "/sys/class/switch/headset/state";
+#ifdef XDUOO_X20
+ const char * const sysfs_bal_switch = "/sys/class/switch/balance/state";
+#endif
+
+ sysfs_get_int(sysfs_lo_switch, &status);
+ if (status) return true;
+
+ sysfs_get_int(sysfs_hs_switch, &status);
+ if (status) return true;
+
+#ifdef XDUOO_X20
+ sysfs_get_int(sysfs_bal_switch, &status);
+ if (status) return true;
+#endif
+
+ return false;
+}
+
+void button_close_device(void)
+{
+ /* close descriptors */
+ for(int i = 0; i < NR_POLL_DESC; i++)
+ {
+ close(poll_fds[i].fd);
+ }
+}
+
+bool button_hold(void)
+{
+ return soft_hold;
+}
diff --git a/firmware/target/hosted/xduoo/debug-xduoo.c b/firmware/target/hosted/xduoo/debug-xduoo.c
new file mode 100644
index 0000000000..33f3ac4b97
--- /dev/null
+++ b/firmware/target/hosted/xduoo/debug-xduoo.c
@@ -0,0 +1,6 @@
+#include <stdbool.h>
+
+bool debug_hw_info(void)
+{
+ return false;
+}
diff --git a/firmware/target/hosted/xduoo/lcd-target.h b/firmware/target/hosted/xduoo/lcd-target.h
new file mode 100644
index 0000000000..bb9b77771b
--- /dev/null
+++ b/firmware/target/hosted/xduoo/lcd-target.h
@@ -0,0 +1,32 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2016 Amaury Pouly
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef __LCD_TARGET_H__
+#define __LCD_TARGET_H__
+
+/* needs special ioctl() to redraw updated framebuffer content */
+#define LCD_OPTIMIZED_UPDATE
+#define LCD_OPTIMIZED_UPDATE_RECT
+
+extern fb_data *framebuffer; /* see lcd-xduoo.c */
+#define LCD_FRAMEBUF_ADDR(col, row) (framebuffer + (row)*LCD_WIDTH + (col))
+
+extern void lcd_set_active(bool active);
+#endif /* __LCD_TARGET_H__ */
diff --git a/firmware/target/hosted/xduoo/lcd-xduoo.c b/firmware/target/hosted/xduoo/lcd-xduoo.c
new file mode 100644
index 0000000000..4b3148da03
--- /dev/null
+++ b/firmware/target/hosted/xduoo/lcd-xduoo.c
@@ -0,0 +1,140 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2017 Marcin Bukat
+ * Copyright (C) 2016 Amaury Pouly
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <linux/fb.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include "lcd.h"
+#include "lcd-target.h"
+#include "backlight-target.h"
+#include "sysfs.h"
+#include "panic.h"
+
+static int fd = -1;
+static struct fb_var_screeninfo vinfo;
+fb_data *framebuffer = 0; /* global variable, see lcd-target.h */
+
+void lcd_init_device(void)
+{
+ const char * const fb_dev = "/dev/fb0";
+ fd = open(fb_dev, O_RDWR);
+ if(fd < 0)
+ {
+ panicf("Cannot open framebuffer: %s\n", fb_dev);
+ }
+
+ /* get fixed and variable information */
+ struct fb_fix_screeninfo finfo;
+ if(ioctl(fd, FBIOGET_FSCREENINFO, &finfo) < 0)
+ {
+ panicf("Cannot read framebuffer fixed information");
+ }
+
+ if(ioctl(fd, FBIOGET_VSCREENINFO, &vinfo) < 0)
+ {
+ panicf("Cannot read framebuffer variable information");
+ }
+
+#if 0
+ /* check resolution and framebuffer size */
+ if(vinfo.xres != LCD_WIDTH || vinfo.yres != LCD_HEIGHT || vinfo.bits_per_pixel != LCD_DEPTH)
+ {
+ panicf("Unexpected framebuffer resolution: %dx%dx%d\n", vinfo.xres,
+ vinfo.yres, vinfo.bits_per_pixel);
+ }
+#endif
+ /* Note: we use a framebuffer size of width*height*bbp. We cannot trust the
+ * values returned by the driver for line_length */
+
+ /* map framebuffer */
+ framebuffer = mmap(0, FRAMEBUFFER_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if((void *)framebuffer == MAP_FAILED)
+ {
+ panicf("Cannot map framebuffer");
+ }
+
+#ifdef HAVE_LCD_ENABLE
+ lcd_set_active(true);
+#endif
+}
+
+#ifdef HAVE_LCD_SHUTDOWN
+void lcd_shutdown(void)
+{
+ munmap(framebuffer, FRAMEBUFFER_SIZE);
+ close(fd);
+}
+#endif
+
+void lcd_enable(bool on)
+{
+ const char * const sysfs_fb_blank = "/sys/class/graphics/fb0/blank";
+
+ if (lcd_active() != on)
+ {
+ sysfs_set_int(sysfs_fb_blank, on ? 0 : 1);
+ lcd_set_active(on);
+
+ if (on)
+ {
+ send_event(LCD_EVENT_ACTIVATION, NULL);
+ }
+ }
+}
+
+static void redraw(void)
+{
+ ioctl(fd, FBIOPAN_DISPLAY, &vinfo);
+}
+
+extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src,
+ int width, int height);
+
+void lcd_update(void)
+{
+ /* Copy the Rockbox framebuffer to the second framebuffer */
+ lcd_copy_buffer_rect(LCD_FRAMEBUF_ADDR(0, 0), FBADDR(0,0),
+ LCD_WIDTH*LCD_HEIGHT, 1);
+ redraw();
+}
+
+void lcd_update_rect(int x, int y, int width, int height)
+{
+ fb_data *dst = LCD_FRAMEBUF_ADDR(x, y);
+ fb_data * src = FBADDR(x,y);
+
+ /* Copy part of the Rockbox framebuffer to the second framebuffer */
+ if (width < LCD_WIDTH)
+ {
+ /* Not full width - do line-by-line */
+ lcd_copy_buffer_rect(dst, src, width, height);
+ }
+ else
+ {
+ /* Full width - copy as one line */
+ lcd_copy_buffer_rect(dst, src, LCD_WIDTH*height, 1);
+ }
+ redraw();
+}
diff --git a/firmware/target/hosted/xduoo/power-xduoo.c b/firmware/target/hosted/xduoo/power-xduoo.c
new file mode 100644
index 0000000000..97a8dd4779
--- /dev/null
+++ b/firmware/target/hosted/xduoo/power-xduoo.c
@@ -0,0 +1,74 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2017 by Marcin Bukat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include <sys/types.h>
+#include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
+
+#include "system.h"
+#include "power-xduoo.h"
+#include "power.h"
+#include "panic.h"
+#include "sysfs.h"
+
+const char * const sysfs_bat_voltage =
+ "/sys/class/power_supply/battery/voltage_now";
+
+const char * const sysfs_bat_capacity =
+ "/sys/class/power_supply/battery/capacity";
+
+const char * const sysfs_bat_status =
+ "/sys/class/power_supply/battery/status";
+
+const char * const sysfs_pow_supply =
+ "/sys/class/power_supply/usb/present";
+
+unsigned int xduoo_power_input_status(void)
+{
+ int present = 0;
+ sysfs_get_int(sysfs_pow_supply, &present);
+
+ return present ? POWER_INPUT_USB_CHARGER : POWER_INPUT_NONE;
+}
+
+bool xduoo_power_charging_status(void)
+{
+ char buf[12] = {0};
+ sysfs_get_string(sysfs_bat_status, buf, sizeof(buf));
+
+ return (strncmp(buf, "Charging", 8) == 0);
+}
+
+unsigned int xduoo_power_get_battery_voltage(void)
+{
+ int battery_voltage;
+ sysfs_get_int(sysfs_bat_voltage, &battery_voltage);
+
+ return battery_voltage/1000;
+}
+
+unsigned int xduoo_power_get_battery_capacity(void)
+{
+ int battery_capacity;
+ sysfs_get_int(sysfs_bat_capacity, &battery_capacity);
+
+ return battery_capacity;
+}
diff --git a/firmware/target/hosted/xduoo/power-xduoo.h b/firmware/target/hosted/xduoo/power-xduoo.h
new file mode 100644
index 0000000000..d573865ed2
--- /dev/null
+++ b/firmware/target/hosted/xduoo/power-xduoo.h
@@ -0,0 +1,31 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2017 by Marcin Bukat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef _POWER_XDUOO_H_
+#define _POWER_XDUOO_H_
+
+#include <stdbool.h>
+#include "config.h"
+
+unsigned int xduoo_power_input_status(void);
+bool xduoo_power_charging_status(void);
+unsigned int xduoo_power_get_battery_voltage(void);
+unsigned int xduoo_power_get_battery_capacity(void);
+#endif /* _POWER_XDUOO_H_ */
+
diff --git a/firmware/target/hosted/xduoo/powermgmt-xduoo.c b/firmware/target/hosted/xduoo/powermgmt-xduoo.c
new file mode 100644
index 0000000000..30001934ba
--- /dev/null
+++ b/firmware/target/hosted/xduoo/powermgmt-xduoo.c
@@ -0,0 +1,70 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2017 Marcin Bukat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "powermgmt.h"
+#include "power.h"
+#include "power-xduoo.h"
+
+const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] =
+{
+ 3470
+};
+
+/* the OF shuts down at this voltage */
+const unsigned short battery_level_shutoff[BATTERY_TYPES_COUNT] =
+{
+ 3400
+};
+
+/* voltages (millivolt) of 0%, 10%, ... 100% when charging disabled */
+const unsigned short percent_to_volt_discharge[BATTERY_TYPES_COUNT][11] =
+{
+ { 3400, 3639, 3697, 3723, 3757, 3786, 3836, 3906, 3980, 4050, 4159 }
+};
+
+/* voltages (millivolt) of 0%, 10%, ... 100% when charging enabled */
+const unsigned short const percent_to_volt_charge[11] =
+{
+ 3485, 3780, 3836, 3857, 3890, 3930, 3986, 4062, 4158, 4185, 4196
+};
+
+unsigned int power_input_status(void)
+{
+ /* POWER_INPUT_USB_CHARGER, POWER_INPUT_NONE */
+ return xduoo_power_input_status();
+}
+
+#if defined(XDUOO_X3II)
+int _battery_voltage(void)
+{
+ return xduoo_power_get_battery_voltage();
+}
+#endif
+
+#if defined(XDUOO_X20)
+int _battery_level(void)
+{
+ return xduoo_power_get_battery_capacity();
+}
+#endif
+
+bool charging_state(void)
+{
+ return xduoo_power_charging_status();
+}
diff --git a/firmware/target/hosted/xduoo/system-target.h b/firmware/target/hosted/xduoo/system-target.h
new file mode 100644
index 0000000000..830f19fde4
--- /dev/null
+++ b/firmware/target/hosted/xduoo/system-target.h
@@ -0,0 +1,28 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2017 Marcin Bukat
+ * Copyright (C) 2016 Amaury Pouly
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef __SYSTEM_TARGET_H__
+#define __SYSTEM_TARGET_H__
+
+#include "kernel-unix.h"
+#include "system-hosted.h"
+
+#define NEED_GENERIC_BYTESWAPS
+#endif /* __SYSTEM_TARGET_H__ */
diff --git a/firmware/target/hosted/xduoo/usb-xduoo.c b/firmware/target/hosted/xduoo/usb-xduoo.c
new file mode 100644
index 0000000000..19248ad262
--- /dev/null
+++ b/firmware/target/hosted/xduoo/usb-xduoo.c
@@ -0,0 +1,118 @@
+/***************************************************************************
+ * __________ __ ___
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ *
+ * Copyright (C) 2018 by Marcin Bukat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include <stdlib.h>
+#include <sys/mount.h>
+#include <string.h>
+#include "config.h"
+#include "disk.h"
+#include "usb.h"
+#include "sysfs.h"
+#include "power.h"
+#include "power-xduoo.h"
+
+static bool adb_mode = false;
+
+/* TODO: implement usb detection properly */
+int usb_detect(void)
+{
+ return power_input_status() == POWER_INPUT_USB_CHARGER ? USB_INSERTED : USB_EXTRACTED;
+}
+
+void usb_enable(bool on)
+{
+ /* Ignore usb enable/disable when ADB is enabled so we can fireup adb shell
+ * without entering ums mode
+ */
+ if (!adb_mode)
+ {
+ sysfs_set_int("/sys/class/android_usb/android0/enable", on ? 1 : 0);
+ }
+}
+
+/* This is called by usb thread after usb extract in order to return
+ * regular FS access
+ *
+ * returns the # of successful mounts
+*/
+int disk_mount_all(void)
+{
+ const char *dev[] = {"/dev/mmcblk0p1", "/dev/mmcblk0"};
+ const char *fs[] = {"vfat", "exfat"};
+
+ sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/lun/file", "");
+
+ for (int i=0; i<2; i++)
+ {
+ for (int j=0; j<2; j++)
+ {
+ if (mount(dev[i], "/mnt/sd_0", fs[j], 0, NULL) == 0)
+ {
+ return 1;
+ }
+ }
+ }
+
+ return 0;
+}
+
+/* This is called by usb thread after all threads ACKs usb inserted message
+ *
+ * returns the # of successful unmounts
+ */
+int disk_unmount_all(void)
+{
+ if (umount("/mnt/sd_0") == 0)
+ {
+ sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/lun/file", "/dev/mmcblk0");
+ return 1;
+ }
+
+ return 0;
+}
+
+void usb_init_device(void)
+{
+ char functions[32] = {0};
+
+ /* Check if ADB was activated in bootloader */
+ sysfs_get_string("/sys/class/android_usb/android0/functions", functions, sizeof(functions));
+ adb_mode = (strstr(functions, "adb") == NULL) ? false : true;
+
+ usb_enable(false);
+
+ if (adb_mode)
+ {
+ sysfs_set_string("/sys/class/android_usb/android0/functions", "mass_storage,adb");
+ sysfs_set_string("/sys/class/android_usb/android0/idVendor", "18D1");
+ sysfs_set_string("/sys/class/android_usb/android0/idProduct", "D002");
+ }
+ else
+ {
+ sysfs_set_string("/sys/class/android_usb/android0/functions", "mass_storage");
+ sysfs_set_string("/sys/class/android_usb/android0/idVendor", "C502");
+ sysfs_set_string("/sys/class/android_usb/android0/idProduct", "0029");
+ }
+
+ sysfs_set_string("/sys/class/android_usb/android0/iManufacturer", "Rockbox.org");
+ sysfs_set_string("/sys/class/android_usb/android0/iProduct", "Rockbox media player");
+ sysfs_set_string("/sys/class/android_usb/android0/iSerial", "0123456789ABCDEF");
+ sysfs_set_string("/sys/class/android_usb/android0/f_mass_storage/inquiry_string", "xDuoo 0100");
+}
diff --git a/firmware/target/hosted/xduoo/xduoo.make b/firmware/target/hosted/xduoo/xduoo.make
new file mode 100644
index 0000000000..5c37d27412
--- /dev/null
+++ b/firmware/target/hosted/xduoo/xduoo.make
@@ -0,0 +1,52 @@
+# __________ __ ___.
+# Open \______ \ ____ ____ | | _\_ |__ _______ ___
+# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+# \/ \/ \/ \/ \/
+# $Id$
+#
+
+INCLUDES += -I$(FIRMDIR)/include -I$(FIRMDIR)/export $(TARGET_INC) -I$(BUILDDIR) -I$(APPSDIR)
+
+SIMFLAGS += $(INCLUDES) $(DEFINES) -DHAVE_CONFIG_H $(GCCOPTS)
+
+# bootloader build is sligtly different
+ifneq (,$(findstring bootloader,$(APPSDIR)))
+
+SRC += $(call preprocess, $(APPSDIR)/SOURCES)
+CLEANOBJS += $(BUILDDIR)/bootloader.*
+
+endif #bootloader
+
+.SECONDEXPANSION: # $$(OBJ) is not populated until after this
+
+ifneq (,$(findstring bootloader,$(APPSDIR)))
+# bootloader build
+
+$(BUILDDIR)/bootloader.elf : $$(OBJ) $(FIRMLIB) $(CORE_LIBS)
+ $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -o $@ $(OBJ) \
+ -L$(BUILDDIR)/firmware -lfirmware \
+ -L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \
+ $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,--gc-sections -Wl,-Map,$(BUILDDIR)/bootloader.map
+
+$(BUILDDIR)/$(BINARY): $(BUILDDIR)/bootloader.elf
+ $(call PRINTS,OC $(@F))$(call objcopy,$^,$@)
+
+else
+# rockbox app build
+
+$(BUILDDIR)/rockbox.elf : $$(OBJ) $(FIRMLIB) $(VOICESPEEXLIB) $(CORE_LIBS)
+ $(call PRINTS,LD $(@F))$(CC) $(GCCOPTS) -Os -o $@ $(OBJ) \
+ -L$(BUILDDIR)/firmware -lfirmware \
+ -L$(RBCODEC_BLD)/codecs $(call a2lnk, $(VOICESPEEXLIB)) \
+ -L$(BUILDDIR)/lib $(call a2lnk,$(CORE_LIBS)) \
+ $(LDOPTS) $(GLOBAL_LDOPTS) -Wl,-Map,$(BUILDDIR)/rockbox.map
+
+$(BUILDDIR)/rockbox.x3ii : $(BUILDDIR)/rockbox.elf
+ $(call PRINTS,OC $(@F))$(call objcopy,$^,$@)
+
+$(BUILDDIR)/rockbox.x20 : $(BUILDDIR)/rockbox.elf
+ $(call PRINTS,OC $(@F))$(call objcopy,$^,$@)
+
+endif
diff --git a/tools/configure b/tools/configure
index f6fc50d905..4b2b1ce829 100755
--- a/tools/configure
+++ b/tools/configure
@@ -888,7 +888,6 @@ mipsellinuxcc () {
SHARED_LDFLAG="-shared"
SHARED_CFLAGS='-fPIC -fvisibility=hidden'
endian="little"
- app_type="rocker"
thread_support="HAVE_SIGALTSTACK_THREADS"
# Include path
@@ -1244,7 +1243,7 @@ voiceconfig () {
exit 4
fi
fi
-
+
echo "Using $ENCODER for encoding voice clips"
# Read custom encoder options from command line
@@ -1392,7 +1391,7 @@ ARG_ARM_THUMB=
ARG_PREFIX="$PREFIX"
ARG_THREAD_SUPPORT=
ARG_32BIT=
-err=
+err=
for arg in "$@"; do
case "$arg" in
--ccache) ARG_CCACHE=1;;
@@ -1565,6 +1564,8 @@ cat <<EOF
229) NWZ-S750 series
==xDuoo== ==AgpTek==
241) X3 240) Rocker
+ 242) X3II
+ 243) X20
EOF
@@ -2260,7 +2261,7 @@ fi
t_manufacturer="tcc780x"
t_model="cowond2"
;;
-
+
34|iaudiom3)
target_id=37
modelname="iaudiom3"
@@ -2403,7 +2404,7 @@ fi
t_manufacturer="tcc77x"
t_model="logikdax"
;;
-
+
89|creativezenxfistyle)
target_id=94
modelname="creativezenxfistyle"
@@ -2446,7 +2447,7 @@ fi
t_manufacturer="tms320dm320"
t_model="creative-zvm"
;;
-
+
91|zenvisionm60gb)
target_id=40
modelname="zenvisionm60gb"
@@ -2469,7 +2470,7 @@ fi
t_manufacturer="tms320dm320"
t_model="creative-zvm"
;;
-
+
92|zenvision)
target_id=39
modelname="zenvision"
@@ -2717,9 +2718,9 @@ fi
;;
54|sansac100)
- target_id=42
- modelname="sansac100"
- target="SANSA_C100"
+ target_id=42
+ modelname="sansac100"
+ target="SANSA_C100"
memory=2
arm946cc
tool="$rootdir/tools/scramble -add=c100"
@@ -3117,7 +3118,7 @@ fi
t_manufacturer="s5l8700"
t_model="meizu-m6sl"
;;
-
+
111|meizum6sp)
target_id=46
modelname="meizum6sp"
@@ -3139,7 +3140,7 @@ fi
t_manufacturer="s5l8700"
t_model="meizu-m6sp"
;;
-
+
112|meizum3)
target_id=47
modelname="meizum3"
@@ -3161,7 +3162,7 @@ fi
t_manufacturer="s5l8700"
t_model="meizu-m3"
;;
-
+
120|ondavx747)
target_id=45
modelname="ondavx747"
@@ -3183,7 +3184,7 @@ fi
t_manufacturer="ingenic_jz47xx"
t_model="onda_vx747"
;;
-
+
121|ondavx767)
target_id=64
modelname="ondavx767"
@@ -3205,7 +3206,7 @@ fi
t_manufacturer="ingenic_jz47xx"
t_model="onda_vx767"
;;
-
+
122|ondavx747p)
target_id=54
modelname="ondavx747p"
@@ -3227,7 +3228,7 @@ fi
t_manufacturer="ingenic_jz47xx"
t_model="onda_vx747"
;;
-
+
123|ondavx777)
target_id=61
modelname="ondavx777"
@@ -3249,7 +3250,7 @@ fi
t_manufacturer="ingenic_jz47xx"
t_model="onda_vx747"
;;
-
+
130|lyreproto1)
target_id=56
modelname="lyreproto1"
@@ -3271,7 +3272,7 @@ fi
t_manufacturer="at91sam"
t_model="lyre_proto1"
;;
-
+
131|mini2440)
target_id=99
modelname="mini2440"
@@ -3390,7 +3391,7 @@ fi
t_manufacturer="s5l8700"
t_model="yps3"
;;
-
+
144|samsungypz5)
target_id=90
modelname="samsungypz5"
@@ -4226,10 +4227,11 @@ fi
240|agptekrocker)
application="yes"
+ app_type="rocker"
target_id=97
modelname="agptekrocker"
target="AGPTEK_ROCKER"
- memory=6
+ memory=8
tool="cp "
boottool="cp "
bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
@@ -4268,6 +4270,52 @@ fi
t_model="xduoo_x3"
;;
+ 242|xduoox3ii)
+ target_id=110
+ application=yes
+ app_type="xduoo"
+ modelname="xduoox3ii"
+ target="XDUOO_X3II"
+ memory=8
+ mipsellinuxcc
+ tool="cp "
+ boottool="cp "
+ bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
+ bmp2rb_native="$rootdir/tools/bmp2rb -f 10"
+ output="rockbox.x3ii"
+ bootoutput="bootloader.x3ii"
+ appextra="recorder:gui:hosted"
+ plugins="yes"
+ swcodec="yes"
+ # architecture, manufacturer and model for the target-tree build
+ t_cpu="hosted"
+ t_manufacturer="xduoo"
+ t_model="xduoo_x3ii"
+ ;;
+
+ 243|xduoox20)
+ target_id=111
+ application=yes
+ app_type="xduoo"
+ modelname="xduoox20"
+ target="XDUOO_X20"
+ memory=8
+ mipsellinuxcc
+ tool="cp "
+ boottool="cp "
+ bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
+ bmp2rb_native="$rootdir/tools/bmp2rb -f 10"
+ output="rockbox.x20"
+ bootoutput="bootloader.x20"
+ appextra="recorder:gui:hosted"
+ plugins="yes"
+ swcodec="yes"
+ # architecture, manufacturer and model for the target-tree build
+ t_cpu="hosted"
+ t_manufacturer="xduoo"
+ t_model="xduoo_x20"
+ ;;
+
250|ihifi770c)
target_id=107
modelname="ihifi770c"
@@ -4749,7 +4797,7 @@ if [ -z "$arch" ]; then
arch="none"
echo "Warning: Could not determine target arch"
fi
- if [ "$arch" != "none" ]; then
+ if [ "$arch" != "none" ]; then
if [ -n "$arch_version" ]; then
echo "Automatically selected arch: $arch (ver $arch_version)"
else
@@ -4789,7 +4837,7 @@ if [ "$ARG_RBDIR" != "" ]; then
rbdir="/"$ARG_RBDIR
else
rbdir=$ARG_RBDIR
- fi
+ fi
echo "Using alternate rockbox dir: ${rbdir}"
fi
diff --git a/tools/root.make b/tools/root.make
index 72039335da..412dbbc97b 100644
--- a/tools/root.make
+++ b/tools/root.make
@@ -105,6 +105,8 @@ ifneq (,$(findstring bootloader,$(APPSDIR)))
include $(ROOTDIR)/firmware/target/hosted/sonynwz/sonynwz.make
else ifneq (,$(findstring rocker,$(APP_TYPE)))
include $(ROOTDIR)/firmware/target/hosted/agptek/rocker.make
+ else ifneq (,$(findstring xduoo,$(APP_TYPE)))
+ include $(ROOTDIR)/firmware/target/hosted/xduoo/xduoo.make
else
include $(APPSDIR)/bootloader.make
endif
@@ -149,6 +151,10 @@ else # core
include $(ROOTDIR)/firmware/target/hosted/agptek/rocker.make
endif
+ ifneq (,$(findstring xduoo,$(APP_TYPE)))
+ include $(ROOTDIR)/firmware/target/hosted/xduoo/xduoo.make
+ endif
+
ifneq (,$(findstring android_ndk, $(APP_TYPE)))
include $(ROOTDIR)/firmware/target/hosted/ibasso/android_ndk.make
else