~mil/fbp

ref: 637f5d16d714cbb54269c8c6554c3d4bdbb21d2e fbp/src/config.zig -rw-r--r-- 9.2 KiB
637f5d16Miles Alan Break out drag threshold dist/ms to config; lower gesture drag threshold ms 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
const types = @import("types.zig");
const handlers = @import("handlers/handlers.zig");
const linput = @cImport({
    @cInclude("linux/input.h");
});

pub const height_proportion = 1.0 / 3.0;

pub const keyboard_paginate = 37;
pub const keyboard_dims_cols = 10;
pub const keyboard_dims_rows = 4;

pub const strings_paginate = 15;
pub const strings_dims_cols = 3;
pub const strings_dims_rows = 5;

pub const fifo_size = 50000;
pub const grid_batch_size = 15;

pub const timeout_poll_ms = 50;

pub const drag_threshold_ms = 400;
pub const drag_threshold_dist = 300;

pub const keyboard = [_]types.GridItem{
    // Row 1
    .{ .t = "q" },
    .{ .t = "w" },
    .{ .t = "e" },
    .{ .t = "r" },
    .{ .t = "t" },
    .{ .t = "y" },
    .{ .t = "u" },
    .{ .t = "i" },
    .{ .t = "o" },
    .{ .t = "p" },

    // Row 2
    .{ .t = "a" },
    .{ .t = "s" },
    .{ .t = "d" },
    .{ .t = "f" },
    .{ .t = "g" },
    .{ .t = "h" },
    .{ .t = "j" },
    .{ .t = "k" },
    .{ .t = "l" },
    .{ .t = ";:", .v = linput.KEY_SEMICOLON },

    // Row 3
    .{ .t = "z" },
    .{ .t = "x" },
    .{ .t = "c" },
    .{ .t = "v" },
    .{ .t = "b" },
    .{ .t = "n" },
    .{ .t = "m" },
    .{ .t = "Tab", .v = linput.KEY_TAB },
    .{ .t = "<-", .span = 2, .v = linput.KEY_BACKSPACE },

    // Row 4
    .{ .t = "L2", .set_offset = 37 },
    .{ .t = "Str", .set_normalsubmode = .Strings },
    .{ .t = "Sft", .v = linput.KEY_LEFTSHIFT, .sticky = true },
    .{ .t = "U", .v = linput.KEY_UP },
    .{ .t = " ", .span = 2 },
    .{ .t = "Esc", .v = linput.KEY_ESC },
    .{ .t = "Ctl", .v = linput.KEY_LEFTCTRL, .sticky = true },
    .{ .t = "Enter", .span = 2, .v = linput.KEY_ENTER },

    // Row 1
    .{ .t = "1!", .v = linput.KEY_1 },
    .{ .t = "2@", .v = linput.KEY_2 },
    .{ .t = "3#", .v = linput.KEY_3 },
    .{ .t = "4$", .v = linput.KEY_4 },
    .{ .t = "5%", .v = linput.KEY_5 },
    .{ .t = "6^", .v = linput.KEY_6 },
    .{ .t = "7&", .v = linput.KEY_7 },
    .{ .t = "8*", .v = linput.KEY_8 },
    .{ .t = "9(", .v = linput.KEY_9 },
    .{ .t = "0)", .v = linput.KEY_0 },

    // Row 2
    .{ .t = "'\"", .v = linput.KEY_APOSTROPHE },
    .{ .t = "`~", .v = linput.KEY_1 }, //TODO
    .{ .t = "-_", .v = linput.KEY_MINUS },
    .{ .t = "=+", .v = linput.KEY_EQUAL },
    .{ .t = "[{", .v = linput.KEY_LEFTBRACE },
    .{ .t = "]}", .v = linput.KEY_RIGHTBRACE },
    .{ .t = ",<", .v = linput.KEY_COMMA },
    .{ .t = ".>", .v = linput.KEY_DOT },
    .{ .t = "/?", .v = linput.KEY_SLASH },
    .{ .t = "\\|", .v = linput.KEY_BACKSLASH },

    // Row 3
    .{ .t = " " },
    .{ .t = " " },
    .{ .t = "L", .v = linput.KEY_LEFT },
    .{ .t = "D", .v = linput.KEY_DOWN },
    .{ .t = "R", .v = linput.KEY_RIGHT },
    .{ .t = " " },
    .{ .t = " " },
    .{ .t = "Tab", .v = linput.KEY_TAB },
    .{ .t = "<-", .span = 2, .v = linput.KEY_BACKSPACE },

    // Row 4
    .{ .t = "L1", .set_offset = 0 },
    .{ .t = "Str", .set_normalsubmode = .Strings },
    .{ .t = "Sft", .v = linput.KEY_LEFTSHIFT, .sticky = true },
    .{ .t = "U", .v = linput.KEY_UP },
    .{ .t = " ", .span = 2 },
    .{ .t = "Esc", .v = linput.KEY_ESC },
    .{ .t = "Ctl", .v = linput.KEY_LEFTCTRL, .sticky = true },
    .{ .t = "Enter", .span = 2, .v = linput.KEY_ENTER },
};

