diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/qmk/flow_led_matrix_effect/led_matrix_module.inc | 58 | ||||
-rw-r--r-- | modules/qmk/flow_led_matrix_effect/qmk_module.json | 8 | ||||
-rw-r--r-- | modules/qmk/flow_rgb_matrix_effect/qmk_module.json | 8 | ||||
-rw-r--r-- | modules/qmk/flow_rgb_matrix_effect/rgb_matrix_module.inc | 64 | ||||
-rw-r--r-- | modules/qmk/hello_world/hello_world.c | 33 | ||||
-rw-r--r-- | modules/qmk/hello_world/introspection.c | 10 | ||||
-rw-r--r-- | modules/qmk/hello_world/introspection.h | 10 | ||||
-rw-r--r-- | modules/qmk/hello_world/qmk_module.json | 15 | ||||
-rw-r--r-- | modules/qmk/hello_world/rules.mk | 2 | ||||
-rw-r--r-- | modules/qmk/super_alt_tab/qmk_module.json | 11 | ||||
-rw-r--r-- | modules/qmk/super_alt_tab/super_alt_tab.c | 50 |
11 files changed, 269 insertions, 0 deletions
diff --git a/modules/qmk/flow_led_matrix_effect/led_matrix_module.inc b/modules/qmk/flow_led_matrix_effect/led_matrix_module.inc new file mode 100644 index 0000000000..734e0f3494 --- /dev/null +++ b/modules/qmk/flow_led_matrix_effect/led_matrix_module.inc @@ -0,0 +1,58 @@ +// Copyright 2024-2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +LED_MATRIX_EFFECT(FLOW) + +#ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS + +// "Flow" animated effect. Draws moving wave patterns mimicking the appearance +// of flowing liquid. For interesting variety of patterns, space coordinates are +// slowly rotated and a function of several sine waves is evaluated. +static bool FLOW(effect_params_t* params) { + LED_MATRIX_USE_LIMITS(led_min, led_max); + + static uint16_t wrap_correction = 0; + static uint8_t last_high_byte = 0; + const uint8_t time_scale = 1 + led_matrix_eeconfig.speed / 8; + const uint8_t high_byte = (uint8_t)(g_led_timer >> 16); + if (last_high_byte != high_byte) { + last_high_byte = high_byte; + wrap_correction += ((uint16_t)time_scale) << 8; + } + const uint16_t time = scale16by8(g_led_timer, time_scale) + wrap_correction; + + // Compute rotation coefficients with 7 fractional bits. + const int8_t rot_c = cos8(time / 4) - 128; + const int8_t rot_s = sin8(time / 4) - 128; + const uint8_t omega = 32 + sin8(time) / 4; + + for (uint8_t i = led_min; i < led_max; ++i) { + LED_MATRIX_TEST_LED_FLAGS(); + const uint8_t x = g_led_config.point[i].x; + const uint8_t y = g_led_config.point[i].y; + + // Rotate (x, y) by the 2x2 rotation matrix described by rot_c, rot_s. + const uint8_t x1 = (uint8_t)((((int16_t)rot_c) * ((int16_t)x)) / 128) - (uint8_t)((((int16_t)rot_s) * ((int16_t)y)) / 128); + const uint8_t y1 = (uint8_t)((((int16_t)rot_s) * ((int16_t)x)) / 128) + (uint8_t)((((int16_t)rot_c) * ((int16_t)y)) / 128); + + uint8_t value = scale8(sin8(x1 - 2 * time), omega) + y1 + time / 4; + value = (value <= 127) ? value : (255 - value); + + led_matrix_set_value(i, scale8(led_matrix_eeconfig.val, value)); + } + + return led_matrix_check_finished_leds(led_max); +} + +#endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS diff --git a/modules/qmk/flow_led_matrix_effect/qmk_module.json b/modules/qmk/flow_led_matrix_effect/qmk_module.json new file mode 100644 index 0000000000..2d047cd0d0 --- /dev/null +++ b/modules/qmk/flow_led_matrix_effect/qmk_module.json @@ -0,0 +1,8 @@ +{ + "module_name": "Flow LED matrix effect", + "maintainer": "QMK Maintainers", + "license": "Apache-2.0", + "features": { + "led_matrix": true + } +} diff --git a/modules/qmk/flow_rgb_matrix_effect/qmk_module.json b/modules/qmk/flow_rgb_matrix_effect/qmk_module.json new file mode 100644 index 0000000000..3e42fe1ef4 --- /dev/null +++ b/modules/qmk/flow_rgb_matrix_effect/qmk_module.json @@ -0,0 +1,8 @@ +{ + "module_name": "Flow RGB matrix effect", + "maintainer": "QMK Maintainers", + "license": "Apache-2.0", + "features": { + "rgb_matrix": true + } +} diff --git a/modules/qmk/flow_rgb_matrix_effect/rgb_matrix_module.inc b/modules/qmk/flow_rgb_matrix_effect/rgb_matrix_module.inc new file mode 100644 index 0000000000..410838f7ec --- /dev/null +++ b/modules/qmk/flow_rgb_matrix_effect/rgb_matrix_module.inc @@ -0,0 +1,64 @@ +// Copyright 2024-2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +RGB_MATRIX_EFFECT(FLOW) + +#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS + +// "Flow" animated effect. Draws moving wave patterns mimicking the appearance +// of flowing liquid. For interesting variety of patterns, space coordinates are +// slowly rotated and a function of several sine waves is evaluated. +static bool FLOW(effect_params_t* params) { + RGB_MATRIX_USE_LIMITS(led_min, led_max); + + static uint16_t wrap_correction = 0; + static uint8_t last_high_byte = 0; + const uint8_t time_scale = 1 + rgb_matrix_config.speed / 8; + const uint8_t high_byte = (uint8_t)(g_rgb_timer >> 16); + if (last_high_byte != high_byte) { + last_high_byte = high_byte; + wrap_correction += ((uint16_t)time_scale) << 8; + } + const uint16_t time = scale16by8(g_rgb_timer, time_scale) + wrap_correction; + + // Compute rotation coefficients with 7 fractional bits. + const int8_t rot_c = cos8(time / 4) - 128; + const int8_t rot_s = sin8(time / 4) - 128; + const uint8_t omega = 32 + sin8(time) / 4; + + for (uint8_t i = led_min; i < led_max; ++i) { + RGB_MATRIX_TEST_LED_FLAGS(); + const uint8_t x = g_led_config.point[i].x; + const uint8_t y = g_led_config.point[i].y; + + // Rotate (x, y) by the 2x2 rotation matrix described by rot_c, rot_s. + const uint8_t x1 = (uint8_t)((((int16_t)rot_c) * ((int16_t)x)) / 128) - (uint8_t)((((int16_t)rot_s) * ((int16_t)y)) / 128); + const uint8_t y1 = (uint8_t)((((int16_t)rot_s) * ((int16_t)x)) / 128) + (uint8_t)((((int16_t)rot_c) * ((int16_t)y)) / 128); + + uint8_t value = scale8(sin8(x1 - 2 * time), omega) + y1 + time / 4; + value = (value <= 127) ? value : (255 - value); + + hsv_t hsv = rgb_matrix_config.hsv; + hsv.h -= value / 4; + hsv.s = scale8(hsv.s, (value < 74) ? 255 : (549 - 4 * value)); + hsv.v = scale8(hsv.v, (value < 95) ? (64 + 2 * value) : 255); + + rgb_t rgb = rgb_matrix_hsv_to_rgb(hsv); + rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + } + + return rgb_matrix_check_finished_leds(led_max); +} + +#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS diff --git a/modules/qmk/hello_world/hello_world.c b/modules/qmk/hello_world/hello_world.c new file mode 100644 index 0000000000..dcabfc60ea --- /dev/null +++ b/modules/qmk/hello_world/hello_world.c @@ -0,0 +1,33 @@ +// Copyright 2025 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#include QMK_KEYBOARD_H + +#include "introspection.h" + +ASSERT_COMMUNITY_MODULES_MIN_API_VERSION(1, 0, 0); + +uint32_t delayed_hello_world(uint32_t trigger_time, void *cb_arg) { + dprintf("Hello, world! I'm a QMK based keyboard! The keymap array size is %d bytes.\n", (int)hello_world_introspection().total_size); + return 0; +} + +void keyboard_post_init_hello_world(void) { + keyboard_post_init_hello_world_kb(); + defer_exec(10000, delayed_hello_world, NULL); +} + +bool process_record_hello_world(uint16_t keycode, keyrecord_t *record) { + if (!process_record_hello_world_kb(keycode, record)) { + return false; + } + + switch (keycode) { + case COMMUNITY_MODULE_HELLO: + if (record->event.pressed) { + SEND_STRING("Hello there."); + break; + } + } + + return true; +} diff --git a/modules/qmk/hello_world/introspection.c b/modules/qmk/hello_world/introspection.c new file mode 100644 index 0000000000..2c32a074f5 --- /dev/null +++ b/modules/qmk/hello_world/introspection.c @@ -0,0 +1,10 @@ +// Copyright 2025 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later + +hello_world_introspection_t hello_world_introspection(void) { + hello_world_introspection_t introspection = { + .total_size = sizeof(keymaps), + .layer_count = sizeof(keymaps) / sizeof(keymaps[0]), + }; + return introspection; +} diff --git a/modules/qmk/hello_world/introspection.h b/modules/qmk/hello_world/introspection.h new file mode 100644 index 0000000000..fd3d7f24a0 --- /dev/null +++ b/modules/qmk/hello_world/introspection.h @@ -0,0 +1,10 @@ +// Copyright 2025 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#include QMK_KEYBOARD_H + +typedef struct hello_world_introspection_t { + int16_t total_size; + int16_t layer_count; +} hello_world_introspection_t; + +hello_world_introspection_t hello_world_introspection(void); diff --git a/modules/qmk/hello_world/qmk_module.json b/modules/qmk/hello_world/qmk_module.json new file mode 100644 index 0000000000..bbd00f3fcc --- /dev/null +++ b/modules/qmk/hello_world/qmk_module.json @@ -0,0 +1,15 @@ +{ + "module_name": "Hello World", + "maintainer": "QMK Maintainers", + "license": "GPL-2.0-or-later", + "features": { + "console": true, + "deferred_exec": true + }, + "keycodes": [ + { + "key": "COMMUNITY_MODULE_HELLO", + "aliases": ["CM_HELO"] + } + ] +} diff --git a/modules/qmk/hello_world/rules.mk b/modules/qmk/hello_world/rules.mk new file mode 100644 index 0000000000..91806fb1e3 --- /dev/null +++ b/modules/qmk/hello_world/rules.mk @@ -0,0 +1,2 @@ +# Just a simple rules.mk which tests that they work from a community module. +$(shell $(QMK_BIN) hello -n "from QMK's hello world community module") diff --git a/modules/qmk/super_alt_tab/qmk_module.json b/modules/qmk/super_alt_tab/qmk_module.json new file mode 100644 index 0000000000..142613a23e --- /dev/null +++ b/modules/qmk/super_alt_tab/qmk_module.json @@ -0,0 +1,11 @@ +{ + "module_name": "Super Alt Tab", + "maintainer": "QMK Maintainers", + "license": "GPL-2.0-or-later", + "keycodes": [ + { + "key": "COMMUNITY_MODULE_SUPER_ALT_TAB", + "aliases": ["CM_S_AT"] + } + ] +} diff --git a/modules/qmk/super_alt_tab/super_alt_tab.c b/modules/qmk/super_alt_tab/super_alt_tab.c new file mode 100644 index 0000000000..dfeb4b5773 --- /dev/null +++ b/modules/qmk/super_alt_tab/super_alt_tab.c @@ -0,0 +1,50 @@ +// Copyright 2025 Christopher Courtney, aka Drashna Jael're (@drashna) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include QMK_KEYBOARD_H + +ASSERT_COMMUNITY_MODULES_MIN_API_VERSION(1, 0, 0); + +static bool is_alt_tab_active = false; +static uint16_t alt_tab_timer = 0; + +#ifndef COMMUNITY_MODULE_SUPER_ALT_TAB_TIMEOUT +# define COMMUNITY_MODULE_SUPER_ALT_TAB_TIMEOUT 1000 +#endif // COMMUNITY_MODULE_SUPER_ALT_TAB_TIMEOUT +#ifndef COMMUNITY_MODULE_SUPER_ALT_TAB_MODIFIER +# define COMMUNITY_MODULE_SUPER_ALT_TAB_MODIFIER MOD_LALT +#endif // COMMUNITY_MODULE_SUPER_ALT_TAB_MODIFIER +#ifndef COMMUNITY_MODULE_SUPER_ALT_TAB_KEY +# define COMMUNITY_MODULE_SUPER_ALT_TAB_KEY KC_TAB +#endif // COMMUNITY_MODULE_SUPER_ALT_TAB_KEY + +bool process_record_super_alt_tab(uint16_t keycode, keyrecord_t *record) { + if (!process_record_super_alt_tab_kb(keycode, record)) { + return false; + } + + switch (keycode) { // This will do most of the grunt work with the keycodes. + case COMMUNITY_MODULE_SUPER_ALT_TAB: + if (record->event.pressed) { + if (!is_alt_tab_active) { + is_alt_tab_active = true; + register_mods(COMMUNITY_MODULE_SUPER_ALT_TAB_MODIFIER); + } + alt_tab_timer = timer_read(); + register_code(COMMUNITY_MODULE_SUPER_ALT_TAB_KEY); + } else { + unregister_code(COMMUNITY_MODULE_SUPER_ALT_TAB_KEY); + } + break; + } + return true; +} + +void housekeeping_task_super_alt_tab(void) { + if (is_alt_tab_active) { + if (timer_elapsed(alt_tab_timer) > COMMUNITY_MODULE_SUPER_ALT_TAB_TIMEOUT) { + unregister_mods(COMMUNITY_MODULE_SUPER_ALT_TAB_MODIFIER); + is_alt_tab_active = false; + } + } +} |