2011-06-13 21:53:02 +00:00
|
|
|
#include <sysinit.h>
|
|
|
|
#include "basic/basic.h"
|
|
|
|
|
2011-07-21 18:37:04 +00:00
|
|
|
uint8_t getInputRaw(void) {
|
2011-06-13 21:53:02 +00:00
|
|
|
uint8_t result = BTN_NONE;
|
|
|
|
|
|
|
|
if (gpioGetValue(RB_BTN3)==0) {
|
2011-07-21 18:37:04 +00:00
|
|
|
result |= BTN_UP;
|
2011-06-13 21:53:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gpioGetValue(RB_BTN2)==0) {
|
2011-07-21 18:37:04 +00:00
|
|
|
result |= BTN_DOWN;
|
2011-06-13 21:53:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gpioGetValue(RB_BTN4)==0) {
|
2011-07-21 18:37:04 +00:00
|
|
|
result |= BTN_ENTER;
|
2011-06-13 21:53:02 +00:00
|
|
|
}
|
|
|
|
|
2011-06-26 09:45:05 +00:00
|
|
|
if (gpioGetValue(RB_BTN0)==0) {
|
2011-07-21 18:37:04 +00:00
|
|
|
result |= BTN_LEFT;
|
2011-06-26 09:45:05 +00:00
|
|
|
}
|
2011-06-13 21:53:02 +00:00
|
|
|
|
|
|
|
if (gpioGetValue(RB_BTN1)==0) {
|
2011-07-21 18:37:04 +00:00
|
|
|
result |= BTN_RIGHT;
|
2011-06-13 21:53:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-07-21 18:37:04 +00:00
|
|
|
uint8_t getInput(void) {
|
|
|
|
uint8_t key = BTN_NONE;
|
2011-07-04 20:49:35 +00:00
|
|
|
|
2011-07-21 18:37:04 +00:00
|
|
|
key=getInputRaw();
|
|
|
|
if(key != BTN_NONE)
|
|
|
|
while(key==getInputRaw()); // Wait for any release
|
2011-07-04 20:49:35 +00:00
|
|
|
|
2011-07-21 18:37:04 +00:00
|
|
|
return key;
|
2011-07-04 20:49:35 +00:00
|
|
|
}
|
|
|
|
|
2011-07-09 18:19:05 +00:00
|
|
|
uint8_t getInputWait(void) {
|
|
|
|
uint8_t key;
|
|
|
|
while ((key=getInput())==BTN_NONE)
|
2011-07-24 13:54:18 +00:00
|
|
|
work_queue();
|
2011-07-09 18:19:05 +00:00
|
|
|
return key;
|
|
|
|
};
|
|
|
|
|
|
|
|
|