aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorJordi Vilalta Prat2010-12-01 12:23:37 +0000
committerJordi Vilalta Prat2010-12-01 12:23:37 +0000
commit0fc6a9bb4568c10e35019cd0928f641202808ed2 (patch)
tree8b311112ff545f88475d3870d723e901c3c9f86a /backends
parente2282e48163030f7c910ccb88921a7d5b9fe4748 (diff)
downloadscummvm-rg350-0fc6a9bb4568c10e35019cd0928f641202808ed2.tar.gz
scummvm-rg350-0fc6a9bb4568c10e35019cd0928f641202808ed2.tar.bz2
scummvm-rg350-0fc6a9bb4568c10e35019cd0928f641202808ed2.zip
WII: Add system language auto-detection.
svn-id: r54697
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/wii/osystem.cpp81
-rw-r--r--backends/platform/wii/osystem.h5
2 files changed, 82 insertions, 4 deletions
diff --git a/backends/platform/wii/osystem.cpp b/backends/platform/wii/osystem.cpp
index c3f350440f..950afbb3ba 100644
--- a/backends/platform/wii/osystem.cpp
+++ b/backends/platform/wii/osystem.cpp
@@ -21,6 +21,7 @@
#include <unistd.h>
+#include <ogc/conf.h>
#include <ogc/mutex.h>
#include <ogc/lwp_watchdog.h>
@@ -218,21 +219,21 @@ OSystem::MutexRef OSystem_Wii::createMutex() {
}
void OSystem_Wii::lockMutex(MutexRef mutex) {
- s32 res = LWP_MutexLock(*(mutex_t *) mutex);
+ s32 res = LWP_MutexLock(*(mutex_t *)mutex);
if (res)
printf("ERROR locking mutex %p (%d)\n", mutex, res);
}
void OSystem_Wii::unlockMutex(MutexRef mutex) {
- s32 res = LWP_MutexUnlock(*(mutex_t *) mutex);
+ s32 res = LWP_MutexUnlock(*(mutex_t *)mutex);
if (res)
printf("ERROR unlocking mutex %p (%d)\n", mutex, res);
}
void OSystem_Wii::deleteMutex(MutexRef mutex) {
- s32 res = LWP_MutexDestroy(*(mutex_t *) mutex);
+ s32 res = LWP_MutexDestroy(*(mutex_t *)mutex);
if (res)
printf("ERROR destroying mutex %p (%d)\n", mutex, res);
@@ -290,3 +291,77 @@ void OSystem_Wii::showOptionsDialog() {
_padAcceleration = 9 - ConfMan.getInt("wii_pad_acceleration");
}
+#ifndef GAMECUBE
+Common::String OSystem_Wii::getSystemLanguage() const {
+ const char *wiiCountries[] = {
+ "JP", // CONF_AREA_JPN Japan
+ "US", // CONF_AREA_USA United States of America
+ "", // CONF_AREA_EUR Europe?
+ "AU", // CONF_AREA_AUS Australia, Commonwealth of
+ "BR", // CONF_AREA_BRA Brazil, Federative Republic of
+ "TW", // CONF_AREA_TWN Taiwan, Province of China
+ "", // CONF_AREA_ROC Republic of China (Taiwan)
+ "KR", // CONF_AREA_KOR Korea, Republic of
+ "HK", // CONF_AREA_HKG Hong Kong, Special Administrative Region of China
+ "", // CONF_AREA_ASI Asia?
+ "", // CONF_AREA_LTN Lithuania?
+ "", // CONF_AREA_SAF South-Africa?
+ "CN" // CONF_AREA_CHN China, People's Republic of
+ };
+
+ // Start by detecting the country, since we can deduce some languages not
+ // supported on the Wii from it.
+ Common::String country;
+ // TODO: Can we get more fine-grained country setting?
+ int32 areaID = CONF_GetArea();
+ if ((areaID >= CONF_AREA_JPN) && (areaID <= CONF_AREA_CHN) {
+ // It's a known area.
+ if (areaID == CONF_AREA_BRA) {
+ // Portuguese isn't available on the Wii, but we know it's the
+ // official language in Brazil, so we handle it separately.
+ return "pt_BR";
+ } else {
+ // Let's use our manual area to country mapping.
+ country = wiiCountries[areaID];
+ }
+ } else {
+ // This will only happen when new areas are added to the API.
+ warning("WII: Unknown system area: %d", areaID);
+ }
+
+
+ const char *wiiLanguages[] = {
+ "ja", // CONF_LANG_JAPANESE Japanese
+ "en", // CONF_LANG_ENGLISH English
+ "de", // CONF_LANG_GERMAN German
+ "fr", // CONF_LANG_FRENCH French
+ "es", // CONF_LANG_SPANISH Spanish
+ "it", // CONF_LANG_ITALIAN Italian
+ "nl", // CONF_LANG_DUTCH Dutch
+ "zh-Hans", // CONF_LANG_SIMP_CHINESE Simplified Chinese
+ "zh-Hant", // CONF_LANG_TRAD_CHINESE Traditional Chinese
+ "ko" // CONF_LANG_KOREAN Korean
+ };
+
+ // Now let's read the system language.
+ Common::String lang;
+ int32 langID = CONF_GetLanguage();
+ if ((langID >= CONF_LANG_JAPANESE) && (langID <= CONF_LANG_KOREAN)) {
+ // It's a known language, let's use our manual language mapping.
+ lang = wiiLanguages[langID];
+
+ if (country.empty()) {
+ // We don't know how to improve the detection,
+ // let's return the language alone.
+ return lang;
+ } else {
+ // Return the complete language_country string.
+ return lang + "_" + country;
+ }
+ } else {
+ // This will only happen when new languages are added to the API.
+ warning("WII: Unknown system language: %d", langID);
+ return "";
+ }
+}
+#endif // !GAMECUBE
diff --git a/backends/platform/wii/osystem.h b/backends/platform/wii/osystem.h
index ed33b43a81..ddfa905a77 100644
--- a/backends/platform/wii/osystem.h
+++ b/backends/platform/wii/osystem.h
@@ -213,7 +213,10 @@ public:
virtual Common::TimerManager *getTimerManager();
virtual FilesystemFactory *getFilesystemFactory();
virtual void getTimeAndDate(TimeDate &t) const;
+
+#ifndef GAMECUBE
+ virtual Common::String getSystemLanguage() const;
+#endif // GAMECUBE
};
#endif
-