pub const multikey_threshold_ms_press = 200;
pub const multikey_threshold_ms_hold = 600;
pub const multikey_threshold_ms_holdrepeat = 50;

pub const font_mono_path = "../assets/inconsolata.ttf";

pub const fifo_path = "/tmp/fbp.fifo";

pub const buttons_up = &[_]u8{linput.KEY_VOLUMEUP};
pub const buttons_down = &[_]u8{linput.KEY_VOLUMEDOWN};
pub const buttons_select = &[_]u8{ linput.KEY_MUTE, linput.KEY_POWER };

pub const status_height = 20;

pub const files_status = [_][]const u8{
    // Pinephone
    "/sys/class/power_supply/axp20x-battery/capacity",

    // Generic laptop (thinkpad)
    "/sys/class/power_supply/BAT0/capacity",

    // Librem 5
    "/sys/class/power_supply/max170xx_battery/capacity",
};

pub const files_led_red = [_][]const u8{
    // Pinephone
    "/sys/class/leds/red:indicator/brightness",

    // Generic laptop (thinkpad)
    "/sys/class/leds/tpacpi::thinklight/brightness",

    // Librem 5
    "/sys/class/leds/red:status/brightness",
};

pub const files_led_green = [_][]const u8{
    // Pinephone
    "/sys/class/leds/green:indicator/brightness",

    // Generic laptop (thinkpad)
    "/sys/class/leds/tpacpi::thinklight/power",

    // Librem 5
    "/sys/class/leds/green:status/brightness",
};

pub const files_led_blue = [_][]const u8{
    // Pinephone
    "/sys/class/leds/blue:indicator/brightness",

    // Generic laptop (thinkpad)
    "/sys/class/leds/input0::capslock/brightness",

    // Librem 5
    "/sys/class/leds/blue:status/brightness",
};

pub const folders_backlight = [_][]const u8{
    // Pinephone
    "/sys/class/backlight/backlight",

    // Generic laptop (thinkpad)
    "/sys/class/backlight/nv_backlight",

    // Librem 5
    "/sys/class/backlight/backlight-dsi",
};

pub const files_wakeupsources_enable = [_][]const u8{
    // Pinephone Power button
    "/sys/devices/platform/soc/1f03400.rsb/sunxi-rsb-3a3/axp221-pek/power/wakeup",

    // Pinephone Modem ring GPIO
    "/sys/devices/platform/gpio-keys/power/wakeup",

    // Librem 5 Power button
    "/sys/bus/platform/devices/30370000.snvs:snvs-powerkey",
};

// All EV_KEY compatible /dev/input devices are polled.
// However, for certain input devices (volume keys on PP)
// escape codes are produced for whatever reason.. to prevent this
// this list of handles are checked against EVIOCGNAME
// and if matched will be requested as an exclusive grab (EVIOCGRAB)
pub const input_handles_exclusive_grab = [_][]const u8{
    // Pinephone volkeys
    "1c21800.lradc",
};

