|
|
@ -33,8 +33,7 @@ int left_initted = 0;
|
|
|
|
#define TS(X) //Serial.print(micros() );Serial.print("\t");Serial.println(X);
|
|
|
|
#define TS(X) //Serial.print(micros() );Serial.print("\t");Serial.println(X);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setup_matrix()
|
|
|
|
void setup_matrix() {
|
|
|
|
{
|
|
|
|
|
|
|
|
reset_key_report();
|
|
|
|
reset_key_report();
|
|
|
|
//blank out the matrix.
|
|
|
|
//blank out the matrix.
|
|
|
|
for (byte col = 0; col < COLS; col++) {
|
|
|
|
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;
|
|
|
|
x = 0;
|
|
|
|
y = 0;
|
|
|
|
y = 0;
|
|
|
|
//scan the Keyboard matrix looking for connections
|
|
|
|
//scan the Keyboard matrix looking for connections
|
|
|
@ -263,16 +261,15 @@ void process_command_buffer() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setup()
|
|
|
|
void setup() {
|
|
|
|
{
|
|
|
|
|
|
|
|
wdt_disable();
|
|
|
|
wdt_disable();
|
|
|
|
Serial.begin(115200);
|
|
|
|
Serial.begin(115200);
|
|
|
|
//usbMaxPower = 100;
|
|
|
|
//usbMaxPower = 100;
|
|
|
|
Keyboard.begin();
|
|
|
|
Keyboard.begin();
|
|
|
|
Mouse.begin();
|
|
|
|
Mouse.begin();
|
|
|
|
setup_leds();
|
|
|
|
setup_leds();
|
|
|
|
led_bootup();
|
|
|
|
led_bootup();
|
|
|
|
setup_command_mode();
|
|
|
|
setup_command_mode();
|
|
|
|
setup_matrix();
|
|
|
|
setup_matrix();
|
|
|
|
setup_pins();
|
|
|
|
setup_pins();
|
|
|
|
rightsx1509.fetchPinStates();
|
|
|
|
rightsx1509.fetchPinStates();
|
|
|
@ -282,8 +279,7 @@ setup_command_mode();
|
|
|
|
|
|
|
|
|
|
|
|
String myApp;
|
|
|
|
String myApp;
|
|
|
|
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
void loop() {
|
|
|
|
{
|
|
|
|
|
|
|
|
// if(Serial.available()) {
|
|
|
|
// if(Serial.available()) {
|
|
|
|
// myApp = Serial.readString();
|
|
|
|
// myApp = Serial.readString();
|
|
|
|
// myApp.trim();
|
|
|
|
// myApp.trim();
|
|
|
@ -299,18 +295,16 @@ void loop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void save_primary_keymap(byte keymap)
|
|
|
|
void save_primary_keymap(byte keymap) {
|
|
|
|
{
|
|
|
|
|
|
|
|
EEPROM.write(EEPROM_KEYMAP_LOCATION, keymap);
|
|
|
|
EEPROM.write(EEPROM_KEYMAP_LOCATION, keymap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
byte load_primary_keymap()
|
|
|
|
byte load_primary_keymap() {
|
|
|
|
{
|
|
|
|
|
|
|
|
byte keymap = EEPROM.read(EEPROM_KEYMAP_LOCATION);
|
|
|
|
byte keymap = EEPROM.read(EEPROM_KEYMAP_LOCATION);
|
|
|
|
if (keymap >= KEYMAPS ) {
|
|
|
|
if (keymap >= KEYMAPS ) {
|
|
|
|
return 0; // undefined positions get saved as 255
|
|
|
|
return 0; // undefined positions get saved as 255
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0; // return keymap;
|
|
|
|
return 0; // return keymap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -319,8 +313,7 @@ return 0; // return keymap;
|
|
|
|
// Debugging Reporting
|
|
|
|
// Debugging Reporting
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
void report_matrix()
|
|
|
|
void report_matrix() {
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef DEBUG_SERIAL
|
|
|
|
#ifdef DEBUG_SERIAL
|
|
|
|
if (reporting_counter++ % 100 == 0 ) {
|
|
|
|
if (reporting_counter++ % 100 == 0 ) {
|
|
|
|
for (byte row = 0; row < ROWS; row++) {
|
|
|
|
for (byte row = 0; row < ROWS; row++) {
|
|
|
@ -336,8 +329,7 @@ void report_matrix()
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void report(byte row, byte col, boolean value)
|
|
|
|
void report(byte row, byte col, boolean value) {
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef DEBUG_SERIAL
|
|
|
|
#ifdef DEBUG_SERIAL
|
|
|
|
Serial.print("Detected a change on ");
|
|
|
|
Serial.print("Detected a change on ");
|
|
|
|
Serial.print(col);
|
|
|
|
Serial.print(col);
|
|
|
@ -353,8 +345,7 @@ void report(byte row, byte col, boolean value)
|
|
|
|
// Key Reports
|
|
|
|
// Key Reports
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
void release_keys_not_being_pressed()
|
|
|
|
void release_keys_not_being_pressed() {
|
|
|
|
{
|
|
|
|
|
|
|
|
// we use charsReportedLastTime to figure out what we might
|
|
|
|
// we use charsReportedLastTime to figure out what we might
|
|
|
|
// not be holding anymore and can now release. this is
|
|
|
|
// not be holding anymore and can now release. this is
|
|
|
|
// destructive to charsReportedLastTime
|
|
|
|
// 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++) {
|
|
|
|
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) {
|
|
|
@ -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);
|
|
|
|
memcpy( charsReportedLastTime, charsBeingReported, KEYS_HELD_BUFFER);
|
|
|
|
memset(charsBeingReported, 0, 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();
|
|
|
|
next_led_mode();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (mappedKey.flags & IS_SYSCTL) {
|
|
|
|
else if (mappedKey.flags & IS_SYSCTL) {
|
|
|
|
|
|
|
|
if (key_toggled_on (switchState)) {
|
|
|
|
if (key_toggled_on (switchState)) {
|
|
|
|
SystemControl.press(mappedKey.rawKey);
|
|
|
|
SystemControl.press(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) {
|
|
|
|
Serial.print("Keyboard.IO keyboard driver v0.00");
|
|
|
|
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 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
|
|
|
|
// 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) {
|
|
|
|
} else if (mappedKey.flags & SYNTHETIC_KEY) {
|
|
|
|
handle_synthetic_key_press(switchState, mappedKey);
|
|
|
|
handle_synthetic_key_press(switchState, mappedKey);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else {
|
|
|
|
|
|
|
|
if (key_is_pressed(switchState)) {
|
|
|
|
if (key_is_pressed(switchState)) {
|
|
|
|
record_key_being_pressed(mappedKey.rawKey);
|
|
|
|
record_key_being_pressed(mappedKey.rawKey);
|
|
|
|
if (key_toggled_on (switchState)) {
|
|
|
|
if (key_toggled_on (switchState)) {
|
|
|
|