]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/keys.cpp
Remove modifier constants
[libs/gui.git] / source / input / keys.cpp
index 15f729abe16652ea0f5304e540e9d39333791f76..38d94807b03fcc0d982f641a433f8aa98e4ae513 100644 (file)
@@ -1,18 +1,11 @@
-/* $Id$
-
-This file is part of libmspgbase
-Copyright © 2008, 2010 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
 #include <map>
+#include <stdexcept>
 #ifdef WIN32
 #include <windows.h>
 #else
 #include <X11/X.h>
 #include <X11/keysym.h>
 #endif
-#include <msp/core/except.h>
 #include "keys.h"
 
 using namespace std;
@@ -104,15 +97,6 @@ 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 {
@@ -120,19 +104,19 @@ namespace Input {
 
 unsigned key_from_sys(unsigned code)
 {
-       static bool init_done=false;
+       static bool init_done = false;
        static map<unsigned, unsigned> reverse_map;
 
        if(!init_done)
        {
                for(unsigned i=0; i<N_KEYS_; ++i)
                        if(keymap[i])
-                               reverse_map[keymap[i]]=i;
+                               reverse_map[keymap[i]] = i;
 
-               init_done=true;
+               init_done = true;
        }
 
-       map<unsigned, unsigned>::const_iterator i=reverse_map.find(code);
+       map<unsigned, unsigned>::const_iterator i = reverse_map.find(code);
        if(i!=reverse_map.end())
                return i->second;
 
@@ -142,18 +126,9 @@ unsigned key_from_sys(unsigned code)
 unsigned key_to_sys(unsigned key)
 {
        if(key>=N_KEYS_)
-               throw InvalidParameterValue("Key out of range");
+               throw invalid_argument("key_to_sys");
        return keymap[key];
 }
 
-unsigned mod_from_sys(unsigned mod)
-{
-       unsigned result;
-       for(unsigned i=0; i<N_MODS_; ++i)
-               if(mod&modmap[i])
-                       result|=1<<i;
-       return result;
-}
-
 } // namespace Input
 } // namespace Msp