diff --git a/apps/SOURCES b/apps/SOURCES index b1e5cce75d..40aa022842 100644 --- a/apps/SOURCES +++ b/apps/SOURCES @@ -138,6 +138,9 @@ metadata/a52.c #ifdef HAVE_TAGCACHE tagcache.c #endif +#ifdef HAVE_TOUCHPAD +keymaps/keymap-touchpad.c +#endif #if (CONFIG_KEYPAD == IRIVER_H100_PAD) \ || (CONFIG_KEYPAD == IRIVER_H300_PAD) keymaps/keymap-h1x0_h3x0.c diff --git a/apps/action.h b/apps/action.h index c1c60c9b0b..96e8086baa 100644 --- a/apps/action.h +++ b/apps/action.h @@ -25,14 +25,15 @@ #define TIMEOUT_NOBLOCK 0 #define CONTEXT_STOPSEARCHING 0xFFFFFFFF -#define CONTEXT_REMOTE 0x80000000 /* | this against another context to get remote buttons for that context */ -#define CONTEXT_CUSTOM 0x40000000 /* | this against anything to get your context number */ +#define CONTEXT_REMOTE 0x80000000 /* | this against another context to get remote buttons for that context */ +#define CONTEXT_CUSTOM 0x40000000 /* | this against anything to get your context number */ +#define CONTEXT_CUSTOM2 0x20000000 /* as above */ #define LAST_ITEM_IN_LIST { CONTEXT_STOPSEARCHING, BUTTON_NONE, BUTTON_NONE } #define LAST_ITEM_IN_LIST__NEXTLIST(a) { a, BUTTON_NONE, BUTTON_NONE } #ifndef HAS_BUTTON_HOLD -#define ALLOW_SOFTLOCK 0x20000000 /* will be stripped.. never needed except in calls to get_action() */ +#define ALLOW_SOFTLOCK 0x10000000 /* will be stripped.. never needed except in calls to get_action() */ #else #define ALLOW_SOFTLOCK 0 #endif @@ -79,6 +80,7 @@ enum { ACTION_UNKNOWN, ACTION_REDRAW, /* returned if keys are locked and we splash()'ed */ ACTION_TOUCHPAD, + ACTION_TOUCHPAD_MODE, /* toggle the touchpad mode */ /* standard actions, use these first */ ACTION_STD_PREV, diff --git a/apps/keymaps/keymap-cowond2.c b/apps/keymaps/keymap-cowond2.c index ff4fdc5417..59ca7cb123 100644 --- a/apps/keymaps/keymap-cowond2.c +++ b/apps/keymaps/keymap-cowond2.c @@ -37,48 +37,27 @@ */ static const struct button_mapping button_context_standard[] = { - { ACTION_STD_PREV, BUTTON_UP, BUTTON_NONE }, { ACTION_STD_PREV, BUTTON_MINUS, BUTTON_NONE }, - { ACTION_STD_PREVREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_PREVREPEAT, BUTTON_MINUS|BUTTON_REPEAT, BUTTON_NONE }, - { ACTION_STD_NEXT, BUTTON_DOWN, BUTTON_NONE }, { ACTION_STD_NEXT, BUTTON_PLUS, BUTTON_NONE }, - { ACTION_STD_NEXTREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_NEXTREPEAT, BUTTON_PLUS|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_OK, BUTTON_MENU|BUTTON_REL, BUTTON_NONE }, - { ACTION_STD_OK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, - { ACTION_STD_MENU, BUTTON_MENU|BUTTON_REPEAT, BUTTON_NONE }, // { ACTION_STD_QUICKSCREEN, BUTTON_MENU|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_CONTEXT, BUTTON_PLUS|BUTTON_REPEAT, BUTTON_NONE }, - { ACTION_STD_CONTEXT, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE }, - { ACTION_STD_CANCEL, BUTTON_LEFT, BUTTON_NONE }, - { ACTION_STD_CANCEL, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, LAST_ITEM_IN_LIST }; /* button_context_standard */ static const struct button_mapping button_context_wps[] = { - { ACTION_WPS_PLAY, BUTTON_SELECT|BUTTON_REL, BUTTON_SELECT }, - { ACTION_WPS_STOP, BUTTON_SELECT|BUTTON_REPEAT, BUTTON_SELECT }, - { ACTION_WPS_SKIPPREV, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT }, - { ACTION_WPS_SEEKBACK, BUTTON_LEFT|BUTTON_REPEAT, BUTTON_NONE }, - { ACTION_WPS_STOPSEEK, BUTTON_LEFT|BUTTON_REL, BUTTON_LEFT|BUTTON_REPEAT }, - { ACTION_WPS_SKIPNEXT, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT }, - { ACTION_WPS_SEEKFWD, BUTTON_RIGHT|BUTTON_REPEAT, BUTTON_NONE }, - { ACTION_WPS_STOPSEEK, BUTTON_RIGHT|BUTTON_REL, BUTTON_RIGHT|BUTTON_REPEAT }, { ACTION_WPS_VOLDOWN, BUTTON_MINUS, BUTTON_NONE }, { ACTION_WPS_VOLDOWN, BUTTON_MINUS|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_WPS_VOLUP, BUTTON_PLUS, BUTTON_NONE }, { ACTION_WPS_VOLUP, BUTTON_PLUS|BUTTON_REPEAT, BUTTON_NONE }, - - { ACTION_WPS_BROWSE, BUTTON_UP|BUTTON_REL, BUTTON_UP }, - { ACTION_WPS_CONTEXT, BUTTON_UP|BUTTON_REPEAT, BUTTON_UP }, { ACTION_WPS_MENU, BUTTON_MENU|BUTTON_REL, BUTTON_MENU }, - { ACTION_WPS_QUICKSCREEN, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_DOWN }, LAST_ITEM_IN_LIST }; /* button_context_wps */ @@ -99,13 +78,9 @@ static const struct button_mapping button_context_listtree_scroll_without_combo[ }; static const struct button_mapping button_context_settings[] = { - { ACTION_SETTINGS_INC, BUTTON_UP, BUTTON_NONE }, { ACTION_SETTINGS_INC, BUTTON_PLUS, BUTTON_NONE }, - { ACTION_SETTINGS_INCREPEAT, BUTTON_UP|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_SETTINGS_INCREPEAT, BUTTON_PLUS|BUTTON_REPEAT, BUTTON_NONE }, - { ACTION_SETTINGS_DEC, BUTTON_DOWN, BUTTON_NONE }, { ACTION_SETTINGS_DEC, BUTTON_MINUS, BUTTON_NONE }, - { ACTION_SETTINGS_DECREPEAT, BUTTON_DOWN|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_SETTINGS_DECREPEAT, BUTTON_MINUS|BUTTON_REPEAT, BUTTON_NONE }, { ACTION_STD_OK, BUTTON_MENU, BUTTON_NONE }, { ACTION_STD_CANCEL, BUTTON_POWER, BUTTON_NONE }, @@ -154,10 +129,9 @@ static const struct button_mapping button_context_keyboard[] = { //LAST_ITEM_IN_LIST }; /* button_context_keyboard */ -extern int current_tick; -const struct button_mapping* get_context_mapping(int context) +const struct button_mapping* target_get_context_mapping(int context) { - switch (context&(~CONTEXT_REMOTE)) + switch (context) { case CONTEXT_STD: return button_context_standard; diff --git a/apps/keymaps/keymap-mr500.c b/apps/keymaps/keymap-mr500.c index b0d75c15bf..c680929efd 100755 --- a/apps/keymaps/keymap-mr500.c +++ b/apps/keymaps/keymap-mr500.c @@ -17,7 +17,7 @@ * ****************************************************************************/ -/* Button Code Definitions for the toshiba gigabeat target */ +/* Button Code Definitions for the Olympus M:robe 500 target */ #include #include #include @@ -137,8 +137,7 @@ static const struct button_mapping button_context_keyboard[] = { LAST_ITEM_IN_LIST }; /* button_context_keyboard */ -extern int current_tick; -const struct button_mapping* get_context_mapping(int context) +const struct button_mapping* target_get_context_mapping(int context) { switch (context&(~CONTEXT_REMOTE)) { diff --git a/apps/keymaps/keymap-touchpad.c b/apps/keymaps/keymap-touchpad.c new file mode 100644 index 0000000000..48f1103cd3 --- /dev/null +++ b/apps/keymaps/keymap-touchpad.c @@ -0,0 +1,214 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: keymap-mr500.c 16056 2008-01-11 21:48:01Z roolku $ + * + * Copyright (C) 2006 Jonathan Gordon + * + * All files in this archive are subject to the GNU General Public License. + * See the file COPYING in the source tree root for full license agreement. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +/* Button Code Definitions for touchpad targets */ +#include +#include +#include + +#include "config.h" +#include "action.h" +#include "button.h" +#include "settings.h" + +const struct button_mapping* target_get_context_mapping(int context); +/* How this file is used: + get_context_mapping() at the bottom of the file is called by action.c as usual. + if the context is for the remote control its then passed straight to + target_get_context_mapping(). + These tables are only used for the touchpad buttons, so at the end of each + CONTEXT_CUSTOM2 is OR'ed with the context and then sent to target_get_context_mapping() + (NOTE: CONTEXT_CUSTOM2 will be stripped before being sent to make it easier.) + In the target keymap, remember to |CONTEXT_CUSTOM2 in the LAST_ITEM_IN_LIST__NEXTLIST() macro + to speed it up a tiny bit... if you dont it will go through these tables first before going + back to the target file. + */ + + +/* touchpad "buttons" + screen is split into a 3x3 grid for buttons... + BUTTON_TOPLEFT BUTTON_TOPMIDDLE BUTTON_TOPRIGHT + BUTTON_MIDLEFT BUTTON_CENTER BUTTON_MIDRIGHT + BUTTON_BOTTOMLEFT BUTTON_BOTTOMMIDDLE BUTTON_BOTTOMRIGHT +*/ + +static const struct button_mapping button_context_standard[] = { + { ACTION_STD_PREV, BUTTON_TOPMIDDLE, BUTTON_NONE }, + { ACTION_STD_PREVREPEAT, BUTTON_TOPMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_NEXT, BUTTON_BOTTOMMIDDLE, BUTTON_NONE }, + { ACTION_STD_NEXTREPEAT, BUTTON_BOTTOMMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, + + { ACTION_STD_OK, BUTTON_CENTER|BUTTON_REL, BUTTON_CENTER }, + { ACTION_STD_OK, BUTTON_MIDRIGHT|BUTTON_REL, BUTTON_MIDRIGHT }, + { ACTION_STD_OK, BUTTON_MIDRIGHT|BUTTON_REPEAT, BUTTON_MIDRIGHT }, + + { ACTION_STD_MENU, BUTTON_TOPLEFT, BUTTON_NONE }, + { ACTION_STD_QUICKSCREEN, BUTTON_TOPLEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_CONTEXT, BUTTON_CENTER|BUTTON_REPEAT, BUTTON_CENTER }, + { ACTION_STD_CANCEL, BUTTON_MIDLEFT, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_MIDLEFT|BUTTON_REPEAT, BUTTON_NONE }, + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_STD) +}; /* button_context_standard */ + +static const struct button_mapping button_context_wps[] = { + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_WPS) +}; /* button_context_wps */ + +static const struct button_mapping button_context_list[] = { +#if 0 + /* this is all to show how the poor-mans-gestures can be used... */ + { ACTION_LISTTREE_PGUP, BUTTON_TOPRIGHT, BUTTON_NONE}, + { ACTION_LISTTREE_PGUP, BUTTON_TOPRIGHT|BUTTON_REPEAT, BUTTON_TOPRIGHT}, + { ACTION_STD_NEXTREPEAT, BUTTON_CENTER, BUTTON_TOPMIDDLE}, + { ACTION_STD_NEXTREPEAT, BUTTON_BOTTOMMIDDLE, BUTTON_CENTER}, + { ACTION_NONE, BUTTON_TOPMIDDLE, BUTTON_NONE }, + { ACTION_NONE, BUTTON_BOTTOMMIDDLE, BUTTON_NONE }, + { ACTION_STD_PREV, BUTTON_TOPMIDDLE|BUTTON_REL, BUTTON_NONE }, + { ACTION_STD_NEXT, BUTTON_BOTTOMMIDDLE|BUTTON_REL, BUTTON_NONE }, + { ACTION_LISTTREE_PGDOWN, BUTTON_BOTTOMRIGHT, BUTTON_NONE}, + { ACTION_LISTTREE_PGDOWN, BUTTON_BOTTOMRIGHT|BUTTON_REPEAT, BUTTON_BOTTOMRIGHT}, + { ACTION_STD_PREVREPEAT, BUTTON_TOPMIDDLE, BUTTON_CENTER}, + { ACTION_STD_PREVREPEAT, BUTTON_CENTER, BUTTON_BOTTOMMIDDLE}, +#endif + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_LIST) +}; /* button_context_list */ + +static const struct button_mapping button_context_tree[] = { + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_CUSTOM2|CONTEXT_TREE) +}; /* button_context_tree */ + +static const struct button_mapping button_context_listtree_scroll_with_combo[] = { + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_CUSTOM|CONTEXT_TREE), +}; + +static const struct button_mapping button_context_listtree_scroll_without_combo[] = { + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_CUSTOM|CONTEXT_TREE), +}; + +static const struct button_mapping button_context_settings[] = { + { ACTION_SETTINGS_INC, BUTTON_TOPMIDDLE, BUTTON_NONE }, + { ACTION_SETTINGS_INCREPEAT, BUTTON_TOPMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_BOTTOMMIDDLE, BUTTON_NONE }, + { ACTION_SETTINGS_DECREPEAT, BUTTON_BOTTOMMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_OK, BUTTON_CENTER, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_MIDLEFT, BUTTON_NONE }, + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_SETTINGS) +}; /* button_context_settings */ + +static const struct button_mapping button_context_settings_right_is_inc[] = { + { ACTION_STD_PREV, BUTTON_TOPMIDDLE, BUTTON_NONE }, + { ACTION_STD_PREVREPEAT, BUTTON_TOPMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_NEXT, BUTTON_BOTTOMMIDDLE, BUTTON_NONE }, + { ACTION_STD_NEXTREPEAT, BUTTON_BOTTOMMIDDLE|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_INC, BUTTON_MIDRIGHT, BUTTON_NONE }, + { ACTION_SETTINGS_INCREPEAT, BUTTON_MIDRIGHT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_SETTINGS_DEC, BUTTON_MIDLEFT, BUTTON_NONE }, + { ACTION_SETTINGS_DECREPEAT, BUTTON_MIDLEFT|BUTTON_REPEAT, BUTTON_NONE }, + { ACTION_STD_OK, BUTTON_CENTER, BUTTON_NONE }, + { ACTION_STD_CANCEL, BUTTON_TOPLEFT, BUTTON_NONE }, + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_CUSTOM|CONTEXT_SETTINGS) +}; /* button_context_settingsgraphical */ + +static const struct button_mapping button_context_yesno[] = { + { ACTION_YESNO_ACCEPT, BUTTON_MIDLEFT, BUTTON_NONE }, + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_YESNOSCREEN) +}; /* button_context_settings_yesno */ + +static const struct button_mapping button_context_colorchooser[] = { + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_SETTINGS_COLOURCHOOSER), +}; /* button_context_colorchooser */ + +static const struct button_mapping button_context_eq[] = { + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_SETTINGS_EQ), +}; /* button_context_eq */ + +/* Bookmark Screen */ +static const struct button_mapping button_context_bmark[] = { + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_BOOKMARKSCREEN), +}; /* button_context_bmark */ + +static const struct button_mapping button_context_time[] = { + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_SETTINGS_TIME), +}; /* button_context_time */ + +static const struct button_mapping button_context_quickscreen[] = { + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_QUICKSCREEN) +}; /* button_context_quickscreen */ + +static const struct button_mapping button_context_pitchscreen[] = { + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_PITCHSCREEN) +}; /* button_context_pitchcreen */ + +static const struct button_mapping button_context_keyboard[] = { + + LAST_ITEM_IN_LIST__NEXTLIST(CONTEXT_CUSTOM2|CONTEXT_KEYBOARD) +}; /* button_context_keyboard */ + +const struct button_mapping* get_context_mapping(int context) +{ + if ((context&CONTEXT_REMOTE) || (context&CONTEXT_CUSTOM2)) + return target_get_context_mapping(context&(~CONTEXT_CUSTOM2)); + + switch (context) + { + case CONTEXT_STD: + return button_context_standard; + case CONTEXT_WPS: + return button_context_wps; + + case CONTEXT_LIST: + return button_context_list; + case CONTEXT_MAINMENU: + case CONTEXT_TREE: + if (global_settings.hold_lr_for_scroll_in_list) + return button_context_listtree_scroll_without_combo; + else + return button_context_listtree_scroll_with_combo; + case CONTEXT_CUSTOM|CONTEXT_TREE: + return button_context_tree; + + case CONTEXT_SETTINGS: + return button_context_settings; + case CONTEXT_CUSTOM|CONTEXT_SETTINGS: + return button_context_settings_right_is_inc; + + case CONTEXT_SETTINGS_COLOURCHOOSER: + return button_context_colorchooser; + case CONTEXT_SETTINGS_EQ: + return button_context_eq; + + case CONTEXT_SETTINGS_TIME: + return button_context_time; + + case CONTEXT_YESNOSCREEN: + return button_context_yesno; + case CONTEXT_BOOKMARKSCREEN: + return button_context_bmark; + case CONTEXT_QUICKSCREEN: + return button_context_quickscreen; + case CONTEXT_PITCHSCREEN: + return button_context_pitchscreen; + case CONTEXT_KEYBOARD: + return button_context_keyboard; + } + return button_context_standard; +} diff --git a/apps/main.c b/apps/main.c index 3f83850df7..7309d95df2 100644 --- a/apps/main.c +++ b/apps/main.c @@ -132,6 +132,9 @@ static void app_main(void) screens[i].update(); } tree_gui_init(); +#ifdef HAVE_TOUCHPAD + touchpad_set_mode(TOUCHPAD_BUTTON); +#endif root_menu(); } diff --git a/bootloader/mrobe500.c b/bootloader/mrobe500.c index e6dc58118d..5958396188 100755 --- a/bootloader/mrobe500.c +++ b/bootloader/mrobe500.c @@ -117,7 +117,7 @@ void mrdebug(void) printf("%d:%d:%d %d %d %d", t->tm_hour, t->tm_min, t->tm_sec, t->tm_mday, t->tm_mon, t->tm_year); printf("time: %d", mktime(t)); #endif - button = button_get(false); + button = button_get(false); if (button == BUTTON_POWER) { printf("reset"); @@ -143,8 +143,18 @@ void mrdebug(void) // // tsc2100_keyclick(); /* doesnt work :( */ // line -= 6; // } + else if (button == BUTTON_RC_HEART) + { + printf("POINT"); + touchpad_set_mode(TOUCHPAD_POINT); + } + else if (button == BUTTON_RC_MODE) + { + printf("BUTTON"); + touchpad_set_mode(TOUCHPAD_BUTTON); + } #if 1 - if (button&BUTTON_TOUCHPAD) + else if (button&BUTTON_TOUCHPAD) { if (button&BUTTON_REL) continue; @@ -152,11 +162,24 @@ void mrdebug(void) int x = (data&0xffff0000)>>16, y = data&0x0000ffff; reset_screen(); line = 9; - printf("%x %d %d\n", button, x,y); + printf("BB: %x %d %d", button, x,y); lcd_hline(x-5, x+5, y); lcd_vline(x, y-5, y+5); lcd_update(); } + else if (button == BUTTON_RC_PLAY) + { + reset_screen(); + } + + else if (button) + { + // if (button&BUTTON_REL) + { + printf("%08x %s\n", button, (button&BUTTON_REL)?"yes":"no"); + } + } + #endif } } diff --git a/firmware/export/button.h b/firmware/export/button.h index 95da7adc42..6decf6ec69 100644 --- a/firmware/export/button.h +++ b/firmware/export/button.h @@ -64,4 +64,23 @@ int button_apply_acceleration(const unsigned int data); #define BUTTON_REPEAT 0x04000000 #define BUTTON_TOUCHPAD 0x08000000 +#ifdef HAVE_TOUCHPAD +#if !defined(BUTTON_TOPLEFT) || !defined(BUTTON_TOPMIDDLE) \ + || !defined(BUTTON_TOPRIGHT) || !defined(BUTTON_MIDLEFT) \ + || !defined(BUTTON_CENTER) || !defined(BUTTON_MIDRIGHT) \ + || !defined(BUTTON_BOTTOMLEFT) || !defined(BUTTON_BOTTOMMIDDLE) \ + || !defined(BUTTON_BOTTOMRIGHT) +#error Touchpad button mode BUTTON_* defines not set up correctly +#endif +enum touchpad_mode { + TOUCHPAD_POINT = 0, /* touchpad returns pixel co-ords */ + TOUCHPAD_BUTTON, /* touchpad returns BUTTON_* area codes + actual pixel value will still be accessable + from button_get_data */ +}; +/* maybe define the number of buttons in button-target.h ? */ +void touchpad_set_mode(enum touchpad_mode mode); +enum touchpad_mode touchpad_get_mode(void); +#endif + #endif /* _BUTTON_H_ */ diff --git a/firmware/export/config-cowond2.h b/firmware/export/config-cowond2.h index 9380de57ef..d3b23b225d 100644 --- a/firmware/export/config-cowond2.h +++ b/firmware/export/config-cowond2.h @@ -56,6 +56,7 @@ /* define this to indicate your device's keypad */ #define CONFIG_KEYPAD COWOND2_PAD +#define HAVE_TOUCHPAD /* define this if you have a real-time clock */ //#define CONFIG_RTC RTC_TCC780X diff --git a/firmware/target/arm/tcc780x/cowond2/button-target.h b/firmware/target/arm/tcc780x/cowond2/button-target.h index 3ccf70cffd..573ab03a11 100644 --- a/firmware/target/arm/tcc780x/cowond2/button-target.h +++ b/firmware/target/arm/tcc780x/cowond2/button-target.h @@ -35,14 +35,25 @@ int button_read_device(void); #define BUTTON_MINUS 0x00000004 #define BUTTON_MENU 0x00000008 -/* Faked buttons based on touchscreen quadrants (not yet read) */ -#define BUTTON_UP 0x00000020 -#define BUTTON_DOWN 0x00000040 -#define BUTTON_LEFT 0x00000080 -#define BUTTON_RIGHT 0x00000100 -#define BUTTON_SELECT 0x00000200 +/* compatibility hacks + not mapped to the touchpad button areas because + the touchpad is not always in that mode */ +#define BUTTON_LEFT BUTTON_MINUS +#define BUTTON_RIGHT BUTTON_PLUS -#define BUTTON_MAIN 0x3FF +/* Faked buttons based on touchscreen quadrants (not yet read) */ +/* Touchpad Screen Area Buttons */ +#define BUTTON_TOPLEFT 0x00000010 +#define BUTTON_TOPMIDDLE 0x00000020 +#define BUTTON_TOPRIGHT 0x00000040 +#define BUTTON_MIDLEFT 0x00000080 +#define BUTTON_CENTER 0x00000100 +#define BUTTON_MIDRIGHT 0x00000200 +#define BUTTON_BOTTOMLEFT 0x00000400 +#define BUTTON_BOTTOMMIDDLE 0x00000800 +#define BUTTON_BOTTOMRIGHT 0x00001000 + +#define BUTTON_MAIN 0x1FFF /* No remote */ #define BUTTON_REMOTE 0 diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c index 0eb1c07e74..d1fd2eb702 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c +++ b/firmware/target/arm/tms320dm320/mrobe-500/button-mr500.c @@ -40,6 +40,22 @@ static short last_x, last_y, last_z1, last_z2; /* for the touch screen */ static bool touch_available = false; +static enum touchpad_mode current_mode = TOUCHPAD_POINT; +static int touchpad_buttons[3][3] = { + {BUTTON_TOPLEFT, BUTTON_TOPMIDDLE, BUTTON_TOPRIGHT}, + {BUTTON_MIDLEFT, BUTTON_CENTER, BUTTON_MIDRIGHT}, + {BUTTON_BOTTOMLEFT, BUTTON_BOTTOMMIDDLE, BUTTON_BOTTOMRIGHT}, +}; + +void touchpad_set_mode(enum touchpad_mode mode) +{ + current_mode = mode; +} +enum touchpad_mode touchpad_get_mode(void) +{ + return current_mode; +} + static struct touch_calibration_point topleft, bottomright; /* Jd's tests.. These will hopefully work for everyone so we dont have to @@ -165,7 +181,19 @@ int button_read_device(int *data) last_x = x; last_y = y; *data = touch_to_pixels(x, y); - r_button |= BUTTON_TOUCHPAD; + switch (current_mode) + { + case TOUCHPAD_POINT: + r_button |= BUTTON_TOUCHPAD; + break; + case TOUCHPAD_BUTTON: + { + int px_x = ((*data&0xffff0000)>>16), px_y = ((*data&0x0000ffff)); + r_button |= touchpad_buttons[px_y/(LCD_HEIGHT/3)][px_x/(LCD_WIDTH/3)]; + oldbutton = r_button; + break; + } + } } last_touch = current_tick; touch_available = false; @@ -219,6 +247,6 @@ void GIO14(void) read_battery_inputs(); break; } - touch_available = true; + //touch_available = true; IO_INTC_IRQ2 = (1<<3); /* IRQ_GIO14 == 35 */ } diff --git a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h index 1f17f3f3c8..ae23346814 100644 --- a/firmware/target/arm/tms320dm320/mrobe-500/button-target.h +++ b/firmware/target/arm/tms320dm320/mrobe-500/button-target.h @@ -53,14 +53,30 @@ void use_calibration(bool enable); #define BUTTON_TOUCH 0x00000200 -/* compatibility hacks */ +/* Touchpad Screen Area Buttons */ +#define BUTTON_TOPLEFT 0x00004000 +#define BUTTON_TOPMIDDLE 0x00008000 +#define BUTTON_TOPRIGHT 0x00010000 +#define BUTTON_MIDLEFT 0x00020000 +#define BUTTON_CENTER 0x00040000 +#define BUTTON_MIDRIGHT 0x00080000 +#define BUTTON_BOTTOMLEFT 0x00100000 +#define BUTTON_BOTTOMMIDDLE 0x00200000 +#define BUTTON_BOTTOMRIGHT 0x00400000 + +/* compatibility hacks + not mapped to the touchpad button areas because + the touchpad is not always in that mode */ #define BUTTON_LEFT BUTTON_RC_REW #define BUTTON_RIGHT BUTTON_RC_FF #define POWEROFF_BUTTON BUTTON_POWER #define POWEROFF_COUNT 10 -#define BUTTON_MAIN BUTTON_POWER +#define BUTTON_MAIN (BUTTON_POWER| \ + BUTTON_TOPLEFT|BUTTON_TOPMIDDLE|BUTTON_TOPRIGHT \ + BUTTON_MIDLEFT|BUTTON_CENTER|BUTTON_MIDRIGHT \ + BUTTON_BOTTOMLEFT|BUTTON_BOTTOMMIDDLE|BUTTON_BOTTOMRIGHT) #define BUTTON_REMOTE (BUTTON_RC_HEART|BUTTON_RC_MODE| \ BUTTON_RC_VOL_DOWN|BUTTON_RC_VOL_UP| \ diff --git a/uisimulator/sdl/button.c b/uisimulator/sdl/button.c index 15764da900..6672a4164e 100644 --- a/uisimulator/sdl/button.c +++ b/uisimulator/sdl/button.c @@ -32,6 +32,15 @@ static intptr_t button_data; /* data value from last message dequeued */ #ifdef HAVE_TOUCHPAD static int mouse_coords = 0; +static enum touchpad_mode touchpad_mode = TOUCHPAD_POINT; +void touchpad_set_mode(enum touchpad_mode mode) +{ + touchpad_mode = mode; +} +enum touchpad_mode touchpad_get_mode(void) +{ + return touchpad_mode; +} #endif /* how long until repeat kicks in */ #define REPEAT_START 6 @@ -111,9 +120,53 @@ void button_event(int key, bool pressed) #ifdef HAVE_TOUCHPAD case BUTTON_TOUCHPAD: - new_btn = BUTTON_TOUCHPAD; data = mouse_coords; + switch (touchpad_mode) + { + case TOUCHPAD_POINT: + new_btn = BUTTON_TOUCHPAD; + break; + case TOUCHPAD_BUTTON: + { + static int touchpad_buttons[3][3] = { + {BUTTON_TOPLEFT, BUTTON_TOPMIDDLE, BUTTON_TOPRIGHT}, + {BUTTON_MIDLEFT, BUTTON_CENTER, BUTTON_MIDRIGHT}, + {BUTTON_BOTTOMLEFT, BUTTON_BOTTOMMIDDLE, BUTTON_BOTTOMRIGHT}, + }; + int px_x = ((data&0xffff0000)>>16), px_y = ((data&0x0000ffff)); + new_btn = touchpad_buttons[px_y/(LCD_HEIGHT/3)][px_x/(LCD_WIDTH/3)]; + break; + } + } break; + case SDLK_KP7: + new_btn = BUTTON_TOPLEFT; + break; + case SDLK_KP8: + new_btn = BUTTON_TOPMIDDLE; + break; + case SDLK_KP9: + new_btn = BUTTON_TOPRIGHT; + break; + case SDLK_KP4: + new_btn = BUTTON_MIDLEFT; + break; + case SDLK_KP5: + new_btn = BUTTON_CENTER; + break; + case SDLK_KP6: + new_btn = BUTTON_MIDRIGHT; + break; + case SDLK_KP1: + new_btn = BUTTON_BOTTOMLEFT; + break; + case SDLK_KP2: + new_btn = BUTTON_BOTTOMMIDDLE; + break; + case SDLK_KP3: + new_btn = BUTTON_BOTTOMRIGHT; + break; + #endif case SDLK_u: if (!pressed) @@ -665,43 +718,34 @@ void button_event(int key, bool pressed) break; #elif CONFIG_KEYPAD == MROBE500_PAD - case SDLK_KP4: + case SDLK_F9: + new_btn = BUTTON_RC_HEART; + break; + case SDLK_F10: + new_btn = BUTTON_RC_MODE; + break; + case SDLK_F11: + new_btn = BUTTON_RC_VOL_DOWN; + break; + case SDLK_F12: + new_btn = BUTTON_RC_VOL_UP; + break; case SDLK_LEFT: new_btn = BUTTON_LEFT; break; - case SDLK_KP6: case SDLK_RIGHT: new_btn = BUTTON_RIGHT; break; - case SDLK_KP8: case SDLK_UP: new_btn = BUTTON_RC_PLAY; break; - case SDLK_KP2: case SDLK_DOWN: new_btn = BUTTON_RC_DOWN; break; - case SDLK_KP_PLUS: case SDLK_F8: - new_btn = BUTTON_POWER; - break; case SDLK_ESCAPE: new_btn = BUTTON_POWER; break; - case SDLK_KP_ENTER: - case SDLK_RETURN: - case SDLK_a: - new_btn = BUTTON_RC_VOL_UP; - break; - case SDLK_KP5: - case SDLK_SPACE: - new_btn = BUTTON_RC_HEART; - break; - case SDLK_KP_PERIOD: - case SDLK_INSERT: - new_btn = BUTTON_RC_MODE; - break; - #elif CONFIG_KEYPAD == MROBE100_PAD case SDLK_KP1: new_btn = BUTTON_DISPLAY; @@ -739,37 +783,16 @@ void button_event(int key, bool pressed) break; #elif CONFIG_KEYPAD == COWOND2_PAD - case SDLK_KP4: - case SDLK_LEFT: - new_btn = BUTTON_LEFT; - break; - case SDLK_KP6: - case SDLK_RIGHT: - new_btn = BUTTON_RIGHT; - break; - case SDLK_KP8: - case SDLK_UP: - new_btn = BUTTON_UP; - break; - case SDLK_KP2: - case SDLK_DOWN: - new_btn = BUTTON_DOWN; - break; - case SDLK_KP3: + case SDLK_ESCAPE: new_btn = BUTTON_POWER; break; - case SDLK_KP5: - case SDLK_KP_ENTER: - case SDLK_RETURN: - new_btn = BUTTON_SELECT; - break; case SDLK_KP_PLUS: new_btn = BUTTON_PLUS; break; case SDLK_KP_MINUS: new_btn = BUTTON_MINUS; break; - case SDLK_KP9: + case SDLK_KP_ENTER: new_btn = BUTTON_MENU; break; #else @@ -977,11 +1000,6 @@ void mouse_tick_task(void) if (debug_wps) printf("Mouse at: (%d, %d)\n", x, y); } - else if (lastbtn == BUTTON_TOUCHPAD) - { - button_event(BUTTON_TOUCHPAD, false); - mouse_coords = 0; - } } #endif void button_init(void) diff --git a/uisimulator/sdl/uisdl.c b/uisimulator/sdl/uisdl.c index 09210926b5..28aaf59f82 100644 --- a/uisimulator/sdl/uisdl.c +++ b/uisimulator/sdl/uisdl.c @@ -83,6 +83,12 @@ void gui_message_loop(void) printf("Mouse at: (%d, %d)\n", event.button.x, event.button.y); } break; +#else + case SDL_MOUSEBUTTONUP: + sim_enter_irq_handler(); + button_event(BUTTON_TOUCHPAD, false); + sim_exit_irq_handler(); + break; #endif case SDL_QUIT: done = true;