|
|
@ -48,7 +48,7 @@ void release_keys_not_being_pressed()
|
|
|
|
|
|
|
|
|
|
|
|
// we use charsReportedLastTime to figure out what we might not be holding anymore and can now release. this is destructive to charsReportedLastTime
|
|
|
|
// we use charsReportedLastTime to figure out what we might not be holding anymore and can now release. this is destructive to charsReportedLastTime
|
|
|
|
|
|
|
|
|
|
|
|
for (byte i=0; i<KEYS_HELD_BUFFER; i++) {
|
|
|
|
for (byte i = 0; i < KEYS_HELD_BUFFER; i++) {
|
|
|
|
// for each key we were holding as of the end of the last cycle
|
|
|
|
// for each key we were holding as of the end of the last cycle
|
|
|
|
// see if we're still holding it
|
|
|
|
// see if we're still holding it
|
|
|
|
// if we're not, call an explicit Release
|
|
|
|
// if we're not, call an explicit Release
|
|
|
@ -56,7 +56,7 @@ void release_keys_not_being_pressed()
|
|
|
|
if (charsReportedLastTime[i] != 0x00) {
|
|
|
|
if (charsReportedLastTime[i] != 0x00) {
|
|
|
|
// if there _was_ a character in this slot, go check the
|
|
|
|
// if there _was_ a character in this slot, go check the
|
|
|
|
// currently held characters
|
|
|
|
// currently held characters
|
|
|
|
for (byte j=0; j<KEYS_HELD_BUFFER; j++) {
|
|
|
|
for (byte j = 0; j < KEYS_HELD_BUFFER; j++) {
|
|
|
|
if (charsReportedLastTime[i] == charsBeingReported[j]) {
|
|
|
|
if (charsReportedLastTime[i] == charsBeingReported[j]) {
|
|
|
|
// if's still held, we don't need to do anything.
|
|
|
|
// if's still held, we don't need to do anything.
|
|
|
|
charsReportedLastTime[i] = 0x00;
|
|
|
|
charsReportedLastTime[i] = 0x00;
|
|
|
@ -66,7 +66,7 @@ void release_keys_not_being_pressed()
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (byte i=0; i<KEYS_HELD_BUFFER; i++) {
|
|
|
|
for (byte i = 0; i < KEYS_HELD_BUFFER; i++) {
|
|
|
|
if (charsReportedLastTime[i] != 0x00) {
|
|
|
|
if (charsReportedLastTime[i] != 0x00) {
|
|
|
|
Keyboard.release(charsReportedLastTime[i]);
|
|
|
|
Keyboard.release(charsReportedLastTime[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -75,7 +75,7 @@ void release_keys_not_being_pressed()
|
|
|
|
|
|
|
|
|
|
|
|
void record_key_being_pressed(byte character)
|
|
|
|
void record_key_being_pressed(byte character)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (byte i=0; i<KEYS_HELD_BUFFER; i++) {
|
|
|
|
for (byte i = 0; i < KEYS_HELD_BUFFER; i++) {
|
|
|
|
// todo - deal with overflowing the 12 key buffer here
|
|
|
|
// todo - deal with overflowing the 12 key buffer here
|
|
|
|
if (charsBeingReported[i] == 0x00) {
|
|
|
|
if (charsBeingReported[i] == 0x00) {
|
|
|
|
charsBeingReported[i] = character;
|
|
|
|
charsBeingReported[i] = character;
|
|
|
@ -91,7 +91,7 @@ void reset_matrix()
|
|
|
|
matrixState[row][col] <<= 1;
|
|
|
|
matrixState[row][col] <<= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (byte i=0; i<KEYS_HELD_BUFFER; i++) {
|
|
|
|
for (byte i = 0; i < KEYS_HELD_BUFFER; i++) {
|
|
|
|
charsReportedLastTime[i] = charsBeingReported[i];
|
|
|
|
charsReportedLastTime[i] = charsBeingReported[i];
|
|
|
|
charsBeingReported[i] = 0x00;
|
|
|
|
charsBeingReported[i] = 0x00;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -100,18 +100,18 @@ void reset_matrix()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void handle_synthetic_key_press(byte switchState,Key mappedKey) {
|
|
|
|
void handle_synthetic_key_press(byte switchState, Key mappedKey) {
|
|
|
|
if(mappedKey.flags & IS_CONSUMER) {
|
|
|
|
if (mappedKey.flags & IS_CONSUMER) {
|
|
|
|
if (key_toggled_on (switchState)) {
|
|
|
|
if (key_toggled_on (switchState)) {
|
|
|
|
Keyboard.consumerControl(mappedKey.rawKey);
|
|
|
|
Keyboard.consumerControl(mappedKey.rawKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(mappedKey.flags & IS_SYSCTL) {
|
|
|
|
else if (mappedKey.flags & IS_SYSCTL) {
|
|
|
|
if (key_toggled_on (switchState)) {
|
|
|
|
if (key_toggled_on (switchState)) {
|
|
|
|
Keyboard.systemControl(mappedKey.rawKey);
|
|
|
|
Keyboard.systemControl(mappedKey.rawKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(mappedKey.flags & IS_MACRO) {
|
|
|
|
else if (mappedKey.flags & IS_MACRO) {
|
|
|
|
if (key_toggled_on (switchState)) {
|
|
|
|
if (key_toggled_on (switchState)) {
|
|
|
|
if (mappedKey.rawKey == 1) {
|
|
|
|
if (mappedKey.rawKey == 1) {
|
|
|
|
Keyboard.print("Keyboard.IO keyboard driver v0.00");
|
|
|
|
Keyboard.print("Keyboard.IO keyboard driver v0.00");
|
|
|
@ -127,25 +127,25 @@ void reset_matrix()
|
|
|
|
Mouse.release(mappedKey.rawKey);
|
|
|
|
Mouse.release(mappedKey.rawKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void handle_mouse_key_press(byte switchState, Key mappedKey, char &x, char &y) {
|
|
|
|
void handle_mouse_key_press(byte switchState, Key mappedKey, char &x, char &y) {
|
|
|
|
|
|
|
|
|
|
|
|
if (key_is_pressed(switchState)) {
|
|
|
|
if (key_is_pressed(switchState)) {
|
|
|
|
if (mappedKey.rawKey & MOUSE_UP) {
|
|
|
|
if (mappedKey.rawKey & MOUSE_UP) {
|
|
|
|
y-=1;
|
|
|
|
y -= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mappedKey.rawKey & MOUSE_DN) {
|
|
|
|
if (mappedKey.rawKey & MOUSE_DN) {
|
|
|
|
y+= 1;
|
|
|
|
y += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mappedKey.rawKey & MOUSE_L) {
|
|
|
|
if (mappedKey.rawKey & MOUSE_L) {
|
|
|
|
x-= 1;
|
|
|
|
x -= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (mappedKey.rawKey & MOUSE_R) {
|
|
|
|
if (mappedKey.rawKey & MOUSE_R) {
|
|
|
|
x+= 1 ;
|
|
|
|
x += 1 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void send_key_events(byte layer)
|
|
|
|
void send_key_events(byte layer)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -165,7 +165,7 @@ void send_key_events(byte layer)
|
|
|
|
byte switchState = matrixState[row][col];
|
|
|
|
byte switchState = matrixState[row][col];
|
|
|
|
Key mappedKey = keymaps[layer][row][col];
|
|
|
|
Key mappedKey = keymaps[layer][row][col];
|
|
|
|
if (mappedKey.flags & MOUSE_KEY ) {
|
|
|
|
if (mappedKey.flags & MOUSE_KEY ) {
|
|
|
|
handle_mouse_key_press(matrixState[row][col], keymaps[layer][row][col],x,y);
|
|
|
|
handle_mouse_key_press(matrixState[row][col], keymaps[layer][row][col], x, y);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (mappedKey.flags & SYNTHETIC_KEY) {
|
|
|
|
} else if (mappedKey.flags & SYNTHETIC_KEY) {
|
|
|
@ -183,7 +183,7 @@ void send_key_events(byte layer)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
handle_mouse_movement(x,y);
|
|
|
|
handle_mouse_movement(x, y);
|
|
|
|
release_keys_not_being_pressed();
|
|
|
|
release_keys_not_being_pressed();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void setup_matrix()
|
|
|
|
void setup_matrix()
|
|
|
@ -266,8 +266,8 @@ void setup()
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.begin(115200);
|
|
|
|
Keyboard.begin();
|
|
|
|
Keyboard.begin();
|
|
|
|
Mouse.begin();
|
|
|
|
Mouse.begin();
|
|
|
|
//#ifdef DEBUG_SERIAL
|
|
|
|
//#ifdef DEBUG_SERIAL
|
|
|
|
//#endif
|
|
|
|
//#endif
|
|
|
|
setup_matrix();
|
|
|
|
setup_matrix();
|
|
|
|
Serial.println("loaded the matrix");
|
|
|
|
Serial.println("loaded the matrix");
|
|
|
|
current_layer = load_current_layer();
|
|
|
|
current_layer = load_current_layer();
|
|
|
|