예제 #1
0
#define CNST_VAR_ABS 0x3
#define BUTTON 0x9
#define PHYSICAL 0x0

PROGMEM const char usbHidReportDescriptor[USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH] = {
	USAGE_PAGE(GENERIC_DESKTOP)
	USAGE(GAME_PAD)
	COLLECTION(APPLICATION)
		COLLECTION(PHYSICAL)
			USAGE_PAGE(BUTTON)
			USAGE_MINIMUM(1)
			USAGE_MAXIMUM(31)
			LOGICAL_MINIMUM(0)
			LOGICAL_MAXIMUM(1)
			REPORT_COUNT(31)
			REPORT_SIZE(1)
			INPUT(DATA_VAR_ABS)
			REPORT_COUNT(1)
			REPORT_SIZE(1)
			INPUT(CNST_VAR_ABS)
		END_COLLECTION
	END_COLLECTION
};

typedef struct
{
	uint8_t buttons0;
	uint8_t buttons1;
	uint8_t buttons2;
	uint8_t buttons3;
	
예제 #2
0
uint8_t * USBMouseKeyboard::reportDesc() {
    if (mouse_type == REL_MOUSE) {
        static uint8_t reportDescriptor[] = {
                // Keyboard
                USAGE_PAGE(1),      0x01,
                USAGE(1),           0x06,
                COLLECTION(1),      0x01,
                REPORT_ID(1),       REPORT_ID_KEYBOARD,
                USAGE_PAGE(1),      0x07,
                USAGE_MINIMUM(1),       0xE0,
                USAGE_MAXIMUM(1),       0xE7,
                LOGICAL_MINIMUM(1),     0x00,
                LOGICAL_MAXIMUM(1),     0x01,
                REPORT_SIZE(1),     0x01,
                REPORT_COUNT(1),    0x08,
                INPUT(1),           0x02,
                REPORT_COUNT(1),    0x01,
                REPORT_SIZE(1),     0x08,
                INPUT(1),           0x01,
                REPORT_COUNT(1),    0x05,
                REPORT_SIZE(1),     0x01,
                USAGE_PAGE(1),      0x08,
                USAGE_MINIMUM(1),       0x01,
                USAGE_MAXIMUM(1),       0x05,
                OUTPUT(1),          0x02,
                REPORT_COUNT(1),    0x01,
                REPORT_SIZE(1),     0x03,
                OUTPUT(1),          0x01,
                REPORT_COUNT(1),    0x06,
                REPORT_SIZE(1),     0x08,
                LOGICAL_MINIMUM(1),     0x00,
                LOGICAL_MAXIMUM(2),     0xff, 0x00,
                USAGE_PAGE(1),      0x07,
                USAGE_MINIMUM(1),       0x00,
                USAGE_MAXIMUM(2),       0xff, 0x00,
                INPUT(1),           0x00,
                END_COLLECTION(0),

                // Mouse
                USAGE_PAGE(1),      0x01,           // Generic Desktop
                USAGE(1),           0x02,           // Mouse
                COLLECTION(1),      0x01,           // Application
                USAGE(1),           0x01,           // Pointer
                COLLECTION(1),      0x00,           // Physical
                REPORT_ID(1),       REPORT_ID_MOUSE,
                REPORT_COUNT(1),    0x03,
                REPORT_SIZE(1),     0x01,
                USAGE_PAGE(1),      0x09,           // Buttons
                USAGE_MINIMUM(1),       0x1,
                USAGE_MAXIMUM(1),       0x3,
                LOGICAL_MINIMUM(1),     0x00,
                LOGICAL_MAXIMUM(1),     0x01,
                INPUT(1),           0x02,
                REPORT_COUNT(1),    0x01,
                REPORT_SIZE(1),     0x05,
                INPUT(1),           0x01,
                REPORT_COUNT(1),    0x03,
                REPORT_SIZE(1),     0x08,
                USAGE_PAGE(1),      0x01,
                USAGE(1),           0x30,           // X
                USAGE(1),           0x31,           // Y
                USAGE(1),           0x38,           // scroll
                LOGICAL_MINIMUM(1),     0x81,
                LOGICAL_MAXIMUM(1),     0x7f,
                INPUT(1),           0x06,
                END_COLLECTION(0),
                END_COLLECTION(0),


                // Media Control
                USAGE_PAGE(1), 0x0C,
                USAGE(1), 0x01,
                COLLECTION(1), 0x01,
                REPORT_ID(1), REPORT_ID_VOLUME,
                USAGE_PAGE(1), 0x0C,
                LOGICAL_MINIMUM(1), 0x00,
                LOGICAL_MAXIMUM(1), 0x01,
                REPORT_SIZE(1), 0x01,
                REPORT_COUNT(1), 0x07,
                USAGE(1), 0xB5,             // Next Track
                USAGE(1), 0xB6,             // Previous Track
                USAGE(1), 0xB7,             // Stop
                USAGE(1), 0xCD,             // Play / Pause
                USAGE(1), 0xE2,             // Mute
                USAGE(1), 0xE9,             // Volume Up
                USAGE(1), 0xEA,             // Volume Down
                INPUT(1), 0x02,             // Input (Data, Variable, Absolute)
                REPORT_COUNT(1), 0x01,
                INPUT(1), 0x01,
                END_COLLECTION(0),
        };
        reportLength = sizeof(reportDescriptor);
        return reportDescriptor;
    } else if (mouse_type == ABS_MOUSE) {
        static uint8_t reportDescriptor[] = {

                // Keyboard
                USAGE_PAGE(1),      0x01,
                USAGE(1),           0x06,
                COLLECTION(1),      0x01,
                REPORT_ID(1),       REPORT_ID_KEYBOARD,
                USAGE_PAGE(1),      0x07,
                USAGE_MINIMUM(1),       0xE0,
                USAGE_MAXIMUM(1),       0xE7,
                LOGICAL_MINIMUM(1),     0x00,
                LOGICAL_MAXIMUM(1),     0x01,
                REPORT_SIZE(1),     0x01,
                REPORT_COUNT(1),    0x08,
                INPUT(1),           0x02,
                REPORT_COUNT(1),    0x01,
                REPORT_SIZE(1),     0x08,
                INPUT(1),           0x01,
                REPORT_COUNT(1),    0x05,
                REPORT_SIZE(1),     0x01,
                USAGE_PAGE(1),      0x08,
                USAGE_MINIMUM(1),       0x01,
                USAGE_MAXIMUM(1),       0x05,
                OUTPUT(1),          0x02,
                REPORT_COUNT(1),    0x01,
                REPORT_SIZE(1),     0x03,
                OUTPUT(1),          0x01,
                REPORT_COUNT(1),    0x06,
                REPORT_SIZE(1),     0x08,
                LOGICAL_MINIMUM(1),     0x00,
                LOGICAL_MAXIMUM(2),     0xff, 0x00,
                USAGE_PAGE(1),      0x07,
                USAGE_MINIMUM(1),       0x00,
                USAGE_MAXIMUM(2),       0xff, 0x00,
                INPUT(1),           0x00,
                END_COLLECTION(0),

                // Mouse
                USAGE_PAGE(1), 0x01,               // Generic Desktop
                USAGE(1), 0x02,                    // Mouse
                COLLECTION(1), 0x01,               // Application
                USAGE(1), 0x01,                    // Pointer
                COLLECTION(1), 0x00,               // Physical
                REPORT_ID(1),       REPORT_ID_MOUSE,

                USAGE_PAGE(1), 0x01,                // Generic Desktop
                USAGE(1), 0x30,                     // X
                USAGE(1), 0x31,                     // Y
                LOGICAL_MINIMUM(1), 0x00,           // 0
                LOGICAL_MAXIMUM(2), 0xff, 0x7f,     // 32767
                REPORT_SIZE(1), 0x10,
                REPORT_COUNT(1), 0x02,
                INPUT(1), 0x02,                     // Data, Variable, Absolute

                USAGE_PAGE(1), 0x01,                // Generic Desktop
                USAGE(1), 0x38,                     // scroll
                LOGICAL_MINIMUM(1), 0x81,           // -127
                LOGICAL_MAXIMUM(1), 0x7f,           // 127
                REPORT_SIZE(1), 0x08,
                REPORT_COUNT(1), 0x01,
                INPUT(1), 0x06,                     // Data, Variable, Relative

                USAGE_PAGE(1), 0x09,                // Buttons
                USAGE_MINIMUM(1), 0x01,
                USAGE_MAXIMUM(1), 0x03,
                LOGICAL_MINIMUM(1), 0x00,           // 0
                LOGICAL_MAXIMUM(1), 0x01,           // 1
                REPORT_COUNT(1), 0x03,
                REPORT_SIZE(1), 0x01,
                INPUT(1), 0x02,                     // Data, Variable, Absolute
                REPORT_COUNT(1), 0x01,
                REPORT_SIZE(1), 0x05,
                INPUT(1), 0x01,                     // Constant

                END_COLLECTION(0),
                END_COLLECTION(0),

                // Media Control
                USAGE_PAGE(1), 0x0C,
                USAGE(1), 0x01,
                COLLECTION(1), 0x01,
                REPORT_ID(1), REPORT_ID_VOLUME,
                USAGE_PAGE(1), 0x0C,
                LOGICAL_MINIMUM(1), 0x00,
                LOGICAL_MAXIMUM(1), 0x01,
                REPORT_SIZE(1), 0x01,
                REPORT_COUNT(1), 0x07,
                USAGE(1), 0xB5,             // Next Track
                USAGE(1), 0xB6,             // Previous Track
                USAGE(1), 0xB7,             // Stop
                USAGE(1), 0xCD,             // Play / Pause
                USAGE(1), 0xE2,             // Mute
                USAGE(1), 0xE9,             // Volume Up
                USAGE(1), 0xEA,             // Volume Down
                INPUT(1), 0x02,             // Input (Data, Variable, Absolute)
                REPORT_COUNT(1), 0x01,
                INPUT(1), 0x01,
                END_COLLECTION(0),
        };
        reportLength = sizeof(reportDescriptor);
        return reportDescriptor;
    }

    return NULL;
}
예제 #3
0
uint8_t * USBMouse::reportDesc() {

    if (mouse_type == REL_MOUSE) {
        static uint8_t reportDescriptor[] = {
            USAGE_PAGE(1),      0x01,       // Genric Desktop
            USAGE(1),           0x02,       // Mouse
            COLLECTION(1),      0x01,       // Application
            USAGE(1),           0x01,       // Pointer
            COLLECTION(1),      0x00,       // Physical

            REPORT_COUNT(1),    0x03,
            REPORT_SIZE(1),     0x01,
            USAGE_PAGE(1),      0x09,       // Buttons
            USAGE_MINIMUM(1),       0x1,
            USAGE_MAXIMUM(1),       0x3,
            LOGICAL_MINIMUM(1),     0x00,
            LOGICAL_MAXIMUM(1),     0x01,
            INPUT(1),           0x02,
            REPORT_COUNT(1),    0x01,
            REPORT_SIZE(1),     0x05,
            INPUT(1),           0x01,

            REPORT_COUNT(1),    0x03,
            REPORT_SIZE(1),     0x08,
            USAGE_PAGE(1),      0x01,
            USAGE(1),           0x30,       // X
            USAGE(1),           0x31,       // Y
            USAGE(1),           0x38,       // scroll
            LOGICAL_MINIMUM(1),     0x81,
            LOGICAL_MAXIMUM(1),     0x7f,
            INPUT(1),           0x06,       // Relative data

            END_COLLECTION(0),
            END_COLLECTION(0),
        };
        reportLength = sizeof(reportDescriptor);
        return reportDescriptor;
    } else if (mouse_type == ABS_MOUSE) {
        static uint8_t reportDescriptor[] = {

            USAGE_PAGE(1), 0x01,           // Generic Desktop
            USAGE(1), 0x02,                // Mouse
            COLLECTION(1), 0x01,           // Application
            USAGE(1), 0x01,                // Pointer
            COLLECTION(1), 0x00,           // Physical

            USAGE_PAGE(1), 0x01,            // Generic Desktop
            USAGE(1), 0x30,                 // X
            USAGE(1), 0x31,                 // Y
            LOGICAL_MINIMUM(1), 0x00,       // 0
            LOGICAL_MAXIMUM(2), 0xff, 0x7f, // 32767
            REPORT_SIZE(1), 0x10,
            REPORT_COUNT(1), 0x02,
            INPUT(1), 0x02,                 // Data, Variable, Absolute

            USAGE_PAGE(1), 0x01,            // Generic Desktop
            USAGE(1), 0x38,                 // scroll
            LOGICAL_MINIMUM(1), 0x81,       // -127
            LOGICAL_MAXIMUM(1), 0x7f,       // 127
            REPORT_SIZE(1), 0x08,
            REPORT_COUNT(1), 0x01,
            INPUT(1), 0x06,                 // Data, Variable, Relative

            USAGE_PAGE(1), 0x09,            // Buttons
            USAGE_MINIMUM(1), 0x01,
            USAGE_MAXIMUM(1), 0x03,
            LOGICAL_MINIMUM(1), 0x00,       // 0
            LOGICAL_MAXIMUM(1), 0x01,       // 1
            REPORT_COUNT(1), 0x03,
            REPORT_SIZE(1), 0x01,
            INPUT(1), 0x02,                 // Data, Variable, Absolute
            REPORT_COUNT(1), 0x01,
            REPORT_SIZE(1), 0x05,
            INPUT(1), 0x01,                 // Constant

            END_COLLECTION(0),
            END_COLLECTION(0)
        };
        reportLength = sizeof(reportDescriptor);
        return reportDescriptor;
    }
    return NULL;
}
예제 #4
0
uint8_t * USBKeyboard::reportDesc() {
    static uint8_t reportDescriptor[] = {
        USAGE_PAGE(1), 0x01,                    // Generic Desktop
        USAGE(1), 0x06,                         // Keyboard
        COLLECTION(1), 0x01,                    // Application
        REPORT_ID(1),       REPORT_ID_KEYBOARD,

        USAGE_PAGE(1), 0x07,                    // Key Codes
        USAGE_MINIMUM(1), 0xE0,
        USAGE_MAXIMUM(1), 0xE7,
        LOGICAL_MINIMUM(1), 0x00,
        LOGICAL_MAXIMUM(1), 0x01,
        REPORT_SIZE(1), 0x01,
        REPORT_COUNT(1), 0x08,
        INPUT(1), 0x02,                         // Data, Variable, Absolute
        REPORT_COUNT(1), 0x01,
        REPORT_SIZE(1), 0x08,
        INPUT(1), 0x01,                         // Constant


        REPORT_COUNT(1), 0x05,
        REPORT_SIZE(1), 0x01,
        USAGE_PAGE(1), 0x08,                    // LEDs
        USAGE_MINIMUM(1), 0x01,
        USAGE_MAXIMUM(1), 0x05,
        OUTPUT(1), 0x02,                        // Data, Variable, Absolute
        REPORT_COUNT(1), 0x01,
        REPORT_SIZE(1), 0x03,
        OUTPUT(1), 0x01,                        // Constant


        REPORT_COUNT(1), 0x06,
        REPORT_SIZE(1), 0x08,
        LOGICAL_MINIMUM(1), 0x00,
        LOGICAL_MAXIMUM(1), 0x65,
        USAGE_PAGE(1), 0x07,                    // Key Codes
        USAGE_MINIMUM(1), 0x00,
        USAGE_MAXIMUM(1), 0x65,
        INPUT(1), 0x00,                         // Data, Array
        END_COLLECTION(0),

        // Media Control
        USAGE_PAGE(1), 0x0C,
        USAGE(1), 0x01,
        COLLECTION(1), 0x01,
        REPORT_ID(1), REPORT_ID_VOLUME,
        USAGE_PAGE(1), 0x0C,
        LOGICAL_MINIMUM(1), 0x00,
        LOGICAL_MAXIMUM(1), 0x01,
        REPORT_SIZE(1), 0x01,
        REPORT_COUNT(1), 0x07,
        USAGE(1), 0xB5,             // Next Track
        USAGE(1), 0xB6,             // Previous Track
        USAGE(1), 0xB7,             // Stop
        USAGE(1), 0xCD,             // Play / Pause
        USAGE(1), 0xE2,             // Mute
        USAGE(1), 0xE9,             // Volume Up
        USAGE(1), 0xEA,             // Volume Down
        INPUT(1), 0x02,             // Input (Data, Variable, Absolute)
        REPORT_COUNT(1), 0x01,
        INPUT(1), 0x01,
        END_COLLECTION(0),
    };
    reportLength = sizeof(reportDescriptor);
    return reportDescriptor;
}