Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 4 Forum Discussions

JaMa_1051561
Level 2
Level 2
10 replies posted 10 sign-ins 5 replies posted

Hi All,

I am developing software for the Trackpad.

For this i have referred following two examples.

CE195394_HID_Mouse  - In this example 3 Bytes mouse data is sent over USB.  Byte1-Button, Byte2- X data, Byte3- Y data

CE216892 USB-HID Trackpad - In this example algorithm is developed to use trackpad and five bytes data is sent over I2C. 

 Byte1- Button Data, Byte2- X data, Byte3 - Y data, Byte4- 0 (Scroll), Byte5 - XY negative sign data.

What changes i will have to do in the following descriptor to send 5 Bytes of data over USB.

Report Count should be 4 Bytes where the arrow is shown. How do I add USAGE for XY negative sign data? What item should I select here. 

Mouse Descriptor.jpg

Any help would be appreciated. 

Thanks.

 

0 Likes
1 Solution
Ekta
Moderator
Moderator
Moderator
250 solutions authored 100 likes received 250 sign-ins

Hello @JaMa_1051561 

I am attaching the screenshot for the HID descriptor used in the case of HID Trackpad example:

Ekta_0-1622463057042.png

Thanks and Regards

Ekta

View solution in original post

0 Likes
13 Replies
Ekta
Moderator
Moderator
Moderator
250 solutions authored 100 likes received 250 sign-ins

Hello @JaMa_1051561 

You can refer to the USB HID Basics with PSoC® 3 and PSoC 5LP to understand how the 3 button mouse HID report is structured and what is implied by each of the parameter in the HID Report.

We also have an Application note on AN58726 - USB HID Intermediate with PSoC® 3 and PSoC 5LP that mentions more details regarding creating a HID report.

Although the Application notes were initially created for PSoC 5LP and PSoC 3 the are applicable for any other PSoC device that supports USB. In case you are using PSoC 4 you need to go with a PSoC 4L device (which is the only PSoC 4 series to support USB).

As mentioned by you, the default 3 button mouse project had 3 bytes:

Byte1(blue box in the image attached by you)- For button presses (on/off) only 3 bits of a byte are being used for this data. The first usage page under the collection is button corresponds to this byte. Thus, the Report count which specifies the number of data fields in an Input is 1 and the Report Size is 8 which is the number of bits in the data field

Byte 2 and Byte 3 (red box) - are covered under single usage_page as dekstop controls.  Thus the Report Count for them is 2 (2 bytes) and Report size is again set to 8.

As per my understanding for adding the other two bytes Byte4- 0 (Scroll), Byte5 - XY negative sign data depending upon you application you can either add a single usage_page before the end collection (in this case the report size and report count will be 8 and 2 respectively) or two separate Usage_page for each (in this case the report size and report count will be 8 and 1 respectively for each of the usage_page). 

You can also refer to the USB HID specification: https://www.usb.org/sites/default/files/hid1_11.pdf for understanding in more details about each of the HID Items in a HID Report.

Thanks and Regards

Ekta

Hello Ekta Mam,

Thank you foryour quick reply.

I understood the single & seperate Usage Page, report count, report size concept.

I have another query that after creating Usage Page i need to add two Usage for byte 4 & 5.

what Item Value should i select to send XYnegative (uint8 variable) data to host?

like for Byte 2 & 3 there were options to choose directly (X, Y)  in the Item Value list.

 

Thank you.

0 Likes

Hello Ekta,

If you have standard touchpad USB HID output example. Please share this to me. 

Thank you. 

0 Likes
Ekta
Moderator
Moderator
Moderator
250 solutions authored 100 likes received 250 sign-ins

Hi @JaMa_1051561 

Could you please let me know what the XY negative data actually corresponds to and what range of values it can have? Based on this you can try selecting a suitable Item type. For details on each Item Value refer to USB HID Usages Tables document

I see that there is a vendor specific Item Value. I think you can probable try using that if you do not find a suitable Item Value.

Thanks and Regards

Ekta

 

0 Likes

Hello,

I am referring CE216892 USB-HID Trackpad example same is attached here.

