13 #include <QGamepadManager>
14 #include <QMainWindow>
20 : QGamepad(0, parent),
24 connect(&m_timer, &QTimer::timeout,
this,
25 &GamepadInput::updateInternalState);
52 screenWidth3D = -screenWidth3D;
54 CCVector3d v(-m_panning.
x * screenWidth3D, -m_panning.
y * screenWidth3D,
57 static_cast<float>(v.
y),
58 static_cast<float>(v.
z));
62 if (m_hasTranslation) {
63 double X = m_translation.
x;
65 double Z = m_translation.
z;
75 screenWidth3D = -screenWidth3D;
77 CCVector3d v(-
X * screenWidth3D, 0, -Z * screenWidth3D);
79 static_cast<float>(v.
y),
80 static_cast<float>(v.
z));
90 void GamepadInput::updateInternalState() {
95 m_hasTranslation =
false;
97 m_hasRotation =
false;
108 m_hasRotation =
true;
111 if (buttonL2() || buttonR2()) {
117 m_rotation = rot * m_rotation;
118 m_hasRotation =
true;
127 }
else if (buttonRight()) {
134 }
else if (buttonDown()) {
142 double x = axisLeftX();
143 double z = axisLeftY();
144 if (
x != 0 ||
z != 0) {
147 m_hasTranslation =
true;
154 if (m_hasRotation || m_hasPanning || m_hasTranslation || m_zoom != 0) {
Vector3Tpl< double > CCVector3d
Double 3D Vector.
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
void normalize()
Sets vector norm to unity.
static ccGLMatrixTpl< double > FromToRotation(const Vector3Tpl< double > &from, const Vector3Tpl< double > &to)
Creates a transformation matrix that rotates a vector to another.
void initFromParameters(T alpha_rad, const Vector3Tpl< T > &axis3D, const Vector3Tpl< T > &t3D)
Inits transformation from a rotation axis, an angle and a translation.
virtual void toIdentity()
Sets matrix to identity.
Double version of ccGLMatrixTpl.
Standard parameters for GL displays/viewports.
bool perspectiveView
Perspective view state.
double computeWidthAtFocalDist() const
Computes the object 'width' at the 'focal' distance.
double computeDistanceToHalfWidthRatio() const
Computes the ratio 'distance to half width' (based on the current FOV)
bool GreaterThanEpsilon(float x)
Test a floating point number against our epsilon (a very small number).
float DegreesToRadians(int degrees)
Convert degrees to radians.