1 /***************************************************************************
2 * Copyright (C) 2003 by Martin Koller *
4 * This file is part of the KDE Control Center Module for Joysticks *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20 ***************************************************************************/
26 #include <sys/types.h>
29 #undef __STRICT_ANSI__
30 #include <linux/joystick.h>
31 #define __STRICT_ANSI__
35 #include <sys/joystick.h>
38 // helper class which holds all current values, file descriptor, etc. for
64 // devicefile to use, e.g. "/dev/js0"
65 JoyDevice(const QString
&devicefile
);
68 // returns one of the error-codes from above
71 // return descriptive error text for given error code
72 QString
errText(ErrorCode code
) const;
74 int fd() const { return joyFd
; }
76 ErrorCode
restoreCorr();
78 // return devicefilename from constructor
79 const QString
&device() const { return devName
; }
81 // descriptive text for this device read from the driver
82 QString
text() const { return descr
; }
84 int numButtons() const { return buttons
; }
85 int numAxes() const { return axes
; }
86 int axisMin(int axis
) const;
87 int axisMax(int axis
) const;
89 // read next event from device; returns true if there was an event during the short timeout
90 bool getEvent(JoyDevice::EventType
&type
, int &number
, int &value
);
92 // methods for calibration
93 ErrorCode
initCalibration(); // must be called first
96 void resetMinMax(int axis
, int value
= 0);
98 // calculate correction values
99 // min[2], center[2], max[2], index 0 == minimum, index 1 == maximum
100 void calcCorrection(int axis
, int *min
, int *center
, int *max
);
101 ErrorCode
applyCalibration();
104 QString devName
; // device filename
105 QString descr
; // descriptive text
110 int *amin
; // axes min values
111 int *amax
; // axes max values
113 struct js_corr
*corr
; // calibration values during the calib. steps
114 struct js_corr
*origCorr
; // original calibration correction values