Instead of having to define `HARDWARE_IMPLEMENTATION` to the class name of the device, and define `KeyboardHardware` from within the plugin, let all devices set `kaleidoscope::Device` to their own class via a typedef. Furthermore, instead of `KeyboardHardware`, use `Kaleidoscope.device()` instead. This makes device plugins a little bit simpler, and our naming more consistent. Because some parts of the firmware need to access the device object before the `Kaleidoscope` object is available, we can't make it a member of that. For this reason, the device object is `kaleidoscope_internal::device`, and `Kaleidoscope.device()` wraps it. In general, the wrapper should be used. But if access to the device is required before `Kaleidoscope` is available, then that's also available. The `Kaleidoscope` object grew a few more wrappers: `storage()` and `serialPort()`, so that one doesn't need to use `Kaleidoscope.device()` directly, but can use the wrappers, which are noticably shorter to write. Signed-off-by: Gergely Nagy <algernon@keyboard.io>pull/710/head
parent
129d37ef04
commit
0c8f998b9f
@ -0,0 +1,21 @@
|
||||
/* kaleidoscope_internal::device - Global device object for internal use
|
||||
* Copyright (C) 2019 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.h>
|
||||
|
||||
namespace kaleidoscope_internal {
|
||||
kaleidoscope::Device device;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/* kaleidoscope_internal::device - Global device object for internal use
|
||||
* Copyright (C) 2019 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/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace kaleidoscope_internal {
|
||||
extern kaleidoscope::Device device;
|
||||
}
|
Loading…
Reference in new issue