Parent directory

process_unicode_common.c

2689 bytes
 1/* Copyright 2017 Jack Humbert
 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
17#include "process_unicode_common.h"
18#include "unicode.h"
19#include "action_util.h"
20#include "keycodes.h"
21#include "modifiers.h"
22
23#if defined(UNICODE_ENABLE)
24#    include "process_unicode.h"
25#elif defined(UNICODEMAP_ENABLE)
26#    include "process_unicodemap.h"
27#elif defined(UCIS_ENABLE)
28#    include "process_ucis.h"
29#endif
30
31bool process_unicode_common(uint16_t keycode, keyrecord_t *record) {
32    if (record->event.pressed) {
33        bool shifted = get_mods() & MOD_MASK_SHIFT;
34        switch (keycode) {
35            case QK_UNICODE_MODE_NEXT:
36                if (shifted) {
37                    unicode_input_mode_step_reverse();
38                } else {
39                    unicode_input_mode_step();
40                }
41                break;
42            case QK_UNICODE_MODE_PREVIOUS:
43                if (shifted) {
44                    unicode_input_mode_step();
45                } else {
46                    unicode_input_mode_step_reverse();
47                }
48                break;
49            case QK_UNICODE_MODE_MACOS:
50                set_unicode_input_mode(UNICODE_MODE_MACOS);
51                break;
52            case QK_UNICODE_MODE_LINUX:
53                set_unicode_input_mode(UNICODE_MODE_LINUX);
54                break;
55            case QK_UNICODE_MODE_WINDOWS:
56                set_unicode_input_mode(UNICODE_MODE_WINDOWS);
57                break;
58            case QK_UNICODE_MODE_BSD:
59                set_unicode_input_mode(UNICODE_MODE_BSD);
60                break;
61            case QK_UNICODE_MODE_WINCOMPOSE:
62                set_unicode_input_mode(UNICODE_MODE_WINCOMPOSE);
63                break;
64            case QK_UNICODE_MODE_EMACS:
65                set_unicode_input_mode(UNICODE_MODE_EMACS);
66                break;
67        }
68    }
69
70#if defined(UNICODE_ENABLE)
71    return process_unicode(keycode, record);
72#elif defined(UNICODEMAP_ENABLE)
73    return process_unicodemap(keycode, record);
74#elif defined(UCIS_ENABLE)
75    return process_ucis(keycode, record);
76#else
77    return true;
78#endif
79}