00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "custominput.h"
00020
00021 #include "inputdevice.h"
00022 #include "custominputprivate.h"
00023
00024 #include <QtCore/QDebug>
00025 #include <QtCore/QStringList>
00026
00027 using namespace GluonInput;
00028
00029 CustomInput::CustomInput( QObject* parent )
00030 : QObject( parent )
00031 , d( new CustomInputPrivate() )
00032 {
00033 }
00034
00035 CustomInput::~CustomInput()
00036 {
00037 }
00038
00039 void CustomInput::setButton( const QString& name, InputDevice* input, int keyCode )
00040 {
00041 if( !input->buttonCapabilities().contains( keyCode ) )
00042 {
00043 qDebug() << "Cannot find keyCode for this input...";
00044 return;
00045 }
00046 connect( input, SIGNAL( eventSent( InputEvent* ) ), SLOT( inputEvent( InputEvent* ) ) );
00047 d->m_buttons.insert( name, qMakePair( input, keyCode ) );
00048
00049 }
00050
00051 void CustomInput::setButton( const QString& name )
00052 {
00053 InputDevice* input = new InputDevice();
00054 d->m_buttons.insert( name, qMakePair( input, 0 ) );
00055 }
00056
00057 void CustomInput::setAbsAxis( const QString& name, InputDevice* input, int axis )
00058 {
00059 if( !input->absAxisCapabilities().contains( axis ) )
00060 {
00061 qDebug() << "Cannot find keyCode for this input...";
00062 return;
00063 }
00064 d->m_absAxis.insert( name, qMakePair( input, axis ) );
00065 connect( input, SIGNAL( eventSent( InputEvent* ) ), SLOT( inputEvent( InputEvent* ) ) );
00066 }
00067
00068 void CustomInput::setRelAxis( const QString& name, InputDevice* input, int axis )
00069 {
00070 if( !input->relAxisCapabilities().contains( axis ) )
00071 {
00072 qDebug() << "Cannot find keyCode for this input...";
00073 return;
00074 }
00075 d->m_absAxis.insert( name, qMakePair( input, axis ) );
00076 connect( input, SIGNAL( eventSent( InputEvent* ) ), SLOT( inputEvent( InputEvent* ) ) );
00077
00078 }
00079
00080 void CustomInput::remButton( const QString& name )
00081 {
00082 if( d->m_buttons.contains( name ) )
00083 {
00084 disconnect( d->m_buttons[name].first, SIGNAL( eventSent( InputEvent* ) ), this, SLOT( inputEvent( InputEvent* ) ) );
00085 d->m_buttons.remove( name );
00086 }
00087 }
00088
00089 void CustomInput::remAbsAxis( const QString& name )
00090 {
00091 if( d->m_absAxis.contains( name ) )
00092 {
00093 disconnect( d->m_buttons[name].first, SIGNAL( eventSent( InputEvent* ) ), this, SLOT( inputEvent( InputEvent* ) ) );
00094 d->m_absAxis.remove( name );
00095 }
00096 }
00097
00098 void CustomInput::remRelAxis( const QString& name )
00099 {
00100 if( d->m_relAxis.contains( name ) )
00101 {
00102 disconnect( d->m_buttons[name].first, SIGNAL( eventSent( InputEvent* ) ), this, SLOT( inputEvent( InputEvent* ) ) );
00103 d->m_relAxis.remove( name );
00104 }
00105 }
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215 QStringList CustomInput::buttonNameList()
00216 {
00217 QStringList list;
00218 QMapIterator <QString, QPair<InputDevice*, int> > i( d->m_buttons );
00219 while( i.hasNext() )
00220 {
00221 i.next();
00222 list << i.key();
00223 }
00224 return list;
00225 }
00226
00227 QStringList CustomInput::absAxisNameList()
00228 {
00229 QStringList list;
00230 QMapIterator<QString, QPair<InputDevice*, int> > i( d->m_absAxis );
00231 while( i.hasNext() )
00232 {
00233 i.next();
00234 list << i.key();
00235 }
00236 return list;
00237 }
00238
00239 QStringList CustomInput::relAxisNameList()
00240 {
00241 QStringList list;
00242 QMapIterator <QString, QPair<InputDevice*, int> > i( d->m_relAxis );
00243 while( i.hasNext() )
00244 {
00245 i.next();
00246 list << i.key();
00247 }
00248 return list;
00249 }
00250
00251 #include "custominput.moc"