コード例 #1
0
ファイル: Hotkeys.cpp プロジェクト: malensek/3RVX
bool Hotkeys::OnArgComboChange() {
    int selectionIdx = _keyList->Selection();
    HotkeyInfo *current = &_keyInfo[selectionIdx];

    HotkeyInfo::HotkeyActions action
        = (HotkeyInfo::HotkeyActions) _action->SelectionIndex();

    switch (action) {
    case HotkeyInfo::IncreaseVolume:
    case HotkeyInfo::DecreaseVolume:
    case HotkeyInfo::SetVolume:
        current->AllocateArg(1);
        current->args[1] = std::to_wstring(_argCombo->SelectionIndex());
        break;

    case HotkeyInfo::EjectDrive:
        current->AllocateArg(0);
        /* We can place the selected string directly into the args */
        current->args[0] = _argCombo->Selection();
        break;

    case HotkeyInfo::MediaKey:
        current->AllocateArg(0);
        current->args[0]
            = HotkeyInfo::MediaKeyNames[_argCombo->SelectionIndex()];
        break;
    }

    LoadSelection(selectionIdx);
    return true;
}
コード例 #2
0
void HotkeysRegistry::UnregisterCustomHotkey(HWND windowHandle, int hotkeyId)
{
    for(size_t i = 0; i < hotkeysRegistry.size(); ++i)
    {
        HotkeyInfo hotkeyInfo = hotkeysRegistry[i];
        if(hotkeyInfo.GetHotkeyId() == hotkeyId && hotkeyInfo.GetWindowHandle() == windowHandle)
        {
            hotkeyInfo.Unregister();
            hotkeysRegistry.erase(hotkeysRegistry.begin() + i);
            break;
        }
    }
}
コード例 #3
0
ファイル: Hotkeys.cpp プロジェクト: malensek/3RVX
void Hotkeys::OnKeyListItemChange(NMLISTVIEW *lv) {
    if (lv->uChanged & LVIF_STATE) {
        if (lv->uNewState & LVIS_SELECTED) {
            int index = lv->iItem;
#if ENABLE_3RVX_LOG != 0
            HotkeyInfo *current = &_keyInfo[index];
            CLOG(L"Selecting key combination %d:", index);
            QCLOG(L"%s", current->ToString().c_str());
#endif
            LoadSelection(index);
        }
    }
}
コード例 #4
0
void KeyboardHotkeyProcessor::ProcessHotkeys(HotkeyInfo &hki) {
    /* These hotkeys *require* exactly one argument: */
    if (hki.args.size() != 1) {
        return;
    }

    switch (hki.action) {
    case HotkeyInfo::MediaKey: {
        std::wstring &arg = hki.args[0];
        unsigned short vk = mediaKeyMap[arg];
        CLOG(L"Media key: %s", arg.c_str());
        SyntheticKeyboard::SimulateKeypress(vk);
        break;
    }

    case HotkeyInfo::VirtualKey: {
        unsigned short vk = (unsigned short) hki.HexArgToInt(0);
        if (vk == 0) {
            CLOG(L"Ignoring invalid VK value");
            return;
        }
        SyntheticKeyboard::SimulateKeypress(vk);
        break;
    }
    }
}
コード例 #5
0
void HotkeysRegistry::RegisterCustomHotkey(HotkeyInfo hotkeyInfo)
{
    if(!isSuspended)
    {
        hotkeyInfo.Register();
    }
    
    hotkeysRegistry.push_back(hotkeyInfo);
}
コード例 #6
0
ファイル: Hotkeys.cpp プロジェクト: malensek/3RVX
std::wstring Hotkeys::ActionString(HotkeyInfo &selection) {
    HotkeyInfo::HotkeyActions action
        = (HotkeyInfo::HotkeyActions) selection.action;

    if (action < 0) {
        /* Selection has no action */
        return L"";
    }

    /* Set to the default string (action with no parameters) */
    std::wstring actionStr = _translator->Translate(
        HotkeyInfo::ActionNames[action]);

    if (selection.HasArgs() == false) {
        /* We're done */
        return actionStr;
    }

    if (selection.args[0] == L"") {
        /* Blank arg = no arg. */
        return actionStr;
    }

    switch ((HotkeyInfo::HotkeyActions) selection.action) {
    case HotkeyInfo::IncreaseVolume:
    case HotkeyInfo::DecreaseVolume:
    case HotkeyInfo::SetVolume:
        actionStr = _translator->TranslateAndReplace(
            VolumeActionString(selection),
            selection.args[0]);
        break;

    case HotkeyInfo::EjectDrive:
        actionStr = _translator->Replace(_ejectActionStr, selection.args[0]);
        break;

    case HotkeyInfo::MediaKey:
        actionStr = _translator->Replace(_mediaActionStr,
            _translator->Translate(selection.args[0]));
        break;

    case HotkeyInfo::VirtualKey:
        actionStr = _translator->Replace(_vkActionStr, selection.args[0]);
        break;

    case HotkeyInfo::Run:
        actionStr = _translator->Replace(_runActionStr, selection.args[0]);
        break;
    }

    return actionStr;
}
コード例 #7
0
ファイル: Hotkeys.cpp プロジェクト: malensek/3RVX
void Hotkeys::VolumeArgControlStates(HotkeyInfo &selection) {
    _argLabel->Text(_amountVolArgStr);
    _argCheck->Text(_amountVolArgStr);
    _argCheck->Checked(selection.HasArgs());
    _argEdit->Enabled(_argCheck->Checked());
    _argEdit->Width(_argEdit->EmSize() * 6);
    _argEdit->PlaceRightOf(*_argCheck);
    _argEdit->X(_action->X());
    _argCombo->Enabled(_argCheck->Checked());
    _argCombo->AddItem(_unitsVolArgStr);
    _argCombo->AddItem(_percentVolArgStr);
    _argCombo->Select(0);
    _argCombo->PlaceRightOf(*_argEdit);
    _argCombo->Width(_action->Width() - (_argCombo->X() - _action->X()));

    if (selection.HasArg(0)) {
        _argEdit->Text(selection.args[0]);
    }
    if (selection.HasArg(1)) {
        _argCombo->Select(selection.ArgToInt(1));
    }
}
コード例 #8
0
ファイル: Hotkeys.cpp プロジェクト: malensek/3RVX
bool Hotkeys::OnArgEditTextChange() {
    if (_argEdit->Enabled() == false || _argEdit->Visible() == false) {
        return FALSE;
    }

    int currentIndex = _keyList->Selection();
    HotkeyInfo *current = CurrentHotkeyInfo();
    if (current == NULL) {
        return FALSE;
    }

    switch ((HotkeyInfo::HotkeyActions) current->action) {
    case HotkeyInfo::IncreaseVolume:
    case HotkeyInfo::DecreaseVolume:
    case HotkeyInfo::SetVolume:
    case HotkeyInfo::Run:
        current->AllocateArg(0);
        current->args[0] = _argEdit->Text();
        _keyList->ItemText(currentIndex, 1, ActionString(*current));
        break;
    }

    return TRUE;
}
コード例 #9
0
ファイル: 3RVX.cpp プロジェクト: AngryLifeender/3RVX
void ProcessHotkeys(HotkeyInfo &hki) {
    switch (hki.action) {
    case HotkeyInfo::IncreaseVolume:
    case HotkeyInfo::DecreaseVolume:
    case HotkeyInfo::SetVolume:
    case HotkeyInfo::Mute:
    case HotkeyInfo::VolumeSlider:
        if (vOSD) {
            vOSD->ProcessHotkeys(hki);
        }
        break;

    case HotkeyInfo::EjectDrive:
    case HotkeyInfo::EjectLatestDrive:
        if (eOSD) {
            eOSD->ProcessHotkeys(hki);
        }
        break;

    case HotkeyInfo::MediaKey:
        MediaKeys::ProcessHotkeys(hki);
        break;

    case HotkeyInfo::Run:
        if (hki.HasArgs()) {
            ShellExecute(NULL, L"open", hki.args[0].c_str(),
                NULL, NULL, SW_SHOWNORMAL);
        }
        break;

    case HotkeyInfo::Settings:
        ShellExecute(NULL, L"open", Settings::SettingsApp().c_str(),
            NULL, NULL, SW_SHOWNORMAL);
        break;

    case HotkeyInfo::Exit:
        SendMessage(mainWnd, WM_CLOSE, NULL, NULL);
        break;
    }
}
コード例 #10
0
ファイル: Settings.cpp プロジェクト: ciel712/3RVX
std::unordered_map<int, HotkeyInfo> Settings::Hotkeys() {
    std::unordered_map<int, HotkeyInfo> keyMappings;

    if (_root == NULL) {
        return keyMappings;
    }

    tinyxml2::XMLElement *hotkeys = _root->FirstChildElement("hotkeys");
    if (hotkeys == NULL) {
        return keyMappings;
    }

    tinyxml2::XMLElement *hotkey = hotkeys->FirstChildElement("hotkey");
    for (; hotkey != NULL; hotkey = hotkey->NextSiblingElement()) {
        const char *actionStr = hotkey->Attribute("action");
        if (actionStr == NULL) {
            CLOG(L"No action provided for hotkey; skipping");
            continue;
        }

        int action = -1;
        std::wstring wActionStr = StringUtils::Widen(actionStr);
        for (unsigned int i = 0; i < HotkeyInfo::ActionNames.size(); ++i) {
            const wchar_t *currentAction = HotkeyInfo::ActionNames[i].c_str();
            if (_wcsicmp(wActionStr.c_str(), currentAction) == 0) {
                action = i;
                break;
            }
        }

        if (action == -1) {
            CLOG(L"Hotkey action '%s' not recognized; skipping",
                wActionStr.c_str());
            continue;
        }

        int combination = -1;
        hotkey->QueryIntAttribute("combination", &combination);
        if (combination == -1) {
            CLOG(L"No key combination provided for hotkey; skipping");
            continue;
        }

        HotkeyInfo hki;
        hki.action = action;
        hki.keyCombination = combination;

        /* Does this hotkey action have any arguments? */
        tinyxml2::XMLElement *arg = hotkey->FirstChildElement("arg");
        for (; arg != NULL; arg = arg->NextSiblingElement()) {
            const char *argStr = arg->GetText();
            hki.args.push_back(StringUtils::Widen(argStr));
        }

        /* Do a validity check on the finished HKI object */
        if (hki.Valid() == false) {
            continue;
        }

        /* Whew, we made it! */
        CLOG(L"%s", hki.ToString().c_str());
        keyMappings[combination] = hki;
    }

    return keyMappings;
}
コード例 #11
0
ファイル: Hotkeys.cpp プロジェクト: malensek/3RVX
void Hotkeys::LoadAction(int index, HotkeyInfo &selection) {
    int action = selection.action;

    if (action < 0) {
        /* Selection has no action */
        return;
    }

    /* First, set the action description */
    _keyList->ItemText(index, 1, ActionString(selection));

    /* Default visiblities */
    bool showLabel = false;
    bool showCheck = false;
    bool showCombo = false;
    bool showEdit = false;
    bool showButton = false;

    switch ((HotkeyInfo::HotkeyActions) action) {
    case HotkeyInfo::IncreaseVolume:
    case HotkeyInfo::DecreaseVolume:
        VolumeArgControlStates(selection);
        showCheck = true; showCombo = true; showEdit = true;
        break;

    case HotkeyInfo::SetVolume:
        VolumeArgControlStates(selection);
        showLabel = true; showCombo = true; showEdit = true;
        break;

    case HotkeyInfo::EjectDrive:
        _argLabel->Text(_driveArgStr);
        _argCombo->Width(_argCombo->EmSize() * 6);
        for (int i = 0; i < 26; ++i) {
            wchar_t ch = (wchar_t) i + 65;
            _argCombo->AddItem(std::wstring(1, ch));
        }

        if (selection.HasArgs()) {
            _argCombo->Select(selection.args[0]);
        }

        showLabel = true; showCombo = true;
        break;

    case HotkeyInfo::MediaKey:
        _argLabel->Text(_keyArgStr);
        for (std::wstring keys : HotkeyInfo::MediaKeyNames) {
            _argCombo->AddItem(_translator->Translate(keys));
        }

        if (selection.HasArgs()) {
            _argCombo->Select(_translator->Translate(selection.args[0]));
        }

        showLabel = true; showCombo = true;
        break;

    case HotkeyInfo::VirtualKey:
        _argLabel->Text(_vkArgStr);
        if (selection.HasArgs()) {
            _argEdit->Text(selection.args[0]);
        }
        showLabel = true; showEdit = true;
        break;

    case HotkeyInfo::Run:
        _argLabel->Text(_pathArgStr);
        _argButton->Text(L"…");
        _argButton->Width(_argButton->EmSize() * 3);
        _argEdit->PlaceRightOf(*_argLabel);
        _argEdit->X(_action->X());
        _argEdit->Width(_keys->Width() - _argButton->Width() - _argEdit->EmSize());
        _argButton->PlaceRightOf(*_argEdit);

        if (selection.HasArgs()) {
            _argEdit->Text(selection.args[0]);
        }

        showLabel = true; showEdit = true; showButton = true;
        break;
    }

    /* Update control visibility */
    _argLabel->Visible(showLabel);
    _argCheck->Visible(showCheck);
    _argCombo->Visible(showCombo);
    _argEdit->Visible(showEdit);
    _argButton->Visible(showButton);

    if (_argCheck->Visible() == false) {
        /* Controls are only disabled for optional arguments (check box).
         * If _argCheck isn't visible, make sure everything is enabled. */
        _argEdit->Enable();
        _argCombo->Enable();
        _argButton->Enable();
    }
}