Compare commits

...

6 Commits

Author SHA1 Message Date
98406dd0df Add some fonts 2024-02-16 13:40:53 +01:00
0dc7eb6049 Tweak Compose button 2024-02-08 15:33:41 +01:00
c34c317f4e Make Layer shifting two-dimensional 2023-08-28 13:53:24 +02:00
727e0bbd72 Add HoldLayer button 2023-06-12 17:52:42 +02:00
903f880c73 Add compose macro button 2023-05-16 23:41:18 +02:00
643f75cf0a Make ModTap into a tuple struct 2023-03-27 18:35:07 +02:00
11 changed files with 67 additions and 8 deletions

BIN
Cantarell-VF.otf Normal file

Binary file not shown.

BIN
IosevkaNerdFont-Medium.ttf Normal file

Binary file not shown.

BIN
IosevkaNerdFont-Regular.ttf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
NotoSans-Regular.ttf Normal file

Binary file not shown.

BIN
NotoSansMath-Regular.ttf Normal file

Binary file not shown.

BIN
NotoSansMono-Regular.ttf Normal file

Binary file not shown.

BIN
SourceCodePro-Regular.otf Normal file

Binary file not shown.

View File

@ -22,25 +22,83 @@ impl From<Modifier> for u8 {
} }
} }
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum Button { pub enum Button {
Mod(Modifier), Mod(Modifier),
Key(Key), Key(Key),
ModTap { keycode: Key, modifier: Modifier }, ModTap(Key, Modifier),
NextLayer, Compose2(CompShift, Key, CompShift, Key),
PrevLayer, Compose3(CompShift, Key, CompShift, Key, CompShift, Key),
Layer(LayerShift, LayerDir, u16),
None, None,
} }
/// Whether a key should be shift modified as part of a compose chain.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum CompShift {
/// Do not shift the key.
#[default]
Lower,
/// Shift the key.
Upper,
/// Shift the key if shift is being held down.
Variable,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum LayerDir {
Left,
Right,
Up,
Down,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum LayerShift {
Move,
Peek,
}
impl Display for Button { impl Display for Button {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let cs = |cs: &CompShift| match cs {
CompShift::Lower => "",
CompShift::Upper => "",
CompShift::Variable => "⇧?",
};
match self { match self {
Button::Mod(modifier) => Debug::fmt(&modifier, f), Button::Mod(modifier) => Debug::fmt(&modifier, f),
Button::Key(keycode) => write!(f, "{keycode:?}"), Button::Key(key) => write!(f, "{key:?}"),
Button::ModTap { keycode, modifier } => write!(f, "{keycode:?}/{modifier:?}"), Button::ModTap(key, modifier) => write!(f, "{key:?}/{modifier}"),
Button::NextLayer => write!(f, ""), Button::Compose2(cs1, k1, cs2, k2) => {
Button::PrevLayer => write!(f, ""), write!(f, "⎄ {}{k1:?} {}{k2:?}", cs(cs1), cs(cs2))
}
Button::Compose3(cs1, k1, cs2, k2, cs3, k3) => {
write!(f, "⎄ {}{k1:?} {}{k2:?} {}{k3:?}", cs(cs1), cs(cs2), cs(cs3))
}
Button::Layer(..) => write!(f, "Lr"),
Button::None => write!(f, "Ø"), Button::None => write!(f, "Ø"),
} }
} }
} }
impl Display for Modifier {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
Modifier::LCtrl => "",
Modifier::LShift => "",
Modifier::LAlt => "",
Modifier::LMod => "",
Modifier::RCtrl => "",
Modifier::RShift => "",
Modifier::RAlt => "",
Modifier::RMod => "",
};
write!(f, "{s}")
}
}

View File

@ -2,6 +2,7 @@ use serde::{Deserialize, Serialize};
#[repr(u8)] #[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
// https://usb.org/sites/default/files/hut1_3_0.pdf // https://usb.org/sites/default/files/hut1_3_0.pdf
pub enum Key { pub enum Key {
A = 0x04, A = 0x04,