[Scummvm-cvs-logs] SF.net SVN: scummvm: [26170] scummvm/trunk

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Sat Mar 17 16:44:27 CET 2007


Revision: 26170
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26170&view=rev
Author:   eriktorbjorn
Date:     2007-03-17 08:44:26 -0700 (Sat, 17 Mar 2007)

Log Message:
-----------
Applied my re-revised patch #1487149 ("Simplified keyboard repeat"), with
Fingolfin's blessings. Keyboard repeat is now handled by the event manager,
rather than by individual engines.

Since this can cause problems with some engines (see the AGI engine), the extra
"key down" events are marked as "synthetic", so that they can be ignored if
necessary.

Modified Paths:
--------------
    scummvm/trunk/backends/events/default/default-events.cpp
    scummvm/trunk/backends/events/default/default-events.h
    scummvm/trunk/common/system.h
    scummvm/trunk/engines/agi/agi.cpp
    scummvm/trunk/engines/agos/agos.cpp
    scummvm/trunk/engines/agos/agos.h
    scummvm/trunk/engines/agos/event.cpp
    scummvm/trunk/engines/kyra/gui.cpp
    scummvm/trunk/engines/kyra/kyra.h
    scummvm/trunk/engines/saga/input.cpp
    scummvm/trunk/engines/saga/interface.cpp
    scummvm/trunk/engines/saga/interface.h
    scummvm/trunk/engines/sword1/control.cpp
    scummvm/trunk/engines/sword1/control.h
    scummvm/trunk/engines/sword2/sword2.cpp
    scummvm/trunk/engines/sword2/sword2.h
    scummvm/trunk/gui/newgui.cpp
    scummvm/trunk/gui/newgui.h

