void CorsairCUE::Initialize()
{
#ifdef CORSAIR_CUE_ENABLED
    CorsairPerformProtocolHandshake();
    if (const auto error = CorsairGetLastError())
    {
        failed = TRUE;
    }
    else
    {
        failed = FALSE;

        positions = CorsairGetLedPositions();

        colors = new CorsairLedColor[positions->numberOfLed];
        x_idx = new int[positions->numberOfLed];
        y_idx = new int[positions->numberOfLed];
        led_idx = new CorsairLedId[positions->numberOfLed];

        double width = getKeyboardWidth(positions);
        double height = getKeyboardHeight(positions);

        for (int i = 0; i < positions->numberOfLed; i++)
        {
            led_idx[i] = positions->pLedPosition[i].ledId;
            x_idx[i] = SPECTROGRAPH_COLS * (positions->pLedPosition[i].left / width);
            y_idx[i] = ROW_IDX_SPECTROGRAPH_TOP + (SPECTROGRAPH_ROWS * (positions->pLedPosition[i].top / height)) + (0.5f * (SPECTROGRAPH_ROWS / height));
        }

        failed = FALSE;
    }
#else
    failed = TRUE;
#endif
}
示例#2
0
		//get all CorsairKey
		std::vector<CorsairLedColor> getAll()
		{
			std::vector<CorsairLedColor> colorsVector;
			for (auto deviceIndex = 0; deviceIndex < CorsairGetDeviceCount(); deviceIndex++) {
				if (auto deviceInfo = CorsairGetDeviceInfo(deviceIndex)) {
					switch (deviceInfo->type) {
					case CDT_Mouse: {
						auto numberOfKeys = deviceInfo->physicalLayout - CPL_Zones1 + 1;
						for (auto i = 0; i < numberOfKeys; i++) {
							auto ledId = static_cast<CorsairLedId>(CLM_1 + i);
							colorsVector.push_back(CorsairLedColor{ ledId, 0, 0, 0 });
						}
					} break;
					case CDT_Keyboard: {
						auto ledPositions = CorsairGetLedPositions();
						if (ledPositions) {
							for (auto i = 0; i < ledPositions->numberOfLed; i++) {
								auto ledId = ledPositions->pLedPosition[i].ledId;
								colorsVector.push_back(CorsairLedColor{ ledId, 0, 0, 0 });
							}
						}
					} break;
					case CDT_Headset: {
						colorsVector.push_back(CorsairLedColor{ CLH_LeftLogo, 0, 0, 0 });
						colorsVector.push_back(CorsairLedColor{ CLH_RightLogo, 0, 0, 0 });
					} break;
					}
				}
			}

			return colorsVector;
		}
示例#3
0
		//CorsairLedPositions as vector of CorsairLedPosition
		std::vector<CorsairLedPosition> getPos()
		{
			std::vector<CorsairLedPosition> ret;
			::CorsairLedPositions *clp = CorsairGetLedPositions();

			CorsairLedPosition *thisLedPos = 0;
			for (int i = 0;
			thisLedPos = &(clp->pLedPosition[i]),
				i < clp->numberOfLed;
				i++)
			{
				ret.push_back(*thisLedPos);
			}
			return ret;
		}