|
|
|
@ -33,8 +33,7 @@ int left_initted = 0;
|
|
|
|
|
#define TS(X) //Serial.print(micros() );Serial.print("\t");Serial.println(X);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setup_matrix()
|
|
|
|
|
{
|
|
|
|
|
void setup_matrix() {
|
|
|
|
|
reset_key_report();
|
|
|
|
|
//blank out the matrix.
|
|
|
|
|
for (byte col = 0; col < COLS; col++) {
|
|
|
|
@ -80,8 +79,7 @@ void set_keymap(Key keymapEntry, byte matrixStateEntry) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void scan_matrix()
|
|
|
|
|
{
|
|
|
|
|
void scan_matrix() {
|
|
|
|
|
x = 0;
|
|
|
|
|
y = 0;
|
|
|
|
|
//scan the Keyboard matrix looking for connections
|
|
|
|
@ -263,8 +261,7 @@ void process_command_buffer() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setup()
|
|
|
|
|
{
|
|
|
|
|
void setup() {
|
|
|
|
|
wdt_disable();
|
|
|
|
|
Serial.begin(115200);
|
|
|
|
|
//usbMaxPower = 100;
|
|
|
|
@ -282,8 +279,7 @@ setup_command_mode();
|
|
|
|
|
|
|
|
|
|
String myApp;
|
|
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
|
{
|
|
|
|
|
void loop() {
|
|
|
|
|
// if(Serial.available()) {
|
|
|
|
|
// myApp = Serial.readString();
|
|
|
|
|
// myApp.trim();
|
|
|
|
@ -299,13 +295,11 @@ void loop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void save_primary_keymap(byte keymap)
|
|
|
|
|
{
|
|
|
|
|
void save_primary_keymap(byte keymap) {
|
|
|
|
|
EEPROM.write(EEPROM_KEYMAP_LOCATION, keymap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
byte load_primary_keymap()
|
|
|
|
|
{
|
|
|
|
|
byte load_primary_keymap() {
|
|
|
|
|
byte keymap = EEPROM.read(EEPROM_KEYMAP_LOCATION);
|
|
|
|
|
if (keymap >= KEYMAPS ) {
|
|
|
|
|
return 0; // undefined positions get saved as 255
|
|
|
|
@ -319,8 +313,7 @@ return 0; // return keymap;
|
|
|
|
|
// Debugging Reporting
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
void report_matrix()
|
|
|
|
|
{
|
|
|
|
|
void report_matrix() {
|
|
|
|
|
#ifdef DEBUG_SERIAL
|
|
|
|
|
if (reporting_counter++ % 100 == 0 ) {
|
|
|
|
|
for (byte row = 0; row < ROWS; row++) {
|
|
|
|
@ -336,8 +329,7 @@ void report_matrix()
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void report(byte row, byte col, boolean value)
|
|
|
|
|
{
|
|
|
|
|
void report(byte row, byte col, boolean value) {
|
|
|
|
|
#ifdef DEBUG_SERIAL
|
|
|
|
|
Serial.print("Detected a change on ");
|
|
|
|
|
Serial.print(col);
|
|
|
|
@ -353,8 +345,7 @@ void report(byte row, byte col, boolean value)
|
|
|
|
|
// Key Reports
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
void release_keys_not_being_pressed()
|
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
@ -380,8 +371,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++) {
|
|
|
|
|
// todo - deal with overflowing the 12 key buffer here
|
|
|
|
|
if (charsBeingReported[i] == 0x00) {
|
|
|
|
@ -391,8 +381,7 @@ void record_key_being_pressed(byte character)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void reset_key_report()
|
|
|
|
|
{
|
|
|
|
|
void reset_key_report() {
|
|
|
|
|
memcpy( charsReportedLastTime, charsBeingReported, KEYS_HELD_BUFFER);
|
|
|
|
|
memset(charsBeingReported, 0, KEYS_HELD_BUFFER);
|
|
|
|
|
|
|
|
|
@ -414,13 +403,11 @@ void handle_synthetic_key_press(byte switchState, Key mappedKey) {
|
|
|
|
|
next_led_mode();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (mappedKey.flags & IS_SYSCTL) {
|
|
|
|
|
} else if (mappedKey.flags & IS_SYSCTL) {
|
|
|
|
|
if (key_toggled_on (switchState)) {
|
|
|
|
|
SystemControl.press(mappedKey.rawKey);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (mappedKey.flags & IS_MACRO) {
|
|
|
|
|
} else if (mappedKey.flags & IS_MACRO) {
|
|
|
|
|
if (key_toggled_on (switchState)) {
|
|
|
|
|
if (mappedKey.rawKey == 1) {
|
|
|
|
|
Serial.print("Keyboard.IO keyboard driver v0.00");
|
|
|
|
@ -439,8 +426,7 @@ void handle_synthetic_key_press(byte switchState, Key mappedKey) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void send_key_event(byte row, byte col)
|
|
|
|
|
{
|
|
|
|
|
void send_key_event(byte row, byte col) {
|
|
|
|
|
//for every newly pressed button, figure out what logical key it is and send a key down event
|
|
|
|
|
// for every newly released button, figure out what logical key it is and send a key up event
|
|
|
|
|
|
|
|
|
@ -465,8 +451,7 @@ void send_key_event(byte row, byte col)
|
|
|
|
|
|
|
|
|
|
} else if (mappedKey.flags & SYNTHETIC_KEY) {
|
|
|
|
|
handle_synthetic_key_press(switchState, mappedKey);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
} else {
|
|
|
|
|
if (key_is_pressed(switchState)) {
|
|
|
|
|
record_key_being_pressed(mappedKey.rawKey);
|
|
|
|
|
if (key_toggled_on (switchState)) {
|
|
|
|
|