Hardware: Move detachFromHost/attachToHost to the base class

Since all implementations of detachFromHost/attachToHost are the same for all
our current keyboards, move it to the base class as a default.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/504/head
Gergely Nagy 6 years ago
parent 2e21af99b9
commit d7df39dffd
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -198,14 +198,17 @@ class Hardware {
* Must detach the device, without rebooting or cutting power. Only the end * Must detach the device, without rebooting or cutting power. Only the end
* points should get detached, the device must remain powered on. * points should get detached, the device must remain powered on.
*/ */
void detachFromHost() {} void detachFromHost() {
UDCON |= _BV(DETACH);
}
/** /**
* Attack the device to the host. * Attack the device to the host.
* *
* Must restore the link detachFromHost severed. * Must restore the link detachFromHost severed.
*/ */
void attachToHost() {} void attachToHost() {
UDCON &= ~_BV(DETACH);
}
/** @} */ /** @} */
/** /**

@ -51,14 +51,6 @@ void ATMegaKeyboard::setup(void) {
TIMSK1 = _BV(TOIE1); TIMSK1 = _BV(TOIE1);
} }
void ATMegaKeyboard::detachFromHost() {
UDCON |= _BV(DETACH);
}
void ATMegaKeyboard::attachToHost() {
UDCON &= ~_BV(DETACH);
}
void __attribute__((optimize(3))) ATMegaKeyboard::readMatrix(void) { void __attribute__((optimize(3))) ATMegaKeyboard::readMatrix(void) {
for (uint8_t current_row = 0; current_row < KeyboardHardware.matrix_rows; current_row++) { for (uint8_t current_row = 0; current_row < KeyboardHardware.matrix_rows; current_row++) {
uint16_t mask, cols; uint16_t mask, cols;

@ -80,17 +80,6 @@ class ATMegaKeyboard : public kaleidoscope::Hardware {
void setup(void); void setup(void);
/** Detaching from / attaching to the host.
*
* These two functions should detach the device from (or attach it to) the
* host, preferably without rebooting the device. Their purpose is to allow
* one to do some configuration inbetween, so the re-attach happens with
* different properties. The device remains powered between these operations,
* only the connection to the host gets severed.
*/
void detachFromHost();
void attachToHost();
void readMatrix(void); void readMatrix(void);
/** /**

@ -223,14 +223,6 @@ void ErgoDox::debounceRow(uint8_t change, uint8_t row) {
} }
} }
void ErgoDox::detachFromHost() {
UDCON |= (1 << DETACH);
}
void ErgoDox::attachToHost() {
UDCON &= ~(1 << DETACH);
}
bool ErgoDox::isKeyswitchPressed(byte row, byte col) { bool ErgoDox::isKeyswitchPressed(byte row, byte col) {
return (bitRead(keyState_[row], col) != 0); return (bitRead(keyState_[row], col) != 0);
} }

@ -61,17 +61,6 @@ class ErgoDox : public kaleidoscope::Hardware {
void actOnMatrixScan(void); void actOnMatrixScan(void);
void setup(); void setup();
/** Detaching from / attaching to the host.
*
* These two functions should detach the device from (or attach it to) the
* host, preferably without rebooting the device. Their purpose is to allow
* one to do some configuration inbetween, so the re-attach happens with
* different properties. The device remains powered between these operations,
* only the connection to the host gets severed.
*/
void detachFromHost();
void attachToHost();
/* Key masking /* Key masking
* ----------- * -----------
* *

@ -292,14 +292,6 @@ void Model01::setKeyscanInterval(uint8_t interval) {
rightHand.setKeyscanInterval(interval); rightHand.setKeyscanInterval(interval);
} }
void Model01::detachFromHost() {
UDCON |= (1 << DETACH);
}
void Model01::attachToHost() {
UDCON &= ~(1 << DETACH);
}
bool Model01::isKeyswitchPressed(byte row, byte col) { bool Model01::isKeyswitchPressed(byte row, byte col) {
if (col <= 7) { if (col <= 7) {
return (bitRead(leftHandState.rows[row], 7 - col) != 0); return (bitRead(leftHandState.rows[row], 7 - col) != 0);

@ -55,17 +55,6 @@ class Model01 : public kaleidoscope::Hardware {
void setup(); void setup();
void rebootBootloader(); void rebootBootloader();
/** Detaching from / attaching to the host.
*
* These two functions should detach the device from (or attach it to) the
* host, preferably without rebooting the device. Their purpose is to allow
* one to do some configuration inbetween, so the re-attach happens with
* different properties. The device remains powered between these operations,
* only the connection to the host gets severed.
*/
void detachFromHost();
void attachToHost();
/* These public functions are things supported by the Model 01, but /* These public functions are things supported by the Model 01, but
* aren't necessarily part of the Kaleidoscope API * aren't necessarily part of the Kaleidoscope API
*/ */

Loading…
Cancel
Save