summaryrefslogtreecommitdiff
path: root/keyboards/donutcables/scrabblepad/keymaps/random
diff options
context:
space:
mode:
authorMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-04-04 15:16:59 -0700
committerDrashna Jaelre <drashna@live.com>2019-04-04 15:16:59 -0700
commit7e5c107d43890eb517184d6fddff9a6da165fc3d (patch)
tree20927e9590d56a8c7b74d9e7466735b8a62f7ec2 /keyboards/donutcables/scrabblepad/keymaps/random
parent60668ef39deab4634dbe7fc1119d9de5ee751b28 (diff)
[Keyboard] Move scrabblepad into donutcables directory (#5553)
* move scrabblepad into donutcables directory * use pragma once * update scrabblepad readme
Diffstat (limited to 'keyboards/donutcables/scrabblepad/keymaps/random')
-rw-r--r--keyboards/donutcables/scrabblepad/keymaps/random/keymap.c75
-rw-r--r--keyboards/donutcables/scrabblepad/keymaps/random/readme.md5
2 files changed, 80 insertions, 0 deletions
diff --git a/keyboards/donutcables/scrabblepad/keymaps/random/keymap.c b/keyboards/donutcables/scrabblepad/keymaps/random/keymap.c
new file mode 100644
index 0000000000..8e78259661
--- /dev/null
+++ b/keyboards/donutcables/scrabblepad/keymaps/random/keymap.c
@@ -0,0 +1,75 @@
+#include "scrabblepad.h"
+#include <stdlib.h>
+
+static uint16_t keystroke;
+static bool shift_pressed;
+
+static int lower = (int) KC_A;
+static int upper = (int) KC_Z;
+
+uint16_t random_keycode(void) {
+ return lower + (rand() % (upper - lower + 1));
+};
+
+enum custom_keycodes {
+ RND_KEY = SAFE_RANGE
+};
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ switch(keycode) {
+ case RND_KEY:
+ if (record->event.pressed) {
+ keystroke = random_keycode();
+ if (rand() % 2 > 0) {
+ shift_pressed = 1;
+ register_code(KC_LSHIFT);
+ }
+ register_code(keystroke);
+ } else {
+ if (shift_pressed > 0) {
+ unregister_code(KC_LSHIFT);
+ }
+ unregister_code(keystroke);
+ }
+
+ return false;
+
+ default:
+ return true;
+ }
+
+ return true;
+}
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+[0] = LAYOUT( /* Base */
+ RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, \
+ RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, \
+ RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, \
+ RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, \
+ RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, \
+ RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, \
+ RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, \
+ RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RESET, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, \
+ RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, \
+ RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, \
+ RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, \
+ RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, \
+ RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, \
+ RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, \
+ RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY, RND_KEY
+),
+};
+
+
+void matrix_init_user(void) {
+
+}
+
+void matrix_scan_user(void) {
+
+}
+
+void led_set_user(uint8_t usb_led) {
+
+}
diff --git a/keyboards/donutcables/scrabblepad/keymaps/random/readme.md b/keyboards/donutcables/scrabblepad/keymaps/random/readme.md
new file mode 100644
index 0000000000..e719adaeb8
--- /dev/null
+++ b/keyboards/donutcables/scrabblepad/keymaps/random/readme.md
@@ -0,0 +1,5 @@
+# Scrabblepad keymap with every key press random
+
+Every key produces a random key press, except the middle key, which is reserved for resetting the board.
+
+The random key press is selected between KC_A and KC_Z keycodes.