You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Kaleidoscope/src/kaleidoscope/Kaleidoscope.cpp

75 lines
2.2 KiB

/* Kaleidoscope - Firmware for computer input devices
* Copyright (C) 2013-2018 Keyboard.io, Inc.
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "kaleidoscope/Kaleidoscope.h"
#include <stdarg.h>
namespace kaleidoscope {
uint32_t Kaleidoscope_::millis_at_cycle_start_;
Kaleidoscope_::Kaleidoscope_(void) {
}
void
Kaleidoscope_::setup(void) {
// We are explicitly initializing the Serial port as early as possible to
// (temporarily, hopefully) work around an issue on OSX. If we initialize
// Serial too late, no matter what we do, we'll end up reading garbage from
// the serial port. For more information, see the following issue:
// https://github.com/keyboardio/Kaleidoscope-Bundle-Keyboardio/pull/7
//
// TODO(anyone): Figure out a way we can get rid of this, and fix the bug
// properly.
Serial.begin(9600);
kaleidoscope::Hooks::onSetup();
8 years ago
KeyboardHardware.setup();
kaleidoscope::hid::initializeKeyboard();
kaleidoscope::hid::initializeConsumerControl();
kaleidoscope::hid::initializeSystemControl();
// Update the keymap cache, so we start with a non-empty state.
Layer.updateActiveLayers();
for (byte row = 0; row < ROWS; row++) {
for (byte col = 0; col < COLS; col++) {
Layer.updateLiveCompositeKeymap(row, col);
}
}
}
void
Kaleidoscope_::loop(void) {
millis_at_cycle_start_ = millis();
kaleidoscope::Hooks::beforeEachCycle();
KeyboardHardware.scanMatrix();
kaleidoscope::Hooks::beforeReportingState();
kaleidoscope::hid::sendKeyboardReport();
kaleidoscope::hid::releaseAllKeys();
kaleidoscope::Hooks::afterEachCycle();
}
Kaleidoscope_ Kaleidoscope;
} // namespace kaleidoscope