summaryrefslogtreecommitdiff
path: root/apps/plugins/sudoku
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/sudoku')
-rw-r--r--apps/plugins/sudoku/sudoku.c53
-rw-r--r--apps/plugins/sudoku/sudoku.h2
2 files changed, 42 insertions, 13 deletions
diff --git a/apps/plugins/sudoku/sudoku.c b/apps/plugins/sudoku/sudoku.c
index 4430778cac..5e34fd404b 100644
--- a/apps/plugins/sudoku/sudoku.c
+++ b/apps/plugins/sudoku/sudoku.c
@@ -211,6 +211,12 @@ static const char default_game[9][9] =
211 211
212#endif /* Layout */ 212#endif /* Layout */
213 213
214#ifdef SUDOKU_BUTTON_CHANGEDIR
215int invertdir=0;
216#else
217#define invertdir 0
218#endif
219
214#define CFGFILE_VERSION 0 /* Current config file version */ 220#define CFGFILE_VERSION 0 /* Current config file version */
215#define CFGFILE_MINVERSION 0 /* Minimum config file version to accept */ 221#define CFGFILE_MINVERSION 0 /* Minimum config file version to accept */
216 222
@@ -1450,36 +1456,52 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame
1450 /* move cursor left */ 1456 /* move cursor left */
1451 case SUDOKU_BUTTON_LEFT: 1457 case SUDOKU_BUTTON_LEFT:
1452 case (SUDOKU_BUTTON_LEFT | BUTTON_REPEAT): 1458 case (SUDOKU_BUTTON_LEFT | BUTTON_REPEAT):
1453 if (state.x==0) { 1459 if ( (state.x==0&&invertdir==0) || (state.y==0&&invertdir==1) ) {
1454#ifndef SUDOKU_BUTTON_UP 1460#ifndef SUDOKU_BUTTON_UP
1455 if (state.y==0) { 1461 if ( (state.y==0&&invertdir==0) || (state.x==0&&invertdir==1)) {
1456 move_cursor(&state,8,8); 1462 move_cursor(&state,8,8);
1457 } else { 1463 } else {
1458 move_cursor(&state,8,state.y-1); 1464 if (invertdir==0) {
1465 move_cursor(&state,8,state.y-1);
1466 } else {
1467 move_cursor(&state,state.x-1,8);
1468 }
1459 } 1469 }
1460#else 1470#else
1461 move_cursor(&state,8,state.y); 1471 move_cursor(&state,8,state.y);
1462#endif 1472#endif
1463 } else { 1473 } else {
1464 move_cursor(&state,state.x-1,state.y); 1474 if (invertdir==0) {
1475 move_cursor(&state,state.x-1,state.y);
1476 } else {
1477 move_cursor(&state,state.x,state.y-1);
1478 }
1465 } 1479 }
1466 break; 1480 break;
1467 1481
1468 /* move cursor right */ 1482 /* move cursor right */
1469 case SUDOKU_BUTTON_RIGHT: 1483 case SUDOKU_BUTTON_RIGHT:
1470 case (SUDOKU_BUTTON_RIGHT | BUTTON_REPEAT): 1484 case (SUDOKU_BUTTON_RIGHT | BUTTON_REPEAT):
1471 if (state.x==8) { 1485 if ( (state.x==8&&invertdir==0) || (state.y==8&&invertdir==1) ) {
1472#ifndef SUDOKU_BUTTON_DOWN 1486#ifndef SUDOKU_BUTTON_DOWN
1473 if (state.y==8) { 1487 if ( (state.y==8&&invertdir==0) || (state.x==8&&invertdir==1) ) {
1474 move_cursor(&state,0,0); 1488 move_cursor(&state,0,0);
1475 } else { 1489 } else {
1476 move_cursor(&state,0,state.y+1); 1490 if (invertdir==0) {
1491 move_cursor(&state,0,state.y+1);
1492 } else {
1493 move_cursor(&state,state.x+1,0);
1494 }
1477 } 1495 }
1478#else 1496#else
1479 move_cursor(&state,0,state.y); 1497 move_cursor(&state,0,state.y);
1480#endif 1498#endif
1481 } else { 1499 } else {
1482 move_cursor(&state,state.x+1,state.y); 1500 if (invertdir==0) {
1501 move_cursor(&state,state.x+1,state.y);
1502 } else {
1503 move_cursor(&state,state.x,state.y+1);
1504 }
1483 } 1505 }
1484 break; 1506 break;
1485 1507
@@ -1543,6 +1565,13 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame
1543 } 1565 }
1544 break; 1566 break;
1545#endif 1567#endif
1568
1569#ifdef SUDOKU_BUTTON_CHANGEDIR
1570 case SUDOKU_BUTTON_CHANGEDIR:
1571 /* Change scroll wheel direction */
1572 invertdir=!invertdir;
1573 break;
1574#endif
1546 default: 1575 default:
1547 if (rb->default_event_handler(button) == SYS_USB_CONNECTED) { 1576 if (rb->default_event_handler(button) == SYS_USB_CONNECTED) {
1548 /* Quit if USB has been connected */ 1577 /* Quit if USB has been connected */
diff --git a/apps/plugins/sudoku/sudoku.h b/apps/plugins/sudoku/sudoku.h
index 75230dde60..b4f18b6341 100644
--- a/apps/plugins/sudoku/sudoku.h
+++ b/apps/plugins/sudoku/sudoku.h
@@ -78,7 +78,7 @@
78#define SUDOKU_BUTTON_MENU BUTTON_MENU 78#define SUDOKU_BUTTON_MENU BUTTON_MENU
79#define SUDOKU_BUTTON_LEFT BUTTON_SCROLL_BACK 79#define SUDOKU_BUTTON_LEFT BUTTON_SCROLL_BACK
80#define SUDOKU_BUTTON_RIGHT BUTTON_SCROLL_FWD 80#define SUDOKU_BUTTON_RIGHT BUTTON_SCROLL_FWD
81#define SUDOKU_BUTTON_ALTTOGGLE BUTTON_SELECT 81#define SUDOKU_BUTTON_CHANGEDIR BUTTON_SELECT
82#define SUDOKU_BUTTON_TOGGLE BUTTON_RIGHT 82#define SUDOKU_BUTTON_TOGGLE BUTTON_RIGHT
83#define SUDOKU_BUTTON_TOGGLEBACK BUTTON_LEFT 83#define SUDOKU_BUTTON_TOGGLEBACK BUTTON_LEFT
84#define SUDOKU_BUTTON_POSSIBLE BUTTON_PLAY 84#define SUDOKU_BUTTON_POSSIBLE BUTTON_PLAY