diff --git a/project/jni/application/opentyrian/src/menus.cpp b/project/jni/application/opentyrian/src/menus.cpp index 0108900c7..cf2c64c88 100644 --- a/project/jni/application/opentyrian/src/menus.cpp +++ b/project/jni/application/opentyrian/src/menus.cpp @@ -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); diff --git a/project/jni/application/opentyrian/src/menus.h b/project/jni/application/opentyrian/src/menus.h index f0e747c54..c36427ca5 100644 --- a/project/jni/application/opentyrian/src/menus.h +++ b/project/jni/application/opentyrian/src/menus.h @@ -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 */ diff --git a/project/jni/application/opentyrian/src/setup.cpp b/project/jni/application/opentyrian/src/setup.cpp index 40450cb42..d5fc0936d 100644 --- a/project/jni/application/opentyrian/src/setup.cpp +++ b/project/jni/application/opentyrian/src/setup.cpp @@ -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();