Skip to content

Commit

Permalink
Duplicate events fix (#17)
Browse files Browse the repository at this point in the history
* Filter duplicate events

Signed-off-by: Sami Salonen <[email protected]>

* Cleanup

Signed-off-by: Sami Salonen <[email protected]>

* Filter zero duration events only with Mute, not Vol up/down

Signed-off-by: Sami Salonen <[email protected]>

---------

Signed-off-by: Sami Salonen <[email protected]>
  • Loading branch information
ssalonen authored Mar 26, 2023
1 parent 7bfb9ef commit 67a914d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## 3.1.1

- Filter duplicate key press events (zero duration)

## 3.1.0


Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ path = 'src/bin.rs'

[package]
name = 'cec-alsa-sync'
version = "3.1.0"
version = "3.1.1"
authors = ['Sami Salonen']
edition = '2018'
license = 'GPL-2.0'
Expand Down
14 changes: 13 additions & 1 deletion src/bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,22 @@ fn on_key_press(keypress: CecKeypress) {
let command: Option<Command> = match keypress.keycode {
CecUserControlCode::VolumeUp => Some(app_config.vol_up_command.new_command()),
CecUserControlCode::VolumeDown => Some(app_config.vol_down_command.new_command()),
CecUserControlCode::Mute => app_config.mute_command.as_ref().map(|c| c.new_command()),
CecUserControlCode::Mute => {
if keypress.duration.is_zero() {
// Filter duplicate events
None
} else {
app_config.mute_command.as_ref().map(|c| c.new_command())
}
}
_ => None,
};
if let Some(mut command) = command {
debug!(
"Executing command {:?} {:?}",
command.get_program(),
command.get_args()
);
command.output().expect("Failed to call amixer");
}
}
Expand Down

0 comments on commit 67a914d

Please sign in to comment.