Skip to content

Commit

Permalink
Merge branch 'master' into pr_host_keymap
Browse files Browse the repository at this point in the history
  • Loading branch information
noseglasses authored Dec 4, 2019
2 parents 7198b5f + 9158661 commit ea011a8
Show file tree
Hide file tree
Showing 81 changed files with 4,407 additions and 213 deletions.
55 changes: 55 additions & 0 deletions examples/Internal/Sketch_Exploration/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This stub makefile for a Kaleidoscope example pulls in all the targets
# required to build the example

UNAME_S := $(shell uname -s)

ifeq ($(UNAME_S),Darwin)
SKETCHBOOK_DIR ?= $(HOME)/Documents/Arduino
PACKAGE_DIR ?= $(HOME)/Library/Arduino15
else
SKETCHBOOK_DIR ?= $(HOME)/Arduino
PACKAGE_DIR ?= $(HOME)/.arduino15
endif


ARDUINO_INSTALLED_ENV=$(shell ls -dt $(PACKAGE_DIR)/packages/keyboardio/hardware/avr 2>/dev/null |head -n 1)
MANUALLY_INSTALLED_ENV=$(shell ls -dt $(SKETCHBOOK_DIR)/hardware/keyboardio/avr 2>/dev/null |head -n 1)



ifneq ("$(wildcard $(ARDUINO_INSTALLED_ENV)/boards.txt)","")

ifneq ("$(wildcard $(MANUALLY_INSTALLED_ENV)/boards.txt)","")

