sonynwz: rework keymap based on lebellium's work and enable volume in list

Change-Id: Ieb015e78d1c0aa74c61591e442bfdf5f883f3811
diff --git a/apps/keymaps/keymap-nwz.c b/apps/keymaps/keymap-nwz.c
index 5e9a629..210841b 100644
--- a/apps/keymaps/keymap-nwz.c
+++ b/apps/keymaps/keymap-nwz.c
@@ -38,24 +38,25 @@
     { ACTION_STD_NEXT,                  BUTTON_DOWN,                       BUTTON_NONE },
     { ACTION_STD_NEXTREPEAT,            BUTTON_DOWN|BUTTON_REPEAT,         BUTTON_NONE },
 
-    { ACTION_STD_CONTEXT,               BUTTON_PLAY|BUTTON_REPEAT,       BUTTON_PLAY },
+    { ACTION_STD_CONTEXT,               BUTTON_PLAY|BUTTON_REPEAT,         BUTTON_PLAY },
     { ACTION_STD_CONTEXT,               BUTTON_RIGHT|BUTTON_REPEAT,        BUTTON_RIGHT },
 
     { ACTION_STD_MENU,                  BUTTON_BACK,                       BUTTON_NONE },
     { ACTION_STD_MENU,                  BUTTON_BACK|BUTTON_REPEAT,         BUTTON_NONE },
     { ACTION_STD_CANCEL,                BUTTON_LEFT,                       BUTTON_NONE },
     { ACTION_STD_CANCEL,                BUTTON_LEFT|BUTTON_REPEAT,         BUTTON_NONE },
-    { ACTION_STD_OK,                    BUTTON_PLAY|BUTTON_REL,          BUTTON_PLAY },
+    { ACTION_STD_OK,                    BUTTON_PLAY|BUTTON_REL,            BUTTON_PLAY },
     { ACTION_STD_OK,                    BUTTON_RIGHT|BUTTON_REL,           BUTTON_RIGHT },
 
     LAST_ITEM_IN_LIST
 }; /* button_context_standard */
 
 static const struct button_mapping button_context_wps[]  = {
-    { ACTION_WPS_PLAY,                  BUTTON_POWER|BUTTON_REL,       BUTTON_POWER },
-    { ACTION_WPS_STOP,                  BUTTON_POWER|BUTTON_REPEAT,    BUTTON_NONE },
+    { ACTION_WPS_PLAY,                  BUTTON_PLAY|BUTTON_REL,            BUTTON_PLAY },
+    { ACTION_WPS_STOP,                  BUTTON_PLAY|BUTTON_REPEAT,         BUTTON_NONE },
 
-    { ACTION_WPS_CONTEXT,               BUTTON_PLAY|BUTTON_REPEAT,       BUTTON_NONE },
+    { ACTION_WPS_QUICKSCREEN,           BUTTON_POWER|BUTTON_REL,           BUTTON_POWER },
+    { ACTION_WPS_CONTEXT,               BUTTON_POWER|BUTTON_REPEAT,        BUTTON_NONE },
 
     { ACTION_WPS_SKIPNEXT,              BUTTON_RIGHT|BUTTON_REL,           BUTTON_RIGHT },
     { ACTION_WPS_SEEKFWD,               BUTTON_RIGHT|BUTTON_REPEAT,        BUTTON_NONE },
@@ -64,14 +65,21 @@
     { ACTION_WPS_STOPSEEK,              BUTTON_LEFT|BUTTON_REL,            BUTTON_LEFT|BUTTON_REPEAT },
     { ACTION_WPS_STOPSEEK,              BUTTON_RIGHT|BUTTON_REL,           BUTTON_RIGHT|BUTTON_REPEAT },
 
-    { ACTION_WPS_VOLUP,                 BUTTON_UP,                         BUTTON_NONE },
-    { ACTION_WPS_VOLUP,                 BUTTON_UP|BUTTON_REPEAT,           BUTTON_NONE },
+/* only compiled if there is a Volume UP button defined */
+#ifdef BUTTON_VOL_UP
+    { 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 },
+#endif
 
-    { ACTION_WPS_VOLDOWN,               BUTTON_DOWN,                       BUTTON_NONE },
+    { ACTION_WPS_VOLUP,                 BUTTON_UP|BUTTON_REPEAT,           BUTTON_NONE },
+    { ACTION_WPS_VOLUP,                 BUTTON_UP,                         BUTTON_NONE },
     { ACTION_WPS_VOLDOWN,               BUTTON_DOWN|BUTTON_REPEAT,         BUTTON_NONE },
- 
-    { ACTION_WPS_MENU,                  BUTTON_BACK,                       BUTTON_NONE },
-    { ACTION_WPS_BROWSE,                BUTTON_PLAY|BUTTON_REL,          BUTTON_PLAY },
+    { ACTION_WPS_VOLDOWN,               BUTTON_DOWN,                       BUTTON_NONE },
+
+    { ACTION_WPS_MENU,                  BUTTON_BACK|BUTTON_REPEAT,         BUTTON_NONE },
+    { ACTION_WPS_BROWSE,                BUTTON_BACK|BUTTON_REL,            BUTTON_BACK },
 
     LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
 }; /* button_context_wps */
