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.
51 lines
1.4 KiB
51 lines
1.4 KiB
8 years ago
|
/* -*- mode: c++ -*-
|
||
8 years ago
|
* Kaleidoscope-HostOS -- Host OS detection and tracking for Kaleidoscope
|
||
6 years ago
|
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc
|
||
8 years ago
|
*
|
||
6 years ago
|
* 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.
|
||
8 years ago
|
*
|
||
6 years ago
|
* 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.
|
||
8 years ago
|
*
|
||
6 years ago
|
* You should have received a copy of the GNU General Public License along with
|
||
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||
8 years ago
|
*/
|
||
|
|
||
6 years ago
|
#include <kaleidoscope/plugin/HostOS.h>
|
||
8 years ago
|
#include <Kaleidoscope-EEPROM-Settings.h>
|
||
8 years ago
|
|
||
8 years ago
|
namespace kaleidoscope {
|
||
6 years ago
|
namespace plugin {
|
||
8 years ago
|
|
||
6 years ago
|
EventHandlerResult HostOS::onSetup(void) {
|
||
8 years ago
|
if (is_configured_)
|
||
7 years ago
|
return EventHandlerResult::OK;
|
||
8 years ago
|
|
||
8 years ago
|
eeprom_slice_ = ::EEPROMSettings.requestSlice(sizeof(os_));
|
||
8 years ago
|
|
||
8 years ago
|
is_configured_ = true;
|
||
8 years ago
|
|
||
6 years ago
|
if (os_ != hostos::UNKNOWN) {
|
||
7 years ago
|
return EventHandlerResult::OK;
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
5 years ago
|
os_ = (hostos::Type)Runtime.storage().read(eeprom_slice_);
|
||
7 years ago
|
|
||
|
return EventHandlerResult::OK;
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
6 years ago
|
void HostOS::os(hostos::Type new_os) {
|
||
8 years ago
|
os_ = new_os;
|
||
5 years ago
|
Runtime.storage().update(eeprom_slice_, os_);
|
||
|
Runtime.storage().commit();
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
6 years ago
|
}
|
||
8 years ago
|
}
|
||
6 years ago
|
|
||
6 years ago
|
kaleidoscope::plugin::HostOS HostOS;
|