-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
89e861a
commit 55c7085
Showing
12 changed files
with
1,563 additions
and
71 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/ShadowBlip/InputPlumber/main/rootfs/usr/share/inputplumber/schema/composite_device_v1.json | ||
# Schema version number | ||
version: 1 | ||
|
||
# The type of configuration schema | ||
kind: CompositeDevice | ||
|
||
# Name of the composite device mapping | ||
name: CEC | ||
|
||
# Maximum number of source devices per CompositeDevice. | ||
maximum_sources: 2 | ||
|
||
# Only use this profile if *any* of the given matches matches. If this list is | ||
# empty, then the source devices will *always* be checked. | ||
# /sys/class/dmi/id/product_name | ||
matches: [] | ||
|
||
# One or more source devices to combine into a single virtual device. The events | ||
# from these devices will be watched and translated according to the key map. | ||
source_devices: | ||
- group: gamepad | ||
udev: | ||
attributes: | ||
- name: protocols | ||
value: '\[cec\]' | ||
sys_name: "event*" | ||
subsystem: input | ||
- group: gamepad | ||
udev: | ||
sys_name: "cec*" | ||
subsystem: "cec" | ||
|
||
# Optional configuration for the composite device | ||
options: | ||
# If true, InputPlumber will automatically try to manage the input device. If | ||
# this is false, InputPlumber will not try to manage the device unless an | ||
# external service enables management of the device. Defaults to 'false' | ||
auto_manage: false | ||
|
||
# The target input device(s) to emulate by default | ||
target_devices: | ||
- xbox-elite | ||
- mouse | ||
- keyboard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
use std::error::Error; | ||
|
||
use device::CecRawDevice; | ||
|
||
use crate::{ | ||
config, | ||
input::{capability::Capability, composite_device::client::CompositeDeviceClient}, | ||
udev::device::UdevDevice, | ||
}; | ||
|
||
use super::{client::SourceDeviceClient, SourceDeviceCompatible, SourceDriver}; | ||
|
||
pub mod device; | ||
|
||
/// [CecDevice] represents an input device using CEC | ||
#[derive(Debug)] | ||
pub enum CecDevice { | ||
Device(SourceDriver<CecRawDevice>), | ||
} | ||
|
||
impl SourceDeviceCompatible for CecDevice { | ||
fn get_device_ref(&self) -> &UdevDevice { | ||
match self { | ||
Self::Device(source_driver) => source_driver.info_ref(), | ||
} | ||
} | ||
|
||
fn get_id(&self) -> String { | ||
match self { | ||
Self::Device(source_driver) => source_driver.get_id(), | ||
} | ||
} | ||
|
||
fn client(&self) -> SourceDeviceClient { | ||
match self { | ||
Self::Device(source_driver) => source_driver.client(), | ||
} | ||
} | ||
|
||
async fn run(self) -> Result<(), Box<dyn Error>> { | ||
match self { | ||
Self::Device(source_driver) => source_driver.run().await, | ||
} | ||
} | ||
|
||
fn get_capabilities(&self) -> Result<Vec<Capability>, super::InputError> { | ||
match self { | ||
Self::Device(source_driver) => source_driver.get_capabilities(), | ||
} | ||
} | ||
|
||
fn get_device_path(&self) -> String { | ||
match self { | ||
Self::Device(source_driver) => source_driver.get_device_path(), | ||
} | ||
} | ||
} | ||
|
||
impl CecDevice { | ||
pub fn new( | ||
device_info: UdevDevice, | ||
composite_device: CompositeDeviceClient, | ||
conf: Option<config::SourceDevice>, | ||
) -> Result<Self, Box<dyn Error + Send + Sync>> { | ||
let device = CecRawDevice::new(); | ||
let source_device = SourceDriver::new(composite_device, device, device_info, conf); | ||
Ok(Self::Device(source_device)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use cec_rs::{CecConnectionCfgBuilder, CecDeviceType, CecDeviceTypeVec}; | ||
|
||
use crate::input::{ | ||
capability::Capability, | ||
source::{InputError, SourceInputDevice, SourceOutputDevice}, | ||
}; | ||
|
||
#[derive(Debug)] | ||
pub struct CecRawDevice {} | ||
|
||
impl CecRawDevice { | ||
pub fn new() -> Self { | ||
let cfg = CecConnectionCfgBuilder::default() | ||
.device_types(CecDeviceTypeVec::new(CecDeviceType::AudioSystem)) | ||
.build(); | ||
Self {} | ||
} | ||
} | ||
|
||
impl Default for CecRawDevice { | ||
fn default() -> Self { | ||
Self::new() | ||
} | ||
} | ||
|
||
impl SourceInputDevice for CecRawDevice { | ||
fn poll(&mut self) -> Result<Vec<crate::input::event::native::NativeEvent>, InputError> { | ||
todo!() | ||
} | ||
|
||
fn get_capabilities(&self) -> Result<Vec<Capability>, InputError> { | ||
todo!() | ||
} | ||
} | ||
|
||
impl SourceOutputDevice for CecRawDevice {} |
Oops, something went wrong.