use crate::{Command, Protocol};
#[derive(Debug)]
pub enum DeviceType {
Generic,
TV,
DVDPlayer,
CDPlayer,
BluRayPlayer,
}
pub trait RemoteControl {
const MODEL: &'static str = "<NONAME>";
const DEVTYPE: DeviceType = DeviceType::Generic;
const PROTOCOL: Protocol = Protocol::Unknown;
const ADDRESS: u32;
type Cmd: Command;
const BUTTONS: &'static [(u8, Button)] = &[];
fn decode(cmd: Self::Cmd) -> Option<Button> {
if Self::ADDRESS != cmd.address() {
return None;
}
Self::BUTTONS
.iter()
.find(|(c, _)| u32::from(*c) == cmd.data())
.map(|(_, b)| *b)
}
fn encode(button: Button) -> Option<Self::Cmd> {
Self::BUTTONS
.iter()
.find(|(_, b)| *b == button)
.and_then(|(c, _)| Self::Cmd::construct(Self::ADDRESS, *c as u32))
}
}
#[allow(non_camel_case_types)]
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[non_exhaustive]
pub enum Button {
Power,
Source,
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Zero,
Teletext,
ChannelPrev,
VolumeUp,
VolumeDown,
VolumeMute,
ChannelList,
ChannelListNext,
ChannelListPrev,
Tools,
Info,
Return,
Exit,
Enter,
Up,
Down,
Left,
Right,
Red,
Green,
Yellow,
Blue,
Emanual,
PictureSize,
Subtitle,
Stop,
Rewind,
Play,
Paus,
Play_Paus,
Forward,
Mode,
Shuffle,
U_SD,
Plus,
Minus,
Next,
Prev,
Eq,
Mute,
Random,
Repeat,
Time,
Setup,
PitchReset,
PitchPlus,
PitchMinus,
Prog,
}