X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fkeys.cpp;h=062b9be8e6b74ef9887901ba2859c45aba0ed9db;hb=ad98112ecfb8898cff23e7a4c8dbd919135d7ae2;hp=4446a7f731568fe828d1b823bc93bf56bd00e675;hpb=9164e74de9dc17c74ee9f3cea21c4d247a3835d9;p=libs%2Fgui.git diff --git a/source/input/keys.cpp b/source/input/keys.cpp index 4446a7f..062b9be 100644 --- a/source/input/keys.cpp +++ b/source/input/keys.cpp @@ -1,7 +1,7 @@ /* $Id$ This file is part of libmspgbase -Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Copyright © 2008, 2010 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ @@ -9,6 +9,7 @@ Distributed under the LGPL #ifdef WIN32 #include #else +#include #include #endif #include @@ -103,6 +104,15 @@ unsigned keymap[Msp::Input::N_KEYS_]= #endif }; +unsigned modmap[Msp::Input::N_MODS_]= +{ +#ifndef WIN32 + ShiftMask, ControlMask, Mod1Mask, Mod4Mask +#else + 1, 2, 4, 8 +#endif +}; + } namespace Msp { @@ -131,10 +141,19 @@ unsigned key_from_sys(unsigned code) unsigned key_to_sys(unsigned key) { - if(key>N_KEYS_) + if(key>=N_KEYS_) throw InvalidParameterValue("Key out of range"); return keymap[key]; } +unsigned mod_from_sys(unsigned mod) +{ + unsigned result = 0; + for(unsigned i=0; i