X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Finput%2Fkeys.cpp;h=062b9be8e6b74ef9887901ba2859c45aba0ed9db;hb=ad98112ecfb8898cff23e7a4c8dbd919135d7ae2;hp=d7de3b1b326ae007168a4ca324edda30d66356f3;hpb=7a4a508629d370c4a79791c7e62fd6f59e8564e9;p=libs%2Fgui.git diff --git a/source/input/keys.cpp b/source/input/keys.cpp index d7de3b1..062b9be 100644 --- a/source/input/keys.cpp +++ b/source/input/keys.cpp @@ -1,12 +1,15 @@ /* $Id$ This file is part of libmspgbase -Copyright © 2007 Mikko Rasa, Mikkosoft Productions +Copyright © 2008, 2010 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ #include -#ifndef WIN32 +#ifdef WIN32 +#include +#else +#include #include #endif #include @@ -101,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 { @@ -129,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