@@ -89,16 +97,16 @@
     { ACTION_KBD_BACKSPACE,             BUTTON_BACK,                       BUTTON_NONE },
     { ACTION_KBD_BACKSPACE,             BUTTON_BACK|BUTTON_REPEAT,         BUTTON_NONE },
 
-    { ACTION_KBD_SELECT,                BUTTON_POWER,                  BUTTON_NONE },
-    { ACTION_KBD_DONE,                  BUTTON_PLAY|BUTTON_REPEAT,       BUTTON_PLAY },
+    { ACTION_KBD_SELECT,                BUTTON_POWER,                      BUTTON_NONE },
+    { ACTION_KBD_DONE,                  BUTTON_PLAY|BUTTON_REPEAT,         BUTTON_PLAY },
 
     LAST_ITEM_IN_LIST
 }; /* button_context_keyboard */
 
 static const struct button_mapping button_context_quickscreen[]  = {
-    { ACTION_STD_CANCEL,                BUTTON_PLAY,                     BUTTON_NONE },
+    { ACTION_STD_CANCEL,                BUTTON_PLAY,                       BUTTON_NONE },
     { ACTION_STD_CANCEL,                BUTTON_BACK,                       BUTTON_NONE },
-    { ACTION_STD_CANCEL,                BUTTON_POWER,                  BUTTON_NONE },
+    { ACTION_STD_CANCEL,                BUTTON_POWER,                      BUTTON_NONE },
     { ACTION_QS_TOP,                    BUTTON_UP,                         BUTTON_NONE },
     { ACTION_QS_DOWN,                   BUTTON_DOWN,                       BUTTON_NONE },
     { ACTION_QS_LEFT,                   BUTTON_LEFT,                       BUTTON_NONE },
@@ -108,13 +116,19 @@
 }; /* button_context_quickscreen */
 
 static const struct button_mapping button_context_tree[]  = {
-    { ACTION_TREE_WPS,                  BUTTON_POWER|BUTTON_REL,       BUTTON_POWER },
-    { ACTION_TREE_STOP,                 BUTTON_POWER|BUTTON_REPEAT,    BUTTON_NONE },
+    { ACTION_TREE_WPS,                  BUTTON_POWER|BUTTON_REL,           BUTTON_POWER },
+    { ACTION_TREE_STOP,                 BUTTON_POWER|BUTTON_REPEAT,        BUTTON_NONE },
 
     LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST)
 }; /* button_context_tree */
 
 static const struct button_mapping button_context_list[]  = {
+#ifdef HAVE_VOLUME_IN_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 },
+#endif
 
     LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
 }; /* button_context_list */
@@ -122,13 +136,13 @@
 #ifdef CONFIG_TUNER
 static const struct button_mapping button_context_radio[]  = {
 
-    { ACTION_FM_MODE,                  BUTTON_PLAY|BUTTON_REL,           BUTTON_PLAY },
-    { ACTION_FM_MENU,                  BUTTON_PLAY|BUTTON_REPEAT,        BUTTON_NONE },
+    { ACTION_FM_MODE,                  BUTTON_POWER|BUTTON_REL,          BUTTON_POWER },
+    { ACTION_FM_MENU,                  BUTTON_POWER|BUTTON_REPEAT,       BUTTON_NONE },
 
-    { ACTION_FM_PLAY,                  BUTTON_POWER|BUTTON_REL,        BUTTON_POWER },
-    { ACTION_FM_STOP,                  BUTTON_POWER|BUTTON_REPEAT,     BUTTON_NONE },
+    { ACTION_FM_PLAY,                  BUTTON_PLAY|BUTTON_REL,           BUTTON_PLAY },
+    { ACTION_FM_STOP,                  BUTTON_PLAY|BUTTON_REPEAT,        BUTTON_NONE },
 
-    { ACTION_FM_EXIT,                  BUTTON_BACK,                        BUTTON_NONE },
+    { ACTION_FM_EXIT,                  BUTTON_BACK,                      BUTTON_NONE },
 
     LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
 }; /* button_context_radio */
