Compare commits

..

5 Commits

Author SHA1 Message Date
Jon Arintok
346cbd8816 Add 3 speed mousekey movement option (#2246)
This allows for constant, non-accelerated mouse movement, while retaining the original functionality. Configurable by a define.
2019-03-26 19:34:33 -07:00
Fabien Culpo
509668ca7c [Keymap] add redox/rev1:fculpo keymap (#5491) 2019-03-26 18:41:37 -07:00
Danny
d8371b3380 [Keymap] Update iris default (#5489)
* Update Iris default to include KC_GRV on base layer and match Configurator default

* Update default config
2019-03-26 18:40:01 -07:00
zvecr
9ef21d2e1c Refactor staryu to current standards and enable support for backlight keycodes (#5487) 2019-03-26 18:39:09 -07:00
Ryan Caltabiano
a0270b55e1 Fixing Ergodox_EZ rgb_led initialization 2019-03-26 16:34:02 -07:00
20 changed files with 1160 additions and 494 deletions

View File

@@ -1,48 +1,48 @@
# Mousekeys
Mousekeys is a feature that allows you to emulate a mouse using your keyboard. You can move the pointer around, click up to 5 buttons, and even scroll in all 4 directions. QMK uses the same algorithm as the X Window System MouseKeysAccel feature. You can read more about it [on Wikipedia](https://en.wikipedia.org/wiki/Mouse_keys).
Mousekeys is a feature that allows you to emulate a mouse using your keyboard. You can move the pointer around, click up to 5 buttons, and even scroll in all 4 directions.
## Adding Mousekeys to a Keymap
There are 2 ways to define how the mousekeys behave, using "[auto-accelerating](#configuring-the-behavior-of-mousekeys-with-auto-accelerated-movement)" or "[3-speed constant](#configuring-the-behavior-of-mousekeys-with-3-speed-constant-movement)" behavior.
There are two steps to adding Mousekeys support to your keyboard. You must enable support in the `rules.mk` file and you must map mouse actions to keys on your keyboard.
In either case, you will need to enable mousekeys in your makefile,
and add the relevant [keycodes](#mapping-mouse-actions-to-keyboard-keys) to your keymap.
### Adding Mousekeys Support in the `rules.mk`
#### Enable Mousekeys
To add support for Mousekeys you simply need to add a single line to your keymap's `rules.mk`:
To enable the mousekey functionality, add the following line to your keymap's `rules.mk`:
```
MOUSEKEY_ENABLE = yes
```
You can see an example here: https://github.com/qmk/qmk_firmware/blob/master/keyboards/clueboard/66/keymaps/mouse_keys/rules.mk
### Mapping Mouse Actions to Keyboard Keys
#### Mapping Mouse Actions to Keyboard Keys
You can use these keycodes within your keymap to map button presses to mouse actions:
|Key |Aliases |Description |
|----------------|---------|---------------------------|
|`KC_MS_UP` |`KC_MS_U`|Mouse Cursor Up |
|`KC_MS_DOWN` |`KC_MS_D`|Mouse Cursor Down |
|`KC_MS_LEFT` |`KC_MS_L`|Mouse Cursor Left |
|`KC_MS_RIGHT` |`KC_MS_R`|Mouse Cursor Right |
|`KC_MS_BTN1` |`KC_BTN1`|Mouse Button 1 |
|`KC_MS_BTN2` |`KC_BTN2`|Mouse Button 2 |
|`KC_MS_BTN3` |`KC_BTN3`|Mouse Button 3 |
|`KC_MS_BTN4` |`KC_BTN4`|Mouse Button 4 |
|`KC_MS_BTN5` |`KC_BTN5`|Mouse Button 5 |
|`KC_MS_WH_UP` |`KC_WH_U`|Mouse Wheel Up |
|`KC_MS_WH_DOWN` |`KC_WH_D`|Mouse Wheel Down |
|`KC_MS_WH_LEFT` |`KC_WH_L`|Mouse Wheel Left |
|`KC_MS_WH_RIGHT`|`KC_WH_R`|Mouse Wheel Right |
|`KC_MS_ACCEL0` |`KC_ACL0`|Set mouse acceleration to 0|
|`KC_MS_ACCEL1` |`KC_ACL1`|Set mouse acceleration to 1|
|`KC_MS_ACCEL2` |`KC_ACL2`|Set mouse acceleration to 2|
|Key |Aliases |Description |
|----------------|---------|-----------------------------------|
|`KC_MS_UP` |`KC_MS_U`|Mouse Cursor Up |
|`KC_MS_DOWN` |`KC_MS_D`|Mouse Cursor Down |
|`KC_MS_LEFT` |`KC_MS_L`|Mouse Cursor Left |
|`KC_MS_RIGHT` |`KC_MS_R`|Mouse Cursor Right |
|`KC_MS_BTN1` |`KC_BTN1`|Mouse Button 1 |
|`KC_MS_BTN2` |`KC_BTN2`|Mouse Button 2 |
|`KC_MS_BTN3` |`KC_BTN3`|Mouse Button 3 |
|`KC_MS_BTN4` |`KC_BTN4`|Mouse Button 4 |
|`KC_MS_BTN5` |`KC_BTN5`|Mouse Button 5 |
|`KC_MS_WH_UP` |`KC_WH_U`|Mouse Wheel Up |
|`KC_MS_WH_DOWN` |`KC_WH_D`|Mouse Wheel Down |
|`KC_MS_WH_LEFT` |`KC_WH_L`|Mouse Wheel Left |
|`KC_MS_WH_RIGHT`|`KC_WH_R`|Mouse Wheel Right |
|`KC_MS_ACCEL0` |`KC_ACL0`|Set mouse acceleration to 0(slow) |
|`KC_MS_ACCEL1` |`KC_ACL1`|Set mouse acceleration to 1(medium)|
|`KC_MS_ACCEL2` |`KC_ACL2`|Set mouse acceleration to 2(fast) |
You can see an example in the `_ML` here: https://github.com/qmk/qmk_firmware/blob/master/keyboards/clueboard/66/keymaps/mouse_keys/keymap.c#L46
## Configuring the Behavior of Mousekeys
## Configuring the Behavior of Mousekeys with auto-accelerated movement
This behavior is intended to emulate the X Window System MouseKeysAccel feature. You can read more about it [on Wikipedia](https://en.wikipedia.org/wiki/Mouse_keys).
The default speed for controlling the mouse with the keyboard is intentionally slow. You can adjust these parameters by adding these settings to your keymap's `config.h` file. All times are specified in milliseconds (ms).
@@ -55,27 +55,60 @@ The default speed for controlling the mouse with the keyboard is intentionally s
#define MOUSEKEY_WHEEL_TIME_TO_MAX 40
```
### `MOUSEKEY_DELAY`
#### `MOUSEKEY_DELAY`
When one of the mouse movement buttons is pressed this setting is used to define the delay between that button press and the mouse cursor moving. Some people find that small movements are impossible if this setting is too low, while settings that are too high feel sluggish.
### `MOUSEKEY_INTERVAL`
#### `MOUSEKEY_INTERVAL`
When a movement key is held down this specifies how long to wait between each movement report. Lower settings will translate into an effectively higher mouse speed.
### `MOUSEKEY_MAX_SPEED`
#### `MOUSEKEY_MAX_SPEED`
As a movement key is held down the speed of the mouse cursor will increase until it reaches `MOUSEKEY_MAX_SPEED`.
### `MOUSEKEY_TIME_TO_MAX`
#### `MOUSEKEY_TIME_TO_MAX`
How long you want to hold down a movement key for until `MOUSEKEY_MAX_SPEED` is reached. This controls how quickly your cursor will accelerate.
### `MOUSEKEY_WHEEL_MAX_SPEED`
#### `MOUSEKEY_WHEEL_MAX_SPEED`
The top speed for scrolling movements.
### `MOUSEKEY_WHEEL_TIME_TO_MAX`
#### `MOUSEKEY_WHEEL_TIME_TO_MAX`
How long you want to hold down a scroll key for until `MOUSEKEY_WHEEL_MAX_SPEED` is reached. This controls how quickly your scrolling will accelerate.
## Configuring the Behavior of Mousekeys with 3-speed constant movement
In your keymap's `config.h`, you must add the line:
```
#define MK_3_SPEED
```
Then you can precisely define 3 different speeds for both the cursor and the mouse wheel, and also whether speed selection is momentary or tap-to-select.
For each speed, you can specify how many milliseconds you want between reports(interval), and how far you want to it to move per report(offset).
For example:
```
#define MK_3_SPEED
#define MK_MOMENTARY_ACCEL // comment this out for tap-to-select acceleration
// cursor speeds:
#define MK_C_OFFSET_SLOW 1 // pixels
#define MK_C_INTERVAL_SLOW 100 // milliseconds
#define MK_C_OFFSET_MED 4
#define MK_C_INTERVAL_MED 16
#define MK_C_OFFSET_FAST 12
#define MK_C_INTERVAL_FAST 16
// scroll wheel speeds:
#define MK_W_OFFSET_SLOW 1 // wheel clicks
#define MK_W_INTERVAL_SLOW 400 // milliseconds
#define MK_W_OFFSET_MED 1
#define MK_W_INTERVAL_MED 200
#define MK_W_OFFSET_FAST 1
#define MK_W_INTERVAL_FAST 100
```
Medium values will be used as the default or unmodified speed.
The speed at which both the cursor and scrolling move can be selected with KC_ACL0, KC_ACL1, KC_ACL2 for slow, medium, and fast. However, if you leave MK_MOMENTARY_ACCEL defined then there is no need to ever send KC_ACL1, since that will be the unmodified speed.

View File

@@ -269,69 +269,68 @@ const is31_led g_is31_leds[DRIVER_LED_TOTAL] = {
};
__attribute__ ((weak))
const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
/*{row | col << 4}
| {x=0..224, y=0..64}
| | modifier
| | | */
{{0|(0<<4)}, {24.9*5, 16*0}, 0}, // LED 1 on right
{{0|(1<<4)}, {24.9*6, 16*0}, 0}, // LED 2
{{0|(2<<4)}, {24.9*7, 16*0}, 0}, // LED 3
{{0|(3<<4)}, {24.9*8, 16*0}, 0}, // LED 4
{{0|(4<<4)}, {24.9*9, 16*0}, 0}, // LED 5
{{ 8|(0<<4)}, {17.2* 8, 12.8*0}, 0}, // LED 1 on right > Key 6
{{ 9|(0<<4)}, {17.2* 9, 12.8*0}, 0}, // LED 2 > Key 7
{{10|(0<<4)}, {17.2*10, 12.8*0}, 0}, // LED 3 > Key 8
{{11|(0<<4)}, {17.2*11, 12.8*0}, 0}, // LED 4 > Key 9
{{12|(0<<4)}, {17.2*12, 12.8*0}, 0}, // LED 5 > Key 0
{{1|(5<<4)}, {24.9*5, 16*1}, 0}, // LED 6
{{1|(6<<4)}, {24.9*6, 16*1}, 0}, // LED 7
{{1|(7<<4)}, {24.9*7, 16*1}, 0}, // LED 8
{{1|(8<<4)}, {24.9*8, 16*1}, 0}, // LED 9
{{1|(9<<4)}, {24.9*9, 16*1}, 0}, // LED 10
{{ 8|(1<<4)}, {17.2* 8, 12.8*1}, 0}, // LED 6
{{ 9|(1<<4)}, {17.2* 9, 12.8*1}, 0}, // LED 7
{{10|(1<<4)}, {17.2*10, 12.8*1}, 0}, // LED 8
{{11|(1<<4)}, {17.2*11, 12.8*1}, 0}, // LED 9
{{12|(1<<4)}, {17.2*12, 12.8*1}, 0}, // LED 10
{{2|(5<<4)}, {24.9*5, 16*2}, 0}, // LED 11
{{2|(6<<4)}, {24.9*6, 16*2}, 0}, // LED 12
{{2|(7<<4)}, {24.9*7, 16*2}, 0}, // LED 13
{{2|(8<<4)}, {24.9*8, 16*2}, 0}, // LED 14
{{2|(9<<4)}, {24.9*9, 16*2}, 0}, // LED 15
{{ 8|(2<<4)}, {17.2* 8, 12.8*2}, 0}, // LED 11
{{ 9|(2<<4)}, {17.2* 9, 12.8*2}, 0}, // LED 12
{{10|(2<<4)}, {17.2*10, 12.8*2}, 0}, // LED 13
{{11|(2<<4)}, {17.2*11, 12.8*2}, 0}, // LED 14
{{12|(2<<4)}, {17.2*12, 12.8*2}, 0}, // LED 15
{{3|(5<<4)}, {24.9*5, 16*2}, 0}, // LED 16
{{3|(6<<4)}, {24.9*6, 16*2}, 0}, // LED 17
{{3|(7<<4)}, {24.9*7, 16*2}, 0}, // LED 18
{{3|(8<<4)}, {24.9*8, 16*2}, 0}, // LED 19
{{3|(9<<4)}, {24.9*9, 16*2}, 0}, // LED 20
{{ 8|(3<<4)}, {17.2* 8, 12.8*3}, 0}, // LED 16
{{ 9|(3<<4)}, {17.2* 9, 12.8*3}, 0}, // LED 17
{{10|(3<<4)}, {17.2*10, 12.8*3}, 0}, // LED 18
{{11|(3<<4)}, {17.2*11, 12.8*3}, 0}, // LED 19
{{12|(3<<4)}, {17.2*12, 12.8*3}, 0}, // LED 20
{{4|(6<<4)}, {24.9*6, 16*2}, 0}, // LED 21
{{4|(7<<4)}, {24.9*7, 16*2}, 0}, // LED 22
{{4|(8<<4)}, {24.9*8, 16*2}, 0}, // LED 23
{{4|(9<<4)}, {24.9*9, 16*2}, 0}, // LED 24
{{ 9|(4<<4)}, {17.2* 9, 12.8*4}, 1}, // LED 21
{{10|(4<<4)}, {17.2*10, 12.8*4}, 1}, // LED 22
{{11|(4<<4)}, {17.2*11, 12.8*4}, 1}, // LED 23
{{12|(4<<4)}, {17.2*12, 12.8*4}, 1}, // LED 24
{{0|(0<<4)}, {24.9*4, 16*0}, 0}, // LED 1 on left
{{0|(1<<4)}, {24.9*3, 16*0}, 0}, // LED 2
{{0|(2<<4)}, {24.9*2, 16*0}, 0}, // LED 3
{{0|(3<<4)}, {24.9*1, 16*0}, 0}, // LED 4
{{0|(4<<4)}, {24.9*0, 16*0}, 0}, // LED 5
{{ 5|(0<<4)}, {17.2* 5, 12.8*0}, 0}, // LED 1 on left > Key 5
{{ 4|(0<<4)}, {17.2* 4, 12.8*0}, 0}, // LED 2 > Key 4
{{ 3|(0<<4)}, {17.2* 3, 12.8*0}, 0}, // LED 3 > Key 3
{{ 2|(0<<4)}, {17.2* 2, 12.8*0}, 0}, // LED 4 > Key 2
{{ 1|(0<<4)}, {17.2* 1, 12.8*0}, 0}, // LED 5 > Key 1
{{1|(5<<4)}, {24.9*4, 16*1}, 0}, // LED 6
{{1|(6<<4)}, {24.9*3, 16*1}, 0}, // LED 7
{{1|(7<<4)}, {24.9*2, 16*1}, 0}, // LED 8
{{1|(8<<4)}, {24.9*1, 16*1}, 0}, // LED 9
{{1|(9<<4)}, {24.9*0, 16*1}, 0}, // LED 10
{{ 5|(1<<4)}, {17.2* 5, 12.8*1}, 0}, // LED 6
{{ 4|(1<<4)}, {17.2* 4, 12.8*1}, 0}, // LED 7
{{ 3|(1<<4)}, {17.2* 3, 12.8*1}, 0}, // LED 8
{{ 2|(1<<4)}, {17.2* 2, 12.8*1}, 0}, // LED 9
{{ 1|(1<<4)}, {17.2* 1, 12.8*1}, 0}, // LED 10
{{2|(5<<4)}, {24.9*4, 16*2}, 0}, // LED 11
{{2|(6<<4)}, {24.9*3, 16*2}, 0}, // LED 12
{{2|(7<<4)}, {24.9*2, 16*2}, 0}, // LED 13
{{2|(8<<4)}, {24.9*1, 16*2}, 0}, // LED 14
{{2|(9<<4)}, {24.9*0, 16*2}, 0}, // LED 15
{{ 5|(2<<4)}, {17.2* 5, 12.8*2}, 0}, // LED 11
{{ 4|(2<<4)}, {17.2* 4, 12.8*2}, 0}, // LED 12
{{ 3|(2<<4)}, {17.2* 3, 12.8*2}, 0}, // LED 13
{{ 2|(2<<4)}, {17.2* 2, 12.8*2}, 0}, // LED 14
{{ 1|(2<<4)}, {17.2* 1, 12.8*2}, 0}, // LED 15
{{3|(5<<4)}, {24.9*4, 16*2}, 0}, // LED 16
{{3|(6<<4)}, {24.9*3, 16*2}, 0}, // LED 17
{{3|(7<<4)}, {24.9*2, 16*2}, 0}, // LED 18
{{3|(8<<4)}, {24.9*1, 16*2}, 0}, // LED 19
{{3|(9<<4)}, {24.9*0, 16*2}, 0}, // LED 20
{{ 5|(3<<4)}, {17.2* 5, 12.8*3}, 0}, // LED 16
{{ 4|(3<<4)}, {17.2* 4, 12.8*3}, 0}, // LED 17
{{ 3|(3<<4)}, {17.2* 3, 12.8*3}, 0}, // LED 18
{{ 2|(3<<4)}, {17.2* 2, 12.8*3}, 0}, // LED 19
{{ 1|(3<<4)}, {17.2* 1, 12.8*3}, 0}, // LED 20
{{4|(6<<4)}, {24.9*3, 16*2}, 0}, // LED 21
{{4|(7<<4)}, {24.9*2, 16*2}, 0}, // LED 22
{{4|(8<<4)}, {24.9*1, 16*2}, 0}, // LED 23
{{4|(9<<4)}, {24.9*0, 16*2}, 0}, // LED 24
{{ 4|(4<<4)}, {17.2* 4, 12.8*4}, 1}, // LED 21
{{ 3|(4<<4)}, {17.2* 3, 12.8*4}, 1}, // LED 22
{{ 2|(4<<4)}, {17.2* 2, 12.8*4}, 1}, // LED 23
{{ 1|(4<<4)}, {17.2* 1, 12.8*4}, 1}, // LED 24 > Key Hack
};
#endif

View File

@@ -17,16 +17,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
/* Use I2C or Serial, not both */
#define USE_SERIAL
// #define USE_I2C
/* Select hand configuration */
#define MASTER_LEFT
// #define MASTER_RIGHT
// #define EE_HANDS
#define EE_HANDS
#undef RGBLED_NUM
#define RGBLIGHT_ANIMATIONS

View File

@@ -5,7 +5,7 @@ extern keymap_config_t keymap_config;
#define _QWERTY 0
#define _LOWER 1
#define _RAISE 2
#define _ADJUST 16
#define _ADJUST 3
enum custom_keycodes {
QWERTY = SAFE_RANGE,
@@ -20,25 +20,25 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//┌────────┬────────┬────────┬────────┬────────┬────────┐ ┌────────┬────────┬────────┬────────┬────────┬────────┐
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
//├────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┤
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
//├────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┤
KC_LSFT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┐ ┌────────┼────────┼────────┼────────┼────────┼────────┼────────┤
KC_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_HOME, KC_END, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
KC_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_GRV, KC_DEL, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
//└────────┴────────┴────────┴───┬────┴───┬────┴───┬────┴───┬────┘ └───┬────┴───┬────┴───┬────┴───┬────┴────────┴────────┴────────┘
KC_LGUI, LOWER, KC_ENT, KC_SPC, RAISE, KC_LALT
KC_LGUI, LOWER, KC_ENT, KC_SPC, RAISE, KC_RALT
// └────────┴────────┴────────┘ └────────┴────────┴────────┘
),
[_LOWER] = LAYOUT(
//┌────────┬────────┬────────┬────────┬────────┬────────┐ ┌────────┬────────┬────────┬────────┬────────┬────────┐
KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC,
KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_PGUP,
//├────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┤
RESET, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______,
RESET, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_PGDN,
//├────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┤
KC_DEL, _______, KC_LEFT, KC_RGHT, KC_UP, KC_LBRC, KC_RBRC, KC_P4, KC_P5, KC_P6, KC_PLUS, KC_PIPE,
KC_DEL, _______, KC_LEFT, KC_RGHT, KC_UP, KC_LBRC, KC_RBRC, KC_P4, KC_P5, KC_P6, KC_PLUS, KC_HOME,
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┐ ┌────────┼────────┼────────┼────────┼────────┼────────┼────────┤
BL_STEP, _______, _______, _______, KC_DOWN, KC_LCBR, KC_LPRN, KC_RPRN, KC_RCBR, KC_P1, KC_P2, KC_P3, KC_MINS, _______,
BL_STEP, _______, _______, _______, KC_DOWN, KC_LCBR, KC_LPRN, KC_RPRN, KC_RCBR, KC_P1, KC_P2, KC_P3, KC_MINS, KC_END,
//└────────┴────────┴────────┴───┬────┴───┬────┴───┬────┴───┬────┘ └───┬────┴───┬────┴───┬────┴───┬────┴────────┴────────┴────────┘
_______, _______, KC_DEL, KC_DEL, _______, KC_P0
// └────────┴────────┴────────┘ └────────┴────────┴────────┘
@@ -50,7 +50,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//├────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┤
RGB_TOG, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______,
//├────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┤
RGB_MOD, KC_MPRV, KC_MNXT, KC_VOLU, KC_PGUP, KC_UNDS, KC_EQL, KC_HOME, RGB_HUI, RGB_SAI, RGB_VAI, KC_BSLS,
RGB_MOD, KC_MPRV, KC_MNXT, KC_VOLU, KC_PGUP, KC_UNDS, KC_EQL, KC_HOME, RGB_HUI, RGB_SAI, RGB_VAI, _______,
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┐ ┌────────┼────────┼────────┼────────┼────────┼────────┼────────┤
KC_MUTE, KC_MSTP, KC_MPLY, KC_VOLD, KC_PGDN, KC_MINS, KC_LPRN, _______, KC_PLUS, KC_END, RGB_HUD, RGB_SAD, RGB_VAD, _______,
//└────────┴────────┴────────┴───┬────┴───┬────┴───┬────┴───┬────┘ └───┬────┴───┬────┴───┬────┴───┬────┴────────┴────────┴────────┘

View File

@@ -0,0 +1,34 @@
/*
Copyright 2018 Mattia Dal Ben <matthewdibi@gmail.com>
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, either version 2 of the License, or
(at your option) any later version.
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
/* Use I2C or Serial, not both */
#define USE_SERIAL
// #define USE_I2C
/* Select hand configuration */
#define MASTER_LEFT
//#define MASTER_RIGHT
//#define EE_HANDS
#undef RGBLED_NUM
#define RGBLIGHT_ANIMATIONS
#define RGBLED_NUM 14
#define RGBLIGHT_HUE_STEP 8
#define RGBLIGHT_SAT_STEP 8
#define RGBLIGHT_VAL_STEP 8

View File

@@ -0,0 +1,92 @@
#include QMK_KEYBOARD_H
extern keymap_config_t keymap_config;
// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them
// entirely and just use numbers.
#define _QWERTY 0
#define _SYMB 1
#define _NAV 2
#define _ADJUST 3
enum custom_keycodes {
QWERTY = SAFE_RANGE,
SYMB,
NAV,
ADJUST,
};
// Shortcut to make keymap more readable
#define SYM_L MO(_SYMB)
#define KC_ALAS LALT_T(KC_PAST)
#define KC_CTES LCTL_T(KC_ESC)
#define KC_CTQU RCTL_T(KC_QUOT)
#define KC_NAGR LT(_NAV, KC_GRV)
#define KC_NAMI LT(_NAV, KC_MINS)
#define KC_ADEN LT(_ADJUST, KC_END)
#define KC_ADPU LT(_ADJUST, KC_PGUP)
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_QWERTY] = LAYOUT(
//┌────────┬────────┬────────┬────────┬────────┬────────┐ ┌────────┬────────┬────────┬────────┬────────┬────────┐
KC_NAGR ,KC_1 ,KC_2 ,KC_3 ,KC_4 ,KC_5 , KC_6 ,KC_7 ,KC_8 ,KC_9 ,KC_0 ,KC_NAMI ,
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┐ ┌────────┼────────┼────────┼────────┼────────┼────────┼────────┤
KC_TAB ,KC_Q ,KC_W ,KC_E ,KC_R ,KC_T ,SYM_L , SYM_L ,KC_Y ,KC_U ,KC_I ,KC_O ,KC_P ,KC_EQL ,
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┤
KC_CTES ,KC_A ,KC_S ,KC_D ,KC_F ,KC_G ,KC_LBRC , KC_RBRC ,KC_H ,KC_J ,KC_K ,KC_L ,KC_SCLN ,KC_CTQU ,
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┐ ┌────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤
KC_LSFT ,KC_Z ,KC_X ,KC_C ,KC_V ,KC_B ,KC_ADPU ,KC_PGDN , KC_HOME ,KC_ADEN ,KC_N ,KC_M ,KC_COMM ,KC_DOT ,KC_SLSH ,KC_RSFT ,
//├────────┼────────┼────────┼────────┼────┬───┴────┬───┼────────┼────────┤ ├────────┼────────┼───┬────┴───┬────┼────────┼────────┼────────┼────────┤
KC_BSLS ,KC_PPLS ,KC_PMNS ,KC_ALAS , KC_LGUI , KC_BSPC ,KC_DEL , KC_ENT ,KC_SPC , KC_RALT , KC_LEFT ,KC_DOWN ,KC_UP ,KC_RGHT
//└────────┴────────┴────────┴────────┘ └────────┘ └────────┴────────┘ └────────┴────────┘ └────────┘ └────────┴────────┴────────┴────────┘
),
[_SYMB] = LAYOUT(
//┌────────┬────────┬────────┬────────┬────────┬────────┐ ┌────────┬────────┬────────┬────────┬────────┬────────┐
_______ ,KC_F1 ,KC_F2 ,KC_F3 ,KC_F4 ,KC_F5 , KC_F8 ,KC_F9 ,KC_F10 ,KC_F11 ,KC_F12 ,_______ ,
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┐ ┌────────┼────────┼────────┼────────┼────────┼────────┼────────┤
_______ ,KC_EXLM ,KC_AT ,KC_LCBR ,KC_RCBR ,KC_PIPE ,KC_F6 , KC_F7 ,XXXXXXX ,KC_KP_7 ,KC_KP_8 ,KC_KP_9 ,XXXXXXX ,_______ ,
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┤
_______ ,KC_HASH ,KC_DLR ,KC_LBRC ,KC_RBRC ,KC_GRV ,_______ , _______ ,XXXXXXX ,KC_KP_4 ,KC_KP_5 ,KC_KP_6 ,XXXXXXX ,XXXXXXX ,
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┐ ┌────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤
_______ ,KC_PERC ,KC_CIRC ,KC_LPRN ,KC_RPRN ,KC_TILD ,_______ ,_______ , _______ ,_______ ,XXXXXXX ,KC_KP_1 ,KC_KP_2 ,KC_KP_3 ,XXXXXXX ,XXXXXXX ,
//├────────┼────────┼────────┼────────┼────┬───┴────┬───┼────────┼────────┤ ├────────┼────────┼───┬────┴───┬────┼────────┼────────┼────────┼────────┤
_______ ,_______ ,_______ ,_______ , _______ , _______ ,_______ , _______ ,_______ , KC_KP_0 , KC_KP_0 ,KC_PDOT ,XXXXXXX ,XXXXXXX
//└────────┴────────┴────────┴────────┘ └────────┘ └────────┴────────┘ └────────┴────────┘ └────────┘ └────────┴────────┴────────┴────────┘
),
[_NAV] = LAYOUT(
//┌────────┬────────┬────────┬────────┬────────┬────────┐ ┌────────┬────────┬────────┬────────┬────────┬────────┐
_______ ,_______ ,_______ ,_______ ,_______ ,_______ , _______ ,_______ ,_______ ,_______ ,_______ ,_______ ,
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┐ ┌────────┼────────┼────────┼────────┼────────┼────────┼────────┤
XXXXXXX ,XXXXXXX ,KC_MS_U ,XXXXXXX ,KC_WH_U ,XXXXXXX ,_______ , _______ ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┤
XXXXXXX ,KC_MS_L ,KC_MS_D ,KC_MS_R ,KC_WH_D ,XXXXXXX ,_______ , _______ ,KC_LEFT ,KC_DOWN ,KC_UP ,KC_RIGHT,XXXXXXX ,XXXXXXX ,
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┐ ┌────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤
XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,_______ ,_______ , _______ ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,
//├────────┼────────┼────────┼────────┼────┬───┴────┬───┼────────┼────────┤ ├────────┼────────┼───┬────┴───┬────┼────────┼────────┼────────┼────────┤
XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX , KC_BTN1 , KC_BTN2 ,_______ , _______ ,_______ , XXXXXXX , XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX
//└────────┴────────┴────────┴────────┘ └────────┘ └────────┴────────┘ └────────┴────────┘ └────────┘ └────────┴────────┴────────┴────────┘
),
[_ADJUST] = LAYOUT(
//┌────────┬────────┬────────┬────────┬────────┬────────┐ ┌────────┬────────┬────────┬────────┬────────┬────────┐
XXXXXXX ,KC_F1 ,KC_F2 ,KC_F3 ,KC_F4 ,KC_F5 , KC_F6 ,KC_F7 ,KC_F8 ,KC_F9 ,KC_F10 ,KC_F11 ,
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┐ ┌────────┼────────┼────────┼────────┼────────┼────────┼────────┤
XXXXXXX ,RESET ,RGB_M_P ,RGB_TOG ,RGB_MOD ,RGB_HUD ,RGB_HUI , RGB_SAD ,RGB_SAI ,RGB_VAD ,RGB_VAI ,XXXXXXX ,XXXXXXX ,KC_F12 ,
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┤ ├────────┼────────┼────────┼────────┼────────┼────────┼────────┤
XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX , XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,
//├────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┐ ┌────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┤
XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,_______ ,XXXXXXX , XXXXXXX ,_______ ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX ,
//├────────┼────────┼────────┼────────┼────┬───┴────┬───┼────────┼────────┤ ├────────┼────────┼───┬────┴───┬────┼────────┼────────┼────────┼────────┤
XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX , XXXXXXX , XXXXXXX ,XXXXXXX , XXXXXXX ,XXXXXXX , XXXXXXX , XXXXXXX ,XXXXXXX ,XXXXXXX ,XXXXXXX
//└────────┴────────┴────────┴────────┘ └────────┘ └────────┴────────┘ └────────┴────────┘ └────────┘ └────────┴────────┴────────┴────────┘
)
};

View File

@@ -0,0 +1,399 @@
[
{
"name": "Redox/rev1",
"author": "Fabien Culpo",
"switchMount": "cherry",
"plate": false,
"pcb": false
},
[
{
"x": 3.5
},
"#\n3",
{
"x": 10.5
},
"*\n8"
],
[
{
"y": -0.875,
"x": 2.5
},
"@\n2",
{
"x": 1
},
"$\n4",
{
"x": 8.5
},
"&\n7",
{
"x": 1
},
"(\n9"
],
[
{
"y": -0.875,
"x": 5.5
},
"%\n5",
{
"x": 6.5
},
"^\n6"
],
[
{
"y": -0.875,
"x": 0.25,
"a": 5,
"w": 1.25
},
"`\nLayer 2\n\n\n\n\n~",
{
"a": 4
},
"!\n1",
{
"x": 14.5
},
")\n0",
{
"a": 5,
"w": 1.25
},
"_\nLayer 2\n\n\n\n\n-"
],
[
{
"y": -0.625,
"x": 6.5
},
"Layer 1",
{
"x": 4.5
},
"Layer 1"
],
[
{
"y": -0.75,
"x": 3.5,
"a": 4
},
"E",
{
"x": 10.5
},
"I"
],
[
{
"y": -0.875,
"x": 2.5
},
"W",
{
"x": 1
},
"R",
{
"x": 8.5
},
"U",
{
"x": 1
},
"O"
],
[
{
"y": -0.875,
"x": 5.5
},
"T",
{
"x": 6.5
},
"Y"
],
[
{
"y": -0.875,
"x": 0.25,
"a": 7,
"w": 1.25
},
"TAB",
{
"a": 4
},
"Q",
{
"x": 14.5
},
"P",
{
"a": 5,
"w": 1.25
},
"+\n="
],
[
{
"y": -0.625,
"x": 6.5,
"a": 7,
"h": 1.5
},
"[",
{
"x": 4.5,
"h": 1.5
},
"]"
],
[
{
"y": -0.75,
"x": 3.5,
"a": 4
},
"D",
{
"x": 10.5
},
"K"
],
[
{
"y": -0.875,
"x": 2.5
},
"S",
{
"x": 1,
"n": true
},
"F",
{
"x": 8.5,
"n": true
},
"J",
{
"x": 1
},
"L"
],
[
{
"y": -0.875,
"x": 5.5
},
"G",
{
"x": 6.5
},
"H"
],
[
{
"y": -0.875,
"x": 0.25,
"a": 5,
"w": 1.25
},
"ESC\nCTRL",
{
"a": 4
},
"A",
{
"x": 14.5
},
":\n;",
{
"a": 5,
"w": 1.25
},
"'\nCTRL"
],
[
{
"y": -0.375,
"x": 3.5,
"a": 4
},
"C",
{
"x": 10.5
},
"<\n,"
],
[
{
"y": -0.875,
"x": 2.5
},
"X",
{
"x": 1
},
"V",
{
"x": 8.5
},
"M",
{
"x": 1
},
">\n."
],
[
{
"y": -0.875,
"x": 5.5
},
"B",
{
"x": 6.5
},
"N"
],
[
{
"y": -0.875,
"x": 0.25,
"a": 5,
"w": 1.25
},
"SHIFT",
{
"a": 4
},
"Z",
{
"x": 14.5
},
"?\n/",
{
"a": 5,
"w": 1.25
},
"SHIFT"
],
[
{
"y": -0.375,
"x": 3.5
},
"*\nALT",
{
"x": 10.5
},
"Left"
],
[
{
"y": -0.875,
"x": 2.5
},
"-",
{
"x": 12.5
},
"Down"
],
[
{
"y": -0.75,
"x": 0.5
},
"|\n\n\n\n\n\n\\",
"+",
{
"x": 14.5
},
"Up",
{
"sb": "cherry",
"st": "MX1A-21xx"
},
"Right"
],
[
{
"r": 15,
"y": -2.625,
"x": 5.75,
"a": 7,
"w": 1.25
},
"SUPER"
],
[
{
"r": 30,
"rx": 6.5,
"ry": 4.25,
"y": -1,
"a": 5
},
"PgUp\nLay. 3",
{
"a": 7
},
"PgDn"
],
[
{
"h": 1.5
},
"Bksp",
{
"h": 1.5
},
"Del"
],
[
{
"r": -30,
"rx": 13,
"y": -1,
"x": -2
},
"Home",
{
"a": 5
},
"End\nLay. 3"
],
[
{
"x": -2,
"a": 7,
"h": 1.5
},
"Enter",
{
"h": 1.5
},
"Space"
],
[
{
"r": -15,
"rx": 0,
"ry": 0,
"y": 7.75,
"x": 11.75,
"w": 1.25
},
"ALT"
]
]

View File

@@ -0,0 +1,18 @@
# A tweaked keymap for Redox
This keymap modifies the [default keymap](https://github.com/qmk/qmk_firmware/tree/master/keyboards/redox) for the awesome [Redox keyboard](https://github.com/mattdibi/redox-keyboard) designed by Mattia Dal Ben.
Also heavily inspired by nrichers layout.
![fculpo Layout Image](https://i.imgur.com/OXT8boJ.png)
## Changes to the default keymap
These keymap changes are meant to improve the usability of the layout in everyday use:
- Move `GUI` (`SUPER`) key to where default left `CTRL` is
- Move `/?` into usual location next to right `SHIFT` - the default flash from Falbatech put `\|` here (might not be the Redox default?), which felt unintuitive
- Put `\|` into bottom-left spot where `GUI` (`SUPER`) was - had to go somewhere and this bottom-left placement sort of balances with the almost bottom-right `/?`
- Change default `ESC` into `ESC` on tap, `CTRL` on hold - Love the UNIX-ey `CTRL` key location and wanted to keep `ESC` in the original position
- Change default `'` above right `SHIFT` into `'` on tap, `CTRL` on hold - Love the UNIX-ey CTRL key location, but it can give you 'left claw hand', which a second, mirrored `CTRL` key fixes
- Add `F11` and `F12` keys to two layers - needed on macOS if you want to control volume up and down from your keyboard (not shown, on a different layer)S

View File

@@ -0,0 +1,2 @@
RGBLIGHT_ENABLE = yes

View File

@@ -1,52 +0,0 @@
#include "backlight.h"
#include <avr/pgmspace.h>
/* backlighting */
void init_backlight_led(void)
{
DDRC |= (1<<PC2 | 1<<PC7);
DDRD |= (1<<PD5 | 1<<PD6);
DDRB |= (1<<PB0);
}
void backlight_led_off(uint8_t index)
{
switch (index) {
case 0:
PORTC |= (1<<PC2);
break;
case 1:
PORTC |= (1<<PC7);
break;
case 2:
PORTD |= (1<<PD5);
break;
case 3:
PORTD |= (1<<PD6);
break;
case 4:
PORTB |= (1<<PB0);
break;
}
}
void backlight_led_on(uint8_t index)
{
switch (index) {
case 0:
PORTC &= ~(1<<PC2);
break;
case 1:
PORTC &= ~(1<<PC7);
break;
case 2:
PORTD &= ~(1<<PD5);
break;
case 3:
PORTD &= ~(1<<PD6);
break;
case 4:
PORTB &= ~(1<<PB0);
break;
}
}

View File

@@ -1,12 +1,21 @@
#ifndef STARYU_BL
#define STARYU_BL
/*
Copyright 2019
#include <stdint.h>
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, either version 2 of the License, or
(at your option) any later version.
void init_backlight_led(void);
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.
void backlight_led_on(uint8_t index);
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
void backlight_led_off(uint8_t index);
#endif
// Add backwards compatibility for existing keymaps
#define backlight_led_off(i) backlight_set_value(i, 0)
#define backlight_led_on(i) backlight_set_value(i, 1)

View File

@@ -14,8 +14,7 @@ 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/>.
*/
#ifndef CONFIG_H
#define CONFIG_H
#pragma once
#include "config_common.h"
@@ -32,43 +31,38 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MATRIX_COLS 5
/* key matrix pins */
#define MATRIX_ROW_PINS { }
#define MATRIX_ROW_PINS { NO_PIN }
#define MATRIX_COL_PINS { D0, D1, D2, D3, D4 }
#define UNUSED_PINS
// from light_ws2812_config @
// https://github.com/kairyu/tmk_keyboard_custom/tree/master/keyboard/staryu
#define RGB_DI_PIN C6
#define RGBLIGHT_ANIMATIONS
#define RGBLED_NUM 1 // Number of LEDs
/* COL2ROW or ROW2COL */
#define DIODE_DIRECTION COL2ROW
#define RGB_DI_PIN C6
#define RGBLED_NUM 1 // Number of LEDs
#define RGBLIGHT_ANIMATIONS
// #ifdef RGB_DI_PIN
// #define RGBLIGHT_HUE_STEP 8
// #define RGBLIGHT_SAT_STEP 8
// #define RGBLIGHT_VAL_STEP 8
// #define RGBLIGHT_LIMIT_VAL 255 /* The maximum brightness level */
// #define RGBLIGHT_SLEEP /* If defined, the RGB lighting will be switched off when the host goes to sleep */
// /*== all animations enable ==*/
// #define RGBLIGHT_ANIMATIONS
// /*== or choose animations ==*/
// #define RGBLIGHT_EFFECT_BREATHING
// #define RGBLIGHT_EFFECT_RAINBOW_MOOD
// #define RGBLIGHT_EFFECT_RAINBOW_SWIRL
// #define RGBLIGHT_EFFECT_SNAKE
// #define RGBLIGHT_EFFECT_KNIGHT
// #define RGBLIGHT_EFFECT_CHRISTMAS
// #define RGBLIGHT_EFFECT_STATIC_GRADIENT
// #define RGBLIGHT_EFFECT_RGB_TEST
// #define RGBLIGHT_EFFECT_ALTERNATING
// #endif
#define BACKLIGHT_LEVELS 1 // either on/off
#define RGBLIGHT_LIMIT_VAL 200
/* Set 0 if debouncing isn't needed */
#define DEBOUNCING_DELAY 5
// TODO backlighting
#define BACKLIGHT_LEVELS 10
// #define BACKLIGHT_PIN B7
/*
Backlight: C2, C7, D5, D6, B0
switch (index) {
case 0:
PORTC &= ~(1<<PC2);
break;
case 1:
PORTC &= ~(1<<PC7);
break;
case 2:
PORTD &= ~(1<<PD5);
break;
case 3:
PORTD &= ~(1<<PD6);
break;
case 4:
PORTB &= ~(1<<PB0);
break;
*/
#endif

View File

@@ -20,62 +20,85 @@ enum layers {
_LAYER0,
_LAYER1,
_LAYER2,
_LAYER3
_LAYER3,
_LAYER4
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_LAYER0] = LAYOUT(
/* ┌─────────┬─────────┬─────────┐ */
KC_UP, TO(_LAYER1),
/* ├─────────┼─────────┼─────────┤ */
KC_LEFT, KC_DOWN, KC_RIGHT
/* └─────────┴─────────┴─────────┘ */
),
[_LAYER1] = LAYOUT(
/* ┌─────────┬─────────┬─────────┐ */
KC_PGUP, TO(_LAYER2),
/* ├─────────┼─────────┼─────────┤ */
KC_HOME, KC_PGDN, KC_END
/* └─────────┴─────────┴─────────┘ */
),
[_LAYER2] = LAYOUT(
/* ┌─────────┬─────────┬─────────┐ */
KC_MSEL, TO(_LAYER3),
/* ├─────────┼─────────┼─────────┤ */
KC_MPRV, KC_MPLY, KC_MNXT
/* └─────────┴─────────┴─────────┘ */
),
[_LAYER3] = LAYOUT(
/* ┌─────────┬─────────┬─────────┐ */
KC_MS_U, TO(_LAYER4),
/* ├─────────┼─────────┼─────────┤ */
KC_MS_L, KC_MS_D, KC_MS_R
/* └─────────┴─────────┴─────────┘ */
),
[_LAYER4] = LAYOUT(
/* ┌─────────┬─────────┬─────────┐ */
XXXXXXX, TO(_LAYER0),
/* ├─────────┼─────────┼─────────┤ */
RGB_TOG, BL_TOGG, BL_STEP
/* └─────────┴─────────┴─────────┘ */
),
const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = {
/* Keymap 0
* ,-----------.
* | |Up |Fn0|
* |---+---+---|
* |Lef|Dow|Rig|
* `-----------'
*/
LAYOUT( KC_UP, TO(_LAYER1), KC_LEFT,KC_DOWN,KC_RIGHT ),
/* Keymap 1
* ,-----------.
* | |PgU|Fn1|
* |---+---+---|
* |Hom|PgD|End|
* `-----------'
*/
LAYOUT( KC_PGUP,TO(_LAYER2), KC_HOME,KC_PGDN,KC_END ),
/* Keymap 2
* ,-----------.
* | |Sel|Fn2|
* |---+---+---|
* |Pre|Pla|Nex|
* `-----------'
*/
LAYOUT( KC_MSEL,TO(_LAYER3), KC_MPRV,KC_MPLY,KC_MNXT ),
/* Keymap 3
* ,-----------.
* | |MsU|Fn3|
* |---+---+---|
* |MsL|MsD|MsR|
* `-----------'
*/
LAYOUT( KC_MS_U,TO(_LAYER0), KC_MS_L,KC_MS_D,KC_MS_R ),
// /* Keymap 4
// * ,-----------.
// * | |Fn6|Fn4|
// * |---+---+---|
// * |Fn7|Fn5|Fn8|
// * `-----------'
// */
// LAYOUT( FN6, FN4, FN7, FN5, FN8 ),
};
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
return MACRO_NONE ;
void eeconfig_init_user(void) {
// use the non noeeprom versions, to write these values to EEPROM too
rgblight_enable();
rgblight_mode(RGBLIGHT_MODE_BREATHING+1);
backlight_enable();
}
void matrix_init_user(void) {
void keyboard_post_init_user(void) {
//layer_state_set_user is not called for inital state - set it here
rgblight_sethsv_noeeprom_white();
}
void matrix_scan_user(void) {
}
void led_set_user(uint8_t usb_led) {
uint32_t layer_state_set_user(uint32_t state) {
switch (biton32(state)) {
case _LAYER1:
rgblight_sethsv_noeeprom_cyan();
break;
case _LAYER2:
rgblight_sethsv_noeeprom_magenta();
break;
case _LAYER3:
rgblight_sethsv_noeeprom_red();
break;
case _LAYER4:
rgblight_sethsv_noeeprom_orange();
break;
case _LAYER0:
default: // for any other layers, or the default layer
rgblight_sethsv_noeeprom_white();
break;
}
return state;
}

View File

@@ -1,10 +1,6 @@
# MCU name
MCU = atmega32u2
BOOTLOADER = lufa-dfu
SRC = backlight_staryu.c
# Processor frequency.
# This will define a symbol, F_CPU, in all source code files equal to the
# processor frequency in Hz. You can then use this symbol in your source code to
@@ -40,21 +36,43 @@ F_USB = $(F_CPU)
# Interrupt driven control endpoint task(+60)
OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
# Bootloader selection
# Teensy halfkay
# Pro Micro caterina
# Atmel DFU atmel-dfu
# LUFA DFU lufa-dfu
# QMK DFU qmk-dfu
# atmega32a bootloadHID
BOOTLOADER = lufa-dfu
# Boot Section Size in *bytes*
OPT_DEFS += -DBOOTLOADER_SIZE=4096
# If you don't know the bootloader type, then you can specify the
# Boot Section Size in *bytes* by uncommenting out the OPT_DEFS line
# Teensy halfKay 512
# Teensy++ halfKay 1024
# Atmel DFU loader 4096
# LUFA bootloader 4096
# USBaspLoader 2048
# OPT_DEFS += -DBOOTLOADER_SIZE=4096
# Build Options
# comment out to disable the options.
#
BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = no # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = yes # Console for debug(+400)
COMMAND_ENABLE = no # Commands for debug and configuration
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
NKRO_ENABLE = no # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
BACKLIGHT_ENABLE = yes # In-switch LEDs
AUDIO_ENABLE = no # There is no available timer or pin for audio on the NovelPad
RGBLIGHT_ENABLE = yes # RGB LEDs for underglow, installed and enabled by default for the NovelPad
BOOTMAGIC_ENABLE = lite # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = no # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
CONSOLE_ENABLE = no # Console for debug(+400)
COMMAND_ENABLE = no # Commands for debug and configuration
# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
NKRO_ENABLE = no # USB Nkey Rollover
BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality on B7 by default
RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
MIDI_ENABLE = no # MIDI support (+2400 to 4200, depending on config)
UNICODE_ENABLE = no # Unicode
BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
AUDIO_ENABLE = no # Audio output on port C6
FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400)

View File

@@ -15,12 +15,30 @@ 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 "staryu.h"
#include "backlight_staryu.h"
// for keyboard subdirectory level init functions
// @Override
void matrix_init_kb(void) {
// call user level keymaps, if any
init_backlight_led();
matrix_init_user();
#ifdef BACKLIGHT_ENABLE
#ifdef BACKLIGHT_PIN
#pragma error "BACKLIGHT_PIN must stay undefined otherwise software pwm is incorrectly used"
#endif
#define BACKLIGHT_PIN_COUNT 5
static const pin_t backlight_pins[BACKLIGHT_PIN_COUNT] = { C2, C7, D5, D6, B0 };
void backlight_init_ports(void) {
for (uint8_t index = 0; index < BACKLIGHT_PIN_COUNT; index++) {
setPinOutput(backlight_pins[index]);
}
}
void backlight_set_value(uint8_t index, uint8_t level) {
writePin(backlight_pins[index], !!level);
}
void backlight_set(uint8_t level) {
for (uint8_t index = 0; index < BACKLIGHT_PIN_COUNT; index++) {
backlight_set_value(index, level);
}
}
#endif //BACKLIGHT_ENABLE

View File

@@ -14,15 +14,19 @@ 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/>.
*/
#ifndef KB_H
#define KB_H
#pragma once
#include "quantum.h"
#define LAYOUT( \
K00, K01, \
K10, K11, K12 \
K00, K01, \
K10, K11, K12 \
) { \
{ K00, K01, K12, K11, K10 }, \
}
#ifdef BACKLIGHT_ENABLE
void backlight_set_value(uint8_t index, uint8_t level);
#endif

View File

@@ -1 +0,0 @@
Note: This board will not flash if the "g_rgb_leds" const is not set to weak in the ergodox_ez.c file

View File

@@ -1,70 +1,2 @@
/* placeholder file */
#include QMK_KEYBOARD_H
#ifdef RGB_MATRIX_ENABLE
const rgb_led g_rgb_leds[DRIVER_LED_TOTAL] = {
/*{row | col << 4}
| {x=0..224, y=0..64}
| | modifier
| | | */
{{0|(0<<4)}, {24.9*5, 16*0}, 0}, // LED 1 on right
{{0|(1<<4)}, {24.9*6, 16*0}, 0}, // LED 2
{{0|(2<<4)}, {24.9*7, 16*0}, 0}, // LED 3
{{0|(3<<4)}, {24.9*8, 16*0}, 0}, // LED 4
{{0|(4<<4)}, {24.9*9, 16*0}, 0}, // LED 5
{{1|(5<<4)}, {24.9*5, 16*1}, 0}, // LED 6
{{1|(6<<4)}, {24.9*6, 16*1}, 0}, // LED 7
{{1|(7<<4)}, {24.9*7, 16*1}, 0}, // LED 8
{{1|(8<<4)}, {24.9*8, 16*1}, 0}, // LED 9
{{1|(9<<4)}, {24.9*9, 16*1}, 0}, // LED 10
{{2|(5<<4)}, {24.9*5, 16*2}, 0}, // LED 11
{{2|(6<<4)}, {24.9*6, 16*2}, 0}, // LED 12
{{2|(7<<4)}, {24.9*7, 16*2}, 0}, // LED 13
{{2|(8<<4)}, {24.9*8, 16*2}, 0}, // LED 14
{{2|(9<<4)}, {24.9*9, 16*2}, 0}, // LED 15
{{3|(5<<4)}, {24.9*5, 16*2}, 0}, // LED 16
{{3|(6<<4)}, {24.9*6, 16*2}, 0}, // LED 17
{{3|(7<<4)}, {24.9*7, 16*2}, 0}, // LED 18
{{3|(8<<4)}, {24.9*8, 16*2}, 0}, // LED 19
{{3|(9<<4)}, {24.9*9, 16*2}, 0}, // LED 20
{{4|(6<<4)}, {24.9*6, 16*2}, 1}, // LED 21
{{4|(7<<4)}, {24.9*7, 16*2}, 1}, // LED 22
{{4|(8<<4)}, {24.9*8, 16*2}, 1}, // LED 23
{{4|(9<<4)}, {24.9*9, 16*2}, 1}, // LED 24
{{0|(0<<4)}, {24.9*4, 16*0}, 0}, // LED 1 on left
{{0|(1<<4)}, {24.9*3, 16*0}, 0}, // LED 2
{{0|(2<<4)}, {24.9*2, 16*0}, 0}, // LED 3
{{0|(3<<4)}, {24.9*1, 16*0}, 0}, // LED 4
{{0|(4<<4)}, {24.9*0, 16*0}, 0}, // LED 5
{{1|(5<<4)}, {24.9*4, 16*1}, 0}, // LED 6
{{1|(6<<4)}, {24.9*3, 16*1}, 0}, // LED 7
{{1|(7<<4)}, {24.9*2, 16*1}, 0}, // LED 8
{{1|(8<<4)}, {24.9*1, 16*1}, 0}, // LED 9
{{1|(9<<4)}, {24.9*0, 16*1}, 0}, // LED 10
{{2|(5<<4)}, {24.9*4, 16*2}, 0}, // LED 11
{{2|(6<<4)}, {24.9*3, 16*2}, 0}, // LED 12
{{2|(7<<4)}, {24.9*2, 16*2}, 0}, // LED 13
{{2|(8<<4)}, {24.9*1, 16*2}, 0}, // LED 14
{{2|(9<<4)}, {24.9*0, 16*2}, 0}, // LED 15
{{3|(5<<4)}, {24.9*4, 16*2}, 0}, // LED 16
{{3|(6<<4)}, {24.9*3, 16*2}, 0}, // LED 17
{{3|(7<<4)}, {24.9*2, 16*2}, 0}, // LED 18
{{3|(8<<4)}, {24.9*1, 16*2}, 0}, // LED 19
{{3|(9<<4)}, {24.9*0, 16*2}, 0}, // LED 20
{{4|(6<<4)}, {24.9*3, 16*2}, 1}, // LED 21
{{4|(7<<4)}, {24.9*2, 16*2}, 1}, // LED 22
{{4|(8<<4)}, {24.9*1, 16*2}, 1}, // LED 23
{{4|(9<<4)}, {24.9*0, 16*2}, 1}, // LED 24
};
#endif

View File

@@ -23,13 +23,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "debug.h"
#include "mousekey.h"
inline int8_t times_inv_sqrt2(int8_t x) {
// 181/256 is pretty close to 1/sqrt(2)
// 0.70703125 0.707106781
// 1 too small for x=99 and x=198
// This ends up being a mult and discard lower 8 bits
return (x * 181) >> 8;
}
static report_mouse_t mouse_report = {};
static uint8_t mousekey_repeat = 0;
static uint8_t mousekey_accel = 0;
static report_mouse_t mouse_report = {0};
static void mousekey_debug(void);
static uint8_t mousekey_accel = 0;
static uint8_t mousekey_repeat = 0;
static uint16_t last_timer = 0;
#ifndef MK_3_SPEED
/*
@@ -52,155 +63,256 @@ uint8_t mk_time_to_max = MOUSEKEY_TIME_TO_MAX;
uint8_t mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED;
uint8_t mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX;
static uint16_t last_timer = 0;
inline int8_t times_inv_sqrt2(int8_t x)
{
// 181/256 is pretty close to 1/sqrt(2)
// 0.70703125 0.707106781
// 1 too small for x=99 and x=198
// This ends up being a mult and discard lower 8 bits
return (x * 181) >> 8;
static uint8_t move_unit(void) {
uint16_t unit;
if (mousekey_accel & (1<<0)) {
unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed)/4;
} else if (mousekey_accel & (1<<1)) {
unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed)/2;
} else if (mousekey_accel & (1<<2)) {
unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed);
} else if (mousekey_repeat == 0) {
unit = MOUSEKEY_MOVE_DELTA;
} else if (mousekey_repeat >= mk_time_to_max) {
unit = MOUSEKEY_MOVE_DELTA * mk_max_speed;
} else {
unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed * mousekey_repeat) / mk_time_to_max;
}
return (unit > MOUSEKEY_MOVE_MAX ? MOUSEKEY_MOVE_MAX : (unit == 0 ? 1 : unit));
}
static uint8_t move_unit(void)
{
uint16_t unit;
if (mousekey_accel & (1<<0)) {
unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed)/4;
} else if (mousekey_accel & (1<<1)) {
unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed)/2;
} else if (mousekey_accel & (1<<2)) {
unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed);
} else if (mousekey_repeat == 0) {
unit = MOUSEKEY_MOVE_DELTA;
} else if (mousekey_repeat >= mk_time_to_max) {
unit = MOUSEKEY_MOVE_DELTA * mk_max_speed;
} else {
unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed * mousekey_repeat) / mk_time_to_max;
}
return (unit > MOUSEKEY_MOVE_MAX ? MOUSEKEY_MOVE_MAX : (unit == 0 ? 1 : unit));
static uint8_t wheel_unit(void) {
uint16_t unit;
if (mousekey_accel & (1<<0)) {
unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed)/4;
} else if (mousekey_accel & (1<<1)) {
unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed)/2;
} else if (mousekey_accel & (1<<2)) {
unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed);
} else if (mousekey_repeat == 0) {
unit = MOUSEKEY_WHEEL_DELTA;
} else if (mousekey_repeat >= mk_wheel_time_to_max) {
unit = MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed;
} else {
unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed * mousekey_repeat) / mk_wheel_time_to_max;
}
return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit));
}
static uint8_t wheel_unit(void)
{
uint16_t unit;
if (mousekey_accel & (1<<0)) {
unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed)/4;
} else if (mousekey_accel & (1<<1)) {
unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed)/2;
} else if (mousekey_accel & (1<<2)) {
unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed);
} else if (mousekey_repeat == 0) {
unit = MOUSEKEY_WHEEL_DELTA;
} else if (mousekey_repeat >= mk_wheel_time_to_max) {
unit = MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed;
} else {
unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed * mousekey_repeat) / mk_wheel_time_to_max;
}
return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit));
void mousekey_task(void) {
if (timer_elapsed(last_timer) < (mousekey_repeat ? mk_interval : mk_delay*10)) {
return;
}
if (mouse_report.x == 0 && mouse_report.y == 0 && mouse_report.v == 0 && mouse_report.h == 0) {
return;
}
if (mousekey_repeat != UINT8_MAX) mousekey_repeat++;
if (mouse_report.x > 0) mouse_report.x = move_unit();
if (mouse_report.x < 0) mouse_report.x = move_unit() * -1;
if (mouse_report.y > 0) mouse_report.y = move_unit();
if (mouse_report.y < 0) mouse_report.y = move_unit() * -1;
/* diagonal move [1/sqrt(2)] */
if (mouse_report.x && mouse_report.y) {
mouse_report.x = times_inv_sqrt2(mouse_report.x);
mouse_report.y = times_inv_sqrt2(mouse_report.y);
}
if (mouse_report.v > 0) mouse_report.v = wheel_unit();
if (mouse_report.v < 0) mouse_report.v = wheel_unit() * -1;
if (mouse_report.h > 0) mouse_report.h = wheel_unit();
if (mouse_report.h < 0) mouse_report.h = wheel_unit() * -1;
mousekey_send();
}
void mousekey_task(void)
{
if (timer_elapsed(last_timer) < (mousekey_repeat ? mk_interval : mk_delay*10))
return;
if (mouse_report.x == 0 && mouse_report.y == 0 && mouse_report.v == 0 && mouse_report.h == 0)
return;
if (mousekey_repeat != UINT8_MAX)
mousekey_repeat++;
if (mouse_report.x > 0) mouse_report.x = move_unit();
if (mouse_report.x < 0) mouse_report.x = move_unit() * -1;
if (mouse_report.y > 0) mouse_report.y = move_unit();
if (mouse_report.y < 0) mouse_report.y = move_unit() * -1;
/* diagonal move [1/sqrt(2)] */
if (mouse_report.x && mouse_report.y) {
mouse_report.x = times_inv_sqrt2(mouse_report.x);
mouse_report.x = mouse_report.x == 0 ? 1 : mouse_report.x;
mouse_report.y = times_inv_sqrt2(mouse_report.y);
mouse_report.y = mouse_report.y == 0 ? 1 : mouse_report.y;
}
if (mouse_report.v > 0) mouse_report.v = wheel_unit();
if (mouse_report.v < 0) mouse_report.v = wheel_unit() * -1;
if (mouse_report.h > 0) mouse_report.h = wheel_unit();
if (mouse_report.h < 0) mouse_report.h = wheel_unit() * -1;
mousekey_send();
void mousekey_on(uint8_t code) {
if (code == KC_MS_UP) mouse_report.y = move_unit() * -1;
else if (code == KC_MS_DOWN) mouse_report.y = move_unit();
else if (code == KC_MS_LEFT) mouse_report.x = move_unit() * -1;
else if (code == KC_MS_RIGHT) mouse_report.x = move_unit();
else if (code == KC_MS_WH_UP) mouse_report.v = wheel_unit();
else if (code == KC_MS_WH_DOWN) mouse_report.v = wheel_unit() * -1;
else if (code == KC_MS_WH_LEFT) mouse_report.h = wheel_unit() * -1;
else if (code == KC_MS_WH_RIGHT) mouse_report.h = wheel_unit();
else if (code == KC_MS_BTN1) mouse_report.buttons |= MOUSE_BTN1;
else if (code == KC_MS_BTN2) mouse_report.buttons |= MOUSE_BTN2;
else if (code == KC_MS_BTN3) mouse_report.buttons |= MOUSE_BTN3;
else if (code == KC_MS_BTN4) mouse_report.buttons |= MOUSE_BTN4;
else if (code == KC_MS_BTN5) mouse_report.buttons |= MOUSE_BTN5;
else if (code == KC_MS_ACCEL0) mousekey_accel |= (1<<0);
else if (code == KC_MS_ACCEL1) mousekey_accel |= (1<<1);
else if (code == KC_MS_ACCEL2) mousekey_accel |= (1<<2);
}
void mousekey_on(uint8_t code)
{
if (code == KC_MS_UP) mouse_report.y = move_unit() * -1;
else if (code == KC_MS_DOWN) mouse_report.y = move_unit();
else if (code == KC_MS_LEFT) mouse_report.x = move_unit() * -1;
else if (code == KC_MS_RIGHT) mouse_report.x = move_unit();
else if (code == KC_MS_WH_UP) mouse_report.v = wheel_unit();
else if (code == KC_MS_WH_DOWN) mouse_report.v = wheel_unit() * -1;
else if (code == KC_MS_WH_LEFT) mouse_report.h = wheel_unit() * -1;
else if (code == KC_MS_WH_RIGHT) mouse_report.h = wheel_unit();
else if (code == KC_MS_BTN1) mouse_report.buttons |= MOUSE_BTN1;
else if (code == KC_MS_BTN2) mouse_report.buttons |= MOUSE_BTN2;
else if (code == KC_MS_BTN3) mouse_report.buttons |= MOUSE_BTN3;
else if (code == KC_MS_BTN4) mouse_report.buttons |= MOUSE_BTN4;
else if (code == KC_MS_BTN5) mouse_report.buttons |= MOUSE_BTN5;
else if (code == KC_MS_ACCEL0) mousekey_accel |= (1<<0);
else if (code == KC_MS_ACCEL1) mousekey_accel |= (1<<1);
else if (code == KC_MS_ACCEL2) mousekey_accel |= (1<<2);
}
void mousekey_off(uint8_t code)
{
if (code == KC_MS_UP && mouse_report.y < 0) mouse_report.y = 0;
else if (code == KC_MS_DOWN && mouse_report.y > 0) mouse_report.y = 0;
else if (code == KC_MS_LEFT && mouse_report.x < 0) mouse_report.x = 0;
else if (code == KC_MS_RIGHT && mouse_report.x > 0) mouse_report.x = 0;
else if (code == KC_MS_WH_UP && mouse_report.v > 0) mouse_report.v = 0;
else if (code == KC_MS_WH_DOWN && mouse_report.v < 0) mouse_report.v = 0;
else if (code == KC_MS_WH_LEFT && mouse_report.h < 0) mouse_report.h = 0;
else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0) mouse_report.h = 0;
else if (code == KC_MS_BTN1) mouse_report.buttons &= ~MOUSE_BTN1;
else if (code == KC_MS_BTN2) mouse_report.buttons &= ~MOUSE_BTN2;
else if (code == KC_MS_BTN3) mouse_report.buttons &= ~MOUSE_BTN3;
else if (code == KC_MS_BTN4) mouse_report.buttons &= ~MOUSE_BTN4;
else if (code == KC_MS_BTN5) mouse_report.buttons &= ~MOUSE_BTN5;
else if (code == KC_MS_ACCEL0) mousekey_accel &= ~(1<<0);
else if (code == KC_MS_ACCEL1) mousekey_accel &= ~(1<<1);
else if (code == KC_MS_ACCEL2) mousekey_accel &= ~(1<<2);
if (mouse_report.x == 0 && mouse_report.y == 0 && mouse_report.v == 0 && mouse_report.h == 0)
mousekey_repeat = 0;
}
void mousekey_send(void)
{
mousekey_debug();
host_mouse_send(&mouse_report);
last_timer = timer_read();
}
void mousekey_clear(void)
{
mouse_report = (report_mouse_t){};
void mousekey_off(uint8_t code) {
if (code == KC_MS_UP && mouse_report.y < 0) mouse_report.y = 0;
else if (code == KC_MS_DOWN && mouse_report.y > 0) mouse_report.y = 0;
else if (code == KC_MS_LEFT && mouse_report.x < 0) mouse_report.x = 0;
else if (code == KC_MS_RIGHT && mouse_report.x > 0) mouse_report.x = 0;
else if (code == KC_MS_WH_UP && mouse_report.v > 0) mouse_report.v = 0;
else if (code == KC_MS_WH_DOWN && mouse_report.v < 0) mouse_report.v = 0;
else if (code == KC_MS_WH_LEFT && mouse_report.h < 0) mouse_report.h = 0;
else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0) mouse_report.h = 0;
else if (code == KC_MS_BTN1) mouse_report.buttons &= ~MOUSE_BTN1;
else if (code == KC_MS_BTN2) mouse_report.buttons &= ~MOUSE_BTN2;
else if (code == KC_MS_BTN3) mouse_report.buttons &= ~MOUSE_BTN3;
else if (code == KC_MS_BTN4) mouse_report.buttons &= ~MOUSE_BTN4;
else if (code == KC_MS_BTN5) mouse_report.buttons &= ~MOUSE_BTN5;
else if (code == KC_MS_ACCEL0) mousekey_accel &= ~(1<<0);
else if (code == KC_MS_ACCEL1) mousekey_accel &= ~(1<<1);
else if (code == KC_MS_ACCEL2) mousekey_accel &= ~(1<<2);
if (mouse_report.x == 0 && mouse_report.y == 0 && mouse_report.v == 0 && mouse_report.h == 0)
mousekey_repeat = 0;
mousekey_accel = 0;
}
static void mousekey_debug(void)
{
if (!debug_mouse) return;
print("mousekey [btn|x y v h](rep/acl): [");
phex(mouse_report.buttons); print("|");
print_decs(mouse_report.x); print(" ");
print_decs(mouse_report.y); print(" ");
print_decs(mouse_report.v); print(" ");
print_decs(mouse_report.h); print("](");
print_dec(mousekey_repeat); print("/");
print_dec(mousekey_accel); print(")\n");
#else /* #ifndef MK_3_SPEED */
enum {
mkspd_slow,
mkspd_med,
mkspd_fast,
mkspd_COUNT
};
static uint8_t mk_speed = mkspd_med;
#ifdef MK_MOMENTARY_ACCEL
static uint8_t mkspd_DEFAULT = mkspd_med;
#endif
static uint16_t last_timer_c = 0;
static uint16_t last_timer_w = 0;
uint16_t c_offsets[mkspd_COUNT] = {
MK_C_OFFSET_SLOW, MK_C_OFFSET_MED, MK_C_OFFSET_FAST
};
uint16_t c_intervals[mkspd_COUNT] = {
MK_C_INTERVAL_SLOW, MK_C_INTERVAL_MED, MK_C_INTERVAL_FAST
};
uint16_t w_offsets[mkspd_COUNT] = {
MK_W_OFFSET_SLOW, MK_W_OFFSET_MED, MK_W_OFFSET_FAST
};
uint16_t w_intervals[mkspd_COUNT] = {
MK_W_INTERVAL_SLOW, MK_W_INTERVAL_MED, MK_W_INTERVAL_FAST
};
void mousekey_task(void) {
// report cursor and scroll movement independently
report_mouse_t const tmpmr = mouse_report;
if ((mouse_report.x || mouse_report.y) && timer_elapsed(last_timer_c) > c_intervals[mk_speed]) {
mouse_report.h = 0;
mouse_report.v = 0;
mousekey_send();
last_timer_c = last_timer;
mouse_report = tmpmr;
}
if ((mouse_report.h || mouse_report.v) && timer_elapsed(last_timer_w) > w_intervals[mk_speed]) {
mouse_report.x = 0;
mouse_report.y = 0;
mousekey_send();
last_timer_w = last_timer;
mouse_report = tmpmr;
}
}
void adjust_speed(void) {
uint16_t const c_offset = c_offsets[mk_speed];
uint16_t const w_offset = w_offsets[mk_speed];
if (mouse_report.x > 0) mouse_report.x = c_offset;
if (mouse_report.x < 0) mouse_report.x = c_offset * -1;
if (mouse_report.y > 0) mouse_report.y = c_offset;
if (mouse_report.y < 0) mouse_report.y = c_offset * -1;
if (mouse_report.h > 0) mouse_report.h = w_offset;
if (mouse_report.h < 0) mouse_report.h = w_offset * -1;
if (mouse_report.v > 0) mouse_report.v = w_offset;
if (mouse_report.v < 0) mouse_report.v = w_offset * -1;
// adjust for diagonals
if (mouse_report.x && mouse_report.y) {
mouse_report.x = times_inv_sqrt2(mouse_report.x);
mouse_report.y = times_inv_sqrt2(mouse_report.y);
}
if (mouse_report.h && mouse_report.v) {
mouse_report.h = times_inv_sqrt2(mouse_report.h);
mouse_report.v = times_inv_sqrt2(mouse_report.v);
}
}
void mousekey_on(uint8_t code) {
uint16_t const c_offset = c_offsets[mk_speed];
uint16_t const w_offset = w_offsets[mk_speed];
uint8_t const old_speed = mk_speed;
if (code == KC_MS_UP) mouse_report.y = c_offset * -1;
else if (code == KC_MS_DOWN) mouse_report.y = c_offset;
else if (code == KC_MS_LEFT) mouse_report.x = c_offset * -1;
else if (code == KC_MS_RIGHT) mouse_report.x = c_offset;
else if (code == KC_MS_WH_UP) mouse_report.v = w_offset;
else if (code == KC_MS_WH_DOWN) mouse_report.v = w_offset * -1;
else if (code == KC_MS_WH_LEFT) mouse_report.h = w_offset * -1;
else if (code == KC_MS_WH_RIGHT) mouse_report.h = w_offset;
else if (code == KC_MS_BTN1) mouse_report.buttons |= MOUSE_BTN1;
else if (code == KC_MS_BTN2) mouse_report.buttons |= MOUSE_BTN2;
else if (code == KC_MS_BTN3) mouse_report.buttons |= MOUSE_BTN3;
else if (code == KC_MS_BTN4) mouse_report.buttons |= MOUSE_BTN4;
else if (code == KC_MS_BTN5) mouse_report.buttons |= MOUSE_BTN5;
else if (code == KC_MS_ACCEL0) mk_speed = mkspd_slow;
else if (code == KC_MS_ACCEL1) mk_speed = mkspd_med;
else if (code == KC_MS_ACCEL2) mk_speed = mkspd_fast;
if (mk_speed != old_speed) adjust_speed();
}
void mousekey_off(uint8_t code) {
#ifdef MK_MOMENTARY_ACCEL
uint8_t const old_speed = mk_speed;
#endif
if (code == KC_MS_UP && mouse_report.y < 0) mouse_report.y = 0;
else if (code == KC_MS_DOWN && mouse_report.y > 0) mouse_report.y = 0;
else if (code == KC_MS_LEFT && mouse_report.x < 0) mouse_report.x = 0;
else if (code == KC_MS_RIGHT && mouse_report.x > 0) mouse_report.x = 0;
else if (code == KC_MS_WH_UP && mouse_report.v > 0) mouse_report.v = 0;
else if (code == KC_MS_WH_DOWN && mouse_report.v < 0) mouse_report.v = 0;
else if (code == KC_MS_WH_LEFT && mouse_report.h < 0) mouse_report.h = 0;
else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0) mouse_report.h = 0;
else if (code == KC_MS_BTN1) mouse_report.buttons &= ~MOUSE_BTN1;
else if (code == KC_MS_BTN2) mouse_report.buttons &= ~MOUSE_BTN2;
else if (code == KC_MS_BTN3) mouse_report.buttons &= ~MOUSE_BTN3;
else if (code == KC_MS_BTN4) mouse_report.buttons &= ~MOUSE_BTN4;
else if (code == KC_MS_BTN5) mouse_report.buttons &= ~MOUSE_BTN5;
#ifdef MK_MOMENTARY_ACCEL
else if (code == KC_MS_ACCEL0) mk_speed = mkspd_DEFAULT;
else if (code == KC_MS_ACCEL1) mk_speed = mkspd_DEFAULT;
else if (code == KC_MS_ACCEL2) mk_speed = mkspd_DEFAULT;
if (mk_speed != old_speed) adjust_speed();
#endif
}
#endif /* #ifndef MK_3_SPEED */
void mousekey_send(void) {
mousekey_debug();
host_mouse_send(&mouse_report);
last_timer = timer_read();
}
void mousekey_clear(void) {
mouse_report = (report_mouse_t){};
mousekey_repeat = 0;
mousekey_accel = 0;
}
static void mousekey_debug(void) {
if (!debug_mouse) return;
print("mousekey [btn|x y v h](rep/acl): [");
phex(mouse_report.buttons); print("|");
print_decs(mouse_report.x); print(" ");
print_decs(mouse_report.y); print(" ");
print_decs(mouse_report.v); print(" ");
print_decs(mouse_report.h); print("](");
print_dec(mousekey_repeat); print("/");
print_dec(mousekey_accel); print(")\n");
}

View File

@@ -16,23 +16,25 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MOUSEKEY_H
#define MOUSEKEY_H
#define MOUSEKEY_H
#endif
#include <stdbool.h>
#include "host.h"
#ifndef MK_3_SPEED
/* max value on report descriptor */
#ifndef MOUSEKEY_MOVE_MAX
#define MOUSEKEY_MOVE_MAX 127
#define MOUSEKEY_MOVE_MAX 127
#elif MOUSEKEY_MOVE_MAX > 127
#error MOUSEKEY_MOVE_MAX needs to be smaller than 127
#error MOUSEKEY_MOVE_MAX needs to be smaller than 127
#endif
#ifndef MOUSEKEY_WHEEL_MAX
#define MOUSEKEY_WHEEL_MAX 127
#define MOUSEKEY_WHEEL_MAX 127
#elif MOUSEKEY_WHEEL_MAX > 127
#error MOUSEKEY_WHEEL_MAX needs to be smaller than 127
#error MOUSEKEY_WHEEL_MAX needs to be smaller than 127
#endif
#ifndef MOUSEKEY_MOVE_DELTA
@@ -60,6 +62,47 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MOUSEKEY_WHEEL_TIME_TO_MAX 40
#endif
#else /* #ifndef MK_3_SPEED */
#ifndef MK_C_OFFSET_SLOW
#define MK_C_OFFSET_SLOW 1
#endif
#ifndef MK_C_INTERVAL_SLOW
#define MK_C_INTERVAL_SLOW 100
#endif
#ifndef MK_C_OFFSET_MED
#define MK_C_OFFSET_MED 4
#endif
#ifndef MK_C_INTERVAL_MED
#define MK_C_INTERVAL_MED 16
#endif
#ifndef MK_C_OFFSET_FAST
#define MK_C_OFFSET_FAST 12
#endif
#ifndef MK_C_INTERVAL_FAST
#define MK_C_INTERVAL_FAST 16
#endif
#ifndef MK_W_OFFSET_SLOW
#define MK_W_OFFSET_SLOW 1
#endif
#ifndef MK_W_INTERVAL_SLOW
#define MK_W_INTERVAL_SLOW 400
#endif
#ifndef MK_W_OFFSET_MED
#define MK_W_OFFSET_MED 1
#endif
#ifndef MK_W_INTERVAL_MED
#define MK_W_INTERVAL_MED 200
#endif
#ifndef MK_W_OFFSET_FAST
#define MK_W_OFFSET_FAST 1
#endif
#ifndef MK_W_INTERVAL_FAST
#define MK_W_INTERVAL_FAST 100
#endif
#endif /* #ifndef MK_3_SPEED */
#ifdef __cplusplus
extern "C" {
@@ -72,7 +115,6 @@ extern uint8_t mk_time_to_max;
extern uint8_t mk_wheel_max_speed;
extern uint8_t mk_wheel_time_to_max;
void mousekey_task(void);
void mousekey_on(uint8_t code);
void mousekey_off(uint8_t code);
@@ -82,5 +124,3 @@ void mousekey_send(void);
#ifdef __cplusplus
}
#endif
#endif