qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

keymap.c (1148B)


      1 // Copyright 2022 Aaron Hong (@hongaaronc)
      2 // SPDX-License-Identifier: GPL-2.0-or-later
      3 
      4 #include QMK_KEYBOARD_H
      5 
      6 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
      7     [0] = LAYOUT_all(
      8                                     JS_0,JS_1,JS_2,JS_3,JS_4,JS_5,JS_6,
      9         JS_7,
     10                                     JS_0,JS_1,JS_2,JS_3,JS_4,JS_5,JS_6
     11     )
     12 };
     13 
     14 #if defined(JOYSTICK_ENABLE) && defined(ENCODER_ENABLE)
     15 
     16 int16_t joystick_position = 0;
     17 int16_t pulses_per_revolution = 24;     // Depends on encoder model. Usually 18ppr or 24ppr for Bourns EC11s.
     18 int16_t full_joystick_value = 32767;    // Equivalent to max value of int16. +full_joystick_value is +1.0 axis output. -full_joystick_value is -1.0 axis output.
     19 joystick_config_t joystick_axes[JOYSTICK_AXIS_COUNT] = {
     20     [0] = JOYSTICK_AXIS_VIRTUAL
     21 };
     22 
     23 bool encoder_update_user(uint8_t index, bool clockwise) {
     24     joystick_position += (clockwise ? 2 : -2) * (full_joystick_value / pulses_per_revolution);  // +2 and -2 are used, since +1.0 and -1.0 axis output refers to positions at half of a full rotation
     25     joystick_set_axis(0, joystick_position);
     26 
     27     return false;
     28 }
     29 
     30 #endif