@@ -136,8 +150,8 @@
 
 #ifdef HAVE_RECORDING
 static const struct button_mapping button_context_recscreen[]  = {
-
-    { ACTION_REC_PAUSE,                BUTTON_POWER,                   BUTTON_NONE },
+ 
+    { ACTION_REC_PAUSE,                BUTTON_PLAY,                        BUTTON_NONE },
     { ACTION_SETTINGS_INC,             BUTTON_RIGHT,                       BUTTON_NONE },
     { ACTION_SETTINGS_INCREPEAT,       BUTTON_RIGHT|BUTTON_REPEAT,         BUTTON_NONE },
     { ACTION_SETTINGS_DEC,             BUTTON_LEFT,                        BUTTON_NONE },
@@ -161,8 +175,8 @@
     { ACTION_STD_NEXT,                  BUTTON_RIGHT,                      BUTTON_NONE },
     { ACTION_STD_NEXTREPEAT,            BUTTON_RIGHT|BUTTON_REPEAT,        BUTTON_NONE },
 
-    { ACTION_STD_OK,                    BUTTON_PLAY|BUTTON_REL,          BUTTON_PLAY },
-    { ACTION_SETTINGS_RESET,            BUTTON_PLAY|BUTTON_REPEAT,       BUTTON_NONE },
+    { ACTION_STD_OK,                    BUTTON_PLAY|BUTTON_REL,            BUTTON_PLAY },
+    { ACTION_SETTINGS_RESET,            BUTTON_PLAY|BUTTON_REPEAT,         BUTTON_NONE },
 
     LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_STD)
 }; /* button_context_settings */
@@ -183,27 +197,27 @@
 static const struct button_mapping button_context_time[]  = {
 
     { ACTION_STD_CANCEL,               BUTTON_BACK,                        BUTTON_NONE },
-    { ACTION_STD_OK,                   BUTTON_POWER,                   BUTTON_NONE },
+    { ACTION_STD_OK,                   BUTTON_PLAY,                        BUTTON_NONE },
 
     LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_SETTINGS)
 }; /* button_context_time */
 
 static const struct button_mapping button_context_colorchooser[]  = {
-    { ACTION_STD_OK,                    BUTTON_PLAY|BUTTON_REL,          BUTTON_PLAY },
-    { ACTION_STD_CANCEL,                BUTTON_BACK,                       BUTTON_NONE   },
+    { ACTION_STD_OK,                    BUTTON_PLAY|BUTTON_REL,            BUTTON_PLAY },
+    { ACTION_STD_CANCEL,                BUTTON_BACK,                       BUTTON_NONE },
 
     LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS),
 }; /* button_context_colorchooser */
 
 static const struct button_mapping button_context_eq[]  = {
-    { ACTION_STD_OK,                    BUTTON_PLAY|BUTTON_REL,          BUTTON_PLAY },
+    { ACTION_STD_OK,                    BUTTON_PLAY|BUTTON_REL,            BUTTON_PLAY },
 
     LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM|CONTEXT_SETTINGS),
 }; /* button_context_eq */
 
 /* Bookmark Screen */
 static const struct button_mapping button_context_bmark[]  = {
-    { ACTION_BMS_DELETE,                BUTTON_PLAY|BUTTON_REPEAT,       BUTTON_PLAY },
+    { ACTION_BMS_DELETE,                BUTTON_PLAY|BUTTON_REPEAT,         BUTTON_PLAY },
 
     LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_LIST),
 }; /* button_context_bmark */
@@ -220,9 +234,9 @@
     { ACTION_PS_NUDGE_RIGHT,    BUTTON_RIGHT,                              BUTTON_NONE },
     { ACTION_PS_NUDGE_RIGHT,    BUTTON_RIGHT|BUTTON_REPEAT,                BUTTON_NONE },
 
-    { ACTION_PS_RESET,          BUTTON_PLAY,                             BUTTON_NONE },
+    { ACTION_PS_RESET,          BUTTON_PLAY,                               BUTTON_NONE },
     { ACTION_PS_EXIT,           BUTTON_BACK,                               BUTTON_NONE },
-    { ACTION_PS_EXIT,           BUTTON_POWER,                          BUTTON_NONE },
+    { ACTION_PS_EXIT,           BUTTON_POWER,                              BUTTON_NONE },
 
     LAST_ITEM_IN_LIST
 }; /* button_context_pitchcreen */
