mirror of
https://github.com/Maschell/hid_to_vpad.git
synced 2024-11-23 23:09:16 +01:00
Use the OS Touchscreen Calibration instead of hardcoded values
This commit is contained in:
parent
9addd4f3c5
commit
f3d3a5835c
@ -40,16 +40,18 @@ public:
|
||||
s32 vpadError = -1;
|
||||
VPADRead(0, &vpad, 1, &vpadError);
|
||||
|
||||
if(vpadError == 0)
|
||||
{
|
||||
if(vpadError == 0){
|
||||
data.buttons_r = vpad.btns_r;
|
||||
data.buttons_h = vpad.btns_h;
|
||||
data.buttons_d = vpad.btns_d;
|
||||
data.validPointer = !vpad.tpdata.invalid;
|
||||
data.touched = vpad.tpdata.touched;
|
||||
|
||||
VPADGetTPCalibratedPoint(0, &tpCalib, &vpad.tpdata1);
|
||||
|
||||
//! calculate the screen offsets
|
||||
data.x = -(width >> 1) + ((s32)(vpad.tpdata1.x * ((width)/1211.0f)*width) >> 12)-30;
|
||||
data.y = -(height >> 1) + ((s32)(vpad.tpdata1.y * ((height)/653.0f)*height) >> 12)-35;
|
||||
data.x = -(width >> 1) + (s32)(((float)tpCalib.x / 1280.0f) * (float)width);
|
||||
data.y = -(height >> 1) + (s32)(float)height - (((float)tpCalib.y / 720.0f) * (float)height);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -58,6 +60,7 @@ public:
|
||||
|
||||
private:
|
||||
VPADData vpad;
|
||||
VPADTPData tpCalib;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user