X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Finput%2Fkeys.cpp;h=082e02299b9c829f4458024147d8fe3d16b0f099;hb=dce7552c5e2f64fcf5f58b0c934bb4a01f6cbcf7;hp=d7de3b1b326ae007168a4ca324edda30d66356f3;hpb=7a4a508629d370c4a79791c7e62fd6f59e8564e9;p=libs%2Fgui.git diff --git a/source/input/keys.cpp b/source/input/keys.cpp index d7de3b1..082e022 100644 --- a/source/input/keys.cpp +++ b/source/input/keys.cpp @@ -1,12 +1,8 @@ -/* $Id$ - -This file is part of libmspgbase -Copyright © 2007 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include -#ifndef WIN32 +#ifdef WIN32 +#include +#else +#include #include #endif #include @@ -101,6 +97,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 { @@ -108,19 +113,19 @@ namespace Input { unsigned key_from_sys(unsigned code) { - static bool init_done=false; + static bool init_done = false; static map reverse_map; if(!init_done) { for(unsigned i=0; i::const_iterator i=reverse_map.find(code); + map::const_iterator i = reverse_map.find(code); if(i!=reverse_map.end()) return i->second; @@ -129,10 +134,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