diff options
Diffstat (limited to 'apps/plugins/brickmania.c')
-rw-r--r-- | apps/plugins/brickmania.c | 123 |
1 files changed, 90 insertions, 33 deletions
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c index 756b4de0ec..f3ccaad783 100644 --- a/apps/plugins/brickmania.c +++ b/apps/plugins/brickmania.c | |||
@@ -446,6 +446,20 @@ enum menu_items { | |||
446 | #endif | 446 | #endif |
447 | 447 | ||
448 | 448 | ||
449 | #ifdef HAVE_TOUCHPAD | ||
450 | #include "lib/touchscreen.h" | ||
451 | |||
452 | static struct ts_mapping main_menu_items[4] = | ||
453 | { | ||
454 | {MENU_ITEMXOFS, BMPYOFS_start, MENU_ITEMWIDTH, MENU_ITEMHEIGHT}, | ||
455 | {MENU_ITEMXOFS, BMPYOFS_resume, MENU_ITEMWIDTH, MENU_ITEMHEIGHT}, | ||
456 | {MENU_ITEMXOFS, BMPYOFS_help, MENU_ITEMWIDTH, MENU_ITEMHEIGHT}, | ||
457 | {MENU_ITEMXOFS, BMPYOFS_quit, MENU_ITEMWIDTH, MENU_ITEMHEIGHT} | ||
458 | }; | ||
459 | static struct ts_mappings main_menu = {main_menu_items, 4}; | ||
460 | #endif | ||
461 | |||
462 | |||
449 | int levels_num = 29; | 463 | int levels_num = 29; |
450 | 464 | ||
451 | static unsigned char levels[29][8][10] = { | 465 | static unsigned char levels[29][8][10] = { |
@@ -1008,6 +1022,18 @@ int game_menu(int when) | |||
1008 | rb->lcd_update(); | 1022 | rb->lcd_update(); |
1009 | 1023 | ||
1010 | button = rb->button_get(true); | 1024 | button = rb->button_get(true); |
1025 | #ifdef HAVE_TOUCHPAD | ||
1026 | if(button & BUTTON_TOUCHPAD) | ||
1027 | { | ||
1028 | unsigned int result = touchscreen_map(&main_menu, rb->button_get_data() >> 16, rb->button_get_data() & 0xffff); | ||
1029 | if(result != (unsigned)-1 && button & BUTTON_REL) | ||
1030 | { | ||
1031 | if(cur == (signed)result) | ||
1032 | button = SELECT; | ||
1033 | cur = result; | ||
1034 | } | ||
1035 | } | ||
1036 | #endif | ||
1011 | switch(button) { | 1037 | switch(button) { |
1012 | case UP: | 1038 | case UP: |
1013 | case UP | BUTTON_REPEAT: | 1039 | case UP | BUTTON_REPEAT: |
@@ -1148,6 +1174,9 @@ int help(int when) | |||
1148 | #ifdef RC_QUIT | 1174 | #ifdef RC_QUIT |
1149 | case RC_QUIT: | 1175 | case RC_QUIT: |
1150 | #endif | 1176 | #endif |
1177 | #ifdef HAVE_TOUCHPAD | ||
1178 | case BUTTON_TOUCHPAD: | ||
1179 | #endif | ||
1151 | case QUIT: | 1180 | case QUIT: |
1152 | switch (game_menu(when)) { | 1181 | switch (game_menu(when)) { |
1153 | case 0: | 1182 | case 0: |
@@ -1840,46 +1869,74 @@ int game_loop(void) | |||
1840 | button = QUIT; | 1869 | button = QUIT; |
1841 | #endif | 1870 | #endif |
1842 | 1871 | ||
1843 | move_button=rb->button_status(); | 1872 | #ifdef HAVE_TOUCHPAD |
1844 | #ifdef ALTRIGHT | 1873 | if(button & BUTTON_TOUCHPAD) |
1845 | button_right=((move_button & RIGHT) || (move_button & ALTRIGHT)); | 1874 | { |
1846 | button_left=((move_button & LEFT) || (move_button & ALTLEFT)); | 1875 | short touch_x, touch_y; |
1847 | #else | 1876 | touch_x = rb->button_get_data() >> 16; |
1848 | button_right=((move_button & RIGHT) || (SCROLL_FWD(button))); | 1877 | touch_y = rb->button_get_data() & 0xffff; |
1849 | button_left=((move_button & LEFT) || (SCROLL_BACK(button))); | 1878 | if(touch_y >= PAD_POS_Y && touch_y <= PAD_POS_Y+PAD_HEIGHT) |
1850 | #endif | 1879 | { |
1851 | if ((con_game== 1 && start_game!=1) && (button_right || button_left)) | 1880 | pad_pos_x += (flip_sides ? -1 : 1) * ( (touch_x-pad_pos_x-PAD_WIDTH/2) / 4 ); |
1852 | continue; | 1881 | |
1853 | if ((button_right && flip_sides==false) || | 1882 | if(pad_pos_x < 0) |
1854 | (button_left && flip_sides==true)) { | 1883 | pad_pos_x = 0; |
1855 | if (pad_pos_x+8+PAD_WIDTH > LCD_WIDTH) { | 1884 | else if(pad_pos_x+PAD_WIDTH > LCD_WIDTH) |
1856 | for(k=0;k<used_balls;k++) | 1885 | pad_pos_x = LCD_WIDTH-PAD_WIDTH; |
1857 | if (start_game==1 || ball[k].glue) | ||
1858 | ball[k].pos_x+=LCD_WIDTH-pad_pos_x-PAD_WIDTH; | ||
1859 | pad_pos_x+=LCD_WIDTH-pad_pos_x-PAD_WIDTH; | ||
1860 | } | ||
1861 | else { | ||
1862 | for(k=0;k<used_balls;k++) | 1886 | for(k=0;k<used_balls;k++) |
1863 | if ((start_game==1 || ball[k].glue)) | 1887 | if ((start_game==1 || ball[k].glue)) |
1864 | ball[k].pos_x+=8; | 1888 | ball[k].pos_x = pad_pos_x+PAD_WIDTH/2; |
1865 | pad_pos_x+=8; | ||
1866 | } | 1889 | } |
1890 | |||
1891 | if(button & BUTTON_REL) | ||
1892 | button = SELECT; | ||
1867 | } | 1893 | } |
1868 | else if ((button_left && flip_sides==false) || | 1894 | else |
1869 | (button_right && flip_sides==true)) { | 1895 | { |
1870 | if (pad_pos_x-8 < 0) { | 1896 | #endif |
1871 | for(k=0;k<used_balls;k++) | 1897 | move_button=rb->button_status(); |
1872 | if (start_game==1 || ball[k].glue) | 1898 | #ifdef ALTRIGHT |
1873 | ball[k].pos_x-=pad_pos_x; | 1899 | button_right=((move_button & RIGHT) || (move_button & ALTRIGHT)); |
1874 | pad_pos_x-=pad_pos_x; | 1900 | button_left=((move_button & LEFT) || (move_button & ALTLEFT)); |
1901 | #else | ||
1902 | button_right=((move_button & RIGHT) || (SCROLL_FWD(button))); | ||
1903 | button_left=((move_button & LEFT) || (SCROLL_BACK(button))); | ||
1904 | #endif | ||
1905 | if ((con_game== 1 && start_game!=1) && (button_right || button_left)) | ||
1906 | continue; | ||
1907 | if ((button_right && flip_sides==false) || | ||
1908 | (button_left && flip_sides==true)) { | ||
1909 | if (pad_pos_x+8+PAD_WIDTH > LCD_WIDTH) { | ||
1910 | for(k=0;k<used_balls;k++) | ||
1911 | if (start_game==1 || ball[k].glue) | ||
1912 | ball[k].pos_x+=LCD_WIDTH-pad_pos_x-PAD_WIDTH; | ||
1913 | pad_pos_x+=LCD_WIDTH-pad_pos_x-PAD_WIDTH; | ||
1914 | } | ||
1915 | else { | ||
1916 | for(k=0;k<used_balls;k++) | ||
1917 | if ((start_game==1 || ball[k].glue)) | ||
1918 | ball[k].pos_x+=8; | ||
1919 | pad_pos_x+=8; | ||
1920 | } | ||
1875 | } | 1921 | } |
1876 | else { | 1922 | else if ((button_left && flip_sides==false) || |
1877 | for(k=0;k<used_balls;k++) | 1923 | (button_right && flip_sides==true)) { |
1878 | if (start_game==1 || ball[k].glue) | 1924 | if (pad_pos_x-8 < 0) { |
1879 | ball[k].pos_x-=8; | 1925 | for(k=0;k<used_balls;k++) |
1880 | pad_pos_x-=8; | 1926 | if (start_game==1 || ball[k].glue) |
1927 | ball[k].pos_x-=pad_pos_x; | ||
1928 | pad_pos_x-=pad_pos_x; | ||
1929 | } | ||
1930 | else { | ||
1931 | for(k=0;k<used_balls;k++) | ||
1932 | if (start_game==1 || ball[k].glue) | ||
1933 | ball[k].pos_x-=8; | ||
1934 | pad_pos_x-=8; | ||
1935 | } | ||
1881 | } | 1936 | } |
1937 | #ifdef HAVE_TOUCHPAD | ||
1882 | } | 1938 | } |
1939 | #endif | ||
1883 | 1940 | ||
1884 | 1941 | ||
1885 | switch(button) { | 1942 | switch(button) { |