@@ -245,20 +259,19 @@
     { ACTION_USB_HID_MULTIMEDIA_VOLUME_DOWN,         BUTTON_DOWN|BUTTON_REPEAT,     BUTTON_NONE },
     { ACTION_USB_HID_MULTIMEDIA_VOLUME_UP,           BUTTON_UP,                     BUTTON_NONE },
     { ACTION_USB_HID_MULTIMEDIA_VOLUME_UP,           BUTTON_UP|BUTTON_REPEAT,       BUTTON_NONE },
-    { ACTION_USB_HID_MULTIMEDIA_VOLUME_MUTE,         BUTTON_PLAY|BUTTON_REL,      BUTTON_PLAY },
+    { ACTION_USB_HID_MULTIMEDIA_VOLUME_MUTE,         BUTTON_PLAY|BUTTON_REL,        BUTTON_PLAY },
     { ACTION_USB_HID_MULTIMEDIA_VOLUME_MUTE,         BUTTON_BACK|BUTTON_REL,        BUTTON_BACK },
-    { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_PLAY_PAUSE, BUTTON_POWER|BUTTON_REL,   BUTTON_POWER },
-    { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_STOP,       BUTTON_POWER|BUTTON_REPEAT, BUTTON_POWER },
+    { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_PLAY_PAUSE, BUTTON_POWER|BUTTON_REL,       BUTTON_POWER },
+    { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_STOP,       BUTTON_POWER|BUTTON_REPEAT,    BUTTON_POWER },
     { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_TRACK_PREV, BUTTON_LEFT|BUTTON_REL,        BUTTON_LEFT },
     { ACTION_USB_HID_MULTIMEDIA_PLAYBACK_TRACK_NEXT, BUTTON_RIGHT|BUTTON_REL,       BUTTON_RIGHT },
 
     LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID)
 }; /* button_context_usb_hid_mode_multimedia */
 
-
 static const struct button_mapping button_context_usb_hid_mode_presentation[] = {
-    { ACTION_USB_HID_PRESENTATION_SLIDESHOW_START, BUTTON_POWER|BUTTON_REL,     BUTTON_POWER },
-    { ACTION_USB_HID_PRESENTATION_SLIDESHOW_LEAVE, BUTTON_POWER|BUTTON_REPEAT,  BUTTON_POWER },
+    { ACTION_USB_HID_PRESENTATION_SLIDESHOW_START, BUTTON_POWER|BUTTON_REL,         BUTTON_POWER },
+    { ACTION_USB_HID_PRESENTATION_SLIDESHOW_LEAVE, BUTTON_POWER|BUTTON_REPEAT,      BUTTON_POWER },
     { ACTION_USB_HID_PRESENTATION_SLIDE_PREV,      BUTTON_LEFT|BUTTON_REL,          BUTTON_LEFT },
     { ACTION_USB_HID_PRESENTATION_SLIDE_NEXT,      BUTTON_RIGHT|BUTTON_REL,         BUTTON_RIGHT },
     { ACTION_USB_HID_PRESENTATION_SLIDE_FIRST,     BUTTON_LEFT|BUTTON_REPEAT,       BUTTON_NONE },
@@ -267,8 +280,8 @@
     { ACTION_USB_HID_PRESENTATION_LINK_PREV,       BUTTON_UP|BUTTON_REPEAT,         BUTTON_NONE },
     { ACTION_USB_HID_PRESENTATION_LINK_NEXT,       BUTTON_DOWN,                     BUTTON_NONE },
     { ACTION_USB_HID_PRESENTATION_LINK_NEXT,       BUTTON_DOWN|BUTTON_REPEAT,       BUTTON_NONE },
-    { ACTION_USB_HID_PRESENTATION_MOUSE_CLICK,     BUTTON_PLAY,                   BUTTON_PLAY },
-    { ACTION_USB_HID_PRESENTATION_MOUSE_OVER,      BUTTON_PLAY|BUTTON_REPEAT,     BUTTON_PLAY },
+    { ACTION_USB_HID_PRESENTATION_MOUSE_CLICK,     BUTTON_PLAY,                     BUTTON_PLAY },
+    { ACTION_USB_HID_PRESENTATION_MOUSE_OVER,      BUTTON_PLAY|BUTTON_REPEAT,       BUTTON_PLAY },
 
     LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID)
 }; /* button_context_usb_hid_mode_presentation */
