summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <me@fwei.tk>2017-07-26 23:28:50 -0400
committerFranklin Wei <git@fwei.tk>2017-07-27 19:09:50 -0400
commit076cf0aa9bc484e9dbaee17660c2e77c16f46b13 (patch)
treec81d30d4d790eb36486a57f2bcaed8e486487d37
parentf1b82b1acf9ffe79b5e44d0385cc1096f05b1a61 (diff)
downloadrockbox-076cf0aa9bc484e9dbaee17660c2e77c16f46b13.tar.gz
rockbox-076cf0aa9bc484e9dbaee17660c2e77c16f46b13.zip
puzzles: new input scheme for Mines and Magnets
Both these puzzles now have long press mapped to spacebar.
-rw-r--r--apps/plugins/puzzles/rockbox.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/apps/plugins/puzzles/rockbox.c b/apps/plugins/puzzles/rockbox.c
index 2f07b392a9..511c1eef86 100644
--- a/apps/plugins/puzzles/rockbox.c
+++ b/apps/plugins/puzzles/rockbox.c
@@ -1641,6 +1641,15 @@ static int process_input(int tmo)
1641 /* weird stuff */ 1641 /* weird stuff */
1642 exit_on_usb(button); 1642 exit_on_usb(button);
1643 1643
1644 /* these games require a second input on long-press */
1645 if(accept_input && (button == (BTN_FIRE | BUTTON_REPEAT)) &&
1646 (strcmp("Mines", midend_which_game(me)->name) != 0 ||
1647 strcmp("Magnets", midend_which_game(me)->name) != 0))
1648 {
1649 accept_input = false;
1650 return ' ';
1651 }
1652
1644 button = rb->button_status(); 1653 button = rb->button_status();
1645 1654
1646#ifdef HAVE_ADJUSTABLE_CPU_FREQ 1655#ifdef HAVE_ADJUSTABLE_CPU_FREQ
@@ -1666,12 +1675,17 @@ static int process_input(int tmo)
1666 return rc; 1675 return rc;
1667 } 1676 }
1668 1677
1669 /* special case for inertia: moves occur after RELEASES */ 1678 /* these three games require, for one reason or another, that
1670 if(!strcmp("Inertia", midend_which_game(me)->name)) 1679 * events fire upon buttons being released rather than when they
1680 * are pressed */
1681 if(strcmp("Inertia", midend_which_game(me)->name) == 0 ||
1682 strcmp("Mines", midend_which_game(me)->name) == 0 ||
1683 strcmp("Magnets", midend_which_game(me)->name) == 0 )
1671 { 1684 {
1672 LOGF("received button 0x%08x", button); 1685 LOGF("received button 0x%08x", button);
1673 1686
1674 unsigned released = ~button & last_keystate; 1687 unsigned released = ~button & last_keystate;
1688
1675 last_keystate = button; 1689 last_keystate = button;
1676 1690
1677 if(!button) 1691 if(!button)
@@ -1691,16 +1705,17 @@ static int process_input(int tmo)
1691 return 0; 1705 return 0;
1692 } 1706 }
1693 1707
1694 button |= released; 1708 if(button)
1695 if(last_keystate)
1696 { 1709 {
1697 LOGF("ignoring input from now until all released"); 1710 LOGF("ignoring input from now until all released");
1698 accept_input = false; 1711 accept_input = false;
1699 } 1712 }
1713
1714 button |= released;
1700 LOGF("accepting event 0x%08x", button); 1715 LOGF("accepting event 0x%08x", button);
1701 } 1716 }
1702 /* default is to ignore repeats except for untangle */ 1717 /* default is to ignore repeats except for untangle */
1703 else if(strcmp("Untangle", midend_which_game(me)->name)) 1718 else if(strcmp("Untangle", midend_which_game(me)->name) != 0)
1704 { 1719 {
1705 /* start accepting input again after a release */ 1720 /* start accepting input again after a release */
1706 if(!button) 1721 if(!button)