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 ***************************************************************************/
23 #include "joywidget.h"
24 #include "joydevice.h"
26 #include <kaboutdata.h>
32 #include <KPluginFactory>
33 #include <KPluginLoader>
35 #include <QVBoxLayout>
36 //---------------------------------------------------------------------------------------------
38 K_PLUGIN_FACTORY(JoystickFactory
,
39 registerPlugin
<Joystick
>();
41 K_EXPORT_PLUGIN(JoystickFactory("joystick"))
45 KDE_EXPORT
bool test_joystick()
46 { /* Code stolen from JoyWidget::init() */
50 for (i
= 0; i
< 5; i
++) // check the first 5 devices
52 sprintf(dev
, "/dev/js%d", i
); // first look in /dev
53 JoyDevice
*joy
= new JoyDevice(dev
);
55 if ( joy
->open() != JoyDevice::SUCCESS
)
58 sprintf(dev
, "/dev/input/js%d", i
); // then look in /dev/input
59 joy
= new JoyDevice(dev
);
61 if ( joy
->open() != JoyDevice::SUCCESS
)
64 continue; // try next number
68 return true; /* We have at least one joystick and should hence be shown */
74 //---------------------------------------------------------------------------------------------
76 Joystick::Joystick(QWidget
*parent
, const QVariantList
&)
77 : KCModule(JoystickFactory::componentData(), parent
)
80 setAboutData(new KAboutData("kcmjoystick", 0, ki18n("KDE Joystick Control Module"), "1.0",
81 ki18n("KDE Control Center Module to test Joysticks"),
82 KAboutData::License_GPL
, ki18n("(c) 2004, Martin Koller"),
83 KLocalizedString(), "m.koller@surfeu.at"));
85 setQuickHelp( i18n("<h1>Joystick</h1>"
86 "This module helps to check if your joystick is working correctly.<br />"
87 "If it delivers wrong values for the axes, you can try to solve this with "
88 "the calibration.<br />"
89 "This module tries to find all available joystick devices "
90 "by checking /dev/js[0-4] and /dev/input/js[0-4]<br />"
91 "If you have another device file, enter it in the combobox.<br />"
92 "The Buttons list shows the state of the buttons on your joystick, the Axes list "
93 "shows the current value for all axes.<br />"
94 "NOTE: the current Linux device driver (Kernel 2.4, 2.6) can only autodetect"
96 "<li>2-axis, 4-button joystick</li>"
97 "<li>3-axis, 4-button joystick</li>"
98 "<li>4-axis, 4-button joystick</li>"
99 "<li>Saitek Cyborg 'digital' joysticks</li>"
101 "(For details you can check your Linux source/Documentation/input/joystick.txt)"
104 joyWidget
= new JoyWidget(this);
106 QVBoxLayout
*top
= new QVBoxLayout(this);
108 top
->setSpacing(KDialog::spacingHint());
109 top
->addWidget(joyWidget
);
112 //---------------------------------------------------------------------------------------------
114 void Joystick::load()
119 //---------------------------------------------------------------------------------------------
121 void Joystick::defaults()
123 joyWidget
->resetCalibration();
128 //---------------------------------------------------------------------------------------------
130 #include "joystick.moc"