First commit to prepare menu support for touch-based Android input:

Preparation to convert start menus from mouse move input (which does not work
at all with touch screen devices) to touch input:

New function select_menuitem_by_touch(), to be used in the next commits:
- modified:   project/jni/application/opentyrian/src/menus.cpp
- modified:   project/jni/application/opentyrian/src/menus.h

Inside #ifdef ANDROID: Disable mouse move input handling in JE_textMenuWait()
- modified:   project/jni/application/opentyrian/src/setup.cpp
This commit is contained in:
Bernhard Kaindl
2012-08-07 10:17:51 +02:00
parent 32c1bead12
commit 2cd039e9fd
3 changed files with 29 additions and 0 deletions

View File

@@ -31,6 +31,26 @@
char episode_name[6][31], difficulty_name[7][21], gameplay_name[5][26];
bool
select_menuitem_by_touch(JE_byte menu_top, JE_byte menu_spacing, JE_shortint menu_item_count, JE_shortint *current_item)
{
if (!mousedown)
return false;
char new_item = (mouse_y - menu_top) / menu_spacing;
if (mouse_y >= menu_top && mouse_y < menu_top + (menu_item_count+1) * menu_spacing)
{
if (new_item == *current_item)
return false;
JE_playSampleNum(S_CURSOR);
*current_item = new_item;
}
return true;
}
bool select_gameplay( void )
{
JE_loadPic(VGAScreen, 2, false);

View File

@@ -26,6 +26,7 @@ extern char episode_name[6][31], difficulty_name[7][21], gameplay_name[5][26];
bool select_gameplay( void );
bool select_episode( void );
bool select_difficulty( void );
bool select_menuitem_by_touch(JE_byte menu_top, JE_byte menu_spacing, JE_shortint menu_item_count, JE_shortint *current_item);
#endif /* MENUS_H */

View File

@@ -31,7 +31,9 @@
void JE_textMenuWait( JE_word *waitTime, JE_boolean doGamma )
{
#ifdef MENU_SELECT_BY_MOUSE_MOVE
set_mouse_position(160, 100);
#endif
do
{
@@ -58,6 +60,11 @@ void JE_textMenuWait( JE_word *waitTime, JE_boolean doGamma )
if (has_mouse && input_grabbed)
{
#ifdef MENU_SELECT_BY_MOUSE_MOVE
/* Whacky hack which changes menu selecton based on
* relative mouse movement does not work with touch
* when a touch tiggers a mousedown which gets mapped
* to SDLK_RETURN above */
if (abs(mouse_y - 100) > 10)
{
inputDetected = true;
@@ -80,6 +87,7 @@ void JE_textMenuWait( JE_word *waitTime, JE_boolean doGamma )
}
newkey = true;
}
#endif
}
NETWORK_KEEP_ALIVE();