Modified: scummvm/trunk/backends/events/default/default-events.cpp
===================================================================
--- scummvm/trunk/backends/events/default/default-events.cpp	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/backends/events/default/default-events.cpp	2007-03-17 15:44:26 UTC (rev 26170)
@@ -33,19 +33,40 @@
 	_shouldQuit(false) {
 
  	assert(_boss);
+
+	// Reset key repeat
+	_currentKeyDown.keycode = 0;
 }
 
 bool DefaultEventManager::pollEvent(OSystem::Event &event) {
+	uint32 time = _boss->getMillis();
 	bool result;
 	
 	result = _boss->pollEvent(event);
 	
 	if (result) {
+		event.synthetic = false;
 		switch (event.type) {
 		case OSystem::EVENT_KEYDOWN:
+			_modifierState = event.kbd.flags;
+
+			// init continuous event stream
+			// not done on PalmOS because keyboard is emulated and keyup is not generated
+#if !defined(PALMOS_MODE)
+			_currentKeyDown.ascii = event.kbd.ascii;
+			_currentKeyDown.keycode = event.kbd.keycode;
+			_currentKeyDown.flags = event.kbd.flags;
+			_keyRepeatTime = time + kKeyRepeatInitialDelay;
+#endif
+			break;
 		case OSystem::EVENT_KEYUP:
 			_modifierState = event.kbd.flags;
+			if (event.kbd.keycode == _currentKeyDown.keycode) {
+				// Only stop firing events if it's the current key
+				_currentKeyDown.keycode = 0;
+			}
 			break;
+
 		case OSystem::EVENT_MOUSEMOVE:
 			_mousePos = event.mouse;
 			break;
@@ -75,6 +96,18 @@
 		default:
 			break;
 		}
+	} else {
+		// Check if event should be sent again (keydown)
+		if (_currentKeyDown.keycode != 0 && _keyRepeatTime < time) {
+			// fire event
+			event.type = OSystem::EVENT_KEYDOWN;
+			event.synthetic = true;
+			event.kbd.ascii = _currentKeyDown.ascii;
+			event.kbd.keycode = _currentKeyDown.keycode;
+			event.kbd.flags = _currentKeyDown.flags;
+			_keyRepeatTime = time + kKeyRepeatSustainDelay;
+			result = true;
+		}
 	}
 	
 	return result;

Modified: scummvm/trunk/backends/events/default/default-events.h
===================================================================
--- scummvm/trunk/backends/events/default/default-events.h	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/backends/events/default/default-events.h	2007-03-17 15:44:26 UTC (rev 26170)
@@ -46,6 +46,19 @@
 	int _modifierState;
 	bool _shouldQuit;
 
+	// for continuous events (keyDown)
+	enum {
+		kKeyRepeatInitialDelay = 400,
+		kKeyRepeatSustainDelay = 100
+	};
+
+	struct {
+		uint16 ascii;
+		byte flags;
+		int keycode;
+	} _currentKeyDown;
+	uint32 _keyRepeatTime;
+
 public:
 	DefaultEventManager(OSystem *boss);
 

Modified: scummvm/trunk/common/system.h
===================================================================
--- scummvm/trunk/common/system.h	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/common/system.h	2007-03-17 15:44:26 UTC (rev 26170)
@@ -743,6 +743,10 @@
 	struct Event {
 		/** The type of the event. */
 		EventType type;
+		/** Flag to indicate if the event is real or synthetic. E.g. keyboard
+		  * repeat events are synthetic.
+		  */
+		bool synthetic;
 		/**
 		  * Keyboard data; only valid for keyboard events (EVENT_KEYDOWN and
 		  * EVENT_KEYUP). For all other event types, content is undefined.

Modified: scummvm/trunk/engines/agi/agi.cpp
===================================================================
--- scummvm/trunk/engines/agi/agi.cpp	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/engines/agi/agi.cpp	2007-03-17 15:44:26 UTC (rev 26170)
@@ -113,35 +113,43 @@
 			switch (key = event.kbd.keycode) {
 			case 256 + 20:	// left arrow
 			case 260:	// key pad 4
-				key = KEY_LEFT;
+				if (!event.synthetic)
+					key = KEY_LEFT;
 				break;
 			case 256 + 19:	// right arrow
 			case 262:	// key pad 6
-				key = KEY_RIGHT;
+				if (!event.synthetic)
+					key = KEY_RIGHT;
 				break;
 			case 256 + 17:	// up arrow
 			case 264:	// key pad 8
-				key = KEY_UP;
+				if (!event.synthetic)
+					key = KEY_UP;
 				break;
 			case 256 + 18:	// down arrow
 			case 258:	// key pad 2
-				key = KEY_DOWN;
+				if (!event.synthetic)
+					key = KEY_DOWN;
 				break;
 			case 256 + 24:	// page up
 			case 265:	// key pad 9
-				key = KEY_UP_RIGHT;
+				if (!event.synthetic)
+					key = KEY_UP_RIGHT;
 				break;
 			case 256 + 25:	// page down
 			case 259:	// key pad 3
-				key = KEY_DOWN_RIGHT;
+				if (!event.synthetic)
+					key = KEY_DOWN_RIGHT;
 				break;
 			case 256 + 22:	// home
 			case 263:	// key pad 7
-				key = KEY_UP_LEFT;
+				if (!event.synthetic)
+					key = KEY_UP_LEFT;
 				break;
 			case 256 + 23:	// end
 			case 257:	// key pad 1
-				key = KEY_DOWN_LEFT;
+				if (!event.synthetic)
+					key = KEY_DOWN_LEFT;
 				break;
 			case 261:	// key pad 5
 				key = KEY_STATIONARY;

Modified: scummvm/trunk/engines/agos/agos.cpp
===================================================================
--- scummvm/trunk/engines/agos/agos.cpp	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/engines/agos/agos.cpp	2007-03-17 15:44:26 UTC (rev 26170)
@@ -81,8 +81,6 @@
 	_debugger = 0;
 
 	_keyPressed = 0;
-	_keyRepeatKey = 0;
-	_keyRepeatTime = 0;
 
 	_gameFile = 0;
 

Modified: scummvm/trunk/engines/agos/agos.h
===================================================================
--- scummvm/trunk/engines/agos/agos.h	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/engines/agos/agos.h	2007-03-17 15:44:26 UTC (rev 26170)
@@ -200,8 +200,6 @@
 	const GameSpecificSettings *gss;
 
 	byte _keyPressed;
-	byte _keyRepeatKey;
-	uint32 _keyRepeatTime;
 
 	typedef enum {
 		FORMAT_NONE,

Modified: scummvm/trunk/engines/agos/event.cpp
===================================================================
--- scummvm/trunk/engines/agos/event.cpp	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/engines/agos/event.cpp	2007-03-17 15:44:26 UTC (rev 26170)
@@ -375,14 +375,7 @@
 					_keyPressed = 8;
 				else
 					_keyPressed = (byte)event.kbd.ascii;
-
-				_keyRepeatTime = _system->getMillis() + 400;
-				_keyRepeatKey = _keyPressed;
 				break;
-			case OSystem::EVENT_KEYUP:
-				_keyRepeatKey = 0;
-				_keyRepeatTime = 0;
-				break;
 			case OSystem::EVENT_MOUSEMOVE:
 				_sdlMouseX = event.mouse.x;
 				_sdlMouseY = event.mouse.y;
@@ -435,11 +428,6 @@
 
 		cur = _system->getMillis();
 	} while (cur < start + amount);
-
-	if (_keyPressed == 0 && _keyRepeatKey != 0 && _keyRepeatTime != 0 && cur >= _keyRepeatTime) {
-		_keyPressed = _keyRepeatKey;
-		_keyRepeatTime = cur + 100;
-	}
 }
 
 void AGOSEngine::timer_callback() {

Modified: scummvm/trunk/engines/kyra/gui.cpp
===================================================================
--- scummvm/trunk/engines/kyra/gui.cpp	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/engines/kyra/gui.cpp	2007-03-17 15:44:26 UTC (rev 26170)
@@ -597,8 +597,7 @@
 		calcCoords(_menu[i]);
 
 	_menuRestoreScreen = true;
-	_keyboardEvent.pending = 0;
-	_keyboardEvent.repeat = 0;
+	_keyPressed = 0;
 	_mousePressFlag = false;
 	
 	_toplevelMenu = 0;
@@ -835,13 +834,8 @@
 			_mouseWheel = 1;
 			break;
 		case OSystem::EVENT_KEYDOWN:
-			_keyboardEvent.pending = true;
-			_keyboardEvent.repeat = now + 400;
-			_keyboardEvent.ascii = event.kbd.ascii;
+			_keyPressed = event.kbd.ascii;
 			break;
-		case OSystem::EVENT_KEYUP:
-			_keyboardEvent.repeat = 0;
-			break;
 		default:
 			break;
 		}
@@ -852,10 +846,6 @@
 		lastScreenUpdate = now;
 	}
 
-	if (!_keyboardEvent.pending && _keyboardEvent.repeat && now >= _keyboardEvent.repeat) {
-		_keyboardEvent.pending = true;
-		_keyboardEvent.repeat = now + 100;
-	}
 	_system->delayMillis(3);
 }
 
@@ -1020,26 +1010,26 @@
 void KyraEngine::gui_updateSavegameString() {
 	int length;
 
-	if (_keyboardEvent.pending && _keyboardEvent.ascii) {
+	if (_keyPressed) {
 		length = strlen(_savegameName);
 
-		if (_keyboardEvent.ascii > 31 && _keyboardEvent.ascii < 127) {
+		if (_keyPressed > 31 && _keyPressed < 127) {
 			if (length < 31) {
-				_savegameName[length] = _keyboardEvent.ascii;
+				_savegameName[length] = _keyPressed;
 				_savegameName[length+1] = 0;
 				gui_redrawTextfield();
 			}
-		} else if (_keyboardEvent.ascii == 8 ||_keyboardEvent.ascii == 127) {
+		} else if (_keyPressed == 8 ||_keyPressed == 127) {
 			if (length > 0) {
 				_savegameName[length-1] = 0;
 				gui_redrawTextfield();
 			}
-		} else if (_keyboardEvent.ascii == 13) {
+		} else if (_keyPressed == 13) {
 			_displaySubMenu = false;
 		}
 	}
 
-	_keyboardEvent.pending = false;
+	_keyPressed = 0;
 }
 
 int KyraEngine::gui_saveGame(Button *button) {

Modified: scummvm/trunk/engines/kyra/kyra.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra.h	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/engines/kyra/kyra.h	2007-03-17 15:44:26 UTC (rev 26170)
@@ -227,12 +227,6 @@
 	MenuItem item[6];
 };
 
-struct KeyboardEvent {
-	bool pending;
-	uint32 repeat;
-	uint8 ascii;
-};
-
 class KyraEngine : public Engine {
 	friend class MusicPlayer;
 	friend class Debugger;
@@ -839,7 +833,7 @@
 	int _gameToLoad;
 	char _savegameName[31];
 	const char *_specialSavegameString;
-	KeyboardEvent _keyboardEvent;
+	uint8 _keyPressed;
 
 	struct KyragemState {
 		uint16 nextOperation;

Modified: scummvm/trunk/engines/saga/input.cpp
===================================================================
--- scummvm/trunk/engines/saga/input.cpp	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/engines/saga/input.cpp	2007-03-17 15:44:26 UTC (rev 26170)
@@ -121,9 +121,6 @@
 				break;
 			}
 			break;
-		case OSystem::EVENT_KEYUP:
-			_interface->processKeyUp(event.kbd.ascii);
-			break;
 		case OSystem::EVENT_LBUTTONUP:
 			_leftMouseButtonPressed = false;
 			break;

Modified: scummvm/trunk/engines/saga/interface.cpp
===================================================================
--- scummvm/trunk/engines/saga/interface.cpp	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/engines/saga/interface.cpp	2007-03-17 15:44:26 UTC (rev 26170)
@@ -212,7 +212,6 @@
 		error("Interface::Interface(): not enough memory");
 	}
 
-	_textInputRepeatPhase = 0;
 	_textInput = false;
 	_statusTextInput = false;
 	_statusTextInputState = kStatusTextInputFirstRun;
@@ -316,7 +315,6 @@
 		_textInput = true;
 		_textInputStringLength = strlen(_textInputString);
 		_textInputPos = _textInputStringLength + 1;
-		_textInputRepeatPhase = 0;
 		break;
 	case kPanelMap:
 		mapPanelShow();
@@ -337,14 +335,13 @@
 		_textInputString[0] = 0;
 		_textInputStringLength = 0;
 		_textInputPos = _textInputStringLength + 1;
-		_textInputRepeatPhase = 0;
 		break;
 	}
 
 	draw();
 }
 
-bool Interface::processAscii(uint16 ascii, bool synthetic) {
+bool Interface::processAscii(uint16 ascii) {
 	// TODO: Checking for Esc and Enter below is a bit hackish, and
 	// and probably only works with the English version. Maybe we should
 	// add a flag to the button so it can indicate if it's the default or
@@ -352,8 +349,6 @@
 
 	int i;
 	PanelButton *panelButton;
-	if (!synthetic)
-		_textInputRepeatPhase = 0;
 	if (_statusTextInput) {
 		processStatusTextInput(ascii);
 		return true;
@@ -536,40 +531,6 @@
 	return false;
 }
 
-#define KEYBOARD_REPEAT_DELAY1 300000L
-#define KEYBOARD_REPEAT_DELAY2 50000L
-
-void Interface::textInputRepeatCallback(void *refCon) {
-	((Interface *)refCon)->textInputRepeat();
-}
-
-void Interface::textInputStartRepeat(uint16 ascii) {
-	if (!_textInputRepeatPhase) {
-		_textInputRepeatPhase = 1;
-		_vm->_timer->removeTimerProc(&textInputRepeatCallback);
-		_vm->_timer->installTimerProc(&textInputRepeatCallback, KEYBOARD_REPEAT_DELAY1, this);
-	}
-
-	_textInputRepeatChar = ascii;
-}
-
-void Interface::textInputRepeat() {
-	if (_textInputRepeatPhase == 1) {
-		_textInputRepeatPhase = 2;
-		_vm->_timer->removeTimerProc(&textInputRepeatCallback);
-		_vm->_timer->installTimerProc(&textInputRepeatCallback, KEYBOARD_REPEAT_DELAY2, this);
-	} else if (_textInputRepeatPhase == 2) {
-		processAscii(_textInputRepeatChar, true);
-	}
-}
-
-void Interface::processKeyUp(uint16 ascii) {
-	if (_textInputRepeatPhase) {
-		_vm->_timer->removeTimerProc(&textInputRepeatCallback);
-		_textInputRepeatPhase = 0;
-	}
-}
-
 void Interface::setStatusText(const char *text, int statusColor) {
 	assert(text != NULL);
 	assert(strlen(text) < STATUS_TEXT_LEN);
@@ -928,7 +889,6 @@
 
 void Interface::processStatusTextInput(uint16 ascii) {
 
-	textInputStartRepeat(ascii);
 	switch (ascii) {
 	case 27: // esc
 		_statusTextInputState = kStatusTextInputAborted;
@@ -968,8 +928,6 @@
 	memset(tempString, 0, SAVE_TITLE_SIZE);
 	ch[1] = 0;
 
-	textInputStartRepeat(ascii);
-
 	switch (ascii) {
 	case 13:
 		return false;

Modified: scummvm/trunk/engines/saga/interface.h
===================================================================
--- scummvm/trunk/engines/saga/interface.h	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/engines/saga/interface.h	2007-03-17 15:44:26 UTC (rev 26170)
@@ -222,8 +222,7 @@
 	void drawStatusBar();
 	void setVerbState(int verb, int state);
 
-	bool processAscii(uint16 ascii, bool synthetic = false);
-	void processKeyUp(uint16 ascii);
+	bool processAscii(uint16 ascii);
 
 	void keyBoss();
 	void keyBossExit();
@@ -243,8 +242,6 @@
 	}
 
 private:
-	static void textInputRepeatCallback(void *refCon);
-
 	void drawInventory(Surface *backBuffer);
 	void updateInventory(int pos);
 	void inventoryChangePos(int chg);
@@ -343,8 +340,6 @@
 	void calcOptionSaveSlider();
 	bool processTextInput(uint16 ascii);
 	void processStatusTextInput(uint16 ascii);
-	void textInputStartRepeat(uint16 ascii);
-	void textInputRepeat(void);
 
 public:
 	void converseInit(void);
@@ -452,9 +447,6 @@
 
 	uint _statusTextInputPos;
 
-	int _textInputRepeatPhase;
-	uint16 _textInputRepeatChar;
-
 	PalEntry _mapSavedPal[PAL_ENTRIES];
 	bool _mapPanelCrossHairState;
 

Modified: scummvm/trunk/engines/sword1/control.cpp
===================================================================
--- scummvm/trunk/engines/sword1/control.cpp	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/engines/sword1/control.cpp	2007-03-17 15:44:26 UTC (rev 26170)
@@ -42,11 +42,6 @@
 
 namespace Sword1 {
 
-enum {
-	kKeyRepeatInitialDelay = 400,
-	kKeyRepeatSustainDelay = 100
-};
-
 enum LangStrings {
 	STR_PAUSED = 0,
 	STR_INSERT_CD_A,
@@ -171,8 +166,6 @@
 	_music = pMusic;
 	_sound = pSound;
 	_lStrings = _languageStrings + SwordEngine::_systemVars.language * 20;
-	_keyRepeat = 0;
-	_keyRepeatTime = 0;
 	_selectedButton = 255;
 }
 
@@ -1053,15 +1046,9 @@
 					_keyPressed = 8;
 				else
 					_keyPressed = (byte)event.kbd.ascii;
-				_keyRepeatTime = now + kKeyRepeatInitialDelay;
-				_keyRepeat = _keyPressed;
 				// we skip the rest of the delay and return immediately
 				// to handle keyboard input
 				return;
-			case OSystem::EVENT_KEYUP:
-				_keyRepeatTime = 0;
-				_keyRepeat = 0;
-				break;
 			case OSystem::EVENT_MOUSEMOVE:
 				_mouseX = event.mouse.x;
 				_mouseY = event.mouse.y;
@@ -1093,10 +1080,6 @@
 				break;
 			}
 		}
-		if (_keyRepeatTime && now > _keyRepeatTime) {
-			_keyRepeatTime += kKeyRepeatSustainDelay;
-			_keyPressed = _keyRepeat;
-		}
 
 		_system->updateScreen();
 		_system->delayMillis(10);

Modified: scummvm/trunk/engines/sword1/control.h
===================================================================
--- scummvm/trunk/engines/sword1/control.h	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/engines/sword1/control.h	2007-03-17 15:44:26 UTC (rev 26170)
@@ -139,8 +139,6 @@
 	uint8 *_font, *_redFont;
 	uint8 *_screenBuf;
 	uint8 _keyPressed;
-	uint8 _keyRepeat;
-	uint32 _keyRepeatTime;
 	void delay(uint32 msecs);
 	uint16 _mouseX, _mouseY, _mouseState;
 	bool _mouseDown;

Modified: scummvm/trunk/engines/sword2/sword2.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sword2.cpp	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/engines/sword2/sword2.cpp	2007-03-17 15:44:26 UTC (rev 26170)
@@ -187,7 +187,6 @@
 	_debugger = NULL;
 
 	_keyboardEvent.pending = false;
-	_keyboardEvent.repeat = 0;
 	_mouseEvent.pending = false;
 
 	_wantSfxDebug = false;
@@ -377,10 +376,6 @@
 
 		if (ke) {
 			if ((ke->modifiers == OSystem::KBD_CTRL && ke->keycode == 'd') || ke->ascii == '#' || ke->ascii == '~') {
-				// HACK: We have to clear the 'repeat' flag, or
-				// it will probably trigger a keyboard repeat
-				// immediately after the debug console closes.
-				_keyboardEvent.repeat = 0;
 				_debugger->attach();
 			} else if (ke->modifiers == 0 || ke->modifiers == OSystem::KBD_SHIFT) {
 				switch (ke->keycode) {
@@ -539,8 +534,6 @@
 void Sword2Engine::parseInputEvents() {
 	OSystem::Event event;
 
-	uint32 now = _system->getMillis();
-
 	Common::EventManager *eventMan = _system->getEventManager();
 	while (eventMan->pollEvent(event)) {
 		switch (event.type) {
@@ -555,15 +548,11 @@
 			}
 			if (!(_inputEventFilter & RD_KEYDOWN)) {
 				_keyboardEvent.pending = true;
-				_keyboardEvent.repeat = now + 400;
 				_keyboardEvent.ascii = event.kbd.ascii;
 				_keyboardEvent.keycode = event.kbd.keycode;
 				_keyboardEvent.modifiers = event.kbd.flags;
 			}
 			break;
-		case OSystem::EVENT_KEYUP:
-			_keyboardEvent.repeat = 0;
-			break;
 		case OSystem::EVENT_MOUSEMOVE:
 			if (!(_inputEventFilter & RD_KEYDOWN)) {
 				_mouse->setPos(event.mouse.x, event.mouse.y - MENUDEEP);
@@ -612,12 +601,6 @@
 			break;
 		}
 	}
-
-	// Handle keyboard auto-repeat
-	if (!_keyboardEvent.pending && _keyboardEvent.repeat && now >= _keyboardEvent.repeat) {
-		_keyboardEvent.pending = true;
-		_keyboardEvent.repeat = now + 100;
-	}
 }
 
 void Sword2Engine::gameCycle() {

Modified: scummvm/trunk/engines/sword2/sword2.h
===================================================================
--- scummvm/trunk/engines/sword2/sword2.h	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/engines/sword2/sword2.h	2007-03-17 15:44:26 UTC (rev 26170)
@@ -74,7 +74,6 @@
 
 struct KeyboardEvent {
 	bool pending;
-	uint32 repeat;
 	uint16 ascii;
 	int keycode;
 	int modifiers;

Modified: scummvm/trunk/gui/newgui.cpp
===================================================================
--- scummvm/trunk/gui/newgui.cpp	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/gui/newgui.cpp	2007-03-17 15:44:26 UTC (rev 26170)
@@ -50,9 +50,7 @@
 
 enum {
 	kDoubleClickDelay = 500, // milliseconds
-	kCursorAnimateDelay = 250,
-	kKeyRepeatInitialDelay = 400,
-	kKeyRepeatSustainDelay = 100
+	kCursorAnimateDelay = 250
 };
 
 void GuiObject::reflowLayout() {
@@ -91,9 +89,6 @@
 	// Clear the cursor
 	memset(_cursor, 0xFF, sizeof(_cursor));
 
-	// Reset key repeat
-	_currentKeyDown.keycode = 0;
-
 	bool loadClassicTheme = true;
 #ifndef DISABLE_FANCY_THEMES
 	ConfMan.registerDefault("gui_theme", "default");
@@ -272,21 +267,10 @@
 			
 			switch (event.type) {
 			case OSystem::EVENT_KEYDOWN:
-#if !defined(PALMOS_MODE)
-				// init continuous event stream
-				// not done on PalmOS because keyboard is emulated and keyup is not generated
-				_currentKeyDown.ascii = event.kbd.ascii;
-				_currentKeyDown.keycode = event.kbd.keycode;
-				_currentKeyDown.flags = event.kbd.flags;
-				_keyRepeatTime = time + kKeyRepeatInitialDelay;
-#endif
 				activeDialog->handleKeyDown(event.kbd.ascii, event.kbd.keycode, event.kbd.flags);
 				break;
 			case OSystem::EVENT_KEYUP:
 				activeDialog->handleKeyUp(event.kbd.ascii, event.kbd.keycode, event.kbd.flags);
-				if (event.kbd.keycode == _currentKeyDown.keycode)
-					// only stop firing events if it's the current key
-					_currentKeyDown.keycode = 0;
 				break;
 			case OSystem::EVENT_MOUSEMOVE:
 				activeDialog->handleMouseMoved(mouse.x, mouse.y, 0);
@@ -327,15 +311,6 @@
 			}
 		}
 
-		// check if event should be sent again (keydown)
-		if (_currentKeyDown.keycode != 0 && activeDialog == getTopDialog()) {
-			if (_keyRepeatTime < time) {
-				// fire event
-				activeDialog->handleKeyDown(_currentKeyDown.ascii, _currentKeyDown.keycode, _currentKeyDown.flags);
-				_keyRepeatTime = time + kKeyRepeatSustainDelay;
-			}
-		}
-
 		// Delay for a moment
 		_system->delayMillis(10);
 	}
@@ -353,7 +328,6 @@
 
 void NewGui::saveState() {
 	// Backup old cursor
-	_currentKeyDown.keycode = 0;
 	_lastClick.x = _lastClick.y = 0;
 	_lastClick.time = 0;
 	_lastClick.count = 0;

Modified: scummvm/trunk/gui/newgui.h
===================================================================
--- scummvm/trunk/gui/newgui.h	2007-03-17 14:34:50 UTC (rev 26169)
+++ scummvm/trunk/gui/newgui.h	2007-03-17 15:44:26 UTC (rev 26170)
@@ -99,14 +99,6 @@
 
 	bool		_useStdCursor;
 
-	// for continuous events (keyDown)
-	struct {
-		uint16 ascii;
-		byte flags;
-		int keycode;
-	} _currentKeyDown;
-	uint32		_keyRepeatTime;
-
 	// position and time of last mouse click (used to detect double clicks)
 	struct {
 		int16 x, y;	// Position of mouse when the click occured


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list