// $Id: KeyCodeSetting.cc 4926 2005-12-08 21:06:36Z m9710797 $ #include "KeyCodeSetting.hh" #include "CommandException.hh" using std::string; namespace openmsx { // class KeyCodeSettingPolicy KeyCodeSettingPolicy::KeyCodeSettingPolicy(CommandController& commandController) : SettingPolicy(commandController) { } string KeyCodeSettingPolicy::toString(Keys::KeyCode key) const { return Keys::getName(key); } Keys::KeyCode KeyCodeSettingPolicy::fromString(const string& str) const { Keys::KeyCode code = Keys::getCode(str); if (code == Keys::K_NONE) { throw CommandException("Not a valid key: " + str); } return code; } std::string KeyCodeSettingPolicy::getTypeString() const { return "key"; } // class KeyCodeSetting KeyCodeSetting::KeyCodeSetting(CommandController& commandController, const string& name, const string& description, Keys::KeyCode initialValue) : SettingImpl( commandController, name, description, initialValue, Setting::SAVE) { } } // namespace openmsx