- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I would like to check where a Click happened with respect to the X axis and therefore assigning a right or a left click, having the Maximum X-Axis position=395 and the Maximum Y-Axis position=395.
I didn't find a way to access the position of where a touchdown or a liftoff happened so I decided to use the CapSense_GetXYCoordinates(CapSense_TOUCHPAD0_WDGT_ID) function. However I am not sure if the output is in the correct format to be compared with the 198 value because the device seems to not work accordingly, always displaying a left click.
How could this be corrected and would there be a better way of doing this? Maybe accessing the touchdown and the lift off positions?
POS_X= (int) (CapSense_GetXYCoordinates(CapSense_TOUCHPAD0_WDGT_ID)<<16);
click = (gestureID == CapSense_ONE_FINGER_SINGLE_CLICK) ? 1u : 0u;
if(click && POS_X<=198){
leftButtonPress = 1u;
abMouseData[0u] = (leftButtonPress ? MOUSE_LB : 0u);
}
if(click && POS_X>198){
rightButtonPress = 1u;
abMouseData[0u] = (rightButtonPress ? MOUSE_RIGHT : 0u);
Thank you for your help
Solved! Go to Solution.
- Labels:
-
PSoC 4 MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The CapSense_GetXYCoordinates API returns the X coordinate in the lower 16 bits of the returned value. So the right way to comprehend the X position would be to using the bitwise AND operation.
So, your code needs to be modified to
POS_X= (int) (CapSense_GetXYCoordinates(CapSense_TOUCHPAD0_WDGT_ID)&0xFFFF);
to obtain the right X coordinates.
You can try this change and check the performance as the data is sent with respect to the coordinates and if you set the maximum X and Y position as 395 in the component, the comparison with 198 in the code is correct.
Best regards,
Hari
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The CapSense_GetXYCoordinates API returns the X coordinate in the lower 16 bits of the returned value. So the right way to comprehend the X position would be to using the bitwise AND operation.
So, your code needs to be modified to
POS_X= (int) (CapSense_GetXYCoordinates(CapSense_TOUCHPAD0_WDGT_ID)&0xFFFF);
to obtain the right X coordinates.
You can try this change and check the performance as the data is sent with respect to the coordinates and if you set the maximum X and Y position as 395 in the component, the comparison with 198 in the code is correct.
Best regards,
Hari