add custom keyboard
Some checks failed
Update API Data / api_data (push) Has been cancelled
CI Build Major Branch / Determine concurrency (push) Has been cancelled
CI Build Major Branch / Compile keymap default (push) Has been cancelled
CI Build Major Branch / Consolidation (push) Has been cancelled
CLI CI / test (push) Has been cancelled
Update develop after master merge / develop_update (push) Has been cancelled
Lint Format / lint (push) Has been cancelled
Regenerate Files / regen (push) Has been cancelled
Unit Tests / test (push) Has been cancelled
Some checks failed
Update API Data / api_data (push) Has been cancelled
CI Build Major Branch / Determine concurrency (push) Has been cancelled
CI Build Major Branch / Compile keymap default (push) Has been cancelled
CI Build Major Branch / Consolidation (push) Has been cancelled
CLI CI / test (push) Has been cancelled
Update develop after master merge / develop_update (push) Has been cancelled
Lint Format / lint (push) Has been cancelled
Regenerate Files / regen (push) Has been cancelled
Unit Tests / test (push) Has been cancelled
This commit is contained in:
parent
782f91a73a
commit
a825b90686
7 changed files with 1243 additions and 0 deletions
24
keyboards/splitkb/aurora/corne/keymaps/chapoline/config.h
Normal file
24
keyboards/splitkb/aurora/corne/keymaps/chapoline/config.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/* Copyright 2022 splitkb.com <support@splitkb.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
|
||||||
|
|
||||||
|
#ifdef RGBLIGHT_ENABLE
|
||||||
|
# define RGBLIGHT_EFFECT_BREATHING
|
||||||
|
# define RGBLIGHT_EFFECT_RAINBOW_MOOD
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SPLIT_LAYER_STATE_ENABLE
|
206
keyboards/splitkb/aurora/corne/keymaps/chapoline/debug.py
Normal file
206
keyboards/splitkb/aurora/corne/keymaps/chapoline/debug.py
Normal file
|
@ -0,0 +1,206 @@
|
||||||
|
from PIL import Image
|
||||||
|
|
||||||
|
# LIB
|
||||||
|
WHITE = (255, 255, 255, 0)
|
||||||
|
im = Image.new('RGB', (320, 1280))
|
||||||
|
|
||||||
|
class Cursor:
|
||||||
|
def __init__(self):
|
||||||
|
self.x = 0
|
||||||
|
self.y = 0
|
||||||
|
|
||||||
|
def move_cursor(self):
|
||||||
|
if self.x < 31:
|
||||||
|
self.x += 1
|
||||||
|
else:
|
||||||
|
self.x = 0
|
||||||
|
self.y += 8
|
||||||
|
|
||||||
|
def set_cursor(self, x, y):
|
||||||
|
if y%8 != 0:
|
||||||
|
return
|
||||||
|
self.x = x
|
||||||
|
self.y = y
|
||||||
|
|
||||||
|
|
||||||
|
def print_pixel(x, y):
|
||||||
|
im.paste(Image.new('RGB', (10, 10), WHITE), (x*10, y*10))
|
||||||
|
|
||||||
|
|
||||||
|
def print_byte(byte, cursor):
|
||||||
|
str = format(byte, '08b')
|
||||||
|
for i in range(8):
|
||||||
|
if str[i] == '1':
|
||||||
|
print_pixel(cursor.x, cursor.y + (7-i))
|
||||||
|
cursor.move_cursor()
|
||||||
|
|
||||||
|
cursor = Cursor()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Program
|
||||||
|
art = [
|
||||||
|
0xff, 0x80, 0x80, 0xb0, 0xf8, 0xc4, 0x9b, 0xa4, 0xc8, 0xb0, 0x80, 0x9c, 0xbe, 0xe1, 0xcc, 0x9e,
|
||||||
|
0xbf, 0xf0, 0xc1, 0xa2, 0x9c, 0x80, 0xb0, 0xf8, 0xc4, 0x9b, 0xa4, 0xc8, 0xb0, 0x80, 0x80, 0xff,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x05, 0x05, 0x7d, 0x05, 0x05, 0x01, 0x7d, 0x55, 0x55, 0x45, 0x01, 0x05, 0x05, 0x7d, 0x05, 0x05,
|
||||||
|
0x01, 0x7d, 0x15, 0x35, 0x49, 0x01, 0x45, 0x45, 0x7d, 0x45, 0x45, 0x01, 0x49, 0x55, 0x55, 0x25]
|
||||||
|
|
||||||
|
I = [[1],
|
||||||
|
[1],
|
||||||
|
[1],
|
||||||
|
[1]]
|
||||||
|
|
||||||
|
S = [[1, 0],
|
||||||
|
[1, 1],
|
||||||
|
[0, 1]]
|
||||||
|
|
||||||
|
Z = [[0, 1],
|
||||||
|
[1, 1],
|
||||||
|
[1, 0]]
|
||||||
|
|
||||||
|
T = [[0, 1],
|
||||||
|
[1, 1],
|
||||||
|
[0, 1]]
|
||||||
|
|
||||||
|
L = [[1, 0],
|
||||||
|
[1, 0],
|
||||||
|
[1, 1]]
|
||||||
|
|
||||||
|
J = [[1, 1],
|
||||||
|
[1, 0],
|
||||||
|
[1, 0]]
|
||||||
|
|
||||||
|
O = [[1, 1],
|
||||||
|
[1, 1]]
|
||||||
|
|
||||||
|
SQUARE = [ 0xf, 0x9, 0x9, 0xf ]
|
||||||
|
|
||||||
|
class Screen:
|
||||||
|
def __init__(self):
|
||||||
|
# There is 2 sets of coordinates
|
||||||
|
# Row and Col : position on the 7x28 grid, starting from the bottom left corner
|
||||||
|
# X and Y : position on the 32x128 screen, starting from the bottom left corner
|
||||||
|
# Row to X : X = 2 + (4 * Row)
|
||||||
|
# Col to Y : Y = 8 + (4 * Col)
|
||||||
|
#
|
||||||
|
# Then, (X, Y) must be converted to a (i, j) position in the byte array, and things start
|
||||||
|
# to get messier. The pixel is defined by the j bit in the i octet.
|
||||||
|
# j = Y % 8 easy
|
||||||
|
# i = X + (120 - (Y//8) * 8) * 4
|
||||||
|
|
||||||
|
self.grid = [[0 for i in range(7)] for j in range(28)]
|
||||||
|
self.screen = art.copy()
|
||||||
|
|
||||||
|
def grid2screen(self, row, col):
|
||||||
|
# Return the x, y coordinates of the bottom left pixel of a square
|
||||||
|
return 2 + 4*row, 8 + 4*col
|
||||||
|
|
||||||
|
def put4bits_to_screen(self, bits, x, y):
|
||||||
|
if y % 8 == 0:
|
||||||
|
bits <<= 4
|
||||||
|
print(x + (120 - (y//8) * 8) * 4)
|
||||||
|
self.screen[x + (120 - (y//8) * 8) * 4] |= bits
|
||||||
|
|
||||||
|
def put_square_to_screen(self, row, col):
|
||||||
|
x, y = self.grid2screen(row, col)
|
||||||
|
square = SQUARE.copy()
|
||||||
|
for i in range(len(SQUARE)):
|
||||||
|
self.put4bits_to_screen(square[i], x+i, y)
|
||||||
|
|
||||||
|
def put_grid_to_screen(self):
|
||||||
|
for i in range(7):
|
||||||
|
for j in range(28):
|
||||||
|
if self.grid[j][i]:
|
||||||
|
self.put_square_to_screen(i, j)
|
||||||
|
|
||||||
|
def put_square_to_grid(self, row, col):
|
||||||
|
self.grid[col][row] = 1
|
||||||
|
|
||||||
|
def print(self):
|
||||||
|
self.put_grid_to_screen()
|
||||||
|
cursor = Cursor()
|
||||||
|
for i in self.screen:
|
||||||
|
print_byte(i, cursor)
|
||||||
|
|
||||||
|
# def print_square(position):
|
||||||
|
# x, y = grid2screen(*position)
|
||||||
|
# square = SQUARE.copy()
|
||||||
|
# if y%8 == 0:
|
||||||
|
# square = [i << 4 for i in square]
|
||||||
|
|
||||||
|
# for i in range(len(square)):
|
||||||
|
# screen[x+4*y-32*i] |= square[i]
|
||||||
|
# print(x, y-i, screen[x+4*y-32*i])
|
||||||
|
|
||||||
|
# def print_tetra(position, tetra):
|
||||||
|
# # if position[1]%4 != 0:
|
||||||
|
# # return
|
||||||
|
|
||||||
|
# # if position[1]%8 == 0:
|
||||||
|
# # lower = True
|
||||||
|
# # cursor.set_cursor(*position)
|
||||||
|
# # else:
|
||||||
|
# # lower = False
|
||||||
|
# # cursor.set_cursor(position[0], position[1] + 4)
|
||||||
|
|
||||||
|
# for i in range(len(tetra)-1, -1, -1):
|
||||||
|
# for j in range(len(tetra[i])):
|
||||||
|
# if tetra[i][j]:
|
||||||
|
# print_square((position[0]+j, position[1]+i))
|
||||||
|
# # else:
|
||||||
|
# # cursor.set_cursor(cursor.x+4, cursor.y)
|
||||||
|
|
||||||
|
# # if lower:
|
||||||
|
# # lower = False
|
||||||
|
# # cursor.set_cursor(position[0], cursor.y)
|
||||||
|
# # else:
|
||||||
|
# # lower = True
|
||||||
|
# # cursor.set_cursor(position[0], cursor.y-8)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# print_tetra((2, 6), J)
|
||||||
|
# print_tetra((3, 8), O)
|
||||||
|
# print_tetra((5, 12), S)
|
||||||
|
|
||||||
|
screen = Screen()
|
||||||
|
|
||||||
|
screen.put_square_to_grid(2, 8)
|
||||||
|
screen.print()
|
||||||
|
# print_square(cursor, (0, 4), True, RIGHT)
|
||||||
|
# print_square(cursor, (4, 4), True, UP | LEFT)
|
||||||
|
# print_square(cursor, (4, 4), False, DOWN | RIGHT)
|
||||||
|
# print_square(cursor, (8, 4), False, LEFT)
|
||||||
|
|
||||||
|
|
||||||
|
im.save('test.png')
|
417
keyboards/splitkb/aurora/corne/keymaps/chapoline/keymap.c
Normal file
417
keyboards/splitkb/aurora/corne/keymaps/chapoline/keymap.c
Normal file
|
@ -0,0 +1,417 @@
|
||||||
|
/* Copyright 2022 splitkb.com <support@splitkb.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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include QMK_KEYBOARD_H
|
||||||
|
|
||||||
|
#include "gpio.h"
|
||||||
|
#include "tetris.h"
|
||||||
|
#include "print.h"
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <timer.h>
|
||||||
|
|
||||||
|
enum layers {
|
||||||
|
_DEFAULT,
|
||||||
|
_LOWER,
|
||||||
|
_RAISE,
|
||||||
|
_ADJUST
|
||||||
|
};
|
||||||
|
|
||||||
|
// I like it short
|
||||||
|
const uint16_t XXXX = XXXXXXX;
|
||||||
|
const uint16_t ____ = _______;
|
||||||
|
|
||||||
|
enum my_keycodes {
|
||||||
|
TRS_LEFT = SAFE_RANGE,
|
||||||
|
TRS_RIGHT,
|
||||||
|
TRS_UP,
|
||||||
|
TRS_DOWN,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
[_DEFAULT] = LAYOUT_split_3x6_3(
|
||||||
|
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
|
||||||
|
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_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ESC,
|
||||||
|
KC_LGUI, MO(2), KC_SPC, KC_ENT, MO(1), KC_RALT
|
||||||
|
),
|
||||||
|
[_LOWER] = LAYOUT_split_3x6_3(
|
||||||
|
KC_TAB, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC,
|
||||||
|
KC_LSFT, XXXX, XXXX, XXXX, XXXX, XXXX, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, XXXX, XXXX,
|
||||||
|
KC_LCTL, XXXX, XXXX, XXXX, XXXX, XXXX, MO(3), XXXX, XXXX, XXXX, XXXX, XXXX,
|
||||||
|
KC_LGUI, MO(3), KC_SPC, KC_ENT, ____, KC_RALT
|
||||||
|
),
|
||||||
|
[_RAISE] = LAYOUT_split_3x6_3(
|
||||||
|
KC_TAB, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC,
|
||||||
|
KC_LSFT, XXXX, XXXX, XXXX, XXXX, XXXX, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, KC_GRV,
|
||||||
|
KC_LCTL, XXXX, XXXX, XXXX, XXXX, MO(3), KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, KC_TILD,
|
||||||
|
KC_LGUI, ____, KC_SPC, KC_ENT, MO(3), KC_RALT
|
||||||
|
),
|
||||||
|
[_ADJUST] = LAYOUT_split_3x6_3(
|
||||||
|
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,
|
||||||
|
UG_TOGG, RM_HUEU, RM_SATU, RM_VALU, XXXX, QK_BOOT, QK_BOOT, XXXX, XXXX, TRS_UP, XXXX, XXXX,
|
||||||
|
RM_NEXT, RM_HUED, RM_SATD, RM_VALD, XXXX, XXXX, XXXX, XXXX, TRS_LEFT, TRS_DOWN, TRS_RIGHT, QK_LLCK,
|
||||||
|
KC_LGUI, ____, KC_SPC, KC_ENT, ____, KC_RALT
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef RGBLIGHT_ENABLE
|
||||||
|
void keyboard_post_init_user(void) {
|
||||||
|
rgblight_enable_noeeprom(); // enables RGB, without saving settings
|
||||||
|
rgblight_sethsv_noeeprom(HSV_RED); // sets the color to red without saving
|
||||||
|
rgblight_mode_noeeprom(RGBLIGHT_MODE_RAINBOW_MOOD + 2); // sets mode to Fast breathing without saving
|
||||||
|
|
||||||
|
// Shut down controller-mounter LED
|
||||||
|
gpio_set_pin_output(24);
|
||||||
|
gpio_write_pin_high(24);
|
||||||
|
|
||||||
|
debug_enable=true;
|
||||||
|
// debug_matrix=true;
|
||||||
|
debug_keyboard=true;
|
||||||
|
//debug_mouse=true;
|
||||||
|
srand(timer_read());
|
||||||
|
place_tetramino(&tetr_list[rand() % 7]);
|
||||||
|
frame_timer = timer_read32();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void oled_render_boot(bool bootloader) {
|
||||||
|
oled_clear();
|
||||||
|
if (bootloader) {
|
||||||
|
oled_write_P(PSTR("Good bye! Bootloader mode... UwU"), false);
|
||||||
|
}
|
||||||
|
oled_render_dirty(true);
|
||||||
|
rgblight_disable_noeeprom();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool shutdown_user(bool jump_to_bootloader) {
|
||||||
|
oled_render_boot(jump_to_bootloader);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
|
switch (keycode) {
|
||||||
|
case TRS_LEFT:
|
||||||
|
if (record->event.pressed && !is_game_over) {
|
||||||
|
if (!is_position_collision(falling_tetra.tetra,
|
||||||
|
falling_tetra.orientation,
|
||||||
|
(GridCoord) {falling_tetra.coord.row-1, falling_tetra.coord.col}))
|
||||||
|
falling_tetra.coord.row -= 1;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case TRS_RIGHT:
|
||||||
|
if (record->event.pressed && !is_game_over) {
|
||||||
|
if (!is_position_collision(falling_tetra.tetra,
|
||||||
|
falling_tetra.orientation,
|
||||||
|
(GridCoord) {falling_tetra.coord.row+1, falling_tetra.coord.col}))
|
||||||
|
falling_tetra.coord.row += 1;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case TRS_UP:
|
||||||
|
if (record->event.pressed && !is_game_over) {
|
||||||
|
if (!is_position_collision(falling_tetra.tetra,
|
||||||
|
(falling_tetra.orientation + 1)%4,
|
||||||
|
(GridCoord) {falling_tetra.coord.row, falling_tetra.coord.col}))
|
||||||
|
falling_tetra.orientation = (falling_tetra.orientation + 1) % 4;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
case TRS_DOWN:
|
||||||
|
if (record->event.pressed && !is_game_over) {
|
||||||
|
while (!is_position_collision(falling_tetra.tetra,
|
||||||
|
falling_tetra.orientation,
|
||||||
|
(GridCoord) {falling_tetra.coord.row, falling_tetra.coord.col-1}))
|
||||||
|
falling_tetra.coord.col -= 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
return true; // Process all other keycodes normally
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef OLED_ENABLE
|
||||||
|
static void render_space(void) {
|
||||||
|
oled_write_P(PSTR(" "), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void render_mod_status_gui_alt(uint8_t modifiers) {
|
||||||
|
static const char PROGMEM gui_off_1[] = {0x85, 0x86, 0};
|
||||||
|
static const char PROGMEM gui_off_2[] = {0xa5, 0xa6, 0};
|
||||||
|
static const char PROGMEM gui_on_1[] = {0x8d, 0x8e, 0};
|
||||||
|
static const char PROGMEM gui_on_2[] = {0xad, 0xae, 0};
|
||||||
|
|
||||||
|
static const char PROGMEM alt_off_1[] = {0x87, 0x88, 0};
|
||||||
|
static const char PROGMEM alt_off_2[] = {0xa7, 0xa8, 0};
|
||||||
|
static const char PROGMEM alt_on_1[] = {0x8f, 0x90, 0};
|
||||||
|
static const char PROGMEM alt_on_2[] = {0xaf, 0xb0, 0};
|
||||||
|
|
||||||
|
// fillers between the modifier icons bleed into the icon frames
|
||||||
|
static const char PROGMEM off_off_1[] = {0xc5, 0};
|
||||||
|
static const char PROGMEM off_off_2[] = {0xc6, 0};
|
||||||
|
static const char PROGMEM on_off_1[] = {0xc7, 0};
|
||||||
|
static const char PROGMEM on_off_2[] = {0xc8, 0};
|
||||||
|
static const char PROGMEM off_on_1[] = {0xc9, 0};
|
||||||
|
static const char PROGMEM off_on_2[] = {0xca, 0};
|
||||||
|
static const char PROGMEM on_on_1[] = {0xcb, 0};
|
||||||
|
static const char PROGMEM on_on_2[] = {0xcc, 0};
|
||||||
|
|
||||||
|
if(modifiers & MOD_MASK_GUI) {
|
||||||
|
oled_write_P(gui_on_1, false);
|
||||||
|
} else {
|
||||||
|
oled_write_P(gui_off_1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((modifiers & MOD_MASK_GUI) && (modifiers & MOD_MASK_ALT)) {
|
||||||
|
oled_write_P(on_on_1, false);
|
||||||
|
} else if(modifiers & MOD_MASK_GUI) {
|
||||||
|
oled_write_P(on_off_1, false);
|
||||||
|
} else if(modifiers & MOD_MASK_ALT) {
|
||||||
|
oled_write_P(off_on_1, false);
|
||||||
|
} else {
|
||||||
|
oled_write_P(off_off_1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(modifiers & MOD_MASK_ALT) {
|
||||||
|
oled_write_P(alt_on_1, false);
|
||||||
|
} else {
|
||||||
|
oled_write_P(alt_off_1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(modifiers & MOD_MASK_GUI) {
|
||||||
|
oled_write_P(gui_on_2, false);
|
||||||
|
} else {
|
||||||
|
oled_write_P(gui_off_2, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((modifiers & MOD_MASK_GUI) && (modifiers & MOD_MASK_ALT)) {
|
||||||
|
oled_write_P(on_on_2, false);
|
||||||
|
} else if(modifiers & MOD_MASK_GUI) {
|
||||||
|
oled_write_P(on_off_2, false);
|
||||||
|
} else if(modifiers & MOD_MASK_ALT) {
|
||||||
|
oled_write_P(off_on_2, false);
|
||||||
|
} else {
|
||||||
|
oled_write_P(off_off_2, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(modifiers & MOD_MASK_ALT) {
|
||||||
|
oled_write_P(alt_on_2, false);
|
||||||
|
} else {
|
||||||
|
oled_write_P(alt_off_2, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void render_mod_status_ctrl_shift(uint8_t modifiers) {
|
||||||
|
static const char PROGMEM ctrl_off_1[] = {0x89, 0x8a, 0};
|
||||||
|
static const char PROGMEM ctrl_off_2[] = {0xa9, 0xaa, 0};
|
||||||
|
static const char PROGMEM ctrl_on_1[] = {0x91, 0x92, 0};
|
||||||
|
static const char PROGMEM ctrl_on_2[] = {0xb1, 0xb2, 0};
|
||||||
|
|
||||||
|
static const char PROGMEM shift_off_1[] = {0x8b, 0x8c, 0};
|
||||||
|
static const char PROGMEM shift_off_2[] = {0xab, 0xac, 0};
|
||||||
|
static const char PROGMEM shift_on_1[] = {0xcd, 0xce, 0};
|
||||||
|
static const char PROGMEM shift_on_2[] = {0xcf, 0xd0, 0};
|
||||||
|
|
||||||
|
// fillers between the modifier icons bleed into the icon frames
|
||||||
|
static const char PROGMEM off_off_1[] = {0xc5, 0};
|
||||||
|
static const char PROGMEM off_off_2[] = {0xc6, 0};
|
||||||
|
static const char PROGMEM on_off_1[] = {0xc7, 0};
|
||||||
|
static const char PROGMEM on_off_2[] = {0xc8, 0};
|
||||||
|
static const char PROGMEM off_on_1[] = {0xc9, 0};
|
||||||
|
static const char PROGMEM off_on_2[] = {0xca, 0};
|
||||||
|
static const char PROGMEM on_on_1[] = {0xcb, 0};
|
||||||
|
static const char PROGMEM on_on_2[] = {0xcc, 0};
|
||||||
|
|
||||||
|
if(modifiers & MOD_MASK_CTRL) {
|
||||||
|
oled_write_P(ctrl_on_1, false);
|
||||||
|
} else {
|
||||||
|
oled_write_P(ctrl_off_1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((modifiers & MOD_MASK_CTRL) && (modifiers & MOD_MASK_SHIFT)) {
|
||||||
|
oled_write_P(on_on_1, false);
|
||||||
|
} else if(modifiers & MOD_MASK_CTRL) {
|
||||||
|
oled_write_P(on_off_1, false);
|
||||||
|
} else if(modifiers & MOD_MASK_SHIFT) {
|
||||||
|
oled_write_P(off_on_1, false);
|
||||||
|
} else {
|
||||||
|
oled_write_P(off_off_1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(modifiers & MOD_MASK_SHIFT) {
|
||||||
|
oled_write_P(shift_on_1, false);
|
||||||
|
} else {
|
||||||
|
oled_write_P(shift_off_1, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(modifiers & MOD_MASK_CTRL) {
|
||||||
|
oled_write_P(ctrl_on_2, false);
|
||||||
|
} else {
|
||||||
|
oled_write_P(ctrl_off_2, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((modifiers & MOD_MASK_CTRL) && (modifiers & MOD_MASK_SHIFT)) {
|
||||||
|
oled_write_P(on_on_2, false);
|
||||||
|
} else if(modifiers & MOD_MASK_CTRL) {
|
||||||
|
oled_write_P(on_off_2, false);
|
||||||
|
} else if(modifiers & MOD_MASK_SHIFT) {
|
||||||
|
oled_write_P(off_on_2, false);
|
||||||
|
} else {
|
||||||
|
oled_write_P(off_off_2, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(modifiers & MOD_MASK_SHIFT) {
|
||||||
|
oled_write_P(shift_on_2, false);
|
||||||
|
} else {
|
||||||
|
oled_write_P(shift_off_2, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void render_logo(void) {
|
||||||
|
static const char PROGMEM aurora_logo[] = {
|
||||||
|
0x00, 0x00, 0x00, 0xe0, 0x00, 0xf8, 0xc0, 0xf8, 0xe0, 0xc0, 0xfc, 0x00, 0x7e, 0x18, 0x00, 0x80,
|
||||||
|
0x00, 0x02, 0x80, 0xf0, 0x00, 0xc0, 0x80, 0xf8, 0xc0, 0xe0, 0x70, 0x60, 0x3c, 0x38, 0x3c, 0x1c,
|
||||||
|
0x00, 0x3f, 0x0c, 0x0f, 0x1f, 0x03, 0x07, 0x01, 0xc3, 0x00, 0xe0, 0x80, 0x00, 0xe0, 0x80, 0xf8,
|
||||||
|
0x80, 0xc0, 0xf7, 0xc7, 0x6f, 0x7b, 0x39, 0x30, 0x00, 0x80, 0x00, 0xc0, 0x00, 0xc0, 0xc2, 0xe0,
|
||||||
|
0x00, 0x40, 0x38, 0x30, 0x38, 0x1e, 0x18, 0x1e, 0x0f, 0x0c, 0x07, 0x07, 0x07, 0x03, 0x03, 0x21,
|
||||||
|
0x21, 0x31, 0x30, 0x18, 0x18, 0x1c, 0x08, 0x0c, 0x0e, 0x07, 0x06, 0x07, 0x03, 0xc3, 0x03, 0x01,
|
||||||
|
0x4c, 0xcc, 0xc2, 0xc2, 0x41, 0x49, 0x09, 0x2b, 0x2a, 0x6a, 0x6e, 0x24, 0x24, 0x04, 0x92, 0x92,
|
||||||
|
0xb1, 0xf1, 0xf1, 0xf2, 0xe6, 0xa4, 0xa4, 0x04, 0x04, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28
|
||||||
|
};
|
||||||
|
oled_write_raw_P(aurora_logo, sizeof(aurora_logo));
|
||||||
|
oled_set_cursor(0, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void render_logo_text(void) {
|
||||||
|
oled_write_P(PSTR("corne"), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void render_kb_LED_state(void) {
|
||||||
|
// Host Keyboard LED Status
|
||||||
|
led_t led_usb_state = host_keyboard_led_state();
|
||||||
|
oled_write_P(led_usb_state.num_lock ? PSTR("N ") : PSTR(" "), false);
|
||||||
|
oled_write_P(led_usb_state.caps_lock ? PSTR("C ") : PSTR(" "), false);
|
||||||
|
oled_write_P(led_usb_state.scroll_lock ? PSTR("S ") : PSTR(" "), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void render_layer_state(void) {
|
||||||
|
static const char PROGMEM default_layer[] = {
|
||||||
|
0x20, 0x94, 0x95, 0x96, 0x20,
|
||||||
|
0x20, 0xb4, 0xb5, 0xb6, 0x20,
|
||||||
|
0x20, 0xd4, 0xd5, 0xd6, 0x20, 0};
|
||||||
|
static const char PROGMEM raise_layer[] = {
|
||||||
|
0x20, 0x97, 0x98, 0x99, 0x20,
|
||||||
|
0x20, 0xb7, 0xb8, 0xb9, 0x20,
|
||||||
|
0x20, 0xd7, 0xd8, 0xd9, 0x20, 0};
|
||||||
|
static const char PROGMEM lower_layer[] = {
|
||||||
|
0x20, 0x9a, 0x9b, 0x9c, 0x20,
|
||||||
|
0x20, 0xba, 0xbb, 0xbc, 0x20,
|
||||||
|
0x20, 0xda, 0xdb, 0xdc, 0x20, 0};
|
||||||
|
static const char PROGMEM adjust_layer[] = {
|
||||||
|
0x20, 0x9d, 0x9e, 0x9f, 0x20,
|
||||||
|
0x20, 0xbd, 0xbe, 0xbf, 0x20,
|
||||||
|
0x20, 0xdd, 0xde, 0xdf, 0x20, 0};
|
||||||
|
|
||||||
|
switch (get_highest_layer(layer_state | default_layer_state)) {
|
||||||
|
case _LOWER:
|
||||||
|
oled_write_P(lower_layer, false);
|
||||||
|
break;
|
||||||
|
case _RAISE:
|
||||||
|
oled_write_P(raise_layer, false);
|
||||||
|
break;
|
||||||
|
case _ADJUST:
|
||||||
|
oled_write_P(adjust_layer, false);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
oled_write_P(default_layer, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void render_art(void) {
|
||||||
|
static const char PROGMEM aurora_art[] = {
|
||||||
|
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x1c, 0x08, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x40,
|
||||||
|
0xe0, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0x80,
|
||||||
|
0xc0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x80, 0x00, 0xf0, 0x00, 0x00, 0xc0,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
|
||||||
|
0x81, 0x00, 0xc0, 0x00, 0xfe, 0x00, 0xfc, 0x00, 0xff, 0x20, 0xff, 0xf0, 0x0f, 0xf0, 0x00, 0xff,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x00, 0xf8, 0x00, 0x00, 0xf8,
|
||||||
|
0xff, 0x10, 0xff, 0x84, 0xff, 0x60, 0xff, 0x36, 0xff, 0x0f, 0xff, 0x3f, 0x00, 0x5f, 0x00, 0x05,
|
||||||
|
0x80, 0x00, 0x80, 0x00, 0xc0, 0x38, 0x00, 0xec, 0xf0, 0x00, 0xfb, 0x80, 0xff, 0xf0, 0xff, 0xef,
|
||||||
|
0xff, 0xe8, 0xff, 0x03, 0xff, 0x0c, 0xff, 0x00, 0xff, 0x00, 0x03, 0x00, 0x00, 0xf8, 0x00, 0x80,
|
||||||
|
0xff, 0x20, 0xff, 0xd0, 0xff, 0xe0, 0xfe, 0xf8, 0xff, 0xfc, 0xff, 0xff, 0x0f, 0xff, 0x01, 0x3f,
|
||||||
|
0xff, 0x00, 0x0f, 0x00, 0x01, 0x00, 0x03, 0x00, 0xfe, 0x80, 0xfe, 0x00, 0xc0, 0xff, 0xc4, 0xfb,
|
||||||
|
0xff, 0xfe, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0x07, 0xff, 0x03, 0x3f, 0x00, 0x0f, 0xc0, 0x00,
|
||||||
|
0x00, 0x00, 0xb8, 0x00, 0xff, 0x40, 0xbe, 0xf0, 0xff, 0xf1, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
|
||||||
|
0x1f, 0xff, 0x67, 0x00, 0xef, 0x00, 0x1f, 0x00, 0x00, 0x07, 0x00, 0x00, 0xe0, 0x00, 0xff, 0xf0,
|
||||||
|
0xff, 0x88, 0xff, 0xc4, 0xff, 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f, 0x7f, 0x0f, 0xff,
|
||||||
|
0x00, 0x07, 0xfe, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0xc0, 0x3f, 0xf8, 0xe7, 0xff,
|
||||||
|
0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0x1f, 0x3f, 0x01, 0xff, 0x0b, 0x00, 0xff, 0x00, 0x00, 0x05,
|
||||||
|
0x00, 0x00, 0x00, 0xe0, 0x00, 0xf8, 0x60, 0x80, 0xfe, 0xe3, 0xfc, 0xff, 0x1e, 0xff, 0xff, 0x23,
|
||||||
|
0xff, 0x09, 0xff, 0x20, 0x00, 0x3f, 0x02, 0x00, 0x00, 0x0f, 0x00, 0x40, 0x00, 0xc0, 0x00, 0xfc,
|
||||||
|
0xe0, 0xfc, 0xf0, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0x0f, 0xff, 0x07, 0x1f, 0x00, 0x01, 0x0f, 0x00,
|
||||||
|
0x0f, 0x00, 0x81, 0x70, 0x0c, 0xf0, 0x80, 0x00, 0x00, 0xe4, 0xf8, 0xe6, 0x70, 0x3f, 0xcf, 0xff,
|
||||||
|
0x1f, 0xff, 0x48, 0xff, 0x0f, 0x00, 0x07, 0x00, 0x00, 0x43, 0x60, 0xf8, 0xf0, 0xfe, 0x38, 0xfe,
|
||||||
|
0x00, 0xfc, 0x03, 0x00, 0xc8, 0x72, 0xcf, 0xfc, 0x00, 0x03, 0x0f, 0x01, 0xe0, 0x1c, 0xe0, 0x03,
|
||||||
|
0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x06, 0xf9, 0x00, 0x03, 0x00, 0x07,
|
||||||
|
0xff, 0x00, 0x10, 0x12, 0xc9, 0xf0, 0xcf, 0xb4, 0x7f, 0x80, 0xe0, 0x1e, 0x01, 0x40, 0x65, 0x5e,
|
||||||
|
0xe0, 0x00, 0x00, 0xf0, 0x0c, 0xf0, 0x00, 0x80, 0x7e, 0x01, 0x80, 0x93, 0xfc, 0xc0, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x89, 0x18, 0x2c, 0x46, 0x00, 0x07, 0x21, 0x10, 0x10, 0x80, 0x09, 0x13,
|
||||||
|
0x31, 0xbf, 0xff, 0x00, 0x08, 0x1a, 0xf7, 0x0f, 0x00, 0x00, 0x44, 0x45, 0x34, 0xbf, 0xb8, 0x00,
|
||||||
|
0x10, 0xf0, 0x08, 0xf4, 0x18, 0x11, 0xfc, 0x18, 0xfb, 0x0e, 0x10, 0xf8, 0x04, 0xf8, 0x10, 0x20,
|
||||||
|
0x18, 0x09, 0xff, 0x0c, 0xea, 0x1f, 0x28, 0x60, 0x30, 0xf8, 0x20, 0xc0, 0x42, 0x33, 0x21, 0x00
|
||||||
|
};
|
||||||
|
// clang-format on
|
||||||
|
oled_write_raw_P(aurora_art, sizeof(aurora_art));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool oled_task_user(void) {
|
||||||
|
// A 128x32 OLED rotated 90 degrees is 5 characters wide and 16 characters tall
|
||||||
|
// This example string should fill that neatly
|
||||||
|
// const char *text = PSTR(" Waf");
|
||||||
|
// const char *text2 = PSTR(" Woof");
|
||||||
|
|
||||||
|
if (!is_keyboard_master()) {
|
||||||
|
render_logo();
|
||||||
|
render_logo_text();
|
||||||
|
render_space();
|
||||||
|
render_layer_state();
|
||||||
|
render_space();
|
||||||
|
render_mod_status_gui_alt(get_mods()|get_oneshot_mods());
|
||||||
|
render_mod_status_ctrl_shift(get_mods()|get_oneshot_mods());
|
||||||
|
render_kb_LED_state();
|
||||||
|
} else {
|
||||||
|
// render_layer_state();
|
||||||
|
// return false;
|
||||||
|
switch (get_highest_layer(layer_state | default_layer_state)) {
|
||||||
|
case _LOWER:
|
||||||
|
oled_write_P(PSTR("Waf"), false);
|
||||||
|
break;
|
||||||
|
case _RAISE:
|
||||||
|
oled_write_P(PSTR("Woof"), false);
|
||||||
|
break;
|
||||||
|
case _ADJUST:
|
||||||
|
render_tetris();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
render_art();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
88
keyboards/splitkb/aurora/corne/keymaps/chapoline/readme.md
Normal file
88
keyboards/splitkb/aurora/corne/keymaps/chapoline/readme.md
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
# Aurora Corne's Default Keymap
|
||||||
|
_This keymap is a copy of the [Corne default keymap](https://github.com/qmk/qmk_firmware/tree/master/keyboards/crkbd/keymaps/default), with modified OLED code._
|
||||||
|
|
||||||
|
A simple default keymap for the Aurora Corne
|
||||||
|
============================================
|
||||||
|
|
||||||
|
Keymaps in general are quite personal, so it is difficult to come up with a default that will suit every user. We hope this keymap serves as a good starting point for your own - although it should be fairly usable out-of-the-box.
|
||||||
|
|
||||||
|
What do all these layers do?
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
### Layer 0: Base layer
|
||||||
|
|
||||||
|
![Layer 0](https://i.imgur.com/Ri5cTHqh.png)
|
||||||
|
|
||||||
|
This is where your basic letters live.
|
||||||
|
|
||||||
|
The homing thumb fingers are used to access the different layers.
|
||||||
|
|
||||||
|
* The homing left thumb finger gives access to the Numbers (or lower) layer
|
||||||
|
* The homing right thumb finger gives access to the Symbols (or raise) layer
|
||||||
|
* Pressing both homing thumb fingers gives access to the Adjust layer
|
||||||
|
|
||||||
|
### Layer 1: Lower
|
||||||
|
|
||||||
|
![Layer 1](https://i.imgur.com/9h6ZRQLh.png)
|
||||||
|
|
||||||
|
The Lower layer gives access to your number keys on the top row. It also exposes the arrow keys in the usual Vim-style layout.
|
||||||
|
|
||||||
|
### Layer 2: Raise
|
||||||
|
|
||||||
|
![Layer 2](https://i.imgur.com/U1pf7pJh.png)
|
||||||
|
|
||||||
|
The Raise layer gives access to the symbols. In addition to shifted number keys on the top row, the right hand also exposes the remaining symbol keys, both as shifted and non-shifted variants.
|
||||||
|
|
||||||
|
### Layer 3: Adjust
|
||||||
|
|
||||||
|
![Layer 3](https://i.imgur.com/A6z1DCbh.png)
|
||||||
|
|
||||||
|
The Adjust layer exposes RGB adjustment keys on the left hand.
|
||||||
|
|
||||||
|
Where is the keymap.c?
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
The keymap.c file is not published to the repository. It is generated from `keymap.json` by the build system.
|
||||||
|
|
||||||
|
This avoids duplicating information and allow users to edit their keymap from the QMK Configurator web interface.
|
||||||
|
|
||||||
|
How do I edit and update the keymap?
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
The `keymap.json` file is generated from the QMK Configurator interface and formatted for better readability in the context of the Ferris keyboard.
|
||||||
|
|
||||||
|
To edit it, you may:
|
||||||
|
* Edit it directly from a text editor.
|
||||||
|
* Edit it from the QMK Configurator.
|
||||||
|
|
||||||
|
If you decide to use the latter workflow, here are the steps to follow:
|
||||||
|
|
||||||
|
* From the [QMK Configurator](https://config.qmk.fm/#/splitkb/aurora/corne/rev1/LAYOUT_split_3x5_2), hit the "import QMK keymap json file" button (it has a drawing with an up arrow on it).
|
||||||
|
* Browse to the location of your keymap (for example, `<your qmk repo>/keyboards/splitkb/aurora/corne/keymaps/default/keymap.json`)
|
||||||
|
* Perform any modification to the keymap in the web UI
|
||||||
|
* Export the keymap to your downloads folder, by hitting the "Export QMK keymap json file" button (it has a drawing with a down arrow on it)
|
||||||
|
* Replace your original keymap with the one you just downloaded
|
||||||
|
|
||||||
|
_**Note:** At the time of writing (the 24th of October 2022), not every feature used in the default keymap is supported by the QMK Configurator. You cannot yet upload the default `keymap.json` due to a file format mismatch - use the "Load Default" button to load the default keymap instead. Additionally, custom configuration options are still being worked on: if your keymap depends on them, please compile your firmware offline for now._
|
||||||
|
|
||||||
|
I want to do more than the JSON format supports!
|
||||||
|
-------------------------------------------------
|
||||||
|
|
||||||
|
While the `json` format is easy to use, it does lack certain functionality - most notably custom OLED or encoder behaviour.
|
||||||
|
|
||||||
|
To add this, you need to convert it to the `c` format. Do keep in mind that this is generally a one-way operation.
|
||||||
|
|
||||||
|
First, from the root of your qmk repo, move to your keymap folder
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd ./keymaps/splitkb/aurora/corne/my_personal_keymap
|
||||||
|
```
|
||||||
|
|
||||||
|
Next, convert your `keymap.json` to a `keymap.c`
|
||||||
|
|
||||||
|
```bash
|
||||||
|
qmk json2c -o keymap.c keymap.json
|
||||||
|
```
|
||||||
|
|
||||||
|
You can add custom C code to the newly generated `keymap.c` file. Do note that you have to use **either** a C file **or** a JSON file - you cannot do both!
|
||||||
|
**If a JSON file is present, the C file is ignored.**
|
26
keyboards/splitkb/aurora/corne/keymaps/chapoline/rules.mk
Normal file
26
keyboards/splitkb/aurora/corne/keymaps/chapoline/rules.mk
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
# Copyright 2022 splitkb.com <support@splitkb.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/>.
|
||||||
|
|
||||||
|
LAYER_LOCK_ENABLE = yes
|
||||||
|
|
||||||
|
RGB_MATRIX_ENABLE = no
|
||||||
|
RGBLIGHT_ENABLE = yes
|
||||||
|
|
||||||
|
ENCODER_ENABLE = no
|
||||||
|
OLED_ENABLE = yes
|
||||||
|
|
||||||
|
CONSOLE_ENABLE = yes
|
||||||
|
|
||||||
|
SRC += tetris.c
|
422
keyboards/splitkb/aurora/corne/keymaps/chapoline/tetris.c
Normal file
422
keyboards/splitkb/aurora/corne/keymaps/chapoline/tetris.c
Normal file
|
@ -0,0 +1,422 @@
|
||||||
|
#include QMK_KEYBOARD_H
|
||||||
|
#include "tetris.h"
|
||||||
|
#include "print.h"
|
||||||
|
#include <timer.h>
|
||||||
|
|
||||||
|
// #ifdef OLED_DRIVER_ENABLE
|
||||||
|
#include "oled_driver.h"
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
#define IDLE_TIMEOUT_MS 200
|
||||||
|
|
||||||
|
static const char PROGMEM square[] = { 0xf, 0x9, 0x9, 0xf };
|
||||||
|
|
||||||
|
const Tetramino PROGMEM tetr_I = {
|
||||||
|
{
|
||||||
|
{
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 1, 1, 1, 1 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 0, 1, 0 },
|
||||||
|
{ 0, 0, 1, 0 },
|
||||||
|
{ 0, 0, 1, 0 },
|
||||||
|
{ 0, 0, 1, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 1, 1, 1, 1 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
(GridCoord) { 2, 25 }
|
||||||
|
};
|
||||||
|
|
||||||
|
const Tetramino PROGMEM tetr_J = {
|
||||||
|
{
|
||||||
|
{
|
||||||
|
{ 1, 0, 0, 0 },
|
||||||
|
{ 1, 1, 1, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 1, 1, 1, 0 },
|
||||||
|
{ 0, 0, 1, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 1, 1, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
(GridCoord) { 2, 24 }
|
||||||
|
};
|
||||||
|
|
||||||
|
const Tetramino PROGMEM tetr_L = {
|
||||||
|
{
|
||||||
|
{
|
||||||
|
{ 0, 0, 1, 0 },
|
||||||
|
{ 1, 1, 1, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 1, 1, 1, 0 },
|
||||||
|
{ 1, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 1, 1, 0, 0 },
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
(GridCoord) { 2, 24 }
|
||||||
|
};
|
||||||
|
|
||||||
|
const Tetramino PROGMEM tetr_0 = {
|
||||||
|
{
|
||||||
|
{
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
(GridCoord) { 2, 24 }
|
||||||
|
};
|
||||||
|
|
||||||
|
const Tetramino PROGMEM tetr_S = {
|
||||||
|
{
|
||||||
|
{
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 1, 1, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 0, 0, 1, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 1, 1, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 1, 0, 0, 0 },
|
||||||
|
{ 1, 1, 0, 0 },
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
(GridCoord) { 2, 24 }
|
||||||
|
};
|
||||||
|
|
||||||
|
const Tetramino PROGMEM tetr_T = {
|
||||||
|
{
|
||||||
|
{
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 1, 1, 1, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 1, 1, 1, 0 },
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 1, 1, 0, 0 },
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
(GridCoord) { 2, 24 }
|
||||||
|
};
|
||||||
|
|
||||||
|
const Tetramino PROGMEM tetr_Z = {
|
||||||
|
{
|
||||||
|
{
|
||||||
|
{ 1, 1, 0, 0 },
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 0, 1, 0 },
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
{ 1, 1, 0, 0 },
|
||||||
|
{ 0, 1, 1, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{ 0, 1, 0, 0 },
|
||||||
|
{ 1, 1, 0, 0 },
|
||||||
|
{ 1, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
(GridCoord) { 2, 24 }
|
||||||
|
};
|
||||||
|
|
||||||
|
const Tetramino PROGMEM tetr_list[] = { tetr_I, tetr_J, tetr_L, tetr_0, tetr_S, tetr_T, tetr_Z };
|
||||||
|
|
||||||
|
FallingTetramino falling_tetra = {
|
||||||
|
&tetr_J,
|
||||||
|
(GridCoord) { 2, 20 },
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
bool is_game_over = false;
|
||||||
|
uint32_t frame_timer = 0;
|
||||||
|
|
||||||
|
void init_screen() {
|
||||||
|
static const char PROGMEM tetris_art[] = {
|
||||||
|
0xff, 0x80, 0x80, 0xb0, 0xf8, 0xc4, 0x9b, 0xa4, 0xc8, 0xb0, 0x80, 0x9c, 0xbe, 0xe1, 0xcc, 0x9e,
|
||||||
|
0xbf, 0xf0, 0xc1, 0xa2, 0x9c, 0x80, 0xb0, 0xf8, 0xc4, 0x9b, 0xa4, 0xc8, 0xb0, 0x80, 0x80, 0xff,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00,
|
||||||
|
0x05, 0x05, 0x7d, 0x05, 0x05, 0x01, 0x7d, 0x55, 0x55, 0x45, 0x01, 0x05, 0x05, 0x7d, 0x05, 0x05,
|
||||||
|
0x01, 0x7d, 0x15, 0x35, 0x49, 0x01, 0x45, 0x45, 0x7d, 0x45, 0x45, 0x01, 0x49, 0x55, 0x55, 0x25
|
||||||
|
};
|
||||||
|
memcpy(screen, tetris_art, 512);
|
||||||
|
}
|
||||||
|
|
||||||
|
void init_grid() {
|
||||||
|
memset(grid, 0, sizeof(grid[0][0]) * 7 * 28);
|
||||||
|
}
|
||||||
|
|
||||||
|
ScreenCoord grid2screen(GridCoord grid_coord) {
|
||||||
|
ScreenCoord screen = {
|
||||||
|
2 + 4 * (uint8_t) grid_coord.row,
|
||||||
|
8 + 4 * (uint8_t) grid_coord.col
|
||||||
|
};
|
||||||
|
return screen;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool put4bits_to_screen(uint8_t bits, ScreenCoord screen_coord) {
|
||||||
|
if (screen_coord.y % 4 != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (screen_coord.y % 8 == 0) {
|
||||||
|
bits <<= 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
screen[screen_coord.x + (120 - (screen_coord.y/8) * 8) * 4] |= bits;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool put_square_to_screen(GridCoord grid_coord) {
|
||||||
|
ScreenCoord screen_coord = grid2screen(grid_coord);
|
||||||
|
for (uint8_t i = 0; i < 4; i++) {
|
||||||
|
put4bits_to_screen(square[i], (ScreenCoord) { screen_coord.x + i, screen_coord.y });
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool put_grid_to_screen() {
|
||||||
|
for (uint8_t i = 0; i < 7; i++) {
|
||||||
|
for (uint8_t j = 0; j < 28; j++) {
|
||||||
|
if (grid[j][i]) {
|
||||||
|
put_square_to_screen((GridCoord) { i, j });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void put_square_to_grid(GridCoord grid_coord) {
|
||||||
|
grid[grid_coord.col][grid_coord.row] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void place_tetramino(const Tetramino *tetra) {
|
||||||
|
falling_tetra.tetra = tetra;
|
||||||
|
falling_tetra.coord.row = tetra->initCoord.row;
|
||||||
|
falling_tetra.coord.col = tetra->initCoord.col;
|
||||||
|
falling_tetra.orientation = 0;
|
||||||
|
if (is_position_collision(tetra, 0, tetra->initCoord))
|
||||||
|
is_game_over = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void show_tetra() {
|
||||||
|
for (uint8_t i = 0; i < 4; i++) {
|
||||||
|
for (uint8_t j = 0; j < 4; j++) {
|
||||||
|
if (falling_tetra.tetra->sprite[falling_tetra.orientation][3-j][i]) {
|
||||||
|
put_square_to_screen((GridCoord) { falling_tetra.coord.row+i, falling_tetra.coord.col+j });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool is_position_collision(const Tetramino *tetra, uint8_t orientation, GridCoord coord) {
|
||||||
|
for (uint8_t i = 0; i < 4; i++) {
|
||||||
|
for (uint8_t j = 0; j < 4; j++) {
|
||||||
|
if (falling_tetra.tetra->sprite[orientation][3-j][i]) {
|
||||||
|
// Vertical inclusion
|
||||||
|
if (coord.col+j < 0 || coord.col+j > 28)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Horizontal inclusion
|
||||||
|
if (coord.row+i < 0 || coord.row+i > 6)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// collision
|
||||||
|
if (grid[coord.col+j][coord.row+i])
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop_tetra() {
|
||||||
|
for (uint8_t i = 0; i < 4; i++) {
|
||||||
|
for (uint8_t j = 0; j < 4; j++) {
|
||||||
|
if (falling_tetra.tetra->sprite[falling_tetra.orientation][3-j][i]) {
|
||||||
|
put_square_to_grid((GridCoord) { falling_tetra.coord.row+i, falling_tetra.coord.col+j });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void remove_full_lines() {
|
||||||
|
for (int8_t j = 27; j >=0; j--) {
|
||||||
|
bool full = true;
|
||||||
|
for (uint8_t i = 0; i < 7; i++) {
|
||||||
|
if (!grid[j][i]) {
|
||||||
|
full = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (full) {
|
||||||
|
for (uint8_t k = (uint8_t) j; k < 27; k++) {
|
||||||
|
memcpy(grid[k], grid[k+1], 7);
|
||||||
|
memcpy(grid[27], (bool[]) { 0, 0, 0, 0, 0, 0, 0}, 7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void game_over() {
|
||||||
|
oled_set_cursor(0, 8);
|
||||||
|
oled_write_P(PSTR("GAME OVER"), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tick_down(uint8_t space) {
|
||||||
|
if (!is_position_collision(falling_tetra.tetra,
|
||||||
|
falling_tetra.orientation,
|
||||||
|
(GridCoord) {falling_tetra.coord.row, falling_tetra.coord.col-1}))
|
||||||
|
falling_tetra.coord.col -= 1;
|
||||||
|
else {
|
||||||
|
stop_tetra();
|
||||||
|
remove_full_lines();
|
||||||
|
place_tetramino(&tetr_list[rand() % 7]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void render_tetris() {
|
||||||
|
oled_write_raw_P(screen, sizeof(screen));
|
||||||
|
if (is_game_over) {
|
||||||
|
game_over();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
init_screen();
|
||||||
|
uint32_t frame_elapsed = timer_elapsed32(frame_timer);
|
||||||
|
if (frame_elapsed > IDLE_TIMEOUT_MS) {
|
||||||
|
tick_down(1);
|
||||||
|
frame_timer = timer_read32();
|
||||||
|
}
|
||||||
|
// init_grid();
|
||||||
|
show_tetra();
|
||||||
|
put_grid_to_screen();
|
||||||
|
}
|
60
keyboards/splitkb/aurora/corne/keymaps/chapoline/tetris.h
Normal file
60
keyboards/splitkb/aurora/corne/keymaps/chapoline/tetris.h
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
char screen[512];
|
||||||
|
bool grid[28][7];
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t x;
|
||||||
|
uint8_t y;
|
||||||
|
} ScreenCoord;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int8_t row;
|
||||||
|
int8_t col;
|
||||||
|
} GridCoord;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t sprite[4][4][4];
|
||||||
|
GridCoord initCoord;
|
||||||
|
} Tetramino;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
const Tetramino *tetra;
|
||||||
|
GridCoord coord;
|
||||||
|
uint8_t orientation;
|
||||||
|
} FallingTetramino;
|
||||||
|
|
||||||
|
extern const Tetramino PROGMEM tetr_I;
|
||||||
|
extern const Tetramino PROGMEM tetr_J;
|
||||||
|
extern const Tetramino PROGMEM tetr_L;
|
||||||
|
extern const Tetramino PROGMEM tetr_0;
|
||||||
|
extern const Tetramino PROGMEM tetr_S;
|
||||||
|
extern const Tetramino PROGMEM tetr_T;
|
||||||
|
extern const Tetramino PROGMEM tetr_Z;
|
||||||
|
extern const Tetramino PROGMEM tetr_list[];
|
||||||
|
|
||||||
|
extern FallingTetramino falling_tetra;
|
||||||
|
|
||||||
|
extern bool is_game_over;
|
||||||
|
extern uint32_t frame_timer;
|
||||||
|
|
||||||
|
void init_screen(void);
|
||||||
|
void init_grid(void);
|
||||||
|
ScreenCoord grid2screen(GridCoord grid_coord);
|
||||||
|
bool put4bits_to_screen(uint8_t bits, ScreenCoord screen_coord);
|
||||||
|
bool put_square_to_screen(GridCoord grid_coord);
|
||||||
|
bool put_grid_to_screen(void);
|
||||||
|
void put_square_to_grid(GridCoord grid_coord);
|
||||||
|
void place_tetramino(const Tetramino *tetra);
|
||||||
|
void show_tetra(void);
|
||||||
|
|
||||||
|
bool is_position_collision(const Tetramino *tetra, uint8_t orientation, GridCoord coord);
|
||||||
|
|
||||||
|
void stop_tetra(void);
|
||||||
|
void remove_full_lines(void);
|
||||||
|
|
||||||
|
void render_tetris(void);
|
||||||
|
|
||||||
|
void game_over(void);
|
||||||
|
|
||||||
|
void tick_down(uint8_t space);
|
Loading…
Add table
Reference in a new issue