27 lines
756 B
C
Raw Normal View History

#include "hid.h"
2016-05-30 01:54:09 +02:00
#include "timer.h"
u32 InputWait() {
2016-05-30 03:03:40 +02:00
static u64 delay = 0;
u32 pad_state_old = HID_STATE;
2016-05-30 03:03:40 +02:00
delay = (delay) ? 80 : 400;
2016-05-30 01:54:09 +02:00
timer_start();
while (true) {
u32 pad_state = HID_STATE;
2016-04-05 23:19:29 +02:00
if (!(~pad_state & BUTTON_ANY)) { // no buttons pressed
pad_state_old = pad_state;
2016-05-30 03:03:40 +02:00
delay = 0;
2016-04-05 23:19:29 +02:00
continue;
}
2016-05-30 03:03:40 +02:00
if ((pad_state == pad_state_old) &&
(!(~pad_state & BUTTON_ARROW) ||
(delay && (timer_msec() < delay))))
2016-04-05 23:19:29 +02:00
continue;
//Make sure the key is pressed
u32 t_pressed = 0;
for(; (t_pressed < 0x13000) && (pad_state == HID_STATE); t_pressed++);
if (t_pressed >= 0x13000)
return ~pad_state;
}
}