Commit Graph

38 Commits

Author SHA1 Message Date
0f2ff7e540 kbscan: Switch from GPIO mode to KBS (Normal) mode
Use the default mode for reading the keyboard scan matrix when being
used as a keyboard. There should be no perceived change in behavior, but
should make the code easier to understand.

Note: `KSO[17:16]` are configured by `GPCRC` on boards that use them.
They are now set to alternate function to use in KBS mode rather than
GPIO mode, with the pull-up enabled to prevent them from floating when
configured as open-drain.

As part of this change, we now only read the hardware matrix state once
upfront, instead of on every iteration through the loop applying the
logic.

Tested by verifying that typing still works on darp9.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-28 20:07:24 -06:00
546458e368 kbscan: Return early if debouncing
A single timer is used for debouncing all keys, so there is no reason to
perform any operations if the matrix is being debounced. Just return
early and remove some of the convoluted logic.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-25 13:03:25 -06:00
e093952dd2 kbscan: Reduce debounce time from 15ms to 5ms
Allows increased typing speed while avoiding repeating keys due to
contact bounce and keys being rejected by ghost key detection.

This is the default value for QMK.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-07-17 13:38:15 -06:00
c09960cbc6 Replace Call Mute with random key for micmute
Replace the Windows specific key with an arbitrary keycode to remap to
micmute on Linux.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-06-07 17:24:06 -06:00
2dd33ffec5 Add "Call Mute" combo key for darp9
The proprietary firmware for the darp9 adds the mic mute hotkey using
the new "Call Mute" hotkey from Windows 11 22H2, which is mapped to
`Super+Alt+K` [1]. Match the behavior in open firmware.

[1]: https://support.microsoft.com/en-us/windows/keyboard-shortcuts-in-windows-dcc61a57-8ff0-cffe-9796-cb9706c75eec#WindowsVersion=Windows_11

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-06-07 17:24:06 -06:00
9ac513128a kbled: Add a "step" function for BKL hotkey
Replace the get+set logic with a step function to change the backlight
level for `K_KBD_BKL`.

Keyboards using a DAC have a different set of levels due to the
brightness difference between the keyboards.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-06-07 17:24:06 -06:00
e032c5f0f2 Update .clang-format and apply
Update .clang-format for LLVM 14.0, available on Ubuntu 22.04.

There is still plenty that clang-format sucks at or does wrong, so
either add some more blocks to disable it, or just put up with it.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-01-10 12:02:21 -07:00
158ec124fe Add Pause key
In proprietary firmware and QMK, the Break key by itself is always just
Pause. They produce the same scan code, but Ctrl must be held for the OS
to recognize it as Break.

Behavior tested with xev.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2022-05-23 13:08:31 -06:00
474b1c2191 Remove unused power states, rename power on/off functions 2022-02-14 18:55:14 -07:00
458cb000f3 kbscan: Use u8 for array access
The index will never be negative and will never exceed 255. Change them
from i16 to u8 so SDCC will generate more efficient code.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2021-08-02 14:37:08 -06:00
99af8a35f5 Use explicitly sized types from stdint
Replace bare int types with stdint types. This was done with:

    grep -rwl 'int' src/ | xargs sed -i 's/\<int\>/int16_t/g'
    grep -rwl 'unsigned long' src/ | xargs sed -i 's/\<unsigned long\>/uint32_t/g'
    grep -rwl 'unsigned char' src/ | xargs sed -i 's/\<unsigned char\>/uint8_t/g'

Then reverted for *main(), putchar(), and getchar().

The Arduino declarations for parallel_main() were also corrected to
match their definitions.

SDCC does *not* generate the same code in all instances, due to `int`
being treated different than `short int`.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2021-08-02 07:46:44 -06:00
146f2d2b4a Implement scancode buffer 2021-07-19 14:52:07 -06:00
720af4b2b0 Use BIT macro
Mostly done with the cocci script. macro.h was then added manually.
2021-05-07 11:24:25 -06:00
16778e4a41 Report all keys as released when lid is closed 2021-04-02 13:38:28 -06:00
2ef4cd7bbd Add matrix command 2021-03-01 11:50:31 -07:00
c931eb4eef Do not repeat K_FAN_TOGGLE 2021-02-26 15:51:47 -07:00
18ec0eb694 Increase keyboard scanning delay to eliminate darp7 scanning issues 2021-02-05 09:52:24 -07:00
5559d4e2f6 system76/common: Switch to pmc_swi for wake events 2021-01-05 12:17:16 -07:00
3b6d262217 Add K_FAN_TOGGLE hotkey 2020-10-05 10:50:11 -07:00
916a6f87f3 Add dynamic keymap config 2020-10-05 09:54:28 -07:00
39e2586c50 Use physical position of keys for config reset 2020-10-01 14:50:26 -07:00
9afec7af27 Reset EC config on Fn+Esc during power on 2020-10-01 14:50:26 -07:00
00043ebfaf Only send hotkey SCI if ACPI OS is loaded 2020-09-29 19:42:05 -06:00
343722e350 Add hardware keyboard color handling 2020-09-29 19:42:05 -06:00
480e05d12b Move hardware hotkey processing to a new function 2020-09-29 19:42:05 -06:00
d0d9f65b6e Use K_ defines for SCI keys 2020-09-29 19:42:05 -06:00
80412e7a10 Rename K_E0 to KF_E0 (key flag E0) to aid in automatic layout generation 2020-09-29 19:42:05 -06:00
432c4f64d2 Remove unnecessary keymap function 2020-09-29 19:42:05 -06:00
582a5e2a97 kbscan: Prevent wake when lid is closed
Resolves: #102
2020-09-29 10:50:39 -06:00
5fd9df0ed0 Add SPDX license identifiers
Add license information to files. Mostly automated with:

    find src/ -name '*.[c,h]' | xargs sed -i '1s,^,// SPDX-License-Identifier: GPL-3.0-only\n\n,'
    find src/ -name '*.mk' | xargs sed -i '1s,^,# SPDX-License-Identifier: GPL-3.0-only\n\n,'
2020-09-17 09:17:08 -06:00
a1826a2fad Do not potentially repeat hardware hotkey actions 2020-08-27 09:22:06 -06:00
f1809926f6 bonw14 2020-08-13 12:56:24 -06:00
787acfb8e5 kbscan: Disable key repeat for certain SCI keys 2020-07-10 15:16:59 -07:00
834aaf97e4 Hot-pluggable parallel port debugging 2020-07-02 12:53:36 -07:00
7aa5767455 keymap: Improve debouncing behavior.
- Update debouncing code to properly handle rollover.
- Update ghost debouncing to properly set the debounce start time.

Signed-off-by: Evan Lojewski <github@meklort.com>
2020-05-07 06:17:38 -06:00
a6093d8708 keymap: Allow ghost keys to be pressed once the ghost is removed
- Don't record a ghost key as pressed
- Debouce on ghost release to allow ghosts to settle.
- Reduce debounce time from 20ms to 15ms.

Signed-off-by: Evan Lojewski <github@meklort.com>
2020-05-04 09:30:23 -06:00
de7d507277 Fix release of key after release of layer key 2020-04-23 08:50:49 -06:00
357fae86fc System76 common board directory (#53)
* Move configuration for battery into board.mk

* lemp9: remove tcpm code

* Move touchpad to its own module

* Add kbled_reset to all platforms, move items to run on CPU reset to a function

* Add defines for battery and charger address

* Add I2C_0 export to it5570e

* Move common system76 board functions into src/board/system76/common
2020-04-14 17:23:29 -06:00