use flipperzero_sys as sys;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum App {
SubGhz,
Rfid,
Nfc,
Ir,
Ibutton,
Badusb,
Plugin,
#[non_exhaustive]
#[doc(hidden)]
Uncategorized(sys::DolphinApp),
}
impl App {
fn from_raw(raw: sys::DolphinApp) -> Self {
match raw {
sys::DolphinAppSubGhz => App::SubGhz,
sys::DolphinAppRfid => App::Rfid,
sys::DolphinAppNfc => App::Nfc,
sys::DolphinAppIr => App::Ir,
sys::DolphinAppIbutton => App::Ibutton,
sys::DolphinAppBadusb => App::Badusb,
sys::DolphinAppPlugin => App::Plugin,
raw => App::Uncategorized(raw),
}
}
fn to_raw(self) -> sys::DolphinApp {
match self {
App::SubGhz => sys::DolphinAppSubGhz,
App::Rfid => sys::DolphinAppRfid,
App::Nfc => sys::DolphinAppNfc,
App::Ir => sys::DolphinAppIr,
App::Ibutton => sys::DolphinAppIbutton,
App::Badusb => sys::DolphinAppBadusb,
App::Plugin => sys::DolphinAppPlugin,
App::Uncategorized(raw) => raw,
}
}
pub fn limit(self) -> u8 {
unsafe { sys::dolphin_deed_get_app_limit(self.to_raw()) }
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub enum Deed {
SubGhzReceiverInfo,
SubGhzSave,
SubGhzRawRec,
SubGhzAddManually,
SubGhzSend,
SubGhzFrequencyAnalyzer,
RfidRead,
RfidReadSuccess,
RfidSave,
RfidEmulate,
RfidAdd,
NfcRead,
NfcReadSuccess,
NfcSave,
NfcDetectReader,
NfcEmulate,
NfcKeyAdd,
NfcAddSave,
NfcAddEmulate,
IrSend,
IrLearnSuccess,
IrSave,
IbuttonRead,
IbuttonReadSuccess,
IbuttonSave,
IbuttonEmulate,
IbuttonAdd,
BadUsbPlayScript,
U2fAuthorized,
GpioUartBridge,
PluginStart,
PluginGameStart,
PluginGameWin,
#[non_exhaustive]
#[doc(hidden)]
Uncategorized(sys::DolphinDeed),
}
impl Deed {
pub(super) fn to_raw(self) -> sys::DolphinDeed {
match self {
Deed::SubGhzReceiverInfo => sys::DolphinDeedSubGhzReceiverInfo,
Deed::SubGhzSave => sys::DolphinDeedSubGhzSave,
Deed::SubGhzRawRec => sys::DolphinDeedSubGhzRawRec,
Deed::SubGhzAddManually => sys::DolphinDeedSubGhzAddManually,
Deed::SubGhzSend => sys::DolphinDeedSubGhzSend,
Deed::SubGhzFrequencyAnalyzer => sys::DolphinDeedSubGhzFrequencyAnalyzer,
Deed::RfidRead => sys::DolphinDeedRfidRead,
Deed::RfidReadSuccess => sys::DolphinDeedRfidReadSuccess,
Deed::RfidSave => sys::DolphinDeedRfidSave,
Deed::RfidEmulate => sys::DolphinDeedRfidEmulate,
Deed::RfidAdd => sys::DolphinDeedRfidAdd,
Deed::NfcRead => sys::DolphinDeedNfcRead,
Deed::NfcReadSuccess => sys::DolphinDeedNfcReadSuccess,
Deed::NfcSave => sys::DolphinDeedNfcSave,
Deed::NfcDetectReader => sys::DolphinDeedNfcDetectReader,
Deed::NfcEmulate => sys::DolphinDeedNfcEmulate,
Deed::NfcKeyAdd => sys::DolphinDeedNfcKeyAdd,
Deed::NfcAddSave => sys::DolphinDeedNfcAddSave,
Deed::NfcAddEmulate => sys::DolphinDeedNfcAddEmulate,
Deed::IrSend => sys::DolphinDeedIrSend,
Deed::IrLearnSuccess => sys::DolphinDeedIrLearnSuccess,
Deed::IrSave => sys::DolphinDeedIrSave,
Deed::IbuttonRead => sys::DolphinDeedIbuttonRead,
Deed::IbuttonReadSuccess => sys::DolphinDeedIbuttonReadSuccess,
Deed::IbuttonSave => sys::DolphinDeedIbuttonSave,
Deed::IbuttonEmulate => sys::DolphinDeedIbuttonEmulate,
Deed::IbuttonAdd => sys::DolphinDeedIbuttonAdd,
Deed::BadUsbPlayScript => sys::DolphinDeedBadUsbPlayScript,
Deed::U2fAuthorized => sys::DolphinDeedU2fAuthorized,
Deed::GpioUartBridge => sys::DolphinDeedGpioUartBridge,
Deed::PluginStart => sys::DolphinDeedPluginStart,
Deed::PluginGameStart => sys::DolphinDeedPluginGameStart,
Deed::PluginGameWin => sys::DolphinDeedPluginGameWin,
Deed::Uncategorized(raw) => raw,
}
}
pub fn app(self) -> App {
App::from_raw(unsafe { sys::dolphin_deed_get_app(self.to_raw()) })
}
pub fn weight(self) -> u8 {
unsafe { sys::dolphin_deed_get_weight(self.to_raw()) }
}
}