~ubuntu-branches/ubuntu/intrepid/blender/intrepid-updates

« back to all changes in this revision

Viewing changes to source/gameengine/GameLogic/SCA_KeyboardSensor.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-08-08 02:45:40 UTC
  • mfrom: (12.1.14 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080808024540-kkjp7ekfivzhuw3l
Tags: 2.46+dfsg-4
* Fix python syntax warning in import_dxf.py, which led to nasty output
  in installation/upgrade logs during byte-compilation, using a patch
  provided by the script author (Closes: #492280):
   - debian/patches/45_fix_python_syntax_warning

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
 * $Id: SCA_KeyboardSensor.cpp,v 1.7 2004/10/16 11:41:48 kester Exp $
 
2
 * $Id: SCA_KeyboardSensor.cpp 14662 2008-05-02 15:47:08Z ben2610 $
3
3
 *
4
 
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
 
4
 * ***** BEGIN GPL LICENSE BLOCK *****
5
5
 *
6
6
 * This program is free software; you can redistribute it and/or
7
7
 * modify it under the terms of the GNU General Public License
8
8
 * as published by the Free Software Foundation; either version 2
9
 
 * of the License, or (at your option) any later version. The Blender
10
 
 * Foundation also sells licenses for use in proprietary software under
11
 
 * the Blender License.  See http://www.blender.org/BL/ for information
12
 
 * about this.
 
9
 * of the License, or (at your option) any later version.
13
10
 *
14
11
 * This program is distributed in the hope that it will be useful,
15
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
24
 *
28
25
 * Contributor(s): none yet.
29
26
 *
30
 
 * ***** END GPL/BL DUAL LICENSE BLOCK *****
 
27
 * ***** END GPL LICENSE BLOCK *****
31
28
 * Sensor for keyboard input
32
29
 */
33
30
#include "SCA_KeyboardSensor.h"
137
134
        {
138
135
                bool justactivated = false;
139
136
                bool justreleased = false;
 
137
                bool active = false;
140
138
 
141
139
                for (int i=SCA_IInputDevice::KX_BEGINKEY ; i< SCA_IInputDevice::KX_ENDKEY;i++)
142
140
                {
143
141
                        const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i);
144
 
                        if (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED)
145
 
                        {
 
142
                        switch (inevent.m_status) 
 
143
                        { 
 
144
                        case SCA_InputEvent::KX_JUSTACTIVATED:
146
145
                                justactivated = true;
147
 
                        }
148
 
                        if (inevent.m_status == SCA_InputEvent::KX_JUSTRELEASED)
149
 
                        {
 
146
                                break;
 
147
                        case SCA_InputEvent::KX_JUSTRELEASED:
150
148
                                justreleased = true;
 
149
                                break;
 
150
                        case SCA_InputEvent::KX_ACTIVE:
 
151
                                active = true;
 
152
                                break;
151
153
                        }
152
154
                }
153
155
 
159
161
                {
160
162
                        if (justreleased)
161
163
                        {
162
 
                                m_val=0;
 
164
                                m_val=(active)?1:0;
163
165
                                result = true;
 
166
                        } else
 
167
                        {
 
168
                                if (active)
 
169
                                {
 
170
                                        if (m_val == 0)
 
171
                                        {
 
172
                                                //see comment below
 
173
                                                //m_val = 1;
 
174
                                                //result = true;
 
175
                                                ;
 
176
                                        }
 
177
                                } else
 
178
                                {
 
179
                                        if (m_val == 1)
 
180
                                        {
 
181
                                                m_val = 0;
 
182
                                                result = true;
 
183
                                        }
 
184
                                }
164
185
                        }
165
186
                }
166
187
 
176
197
 
177
198
                if (inevent.m_status == SCA_InputEvent::KX_NO_INPUTSTATUS)
178
199
                {
 
200
                        if (m_val == 1)
 
201
                        {
 
202
                                // this situation may occur after a scene suspend: the keyboard release 
 
203
                                // event was not captured, produce now the event off
 
204
                                m_val = 0;
 
205
                                result = true;
 
206
                        }
179
207
                } else
180
208
                {
181
209
                        if (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED)
188
216
                                {
189
217
                                        m_val = 0;
190
218
                                        result = true;
 
219
                                } else 
 
220
                                {
 
221
                                        if (inevent.m_status == SCA_InputEvent::KX_ACTIVE)
 
222
                                        {
 
223
                                                if (m_val == 0)
 
224
                                                {
 
225
                                                        //hmm, this abnormal situation may occur in the following cases:
 
226
                                                        //- the key was pressed while the scene was suspended
 
227
                                                        //- this is a new scene and the key is active from the start
 
228
                                                        //In the second case, it's dangerous to activate the sensor
 
229
                                                        //(think of a key to go to next scene)
 
230
                                                        //What we really need is a edge/level flag in the key sensor
 
231
                                                        //m_val = 1;
 
232
                                                        //result = true;
 
233
                                                        ;
 
234
                                                }
 
235
                                        }
191
236
                                }
192
237
                        }
193
238
                }
212
257
                                        newprop.SetLength(oldlength - 1);
213
258
                                        CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);
214
259
                                        GetParent()->SetProperty(m_targetprop, newstringprop);
 
260
                                        newstringprop->Release();
215
261
                                }                               
216
262
                        } else {
217
263
                                /* append */
219
265
                                STR_String newprop = tprop->GetText() + pchar;
220
266
                                CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);                 
221
267
                                GetParent()->SetProperty(m_targetprop, newstringprop);
 
268
                                newstringprop->Release();
222
269
                        }
223
270
                } else {
224
271
                        if (!IsDelete(keyIndex)) {
227
274
                                STR_String newprop = pchar;
228
275
                                CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);                 
229
276
                                GetParent()->SetProperty(m_targetprop, newstringprop);
 
277
                                newstringprop->Release();
230
278
                        }
231
279
                }
232
280
        }