Exemplo n.º 1
0
void GeekBind::unbind(const char *keybind)
{
    std::vector<KeyBind>::iterator it;
    KeyBind b;
    b.set(keybind);
    for (it = binds.begin();
         it != binds.end(); it++)
    {
        if (b.len != it->len)
            continue;
        bool eq = true;
        for (int i = 0; i < b.len; i++)
        {
            if (b.mod[i] != it->mod[i])
            {
                eq = false;
                break;
            }
            if (b.c[i] != it->c[i])
            {
                eq = false;
                break;
            }
        }
        if (eq)
        {
            binds.erase(it);
            break;
        }
    }
    return;
}
Exemplo n.º 2
0
std::string GeekBind::getParams(std::string keybind)
{
    std::vector<KeyBind>::iterator it;
    KeyBind k;
    k.set(keybind.c_str());
    std::string str = k.keyToStr();
    for (it = binds.begin();
         it != binds.end(); it++)
    {
        if (str == it->keyToStr())
            return it->params;
    }
    return "";
}
Exemplo n.º 3
0
bool GeekBind::bind(const char *keybind, std::string funName, bool arch)
{
    KeyBind k;
    if (!k.set(keybind))
        return false;
    k.gcFunName = funName;

    // get first param of params of keybind
    string::size_type startpos = 0, endpos;
    if (!k.params.empty())
    {
        if (k.params[0] == '#')
            startpos = k.params.find_first_not_of('#');
        if (startpos != string::npos)
            endpos = k.params.find_first_of('#', startpos);
        k.firstParam = string(k.params, startpos, endpos - 1);
    }
    k.archive = arch;

    unbind(keybind);
    binds.push_back(k);
    needSort = true;
    return true;
}
Exemplo n.º 4
0
GeekBind::BindStatus GeekBind::isBinded(string &key)
{
    KeyBind k;
    k.set(key.c_str());
    return isBinded(k);
}