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.
79 lines
2.3 KiB
79 lines
2.3 KiB
8 years ago
|
/* -*- mode: c++ -*-
|
||
7 years ago
|
* Kaleidoscope-SpaceCadet -- Space Cadet Shift Extended
|
||
6 years ago
|
* Copyright (C) 2016, 2017, 2018 Keyboard.io, Inc, Ben Gemperline
|
||
6 years ago
|
* Copyright (C) 2019 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
|
*/
|
||
|
|
||
|
#pragma once
|
||
|
|
||
5 years ago
|
#include "kaleidoscope/Runtime.h"
|
||
7 years ago
|
#include <Kaleidoscope-Ranges.h>
|
||
8 years ago
|
|
||
7 years ago
|
#ifndef SPACECADET_MAP_END
|
||
6 years ago
|
#define SPACECADET_MAP_END (kaleidoscope::plugin::SpaceCadet::KeyBinding) { Key_NoKey, Key_NoKey, 0 }
|
||
7 years ago
|
#endif
|
||
8 years ago
|
|
||
6 years ago
|
#define Key_SpaceCadetEnable Key(kaleidoscope::ranges::SC_FIRST)
|
||
|
#define Key_SpaceCadetDisable Key(kaleidoscope::ranges::SC_LAST)
|
||
7 years ago
|
|
||
7 years ago
|
namespace kaleidoscope {
|
||
6 years ago
|
namespace plugin {
|
||
7 years ago
|
|
||
|
class SpaceCadet : public kaleidoscope::Plugin {
|
||
7 years ago
|
public:
|
||
7 years ago
|
//Internal Class
|
||
7 years ago
|
//Declarations for the modifier key mapping
|
||
7 years ago
|
class KeyBinding {
|
||
|
public:
|
||
|
//Empty constructor; set the vars separately
|
||
|
KeyBinding(void) {}
|
||
|
//Constructor with input and output
|
||
|
KeyBinding(Key input_, Key output_);
|
||
|
//Constructor with all three set
|
||
|
KeyBinding(Key input_, Key output_, uint16_t timeout_);
|
||
|
//The key that is pressed
|
||
|
Key input;
|
||
|
//the key that is sent
|
||
|
Key output;
|
||
|
//The timeout (default to global timeout)
|
||
|
uint16_t timeout = 0;
|
||
|
//The flag (set to 0)
|
||
|
bool flagged = false;
|
||
|
//the start time for this key press
|
||
6 years ago
|
uint16_t start_time = 0;
|
||
7 years ago
|
};
|
||
7 years ago
|
|
||
|
SpaceCadet(void);
|
||
|
|
||
|
//Methods
|
||
7 years ago
|
static void enable(void);
|
||
|
static void disable(void);
|
||
|
static bool active(void);
|
||
7 years ago
|
|
||
|
//Publically accessible variables
|
||
|
static uint16_t time_out; // The global timeout in milliseconds
|
||
7 years ago
|
static SpaceCadet::KeyBinding * map; // The map of key bindings
|
||
7 years ago
|
|
||
5 years ago
|
EventHandlerResult onKeyswitchEvent(Key &mapped_key, KeyAddr key_addr, uint8_t key_state);
|
||
7 years ago
|
|
||
7 years ago
|
private:
|
||
7 years ago
|
static bool disabled;
|
||
7 years ago
|
};
|
||
6 years ago
|
}
|
||
|
|
||
|
}
|
||
8 years ago
|
|
||
6 years ago
|
extern kaleidoscope::plugin::SpaceCadet SpaceCadet;
|