Skip to content

Commit

Permalink
disperse durgod/k3x0/ source files to keyboard folders
Browse files Browse the repository at this point in the history
Relocate/duplicate the source files in `durgod/k3x0/` to `durgod/k310/(base/)` and `durgod/k320/(base/)` as needed.
  • Loading branch information
noroadsleft committed Aug 31, 2022
1 parent 1ede73d commit 0689d7b
Show file tree
Hide file tree
Showing 10 changed files with 227 additions and 104 deletions.
32 changes: 30 additions & 2 deletions keyboards/durgod/k310/base/config.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2021 Don Kjer and Tyler Tidman
/* Copyright 2021 kuenhlee, Don Kjer, Tyler Tidman
* Copyright 2021 Simon Arlott
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -19,10 +19,38 @@

#include "config_common.h"

/* key matrix size (cols in generic keyboard config) */
#define WAIT_US_TIMER GPTD3

/* key matrix size */
#define MATRIX_ROWS 8
#define MATRIX_COLS 16

#define MATRIX_ROW_PINS { A0, A1, A2, A3, A4, A5, A6, A7 }
#define MATRIX_COL_PINS { C4, C5, B0, B1, B2, B10, B11, B12, B13, B14, B15, C6, C7, C10, C11, C12 }

/* COL2ROW, ROW2COL*/
#define DIODE_DIRECTION ROW2COL

// Dynamic EEPROM
// Something sensible or else VIA may crash
// Users may enable more if they wish
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 4095

/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
#define DEBOUNCE 5

/* Bootmagic Lite key configuration */
#define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
#define BOOTMAGIC_LITE_ROW 0
#define BOOTMAGIC_LITE_COLUMN 0

/* LED indicator pins */
#define LED_NUM_LOCK_PIN C8
#define LED_CAPS_LOCK_PIN C9
#define LED_SCROLL_LOCK_PIN A8
#define LED_WIN_LOCK_PIN A9
#define LED_MR_LOCK_PIN A10
#define LED_PIN_ON_STATE 0

/* Original hardware "reset" button on pin D2 */
#define HARDWARE_RESET_PIN D2
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions keyboards/durgod/k310/k310.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#pragma once

#include "quantum.h"

#define XXX KC_NO

// This a shortcut to help you visually see your layout.
Expand Down Expand Up @@ -76,3 +78,23 @@
{ XXX, XXX, XXX, XXX, XXX, XXX, XXX, K77, K78, K79, K7A, K7B, K7C, K7D, K7E, K7F } \
}


#ifndef WINLOCK_DISABLED
// Define the TGUI key here so it is available in QMK configurator
enum K3x0_keycodes {
#ifdef VIA_ENABLE
KC_TGUI = USER00, // Toggle between GUI Lock or Unlock
NEW_SAFE_RANGE = SAFE_RANGE
#else
KC_TGUI = SAFE_RANGE, // Toggle between GUI Lock or Unlock
NEW_SAFE_RANGE
#endif
};

#undef SAFE_RANGE
#define SAFE_RANGE NEW_SAFE_RANGE
#endif /* WINLOCK_DISABLED */

/* Function Prototype */
void off_all_leds(void);
void on_all_leds(void);
34 changes: 32 additions & 2 deletions keyboards/durgod/k320/base/config.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2021 Don Kjer and Tyler Tidman
/* Copyright 2021 kuenhlee, Don Kjer, Tyler Tidman
* Copyright 2021 Simon Arlott
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -19,7 +19,37 @@

#include "config_common.h"

/* key matrix size (cols in generic keyboard config) */
#define WAIT_US_TIMER GPTD3

/* key matrix size */
#define MATRIX_ROWS 7
#define MATRIX_COLS 16

#define MATRIX_ROW_PINS { A0, A1, A2, A3, A4, A5, A6 }
#define MATRIX_COL_PINS { C4, C5, B0, B1, B2, B10, B11, B12, B13, B14, B15, C6, C7, C10, C11, C12 }

/* COL2ROW, ROW2COL*/
#define DIODE_DIRECTION ROW2COL

// Dynamic EEPROM
// Something sensible or else VIA may crash
// Users may enable more if they wish
#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 4095

/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
#define DEBOUNCE 5

/* Bootmagic Lite key configuration */
#define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE
#define BOOTMAGIC_LITE_ROW 0
#define BOOTMAGIC_LITE_COLUMN 0

/* LED indicator pins */
#define LED_CAPS_LOCK_PIN C9
#define LED_SCROLL_LOCK_PIN A8
#define LED_WIN_LOCK_PIN A9
#define LED_MR_LOCK_PIN A10
#define LED_PIN_ON_STATE 0

/* Original hardware "reset" button on pin D2 */
#define HARDWARE_RESET_PIN D2
24 changes: 24 additions & 0 deletions keyboards/durgod/k320/halconf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* Copyright 2021 Simon Arlott
*
* 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

