mirror of
https://bitbucket.org/C_Classic/prgkbd.git
synced 2024-11-22 18:25:09 +01:00
Added some delay functions (untested)
This commit is contained in:
parent
77818dde76
commit
766f788bf3
@ -8,6 +8,8 @@
|
|||||||
#include "usbdrv.h"
|
#include "usbdrv.h"
|
||||||
#include "lib/prgKeyboard.h"
|
#include "lib/prgKeyboard.h"
|
||||||
|
|
||||||
|
void delay_ms_wdreset(unsigned int ms);
|
||||||
|
|
||||||
static uchar reportBuffer[8] = {0,0,0,0,0,0,0,0}; /* buffer for HID reports */
|
static uchar reportBuffer[8] = {0,0,0,0,0,0,0,0}; /* buffer for HID reports */
|
||||||
static uchar idleRate; /* in 4 ms units */
|
static uchar idleRate; /* in 4 ms units */
|
||||||
static uchar newReport = 1; /* current report */
|
static uchar newReport = 1; /* current report */
|
||||||
@ -310,6 +312,36 @@ void continueExecution() {
|
|||||||
if ((keyType[oldKey-1] == KEYTYPE_TEXT) || keyAction == KEYACTION_DOWN) reportBuffer[0] &= ~(1 << (instr - 232)); // MOD-Keys (dis)
|
if ((keyType[oldKey-1] == KEYTYPE_TEXT) || keyAction == KEYACTION_DOWN) reportBuffer[0] &= ~(1 << (instr - 232)); // MOD-Keys (dis)
|
||||||
else reportBuffer[0] |= (1 << (instr - 232)); // MOD-Keys (en)
|
else reportBuffer[0] |= (1 << (instr - 232)); // MOD-Keys (en)
|
||||||
}
|
}
|
||||||
|
else if (instr >= 240 && instr <= 250) {
|
||||||
|
// Delay execution by a few ms
|
||||||
|
// Yeah I know the code is ugly, but I don't really care.
|
||||||
|
switch (instr) {
|
||||||
|
case 240:
|
||||||
|
delay_ms_wdreset(10);
|
||||||
|
break;
|
||||||
|
case 241:
|
||||||
|
delay_ms_wdreset(50);
|
||||||
|
break;
|
||||||
|
case 242:
|
||||||
|
delay_ms_wdreset(100);
|
||||||
|
break;
|
||||||
|
case 243:
|
||||||
|
delay_ms_wdreset(250);
|
||||||
|
break;
|
||||||
|
case 244:
|
||||||
|
delay_ms_wdreset(250);
|
||||||
|
delay_ms_wdreset(250);
|
||||||
|
break;
|
||||||
|
case 245:
|
||||||
|
delay_ms_wdreset(500);
|
||||||
|
delay_ms_wdreset(500);
|
||||||
|
delay_ms_wdreset(500);
|
||||||
|
delay_ms_wdreset(500);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!flag_keyPress) memAddr++; // increase memory address
|
if (!flag_keyPress) memAddr++; // increase memory address
|
||||||
// Currently there's NO protection.The system could jump onto the next key
|
// Currently there's NO protection.The system could jump onto the next key
|
||||||
@ -317,6 +349,15 @@ void continueExecution() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MAX 255ms
|
||||||
|
void delay_ms_wdreset(unsigned int ms) {
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < ms; i++) {
|
||||||
|
_delay_ms(1);
|
||||||
|
wdt_reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void detectKeyType() {
|
void detectKeyType() {
|
||||||
uint8_t keyId;
|
uint8_t keyId;
|
||||||
uint16_t x;
|
uint16_t x;
|
||||||
|
Loading…
Reference in New Issue
Block a user