diff options
Diffstat (limited to 'apps/plugins/jpeg.c')
-rw-r--r-- | apps/plugins/jpeg.c | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/apps/plugins/jpeg.c b/apps/plugins/jpeg.c index 4e47d9faf2..7d8fab7456 100644 --- a/apps/plugins/jpeg.c +++ b/apps/plugins/jpeg.c | |||
@@ -29,6 +29,16 @@ | |||
29 | #ifdef HAVE_LCD_BITMAP /* and also not for the Player */ | 29 | #ifdef HAVE_LCD_BITMAP /* and also not for the Player */ |
30 | #include "gray.h" | 30 | #include "gray.h" |
31 | 31 | ||
32 | /* variable button definitions */ | ||
33 | #if CONFIG_KEYPAD == RECORDER_PAD | ||
34 | #define JPEG_ZOOM_IN BUTTON_PLAY | ||
35 | #define JPEG_ZOOM_OUT BUTTON_ON | ||
36 | #elif CONFIG_KEYPAD == ONDIO_PAD | ||
37 | #define JPEG_ZOOM_PRE BUTTON_MENU | ||
38 | #define JPEG_ZOOM_IN (BUTTON_MENU | BUTTON_REL) | ||
39 | #define JPEG_ZOOM_OUT (BUTTON_MENU | BUTTON_REPEAT) | ||
40 | #endif | ||
41 | |||
32 | /******************************* Globals ***********************************/ | 42 | /******************************* Globals ***********************************/ |
33 | 43 | ||
34 | static struct plugin_api* rb; | 44 | static struct plugin_api* rb; |
@@ -1494,9 +1504,19 @@ int root_size; | |||
1494 | #define ZOOM_IN 100 // return codes for below function | 1504 | #define ZOOM_IN 100 // return codes for below function |
1495 | #define ZOOM_OUT 101 | 1505 | #define ZOOM_OUT 101 |
1496 | 1506 | ||
1507 | /* switch off overlay, for handling SYS_ events */ | ||
1508 | void cleanup(void *parameter) | ||
1509 | { | ||
1510 | (void)parameter; | ||
1511 | |||
1512 | gray_show_display(false); | ||
1513 | } | ||
1514 | |||
1497 | /* interactively scroll around the image */ | 1515 | /* interactively scroll around the image */ |
1498 | int scroll_bmp(struct t_disp* pdisp) | 1516 | int scroll_bmp(struct t_disp* pdisp) |
1499 | { | 1517 | { |
1518 | int lastbutton = 0; | ||
1519 | |||
1500 | /*empty the button queue first, to avoid unwanted scrolling */ | 1520 | /*empty the button queue first, to avoid unwanted scrolling */ |
1501 | while(rb->button_get(false) != BUTTON_NONE); | 1521 | while(rb->button_get(false) != BUTTON_NONE); |
1502 | 1522 | ||
@@ -1506,13 +1526,15 @@ int scroll_bmp(struct t_disp* pdisp) | |||
1506 | int move; | 1526 | int move; |
1507 | 1527 | ||
1508 | button = rb->button_get(true); | 1528 | button = rb->button_get(true); |
1509 | 1529 | ||
1510 | if (button == SYS_USB_CONNECTED) | 1530 | if (rb->default_event_handler_ex(button, cleanup, NULL) |
1531 | == SYS_USB_CONNECTED) | ||
1511 | return PLUGIN_USB_CONNECTED; | 1532 | return PLUGIN_USB_CONNECTED; |
1512 | 1533 | ||
1513 | switch(button & ~(BUTTON_REPEAT)) | 1534 | switch(button) |
1514 | { | 1535 | { |
1515 | case BUTTON_LEFT: | 1536 | case BUTTON_LEFT: |
1537 | case BUTTON_LEFT | BUTTON_REPEAT: | ||
1516 | move = MIN(10, pdisp->x); | 1538 | move = MIN(10, pdisp->x); |
1517 | if (move > 0) | 1539 | if (move > 0) |
1518 | { | 1540 | { |
@@ -1527,6 +1549,7 @@ int scroll_bmp(struct t_disp* pdisp) | |||
1527 | break; | 1549 | break; |
1528 | 1550 | ||
1529 | case BUTTON_RIGHT: | 1551 | case BUTTON_RIGHT: |
1552 | case BUTTON_RIGHT | BUTTON_REPEAT: | ||
1530 | move = MIN(10, pdisp->width - pdisp->x - LCD_WIDTH); | 1553 | move = MIN(10, pdisp->width - pdisp->x - LCD_WIDTH); |
1531 | if (move > 0) | 1554 | if (move > 0) |
1532 | { | 1555 | { |
@@ -1541,6 +1564,7 @@ int scroll_bmp(struct t_disp* pdisp) | |||
1541 | break; | 1564 | break; |
1542 | 1565 | ||
1543 | case BUTTON_UP: | 1566 | case BUTTON_UP: |
1567 | case BUTTON_UP | BUTTON_REPEAT: | ||
1544 | move = MIN(8, pdisp->y); | 1568 | move = MIN(8, pdisp->y); |
1545 | if (move > 0) | 1569 | if (move > 0) |
1546 | { | 1570 | { |
@@ -1558,6 +1582,7 @@ int scroll_bmp(struct t_disp* pdisp) | |||
1558 | break; | 1582 | break; |
1559 | 1583 | ||
1560 | case BUTTON_DOWN: | 1584 | case BUTTON_DOWN: |
1585 | case BUTTON_DOWN | BUTTON_REPEAT: | ||
1561 | move = MIN(8, pdisp->height - pdisp->y - LCD_HEIGHT); | 1586 | move = MIN(8, pdisp->height - pdisp->y - LCD_HEIGHT); |
1562 | if (move > 0) | 1587 | if (move > 0) |
1563 | { | 1588 | { |
@@ -1574,17 +1599,28 @@ int scroll_bmp(struct t_disp* pdisp) | |||
1574 | } | 1599 | } |
1575 | break; | 1600 | break; |
1576 | 1601 | ||
1577 | case BUTTON_PLAY: | 1602 | case JPEG_ZOOM_IN: |
1603 | #ifdef JPEG_ZOOM_PRE | ||
1604 | if (lastbutton != JPEG_ZOOM_PRE) | ||
1605 | break; | ||
1606 | #endif | ||
1578 | return ZOOM_IN; | 1607 | return ZOOM_IN; |
1579 | break; | 1608 | break; |
1580 | 1609 | ||
1581 | case BUTTON_ON: | 1610 | case JPEG_ZOOM_OUT: |
1611 | #ifdef JPEG_ZOOM_PRE | ||
1612 | if (lastbutton != JPEG_ZOOM_PRE) | ||
1613 | break; | ||
1614 | #endif | ||
1582 | return ZOOM_OUT; | 1615 | return ZOOM_OUT; |
1583 | break; | 1616 | break; |
1584 | 1617 | ||
1585 | case BUTTON_OFF: | 1618 | case BUTTON_OFF: |
1586 | return PLUGIN_OK; | 1619 | return PLUGIN_OK; |
1587 | } /* switch */ | 1620 | } /* switch */ |
1621 | |||
1622 | if (button != BUTTON_NONE) | ||
1623 | lastbutton = button; | ||
1588 | } /* while (true) */ | 1624 | } /* while (true) */ |
1589 | } | 1625 | } |
1590 | 1626 | ||
@@ -1913,7 +1949,6 @@ int main(char* filename) | |||
1913 | 1949 | ||
1914 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | 1950 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) |
1915 | { | 1951 | { |
1916 | int ret; | ||
1917 | /* this macro should be called as the first thing you do in the plugin. | 1952 | /* this macro should be called as the first thing you do in the plugin. |
1918 | it test that the api version and model the plugin was compiled for | 1953 | it test that the api version and model the plugin was compiled for |
1919 | matches the machine it is running on */ | 1954 | matches the machine it is running on */ |
@@ -1923,11 +1958,8 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
1923 | 1958 | ||
1924 | /* This plugin uses the grayscale framework, so initialize */ | 1959 | /* This plugin uses the grayscale framework, so initialize */ |
1925 | gray_init(api); | 1960 | gray_init(api); |
1926 | ret = main((char*)parameter); | ||
1927 | 1961 | ||
1928 | if (ret == PLUGIN_USB_CONNECTED) | 1962 | return main((char*)parameter); |
1929 | rb->usb_screen(); | ||
1930 | return ret; | ||
1931 | } | 1963 | } |
1932 | 1964 | ||
1933 | #endif /* #ifdef HAVE_LCD_BITMAP */ | 1965 | #endif /* #ifdef HAVE_LCD_BITMAP */ |