rev3_5rows.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Copyright 2020 yushakobo
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  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. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "helix.h"
  17. bool is_mac_mode(void) {
  18. return keymap_config.swap_lalt_lgui == false;
  19. }
  20. void set_mac_mode(bool macmode) {
  21. /* The result is the same as pressing the AG_NORM(=MAGIC_UNSWAP_ALT_GUI)/AG_SWAP(=MAGIC_SWAP_ALT_GUI) keys.
  22. * see
  23. * https://github.com/qmk/qmk_firmware/blob/fb4a6ad30ea7a648acd59793ed4a30c3a8d8dc32/quantum/process_keycode/process_magic.c#L123-L124
  24. * https://github.com/qmk/qmk_firmware/blob/fb4a6ad30ea7a648acd59793ed4a30c3a8d8dc32/quantum/process_keycode/process_magic.c#L80-L81
  25. */
  26. keymap_config.swap_lalt_lgui = keymap_config.swap_ralt_rgui = !macmode;
  27. eeconfig_update_keymap(keymap_config.raw);
  28. }
  29. void dip_switch_update_kb(uint8_t index, bool active) {
  30. switch (index) {
  31. case 0:
  32. if(active) { // Left no.1 Helix rev3 common
  33. set_mac_mode(false);
  34. } else {
  35. set_mac_mode(true);
  36. }
  37. break;
  38. default: // Left no.2 or Right no.1 or Right no.2 for user/keymap
  39. dip_switch_update_user(index, active);
  40. break;
  41. }
  42. }