summaryrefslogtreecommitdiffstats
path: root/users/edvorakjp/edvorakjp_status.c
diff options
context:
space:
mode:
authorepaew <epaew@users.noreply.github.com>2018-11-27 02:50:45 +0900
committerDrashna Jaelre <drashna@live.com>2018-11-26 09:50:45 -0800
commitf3ffd6ad50f0a4bf24f0a0453cc5502b4b88f390 (patch)
treeba63b9851104dfc7916740af4bcee8f2476e50b3 /users/edvorakjp/edvorakjp_status.c
parent0031e461913d23e37a9aebd1da5daf1c93a149ee (diff)
Keymap: Refactor edvorakjp user library (#4480)
* Refactor edvorakjp user library * add tap dance support * update keymaps * edvorakjp: add SWAP_SCLN option * fix behavior of SWAP_SCLN
Diffstat (limited to 'users/edvorakjp/edvorakjp_status.c')
-rw-r--r--users/edvorakjp/edvorakjp_status.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/users/edvorakjp/edvorakjp_status.c b/users/edvorakjp/edvorakjp_status.c
new file mode 100644
index 0000000000..a60c8d853b
--- /dev/null
+++ b/users/edvorakjp/edvorakjp_status.c
@@ -0,0 +1,75 @@
+#include "eeprom.h"
+#include "edvorakjp.h"
+
+typedef union {
+ uint8_t raw;
+ struct {
+ bool enable_jp_extra_layer : 1;
+ bool enable_kc_lang : 1; // for macOS
+ };
+} edvorakjp_config_t;
+static edvorakjp_config_t edvorakjp_config;
+
+typedef struct {
+ bool japanese_mode;
+} edvorakjp_state_t;
+static edvorakjp_state_t edvorakjp_state;
+
+/*
+ * private methods
+ */
+uint8_t eeconfig_read_edvorakjp(void) {
+ return eeprom_read_byte(EECONFIG_EDVORAK);
+}
+
+void eeconfig_update_edvorakjp(uint8_t val) {
+ eeprom_update_byte(EECONFIG_EDVORAK, val);
+}
+
+/*
+ * public methods
+ */
+void edvorakjp_status_init(void) {
+ edvorakjp_state.japanese_mode = false;
+ edvorakjp_config.raw = eeconfig_read_edvorakjp();
+}
+
+bool get_enable_jp_extra_layer(void) {
+ return edvorakjp_config.enable_jp_extra_layer;
+}
+
+void set_enable_jp_extra_layer(bool new_state) {
+ edvorakjp_config.enable_jp_extra_layer = new_state;
+ eeconfig_update_edvorakjp(edvorakjp_config.raw);
+}
+
+bool get_enable_kc_lang(void) {
+ return edvorakjp_config.enable_kc_lang;
+}
+
+void set_enable_kc_lang(bool new_state) {
+ edvorakjp_config.enable_kc_lang = new_state;
+ eeconfig_update_edvorakjp(edvorakjp_config.raw);
+}
+
+bool get_japanese_mode(void) {
+ return edvorakjp_state.japanese_mode;
+}
+
+void set_japanese_mode(bool new_state) {
+ edvorakjp_state.japanese_mode = new_state;
+ if (edvorakjp_state.japanese_mode) {
+ if (edvorakjp_config.enable_kc_lang) {
+ SEND_STRING(SS_TAP(X_LANG1));
+ } else {
+ SEND_STRING(SS_LALT("`"));
+ }
+ } else {
+ dvorakj_layer_off();
+ if (edvorakjp_config.enable_kc_lang) {
+ SEND_STRING(SS_TAP(X_LANG2));
+ } else {
+ SEND_STRING(SS_LALT("`"));
+ }
+ }
+}