From 95ba2986d353cbc6a8cd4262cb9980b6071499b1 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 2 Jun 2007 12:42:40 +0000 Subject: Enhanced Common::String by adding char constructor and operator+ for chars svn-id: r27051 --- common/str.cpp | 21 +++++++++++++++++++++ common/str.h | 5 +++++ 2 files changed, 26 insertions(+) (limited to 'common') diff --git a/common/str.cpp b/common/str.cpp index 01d24c1e75..88aca87bb4 100644 --- a/common/str.cpp +++ b/common/str.cpp @@ -86,7 +86,16 @@ String::String(const String &str) } assert(_str != 0); } + +String::String(char c) +: _len(0), _str(_storage) { + _storage[0] = c; + _storage[1] = 0; + + _len = (c == 0) ? 0 : 1; +} + String::~String() { decRefCount(_extern._refCount); } @@ -437,6 +446,18 @@ String operator +(const String &x, const char *y) { return temp; } +String operator +(char x, const String &y) { + String temp(x); + temp += y; + return temp; +} + +String operator +(const String &x, char y) { + String temp(x); + temp += y; + return temp; +} + char *ltrim(char *t) { while (isspace(*t)) t++; diff --git a/common/str.h b/common/str.h index 509300dd6f..55ff94c51c 100644 --- a/common/str.h +++ b/common/str.h @@ -99,6 +99,7 @@ public: String() : _len(0), _str(_storage) { _storage[0] = 0; } String(const char *str, uint32 len = 0); String(const String &str); + String(char c); virtual ~String(); String &operator =(const char *str); @@ -187,9 +188,13 @@ protected: // Append two strings to form a new (temp) string String operator +(const String &x, const String &y); + String operator +(const char *x, const String &y); String operator +(const String &x, const char *y); +String operator +(const String &x, char y); +String operator +(char x, const String &y); + // Some useful additional comparision operators for Strings bool operator == (const char *x, const String &y); bool operator != (const char *x, const String &y); -- cgit v1.2.3 From 5df28554acb998b7df686122bb26cb897e40e075 Mon Sep 17 00:00:00 2001 From: Kostas Nakos Date: Sun, 3 Jun 2007 18:44:03 +0000 Subject: Adding the new kFeatureDisableKeyFiltering OSystem feature. This feature is used by agi's prediction dialog and is a hint to the backend to temporarily switch off any keyboard mapping, used in devices with limited keyboard input. Also, supply some comments to the newly added event & feature. svn-id: r27069 --- common/events.h | 6 ++++++ common/system.h | 19 +++++++++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/events.h b/common/events.h index 9b434e94f9..ac12fd3f4c 100644 --- a/common/events.h +++ b/common/events.h @@ -57,6 +57,12 @@ enum EventType { EVENT_QUIT = 10, EVENT_SCREEN_CHANGED = 11, + /** The backend requests the agi engine's predictive dialog to be shown. + * TODO: Fingolfin suggests that it would be of better value to expand + * on this notion by generalizing its use. For example the backend could + * use events to ask for the save game dialog or to pause the engine. + * An associated enumerated type can accomplish this. + **/ EVENT_PREDICTIVE_DIALOG = 12 }; diff --git a/common/system.h b/common/system.h index ccca1fb7c7..500056e695 100644 --- a/common/system.h +++ b/common/system.h @@ -125,7 +125,7 @@ public: kFeatureAutoComputeDirtyRects, /** - * This flags determines either cursor can have its own palette or not + * This flag determines either cursor can have its own palette or not * It is currently used only by some Macintosh versions of Humongous * Entertainment games. If backend doesn't implement this feature then * engine switches to b/w version of cursors. @@ -142,7 +142,22 @@ public: /** * Set to true to iconify the window. */ - kFeatureIconifyWindow + kFeatureIconifyWindow, + + /** + * This feature, set to true, is a hint toward the backend to disable all + * key filtering/mapping, in cases where it would be beneficial to do so. + * As an example case, this is used in the agi engine's predictive dialog. + * When the dialog is displayed this feature is set so that backends with + * phone-like keypad temporarily unmap all user actions which leads to + * comfortable word entry. Conversely, when the dialog exits the feature + * is set to false. + * TODO: Fingolfin suggests that the way the feature is used can be + * generalized in this sense: Have a keyboard mapping feature, which the + * engine queries for to assign keys to actions ("Here's my default key + * map for these actions, what do you want them set to?"). + */ + kFeatureDisableKeyFiltering }; /** -- cgit v1.2.3 From 9e651592ec9d58d8f5c0d2dea0e351bf048d2743 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 6 Jun 2007 18:35:37 +0000 Subject: Adv detector: Merged upgradeTargetIfNecessary() into detectGameForEngineCreation() svn-id: r27144 --- common/advancedDetector.cpp | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) (limited to 'common') diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp index 24e884a164..da65c30411 100644 --- a/common/advancedDetector.cpp +++ b/common/advancedDetector.cpp @@ -72,27 +72,6 @@ GameList gameIDList(const Common::ADParams ¶ms) { return GameList(params.list); } -static void upgradeTargetIfNecessary(const Common::ADParams ¶ms) { - if (params.obsoleteList == 0) - return; - - const char *gameid = ConfMan.get("gameid").c_str(); - - for (const Common::ADObsoleteGameID *o = params.obsoleteList; o->from; ++o) { - if (!scumm_stricmp(gameid, o->from)) { - gameid = o->to; - ConfMan.set("gameid", o->to); - - if (o->platform != Common::kPlatformUnknown) - ConfMan.set("platform", Common::getPlatformCode(o->platform)); - - warning("Target upgraded from %s to %s", o->from, o->to); - ConfMan.flushToDisk(); - break; - } - } -} - GameDescriptor findGameID( const char *gameid, const Common::ADParams ¶ms @@ -221,10 +200,24 @@ PluginError detectGameForEngineCreation( const Common::ADParams ¶ms ) { - upgradeTargetIfNecessary(params); - Common::String gameid = ConfMan.get("gameid"); + if (params.obsoleteList != 0) { + for (const Common::ADObsoleteGameID *o = params.obsoleteList; o->from; ++o) { + if (!scumm_stricmp(gameid.c_str(), o->from)) { + gameid = o->to; + ConfMan.set("gameid", o->to); + + if (o->platform != Common::kPlatformUnknown) + ConfMan.set("platform", Common::getPlatformCode(o->platform)); + + warning("Target upgraded from %s to %s", o->from, o->to); + ConfMan.flushToDisk(); + break; + } + } + } + FSList fslist; FilesystemNode dir(ConfMan.get("path")); if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) { -- cgit v1.2.3 From add3243e5e564bb730ac57af2fd9ce15e6d54309 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 11 Jun 2007 08:38:23 +0000 Subject: Fix for bug #1719463: "DETECTOR: Launching undefined target adds launcher entry" svn-id: r27352 --- common/advancedDetector.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp index da65c30411..f0f77ee26e 100644 --- a/common/advancedDetector.cpp +++ b/common/advancedDetector.cpp @@ -212,7 +212,12 @@ PluginError detectGameForEngineCreation( ConfMan.set("platform", Common::getPlatformCode(o->platform)); warning("Target upgraded from %s to %s", o->from, o->to); - ConfMan.flushToDisk(); + + if (ConfMan.hasKey("id_came_from_command_line")) { + warning("Target came from command line. Skipping save"); + } else { + ConfMan.flushToDisk(); + } break; } } -- cgit v1.2.3 From 6e5b70f5e9f8690b467ea8837e727e1048838788 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 12 Jun 2007 12:22:25 +0000 Subject: Patch #1733764: "Fallback detection patch". GSoC student. svn-id: r27375 --- common/advancedDetector.cpp | 136 ++++++++++++++++++++++++++++++-------------- common/advancedDetector.h | 27 ++++++++- 2 files changed, 117 insertions(+), 46 deletions(-) (limited to 'common') diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp index f0f77ee26e..7d7cadbade 100644 --- a/common/advancedDetector.cpp +++ b/common/advancedDetector.cpp @@ -72,6 +72,32 @@ GameList gameIDList(const Common::ADParams ¶ms) { return GameList(params.list); } +static void upgradeTargetIfNecessary(const Common::ADParams ¶ms) { + if (params.obsoleteList == 0) + return; + + const char *gameid = ConfMan.get("gameid").c_str(); + + for (const Common::ADObsoleteGameID *o = params.obsoleteList; o->from; ++o) { + if (!scumm_stricmp(gameid, o->from)) { + gameid = o->to; + ConfMan.set("gameid", o->to); + + if (o->platform != Common::kPlatformUnknown) + ConfMan.set("platform", Common::getPlatformCode(o->platform)); + + warning("Target upgraded from %s to %s", o->from, o->to); + + if (ConfMan.hasKey("id_came_from_command_line")) { + warning("Target came from command line. Skipping save"); + } else { + ConfMan.flushToDisk(); + } + break; + } + } +} + GameDescriptor findGameID( const char *gameid, const Common::ADParams ¶ms @@ -110,6 +136,24 @@ static GameDescriptor toGameDescriptor(const ADGameDescription &g, const PlainGa return gd; } +// Almost identical to the toGameDescriptor function that takes a ADGameDescription and PlainGameDescriptor. +// Just a little fine tuning about accessing variables. +// Used because of fallback detection and the dynamic string content it needs. +static GameDescriptor toGameDescriptor(const EncapsulatedADGameDesc &g, const PlainGameDescriptor *sg) { + const char *title = 0; + + while (sg->gameid) { + if (!scumm_stricmp(g.getGameID(), sg->gameid)) + title = sg->description; + sg++; + } + + assert(g.realDesc); + GameDescriptor gd(g.getGameID(), title, g.realDesc->language, g.realDesc->platform); + gd.updateDesc(g.getExtra()); + return gd; +} + /** * Generate a preferred target value as * GAMEID-PLAFORM-LANG @@ -134,38 +178,49 @@ static String generatePreferredTarget(const String &id, const ADGameDescription return res; } +static void updateGameDescriptor(GameDescriptor &desc, const ADGameDescription *realDesc, const Common::ADParams ¶ms) { + if (params.singleid != NULL) { + desc["preferredtarget"] = desc["gameid"]; + desc["gameid"] = params.singleid; + } + + if (params.flags & kADFlagAugmentPreferredTarget) { + if (!desc.contains("preferredtarget")) + desc["preferredtarget"] = desc["gameid"]; + + desc["preferredtarget"] = generatePreferredTarget(desc["preferredtarget"], realDesc); + } +} + GameList detectAllGames( const FSList &fslist, const Common::ADParams ¶ms ) { ADGameDescList matches = detectGame(&fslist, params, Common::UNK_LANG, Common::kPlatformUnknown); - GameList detectedGames; - for (uint i = 0; i < matches.size(); i++) { - GameDescriptor desc(toGameDescriptor(*matches[i], params.list)); - - if (params.singleid != NULL) { - desc["preferredtarget"] = desc["gameid"]; - desc["gameid"] = params.singleid; - } - if (params.flags & kADFlagAugmentPreferredTarget) { - if (!desc.contains("preferredtarget")) - desc["preferredtarget"] = desc["gameid"]; - - desc["preferredtarget"] = generatePreferredTarget(desc["preferredtarget"], matches[i]); + // Use fallback detector if there were no matches by other means + if (matches.empty() && params.fallbackDetectFunc != NULL) { + EncapsulatedADGameDesc fallbackDesc = (*params.fallbackDetectFunc)(&fslist); + if (fallbackDesc.realDesc != 0) { + GameDescriptor desc(toGameDescriptor(fallbackDesc, params.list)); + updateGameDescriptor(desc, fallbackDesc.realDesc, params); + detectedGames.push_back(desc); } - + } else for (uint i = 0; i < matches.size(); i++) { // Otherwise use the found matches + GameDescriptor desc(toGameDescriptor(*matches[i], params.list)); + updateGameDescriptor(desc, matches[i], params); detectedGames.push_back(desc); } return detectedGames; } -const ADGameDescription *detectBestMatchingGame( +EncapsulatedADGameDesc detectBestMatchingGame( const Common::ADParams ¶ms ) { const ADGameDescription *agdDesc = 0; + EncapsulatedADGameDesc result; Common::Language language = Common::UNK_LANG; Common::Platform platform = Common::kPlatformUnknown; @@ -189,39 +244,29 @@ const ADGameDescription *detectBestMatchingGame( agdDesc = matches[0]; } - if (agdDesc != 0) { - debug(2, "Running %s", toGameDescriptor(*agdDesc, params.list).description().c_str()); + if (agdDesc != 0) { // Check if we found a match without fallback detection + result = EncapsulatedADGameDesc(agdDesc); + } else if (params.fallbackDetectFunc != NULL) { // Use fallback detector if there were no matches by other means + EncapsulatedADGameDesc fallbackDesc = (*params.fallbackDetectFunc)(NULL); + if (fallbackDesc.realDesc != 0 && (params.singleid != NULL || fallbackDesc.getGameID() == gameid)) { + result = fallbackDesc; // Found a fallback match + } + } + + if (result.realDesc != 0) { + debug(2, "Running %s", toGameDescriptor(result, params.list).description().c_str()); } - return agdDesc; + return result; } PluginError detectGameForEngineCreation( const Common::ADParams ¶ms ) { - Common::String gameid = ConfMan.get("gameid"); + upgradeTargetIfNecessary(params); - if (params.obsoleteList != 0) { - for (const Common::ADObsoleteGameID *o = params.obsoleteList; o->from; ++o) { - if (!scumm_stricmp(gameid.c_str(), o->from)) { - gameid = o->to; - ConfMan.set("gameid", o->to); - - if (o->platform != Common::kPlatformUnknown) - ConfMan.set("platform", Common::getPlatformCode(o->platform)); - - warning("Target upgraded from %s to %s", o->from, o->to); - - if (ConfMan.hasKey("id_came_from_command_line")) { - warning("Target came from command line. Skipping save"); - } else { - ConfMan.flushToDisk(); - } - break; - } - } - } + Common::String gameid = ConfMan.get("gameid"); FSList fslist; FilesystemNode dir(ConfMan.get("path")); @@ -241,6 +286,14 @@ PluginError detectGameForEngineCreation( } } + // Use fallback detector if there were no matches by other means + if (params.fallbackDetectFunc != NULL) { + EncapsulatedADGameDesc fallbackDesc = (*params.fallbackDetectFunc)(&fslist); + if (fallbackDesc.realDesc != 0 && (params.singleid != NULL || fallbackDesc.getGameID() == gameid)) { + return kNoError; + } + } + return kNoGameDataFoundError; } @@ -491,11 +544,6 @@ static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &p } } - // If we still haven't got a match, try to use the fallback callback :-) - if (matched.empty() && params.fallbackDetectFunc != 0) { - matched = (*params.fallbackDetectFunc)(fslist); - } - return matched; } diff --git a/common/advancedDetector.h b/common/advancedDetector.h index fab847e671..2031f001a9 100644 --- a/common/advancedDetector.h +++ b/common/advancedDetector.h @@ -63,6 +63,29 @@ struct ADGameDescription { uint32 flags; }; +/** + * Encapsulates ADGameDescription and makes gameid and extra strings dynamic. + * Used in fallback detection when dynamically creating string content. + */ +struct EncapsulatedADGameDesc { + Common::String gameid; + Common::String extra; + const ADGameDescription *realDesc; + + // Constructor for the EncapsulatedADGameDesc + EncapsulatedADGameDesc() : realDesc(0) {} + EncapsulatedADGameDesc(const ADGameDescription *paramRealDesc, + Common::String paramGameID = Common::String(""), + Common::String paramExtra = Common::String("")) + : realDesc(paramRealDesc), gameid(paramGameID), extra(paramExtra) { + assert(paramRealDesc != NULL); + } + + // Functions for getting the correct gameid and extra values from the struct + const char *getGameID() const { return (gameid.empty() && realDesc != 0) ? realDesc->gameid : gameid.c_str(); } + const char *getExtra() const { return (extra.empty() && realDesc != 0) ? realDesc->extra : extra.c_str(); } +}; + /** * A list of pointers to ADGameDescription structs (or subclasses thereof). */ @@ -177,7 +200,7 @@ struct ADParams { * * @todo */ - ADGameDescList (*fallbackDetectFunc)(const FSList *fslist); + EncapsulatedADGameDesc (*fallbackDetectFunc)(const FSList *fslist); /** * A bitmask of flags which can be used to configure the behavior @@ -207,7 +230,7 @@ GameDescriptor findGameID(const char *gameid, const Common::ADParams ¶ms); GameList detectAllGames(const FSList &fslist, const Common::ADParams ¶ms); // FIXME/TODO: Rename this function to something more sensible. -const ADGameDescription *detectBestMatchingGame(const Common::ADParams ¶ms); +EncapsulatedADGameDesc detectBestMatchingGame(const Common::ADParams ¶ms); // FIXME/TODO: Rename this function to something more sensible. // Only used by ADVANCED_DETECTOR_DEFINE_PLUGIN_WITH_FUNC -- cgit v1.2.3 From d6e47d5fd322cf7cb61bee94b946096ecef64abb Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 15 Jun 2007 17:36:41 +0000 Subject: ADV detector: Refactored findGameID() a bit, making it possible to use it outside the AdvancedDetector framework; also made it generate somewhat more user friendly desc for obsolete game IDs svn-id: r27424 --- common/advancedDetector.cpp | 28 +++++++++++++++++----------- common/advancedDetector.h | 8 ++++++-- 2 files changed, 23 insertions(+), 13 deletions(-) (limited to 'common') diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp index 7d7cadbade..6b4d3f685e 100644 --- a/common/advancedDetector.cpp +++ b/common/advancedDetector.cpp @@ -100,25 +100,31 @@ static void upgradeTargetIfNecessary(const Common::ADParams ¶ms) { GameDescriptor findGameID( const char *gameid, - const Common::ADParams ¶ms + const PlainGameDescriptor *list, + const Common::ADObsoleteGameID *obsoleteList ) { - const PlainGameDescriptor *g = params.list; - while (g->gameid) { - if (0 == scumm_stricmp(gameid, g->gameid)) - return GameDescriptor(*g); - g++; - } - - if (params.obsoleteList != 0) { - const Common::ADObsoleteGameID *o = params.obsoleteList; + // First search the list of supported game IDs for a match. + const PlainGameDescriptor *g = findPlainGameDescriptor(gameid, list); + if (g) + return GameDescriptor(*g); + + // If we didn't find the gameid in the main list, check if it + // is an obsolete game id. + if (obsoleteList != 0) { + const Common::ADObsoleteGameID *o = obsoleteList; while (o->from) { if (0 == scumm_stricmp(gameid, o->from)) { - return GameDescriptor(gameid, "Obsolete game ID"); + g = findPlainGameDescriptor(o->to, list); + if (g && g->description) + return GameDescriptor(gameid, "Obsolete game ID (" + Common::String(g->description) + ")"); + else + return GameDescriptor(gameid, "Obsolete game ID"); } o++; } } + // No match found return GameDescriptor(); } diff --git a/common/advancedDetector.h b/common/advancedDetector.h index 2031f001a9..5066ba71e9 100644 --- a/common/advancedDetector.h +++ b/common/advancedDetector.h @@ -224,7 +224,11 @@ GameList gameIDList(const Common::ADParams ¶ms); * 'gameid' in there. If a match is found, returns a GameDescriptor * with gameid and description set. */ -GameDescriptor findGameID(const char *gameid, const Common::ADParams ¶ms); +GameDescriptor findGameID( + const char *gameid, + const PlainGameDescriptor *list, + const Common::ADObsoleteGameID *obsoleteList = 0 + ); // FIXME/TODO: Rename this function to something more sensible. GameList detectAllGames(const FSList &fslist, const Common::ADParams ¶ms); @@ -253,7 +257,7 @@ PluginError detectGameForEngineCreation(const Common::ADParams ¶ms); return Common::AdvancedDetector::gameIDList(params); \ } \ GameDescriptor Engine_##engine##_findGameID(const char *gameid) { \ - return Common::AdvancedDetector::findGameID(gameid, params); \ + return Common::AdvancedDetector::findGameID(gameid, params.list, params.obsoleteList); \ } \ GameList Engine_##engine##_detectGames(const FSList &fslist) { \ return Common::AdvancedDetector::detectAllGames(fslist, params); \ -- cgit v1.2.3 From 0a7bb215d9d4888c7106b41f6ca2ee46e09bca70 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 15 Jun 2007 17:37:28 +0000 Subject: Added a FIXME comment to the adv. detector code regarding (not) using FSNode/FSList svn-id: r27425 --- common/advancedDetector.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'common') diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp index 6b4d3f685e..a342ed910a 100644 --- a/common/advancedDetector.cpp +++ b/common/advancedDetector.cpp @@ -338,6 +338,9 @@ static ADGameDescList detectGame(const FSList *fslist, const Common::ADParams &p } } + // TODO/FIXME: Fingolfin says: It's not good that we have two different code paths here, + // one using a FSList, one using File::open, as that will lead to discrepancies and subtle + // problems caused by those. if (fslist != 0) { // Get the information of the existing files for (FSList::const_iterator file = fslist->begin(); file != fslist->end(); ++file) { -- cgit v1.2.3 From b51f2f3212ae8a5abbdce4d947ec2d1cad1a0b6f Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 19 Jun 2007 22:39:59 +0000 Subject: Implemented the OSystem framebuffer API, as discussed on scummvm-devel. All changes are just fine, and won't cause any compile problems or regressions, despite the fact that I can't test most of the non-SDL backend changes, at an improbability level of two to the power of two hundred and seventy-six thousand to one against - possibly much higher. Anything you still can't cope with is therefore your own problem. Please relax. svn-id: r27548 --- common/system.cpp | 5 +++++ common/system.h | 29 +++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) (limited to 'common') diff --git a/common/system.cpp b/common/system.cpp index 2720a19775..f8068d41f5 100644 --- a/common/system.cpp +++ b/common/system.cpp @@ -101,3 +101,8 @@ Common::EventManager *OSystem::getEventManager() { return s_eventManager; } +void OSystem::clearScreen() { + Graphics::Surface *screen = lockScreen(); + memset(screen->pixels, 0, screen->h * screen->pitch); + unlockScreen(); +} diff --git a/common/system.h b/common/system.h index 500056e695..a54546f233 100644 --- a/common/system.h +++ b/common/system.h @@ -452,21 +452,34 @@ public: virtual void copyRectToScreen(const byte *buf, int pitch, int x, int y, int w, int h) = 0; /** - * Copies the current screen contents to a new surface, with the original - * bit depth. This will allocate memory for the pixel data. - * WARNING: surf->free() must be called by the user to avoid leaking. + * Lock the active screen framebuffer and return a Graphics::Surface + * representing it. The caller can then perform arbitrary graphics + * transformations on the framebuffer (blitting, scrolling, etc.). + * Must be followed by matching call to unlockScreen(). Calling code + * should make sure to only lock the framebuffer for the briefest + * periods of time possible, as the whole system is potentially stalled + * while the lock is active. + * Returns 0 if an error occurred. Otherwise an 8bit surface is returned. * - * @param surf the surfce to store the data in it - * @return true if all went well, false if an error occured + * The returned surface must *not* be deleted by the client code. */ - virtual bool grabRawScreen(Graphics::Surface *surf) = 0; + virtual Graphics::Surface *lockScreen() = 0; + + /** + * Unlock the screen framebuffer, and mark it as dirty (i.e. during the + * next updateScreen() call, the whole screen will be updated. + */ + virtual void unlockScreen() = 0; /** * Clear the screen to black. */ - virtual void clearScreen() {} + virtual void clearScreen(); - /** Update the dirty areas of the screen. */ + /** + * Flush the whole screen, that is render the current content of the screen + * framebuffer (resp. the dirty/changed parts of it) to the display. + */ virtual void updateScreen() = 0; /** -- cgit v1.2.3 From 218a2da5d4e19089b6cb99199bb18493ef6e25af Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Wed, 20 Jun 2007 17:52:24 +0000 Subject: typo - (returh => return) -- jvprat svn-id: r27558 --- common/system.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/system.h b/common/system.h index a54546f233..95f970d956 100644 --- a/common/system.h +++ b/common/system.h @@ -791,7 +791,7 @@ public: //@{ /** - * Returh the audio mixer. For more information, refer to the + * Return the audio mixer. For more information, refer to the * Audio::Mixer documentation. */ virtual Audio::Mixer *getMixer() = 0; -- cgit v1.2.3 From bd9ba26109ff741a541204481b6ad8ef15fefd0b Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 21 Jun 2007 18:35:15 +0000 Subject: Modified version of patch #1740493 (EVENTS: Event Key Codes) svn-id: r27592 --- common/events.h | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 152 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/events.h b/common/events.h index ac12fd3f4c..0330f4b417 100644 --- a/common/events.h +++ b/common/events.h @@ -57,7 +57,8 @@ enum EventType { EVENT_QUIT = 10, EVENT_SCREEN_CHANGED = 11, - /** The backend requests the agi engine's predictive dialog to be shown. + /** + * The backend requests the agi engine's predictive dialog to be shown. * TODO: Fingolfin suggests that it would be of better value to expand * on this notion by generalizing its use. For example the backend could * use events to ask for the save game dialog or to pause the engine. @@ -66,6 +67,155 @@ enum EventType { EVENT_PREDICTIVE_DIALOG = 12 }; +enum KeyCode { + KEYCODE_BACKSPACE = 8, + KEYCODE_TAB = 9, + KEYCODE_CLEAR = 12, + KEYCODE_RETURN = 13, + KEYCODE_PAUSE = 19, + KEYCODE_ESCAPE = 27, + KEYCODE_SPACE = 32, + KEYCODE_EXCLAIM = 33, + KEYCODE_QUOTEDBL = 34, + KEYCODE_HASH = 35, + KEYCODE_DOLLAR = 36, + KEYCODE_AMPERSAND = 38, + KEYCODE_QUOTE = 39, + KEYCODE_LEFTPAREN = 40, + KEYCODE_RIGHTPAREN = 41, + KEYCODE_ASTERISK = 42, + KEYCODE_PLUS = 43, + KEYCODE_COMMA = 44, + KEYCODE_MINUS = 45, + KEYCODE_PERIOD = 46, + KEYCODE_SLASH = 47, + KEYCODE_0 = 48, + KEYCODE_1 = 49, + KEYCODE_2 = 50, + KEYCODE_3 = 51, + KEYCODE_4 = 52, + KEYCODE_5 = 53, + KEYCODE_6 = 54, + KEYCODE_7 = 55, + KEYCODE_8 = 56, + KEYCODE_9 = 57, + KEYCODE_COLON = 58, + KEYCODE_SEMICOLON = 59, + KEYCODE_LESS = 60, + KEYCODE_EQUALS = 61, + KEYCODE_GREATER = 62, + KEYCODE_QUESTION = 63, + KEYCODE_AT = 64, + + KEYCODE_LEFTBRACKET = 91, + KEYCODE_BACKSLASH = 92, + KEYCODE_RIGHTBRACKET = 93, + KEYCODE_CARET = 94, + KEYCODE_UNDERSCORE = 95, + KEYCODE_BACKQUOTE = 96, + KEYCODE_a = 97, + KEYCODE_b = 98, + KEYCODE_c = 99, + KEYCODE_d = 100, + KEYCODE_e = 101, + KEYCODE_f = 102, + KEYCODE_g = 103, + KEYCODE_h = 104, + KEYCODE_i = 105, + KEYCODE_j = 106, + KEYCODE_k = 107, + KEYCODE_l = 108, + KEYCODE_m = 109, + KEYCODE_n = 110, + KEYCODE_o = 111, + KEYCODE_p = 112, + KEYCODE_q = 113, + KEYCODE_r = 114, + KEYCODE_s = 115, + KEYCODE_t = 116, + KEYCODE_u = 117, + KEYCODE_v = 118, + KEYCODE_w = 119, + KEYCODE_x = 120, + KEYCODE_y = 121, + KEYCODE_z = 122, + KEYCODE_DELETE = 127, + + // Numeric keypad + KEYCODE_KP0 = 256, + KEYCODE_KP1 = 257, + KEYCODE_KP2 = 258, + KEYCODE_KP3 = 259, + KEYCODE_KP4 = 260, + KEYCODE_KP5 = 261, + KEYCODE_KP6 = 262, + KEYCODE_KP7 = 263, + KEYCODE_KP8 = 264, + KEYCODE_KP9 = 265, + KEYCODE_KP_PERIOD = 266, + KEYCODE_KP_DIVIDE = 267, + KEYCODE_KP_MULTIPLY = 268, + KEYCODE_KP_MINUS = 269, + KEYCODE_KP_PLUS = 270, + KEYCODE_KP_ENTER = 271, + KEYCODE_KP_EQUALS = 272, + + // Arrows + Home/End pad + KEYCODE_UP = 273, + KEYCODE_DOWN = 274, + KEYCODE_RIGHT = 275, + KEYCODE_LEFT = 276, + KEYCODE_INSERT = 277, + KEYCODE_HOME = 278, + KEYCODE_END = 279, + KEYCODE_PAGEUP = 280, + KEYCODE_PAGEDOWN = 281, + + // Function keys + KEYCODE_F1 = 282, + KEYCODE_F2 = 283, + KEYCODE_F3 = 284, + KEYCODE_F4 = 285, + KEYCODE_F5 = 286, + KEYCODE_F6 = 287, + KEYCODE_F7 = 288, + KEYCODE_F8 = 289, + KEYCODE_F9 = 290, + KEYCODE_F10 = 291, + KEYCODE_F11 = 292, + KEYCODE_F12 = 293, + KEYCODE_F13 = 294, + KEYCODE_F14 = 295, + KEYCODE_F15 = 296, + + // Key state modifier keys + KEYCODE_NUMLOCK = 300, + KEYCODE_CAPSLOCK = 301, + KEYCODE_SCROLLOCK = 302, + KEYCODE_RSHIFT = 303, + KEYCODE_LSHIFT = 304, + KEYCODE_RCTRL = 305, + KEYCODE_LCTRL = 306, + KEYCODE_RALT = 307, + KEYCODE_LALT = 308, + KEYCODE_RMETA = 309, + KEYCODE_LMETA = 310, + KEYCODE_LSUPER = 311, // Left "Windows" key + KEYCODE_RSUPER = 312, // Right "Windows" key + KEYCODE_MODE = 313, // "Alt Gr" key + KEYCODE_COMPOSE = 314, // Multi-key compose key + + // Miscellaneous function keys + KEYCODE_HELP = 315, + KEYCODE_PRINT = 316, + KEYCODE_SYSREQ = 317, + KEYCODE_BREAK = 318, + KEYCODE_MENU = 319, + KEYCODE_POWER = 320, // Power Macintosh power key + KEYCODE_EURO = 321, // Some european keyboards + KEYCODE_UNDO = 322 // Atari keyboard has Undo +}; + /** * Keyboard modifier flags, used for Event::kbd::flags. */ @@ -125,7 +275,7 @@ struct Event { * we fix this, your best bet is to get a copy of SDL_keysym.h * and look at that, if you want to find out a key code. */ - int keycode; + KeyCode keycode; /** * ASCII-value of the pressed key (if any). * This depends on modifiers, i.e. pressing the 'A' key results in -- cgit v1.2.3 From 55f93678b8589b74922609d55774222ee7119f55 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 22 Jun 2007 17:51:51 +0000 Subject: Heavily modified/reduced version of patch #1741454 (EVENTS: ASCII enum) svn-id: r27612 --- common/events.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'common') diff --git a/common/events.h b/common/events.h index 0330f4b417..253c9f053c 100644 --- a/common/events.h +++ b/common/events.h @@ -216,6 +216,25 @@ enum KeyCode { KEYCODE_UNDO = 322 // Atari keyboard has Undo }; +/** + * List of fake 'ascii' values used in keyboard events. + * The values here are based on what certain SCUMM games require + * in their scripts. + * @todo Get rid of this, and instead enforce that engines use the + * keycode instead to handle these. + */ +enum { + ASCII_F1 = 315, + ASCII_F2 = 316, + ASCII_F3 = 317, + ASCII_F4 = 318, + ASCII_F5 = 319, + ASCII_F6 = 320, + ASCII_F7 = 321, + ASCII_F8 = 322, + ASCII_F9 = 323 +}; + /** * Keyboard modifier flags, used for Event::kbd::flags. */ -- cgit v1.2.3 From 2b23374468549722c8068d448d9bbf5e100d7301 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 22 Jun 2007 20:04:44 +0000 Subject: Converted lots of code to use Common::ASCII_* and COMMON::KEYCODE_* constants. This also revealed the evil mixing of keycodes and ascii we do in many places :-/ svn-id: r27616 --- common/events.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/events.h b/common/events.h index 253c9f053c..3580ac3144 100644 --- a/common/events.h +++ b/common/events.h @@ -232,7 +232,10 @@ enum { ASCII_F6 = 320, ASCII_F7 = 321, ASCII_F8 = 322, - ASCII_F9 = 323 + ASCII_F9 = 323, + ASCII_F10 = 324, + ASCII_F11 = 325, + ASCII_F12 = 326 }; /** @@ -300,7 +303,6 @@ struct Event { * This depends on modifiers, i.e. pressing the 'A' key results in * different values here depending on the status of shift, alt and * caps lock. - * For the function keys F1-F9, values of 315-323 are used. */ uint16 ascii; /** -- cgit v1.2.3 From 17a75e7bd3f44eacdef2d8c48afc24f73d30b83a Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 22 Jun 2007 20:30:52 +0000 Subject: Replace tabs by spaces in keycode enum, to ensure proper indention svn-id: r27618 --- common/events.h | 272 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 136 insertions(+), 136 deletions(-) (limited to 'common') diff --git a/common/events.h b/common/events.h index 3580ac3144..d52ae1f739 100644 --- a/common/events.h +++ b/common/events.h @@ -68,152 +68,152 @@ enum EventType { }; enum KeyCode { - KEYCODE_BACKSPACE = 8, - KEYCODE_TAB = 9, - KEYCODE_CLEAR = 12, - KEYCODE_RETURN = 13, - KEYCODE_PAUSE = 19, - KEYCODE_ESCAPE = 27, - KEYCODE_SPACE = 32, - KEYCODE_EXCLAIM = 33, - KEYCODE_QUOTEDBL = 34, - KEYCODE_HASH = 35, - KEYCODE_DOLLAR = 36, - KEYCODE_AMPERSAND = 38, - KEYCODE_QUOTE = 39, - KEYCODE_LEFTPAREN = 40, - KEYCODE_RIGHTPAREN = 41, - KEYCODE_ASTERISK = 42, - KEYCODE_PLUS = 43, - KEYCODE_COMMA = 44, - KEYCODE_MINUS = 45, - KEYCODE_PERIOD = 46, - KEYCODE_SLASH = 47, - KEYCODE_0 = 48, - KEYCODE_1 = 49, - KEYCODE_2 = 50, - KEYCODE_3 = 51, - KEYCODE_4 = 52, - KEYCODE_5 = 53, - KEYCODE_6 = 54, - KEYCODE_7 = 55, - KEYCODE_8 = 56, - KEYCODE_9 = 57, - KEYCODE_COLON = 58, - KEYCODE_SEMICOLON = 59, - KEYCODE_LESS = 60, - KEYCODE_EQUALS = 61, - KEYCODE_GREATER = 62, - KEYCODE_QUESTION = 63, - KEYCODE_AT = 64, + KEYCODE_BACKSPACE = 8, + KEYCODE_TAB = 9, + KEYCODE_CLEAR = 12, + KEYCODE_RETURN = 13, + KEYCODE_PAUSE = 19, + KEYCODE_ESCAPE = 27, + KEYCODE_SPACE = 32, + KEYCODE_EXCLAIM = 33, + KEYCODE_QUOTEDBL = 34, + KEYCODE_HASH = 35, + KEYCODE_DOLLAR = 36, + KEYCODE_AMPERSAND = 38, + KEYCODE_QUOTE = 39, + KEYCODE_LEFTPAREN = 40, + KEYCODE_RIGHTPAREN = 41, + KEYCODE_ASTERISK = 42, + KEYCODE_PLUS = 43, + KEYCODE_COMMA = 44, + KEYCODE_MINUS = 45, + KEYCODE_PERIOD = 46, + KEYCODE_SLASH = 47, + KEYCODE_0 = 48, + KEYCODE_1 = 49, + KEYCODE_2 = 50, + KEYCODE_3 = 51, + KEYCODE_4 = 52, + KEYCODE_5 = 53, + KEYCODE_6 = 54, + KEYCODE_7 = 55, + KEYCODE_8 = 56, + KEYCODE_9 = 57, + KEYCODE_COLON = 58, + KEYCODE_SEMICOLON = 59, + KEYCODE_LESS = 60, + KEYCODE_EQUALS = 61, + KEYCODE_GREATER = 62, + KEYCODE_QUESTION = 63, + KEYCODE_AT = 64, + + KEYCODE_LEFTBRACKET = 91, + KEYCODE_BACKSLASH = 92, + KEYCODE_RIGHTBRACKET= 93, + KEYCODE_CARET = 94, + KEYCODE_UNDERSCORE = 95, + KEYCODE_BACKQUOTE = 96, + KEYCODE_a = 97, + KEYCODE_b = 98, + KEYCODE_c = 99, + KEYCODE_d = 100, + KEYCODE_e = 101, + KEYCODE_f = 102, + KEYCODE_g = 103, + KEYCODE_h = 104, + KEYCODE_i = 105, + KEYCODE_j = 106, + KEYCODE_k = 107, + KEYCODE_l = 108, + KEYCODE_m = 109, + KEYCODE_n = 110, + KEYCODE_o = 111, + KEYCODE_p = 112, + KEYCODE_q = 113, + KEYCODE_r = 114, + KEYCODE_s = 115, + KEYCODE_t = 116, + KEYCODE_u = 117, + KEYCODE_v = 118, + KEYCODE_w = 119, + KEYCODE_x = 120, + KEYCODE_y = 121, + KEYCODE_z = 122, + KEYCODE_DELETE = 127, - KEYCODE_LEFTBRACKET = 91, - KEYCODE_BACKSLASH = 92, - KEYCODE_RIGHTBRACKET = 93, - KEYCODE_CARET = 94, - KEYCODE_UNDERSCORE = 95, - KEYCODE_BACKQUOTE = 96, - KEYCODE_a = 97, - KEYCODE_b = 98, - KEYCODE_c = 99, - KEYCODE_d = 100, - KEYCODE_e = 101, - KEYCODE_f = 102, - KEYCODE_g = 103, - KEYCODE_h = 104, - KEYCODE_i = 105, - KEYCODE_j = 106, - KEYCODE_k = 107, - KEYCODE_l = 108, - KEYCODE_m = 109, - KEYCODE_n = 110, - KEYCODE_o = 111, - KEYCODE_p = 112, - KEYCODE_q = 113, - KEYCODE_r = 114, - KEYCODE_s = 115, - KEYCODE_t = 116, - KEYCODE_u = 117, - KEYCODE_v = 118, - KEYCODE_w = 119, - KEYCODE_x = 120, - KEYCODE_y = 121, - KEYCODE_z = 122, - KEYCODE_DELETE = 127, - // Numeric keypad - KEYCODE_KP0 = 256, - KEYCODE_KP1 = 257, - KEYCODE_KP2 = 258, - KEYCODE_KP3 = 259, - KEYCODE_KP4 = 260, - KEYCODE_KP5 = 261, - KEYCODE_KP6 = 262, - KEYCODE_KP7 = 263, - KEYCODE_KP8 = 264, - KEYCODE_KP9 = 265, - KEYCODE_KP_PERIOD = 266, - KEYCODE_KP_DIVIDE = 267, - KEYCODE_KP_MULTIPLY = 268, - KEYCODE_KP_MINUS = 269, - KEYCODE_KP_PLUS = 270, - KEYCODE_KP_ENTER = 271, - KEYCODE_KP_EQUALS = 272, + KEYCODE_KP0 = 256, + KEYCODE_KP1 = 257, + KEYCODE_KP2 = 258, + KEYCODE_KP3 = 259, + KEYCODE_KP4 = 260, + KEYCODE_KP5 = 261, + KEYCODE_KP6 = 262, + KEYCODE_KP7 = 263, + KEYCODE_KP8 = 264, + KEYCODE_KP9 = 265, + KEYCODE_KP_PERIOD = 266, + KEYCODE_KP_DIVIDE = 267, + KEYCODE_KP_MULTIPLY = 268, + KEYCODE_KP_MINUS = 269, + KEYCODE_KP_PLUS = 270, + KEYCODE_KP_ENTER = 271, + KEYCODE_KP_EQUALS = 272, // Arrows + Home/End pad - KEYCODE_UP = 273, - KEYCODE_DOWN = 274, - KEYCODE_RIGHT = 275, - KEYCODE_LEFT = 276, - KEYCODE_INSERT = 277, - KEYCODE_HOME = 278, - KEYCODE_END = 279, - KEYCODE_PAGEUP = 280, - KEYCODE_PAGEDOWN = 281, + KEYCODE_UP = 273, + KEYCODE_DOWN = 274, + KEYCODE_RIGHT = 275, + KEYCODE_LEFT = 276, + KEYCODE_INSERT = 277, + KEYCODE_HOME = 278, + KEYCODE_END = 279, + KEYCODE_PAGEUP = 280, + KEYCODE_PAGEDOWN = 281, // Function keys - KEYCODE_F1 = 282, - KEYCODE_F2 = 283, - KEYCODE_F3 = 284, - KEYCODE_F4 = 285, - KEYCODE_F5 = 286, - KEYCODE_F6 = 287, - KEYCODE_F7 = 288, - KEYCODE_F8 = 289, - KEYCODE_F9 = 290, - KEYCODE_F10 = 291, - KEYCODE_F11 = 292, - KEYCODE_F12 = 293, - KEYCODE_F13 = 294, - KEYCODE_F14 = 295, - KEYCODE_F15 = 296, + KEYCODE_F1 = 282, + KEYCODE_F2 = 283, + KEYCODE_F3 = 284, + KEYCODE_F4 = 285, + KEYCODE_F5 = 286, + KEYCODE_F6 = 287, + KEYCODE_F7 = 288, + KEYCODE_F8 = 289, + KEYCODE_F9 = 290, + KEYCODE_F10 = 291, + KEYCODE_F11 = 292, + KEYCODE_F12 = 293, + KEYCODE_F13 = 294, + KEYCODE_F14 = 295, + KEYCODE_F15 = 296, // Key state modifier keys - KEYCODE_NUMLOCK = 300, - KEYCODE_CAPSLOCK = 301, - KEYCODE_SCROLLOCK = 302, - KEYCODE_RSHIFT = 303, - KEYCODE_LSHIFT = 304, - KEYCODE_RCTRL = 305, - KEYCODE_LCTRL = 306, - KEYCODE_RALT = 307, - KEYCODE_LALT = 308, - KEYCODE_RMETA = 309, - KEYCODE_LMETA = 310, - KEYCODE_LSUPER = 311, // Left "Windows" key - KEYCODE_RSUPER = 312, // Right "Windows" key - KEYCODE_MODE = 313, // "Alt Gr" key - KEYCODE_COMPOSE = 314, // Multi-key compose key + KEYCODE_NUMLOCK = 300, + KEYCODE_CAPSLOCK = 301, + KEYCODE_SCROLLOCK = 302, + KEYCODE_RSHIFT = 303, + KEYCODE_LSHIFT = 304, + KEYCODE_RCTRL = 305, + KEYCODE_LCTRL = 306, + KEYCODE_RALT = 307, + KEYCODE_LALT = 308, + KEYCODE_RMETA = 309, + KEYCODE_LMETA = 310, + KEYCODE_LSUPER = 311, // Left "Windows" key + KEYCODE_RSUPER = 312, // Right "Windows" key + KEYCODE_MODE = 313, // "Alt Gr" key + KEYCODE_COMPOSE = 314, // Multi-key compose key // Miscellaneous function keys - KEYCODE_HELP = 315, - KEYCODE_PRINT = 316, - KEYCODE_SYSREQ = 317, - KEYCODE_BREAK = 318, - KEYCODE_MENU = 319, - KEYCODE_POWER = 320, // Power Macintosh power key - KEYCODE_EURO = 321, // Some european keyboards - KEYCODE_UNDO = 322 // Atari keyboard has Undo + KEYCODE_HELP = 315, + KEYCODE_PRINT = 316, + KEYCODE_SYSREQ = 317, + KEYCODE_BREAK = 318, + KEYCODE_MENU = 319, + KEYCODE_POWER = 320, // Power Macintosh power key + KEYCODE_EURO = 321, // Some european keyboards + KEYCODE_UNDO = 322 // Atari keyboard has Undo }; /** -- cgit v1.2.3 From 8a658e01878150f0163c91f88ab0747294a740be Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 22 Jun 2007 20:33:51 +0000 Subject: Added 'ASCII_' enum values for certain standard keys, and update comment svn-id: r27619 --- common/events.h | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'common') diff --git a/common/events.h b/common/events.h index d52ae1f739..bfbe48e9e5 100644 --- a/common/events.h +++ b/common/events.h @@ -217,25 +217,31 @@ enum KeyCode { }; /** - * List of fake 'ascii' values used in keyboard events. - * The values here are based on what certain SCUMM games require - * in their scripts. - * @todo Get rid of this, and instead enforce that engines use the - * keycode instead to handle these. + * List of certan special and some fake 'ascii' values used in keyboard events. + * The values for the function keys listed here are based on what certain SCUMM + * games expect in their scripts. + * @todo Get rid of the function key values, and instead enforce that engines use + * the keycode value to handle these. */ enum { - ASCII_F1 = 315, - ASCII_F2 = 316, - ASCII_F3 = 317, - ASCII_F4 = 318, - ASCII_F5 = 319, - ASCII_F6 = 320, - ASCII_F7 = 321, - ASCII_F8 = 322, - ASCII_F9 = 323, - ASCII_F10 = 324, - ASCII_F11 = 325, - ASCII_F12 = 326 + ASCII_BACKSPACE = 8, + ASCII_TAB = 9, + ASCII_RETURN = 13, + ASCII_ESCAPE = 27, + ASCII_SPACE = 32, + + ASCII_F1 = 315, + ASCII_F2 = 316, + ASCII_F3 = 317, + ASCII_F4 = 318, + ASCII_F5 = 319, + ASCII_F6 = 320, + ASCII_F7 = 321, + ASCII_F8 = 322, + ASCII_F9 = 323, + ASCII_F10 = 324, + ASCII_F11 = 325, + ASCII_F12 = 326 }; /** -- cgit v1.2.3 From 85bf0f6d6b03097290fbcbc18357756c048f8a8f Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 22 Jun 2007 20:51:13 +0000 Subject: Added Common::KEYCODE_INALID svn-id: r27622 --- common/events.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'common') diff --git a/common/events.h b/common/events.h index bfbe48e9e5..39c7ad49e8 100644 --- a/common/events.h +++ b/common/events.h @@ -68,6 +68,8 @@ enum EventType { }; enum KeyCode { + KEYCODE_INALID = 0, + KEYCODE_BACKSPACE = 8, KEYCODE_TAB = 9, KEYCODE_CLEAR = 12, -- cgit v1.2.3 From 2fa0a5c457e0aea4edffb49aa80a04a59b6e9994 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 22 Jun 2007 21:16:07 +0000 Subject: Cleaning up after myself (I blame it on, err, uhh... the Vogons?) svn-id: r27625 --- common/events.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'common') diff --git a/common/events.h b/common/events.h index 39c7ad49e8..6eb26046ce 100644 --- a/common/events.h +++ b/common/events.h @@ -68,7 +68,7 @@ enum EventType { }; enum KeyCode { - KEYCODE_INALID = 0, + KEYCODE_INVALID = 0, KEYCODE_BACKSPACE = 8, KEYCODE_TAB = 9, -- cgit v1.2.3 From 753eee6d0c25b5b3767c4ab7e7a95488753423a7 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 22 Jun 2007 21:32:49 +0000 Subject: Promoted the struct inside Common::Event which captures the keystate to a full-blown independent struct named KeyState (makes it easier for engines to capture the full keystate, instead of only the keycode or only the ascii/unicode value) svn-id: r27626 --- common/events.h | 57 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 26 deletions(-) (limited to 'common') diff --git a/common/events.h b/common/events.h index 6eb26046ce..92a2bda647 100644 --- a/common/events.h +++ b/common/events.h @@ -255,6 +255,36 @@ enum { KBD_SHIFT = 1 << 2 }; +/** + * Keyboard status, as used in the Event struct. + */ +struct KeyState { + /** + * Abstract key code (will be the same for any given key regardless + * of modifiers being held at the same time. + * For example, this is the same for both 'A' and Shift-'A'. + * @todo Document which values are to be used for non-ASCII keys + * like F1-F10. For now, let's just say that our primary backend + * is the SDL one, and it uses the values SDL uses... so until + * we fix this, your best bet is to get a copy of SDL_keysym.h + * and look at that, if you want to find out a key code. + */ + KeyCode keycode; + /** + * ASCII-value of the pressed key (if any). + * This depends on modifiers, i.e. pressing the 'A' key results in + * different values here depending on the status of shift, alt and + * caps lock. + */ + uint16 ascii; + /** + * Status of the modifier keys. Bits are set in this for each + * pressed modifier + * @see KBD_CTRL, KBD_ALT, KBD_SHIFT + */ + byte flags; +}; + /** * Data structure for an event. A pointer to an instance of Event * can be passed to pollEvent. @@ -294,32 +324,7 @@ struct Event { * Keyboard data; only valid for keyboard events (EVENT_KEYDOWN and * EVENT_KEYUP). For all other event types, content is undefined. */ - struct { - /** - * Abstract key code (will be the same for any given key regardless - * of modifiers being held at the same time. - * For example, this is the same for both 'A' and Shift-'A'. - * @todo Document which values are to be used for non-ASCII keys - * like F1-F10. For now, let's just say that our primary backend - * is the SDL one, and it uses the values SDL uses... so until - * we fix this, your best bet is to get a copy of SDL_keysym.h - * and look at that, if you want to find out a key code. - */ - KeyCode keycode; - /** - * ASCII-value of the pressed key (if any). - * This depends on modifiers, i.e. pressing the 'A' key results in - * different values here depending on the status of shift, alt and - * caps lock. - */ - uint16 ascii; - /** - * Status of the modifier keys. Bits are set in this for each - * pressed modifier - * @see KBD_CTRL, KBD_ALT, KBD_SHIFT - */ - byte flags; - } kbd; + KeyState kbd; /** * The mouse coordinates, in virtual screen coordinates. Only valid * for mouse events. -- cgit v1.2.3 From c690cad67f91fea90be949e29b2d218952c79859 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 22 Jun 2007 22:18:15 +0000 Subject: Added constructor & reset() method to Common::KeyState svn-id: r27634 --- common/events.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'common') diff --git a/common/events.h b/common/events.h index 92a2bda647..3263b7ab22 100644 --- a/common/events.h +++ b/common/events.h @@ -283,6 +283,12 @@ struct KeyState { * @see KBD_CTRL, KBD_ALT, KBD_SHIFT */ byte flags; + + KeyState() { reset(); } + void reset() { + keycode = KEYCODE_INVALID; + ascii = flags = 0; + } }; /** -- cgit v1.2.3 From e7a58d9369af9a416898866465edfcdae3abeae7 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 22 Jun 2007 23:20:50 +0000 Subject: Moved keyboard stuff to a separate header file svn-id: r27640 --- common/events.h | 225 +---------------------------------------------- common/keyboard.h | 259 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 260 insertions(+), 224 deletions(-) create mode 100644 common/keyboard.h (limited to 'common') diff --git a/common/events.h b/common/events.h index 3263b7ab22..d5e578a9ce 100644 --- a/common/events.h +++ b/common/events.h @@ -26,6 +26,7 @@ #ifndef COMMON_EVENTS_H #define COMMON_EVENTS_H +#include "common/keyboard.h" #include "common/rect.h" #include "common/system.h" #include "common/noncopyable.h" @@ -67,230 +68,6 @@ enum EventType { EVENT_PREDICTIVE_DIALOG = 12 }; -enum KeyCode { - KEYCODE_INVALID = 0, - - KEYCODE_BACKSPACE = 8, - KEYCODE_TAB = 9, - KEYCODE_CLEAR = 12, - KEYCODE_RETURN = 13, - KEYCODE_PAUSE = 19, - KEYCODE_ESCAPE = 27, - KEYCODE_SPACE = 32, - KEYCODE_EXCLAIM = 33, - KEYCODE_QUOTEDBL = 34, - KEYCODE_HASH = 35, - KEYCODE_DOLLAR = 36, - KEYCODE_AMPERSAND = 38, - KEYCODE_QUOTE = 39, - KEYCODE_LEFTPAREN = 40, - KEYCODE_RIGHTPAREN = 41, - KEYCODE_ASTERISK = 42, - KEYCODE_PLUS = 43, - KEYCODE_COMMA = 44, - KEYCODE_MINUS = 45, - KEYCODE_PERIOD = 46, - KEYCODE_SLASH = 47, - KEYCODE_0 = 48, - KEYCODE_1 = 49, - KEYCODE_2 = 50, - KEYCODE_3 = 51, - KEYCODE_4 = 52, - KEYCODE_5 = 53, - KEYCODE_6 = 54, - KEYCODE_7 = 55, - KEYCODE_8 = 56, - KEYCODE_9 = 57, - KEYCODE_COLON = 58, - KEYCODE_SEMICOLON = 59, - KEYCODE_LESS = 60, - KEYCODE_EQUALS = 61, - KEYCODE_GREATER = 62, - KEYCODE_QUESTION = 63, - KEYCODE_AT = 64, - - KEYCODE_LEFTBRACKET = 91, - KEYCODE_BACKSLASH = 92, - KEYCODE_RIGHTBRACKET= 93, - KEYCODE_CARET = 94, - KEYCODE_UNDERSCORE = 95, - KEYCODE_BACKQUOTE = 96, - KEYCODE_a = 97, - KEYCODE_b = 98, - KEYCODE_c = 99, - KEYCODE_d = 100, - KEYCODE_e = 101, - KEYCODE_f = 102, - KEYCODE_g = 103, - KEYCODE_h = 104, - KEYCODE_i = 105, - KEYCODE_j = 106, - KEYCODE_k = 107, - KEYCODE_l = 108, - KEYCODE_m = 109, - KEYCODE_n = 110, - KEYCODE_o = 111, - KEYCODE_p = 112, - KEYCODE_q = 113, - KEYCODE_r = 114, - KEYCODE_s = 115, - KEYCODE_t = 116, - KEYCODE_u = 117, - KEYCODE_v = 118, - KEYCODE_w = 119, - KEYCODE_x = 120, - KEYCODE_y = 121, - KEYCODE_z = 122, - KEYCODE_DELETE = 127, - - // Numeric keypad - KEYCODE_KP0 = 256, - KEYCODE_KP1 = 257, - KEYCODE_KP2 = 258, - KEYCODE_KP3 = 259, - KEYCODE_KP4 = 260, - KEYCODE_KP5 = 261, - KEYCODE_KP6 = 262, - KEYCODE_KP7 = 263, - KEYCODE_KP8 = 264, - KEYCODE_KP9 = 265, - KEYCODE_KP_PERIOD = 266, - KEYCODE_KP_DIVIDE = 267, - KEYCODE_KP_MULTIPLY = 268, - KEYCODE_KP_MINUS = 269, - KEYCODE_KP_PLUS = 270, - KEYCODE_KP_ENTER = 271, - KEYCODE_KP_EQUALS = 272, - - // Arrows + Home/End pad - KEYCODE_UP = 273, - KEYCODE_DOWN = 274, - KEYCODE_RIGHT = 275, - KEYCODE_LEFT = 276, - KEYCODE_INSERT = 277, - KEYCODE_HOME = 278, - KEYCODE_END = 279, - KEYCODE_PAGEUP = 280, - KEYCODE_PAGEDOWN = 281, - - // Function keys - KEYCODE_F1 = 282, - KEYCODE_F2 = 283, - KEYCODE_F3 = 284, - KEYCODE_F4 = 285, - KEYCODE_F5 = 286, - KEYCODE_F6 = 287, - KEYCODE_F7 = 288, - KEYCODE_F8 = 289, - KEYCODE_F9 = 290, - KEYCODE_F10 = 291, - KEYCODE_F11 = 292, - KEYCODE_F12 = 293, - KEYCODE_F13 = 294, - KEYCODE_F14 = 295, - KEYCODE_F15 = 296, - - // Key state modifier keys - KEYCODE_NUMLOCK = 300, - KEYCODE_CAPSLOCK = 301, - KEYCODE_SCROLLOCK = 302, - KEYCODE_RSHIFT = 303, - KEYCODE_LSHIFT = 304, - KEYCODE_RCTRL = 305, - KEYCODE_LCTRL = 306, - KEYCODE_RALT = 307, - KEYCODE_LALT = 308, - KEYCODE_RMETA = 309, - KEYCODE_LMETA = 310, - KEYCODE_LSUPER = 311, // Left "Windows" key - KEYCODE_RSUPER = 312, // Right "Windows" key - KEYCODE_MODE = 313, // "Alt Gr" key - KEYCODE_COMPOSE = 314, // Multi-key compose key - - // Miscellaneous function keys - KEYCODE_HELP = 315, - KEYCODE_PRINT = 316, - KEYCODE_SYSREQ = 317, - KEYCODE_BREAK = 318, - KEYCODE_MENU = 319, - KEYCODE_POWER = 320, // Power Macintosh power key - KEYCODE_EURO = 321, // Some european keyboards - KEYCODE_UNDO = 322 // Atari keyboard has Undo -}; - -/** - * List of certan special and some fake 'ascii' values used in keyboard events. - * The values for the function keys listed here are based on what certain SCUMM - * games expect in their scripts. - * @todo Get rid of the function key values, and instead enforce that engines use - * the keycode value to handle these. - */ -enum { - ASCII_BACKSPACE = 8, - ASCII_TAB = 9, - ASCII_RETURN = 13, - ASCII_ESCAPE = 27, - ASCII_SPACE = 32, - - ASCII_F1 = 315, - ASCII_F2 = 316, - ASCII_F3 = 317, - ASCII_F4 = 318, - ASCII_F5 = 319, - ASCII_F6 = 320, - ASCII_F7 = 321, - ASCII_F8 = 322, - ASCII_F9 = 323, - ASCII_F10 = 324, - ASCII_F11 = 325, - ASCII_F12 = 326 -}; - -/** - * Keyboard modifier flags, used for Event::kbd::flags. - */ -enum { - KBD_CTRL = 1 << 0, - KBD_ALT = 1 << 1, - KBD_SHIFT = 1 << 2 -}; - -/** - * Keyboard status, as used in the Event struct. - */ -struct KeyState { - /** - * Abstract key code (will be the same for any given key regardless - * of modifiers being held at the same time. - * For example, this is the same for both 'A' and Shift-'A'. - * @todo Document which values are to be used for non-ASCII keys - * like F1-F10. For now, let's just say that our primary backend - * is the SDL one, and it uses the values SDL uses... so until - * we fix this, your best bet is to get a copy of SDL_keysym.h - * and look at that, if you want to find out a key code. - */ - KeyCode keycode; - /** - * ASCII-value of the pressed key (if any). - * This depends on modifiers, i.e. pressing the 'A' key results in - * different values here depending on the status of shift, alt and - * caps lock. - */ - uint16 ascii; - /** - * Status of the modifier keys. Bits are set in this for each - * pressed modifier - * @see KBD_CTRL, KBD_ALT, KBD_SHIFT - */ - byte flags; - - KeyState() { reset(); } - void reset() { - keycode = KEYCODE_INVALID; - ascii = flags = 0; - } -}; - /** * Data structure for an event. A pointer to an instance of Event * can be passed to pollEvent. diff --git a/common/keyboard.h b/common/keyboard.h new file mode 100644 index 0000000000..f526b8cb8e --- /dev/null +++ b/common/keyboard.h @@ -0,0 +1,259 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * $URL$ + * $Id$ + * + */ + +#ifndef COMMON_KEYBOARD_H +#define COMMON_KEYBOARD_H + +#include "common/scummsys.h" + +namespace Common { + +enum KeyCode { + KEYCODE_INVALID = 0, + + KEYCODE_BACKSPACE = 8, + KEYCODE_TAB = 9, + KEYCODE_CLEAR = 12, + KEYCODE_RETURN = 13, + KEYCODE_PAUSE = 19, + KEYCODE_ESCAPE = 27, + KEYCODE_SPACE = 32, + KEYCODE_EXCLAIM = 33, + KEYCODE_QUOTEDBL = 34, + KEYCODE_HASH = 35, + KEYCODE_DOLLAR = 36, + KEYCODE_AMPERSAND = 38, + KEYCODE_QUOTE = 39, + KEYCODE_LEFTPAREN = 40, + KEYCODE_RIGHTPAREN = 41, + KEYCODE_ASTERISK = 42, + KEYCODE_PLUS = 43, + KEYCODE_COMMA = 44, + KEYCODE_MINUS = 45, + KEYCODE_PERIOD = 46, + KEYCODE_SLASH = 47, + KEYCODE_0 = 48, + KEYCODE_1 = 49, + KEYCODE_2 = 50, + KEYCODE_3 = 51, + KEYCODE_4 = 52, + KEYCODE_5 = 53, + KEYCODE_6 = 54, + KEYCODE_7 = 55, + KEYCODE_8 = 56, + KEYCODE_9 = 57, + KEYCODE_COLON = 58, + KEYCODE_SEMICOLON = 59, + KEYCODE_LESS = 60, + KEYCODE_EQUALS = 61, + KEYCODE_GREATER = 62, + KEYCODE_QUESTION = 63, + KEYCODE_AT = 64, + + KEYCODE_LEFTBRACKET = 91, + KEYCODE_BACKSLASH = 92, + KEYCODE_RIGHTBRACKET= 93, + KEYCODE_CARET = 94, + KEYCODE_UNDERSCORE = 95, + KEYCODE_BACKQUOTE = 96, + KEYCODE_a = 97, + KEYCODE_b = 98, + KEYCODE_c = 99, + KEYCODE_d = 100, + KEYCODE_e = 101, + KEYCODE_f = 102, + KEYCODE_g = 103, + KEYCODE_h = 104, + KEYCODE_i = 105, + KEYCODE_j = 106, + KEYCODE_k = 107, + KEYCODE_l = 108, + KEYCODE_m = 109, + KEYCODE_n = 110, + KEYCODE_o = 111, + KEYCODE_p = 112, + KEYCODE_q = 113, + KEYCODE_r = 114, + KEYCODE_s = 115, + KEYCODE_t = 116, + KEYCODE_u = 117, + KEYCODE_v = 118, + KEYCODE_w = 119, + KEYCODE_x = 120, + KEYCODE_y = 121, + KEYCODE_z = 122, + KEYCODE_DELETE = 127, + + // Numeric keypad + KEYCODE_KP0 = 256, + KEYCODE_KP1 = 257, + KEYCODE_KP2 = 258, + KEYCODE_KP3 = 259, + KEYCODE_KP4 = 260, + KEYCODE_KP5 = 261, + KEYCODE_KP6 = 262, + KEYCODE_KP7 = 263, + KEYCODE_KP8 = 264, + KEYCODE_KP9 = 265, + KEYCODE_KP_PERIOD = 266, + KEYCODE_KP_DIVIDE = 267, + KEYCODE_KP_MULTIPLY = 268, + KEYCODE_KP_MINUS = 269, + KEYCODE_KP_PLUS = 270, + KEYCODE_KP_ENTER = 271, + KEYCODE_KP_EQUALS = 272, + + // Arrows + Home/End pad + KEYCODE_UP = 273, + KEYCODE_DOWN = 274, + KEYCODE_RIGHT = 275, + KEYCODE_LEFT = 276, + KEYCODE_INSERT = 277, + KEYCODE_HOME = 278, + KEYCODE_END = 279, + KEYCODE_PAGEUP = 280, + KEYCODE_PAGEDOWN = 281, + + // Function keys + KEYCODE_F1 = 282, + KEYCODE_F2 = 283, + KEYCODE_F3 = 284, + KEYCODE_F4 = 285, + KEYCODE_F5 = 286, + KEYCODE_F6 = 287, + KEYCODE_F7 = 288, + KEYCODE_F8 = 289, + KEYCODE_F9 = 290, + KEYCODE_F10 = 291, + KEYCODE_F11 = 292, + KEYCODE_F12 = 293, + KEYCODE_F13 = 294, + KEYCODE_F14 = 295, + KEYCODE_F15 = 296, + + // Key state modifier keys + KEYCODE_NUMLOCK = 300, + KEYCODE_CAPSLOCK = 301, + KEYCODE_SCROLLOCK = 302, + KEYCODE_RSHIFT = 303, + KEYCODE_LSHIFT = 304, + KEYCODE_RCTRL = 305, + KEYCODE_LCTRL = 306, + KEYCODE_RALT = 307, + KEYCODE_LALT = 308, + KEYCODE_RMETA = 309, + KEYCODE_LMETA = 310, + KEYCODE_LSUPER = 311, // Left "Windows" key + KEYCODE_RSUPER = 312, // Right "Windows" key + KEYCODE_MODE = 313, // "Alt Gr" key + KEYCODE_COMPOSE = 314, // Multi-key compose key + + // Miscellaneous function keys + KEYCODE_HELP = 315, + KEYCODE_PRINT = 316, + KEYCODE_SYSREQ = 317, + KEYCODE_BREAK = 318, + KEYCODE_MENU = 319, + KEYCODE_POWER = 320, // Power Macintosh power key + KEYCODE_EURO = 321, // Some european keyboards + KEYCODE_UNDO = 322 // Atari keyboard has Undo +}; + +/** + * List of certan special and some fake 'ascii' values used in keyboard events. + * The values for the function keys listed here are based on what certain SCUMM + * games expect in their scripts. + * @todo Get rid of the function key values, and instead enforce that engines use + * the keycode value to handle these. + */ +enum { + ASCII_BACKSPACE = 8, + ASCII_TAB = 9, + ASCII_RETURN = 13, + ASCII_ESCAPE = 27, + ASCII_SPACE = 32, + + ASCII_F1 = 315, + ASCII_F2 = 316, + ASCII_F3 = 317, + ASCII_F4 = 318, + ASCII_F5 = 319, + ASCII_F6 = 320, + ASCII_F7 = 321, + ASCII_F8 = 322, + ASCII_F9 = 323, + ASCII_F10 = 324, + ASCII_F11 = 325, + ASCII_F12 = 326 +}; + +/** + * Keyboard modifier flags, used for Event::kbd::flags. + */ +enum { + KBD_CTRL = 1 << 0, + KBD_ALT = 1 << 1, + KBD_SHIFT = 1 << 2 +}; + +/** + * Keyboard status, as used in the Event struct. + */ +struct KeyState { + /** + * Abstract key code (will be the same for any given key regardless + * of modifiers being held at the same time. + * For example, this is the same for both 'A' and Shift-'A'. + * @todo Document which values are to be used for non-ASCII keys + * like F1-F10. For now, let's just say that our primary backend + * is the SDL one, and it uses the values SDL uses... so until + * we fix this, your best bet is to get a copy of SDL_keysym.h + * and look at that, if you want to find out a key code. + */ + KeyCode keycode; + /** + * ASCII-value of the pressed key (if any). + * This depends on modifiers, i.e. pressing the 'A' key results in + * different values here depending on the status of shift, alt and + * caps lock. + */ + uint16 ascii; + /** + * Status of the modifier keys. Bits are set in this for each + * pressed modifier + * @see KBD_CTRL, KBD_ALT, KBD_SHIFT + */ + byte flags; + + KeyState() { reset(); } + void reset() { + keycode = KEYCODE_INVALID; + ascii = flags = 0; + } +}; + +} // End of namespace Common + +#endif -- cgit v1.2.3 From d9718b068446add78e62c92f104e1ad6243d19ef Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 22 Jun 2007 23:27:32 +0000 Subject: Do not use SCUMMVM_USE_LONG_INT on _MSC_VER anymore (if it *is* needed after all, speak up -- that FIXME has been in there for far too long, however) svn-id: r27641 --- common/scummsys.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'common') diff --git a/common/scummsys.h b/common/scummsys.h index e4f52295fb..4cb8d5d8e9 100644 --- a/common/scummsys.h +++ b/common/scummsys.h @@ -142,11 +142,6 @@ #define SCUMM_LITTLE_ENDIAN - // FIXME: Do you really need to use 'long' on this port? Please replace - // this comment with a new comment that states so, and ideally also - // explains the reasons briefly. - #define SCUMMVM_USE_LONG_INT - #define FORCEINLINE __forceinline #define NORETURN _declspec(noreturn) #define PLUGIN_EXPORT __declspec(dllexport) @@ -240,11 +235,6 @@ #define SCUMM_BIG_ENDIAN #define SCUMM_NEED_ALIGNMENT - // FIXME: Do you really need to use 'long' on this port? Please replace - // this comment with a new comment that states so, and ideally also - // explains the reasons briefly. - #define SCUMMVM_USE_LONG_INT - #elif defined(__DC__) #define scumm_stricmp strcasecmp -- cgit v1.2.3 From 2bbe67afdf4d4df36fc100690cf87c8a75d5a354 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 23 Jun 2007 10:06:39 +0000 Subject: Added more flexible KeyState constructor; updated comment in gui/Key.h svn-id: r27654 --- common/keyboard.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'common') diff --git a/common/keyboard.h b/common/keyboard.h index f526b8cb8e..d0d0e43f00 100644 --- a/common/keyboard.h +++ b/common/keyboard.h @@ -233,6 +233,7 @@ struct KeyState { * and look at that, if you want to find out a key code. */ KeyCode keycode; + /** * ASCII-value of the pressed key (if any). * This depends on modifiers, i.e. pressing the 'A' key results in @@ -240,6 +241,7 @@ struct KeyState { * caps lock. */ uint16 ascii; + /** * Status of the modifier keys. Bits are set in this for each * pressed modifier @@ -247,7 +249,12 @@ struct KeyState { */ byte flags; - KeyState() { reset(); } + KeyState(KeyCode kc = KEYCODE_INVALID, uint16 asc = 0, byte f = 0) { + keycode = kc; + ascii = asc ? asc : (uint16)kc; + flags = f; + } + void reset() { keycode = KEYCODE_INVALID; ascii = flags = 0; -- cgit v1.2.3