I'm developing an Xbox Keyboard Mouse Adapter Using an Arduino Mega and 12Bit DAC MCP4922. I ran into some problem and i need your guy help. My problem is my mouse algorithms are not working correctly; playtesting in Halo the game somehow combines the X and Y thumbstick values so the thumbstick moves faster diagonally than the X or Y axis alone. Will need to add yet another filter to the chain to compensate. But keyboard and anything else is working correctly
Here is my current configuration:
Set mouse to 8 counts/mm (highest resolution available for PS/2).
Set mouse sample rate to 200Hz (highest sample rate available for PS/2).
Read X Y.
Finds the absolute value of X Y.
Since I set the mouse to 8 counts/mm so it only output -127 to 127. So we take X Y divided by 127 time it by 2048 because I'm currently using 12bit DAC MCP4922 (0 to 4095).
Depend on the sign bit and the axis we either + or - from 2048.
I think we have to clamp all the value inside the green circle. But I don't know the right formula for it please help me Because since the Xbox controller joystick zone are a circle that why make the diagonal move so fast
mouse is "PS2 mouse(m_clockPin, m_dataPin);"
and 1 byte is equal to 8 bit
M1 = Byte 1
M2 = Byte 2
M3 = Byte 3
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Byte 1 Y overflow X overflow Y sign bit X sign bit Always 1 Middle Btn Right Btn Left Btn
Byte 2 X movement
Byte 3 Y movement
The way I see it is that you move on the square and not the circle.
You need to calculate the lengh of the vector from (0,0) to (x_move,y_move). If the lengh is < 4095 you are inside the circle and you have no problem - just move.
If lengh is > 4095 you are outside the circle and you have a problem.
2a)Convert x_move and y_move til abs values.
2b) Calculate the angle between your abs vector and x-axis (0,4095).
2c) Calculate the intersect cordinats with the circal - this can be done since you know both the angle and the radius of your circle (4095). This is your new x_move and y_move.
2d) Apply correct signs (+/-) to new x_move and y_move based on the original x_move and y_move - check the 4 quardrants.
2e) Move.
The way I see it is that you move on the square and not the circle.
You need to calculate the lengh of the vector from (0,0) to (x_move,y_move). If the lengh is < 4095 you are inside the circle and you have no problem - just move.
If lengh is > 4095 you are outside the circle and you have a problem.
2a)Convert x_move and y_move til abs values.
2b) Calculate the angle between your abs vector and x-axis (0,4095).
2c) Calculate the intersect cordinats with the circal - this can be done since you know both the angle and the radius of your circle (4095). This is your new x_move and y_move.
2d) Apply correct signs (+/-) to new x_move and y_move based on the original x_move and y_move - check the 4 quardrants.
2e) Move.
-Fletcher
Thank for helping
But this is not my problem if you move the mouse diagonally it seen faster than up, down, left, and right. We need to clamp the value inside the circle not chop it off i'm not good at math so i need some help here