$(info ***************************************************************************)
$(info It appears that you have installed two copies of Kaleidoscope. One copy was)
$(info installed using Arduino's "Board Manager", while the other was installed by)
$(info hand, probably using "git".)
$(info )
$(info This will likely cause some trouble as you try to build keyboard firmware)
$(info using Kaleidoscope. You may want to remove either: )
$(info )
$(info $(PACKAGE_DIR)/packages/keyboardio/ which was installed using Arduino)
$(info )
$(info or)
$(info )
$(info $(SKETCHBOOK_DIR)/hardware/keyboardio/ which was installed by hand.)
$(info )
$(info ***************************************************************************)
$(info )

endif

BOARD_HARDWARE_PATH = $(ARDUINO_INSTALLED_ENV)
KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR ?= build-tools/makefiles/
KALEIDOSCOPE_BUILDER_DIR ?= $(ARDUINO_INSTALLED_ENV)/libraries/Kaleidoscope/bin/



endif


BOARD_HARDWARE_PATH ?= $(SKETCHBOOK_DIR)/hardware
KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR ?= keyboardio/avr/build-tools/makefiles/

include $(BOARD_HARDWARE_PATH)/$(KALEIDOSCOPE_PLUGIN_MAKEFILE_DIR)/rules.mk
139 changes: 139 additions & 0 deletions examples/Internal/Sketch_Exploration/Sketch_Exploration.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/* -*- mode: c++ -*-
* Basic -- A very basic Kaleidoscope example
* Copyright (C) 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.h"


// This example demonstrates how a plugin can gather information about
// the keymap at compile time, e.g. to adapt its behavior, safe resources, ...

/* *INDENT-OFF* */
KEYMAPS(
[0] = KEYMAP_STACKED
(
Key_NoKey, Key_1, Key_1, Key_1, Key_4, Key_5, Key_NoKey,
Key_Backtick, Key_Q, Key_W, Key_E, Key_R, Key_T, Key_Tab,
Key_PageUp, Key_A, Key_S, Key_D, Key_F, Key_G,
Key_PageDown, Key_Z, Key_X, Key_C, Key_V, Key_B, Key_Escape,

Key_LeftControl, Key_Backspace, Key_LeftGui, Key_LeftShift,
Key_NoKey,

Key_skip, Key_6, Key_7, Key_8, Key_9, Key_0, Key_skip,
Key_Enter, Key_Y, Key_U, Key_I, Key_O, Key_P, Key_Equals,
Key_H, Key_J, Key_K, Key_L, Key_Semicolon, Key_Quote,
Key_skip, Key_N, Key_M, Key_Comma, Key_Period, Key_Slash, Key_Minus,

Key_RightShift, Key_RightAlt, Key_Spacebar, Key_RightControl,
Key_NoKey
),
)
/* *INDENT-ON* */

using namespace kaleidoscope::sketch_exploration;

class BPlugin : public kaleidoscope::Plugin {};
class CPlugin : public kaleidoscope::Plugin {};

// A simple plugin that defines just one hook.
//
class APlugin : public kaleidoscope::Plugin {

public:
APlugin() : has_key_1_{false} {}

template<typename _Sketch>
kaleidoscope::EventHandlerResult exploreSketch() {

// Static keymap exploration

typedef typename _Sketch::StaticKeymap K;

// Important: Always make sure to call _Sketch::StaticKeymap's methods
// in a constexpr context. This is done by
// passing their value to a constexpr temporary variable.

constexpr uint8_t n_key_1 = K::collect(NumKeysEqual{Key_1});
static_assert(n_key_1 == 3, "Error determining key count");

constexpr bool has_key_1 = K::collect(HasKey{Key_1});
static_assert(has_key_1, "Error querying key existence");
has_key_1_ = has_key_1; // Assign the temporary that was computed
// at compile time.

constexpr Key max_key = K::collect(MaxKeyRaw{});
static_assert(max_key.getRaw() > 0, "");

static_assert(K::getKey(0 /*layer*/, KeyAddr{2, 3}) == Key_D,
"Key lookup failed");

constexpr auto n_layers = K::nLayers();
constexpr auto layer_size = K::layerSize();

// Plugin exploration
//
// Use macros ENTRY_TYPE, ENRTY_IS_LAST, PLUGIN_POSITION,
// PLUGIN_IS_REGISTERED and NUM_OCCURRENCES to retreive information
// about the plugins that are registered in the sketch.

typedef typename _Sketch::Plugins P;

static_assert(std::is_same<ENTRY_TYPE(P, 0), APlugin>::value, "");
static_assert(std::is_same<ENTRY_TYPE(P, 1), BPlugin>::value, "");

static_assert(P::size == 3, "");

static_assert(!ENRTY_IS_LAST(P, 0), "");
static_assert(!ENRTY_IS_LAST(P, 1), "");
static_assert(ENRTY_IS_LAST(P, 2), "");

static_assert(PLUGIN_POSITION(P, APlugin) == 0, "");
static_assert(PLUGIN_POSITION(P, BPlugin) == 1, "");
static_assert(PLUGIN_POSITION(P, CPlugin) == -1, "");

static_assert(PLUGIN_IS_REGISTERED(P, APlugin) == true, "");
static_assert(PLUGIN_IS_REGISTERED(P, BPlugin) == true, "");
static_assert(PLUGIN_IS_REGISTERED(P, CPlugin) == false, "");

static_assert(NUM_OCCURRENCES(P, APlugin) == 2, "");
static_assert(NUM_OCCURRENCES(P, BPlugin) == 1, "");
static_assert(NUM_OCCURRENCES(P, CPlugin) == 0, "");

return kaleidoscope::EventHandlerResult::OK;
}

private:

bool has_key_1_;
};

APlugin a_plugin1, a_plugin2;
BPlugin b_plugin;

KALEIDOSCOPE_INIT_PLUGINS(
a_plugin1,
b_plugin,
a_plugin2
)

void setup() {
Kaleidoscope.setup();
}

void loop() {
Kaleidoscope.loop();
}
21 changes: 21 additions & 0 deletions src/Kaleidoscope-Hardware-Dygma-Raise.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* -*- mode: c++ -*-
* kaleidoscope::device::dygma::Raise -- Kaleidoscope device plugin for Dygma Raise
* Copyright (C) 2017-2019 Keyboard.io, Inc
* Copyright (C) 2017-2019 Dygma Lab S.L.
*
* 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

#include "kaleidoscope/device/dygma/Raise.h"
1 change: 1 addition & 0 deletions src/kaleidoscope/Kaleidoscope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Kaleidoscope_::setup(void) {
// properly.
device().serialPort().begin(9600);

kaleidoscope::sketch_exploration::pluginsExploreSketch();
kaleidoscope::Hooks::onSetup();

device().setup();
Expand Down
3 changes: 2 additions & 1 deletion src/kaleidoscope/Kaleidoscope.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void setup();
#include <math.h>
#include <stdint.h>

#include KALEIDOSCOPE_HARDWARE_H
#include "kaleidoscope/device/device.h"
#include "kaleidoscope/device/key_indexes.h"
#include "kaleidoscope_internal/device.h"
#include "kaleidoscope_internal/deprecations.h"
Expand Down Expand Up @@ -87,6 +87,7 @@ static constexpr DEPRECATED(LED_COUNT) uint8_t LED_COUNT = kaleidoscope_internal
#include "kaleidoscope/key_events.h"
#include "kaleidoscope/hid.h"
#include "kaleidoscope/layers.h"
#include "kaleidoscope_internal/sketch_exploration/sketch_exploration.h"
#include "kaleidoscope/macro_map.h"
#include "kaleidoscope_internal/event_dispatch.h"
#include "kaleidoscope_internal/LEDModeManager.h"
Expand Down
2 changes: 1 addition & 1 deletion src/kaleidoscope/KeyAddr.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

#pragma once

#include KALEIDOSCOPE_HARDWARE_H
#include "kaleidoscope/device/device.h"

typedef kaleidoscope::Device::KeyAddr KeyAddr;
59 changes: 0 additions & 59 deletions src/kaleidoscope/device/ATMega32U4Keyboard.h

This file was deleted.

Loading

0 comments on commit ea011a8

Please sign in to comment.