Skip to content

Commit

Permalink
change: ignore mapping for idling rotary encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
daystram committed Jul 28, 2024
1 parent f750bfa commit 3d352d1
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/processor/mapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,14 @@ impl<
events: &mut Vec<Event<L>>,
) {
// map key matrix
let result = input.key_matrix_result;
let mut provisional_events = Vec::<Event<L>>::with_capacity(10);
let mut new_layer = true;
let mut layer = L::default();
while new_layer {
provisional_events.clear();
new_layer = false;
for (i, row) in input.key_matrix_result.matrix.iter().enumerate() {
for (i, row) in result.matrix.iter().enumerate() {
for (j, bit) in row.iter().enumerate() {
let action = self.mapping.key_matrix[layer.into()][i][j];
if bit.pressed {
Expand All @@ -104,7 +105,7 @@ impl<
#[allow(clippy::nonminimal_bool)]
if !(bit.edge == Edge::None && !bit.pressed) {
provisional_events.push(Event {
time_ticks: input.key_matrix_result.scan_time_ticks,
time_ticks: result.scan_time_ticks,
i,
j,
edge: bit.edge,
Expand All @@ -116,14 +117,16 @@ impl<
}

// map rotary encoder
provisional_events.push(Event {
time_ticks: input.rotary_encoder_result.scan_time_ticks,
i: 0,
j: 0,
edge: input.rotary_encoder_result.edge,
action: self.mapping.rotary_encoder[layer.into()]
[input.rotary_encoder_result.direction],
});
let result = input.rotary_encoder_result;
if !(result.edge == Edge::None && result.direction == Direction::None) {
provisional_events.push(Event {
time_ticks: result.scan_time_ticks,
i: 0,
j: 0,
edge: result.edge,
action: self.mapping.rotary_encoder[layer.into()][result.direction],
});
}

*events = provisional_events;
self.previous_key_matrix_result = input.key_matrix_result;
Expand Down

0 comments on commit 3d352d1

Please sign in to comment.