Skip to content

Commit d050d60

Browse files
committed
refactor: rename fork's StateBits and minor fixes
Signed-off-by: Haobo Gu <haobogu@outlook.com>
1 parent be2845c commit d050d60

9 files changed

Lines changed: 24 additions & 20 deletions

File tree

examples/use_rust/nrf52840_ble_split/Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rmk-types/src/fork.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ use crate::mouse_button::MouseButtons;
2020
postcard_schema::Schema,
2121
)]
2222
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
23-
pub struct ForkStateBits {
23+
pub struct StateBits {
2424
pub modifiers: ModifierCombination,
2525
pub leds: LedIndicator,
2626
pub mouse: MouseButtons,
2727
}
2828

29-
impl BitOr for ForkStateBits {
29+
impl BitOr for StateBits {
3030
type Output = Self;
3131

3232
fn bitor(self, rhs: Self) -> Self::Output {
@@ -38,7 +38,7 @@ impl BitOr for ForkStateBits {
3838
}
3939
}
4040

41-
impl BitAnd for ForkStateBits {
41+
impl BitAnd for StateBits {
4242
type Output = Self;
4343

4444
fn bitand(self, rhs: Self) -> Self::Output {
@@ -50,7 +50,7 @@ impl BitAnd for ForkStateBits {
5050
}
5151
}
5252

53-
impl Not for ForkStateBits {
53+
impl Not for StateBits {
5454
type Output = Self;
5555

5656
fn not(self) -> Self::Output {
@@ -62,7 +62,7 @@ impl Not for ForkStateBits {
6262
}
6363
}
6464

65-
impl ForkStateBits {
65+
impl StateBits {
6666
pub const fn new_from(modifiers: ModifierCombination, leds: LedIndicator, mouse: MouseButtons) -> Self {
6767
Self { modifiers, leds, mouse }
6868
}

rmk-types/src/keycode/ascii.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ pub fn to_ascii(keycode: HidKeyCode, shifted: bool) -> u8 {
201201
(HidKeyCode::Quote, true) => b'"',
202202
(HidKeyCode::Grave, false) => b'`',
203203
(HidKeyCode::Grave, true) => b'~',
204-
(HidKeyCode::Backslash, true) => b'\\',
205-
(HidKeyCode::Backslash, false) => b'|',
204+
(HidKeyCode::Backslash, false) => b'\\',
205+
(HidKeyCode::Backslash, true) => b'|',
206206
(HidKeyCode::Comma, false) => b',',
207207
(HidKeyCode::Comma, true) => b'<',
208208
(HidKeyCode::Dot, false) => b'.',

rmk-types/src/protocol/rmk/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
55

66
use super::{MAX_COMBO_KEYS, MAX_MORSE_PATTERNS};
77
use crate::action::{KeyAction, MorseProfile};
8-
use crate::fork::ForkStateBits;
8+
use crate::fork::StateBits;
99
use crate::modifier::ModifierCombination;
1010

1111
/// Protocol-facing morse/tap-dance configuration.
@@ -30,8 +30,8 @@ pub struct ForkConfig {
3030
pub trigger: KeyAction,
3131
pub negative_output: KeyAction,
3232
pub positive_output: KeyAction,
33-
pub match_any: ForkStateBits,
34-
pub match_none: ForkStateBits,
33+
pub match_any: StateBits,
34+
pub match_none: StateBits,
3535
pub kept_modifiers: ModifierCombination,
3636
pub bindable: bool,
3737
}

rmk-types/src/protocol/rmk/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ mod tests {
247247
use crate::action::MorseProfile;
248248
use crate::battery::ChargeState;
249249
use crate::ble::BleState;
250-
use crate::fork::ForkStateBits;
250+
use crate::fork::StateBits;
251251
use crate::led_indicator::LedIndicator;
252252
use crate::modifier::ModifierCombination;
253253
use crate::mouse_button::MouseButtons;
@@ -557,12 +557,12 @@ mod tests {
557557
trigger: KeyAction::No,
558558
negative_output: KeyAction::No,
559559
positive_output: KeyAction::No,
560-
match_any: ForkStateBits {
560+
match_any: StateBits {
561561
modifiers: ModifierCombination::new(),
562562
leds: LedIndicator::new(),
563563
mouse: MouseButtons::new(),
564564
},
565-
match_none: ForkStateBits {
565+
match_none: StateBits {
566566
modifiers: ModifierCombination::new(),
567567
leds: LedIndicator::new(),
568568
mouse: MouseButtons::new(),

rmk/src/ble/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub(crate) mod led;
6161
pub mod passkey;
6262
pub(crate) mod profile;
6363

64-
pub use rmk_types::ble::{BleState, BleStatus};
64+
use rmk_types::ble::{BleState, BleStatus};
6565

6666
/// Global BLE status: tracks the active profile and current BLE state.
6767
pub static BLE_STATUS: Mutex<crate::RawMutex, Cell<BleStatus>> = Mutex::new(Cell::new(BleStatus {

rmk/src/fork.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use postcard::experimental::max_size::MaxSize;
22
use rmk_types::action::KeyAction;
3-
pub use rmk_types::fork::ForkStateBits as StateBits;
3+
use rmk_types::fork::StateBits;
44
use rmk_types::modifier::ModifierCombination;
55
use serde::{Deserialize, Serialize};
66

rmk/src/keyboard.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ use crate::event::ClearPeerEvent;
2222
use crate::event::{
2323
ActionEvent, KeyboardEvent, KeyboardEventPos, ModifierEvent, SubscribableEvent, publish_event, publish_event_async,
2424
};
25-
use crate::fork::{ActiveFork, StateBits};
25+
use rmk_types::fork::StateBits;
26+
27+
use crate::fork::ActiveFork;
2628
use crate::hid::Report;
2729
use crate::input_device::Runnable;
2830
use crate::keyboard::held_buffer::{HeldBuffer, HeldKey, KeyState};

rmk/src/keymap.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,9 @@ mod test {
732732
use rmk_types::modifier::ModifierCombination;
733733

734734
use crate::combo::{Combo, ComboConfig};
735-
use crate::fork::{Fork, StateBits};
735+
use rmk_types::fork::StateBits;
736+
737+
use crate::fork::Fork;
736738
use crate::keymap::fill_vec;
737739
use crate::{COMBO_MAX_NUM, FORK_MAX_NUM, k};
738740

0 commit comments

Comments
 (0)