I have disabled the Tuner so Trackpad acts as a HID mouse.

In this example data is sent over I2C. I have to send same data over USB HID. 

What should be the HID Descriptor settings to send 5 bytes of data?

This xyDirectionData variable is declared like following.

/* Contains information of whether DeltaX and DeltaY is negative */
uint8 xyDirectionData;

It is updated in the code

xyDirectionData = xyDirectionData | X_POSITION_NEGATIVE;

xyDirectionData = xyDirectionData | Y_POSITION_NEGATIVE;

X_POSITION_NEGATIVE &  Y_POSITION_NEGATIVE are macros.

#define X_POSITION_NEGATIVE (2u)
#define Y_POSITION_NEGATIVE (1u)

following buffer has to update over USB.

/* 5 bytes of data is sent to host
BYTE1 - Mouse click data
BYTE2 - Delta x data
BYTE3 - Delta y data
BYTE4 - 0 (Scroll data, not used in this code example)
BYTE5 - delta x and delta y sign information
*/
ezI2cBuffer[BYTES_IN_BUFFER_INDEX] = MOUSE_DATA_BYTES_COUNT;

ezI2cBuffer[DATA_BYTE1_INDEX] = mouseClickData;
ezI2cBuffer[DATA_BYTE2_INDEX] = diffPosition[Y_POSITION];
ezI2cBuffer[DATA_BYTE3_INDEX] = diffPosition[X_POSITION];
ezI2cBuffer[DATA_BYTE4_INDEX] = 0u;
ezI2cBuffer[DATA_BYTE5_INDEX] = xyDirectionData;

Please check the attached example for more details.

Thank you.

0 Likes

Hello Ekta Mam,

Waiting for your reply.  please revert.

0 Likes

Hello Mam,

I checked the vendor specific Item Value still the problem is not resolved. 

Pointer is going in one direction and not updating direction as per Byte 5.

0 Likes
Ekta
Moderator
Moderator
Moderator
250 solutions authored 100 likes received 250 sign-ins

Hello @jama_4444671 

I am checking internally to see if I could get the USB Code example that was created (for which the .cyacd file is provided) to support the USB HID Trackpad code example.  

In that case we can directly look into the descriptor file of the USB to see how the HID descriptor was configured.

Thanks and Regards

Ekta

0 Likes

Hello @Ekta Mam,

Did you get any help internally or any example ?  Please let me know. 

Thank you.

0 Likes
JaMa_1051561
Level 2
Level 2
10 replies posted 10 sign-ins 5 replies posted

Thank you.

Please update me once you get it.

In case of mouse 3 bytes are sent to the USB out. mouse data, X&Y coordinate data.

whereas in touchpad 5 bytes are sent to the USB as per standard Trackpad example. 

Button data, X data, Y data, scroll data (0), XY direction

I have query while selecting item value for the XY direction byte.

remaining part is perfect. 

0 Likes
Ekta
Moderator
Moderator
Moderator
250 solutions authored 100 likes received 250 sign-ins

Hello @JaMa_1051561 

I am attaching the screenshot for the HID descriptor used in the case of HID Trackpad example:

Ekta_0-1622463057042.png

Thanks and Regards

Ekta

0 Likes

Thank you @Ekta  for the reply.

Could you please let me know what the Wheel data actually corresponds to and what range of values it can have?

if you share the example that would be great help for me.

Thank you.

0 Likes
Ekta
Moderator
Moderator
Moderator
250 solutions authored 100 likes received 250 sign-ins

Hello @JaMa_1051561 

The Wheel data corresponds to the Scroll Byte. The value of this parameter ranges from -127 to 127.

The following document: https://www.usb.org/sites/default/files/documents/hut1_12v2.pdf mentions the wheel parameter as a rotatory control for generating variable value, normally rolled, unlike dial. Report values should increase as controls are rolled forward, away from user. 

The project is confidential and I am not allowed to share it in the community.

In the Default  USB Mouse code example the X and Y bytes contain information regarding deltaX and delta Y along with there signs (which tells the direction ).

Thanks and Regards

Ekta

0 Likes