aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2016-10-06 19:44:39 -0400
committerGitHub <noreply@github.com>2016-10-06 19:44:39 -0400
commit91d2b64850acb94177eca0c0c03380282c1b890b (patch)
tree0dfd260ebffa260a735fc299a8fb3e6d5f79a4a5
parentd465e3f0c384654b4e65f4dc031a0c7422cdf853 (diff)
parentb7442999dff637696842f272edca870f8e2f64e4 (diff)
downloadqmk_firmware-91d2b64850acb94177eca0c0c03380282c1b890b.tar.gz
qmk_firmware-91d2b64850acb94177eca0c0c03380282c1b890b.zip
Merge pull request #805 from SethSenpai/gamenum
Gamenum
-rw-r--r--keyboards/handwired/gamenum/Makefile3
-rw-r--r--keyboards/handwired/gamenum/README.md102
-rw-r--r--keyboards/handwired/gamenum/config.h162
-rw-r--r--keyboards/handwired/gamenum/gamenum.c14
-rw-r--r--keyboards/handwired/gamenum/gamenum.h21
-rw-r--r--keyboards/handwired/gamenum/keymaps/default/keymap.c68
-rw-r--r--keyboards/handwired/gamenum/rules.mk73
7 files changed, 443 insertions, 0 deletions
diff --git a/keyboards/handwired/gamenum/Makefile b/keyboards/handwired/gamenum/Makefile
new file mode 100644
index 000000000..191c6bb66
--- /dev/null
+++ b/keyboards/handwired/gamenum/Makefile
@@ -0,0 +1,3 @@
1ifndef MAKEFILE_INCLUDED
2 include ../../../Makefile
3endif \ No newline at end of file
diff --git a/keyboards/handwired/gamenum/README.md b/keyboards/handwired/gamenum/README.md
new file mode 100644
index 000000000..5b53004ef
--- /dev/null
+++ b/keyboards/handwired/gamenum/README.md
@@ -0,0 +1,102 @@
1GameNum firmware
2======================
3## Board overview
4
5The GameNum was designed to facilitate the use of mechanical keys for gaming even when your packing space is limited.
6It uses a standard numpad layout replacing the NumLock key with a layer toggle that allows you to cycle through the different layers.
7The standard layout features a default layer that acts as a standard numpad, a layer that was meant for simple WASD based games and a layer that was designed to be used for MOBA/RTS related games.
8The RTS layer is meant to be used rotating the device 90 degrees counterclockwise.
9
10The README.MD for this board is reasonably extensive and in-depth because the build is quite small and covers a lot of things that I feel that it would be a good starting point for getting into QMK.
11
12## Build considerations
13
14Since the GameNum is handwired and uses 2 of its pins to toggle indicator lights there are some things to keep in mind.
15Firmware was build for use with a Pro Micro based on a ATMEGA32u4 at 16mHz.
16The indicator LED's are normally assigned to `pin C6` and `pin D4`, C6 goes high when the first layer is used, D4 goes high when layer 2 is used. Both LED's are off when the default layer is enabled.
17'+' of the LED goes to the respective pins and can be joined together on the '-' into a resistor that runs to the ground pin of the pro micro. With a standard LED a resistor value of 100 ohm is fine, keep in mind that you cannot use high powered LEDS on these pins without ruining your pro micro.
18
19## schematic of the switches and diodes
20
21![schematic overview](http://i.imgur.com/fleitoA.jpg)
22
23Keep in mind that the minus of the diodes should point towards the pro micros inputs.
24
25##LED hookup
26
27![led overview](http://i.imgur.com/U6m865n.jpg)
28
29## Adding more layers
30
31Adding additional layers is pretty straight forward. Look in `keymaps/default/keymap.c` and find `#define OSY 2` add a new definition for the layer you are going to add. This can be named pretty much anything. Example: `#define NAMEHERE 3`.
32Keep in mind here that the number after the name should correspond with the number that the layer has in the stack of layers.
33
34Next thing to do is to add the actual layer for the keymap.
35
36```
37[DEF] = KEYMAP(
38 KC_FN0, KC_SLSH, KC_ASTR, KC_MINS, \
39 KC_7, KC_8, KC_9, KC_PLUS, \
40 KC_4, KC_5, KC_6, \
41 KC_1, KC_2, KC_3, \
42 KC_0, KC_DOT, KC_ENT \
43)
44```
45
46This is the default layer for the gamenum. It's generally easiest to just copy this and change things as you see fit. Keep in mind that at least 1 button on the pad has to be used to switch to the next layer in the stack or you will be stuck in that layer FOREVER! D:
47In the case of DEF this is key `KC_FN0`. Also keep in mind that the last layer that you add does not have a comma after its closing bracket but any other layer does!
48
49Which brings us nicely to the next part, the layer switching logic. Under the keymaps look for `PROGMEM fn_actions[]` this function handles the switching between layers, as you might have noticed every layer in the keymap has its own KC_FNx key. This is the key responsible for switching you from layer to layer.
50The number that is at the end of the keycode corresponds with the code in the function.
51`[0] = ACTION_LAYER_SET(HDN, ON_PRESS),` When `KC_FN0` is pressed the keyboard switches layer `HDN` on when the key is pressed down. Add an extra line for your layer here as well.
52
53Now for the LEDs, if you plan on adding extra LED's to the keyboard to indicate other layers you have to first define the pin that the LED will be using in `gamenum.c`.
54Look for this piece of code:
55
56```
57 DDRD |= (1<<4);
58 PORTD &= ~(1<<4);
59```
60
61Copy it and change the letter after DDR and PORT to the letter of your pin. Change the 4 to the number of your pin. `DDRx |= (1<<y);` defines that pin as an output. `PORTx &= ~(1<<y);` sets the pin to LOW turning off the LED.
62
63Now go back to `keymap.c` and look for the `process_record_user` function. The function is basically a switch case that checks if you pushed one of the defined layer-switch buttons. When it sees that you pushed one of them it sets the pins of the LED's either low or high.
64
65```
66 case KC_FN1:
67 if (record->event.pressed) {
68 PORTC &= ~(1 << 6); // PC6 goes low
69 PORTD |= (1<<4); //PD4 goes high
70 }
71 break;
72```
73
74This is the code for the KC_FN1 button. Notice how we check against what key is pressed in the case and then set pin C6 low and pin D4 high. Adjust this as you see fit.
75
76
77## Quantum MK Firmware
78
79For the full Quantum feature list, see [the parent readme.md](/doc/readme.md).
80
81## Building
82
83Download or clone the whole firmware and navigate to the keyboards/handwired/gamenum folder.
84Read the README.md for the qmk repository on how to set up your developer enviroment to build your firmware with.
85Building firmware on Windows can be a bit of a hassle. Linux is a lot easier to use if you have some experience with it. A raspberry pi will already be able to build the firmware for you.
86Once your dev env is set up, you'll be able to type `make` to generate your .hex - you can then use AVRDudess to program your .hex file.
87
88### Default
89
90To build with the default keymap, simply run `make`.
91
92### Other Keymaps
93
94To build the firmware binary hex file with a keymap just do `make` with `keymap` option like:
95
96```
97$ make keymap=[default|jack|<name>]
98```
99
100Keymaps follow the format **__keymap.c__** and are stored in folders in the `keymaps` folder, eg `keymaps/my_keymap/`
101
102
diff --git a/keyboards/handwired/gamenum/config.h b/keyboards/handwired/gamenum/config.h
new file mode 100644
index 000000000..6af876ab7
--- /dev/null
+++ b/keyboards/handwired/gamenum/config.h
@@ -0,0 +1,162 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#ifndef CONFIG_H
19#define CONFIG_H
20
21#include "config_common.h"
22
23/* USB Device descriptor parameter */
24#define VENDOR_ID 0x1234
25#define PRODUCT_ID 0x5678
26#define DEVICE_VER 0x0001
27#define MANUFACTURER Seth-Senpai
28#define PRODUCT GameNum
29#define DESCRIPTION Numpad with gamelayers
30
31/* key matrix size */
32#define MATRIX_ROWS 5
33#define MATRIX_COLS 4
34
35/*
36 * Keyboard Matrix Assignments
37 *
38 * Change this to how you wired your keyboard
39 * COLS: AVR pins used for columns, left to right
40 * ROWS: AVR pins used for rows, top to bottom
41 * DIODE_DIRECTION: COL2ROW = COL = Anode (+), ROW = Cathode (-, marked on diode)
42 * ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
43 *
44*/
45#define MATRIX_ROW_PINS { B6, B2, B3, B1, F7 }
46#define MATRIX_COL_PINS { D7, E6, B4, B5 }
47#define UNUSED_PINS
48
49/* COL2ROW or ROW2COL */
50#define DIODE_DIRECTION ROW2COL
51
52// #define BACKLIGHT_PIN C6
53// #define BACKLIGHT_BREATHING
54// #define BACKLIGHT_LEVELS 3
55
56
57/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */
58#define DEBOUNCING_DELAY 5
59
60/* define if matrix has ghost (lacks anti-ghosting diodes) */
61//#define MATRIX_HAS_GHOST
62
63/* number of backlight levels */
64
65/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
66#define LOCKING_SUPPORT_ENABLE
67/* Locking resynchronize hack */
68#define LOCKING_RESYNC_ENABLE
69
70/*
71 * Force NKRO
72 *
73 * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved
74 * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the
75 * makefile for this to work.)
76 *
77 * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N)
78 * until the next keyboard reset.
79 *
80 * NKRO may prevent your keystrokes from being detected in the BIOS, but it is
81 * fully operational during normal computer usage.
82 *
83 * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N)
84 * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by
85 * bootmagic, NKRO mode will always be enabled until it is toggled again during a
86 * power-up.
87 *
88 */
89//#define FORCE_NKRO
90
91/*
92 * Magic Key Options
93 *
94 * Magic keys are hotkey commands that allow control over firmware functions of
95 * the keyboard. They are best used in combination with the HID Listen program,
96 * found here: https://www.pjrc.com/teensy/hid_listen.html
97 *
98 * The options below allow the magic key functionality to be changed. This is
99 * useful if your keyboard/keypad is missing keys and you want magic key support.
100 *
101 */
102
103/* key combination for magic key command */
104#define IS_COMMAND() ( \
105 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
106)
107
108/* control how magic key switches layers */
109//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true
110//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true
111//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false
112
113/* override magic key keymap */
114//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS
115//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS
116//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM
117//#define MAGIC_KEY_HELP1 H
118//#define MAGIC_KEY_HELP2 SLASH
119//#define MAGIC_KEY_DEBUG D
120//#define MAGIC_KEY_DEBUG_MATRIX X
121//#define MAGIC_KEY_DEBUG_KBD K
122//#define MAGIC_KEY_DEBUG_MOUSE M
123//#define MAGIC_KEY_VERSION V
124//#define MAGIC_KEY_STATUS S
125//#define MAGIC_KEY_CONSOLE C
126//#define MAGIC_KEY_LAYER0_ALT1 ESC
127//#define MAGIC_KEY_LAYER0_ALT2 GRAVE
128//#define MAGIC_KEY_LAYER0 0
129//#define MAGIC_KEY_LAYER1 1
130//#define MAGIC_KEY_LAYER2 2
131//#define MAGIC_KEY_LAYER3 3
132//#define MAGIC_KEY_LAYER4 4
133//#define MAGIC_KEY_LAYER5 5
134//#define MAGIC_KEY_LAYER6 6
135//#define MAGIC_KEY_LAYER7 7
136//#define MAGIC_KEY_LAYER8 8
137//#define MAGIC_KEY_LAYER9 9
138//#define MAGIC_KEY_BOOTLOADER PAUSE
139//#define MAGIC_KEY_LOCK CAPS
140//#define MAGIC_KEY_EEPROM E
141//#define MAGIC_KEY_NKRO N
142//#define MAGIC_KEY_SLEEP_LED Z
143
144/*
145 * Feature disable options
146 * These options are also useful to firmware size reduction.
147 */
148
149/* disable debug print */
150//#define NO_DEBUG
151
152/* disable print */
153//#define NO_PRINT
154
155/* disable action features */
156//#define NO_ACTION_LAYER
157//#define NO_ACTION_TAPPING
158//#define NO_ACTION_ONESHOT
159//#define NO_ACTION_MACRO
160//#define NO_ACTION_FUNCTION
161
162#endif
diff --git a/keyboards/handwired/gamenum/gamenum.c b/keyboards/handwired/gamenum/gamenum.c
new file mode 100644
index 000000000..8048194bb
--- /dev/null
+++ b/keyboards/handwired/gamenum/gamenum.c
@@ -0,0 +1,14 @@
1#include "gamenum.h"
2
3void matrix_init_kb(void) {
4 // put your keyboard start-up code here
5 // runs once when the firmware starts up
6 DDRC |= (1<<6);
7 PORTC &= ~(1<<6);
8
9 DDRD |= (1<<4);
10 PORTD &= ~(1<<4);
11
12 matrix_init_user();
13
14}
diff --git a/keyboards/handwired/gamenum/gamenum.h b/keyboards/handwired/gamenum/gamenum.h
new file mode 100644
index 000000000..ea633b9bf
--- /dev/null
+++ b/keyboards/handwired/gamenum/gamenum.h
@@ -0,0 +1,21 @@
1#ifndef GAMENUM_H
2#define GAMENUM_H
3
4#include "quantum.h"
5
6#define KEYMAP( \
7 k00, k01, k02, k03, \
8 k10, k11, k12, k13, \
9 k20, k21, k22, \
10 k30, k31, k32, \
11 k41, k42, k43 \
12) \
13{ \
14 { k00, k01, k02, k03}, \
15 { k10, k11, k12, k13}, \
16 { k20, k21, k22, KC_NO}, \
17 { k30, k31, k32, KC_NO}, \
18 { KC_NO, k41, k42, k43} \
19}
20
21#endif
diff --git a/keyboards/handwired/gamenum/keymaps/default/keymap.c b/keyboards/handwired/gamenum/keymaps/default/keymap.c
new file mode 100644
index 000000000..6950b741a
--- /dev/null
+++ b/keyboards/handwired/gamenum/keymaps/default/keymap.c
@@ -0,0 +1,68 @@
1#include "gamenum.h"
2#include "action_layer.h"
3#include "eeconfig.h"
4
5
6#define _______ KC_TRNS
7
8#define DEF 0
9#define HDN 1
10#define OSY 2
11
12const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
13[DEF] = KEYMAP(
14 KC_FN0, KC_SLSH, KC_ASTR, KC_MINS, \
15 KC_7, KC_8, KC_9, KC_PLUS, \
16 KC_4, KC_5, KC_6, \
17 KC_1, KC_2, KC_3, \
18 KC_0, KC_DOT, KC_ENT \
19),
20[HDN] = KEYMAP(
21 KC_FN1, KC_1, KC_2, KC_3, \
22 KC_Q, KC_W, KC_E, KC_R, \
23 KC_A, KC_S, KC_D, \
24 KC_Z, KC_X, KC_C, \
25 KC_LSFT, KC_LALT, KC_SPC \
26),
27[OSY] = KEYMAP(
28 KC_A, KC_Q, KC_1, KC_FN2, \
29 KC_S, KC_W, KC_2, KC_LALT, \
30 KC_D, KC_E, KC_3, \
31 KC_F, KC_R, KC_4, \
32 KC_SPC, KC_T, KC_TAB \
33)
34};
35
36
37const uint16_t PROGMEM fn_actions[] = {
38 [0] = ACTION_LAYER_SET(HDN, ON_PRESS),
39 [1] = ACTION_LAYER_SET(OSY, ON_PRESS),
40 [2] = ACTION_LAYER_SET(DEF, ON_PRESS),
41};
42
43const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
44 return MACRO_NONE;
45};
46
47
48bool process_record_user (uint16_t keycode, keyrecord_t *record) {
49 switch(keycode) {
50 case KC_FN0:
51 if (record->event.pressed) {
52 PORTC |= (1 << 6); // PC6 goes high
53 }
54 break;
55 case KC_FN1:
56 if (record->event.pressed) {
57 PORTC &= ~(1 << 6); // PC6 goes high
58 PORTD |= (1<<4);
59 }
60 break;
61 case KC_FN2:
62 if (record->event.pressed) {
63 PORTD &= ~(1 << 4); // PC6 goes high
64 }
65 break;
66 }
67 return true;
68} \ No newline at end of file
diff --git a/keyboards/handwired/gamenum/rules.mk b/keyboards/handwired/gamenum/rules.mk
new file mode 100644
index 000000000..afb9372e1
--- /dev/null
+++ b/keyboards/handwired/gamenum/rules.mk
@@ -0,0 +1,73 @@
1
2# MCU name
3MCU = atmega32u4
4
5# Processor frequency.
6# This will define a symbol, F_CPU, in all source code files equal to the
7# processor frequency in Hz. You can then use this symbol in your source code to
8# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
9# automatically to create a 32-bit value in your source code.
10#
11# This will be an integer division of F_USB below, as it is sourced by
12# F_USB after it has run through any CPU prescalers. Note that this value
13# does not *change* the processor frequency - it should merely be updated to
14# reflect the processor speed set externally so that the code can use accurate
15# software delays.
16F_CPU = 16000000
17
18
19#
20# LUFA specific
21#
22# Target architecture (see library "Board Types" documentation).
23ARCH = AVR8
24
25# Input clock frequency.
26# This will define a symbol, F_USB, in all source code files equal to the
27# input clock frequency (before any prescaling is performed) in Hz. This value may
28# differ from F_CPU if prescaling is used on the latter, and is required as the
29# raw input clock is fed directly to the PLL sections of the AVR for high speed
30# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
31# at the end, this will be done automatically to create a 32-bit value in your
32# source code.
33#
34# If no clock division is performed on the input clock inside the AVR (via the
35# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
36F_USB = $(F_CPU)
37
38# Interrupt driven control endpoint task(+60)
39OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
40
41
42# Boot Section Size in *bytes*
43# Teensy halfKay 512
44# Teensy++ halfKay 1024
45# Atmel DFU loader 4096
46# LUFA bootloader 4096
47# USBaspLoader 2048
48OPT_DEFS += -DBOOTLOADER_SIZE=512
49
50
51# Build Options
52# change yes to no to disable
53#
54BOOTMAGIC_ENABLE ?= no # Virtual DIP switch configuration(+1000)
55MOUSEKEY_ENABLE ?= yes # Mouse keys(+4700)
56EXTRAKEY_ENABLE ?= yes # Audio control and System control(+450)
57CONSOLE_ENABLE ?= yes # Console for debug(+400)
58COMMAND_ENABLE ?= yes # Commands for debug and configuration
59# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
60SLEEP_LED_ENABLE ?= no # Breathing sleep LED during USB suspend
61# if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
62NKRO_ENABLE ?= no # USB Nkey Rollover
63BACKLIGHT_ENABLE ?= no # Enable keyboard backlight functionality on B7 by default
64MIDI_ENABLE ?= no # MIDI controls
65UNICODE_ENABLE ?= no # Unicode
66BLUETOOTH_ENABLE ?= no # Enable Bluetooth with the Adafruit EZ-Key HID
67AUDIO_ENABLE ?= no # Audio output on port C6
68
69ifndef QUANTUM_DIR
70 include ../../Makefile
71endif
72
73