From 0aa7b8871e4909de2d1d16add65d617c97df0feb Mon Sep 17 00:00:00 2001 From: jaseg Date: Mon, 22 Jun 2020 23:58:20 +0200 Subject: Initial minikbd mod --- hid-dials/Inc/usbd_hid.h | 2 +- hid-dials/Src/main.c | 338 +++++++++++++++------------------------------- hid-dials/Src/usbd_desc.c | 10 +- hid-dials/Src/usbd_hid.c | 112 +++++++-------- 4 files changed, 164 insertions(+), 298 deletions(-) diff --git a/hid-dials/Inc/usbd_hid.h b/hid-dials/Inc/usbd_hid.h index 4bf5e34..fa2f0a2 100644 --- a/hid-dials/Inc/usbd_hid.h +++ b/hid-dials/Inc/usbd_hid.h @@ -95,7 +95,7 @@ -#define HID_REPORT_DESC_SIZE (47+HID_MEDIA_SIZE+HID_LED_SIZE) +#define HID_REPORT_DESC_SIZE 104 #define HID_DESCRIPTOR_TYPE 0x21 diff --git a/hid-dials/Src/main.c b/hid-dials/Src/main.c index 58c40ad..0aa694f 100644 --- a/hid-dials/Src/main.c +++ b/hid-dials/Src/main.c @@ -1,4 +1,6 @@ +#include + #include "main.h" #include "usb_device.h" #include "usbd_hid.h" @@ -13,12 +15,13 @@ PCD_HandleTypeDef hpcd_USB_FS; void SystemClock_Config(void); static void MX_GPIO_Init(void); -static void MX_DMA_Init(void); -static void MX_ADC_Init(void); -static void MX_USB_PCD_Init(void); -void sendVolDown(void); -void sendVolUp(void); +enum keybits { + KEYBITS_VOL_UP = 0x20, + KEYBITS_VOL_DOWN = 0x40, +}; + +void sendKeybits(uint8_t keybits); struct key_t { @@ -32,94 +35,69 @@ uint16_t ADCreg[8]; uint16_t ADCval[8]; uint16_t ADClast[8]; +/* FIXME debug remove */ +TIM_TypeDef *tim1 = TIM1; +TIM_TypeDef *tim3 = TIM3; + int main(void) { - HAL_Init(); - - SystemClock_Config(); - - MX_GPIO_Init(); - MX_DMA_Init(); - MX_ADC_Init(); - MX_USB_HID_INIT(); - - HAL_ADC_Start_DMA(&hadc, ADCreg, 8); - - while (1) - { - - - for(int i = 0; i < 8; i++){ - ADCval[i] = ADCreg[i]; - if(ADCval[i] - ADClast[i] > 2000 || ADClast[i] - ADCval[i] > 2000 ) ADClast[i] = ADCval[i]; - } - - // Volume Dial 8 - if(ADCval[0] >= ADClast[0] + HYSTERESIS){ - sendVolUp(); - ADClast[0] = ADCval[0]; - } else if(ADCval[0] <= ADClast[0] - HYSTERESIS){ - sendVolDown(); - ADClast[0] = ADCval[0]; - } - - // Dial 1 - if(ADCval[1] >= ADClast[1] + HYSTERESIS){ - } else if(ADCval[1] <= ADClast[1] - HYSTERESIS){ - } - - // SwitchLayer - if(ADCval[2] >= ADClast[2] + HYSTERESIS){ - sendChar('v'); - ADClast[2] = ADCval[2]; - } else if(ADCval[2] <= ADClast[2] - HYSTERESIS){ - sendChar('v'); - ADClast[2] = ADCval[2]; - } - - // RotatePart Dial 3 - if(ADCval[3] >= ADClast[3] + HYSTERESIS){ - sendChar('R'); - ADClast[3] = ADCval[3]; - } else if(ADCval[3] <= ADClast[3] - HYSTERESIS){ - sendChar('r'); - ADClast[3] = ADCval[3]; - } - - // Grid Dial 4 - if(ADCval[4] >= ADClast[4] + HYSTERESIS){ - sendChar('n'); - ADClast[4] = ADCval[4]; - } else if(ADCval[4] <= ADClast[4] - HYSTERESIS){ - sendChar('N'); - ADClast[4] = ADCval[4]; - } - - // via - if(ADCval[5] >= ADClast[5] + HYSTERESIS){ - } else if(ADCval[5] <= ADClast[5] - HYSTERESIS){ - } - - // Trackwidth Dial 6 - if(ADCval[6] >= ADClast[6] + HYSTERESIS){ - sendChar('w'); - ADClast[6] = ADCval[6]; - } else if(ADCval[6] <= ADClast[6] - HYSTERESIS){ - sendChar('W'); - ADClast[6] = ADCval[6]; - } - - // zoom - if(ADCval[7] >= ADClast[7] + HYSTERESIS){ - sendCharWrong(0x3a); - ADClast[7] = ADCval[7]; - } else if(ADCval[7] <= ADClast[7] - HYSTERESIS){ - sendCharWrong(0x3b); - ADClast[7] = ADCval[7]; + HAL_Init(); + + SystemClock_Config(); + + MX_GPIO_Init(); + MX_USB_HID_INIT(); + + __HAL_RCC_TIM1_CLK_ENABLE(); + __HAL_RCC_TIM3_CLK_ENABLE(); + + TIM1->SMCR = 3; // Encoder mode 3 + TIM1->CCER = 0; // rising edge polarity + TIM1->ARR = 0xFFFF; // count from 0-ARR or ARR-0 + TIM1->CCMR1 = 0x0101; // f_DTS/16, N=8, IC1->TI1, IC2->TI2 + TIM1->CNT = 0; // Initialize counter + TIM1->EGR = 1; // Generate an update event + TIM1->CR1 = 1; // Enable the counter + + TIM3->SMCR = 3; // Encoder mode 3 + TIM3->CCER = 0; // rising edge polarity + TIM3->ARR = 0xFFFF; // count from 0-ARR or ARR-0 + TIM3->CCMR1 = 0x0101; // f_DTS/16, N=8, IC1->TI1, IC2->TI2 + TIM3->CNT = 0; // Initialize counter + TIM3->EGR = 1; // Generate an update event + TIM3->CR1 = 1; // Enable the counter + + uint16_t tim1_last = TIM1->CNT, tim3_last = TIM3->CNT; + int vol_delta = 0; + bool tx_vol_reset = 0; + while (1) { + uint16_t tim1_now = TIM1->CNT, tim3_now = TIM3->CNT; + int16_t tim1_delta = (int16_t)(tim1_now - tim1_last); + int16_t tim3_delta = (int16_t)(tim3_now - tim3_last); + + vol_delta += tim3_delta - tim1_delta; + +#define VOL_DELTA_INC 4 + uint8_t keybits = 0; + if (!tx_vol_reset) { + if (vol_delta >= VOL_DELTA_INC) { + keybits |= KEYBITS_VOL_UP; + vol_delta -= VOL_DELTA_INC; + tx_vol_reset = 1; + } else if (vol_delta <= -VOL_DELTA_INC) { + keybits |= KEYBITS_VOL_DOWN; + vol_delta += VOL_DELTA_INC; + tx_vol_reset = 1; + } + } else { + tx_vol_reset = 0; + } + sendKeybits(keybits); + + tim1_last = tim1_now; + tim3_last = tim3_now; + HAL_Delay(10); } - - HAL_Delay(10); - } } @@ -293,154 +271,58 @@ void sendCharWrong(uint8_t ch){ HAL_Delay(10); } -void sendVolUp(){ - uint8_t report[3]; - report[0]= HID_MEDIA_REPORT; - report[1]= 0xE9; - report[2]= 0x00; - USBD_HID_SendReport(&hUsbDeviceFS, report, 3); - HAL_Delay(10); - - report[0]= HID_MEDIA_REPORT; - report[1]= 0x00; - report[2]= 0x00; - USBD_HID_SendReport(&hUsbDeviceFS, report, 3); -} - -void sendVolDown(){ - uint8_t report[3]; - report[0]= HID_MEDIA_REPORT; - report[1]= 0xEA; - report[2]= 0x00; - USBD_HID_SendReport(&hUsbDeviceFS, report, 3); - HAL_Delay(10); - - report[0]= HID_MEDIA_REPORT; - report[1]= 0x00; - report[2]= 0x00; - USBD_HID_SendReport(&hUsbDeviceFS, report, 3); +void sendKeybits(uint8_t keybits){ + uint8_t report[2]; + report[0]= HID_MEDIA_REPORT; + report[1]= keybits; + USBD_HID_SendReport(&hUsbDeviceFS, report, 2); } void SystemClock_Config(void) { - RCC_OscInitTypeDef RCC_OscInitStruct = {0}; - RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; - RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; - - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI14|RCC_OSCILLATORTYPE_HSI48; - RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; - RCC_OscInitStruct.HSI14State = RCC_HSI14_ON; - RCC_OscInitStruct.HSI14CalibrationValue = 16; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; - HAL_RCC_OscConfig(&RCC_OscInitStruct); - - RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK - |RCC_CLOCKTYPE_PCLK1; - RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI48; - RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; - HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1); - - PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; - PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; - HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit); + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + RCC_PeriphCLKInitTypeDef PeriphClkInit = {0}; + + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI14|RCC_OSCILLATORTYPE_HSI48; + RCC_OscInitStruct.HSI48State = RCC_HSI48_ON; + RCC_OscInitStruct.HSI14State = RCC_HSI14_ON; + RCC_OscInitStruct.HSI14CalibrationValue = 16; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE; + HAL_RCC_OscConfig(&RCC_OscInitStruct); + + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI48; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; + HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1); + + PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB; + PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48; + HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit); } -static void MX_ADC_Init(void) -{ +static void MX_GPIO_Init(void) { + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); - ADC_ChannelConfTypeDef sConfig = {0}; - - hadc.Instance = ADC1; - hadc.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV1; - hadc.Init.Resolution = ADC_RESOLUTION_12B; - hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT; - hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD; - hadc.Init.EOCSelection = ADC_EOC_SEQ_CONV; - hadc.Init.LowPowerAutoWait = DISABLE; - hadc.Init.LowPowerAutoPowerOff = DISABLE; - hadc.Init.ContinuousConvMode = ENABLE; - hadc.Init.DiscontinuousConvMode = DISABLE; - hadc.Init.ExternalTrigConv = ADC_SOFTWARE_START; - hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; - hadc.Init.DMAContinuousRequests = ENABLE; - hadc.Init.Overrun = ADC_OVR_DATA_PRESERVED; - HAL_ADC_Init(&hadc); - - sConfig.Rank = ADC_RANK_CHANNEL_NUMBER; - sConfig.SamplingTime = ADC_SAMPLETIME_71CYCLES_5; - sConfig.Channel = ADC_CHANNEL_1; - HAL_ADC_ConfigChannel(&hadc, &sConfig); - - sConfig.Channel = ADC_CHANNEL_2; - HAL_ADC_ConfigChannel(&hadc, &sConfig); - - sConfig.Channel = ADC_CHANNEL_3; - HAL_ADC_ConfigChannel(&hadc, &sConfig); - - sConfig.Channel = ADC_CHANNEL_4; - HAL_ADC_ConfigChannel(&hadc, &sConfig); - - sConfig.Channel = ADC_CHANNEL_5; - HAL_ADC_ConfigChannel(&hadc, &sConfig); - - sConfig.Channel = ADC_CHANNEL_6; - HAL_ADC_ConfigChannel(&hadc, &sConfig); - - sConfig.Channel = ADC_CHANNEL_7; - HAL_ADC_ConfigChannel(&hadc, &sConfig); - - sConfig.Channel = ADC_CHANNEL_8; - HAL_ADC_ConfigChannel(&hadc, &sConfig); -} - -static void MX_USB_PCD_Init(void) -{ - - hpcd_USB_FS.Instance = USB; - hpcd_USB_FS.Init.dev_endpoints = 8; - hpcd_USB_FS.Init.speed = PCD_SPEED_FULL; - hpcd_USB_FS.Init.phy_itface = PCD_PHY_EMBEDDED; - hpcd_USB_FS.Init.low_power_enable = DISABLE; - hpcd_USB_FS.Init.lpm_enable = DISABLE; - hpcd_USB_FS.Init.battery_charging_enable = DISABLE; - HAL_PCD_Init(&hpcd_USB_FS); -} - - -static void MX_DMA_Init(void) -{ - __HAL_RCC_DMA1_CLK_ENABLE(); - - HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn); -} - - -static void MX_GPIO_Init(void) -{ - - GPIO_InitTypeDef GPIO_InitStruct = {0}; - - __HAL_RCC_GPIOB_CLK_ENABLE(); - __HAL_RCC_GPIOA_CLK_ENABLE(); - - HAL_GPIO_WritePin(GPIOB, GPIO_PIN_13, GPIO_PIN_RESET); - - GPIO_InitStruct.Pin = GPIO_PIN_13; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + GPIOA->MODER = 0x28000000 | (2<<(8*2)) | (2<<(9*2)); + GPIOB->MODER = (2<<(4*2)) | (2<<(5*2)); + GPIOA->PUPDR = 0x24000000 | (1<<(8*2)) | (1<<(9*2)); + GPIOB->PUPDR = (1<<(4*2)) | (1<<(5*2)); + GPIOA->AFR[1]= 0x00000022; + GPIOB->AFR[0]= 0x00110000; } void Error_Handler(void) { - while(1){ - HAL_GPIO_WritePin(GPIOB,GPIO_PIN_13,1); - HAL_Delay(100); - HAL_GPIO_WritePin(GPIOB,GPIO_PIN_13,0); - HAL_Delay(100); - } + while(1){ + HAL_GPIO_WritePin(GPIOB,GPIO_PIN_13,1); + HAL_Delay(100); + HAL_GPIO_WritePin(GPIOB,GPIO_PIN_13,0); + HAL_Delay(100); + } } + diff --git a/hid-dials/Src/usbd_desc.c b/hid-dials/Src/usbd_desc.c index cf30160..bdcaca4 100644 --- a/hid-dials/Src/usbd_desc.c +++ b/hid-dials/Src/usbd_desc.c @@ -100,12 +100,12 @@ ************************************************************************************************************ */ -#define USBD_VID 0x1209 //MUST BE CHANGED. +#define USBD_VID 0x1209 #define USBD_LANGID_STRING 1041 -#define USBD_MANUFACTURER_STRING "Otter Scientific" -#define USBD_PID_FS 0x0001 //MUST BE CHANGED. -#define USBD_PRODUCT_STRING_FS "HID Dials" -#define USBD_SERIALNUMBER_STRING_FS "00000000001A" +#define USBD_MANUFACTURER_STRING "jaseg.de" +#define USBD_PID_FS 0x0002 // FIXME +#define USBD_PRODUCT_STRING_FS "MultiHID" +#define USBD_SERIALNUMBER_STRING_FS "000000000001" #define USBD_CONFIGURATION_STRING_FS "HID Config" #define USBD_INTERFACE_STRING_FS "HID Interface" diff --git a/hid-dials/Src/usbd_hid.c b/hid-dials/Src/usbd_hid.c index f06d2db..3704be4 100644 --- a/hid-dials/Src/usbd_hid.c +++ b/hid-dials/Src/usbd_hid.c @@ -152,7 +152,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_ 0xE0, /*bmAttributes: bus powered and Support Remote Wake-up */ 0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/ - /************** Descriptor of Joystick Mouse interface ****************/ + /* Interface descriptor */ /* 09 */ 0x09, /*bLength: Interface Descriptor size*/ USB_DESC_TYPE_INTERFACE,/*bDescriptorType: Interface descriptor type*/ @@ -165,7 +165,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_ 0x01, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/ 0x01, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/ 0, /*iInterface: Index of string descriptor*/ - /******************** Descriptor of Joystick Mouse HID ********************/ + /* HID descriptor */ /* 18 */ 0x09, /*bLength: HID Descriptor size*/ HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/ @@ -176,7 +176,7 @@ __ALIGN_BEGIN static uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_ 0x22, /*bDescriptorType*/ HID_REPORT_DESC_SIZE,/*wItemLength: Total length of Report descriptor*/ 0x00, - /******************** Descriptor of Mouse endpoint ********************/ + /* HID endpoint descriptor */ /* 27 */ 0x07, /*bLength: Endpoint Descriptor size*/ USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/ @@ -233,29 +233,21 @@ __ALIGN_BEGIN static uint8_t USBD_HID_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_ __ALIGN_BEGIN static uint8_t HID_ReportDesc[HID_REPORT_DESC_SIZE] __ALIGN_END = { - //copy from arduino code https://github.com/arduino-libraries/Keyboard/blob/master/src/Keyboard.cpp - - 0x05, 0x01, // Usage Page (Generic Desktop Ctrls) - 0x09, 0x06, // Usage (Keyboard) - 0xA1, 0x01, // Collection (Application) - - 0x85, 0x01, // Report ID (1) - - 0x05, 0x07, // Usage Page (Kbrd/Keypad) - 0x19, 0xE0, // Usage Minimum (0xE0) - 0x29, 0xE7, // Usage Maximum (0xE7) - - // it seam we missed the shit ctrl etc .. here - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x01, // Logical Maximum (1) - 0x75, 0x01, // Report Size (1) - 0x95, 0x08, // Report Count (8) - 0x81, 0x02, // Input (Data,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0x95, 0x01, // Report Count (1) - 0x75, 0x08, // Report Size (8) - 0x81, 0x03, // Input (Const,Var,Abs,No Wrap,Linear,Preferred State,No Null Position) -#if HID_LED_SUPPORT - // --------------------- output report for LED + 0x05, 0x01, // USAGE_PAGE (Generic Desktop) + 0x09, 0x06, // USAGE (Keyboard) + 0xa1, 0x01, // COLLECTION (Application) + 0x85, 0x01, /* Report ID */ + 0x05, 0x07, // USAGE_PAGE (Keyboard) + 0x19, 0xe0, // USAGE_MINIMUM (Keyboard LeftControl) + 0x29, 0xe7, // USAGE_MAXIMUM (Keyboard Right GUI) + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x25, 0x01, // LOGICAL_MAXIMUM (1) + 0x75, 0x01, // REPORT_SIZE (1) + 0x95, 0x08, // REPORT_COUNT (8) + 0x81, 0x02, // INPUT (Data,Var,Abs) + 0x95, 0x01, // REPORT_COUNT (1) + 0x75, 0x08, // REPORT_SIZE (8) + 0x81, 0x03, // INPUT (Cnst,Var,Abs) 0x95, 0x05, // REPORT_COUNT (5) 0x75, 0x01, // REPORT_SIZE (1) 0x05, 0x08, // USAGE_PAGE (LEDs) @@ -265,50 +257,42 @@ __ALIGN_BEGIN static uint8_t HID_ReportDesc[HID_REPORT_DESC_SIZE] __ALIGN_END = 0x95, 0x01, // REPORT_COUNT (1) 0x75, 0x03, // REPORT_SIZE (3) 0x91, 0x03, // OUTPUT (Cnst,Var,Abs) -#endif - 0x95, 0x06, // Report Count (6) - 0x75, 0x08, // Report Size (8) - 0x15, 0x00, // Logical Minimum (0) - 0x25, 0x65, // Logical Maximum (101) - 0x05, 0x07, // Usage Page (Kbrd/Keypad) - 0x19, 0x00, // Usage Minimum (0x00) - 0x29, 0x65, // Usage Maximum (0x65) - 0x81, 0x00, // Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xC0, // End Collection - - // 47 bytes -#if HID_MEDIA_REPORT - //help from http://www.microchip.com/forums/m618147.aspx - // this way of describing and sending media control is convenient - // short descriptor that permit all kidn meda by sending "usage" code - // see usb hid spec for full list - // it is possible to define one media key per bit it requires more space - // for descripotor and report ending is tighlyu couple to decriptor - // so it is not as convenient - // one such working code can be find here https://github.com/markwj/hidmedia/blob/master/hidmedia.X/usb_descriptors.c - // - - 0x05, 0x0C, // Usage Page (Consumer) - 0x09, 0x01, // Usage (Consumer Control) - 0xA1, 0x01, // Collection (Application) - 0x85, HID_MEDIA_REPORT, // Report ID (VOLUME_REPORT ) - 0x19, 0x00, // Usage Minimum (Unassigned) - 0x2A, 0x3C, 0x02, // Usage Maximum (AC Format) - 0x15, 0x00, // Logical Minimum (0) - 0x26, 0x3C, 0x02, // Logical Maximum (572) - 0x95, 0x01, // Report Count (1) - 0x75, 0x10, // Report Size (16) - 0x81, 0x00, // Input (Data,Array,Abs,No Wrap,Linear,Preferred State,No Null Position) - 0xC0, // End Collection + 0x95, 0x06, // REPORT_COUNT (6) + 0x75, 0x08, // REPORT_SIZE (8) + 0x15, 0x00, // LOGICAL_MINIMUM (0) + 0x25, 0x65, // LOGICAL_MAXIMUM (101) + 0x05, 0x07, // USAGE_PAGE (Keyboard) + 0x19, 0x00, // USAGE_MINIMUM (Reserved (no event indicated)) + 0x29, 0x65, // USAGE_MAXIMUM (Keyboard Application) + 0x81, 0x00, // INPUT (Data,Ary,Abs) + 0xc0, // End Collection +// + 0x05, 0x0C, /* Usage Page (Consumer Devices) */ + 0x09, 0x01, /* Usage (Consumer Control) */ + 0xA1, 0x01, /* Collection (Application) */ + 0x85, 0x02, /* Report ID=2 */ + 0x05, 0x0C, /* Usage Page (Consumer Devices) */ + 0x15, 0x00, /* Logical Minimum (0) */ + 0x25, 0x01, /* Logical Maximum (1) */ + 0x75, 0x01, /* Report Size (1) */ + 0x95, 0x07, /* Report Count (7) */ + 0x09, 0xB5, /* Usage (Scan Next Track) */ + 0x09, 0xB6, /* Usage (Scan Previous Track) */ + 0x09, 0xB7, /* Usage (Stop) */ + 0x09, 0xCD, /* Usage (Play / Pause) */ + 0x09, 0xE2, /* Usage (Mute) */ + 0x09, 0xE9, /* Usage (Volume Up) */ + 0x09, 0xEA, /* Usage (Volume Down) */ + 0x81, 0x02, /* Input (Data, Variable, Absolute) */ + 0x95, 0x01, /* Report Count (1) */ + 0x81, 0x01, /* Input (Constant) */ + 0xC0, // End Collection // how to format the 3 byte report // byte 0 report ID = 0x02 (VOLUME_REPORT) // byte 1 media code for ex VOL_UP 0xE9 , VOL_DONW 0xEA ... etc // byte 2 0x00 // a second report with 0 code shal be send to avoid "key repaeat" - - // 25 bytes -#endif }; uint32_t nOutData; -- cgit