mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-06-07 19:01:54 -07:00
Adds hal modifications
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,11.3,,
|
||||
Version,v,12.0,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
Header,+,applications/services/cli/cli_vcp.h,,
|
||||
@@ -572,7 +572,7 @@ Function,+,bt_disconnect,void,Bt*
|
||||
Function,+,bt_forget_bonded_devices,void,Bt*
|
||||
Function,+,bt_keys_storage_set_default_path,void,Bt*
|
||||
Function,+,bt_keys_storage_set_storage_path,void,"Bt*, const char*"
|
||||
Function,+,bt_set_profile,_Bool,"Bt*, BtProfile"
|
||||
Function,?,bt_set_profile,_Bool,"Bt*, BtProfile"
|
||||
Function,+,bt_set_status_changed_callback,void,"Bt*, BtStatusChangedCallback, void*"
|
||||
Function,+,buffered_file_stream_alloc,Stream*,Storage*
|
||||
Function,+,buffered_file_stream_close,_Bool,Stream*
|
||||
@@ -1000,6 +1000,7 @@ Function,+,furi_hal_bt_get_transmitted_packets,uint32_t,
|
||||
Function,+,furi_hal_bt_hid_consumer_key_press,_Bool,uint16_t
|
||||
Function,+,furi_hal_bt_hid_consumer_key_release,_Bool,uint16_t
|
||||
Function,+,furi_hal_bt_hid_consumer_key_release_all,_Bool,
|
||||
Function,?,furi_hal_bt_hid_kb_free_slots,_Bool,uint8_t
|
||||
Function,+,furi_hal_bt_hid_kb_press,_Bool,uint16_t
|
||||
Function,+,furi_hal_bt_hid_kb_release,_Bool,uint16_t
|
||||
Function,+,furi_hal_bt_hid_kb_release_all,_Bool,
|
||||
@@ -1016,6 +1017,7 @@ Function,+,furi_hal_bt_is_alive,_Bool,
|
||||
Function,+,furi_hal_bt_is_ble_gatt_gap_supported,_Bool,
|
||||
Function,+,furi_hal_bt_is_testing_supported,_Bool,
|
||||
Function,+,furi_hal_bt_lock_core2,void,
|
||||
Function,?,furi_hal_bt_modify_profile_adv_name,void,"const char*, FuriHalBtProfile"
|
||||
Function,+,furi_hal_bt_nvm_sram_sem_acquire,void,
|
||||
Function,+,furi_hal_bt_nvm_sram_sem_release,void,
|
||||
Function,+,furi_hal_bt_reinit,void,
|
||||
|
||||
|
@@ -219,8 +219,10 @@ bool furi_hal_bt_start_app(FuriHalBtProfile profile, GapEventCallback event_cb,
|
||||
// Change MAC address for HID profile
|
||||
config->mac_address[2]++;
|
||||
// Change name Flipper -> Control
|
||||
const char* clicker_str = "Control";
|
||||
memcpy(&config->adv_name[1], clicker_str, strlen(clicker_str));
|
||||
if (strlen(&config->adv_name[1]) > 1) {
|
||||
const char* clicker_str = "Control";
|
||||
memcpy(&config->adv_name[1], clicker_str, strlen(clicker_str));
|
||||
}
|
||||
}
|
||||
if(!gap_init(config, event_cb, context)) {
|
||||
gap_thread_stop();
|
||||
@@ -444,3 +446,11 @@ bool furi_hal_bt_ensure_c2_mode(BleGlueC2Mode mode) {
|
||||
FURI_LOG_E(TAG, "Failed to switch C2 mode: %d", fw_start_res);
|
||||
return false;
|
||||
}
|
||||
|
||||
void furi_hal_bt_modify_profile_adv_name(const char* name, FuriHalBtProfile profile) {
|
||||
furi_assert(name);
|
||||
furi_assert(strlen(name) < FURI_HAL_VERSION_DEVICE_NAME_LENGTH);
|
||||
furi_assert(profile < FuriHalBtProfileNumber);
|
||||
|
||||
strncpy(profile_config[profile].config.adv_name, name, FURI_HAL_VERSION_DEVICE_NAME_LENGTH);
|
||||
}
|
||||
|
||||
@@ -138,24 +138,10 @@ void furi_hal_bt_hid_start() {
|
||||
if(!hid_svc_is_started()) {
|
||||
hid_svc_start();
|
||||
}
|
||||
// Configure HID Keyboard
|
||||
//
|
||||
// this will also be called by Bad-usb now, so we need to prevent memory leak
|
||||
// I dont know for now, how apps and mains interacts together, so lets add some
|
||||
// protection in case a crash in one doesn't affect the other
|
||||
if(kb_report)
|
||||
memset(kb_report, 0, sizeof(FuriHalBtHidKbReport));
|
||||
else
|
||||
kb_report = malloc(sizeof(FuriHalBtHidKbReport));
|
||||
|
||||
if(mouse_report)
|
||||
memset(mouse_report, 0, sizeof(FuriHalBtHidMouseReport));
|
||||
else
|
||||
mouse_report = malloc(sizeof(FuriHalBtHidMouseReport));
|
||||
if(consumer_report)
|
||||
memset(consumer_report, 0, sizeof(FuriHalBtHidConsumerReport));
|
||||
else
|
||||
consumer_report = malloc(sizeof(FuriHalBtHidConsumerReport));
|
||||
kb_report = malloc(sizeof(FuriHalBtHidKbReport));
|
||||
mouse_report = malloc(sizeof(FuriHalBtHidMouseReport));
|
||||
consumer_report = malloc(sizeof(FuriHalBtHidConsumerReport));
|
||||
|
||||
// Configure Report Map characteristic
|
||||
hid_svc_update_report_map(
|
||||
@@ -195,17 +181,30 @@ void furi_hal_bt_hid_stop() {
|
||||
|
||||
bool furi_hal_bt_hid_kb_press(uint16_t button) {
|
||||
furi_assert(kb_report);
|
||||
for(uint8_t i = 0; i < FURI_HAL_BT_HID_KB_MAX_KEYS; i++) {
|
||||
uint8_t i;
|
||||
for(i = 0; i < FURI_HAL_BT_HID_KB_MAX_KEYS; i++) {
|
||||
if(kb_report->key[i] == 0) {
|
||||
kb_report->key[i] = button & 0xFF;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i == FURI_HAL_BT_HID_KB_MAX_KEYS) {
|
||||
return false;
|
||||
}
|
||||
kb_report->mods |= (button >> 8);
|
||||
return hid_svc_update_input_report(
|
||||
ReportNumberKeyboard, (uint8_t*)kb_report, sizeof(FuriHalBtHidKbReport));
|
||||
}
|
||||
|
||||
bool furi_hal_bt_hid_kb_free_slots(uint8_t n_empty_slots) {
|
||||
furi_assert(kb_report);
|
||||
for(uint8_t i = 0; n_empty_slots > 0 && i < FURI_HAL_BT_HID_KB_MAX_KEYS; i++) {
|
||||
if(kb_report->key[i] == 0)
|
||||
n_empty_slots--;
|
||||
}
|
||||
return (n_empty_slots == 0);
|
||||
}
|
||||
|
||||
bool furi_hal_bt_hid_kb_release(uint16_t button) {
|
||||
furi_assert(kb_report);
|
||||
for(uint8_t i = 0; i < FURI_HAL_BT_HID_KB_MAX_KEYS; i++) {
|
||||
|
||||
@@ -224,6 +224,8 @@ uint32_t furi_hal_bt_get_transmitted_packets();
|
||||
*/
|
||||
bool furi_hal_bt_ensure_c2_mode(BleGlueC2Mode mode);
|
||||
|
||||
void furi_hal_bt_modify_profile_adv_name(const char* name, FuriHalBtProfile profile);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -86,6 +86,15 @@ bool furi_hal_bt_hid_consumer_key_release(uint16_t button);
|
||||
*/
|
||||
bool furi_hal_bt_hid_consumer_key_release_all();
|
||||
|
||||
/**
|
||||
* @brief Check if keyboard buffer has free slots
|
||||
*
|
||||
* @param n_emptry_slots number of empty slots in buffer to consider buffer is not full
|
||||
*
|
||||
* @return true if there is enough free slots in buffer
|
||||
*/
|
||||
bool furi_hal_bt_hid_kb_free_slots(uint8_t n_empty_slots);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user