This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Using sample sample ble_app_hids_mouse,the AC HOME can't be controled, but Android can!(IOS12.1.4)

static uint8_t rep_map_data[] =
{
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x02, // Usage (Mouse)

0xA1, 0x01, // Collection (Application)

// Report ID 1: Mouse buttons + scroll/pan
0x85, 0x01, // Report Id 1
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection (Physical)
0x95, 0x05, // Report Count (3)
0x75, 0x01, // Report Size (1)
0x05, 0x09, // Usage Page (Buttons)
0x19, 0x01, // Usage Minimum (01)
0x29, 0x05, // Usage Maximum (05)
0x15, 0x00, // Logical Minimum (0)
0x25, 0x01, // Logical Maximum (1)
0x81, 0x02, // Input (Data, Variable, Absolute)
0x95, 0x01, // Report Count (1)
0x75, 0x03, // Report Size (3)
0x81, 0x01, // Input (Constant) for padding
0x75, 0x08, // Report Size (8)
0x95, 0x01, // Report Count (1)
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x38, // Usage (Wheel)
0x15, 0x81, // Logical Minimum (-127)
0x25, 0x7F, // Logical Maximum (127)
0x81, 0x06, // Input (Data, Variable, Relative)
0x05, 0x0C, // Usage Page (Consumer)
0x0A, 0x38, 0x02, // Usage (AC Pan)
0x95, 0x01, // Report Count (1)
0x81, 0x06, // Input (Data,Value,Relative,Bit Field)
0xC0, // End Collection (Physical)

// Report ID 2: Mouse motion
0x85, 0x02, // Report Id 2
0x09, 0x01, // Usage (Pointer)
0xA1, 0x00, // Collection (Physical)
0x75, 0x0C, // Report Size (12)
0x95, 0x02, // Report Count (2)
0x05, 0x01, // Usage Page (Generic Desktop)
0x09, 0x30, // Usage (X)
0x09, 0x31, // Usage (Y)
0x16, 0x01, 0xF8, // Logical maximum (2047)
0x26, 0xFF, 0x07, // Logical minimum (-2047)
0x81, 0x06, // Input (Data, Variable, Relative)
0xC0, // End Collection (Physical)
0xC0, // End Collection (Application)

// Report ID 3: Advanced buttons
0x05, 0x0C, // Usage Page (Consumer)
0x09, 0x01, // Usage (Consumer Control)
0xA1, 0x01, // Collection (Application)
0x85, 0x03, // Report Id (3)
0x15, 0x00, // Logical minimum (0)
0x25, 0x02, // Logical maximum (1)
0x75, 0x01, // Report Size (1)
0x95, 0x01, // Report Count (1)

0x09, 0xCD, // Usage (Play/Pause)
0x81, 0x06, // Input (Data,Value,Relative,Bit Field)
0x0A, 0x83, 0x01, // Usage (AL Consumer Control Configuration)
0x81, 0x06, // Input (Data,Value,Relative,Bit Field)
0x09, 0xB5, // Usage (Scan Next Track)
0x81, 0x06, // Input (Data,Value,Relative,Bit Field)
0x09, 0xB6, // Usage (Scan Previous Track)
0x81, 0x06, // Input (Data,Value,Relative,Bit Field)

0x09, 0xEA, // Usage (Volume Down)
0x81, 0x06, // Input (Data,Value,Relative,Bit Field)
0x09, 0xE9, // Usage (Volume Up)
0x81, 0x06, // Input (Data,Value,Relative,Bit Field)
0x0A, 0x25, 0x02, // Usage (AC Forward)
0x81, 0x06, // Input (Data,Value,Relative,Bit Field)
0x0A, 0x23, 0x02, // Usage (AC Home)
0x81, 0x06, // Input (Data,Value,Relative,Bit Field)
0xC0 // End Collection
};

void media_player_control(uint8_t control)
{
uint32_t err_code;
uint8_t buffer[1];

buffer[0] = control;

err_code = ble_hids_inp_rep_send( &m_hids,INPUT_REP_MPLAYER_INDEX,1,buffer );

if(( err_code != NRF_SUCCESS ) &&( err_code != NRF_ERROR_INVALID_STATE ) &&( err_code != BLE_ERROR_NO_TX_BUFFERS ) &&

( err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING ))

{

APP_ERROR_HANDLER( err_code );

}

buffer[0] = 0;
err_code = ble_hids_inp_rep_send( &m_hids,INPUT_REP_MPLAYER_INDEX,1,buffer );

if(( err_code != NRF_SUCCESS ) &&( err_code != NRF_ERROR_INVALID_STATE ) &&( err_code != BLE_ERROR_NO_TX_BUFFERS ) &&
( err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING ))
{

APP_ERROR_HANDLER( err_code );

}

}

static void bsp_event_handler(bsp_event_t event)
{
uint32_t err_code;
switch (event)
{
case BSP_EVENT_SLEEP:
sleep_mode_enter();
break;

case BSP_EVENT_DISCONNECT:
err_code = sd_ble_gap_disconnect(m_conn_handle, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
if (err_code != NRF_ERROR_INVALID_STATE)
{
APP_ERROR_CHECK(err_code);
}
break;

case BSP_EVENT_WHITELIST_OFF:
err_code = ble_advertising_restart_without_whitelist();
if (err_code != NRF_ERROR_INVALID_STATE)
{
APP_ERROR_CHECK(err_code);
}
break;

case BSP_EVENT_KEY_0:
if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
{
media_player_control(0x80);
// mouse_movement_send(-MOVEMENT_SPEED, 0);
}
break;

case BSP_EVENT_KEY_1:
if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
{
media_player_control(0x10);
// mouse_movement_send(0, -MOVEMENT_SPEED);
}
break;

case BSP_EVENT_KEY_2:
if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
{
mouse_movement_send(MOVEMENT_SPEED, 0);
}
break;

case BSP_EVENT_KEY_3:
if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
{
mouse_movement_send(0, MOVEMENT_SPEED);
}
break;

default:
break;
}
}

Related