#define HAL_USE_PAL TRUE
#define PAL_USE_CALLBACKS TRUE

#define HAL_USE_GPT TRUE

#include_next <halconf.h>
96 changes: 96 additions & 0 deletions keyboards/durgod/k320/k320.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/* Copyright 2021 kuenhlee, Don Kjer, Tyler Tidman
* Copyright 2021 Simon Arlott
*
* 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/>.
*/

#include "k3x0.h"
#include <ch.h>
#include <hal.h>

/* Private Functions */
void off_all_leds(void) {
#ifdef LED_NUM_LOCK_PIN
writePinHigh(LED_NUM_LOCK_PIN);
#endif
writePinHigh(LED_CAPS_LOCK_PIN);
writePinHigh(LED_SCROLL_LOCK_PIN);
writePinHigh(LED_WIN_LOCK_PIN);
writePinHigh(LED_MR_LOCK_PIN);
}

void on_all_leds(void) {
#ifdef LED_NUM_LOCK_PIN
writePinLow(LED_NUM_LOCK_PIN);
#endif
writePinLow(LED_CAPS_LOCK_PIN);
writePinLow(LED_SCROLL_LOCK_PIN);
writePinLow(LED_WIN_LOCK_PIN);
writePinLow(LED_MR_LOCK_PIN);
}

/* WinLock and MR LEDs are non-standard. Need to override led init */
void led_init_ports(void) {
#ifdef LED_NUM_LOCK_PIN
setPinOutput(LED_NUM_LOCK_PIN);
#endif
setPinOutput(LED_CAPS_LOCK_PIN);
setPinOutput(LED_SCROLL_LOCK_PIN);
setPinOutput(LED_WIN_LOCK_PIN);
setPinOutput(LED_MR_LOCK_PIN);
off_all_leds();
}

#ifndef WINLOCK_DISABLED
static bool win_key_locked = false;

bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case KC_TGUI:
if (record->event.pressed) {
// Toggle GUI lock on key press
win_key_locked = !win_key_locked;
writePin(LED_WIN_LOCK_PIN, !win_key_locked);
}
break;
case KC_LGUI:
if (win_key_locked) { return false; }
break;
}
return process_record_user(keycode, record);
}
#endif /* WINLOCK_DISABLED */

#ifndef HW_RESET_PIN_DISABLED
static void hardware_reset_cb(void *arg) {
chSysLockFromISR();
bootloader_jump();
chSysUnlockFromISR();
}
#endif

void keyboard_pre_init_kb(void) {
setPinInputHigh(HARDWARE_RESET_PIN);

#ifndef HW_RESET_PIN_DISABLED
/* Jump to bootloader when the hardware reset button is pressed */
palEnablePadEvent(PAL_PORT(HARDWARE_RESET_PIN), PAL_PAD(HARDWARE_RESET_PIN), PAL_EVENT_MODE_FALLING_EDGE);
palSetPadCallback(PAL_PORT(HARDWARE_RESET_PIN), PAL_PAD(HARDWARE_RESET_PIN), hardware_reset_cb, NULL);

/* The interrupt is edge-triggered so check that it's not already pressed */
if (!readPin(HARDWARE_RESET_PIN)) {
bootloader_jump();
}
#endif
}
23 changes: 23 additions & 0 deletions keyboards/durgod/k320/k320.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#pragma once

#include "quantum.h"

#define XXX KC_NO

// This a shortcut to help you visually see your layout.
Expand Down Expand Up @@ -90,3 +92,24 @@
{ K50, K51, K52, XXX, XXX, XXX, K56, XXX, XXX, XXX, K5A, K5B, K5C, K5D, K5E, K5F }, \
{ XXX, XXX, XXX, XXX, XXX, XXX, XXX, K67, K68, K69, K6A, K6B, K6C, K6D, K6E, K6F } \
}


#ifndef WINLOCK_DISABLED
// Define the TGUI key here so it is available in QMK configurator
enum K3x0_keycodes {
#ifdef VIA_ENABLE
KC_TGUI = USER00, // Toggle between GUI Lock or Unlock
NEW_SAFE_RANGE = SAFE_RANGE
#else
KC_TGUI = SAFE_RANGE, // Toggle between GUI Lock or Unlock
NEW_SAFE_RANGE
#endif
};

#undef SAFE_RANGE
#define SAFE_RANGE NEW_SAFE_RANGE
#endif /* WINLOCK_DISABLED */

/* Function Prototype */
void off_all_leds(void);
void on_all_leds(void);
53 changes: 0 additions & 53 deletions keyboards/durgod/k3x0/config.h

This file was deleted.

47 changes: 0 additions & 47 deletions keyboards/durgod/k3x0/k3x0.h

This file was deleted.

0 comments on commit 0689d7b

Please sign in to comment.