// Keybinding actions to take on volume/power key
// Multikey
pub const keybinding_actions = [_]types.KeybindingAction{
    .{ .mode = .Normal, .keybinding = .{ .key = .Up, .MultiTap = 1 }, .handler = handlers.handler_grid_delta, .arg = .{ .Number = -1 } },
    .{ .mode = .Normal, .keybinding = .{ .key = .Down, .MultiTap = 1 }, .handler = handlers.handler_grid_delta, .arg = .{ .Number = 1 } },
    .{ .mode = .Normal, .keybinding = .{ .key = .Up, .MultiTap = 1, .HoldRepeat = true }, .handler = handlers.handler_grid_delta, .arg = .{ .Number = -1 } },
    .{ .mode = .Normal, .keybinding = .{ .key = .Down, .MultiTap = 1, .HoldRepeat = true }, .handler = handlers.handler_grid_delta, .arg = .{ .Number = 1 } },

    .{ .mode = .Normal, .keybinding = .{ .key = .Select, .MultiTap = 1 }, .handler = handlers.handler_grid_select },
    .{ .mode = .Normal, .keybinding = .{ .key = .Select, .MultiTap = 2 }, .handler = handlers.handler_mode_strings_keyboard_flip },
    .{ .mode = .Normal, .keybinding = .{ .key = .Select, .MultiTap = 3 }, .handler = handlers.handler_mode_lock_toggle },
    .{ .mode = .Normal, .keybinding = .{ .key = .Select, .MultiTap = 4 }, .handler = handlers.handler_send_clearscreen },
    .{ .mode = .Normal, .keybinding = .{ .key = .Select, .MultiTap = 1, .HoldStart = true }, .handler = handlers.handler_send_killreset },

    .{ .mode = .Lock, .submode = .{ .Lock = .ScreenOn }, .keybinding = .{ .key = .Up, .MultiTap = 1 }, .handler = handlers.handler_vt_delta, .arg = .{ .Number = -1 } },
    .{ .mode = .Lock, .submode = .{ .Lock = .ScreenOn }, .keybinding = .{ .key = .Up, .MultiTap = 2 }, .handler = handlers.handler_backlight_delta, .arg = .{ .Number = 1 } },
    .{ .mode = .Lock, .submode = .{ .Lock = .ScreenOn }, .keybinding = .{ .key = .Up, .MultiTap = 1, .HoldStart = true }, .handler = handlers.handler_deep_sleep },

    .{ .mode = .Lock, .submode = .{ .Lock = .ScreenOn }, .keybinding = .{ .key = .Down, .MultiTap = 1 }, .handler = handlers.handler_vt_delta, .arg = .{ .Number = 1 } },
    .{ .mode = .Lock, .submode = .{ .Lock = .ScreenOn }, .keybinding = .{ .key = .Down, .MultiTap = 2 }, .handler = handlers.handler_backlight_delta, .arg = .{ .Number = -1 } },
    .{ .mode = .Lock, .submode = .{ .Lock = .ScreenOn }, .keybinding = .{ .key = .Down, .MultiTap = 1, .HoldStart = true }, .handler = handlers.handler_lock_submode_screen_toggle },

    .{ .mode = .Lock, .submode = .{ .Lock = .ScreenOn }, .keybinding = .{ .key = .Select, .MultiTap = 1, .HoldStart = true }, .handler = handlers.handler_mode_lock_toggle },
    .{ .mode = .Lock, .submode = .{ .Lock = .ScreenOn }, .keybinding = .{ .key = .Select, .MultiTap = 3 }, .handler = handlers.handler_mode_lock_toggle },

    .{ .mode = .Lock, .submode = .{ .Lock = .ScreenOff }, .keybinding = .{ .key = .Up, .MultiTap = 1, .HoldStart = true }, .handler = handlers.handler_deep_sleep },
    .{ .mode = .Lock, .submode = .{ .Lock = .ScreenOff }, .keybinding = .{ .key = .Down, .MultiTap = 1, .HoldStart = true }, .handler = handlers.handler_lock_submode_screen_toggle },
    .{ .mode = .Lock, .submode = .{ .Lock = .ScreenOff }, .keybinding = .{ .key = .Select, .MultiTap = 1, .HoldStart = true }, .handler = handlers.handler_mode_lock_toggle },
};

// Drag actions
pub const drag_actions = [_]types.DragAction{
    .{ .swipe = .LR, .handler = handlers.handler_vt_delta, .arg = .{ .Number = -1 } },
    .{ .swipe = .RL, .handler = handlers.handler_vt_delta, .arg = .{ .Number = 1 } },
    .{ .swipe = .DU, .handler = handlers.handler_backlight_delta, .arg = .{ .Number = 1 } },
    .{ .swipe = .UD, .handler = handlers.handler_backlight_delta, .arg = .{ .Number = -1 } },
};