Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 790198f6 authored by Sonny Sasaka's avatar Sonny Sasaka
Browse files

Add constructor for HidHost

This adds `new` function to HidHost to construct it from a
`BluetoothInterface`.

Bug: 186492781
Tag: #floss
Test: manual - build floss on Linux

Change-Id: Ic399c5f49151f3a0d3b0dbdb1efb2fdcfc5d3cc8
parent 8ebead2a
Loading
Loading
Loading
Loading
+12 −2
Original line number Original line Diff line number Diff line
use crate::bindings::root as bindings;
use crate::bindings::root as bindings;
use crate::btif::RawAddress;
use crate::btif::{BluetoothInterface, RawAddress, SupportedProfiles};
use crate::ccall;
use crate::ccall;
use crate::profiles::hid_host::bindings::bthh_interface_t;
use crate::topstack::get_dispatchers;
use crate::topstack::get_dispatchers;


use num_traits::cast::{FromPrimitive, ToPrimitive};
use num_traits::cast::{FromPrimitive, ToPrimitive};
@@ -107,7 +108,7 @@ pub enum HHCallbacks {
}
}


pub struct HHCallbacksDispatcher {
pub struct HHCallbacksDispatcher {
    dispatch: Box<dyn Fn(HHCallbacks) + Send>,
    pub dispatch: Box<dyn Fn(HHCallbacks) + Send>,
}
}


type HHCb = Arc<Mutex<HHCallbacksDispatcher>>;
type HHCb = Arc<Mutex<HHCallbacksDispatcher>>;
@@ -158,6 +159,15 @@ pub struct HidHost {
}
}


impl HidHost {
impl HidHost {
    pub fn new(intf: &BluetoothInterface) -> HidHost {
        let r = intf.get_profile_interface(SupportedProfiles::HidHost);
        HidHost {
            internal: RawHHWrapper { raw: r as *const bthh_interface_t },
            is_init: false,
            callbacks: None,
        }
    }

    pub fn is_initialized(&self) -> bool {
    pub fn is_initialized(&self) -> bool {
        self.is_init
        self.is_init
    }
    }