summaryrefslogtreecommitdiffstats
path: root/kcontrol/joystick/joystick.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /kcontrol/joystick/joystick.cpp
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kcontrol/joystick/joystick.cpp')
-rw-r--r--kcontrol/joystick/joystick.cpp123
1 files changed, 123 insertions, 0 deletions
diff --git a/kcontrol/joystick/joystick.cpp b/kcontrol/joystick/joystick.cpp
new file mode 100644
index 000000000..75115fcb7
--- /dev/null
+++ b/kcontrol/joystick/joystick.cpp
@@ -0,0 +1,123 @@
+/***************************************************************************
+ * Copyright (C) 2003 by Martin Koller *
+ * This file is part of the KDE Control Center Module for Joysticks *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <kaboutdata.h>
+#include <kgenericfactory.h>
+#include <kglobal.h>
+#include <klocale.h>
+
+#include "joystick.h"
+#include "joywidget.h"
+#include "joydevice.h"
+
+//---------------------------------------------------------------------------------------------
+
+typedef KGenericFactory<joystick, QWidget> JoystickFactory;
+K_EXPORT_COMPONENT_FACTORY(kcm_joystick, JoystickFactory("joystick"))
+
+extern "C"
+{
+ KDE_EXPORT bool test_joystick()
+ { /* Code stolen from JoyWidget::init() */
+ int i;
+ char dev[30];
+
+ for (i = 0; i < 5; i++) // check the first 5 devices
+ {
+ sprintf(dev, "/dev/js%d", i); // first look in /dev
+ JoyDevice *joy = new JoyDevice(dev);
+
+ if ( joy->open() != JoyDevice::SUCCESS )
+ {
+ delete joy;
+ sprintf(dev, "/dev/input/js%d", i); // then look in /dev/input
+ joy = new JoyDevice(dev);
+
+ if ( joy->open() != JoyDevice::SUCCESS )
+ {
+ delete joy;
+ continue; // try next number
+ }
+ }
+
+ return true; /* We have at least one joystick and should hence be shown */
+ }
+ return false;
+ }
+}
+
+//---------------------------------------------------------------------------------------------
+
+joystick::joystick(QWidget *parent, const char *name, const QStringList &)
+ : KCModule(JoystickFactory::instance(), parent, name)
+{
+ setAboutData( new KAboutData("kcmjoystick", I18N_NOOP("KDE Joystick Control Module"), "1.0",
+ I18N_NOOP("KDE Control Center Module to test Joysticks"),
+ KAboutData::License_GPL, "(c) 2004, Martin Koller",
+
+ setQuickHelp( i18n("<h1>Joystick</h1>"
+ "This module helps to check if your joystick is working correctly.<br>"
+ "If it delivers wrong values for the axes, you can try to solve this with "
+ "the calibration.<br>"
+ "This module tries to find all available joystick devices "
+ "by checking /dev/js[0-4] and /dev/input/js[0-4]<br>"
+ "If you have another device file, enter it in the combobox.<br>"
+ "The Buttons list shows the state of the buttons on your joystick, the Axes list "
+ "shows the current value for all axes.<br>"
+ "NOTE: the current Linux device driver (Kernel 2.4, 2.6) can only autodetect"
+ "<ul>"
+ "<li>2-axis, 4-button joystick</li>"
+ "<li>3-axis, 4-button joystick</li>"
+ "<li>4-axis, 4-button joystick</li>"
+ "<li>Saitek Cyborg 'digital' joysticks</li>"
+ "</ul>"
+ "(For details you can check your Linux source/Documentation/input/joystick.txt)"
+ ));
+
+ joyWidget = new JoyWidget(this);
+
+ setMinimumSize(joyWidget->minimumSize());
+
+ setButtons(KCModule::Default);
+}
+
+//---------------------------------------------------------------------------------------------
+
+void joystick::load()
+{
+ joyWidget->init();
+}
+
+//---------------------------------------------------------------------------------------------
+
+void joystick::defaults()
+{
+ joyWidget->resetCalibration();
+
+ emit changed(true);
+}
+
+//---------------------------------------------------------------------------------------------
+
+//---------------------------------------------------------------------------------------------
+
+#include "joystick.moc"