[Scummvm-cvs-logs] CVS: scummvm/sword1 control.cpp,1.55,1.56 control.h,1.23,1.24
Torbjörn Andersson
eriktorbjorn at users.sourceforge.net
Thu Aug 25 08:35:22 CEST 2005
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sword1 control.cpp,1.54,1.55 control.h,1.22,1.23
- Next message: [Scummvm-cvs-logs] CVS: scummvm/saga ihnm_introproc.cpp,1.53,1.54 saga.cpp,1.130,1.131 sfuncs.cpp,1.153,1.154 sthread.cpp,1.103,1.104
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/sword1
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10264
Modified Files:
control.cpp control.h
Log Message:
Added keyboard repeating.
Index: control.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/control.cpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- control.cpp 24 Aug 2005 16:10:08 -0000 1.55
+++ control.cpp 25 Aug 2005 15:33:38 -0000 1.56
@@ -43,6 +43,11 @@
#define SAVEFILE_WRITE true
#define SAVEFILE_READ false
+enum {
+ kKeyRepeatInitialDelay = 400,
+ kKeyRepeatSustainDelay = 100
+};
+
enum LangStrings {
STR_PAUSED = 0,
STR_INSERT_CD_A,
@@ -167,6 +172,8 @@
_music = pMusic;
_sound = pSound;
_lStrings = _languageStrings + SwordEngine::_systemVars.language * 20;
+ _keyRepeat = 0;
+ _keyRepeatTime = 0;
}
void Control::askForCd(void) {
@@ -1005,7 +1012,8 @@
void Control::delay(uint32 msecs) {
OSystem::Event event;
- uint32 endTime = _system->getMillis() + msecs;
+ uint32 now = _system->getMillis();
+ uint32 endTime = now + msecs;
_keyPressed = 0; //reset
_mouseState = 0;
@@ -1019,6 +1027,12 @@
_keyPressed = 8;
else
_keyPressed = (byte)event.kbd.ascii;
+ _keyRepeatTime = now + kKeyRepeatInitialDelay;
+ _keyRepeat = _keyPressed;
+ break;
+ case OSystem::EVENT_KEYUP:
+ _keyRepeatTime = 0;
+ _keyRepeat = 0;
break;
case OSystem::EVENT_MOUSEMOVE:
_mouseX = event.mouse.x;
@@ -1051,6 +1065,10 @@
break;
}
}
+ if (_keyRepeatTime && now > _keyRepeatTime) {
+ _keyRepeatTime += kKeyRepeatSustainDelay;
+ _keyPressed = _keyRepeat;
+ }
#ifndef __PALM_OS__
_system->delayMillis(10);
#endif
Index: control.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/control.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- control.h 24 Aug 2005 16:10:09 -0000 1.23
+++ control.h 25 Aug 2005 15:33:38 -0000 1.24
@@ -138,6 +138,8 @@
uint8 *_font, *_redFont;
uint8 *_screenBuf;
uint8 _keyPressed;
+ uint8 _keyRepeat;
+ uint32 _keyRepeatTime;
void delay(uint32 msecs);
uint16 _mouseX, _mouseY, _mouseState;
bool _mouseDown;
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sword1 control.cpp,1.54,1.55 control.h,1.22,1.23
- Next message: [Scummvm-cvs-logs] CVS: scummvm/saga ihnm_introproc.cpp,1.53,1.54 saga.cpp,1.130,1.131 sfuncs.cpp,1.153,1.154 sthread.cpp,1.103,1.104
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list