Commit ef66920b authored by minute's avatar minute
Browse files

trackpad: implement horizontal and hi-res scroll/pan

parent 4a644c6f
......@@ -58,6 +58,7 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
HID_RI_USAGE(8, 0x02), /* Mouse */
HID_RI_COLLECTION(8, 0x01), /* Application */
HID_RI_REPORT_ID(8, 0x01),
HID_RI_USAGE(8, 0x01), /* Pointer */
HID_RI_COLLECTION(8, 0x00), /* Physical */
HID_RI_USAGE_PAGE(8, 0x09), /* Button */
......@@ -68,9 +69,11 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
HID_RI_REPORT_COUNT(8, 0x03),
HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_REPORT_COUNT(8, 0x01), // 5 bits padding
HID_RI_REPORT_SIZE(8, 0x05),
HID_RI_INPUT(8, HID_IOF_CONSTANT),
HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
HID_RI_USAGE(8, 0x30), /* Usage X */
HID_RI_USAGE(8, 0x31), /* Usage Y */
......@@ -80,19 +83,46 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
HID_RI_PHYSICAL_MAXIMUM(8, 127),
HID_RI_REPORT_COUNT(8, 0x02),
HID_RI_REPORT_SIZE(8, 0x08),
//HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
HID_RI_COLLECTION(8, 0x02), /* Logical */
// ---
HID_RI_REPORT_ID(8, 0x02),
HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
HID_RI_USAGE(8, 0x48), /* Usage Resolution Multiplier */
HID_RI_LOGICAL_MINIMUM(8, 0),
HID_RI_LOGICAL_MAXIMUM(8, 1),
HID_RI_PHYSICAL_MINIMUM(8, 1),
HID_RI_PHYSICAL_MAXIMUM(8, 12), /* Sensitivity of Wheels */
HID_RI_REPORT_COUNT(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_FEATURE(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
// ---
// ---
HID_RI_REPORT_ID(8, 0x01),
HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
HID_RI_USAGE(8, 0x38), /* Usage Wheel */
HID_RI_LOGICAL_MINIMUM(8, -127),
HID_RI_LOGICAL_MAXIMUM(8, 127),
HID_RI_PHYSICAL_MINIMUM(8, 0),
HID_RI_PHYSICAL_MAXIMUM(8, 0),
HID_RI_REPORT_COUNT(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
// ---
// ---
HID_RI_REPORT_ID(8, 0x01),
HID_RI_USAGE_PAGE(8, 0x0c), /* Consumer */
HID_RI_USAGE(16, 0x238), /* Usage AC Pan, Linear Control */
HID_RI_LOGICAL_MINIMUM(8, -127),
HID_RI_LOGICAL_MAXIMUM(8, 127),
HID_RI_PHYSICAL_MINIMUM(8, -127),
HID_RI_PHYSICAL_MAXIMUM(8, 127),
HID_RI_REPORT_COUNT(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
// ---
HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0),
HID_RI_END_COLLECTION(0),
};
......
......@@ -95,6 +95,12 @@ typedef struct
int8_t X;
int8_t Y;
int8_t Wheel;
int8_t Pan;
} ATTR_PACKED USB_WheelMouseReport_Data_t;
typedef struct
{
int8_t Multiplier;
} ATTR_PACKED USB_WheelMouseFeatureReport_Data_t;
#endif
......@@ -115,9 +115,6 @@ USB_ClassInfo_HID_Device_t Mouse_HID_Interface =
},
};
// LM PD0 input pullup
// RM PD1 input pullup
#define ADDR_SENSOR (0x74<<1)
uint8_t twi_write_reg[1];
......@@ -236,13 +233,35 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
void* ReportData,
uint16_t* const ReportSize)
{
if (ReportType==HID_REPORT_ITEM_Feature) return false;
if (ReportType==HID_REPORT_ITEM_Feature) {
if (*ReportID==0) {
*ReportID=2;
}
if (*ReportID==2) {
USB_WheelMouseFeatureReport_Data_t* FeatureReport = (USB_WheelMouseFeatureReport_Data_t*)ReportData;
FeatureReport->Multiplier = 2;
*ReportSize = sizeof(USB_WheelMouseFeatureReport_Data_t);
return true;
} else {
return false;
}
}
if (*ReportID==0) {
*ReportID=1;
}
if (*ReportID!=1) {
return false;
}
USB_WheelMouseReport_Data_t* MouseReport = (USB_WheelMouseReport_Data_t*)ReportData;
// note: look for IQS550
MouseReport->Button = 0;
MouseReport->Pan = 0;
MouseReport->Wheel = 0;
MouseReport->X = 0;
MouseReport->Y = 0;
......@@ -323,11 +342,9 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
//if (dyy<=-MOTION_CLIP) dyy=-MOTION_CLIP;
if (wheeling) {
float sgn = 1;
if (dyy<0) sgn = -1;
if (dyy>=2 || dyy<=-2) {
MouseReport->Wheel = (-sgn) * sqrt(sgn*dyy);
}
// horizontal and vertical scrolling
MouseReport->Pan = dxx;
MouseReport->Wheel = -dyy;
} else {
// normal movement
MouseReport->X = dxx;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment