Display a useful error when using the old-style API

Override the copy constructor of `combo_t`, so that we can display an error when
initializing using the old-style API.

Fixes #8.

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/365/head
Gergely Nagy 6 years ago
parent d97c860dfb
commit df68cd510d

@ -31,6 +31,13 @@
} \ } \
} }
#define _MAGICCOMBO_API_CHANGE \
"The MagicCombo API changed in an incompatible way, you will need to\n" \
"upgrade.\n" \
"\n" \
"Please see the `UPGRADING.md` document shipped with the source:\n" \
" https://github.com/keyboardio/Kaleidoscope-MagicCombo/blob/master/UPGRADING.md"
namespace kaleidoscope { namespace kaleidoscope {
class MagicCombo : public kaleidoscope::Plugin { class MagicCombo : public kaleidoscope::Plugin {
@ -43,8 +50,15 @@ class MagicCombo : public kaleidoscope::Plugin {
typedef struct combo_t { typedef struct combo_t {
uint32_t left_hand, right_hand; uint32_t left_hand, right_hand;
private: template <typename T>
combo_t(byte left, byte right) {} struct always_false {
enum { value = false };
};
template <typename T>
combo_t(T l, T r) {
static_assert(always_false<T>::value, _DEPRECATE(_MAGICCOMBO_API_CHANGE));
}
} combo_t; } combo_t;
MagicCombo(void) {} MagicCombo(void) {}

Loading…
Cancel
Save