@@ -31,6 +31,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
31
31
32
32
#include < ISceneCollisionManager.h>
33
33
34
+ // Very slow button repeat frequency (in seconds)
35
+ #define SLOW_BUTTON_REPEAT (1 .0f )
36
+
34
37
using namespace irr ::core;
35
38
36
39
extern Settings *g_settings;
@@ -121,6 +124,7 @@ TouchScreenGUI::TouchScreenGUI(IrrlichtDevice *device, IEventReceiver* receiver)
121
124
for (unsigned int i=0 ; i < after_last_element_id; i++) {
122
125
m_buttons[i].guibutton = 0 ;
123
126
m_buttons[i].repeatcounter = -1 ;
127
+ m_buttons[i].repeatdelay = BUTTON_REPEAT_DELAY;
124
128
}
125
129
126
130
m_screensize = m_device->getVideoDriver ()->getScreenSize ();
@@ -141,13 +145,14 @@ void TouchScreenGUI::loadButtonTexture(button_info* btn, const char* path)
141
145
}
142
146
143
147
void TouchScreenGUI::initButton (touch_gui_button_id id, rect<s32> button_rect,
144
- std::wstring caption, bool immediate_release )
148
+ std::wstring caption, bool immediate_release, float repeat_delay )
145
149
{
146
150
147
151
button_info* btn = &m_buttons[id];
148
152
btn->guibutton = m_guienv->addButton (button_rect, 0 , id, caption.c_str ());
149
153
btn->guibutton ->grab ();
150
154
btn->repeatcounter = -1 ;
155
+ btn->repeatdelay = repeat_delay;
151
156
btn->keycode = id2keycode (id);
152
157
btn->immediate_release = immediate_release;
153
158
btn->ids .clear ();
@@ -240,25 +245,25 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc, float density)
240
245
rect<s32>(m_screensize.X - (0.75 *button_size),
241
246
m_screensize.Y - (2.25 *button_size),
242
247
m_screensize.X , m_screensize.Y - (button_size*1.5 )),
243
- L" fly" , true );
248
+ L" fly" , false , SLOW_BUTTON_REPEAT );
244
249
245
250
/* init noclip button */
246
251
initButton (noclip_id,
247
252
rect<s32>(m_screensize.X - (0.75 *button_size), 2.25 *button_size,
248
253
m_screensize.X , 3 *button_size),
249
- L" clip" , true );
254
+ L" clip" , false , SLOW_BUTTON_REPEAT );
250
255
251
256
/* init fast button */
252
257
initButton (fast_id,
253
258
rect<s32>(m_screensize.X - (0.75 *button_size), 1.5 *button_size,
254
259
m_screensize.X , 2.25 *button_size),
255
- L" fast" , true );
260
+ L" fast" , false , SLOW_BUTTON_REPEAT );
256
261
257
262
/* init debug button */
258
263
initButton (debug_id,
259
264
rect<s32>(m_screensize.X - (0.75 *button_size), 0.75 *button_size,
260
265
m_screensize.X , 1.5 *button_size),
261
- L" dbg" , true );
266
+ L" dbg" , false , SLOW_BUTTON_REPEAT );
262
267
263
268
/* init chat button */
264
269
initButton (chat_id,
@@ -270,13 +275,13 @@ void TouchScreenGUI::init(ISimpleTextureSource* tsrc, float density)
270
275
initButton (camera_id,
271
276
rect<s32>(m_screensize.X - (1.5 *button_size), 0 ,
272
277
m_screensize.X - (0.75 *button_size), 0.75 *button_size),
273
- L" cam" , true );
278
+ L" cam" , false , SLOW_BUTTON_REPEAT );
274
279
275
280
/* init rangeselect button */
276
281
initButton (range_id,
277
282
rect<s32>(m_screensize.X - (2.25 *button_size), 0 ,
278
283
m_screensize.X - (1.5 *button_size), 0.75 *button_size),
279
- L" far" , true );
284
+ L" far" , false , SLOW_BUTTON_REPEAT );
280
285
}
281
286
282
287
touch_gui_button_id TouchScreenGUI::getButtonID (s32 x, s32 y)
@@ -687,7 +692,7 @@ void TouchScreenGUI::step(float dtime)
687
692
if (m_move_id != -1 )
688
693
m_move_has_really_moved = true ;
689
694
690
- if (btn->repeatcounter < 0.2 ) continue ;
695
+ if (btn->repeatcounter < btn-> repeatdelay ) continue ;
691
696
692
697
btn->repeatcounter = 0 ;
693
698
SEvent translated;
0 commit comments