cold = c;
return c;
}
+ penalty = 0;
+ } else {
+ penalty++;
+ if(penalty > 4) {
+ penalty = 0;
+ cold = charcode_null; // About 100ms
+ }
}
- penalty++;
- if(penalty > 65) cold = charcode_null; // About 1500ms
} while(1);
}
{
unsigned char c;
unsigned int ticks = 0;
+ unsigned char penalty = 0;
+ unsigned char count = 0;
-// cold = charcode_null;
+ cold = charcode_null;
+ pollkeybuf[0] = charcode_null;
do {
+ if(limit != 0) {
+ ticks++;
+ if(ticks > limit) {
+ break;
+ }
+ }
idle_time_ms(5); // 5ms.
c = readkey(); // 2 * 9 = 18ms
ClrWdt();
ticks++;
- if(c != charcode_null) {
- if(repeat != 0){
+ if(c != charcode_null){
+ if(cold != c) {
+ pollkeybuf[count++] = c;
cold = c;
- break;
- } else {
- if(cold != c) {
- cold = c;
- break;
+ count++;
+ if(repeat == 0) {
+ break;
}
+ penalty = 0;
}
- }
- if(limit != 0) {
- ticks++;
- if(ticks > limit) {
+ } else {
+ penalty++;
+ if(penalty > 4){
+ penalty = 0;
cold = charcode_null;
- return charcode_null;
}
}
- } while(1);
+ } while(count < 32);
/*
* Set Deadzone.
*/
if(limit == 0) {
-// if(ticks >= (limit >> 1)) cold = charcode_null;
while(ticks <= limit) {
idle_time_ms(5 + 18);
ticks++;
}
}
+ c = pollkeybuf[0];
return c;
}
/*