对于多种类型的报告,我如何使用org.bluetooth.characteristic.report_map?

时间:2015-03-25 17:58:44

标签: usb bluetooth-lowenergy core-bluetooth hid bluez

好吧,我正在构建一个带有用作鼠标的集成触摸屏的键盘,我通过HID OVER GATT发送通过BLE生成的数据。这适用于org.bluetooth.characteristic.boot_keyboard_input_report& org.bluetooth.characteristic.boot_mouse_input_report,但我不太确定如何根据这些声明配置report_map以及我需要发送的内容。

主要问题是,因为没有混合类型的用法,我需要使用两个用法。但是我需要第二个使用页面吗?如何定义这种混合设备的集合(应用程序)?

Usage Page
Usage Keyboard
??Usage Page
Usage Mouse

所以我像这样定义了我的report_map:

   0x05, 0x01, // Usage Page (Generic Desktop),
    0x09, 0x06, // Usage (Keyboard),
    0xA1, 0x01, // Collection (Application),
        0x05, 0x07, // Usage Page (Key Codes);
        0x19, 0xE0, // Usage Minimum (224),
        0x29, 0xE7, // Usage Maximum (231),
        0x15, 0x00, // Logical Minimum (0),
        0x25, 0x01, // Logical Maximum (1),
        0x75, 0x01, // Report Size (1),
        0x95, 0x08, // Report Count (8),
        0x81, 0x02, // Input (Data, Variable, Absolute),            ; Modifier-Byte 8 bit
        0x95, 0x01, // Report Count (1),
        0x75, 0x08, // Report Size (8),
        0x81, 0x01, // Input (Constant),                            ; Reserved byte 8 bit
        0x95, 0x05, // Report Count (5),
        0x75, 0x01, // Report Size (1),
        0x05, 0x08, // Usage Page (Page# for LEDs),                
        0x19, 0x01, // Usage Minimum (1),
        0x29, 0x05, // Usage Maximum (5),
        0x91, 0x02, // Output (Data, Variable, Absolute),           ; LED byte 5 bits
        0x95, 0x01, // Report Count (1),
        0x75, 0x03, // Report Size (3),
        0x91, 0x01, // Output (Constant),                           ; Padding of 3 bits
        0x95, 0x06, // Report Count (6),
        0x75, 0x08, // Report Size (8),
        0x15, 0x00, // Logical Minimum (0),
        0x25, 0x65, // Logical Maximum(101),
        0x05, 0x07, // Usage Page (Key Codes), 
        0x19, 0x00, // Usage Minimum (0),
        0x29, 0x65, // Usage Maximum (101),
        0x81, 0x00, // Input (Data, Array),
    0xC0, // End Collection    
    0x05, 0x01, // USAGE_PAGE (Generic Desktop)
    0x09, 0x02, // USAGE (Mouse)
    0xa1, 0x01, // COLLECTION (Application)
    0x09, 0x02, // USAGE (Mouse)
    0xa1, 0x02, // COLLECTION (Logical)
    0x09, 0x01, // USAGE (Pointer)
    0xa1, 0x00, // COLLECTION (Physical)
    // ------------------------------ Buttons
    0x05, 0x09, // USAGE_PAGE (Button) 
    0x19, 0x01, // USAGE_MINIMUM (Button 1)
    0x29, 0x05, // USAGE_MAXIMUM (Button 5)
    0x15, 0x00, // LOGICAL_MINIMUM (0)
    0x25, 0x01, // LOGICAL_MAXIMUM (1)
    0x75, 0x01, // REPORT_SIZE (1)
    0x95, 0x03, // REPORT_COUNT (3)
    0x81, 0x02, // INPUT (Data,Var,Abs)
    // ------------------------------ Padding
    0x75, 0x05, // REPORT_SIZE (5)
    0x95, 0x01, // REPORT_COUNT (1)
    0x81, 0x03, // INPUT (Cnst,Var,Abs)
    // ------------------------------ X,Y position
    0x05, 0x01, // USAGE_PAGE (Generic Desktop)
    0x09, 0x30, // USAGE (X)
    0x09, 0x31, // USAGE (Y)
    0x15, 0x81, // LOGICAL_MINIMUM (-127)
    0x25, 0x7f, // LOGICAL_MAXIMUM (127)
    0x75, 0x08, // REPORT_SIZE (8)
    0x95, 0x02, // REPORT_COUNT (2)
    0x81, 0x06, // INPUT (Data,Var,Rel)
    0xa1, 0x02, // COLLECTION (Logical)
    // ------------------------------ Vertical wheel res multiplier
    0x09, 0x48, // USAGE (Resolution Multiplier)
    0x15, 0x00, // LOGICAL_MINIMUM (0)
    0x25, 0x01, // LOGICAL_MAXIMUM (1)
    0x35, 0x01, // PHYSICAL_MINIMUM (1)
    0x45, 0x04, // PHYSICAL_MAXIMUM (4)
    0x75, 0x02, // REPORT_SIZE (2)
    0x95, 0x01, // REPORT_COUNT (1)
    0xa4, // PUSH
    0xb1, 0x02, // FEATURE (Data,Var,Abs)
    // ------------------------------ Vertical wheel
    0x09, 0x38, // USAGE (Wheel)
    0x15, 0x81, // LOGICAL_MINIMUM (-127)
    0x25, 0x7f, // LOGICAL_MAXIMUM (127)
    0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical
    0x45, 0x00, // PHYSICAL_MAXIMUM (0)
    0x75, 0x08, // REPORT_SIZE (8)
    0x81, 0x06, // INPUT (Data,Var,Rel)
    0xc0, // END_COLLECTION
    0xa1, 0x02, // COLLECTION (Logical)
    // ------------------------------ Horizontal wheel res multiplier
    0x09, 0x48, // USAGE (Resolution Multiplier)
    0xb4, // POP
    0xb1, 0x02, // FEATURE (Data,Var,Abs)
    // ------------------------------ Padding for Feature report
    0x35, 0x00, // PHYSICAL_MINIMUM (0) - reset physical
    0x45, 0x00, // PHYSICAL_MAXIMUM (0)
    0x75, 0x04, // REPORT_SIZE (4)
    0xb1, 0x03, // FEATURE (Cnst,Var,Abs)
    // ------------------------------ Horizontal wheel
    0x05, 0x0c, // USAGE_PAGE (Consumer Devices)
    0x0a, 0x38, 0x02, // USAGE (AC Pan)
    0x15, 0x81, // LOGICAL_MINIMUM (-127)
    0x25, 0x7f, // LOGICAL_MAXIMUM (127)
    0x75, 0x08, // REPORT_SIZE (8)
    0x81, 0x06, // INPUT (Data,Var,Rel)
    0xc0, // END_COLLECTION
    0xc0, // END_COLLECTION
    0xc0, // END_COLLECTION
    0xc0 // END_COLLECTION

