altlocal_keys.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #pragma once
  2. /*
  3. Copyright 2018 Eric Gebhart <e.a.gebhart@gmail.com>
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. // Create custom keycodes with arbitrary shifted and unshifted keys.
  16. // originally for dvorak on bepo. But used by beakl on qwerty now too.
  17. // Why?: Because the keycodes are actually defined on the computer. So
  18. // if you are trying to have dvorak, or beakl on bepo-fr, the shifted keys
  19. // are wrong. But, I want my dvorak, so this allows the pairing of keys into
  20. // a keycode that has shifted and non shifted behavior, outside of what the
  21. // locale map says on the computer.
  22. //
  23. // These are the keys for dvorak on bepo. column one is the keycode and mods for
  24. // the unshifted key, the second column is the keycode and mods for the shifted key.
  25. // GR is Good Range. It subtracts SAFE_RANGE from the keycode so we can make a
  26. // reasonably sized array without difficulties. The macro is for the constant declarations
  27. // the function is for when we use it.
  28. //make an alt_local_keys.def - see the example.
  29. // Include this file where you have your process_record_user function,
  30. // call process_alt_local_key inside your process_record_user.
  31. uint8_t gr(uint16_t);
  32. void send_keycode(uint16_t);
  33. bool process_alt_local_key(uint16_t keycode, keyrecord_t* record);
  34. #define MOD_NONE 0x00
  35. #define GR(x) (x-SAFE_RANGE)
  36. // indexs for the keycode translation table.
  37. #define MK_KEY(KCNAME, KC1, MOD1, KC2, MOD2) \
  38. [GR(KCNAME)] = {{KC1, MOD1}, {KC2, MOD2}},
  39. #define MK_SKEY(KCNAME, KC1, KC2) \
  40. [GR(KCNAME)] = {{KC1, MOD_NONE}, {KC2, MOD_NONE}},
  41. #define UNSHIFTED_KEY(key) key_translations[gr(key)][0][0]
  42. #define UNSHIFTED_MODS(key) key_translations[gr(key)][0][1]
  43. #define SHIFTED_KEY(key) key_translations[gr(key)][1][0]
  44. #define SHIFTED_MODS(key) key_translations[gr(key)][1][1]