00001 /* 00002 * This file is part of the KGLEngine2D project. 00003 * Copyright (C) 2008 Sacha Schutz <istdasklar@free.fr> 00004 * Copyright (C) 2008 Olivier Gueudelot <gueudelotolive@gmail.com> 00005 * Copyright (C) 2008 Charles Huet <packadal@gmail.com> 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; see the file COPYING. If not, write to 00019 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 * Boston, MA 02110-1301, USA. 00021 */ 00022 00023 #include <gluon/input/inputmanager.h> 00024 00025 #include <QDebug> 00026 00027 int main( int argc, char* argv[] ) 00028 { 00029 qDebug() << "Number of devices available : " << GluonInput::InputManager::instance()->deviceCount(); 00030 qDebug() << "Number of keyboards available : " << GluonInput::InputManager::instance()->keyboardCount(); 00031 qDebug() << "Number of mice available : " << GluonInput::InputManager::instance()->mouseCount(); 00032 qDebug() << "Number of joysticks available : " << GluonInput::InputManager::instance()->joystickCount(); 00033 qDebug() << "Number of touches available : " << GluonInput::InputManager::instance()->touchCount(); 00034 qDebug() << "Number of unknown devices available : " << GluonInput::InputManager::instance()->unknownDeviceCount(); 00035 00036 foreach( GluonInput::InputDevice * input, GluonInput::InputManager::instance()->inputList() ) 00037 { 00038 qDebug() << input->deviceName(); 00039 00040 switch( input->deviceType() ) 00041 { 00042 case GluonInput::KeyboardDevice: 00043 qDebug() << "this is a keyboard"; 00044 break; 00045 case GluonInput::MouseDevice: 00046 qDebug() << "this is a mouse"; 00047 break; 00048 case GluonInput::JoystickDevice: 00049 qDebug() << "this is a joystick"; 00050 break; 00051 case GluonInput::TouchDevice: 00052 qDebug() << "this is a touch"; 00053 break; 00054 case GluonInput::UnknownDevice: 00055 qDebug() << "this is an unknown device"; 00056 break; 00057 default: 00058 break; 00059 } 00060 00061 // Now we can show the capability of inputs...This example show the buttons capabilities 00062 foreach( int buttonCode, input->buttonCapabilities() ) 00063 qDebug() << "BUTTON : " << buttonCode << "->" << input->buttonName( buttonCode ); 00064 00065 foreach( int axis, input->absAxisCapabilities() ) 00066 qDebug() << "ABSOLUTE AXIS " << axis << "->" << input->axisName( axis ); 00067 00068 foreach( int axis, input->relAxisCapabilities() ) 00069 qDebug() << "RELATIVE AXIS " << axis << "->" << input->axisName( axis ); 00070 00071 qDebug() << "==========================================================="; 00072 } 00073 }