@@ -278,13 +291,13 @@
     { ACTION_USB_HID_BROWSER_SCROLL_UP,        BUTTON_UP|BUTTON_REPEAT,             BUTTON_NONE },
     { ACTION_USB_HID_BROWSER_SCROLL_DOWN,      BUTTON_DOWN,                         BUTTON_NONE },
     { ACTION_USB_HID_BROWSER_SCROLL_DOWN,      BUTTON_DOWN|BUTTON_REPEAT,           BUTTON_NONE },
-    { ACTION_USB_HID_BROWSER_ZOOM_RESET,       BUTTON_POWER|BUTTON_REPEAT,      BUTTON_NONE },
+    { ACTION_USB_HID_BROWSER_ZOOM_RESET,       BUTTON_POWER|BUTTON_REPEAT,          BUTTON_NONE },
     { ACTION_USB_HID_BROWSER_TAB_PREV,         BUTTON_LEFT|BUTTON_REL,              BUTTON_LEFT },
     { ACTION_USB_HID_BROWSER_TAB_NEXT,         BUTTON_RIGHT|BUTTON_REL,             BUTTON_RIGHT },
     { ACTION_USB_HID_BROWSER_TAB_CLOSE,        BUTTON_BACK|BUTTON_REPEAT,           BUTTON_BACK },
     { ACTION_USB_HID_BROWSER_HISTORY_BACK,     BUTTON_LEFT|BUTTON_REPEAT,           BUTTON_LEFT },
     { ACTION_USB_HID_BROWSER_HISTORY_FORWARD,  BUTTON_RIGHT|BUTTON_REPEAT,          BUTTON_RIGHT },
-    { ACTION_USB_HID_BROWSER_VIEW_FULL_SCREEN, BUTTON_PLAY|BUTTON_REPEAT,         BUTTON_PLAY },
+    { ACTION_USB_HID_BROWSER_VIEW_FULL_SCREEN, BUTTON_PLAY|BUTTON_REPEAT,           BUTTON_PLAY },
 
     LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID)
 }; /* button_context_usb_hid_mode_browser */
@@ -300,15 +313,15 @@
     { ACTION_USB_HID_MOUSE_RIGHT,             BUTTON_RIGHT,                         BUTTON_NONE },
     { ACTION_USB_HID_MOUSE_RIGHT_REP,         BUTTON_RIGHT|BUTTON_REPEAT,           BUTTON_NONE },
 
-    { ACTION_USB_HID_MOUSE_BUTTON_LEFT,       BUTTON_PLAY,                        BUTTON_NONE },
-    { ACTION_USB_HID_MOUSE_BUTTON_LEFT_REL,   BUTTON_PLAY|BUTTON_REL,             BUTTON_NONE },
- 
-    { ACTION_USB_HID_MOUSE_BUTTON_RIGHT,      BUTTON_POWER,                     BUTTON_NONE },
-    { ACTION_USB_HID_MOUSE_BUTTON_RIGHT_REL,  BUTTON_POWER|BUTTON_REL,          BUTTON_POWER },
+    { ACTION_USB_HID_MOUSE_BUTTON_LEFT,       BUTTON_PLAY,                          BUTTON_NONE },
+    { ACTION_USB_HID_MOUSE_BUTTON_LEFT_REL,   BUTTON_PLAY|BUTTON_REL,               BUTTON_NONE },
+
+    { ACTION_USB_HID_MOUSE_BUTTON_RIGHT,      BUTTON_POWER,                         BUTTON_NONE },
+    { ACTION_USB_HID_MOUSE_BUTTON_RIGHT_REL,  BUTTON_POWER|BUTTON_REL,              BUTTON_POWER },
 
     { ACTION_USB_HID_MOUSE_WHEEL_SCROLL_UP,   BUTTON_BACK,                          BUTTON_NONE },
     { ACTION_USB_HID_MOUSE_WHEEL_SCROLL_UP,   BUTTON_BACK|BUTTON_REPEAT,            BUTTON_NONE },
- 
+
     LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_USB_HID)
 }; /* button_context_usb_hid_mode_mouse */
 #endif
diff --git a/firmware/export/config/sonynwze360.h b/firmware/export/config/sonynwze360.h
index a0f05f4..ddb1979 100644
--- a/firmware/export/config/sonynwze360.h
+++ b/firmware/export/config/sonynwze360.h
@@ -40,6 +40,9 @@
 /* define this if you would like tagcache to build on this target */
 #define HAVE_TAGCACHE
 
+/* define this if the target has volume keys which can be used in the lists */
+#define HAVE_VOLUME_IN_LIST
+
 /* define this if you have LCD enable function */
 #define HAVE_LCD_ENABLE