예제 #1
0
        LFXE_API bool DeviceLogitech::PushColorToDevice(const vector<LightColor>& colors) {
            double red = colors[0].red;
            double green = colors[0].green;
            double blue = colors[0].blue;
            double alpha = colors[0].brightness;

            if (this->RestoreLightsOnNullEnabled && red == 0.0 && green == 0.0 && blue == 0.0 && alpha == 0.0)
            {
                return LogiLedRestoreLighting();
            }

            if (this->g110WorkaroundEnabled) {
                double total = red + blue;
                if (total > 255) {
                    red = red * 255 / total;
                    blue = blue * 255 / total;
                }
            }

            double divider = (this->rangeOutMax - this->rangeOutMin) / ((this->rangeInMax - this->rangeInMin) / 100.0) / 100.0;
            double brightness = colors[0].brightness / 255.0;
            red = (red - this->rangeOutMin) / divider * brightness + this->rangeInMin;
            green = (green - this->rangeOutMin) / divider * brightness + this->rangeInMin;
            blue = (blue - this->rangeOutMin) / divider * brightness + this->rangeInMin;

            LOG_DEBUG(L"Update color to (" + to_wstring(red) + L"," + to_wstring(green) + L"," + to_wstring(blue) + L")");

            return LogiLedSetLighting((int)red, (int)green, (int)blue);
        }
예제 #2
0
void CLEDSlidersDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
    // TODO: Add your message handler code here and/or call default
    // TODO: Add your message handler code here and/or call default
    int CurPos = pScrollBar->GetScrollPos();

    // Determine the new position of scroll box.
    switch (nSBCode)
    {
    case SB_LEFT:      // Scroll to far left.
        CurPos = 0;
        break;

    case SB_RIGHT:      // Scroll to far right.
        CurPos = 122;
        break;

    case SB_ENDSCROLL:   // End scroll.
        break;

    case SB_LINELEFT:      // Scroll left.
        if (CurPos > 0)
            CurPos--;
        break;

    case SB_LINERIGHT:   // Scroll right.
        if (CurPos < 122)
            CurPos++;
        break;

    case SB_PAGELEFT:    // Scroll one page left.
        {
            // Get the page size. 
            SCROLLINFO   info;
            pScrollBar->GetScrollInfo(&info, SIF_ALL);

            if (CurPos > 0)
                CurPos = max(0, CurPos - (int) info.nPage);
        }
        break;

    case SB_PAGERIGHT:      // Scroll one page right
        {
            // Get the page size. 
            SCROLLINFO   info;
            pScrollBar->GetScrollInfo(&info, SIF_ALL);

            if (CurPos < 122)
                CurPos = min(122, CurPos + (int) info.nPage);
        }
        break;

    case SB_THUMBPOSITION: // Scroll to absolute position. nPos is the position
        CurPos = nPos;      // of the scroll box at the end of the drag operation.
        break;

    case SB_THUMBTRACK:   // Drag scroll box to specified position. nPos is the
        CurPos = nPos;     // position that the scroll box has been dragged to.
        break;
    }

    pScrollBar->SetScrollPos(CurPos);

    int red = m_scrollBarMouseRed.GetScrollPos();
    int green = m_scrollBarMouseGreen.GetScrollPos();
    int blue = m_scrollBarMouseBlue.GetScrollPos();

    if (pScrollBar == &m_scrollBarKbdRed)
    {
        red = CurPos;
    }
    else if (pScrollBar == &m_scrollBarKbdGreen)
    {
        green = CurPos;
    }
    else if (pScrollBar == &m_scrollBarKbdBlue)
    {
        blue = CurPos;
    }

#ifndef USE_LOGITECH_DLL_ONLY
    LogiLedSetLighting(GetDeviceType(), red, green, blue);
#else
    g_lpfnDllSetLighting(GetDeviceType(), red, green, blue);
#endif

    CDialogEx::OnHScroll(nSBCode, nPos, pScrollBar);
}