Skip to content

Commit

Permalink
Disable key repeat for rotate: this is bad for gaming UX
Browse files Browse the repository at this point in the history
  • Loading branch information
ryukinix committed Mar 10, 2019
1 parent 69022fb commit 34c750d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,13 @@ Block const BLOCK_EMPTY = {
BLOCK_I };
*/
inline void disable_interrupt() { INTCONbits.GIE = 0; }
inline void disable_interrupt() {
INTCONbits.GIE = 0;
}

inline void enable_interrupt() { INTCONbits.GIE = 1; }
inline void enable_interrupt() {
INTCONbits.GIE = 1;
}

void set_display(byte value) {
TMR2IE = 0;
Expand Down Expand Up @@ -412,6 +416,11 @@ void kbd_manager(void) {

byte aux = PORTB & 0x07;

// this avoid key rotate repeat, whic is a undesired behavior
if ((aux == KEY_ROTATE) && (aux == key)) {
return;
}

if (aux == key_ant) {
if (++key_tmr1 > DELAY_KEY_DEBOUNCE) {
key_tmr1 = DELAY_KEY_DEBOUNCE;
Expand All @@ -437,8 +446,9 @@ void kbd_manager(void) {
} else if (++key_tmr2 > DELAY_KEY_REPEAT) {
key_tmr2 = 0;
key_cmd = key;
} else
} else {
key_cmd = KEY_NONE;
}

switch (key_cmd) {
case KEY_LEFT:
Expand All @@ -454,7 +464,6 @@ void kbd_manager(void) {
break;

case KEY_ROTATE:

if (!(collision_state & (COLLISION_LEFT | COLLISION_RIGHT))) {
rotate_player();
}
Expand Down

0 comments on commit 34c750d

Please sign in to comment.