Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed MxSS ISO layouts in QMK configuator (hopefully) #3352

Merged
merged 16 commits into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added custom keycodes, along with their handlers
  • Loading branch information
MxBlu committed Jul 7, 2018
commit dbc03dd078c518394a5d007135cf1d0a51a19a73
2 changes: 1 addition & 1 deletion keyboards/mxss/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

LAYOUT( /* L1 */
KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL,
KC_TRNS, KC_MPLY, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_PSCR, KC_TRNS, KC_TRNS, RGB_VAI,
KC_TRNS, KC_MPLY, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_PSCR, FLED_VAD, FLED_VAI, FLED_MOD, RGB_VAI,
RESET, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_END, KC_TRNS, KC_TRNS, KC_TRNS, RGB_VAD,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MUTE, KC_VOLD, KC_VOLU, KC_TRNS, RGB_MOD, RGB_SAI, RGB_TOG,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_HUD, RGB_SAD, RGB_HUI
Expand Down
80 changes: 75 additions & 5 deletions keyboards/mxss/mxss.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,26 @@ void matrix_scan_kb(void) {
}

bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
// put your per-action keyboard code here
// runs for every action, just before processing by the firmware
// Handle custom keycodes for front LED operation
switch (keycode) {
case FLED_MOD: // Change between front LED operation modes (off, indicator, RGB)
if (record->event.pressed)
fled_mode_cycle();
break;

case FLED_VAI: // Increase the brightness of the front LEDs by FLED_VAL_STEP
if (record->event.pressed)
fled_val_increase();
break;

case FLED_VAD: // Decrease the brightness of the front LEDs by FLED_VAL_STEP
if (record->event.pressed)
fled_val_decrease();
break;

default:
break; // Process all other keycodes normally
}

return process_record_user(keycode, record);
}
Expand All @@ -87,7 +105,6 @@ void led_set_kb(uint8_t usb_led) {
}

uint32_t layer_state_set_kb(uint32_t state) {

// Determine and set colour of layer LED according to current layer
// if hue = sat = 0, leave LED off
uint8_t layer = biton32(state);
Expand Down Expand Up @@ -116,6 +133,59 @@ void eeprom_update_conf(void)
{
fled_config conf;
conf.mode = fled_mode;
conf.val = fled_val / FLED_VAL_STEP;

// Small hack to ensure max value is stored correctly
if (fled_val == 255)
conf.val = 256 / FLED_VAL_STEP;
else
conf.val = fled_val / FLED_VAL_STEP;

eeprom_update_word(EEPROM_FRONTLED_ADDR, conf.raw);
}
}

// Custom keycode functions

void fled_mode_cycle(void)
{
// FLED -> FLED_RGB -> FLED_INDI
switch (fled_mode) {
case FLED_OFF:
fled_mode = FLED_RGB;
break;

case FLED_RGB:
fled_mode = FLED_INDI;
break;

case FLED_INDI:
fled_mode = FLED_OFF;
break;
}

// Update stored config
// eeprom_update_conf();
}

void fled_val_increase(void)
{
// Increase val by FLED_VAL_STEP, handling the upper edge case
if (fled_val + FLED_VAL_STEP > 255)
fled_val = 255;
else
fled_val += FLED_VAL_STEP;

// Update stored config
// eeprom_update_conf();
}

void fled_val_decrease(void)
{
// Decrease val by FLED_VAL_STEP, handling the lower edge case
if (fled_val - FLED_VAL_STEP > 255)
fled_val = 255;
else
fled_val -= FLED_VAL_STEP;

// Update stored config
// eeprom_update_conf();
}
15 changes: 15 additions & 0 deletions keyboards/mxss/mxss_frontled.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#ifndef MXSS_FRONTLED_H
#define MXSS_FRONTLED_H

#include "quantum_keycodes.h"

// RGBLED index for front LEDs
#define RGBLIGHT_FLED1 14
#define RGBLIGHT_FLED2 15
Expand All @@ -45,6 +47,7 @@
#define FLED_CAPS_H 0
#define FLED_CAPS_S 255

// Config storage format for EEPROM
typedef union {
uint8_t raw;
struct {
Expand All @@ -53,12 +56,24 @@ typedef union {
};
} fled_config;

// Structure to store hue and saturation values
typedef struct _hs_set {
uint16_t hue;
uint8_t sat;
} hs_set;

// Custom keycodes for front LED control
enum fled_keycodes {
FLED_MOD = SAFE_RANGE,
FLED_VAI,
FLED_VAD
};

bool eeprom_is_valid(void); // Check if EEPROM has been set up
void eeprom_set_valid(bool valid); // Change validity state of EEPROM

void fled_mode_cycle(void); // Cycle between the 3 modes for the front LEDs
void fled_val_increase(void); // Increase the brightness of the front LEDs
void fled_val_decrease(void); // Decrease the brightness of the front LEDs

#endif //MXSS_FRONTLED_H