我不完全确定,如果我被允许定义两个使用情况页面,或者我需要创建一个集合,但是那里有所有报告。

我不确定的第二件事是我如何为特定的INPUT报告创建值。他们是否通过报告ID获得了一些我无法获得的编号系统?或者他们必须立即发送(我猜这是对的)。

在我的情况下,报告看起来像这样:

// Output Report
// 
// Byte | D7            D6              D5              D4          D3              D2              D1          D0
// ------+---------------------------------------------------------------------
// 0    | NUM_LOCK      CAPS_LOCK       SCROLL_LOCK     COMPOSE     KANA            CONSTANT        CONSTANT    CONSTANT

// Input Report for Keyboard
// Byte | D7            D6              D5          D4          D3              D2              D1          D0
// ------+---------------------------------------------------------------------
// 0    | LEFT_CTRL     LEFT_SHIFT      LEFT_ALT    LEFT_OS     RIGHT_CTRL      RIGHT_SHIFT     RIGHT_ALT   RIGHT_OS
// 1    | Reserved please leave at 0
// 2-7  | Keycodes

// Input Report for Pointer
// Byte | D7 D6 D5 D4 D3 D2 D1 D0
// ------+---------------------------------------------------------------------
// 0 | 0 0 0 Forward Back Middle Right Left (Button)
// 1 | X
// 2 | Y
// 3 | Vertical Wheel
// 4 | Horizontal (Tilt) Wheel

提前致谢。

0 个答案:

没有答案