mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 13:29:54 +00:00
remove some unnecessary stuff
This commit is contained in:
parent
0ac2f91663
commit
50e7468d35
5 changed files with 3 additions and 490 deletions
|
|
@ -1,351 +0,0 @@
|
|||
//! \example ChromaSDKImpl.cpp
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <windows.h>
|
||||
#include "ChromaSDKImpl.h"
|
||||
#include "FrameController.h"
|
||||
|
||||
CChromaSDKImpl g_ChromaSDKImpl;
|
||||
|
||||
#ifdef _WIN64
|
||||
#define CHROMASDKDLL L"RzChromaSDK64.dll"
|
||||
#else
|
||||
#define CHROMASDKDLL L"RzChromaSDK.dll"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace ChromaSDK;
|
||||
using namespace ChromaSDK::Keyboard;
|
||||
using namespace ChromaSDK::Keypad;
|
||||
using namespace ChromaSDK::Mouse;
|
||||
using namespace ChromaSDK::Mousepad;
|
||||
using namespace ChromaSDK::Headset;
|
||||
|
||||
typedef RZRESULT (*INIT)(void);
|
||||
typedef RZRESULT (*UNINIT)(void);
|
||||
typedef RZRESULT (*CREATEEFFECT)(RZDEVICEID DeviceId, ChromaSDK::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId);
|
||||
typedef RZRESULT (*CREATEKEYBOARDEFFECT)(ChromaSDK::Keyboard::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId);
|
||||
typedef RZRESULT (*CREATEHEADSETEFFECT)(ChromaSDK::Headset::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId);
|
||||
typedef RZRESULT (*CREATEMOUSEPADEFFECT)(ChromaSDK::Mousepad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId);
|
||||
typedef RZRESULT (*CREATEMOUSEEFFECT)(ChromaSDK::Mouse::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId);
|
||||
typedef RZRESULT (*CREATEKEYPADEFFECT)(ChromaSDK::Keypad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId);
|
||||
typedef RZRESULT (*CREATECHROMALINKEFFECT)(ChromaSDK::ChromaLink::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId);
|
||||
typedef RZRESULT (*SETEFFECT)(RZEFFECTID EffectId);
|
||||
typedef RZRESULT (*DELETEEFFECT)(RZEFFECTID EffectId);
|
||||
typedef RZRESULT (*REGISTEREVENTNOTIFICATION)(HWND hWnd);
|
||||
typedef RZRESULT (*UNREGISTEREVENTNOTIFICATION)(void);
|
||||
typedef RZRESULT (*QUERYDEVICE)(RZDEVICEID DeviceId, ChromaSDK::DEVICE_INFO_TYPE &DeviceInfo);
|
||||
|
||||
INIT Init = NULL;
|
||||
UNINIT UnInit = NULL;
|
||||
CREATEEFFECT CreateEffect = NULL;
|
||||
CREATEKEYBOARDEFFECT CreateKeyboardEffect = NULL;
|
||||
CREATEMOUSEEFFECT CreateMouseEffect = NULL;
|
||||
CREATEHEADSETEFFECT CreateHeadsetEffect = NULL;
|
||||
CREATEMOUSEPADEFFECT CreateMousematEffect = NULL;
|
||||
CREATEKEYPADEFFECT CreateKeypadEffect = NULL;
|
||||
CREATECHROMALINKEFFECT CreateChromaLinkEffect = NULL;
|
||||
SETEFFECT SetEffect = NULL;
|
||||
DELETEEFFECT DeleteEffect = NULL;
|
||||
QUERYDEVICE QueryDevice = NULL;
|
||||
|
||||
#define EVENT_NAME L"{4784D90A-1179-4F7D-8558-52511D809190}"
|
||||
|
||||
#define MAX_EFFECTS 100
|
||||
|
||||
typedef struct _EFFECTDATATYPE
|
||||
{
|
||||
long numEffects;
|
||||
BOOL repeat;
|
||||
HANDLE thread;
|
||||
struct _EFFECT
|
||||
{
|
||||
RZEFFECTID id;
|
||||
long delay;
|
||||
} Effect[MAX_EFFECTS];
|
||||
} EFFECTDATATYPE;
|
||||
|
||||
struct GUIDCompare
|
||||
{
|
||||
BOOL operator()(const GUID & Left, const GUID & Right) const
|
||||
{
|
||||
return memcmp(&Left , &Right,sizeof(Right)) < 0;
|
||||
}
|
||||
};
|
||||
|
||||
std::map<RZEFFECTID, EFFECTDATATYPE, GUIDCompare> g_Effects;
|
||||
|
||||
DWORD WINAPI Thread_RenderEffects(LPVOID lpParameter)
|
||||
{
|
||||
RZEFFECTID *pEffectId = (RZEFFECTID*)lpParameter;
|
||||
|
||||
auto iterator = g_Effects.find(*pEffectId);
|
||||
if(iterator != g_Effects.end())
|
||||
{
|
||||
EFFECTDATATYPE *pEffectData = &iterator->second;
|
||||
|
||||
CFrameController FrameControl(30);
|
||||
|
||||
if(pEffectData->repeat == FALSE)
|
||||
{
|
||||
for(int i=0; i<pEffectData->numEffects; i++)
|
||||
{
|
||||
FrameControl.Begin();
|
||||
|
||||
SetEffect(pEffectData->Effect[i].id);
|
||||
|
||||
Sleep(pEffectData->Effect[i].delay);
|
||||
|
||||
FrameControl.End();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while(pEffectData->repeat)
|
||||
{
|
||||
for(int i=0; i<pEffectData->numEffects; i++)
|
||||
{
|
||||
FrameControl.Begin();
|
||||
|
||||
SetEffect(pEffectData->Effect[i].id);
|
||||
|
||||
Sleep(pEffectData->Effect[i].delay);
|
||||
|
||||
FrameControl.End();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// CChromaSDKImpl
|
||||
|
||||
CChromaSDKImpl::CChromaSDKImpl():
|
||||
m_hModule(NULL),
|
||||
m_hEvent(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
CChromaSDKImpl::~CChromaSDKImpl()
|
||||
{
|
||||
}
|
||||
|
||||
void CChromaSDKImpl::Initialize()
|
||||
{
|
||||
if(m_hModule == NULL)
|
||||
{
|
||||
m_hModule =::LoadLibrary(CHROMASDKDLL);
|
||||
if(m_hModule != NULL)
|
||||
{
|
||||
INIT Init = (INIT)::GetProcAddress(m_hModule, "Init");
|
||||
if(Init != NULL)
|
||||
{
|
||||
RZRESULT rzResult = Init();
|
||||
if(rzResult == RZRESULT_SUCCESS)
|
||||
{
|
||||
CreateEffect = (CREATEEFFECT)::GetProcAddress(m_hModule, "CreateEffect");
|
||||
CreateKeyboardEffect = (CREATEKEYBOARDEFFECT)::GetProcAddress(m_hModule, "CreateKeyboardEffect");
|
||||
CreateMouseEffect = (CREATEMOUSEEFFECT)::GetProcAddress(m_hModule, "CreateMouseEffect");
|
||||
CreateMousematEffect = (CREATEMOUSEPADEFFECT)::GetProcAddress(m_hModule, "CreateMousepadEffect");
|
||||
CreateKeypadEffect = (CREATEKEYPADEFFECT)::GetProcAddress(m_hModule, "CreateKeypadEffect");
|
||||
CreateHeadsetEffect = (CREATEHEADSETEFFECT)::GetProcAddress(m_hModule, "CreateHeadsetEffect");
|
||||
CreateChromaLinkEffect = (CREATECHROMALINKEFFECT)::GetProcAddress(m_hModule, "CreateChromaLinkEffect");
|
||||
SetEffect = (SETEFFECT)GetProcAddress(m_hModule, "SetEffect");
|
||||
DeleteEffect = (DELETEEFFECT)GetProcAddress(m_hModule, "DeleteEffect");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(m_hEvent == NULL)
|
||||
{
|
||||
m_hEvent = ::CreateEvent(NULL, TRUE, FALSE, EVENT_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
void CChromaSDKImpl::UnInitialize()
|
||||
{
|
||||
// Free memeory
|
||||
while(!g_Effects.empty())
|
||||
{
|
||||
auto iterator = g_Effects.begin();
|
||||
for(int i=0; i<iterator->second.numEffects; i++)
|
||||
{
|
||||
DeleteEffect(iterator->second.Effect[i].id);
|
||||
}
|
||||
|
||||
g_Effects.erase(iterator);
|
||||
};
|
||||
|
||||
if(m_hEvent != NULL)
|
||||
{
|
||||
::CloseHandle(m_hEvent);
|
||||
m_hEvent = NULL;
|
||||
}
|
||||
|
||||
if(m_hModule != NULL)
|
||||
{
|
||||
UNINIT UnInit = (UNINIT)::GetProcAddress(m_hModule, "UnInit");
|
||||
if(UnInit != NULL)
|
||||
{
|
||||
RZRESULT rzResult = UnInit();
|
||||
if(rzResult != RZRESULT_SUCCESS)
|
||||
{
|
||||
// Some error here
|
||||
}
|
||||
}
|
||||
|
||||
::FreeLibrary(m_hModule);
|
||||
m_hModule = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CChromaSDKImpl::CreateEffectImpl(RZDEVICEID DeviceId, ChromaSDK::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId)
|
||||
{
|
||||
if(CreateEffect == NULL) return;
|
||||
|
||||
CreateEffect(DeviceId, Effect, pParam, pEffectId);
|
||||
}
|
||||
|
||||
void CChromaSDKImpl::CreateKeyboardEffectImpl(ChromaSDK::Keyboard::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId)
|
||||
{
|
||||
if(CreateKeyboardEffect == NULL) return;
|
||||
|
||||
CreateKeyboardEffect(Effect, pParam, pEffectId);
|
||||
}
|
||||
|
||||
void CChromaSDKImpl::CreateMouseEffectImpl(ChromaSDK::Mouse::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId)
|
||||
{
|
||||
if(CreateMouseEffect == NULL) return;
|
||||
|
||||
CreateMouseEffect(Effect, pParam, pEffectId);
|
||||
}
|
||||
|
||||
void CChromaSDKImpl::CreateMousematEffectImpl(ChromaSDK::Mousepad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId)
|
||||
{
|
||||
if(CreateMousematEffect == NULL) return;
|
||||
|
||||
CreateMousematEffect(Effect, pParam, pEffectId);
|
||||
}
|
||||
|
||||
void CChromaSDKImpl::CreateKeypadEffectImpl(ChromaSDK::Keypad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId)
|
||||
{
|
||||
if(CreateKeypadEffect == NULL) return;
|
||||
|
||||
CreateKeypadEffect(Effect, pParam, pEffectId);
|
||||
}
|
||||
|
||||
void CChromaSDKImpl::CreateHeadsetEffectImpl(ChromaSDK::Headset::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId)
|
||||
{
|
||||
if(CreateHeadsetEffect == NULL) return;
|
||||
|
||||
CreateHeadsetEffect(Effect, pParam, pEffectId);
|
||||
}
|
||||
|
||||
void CChromaSDKImpl::CreateChromaLinkEffectImpl(ChromaSDK::ChromaLink::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId)
|
||||
{
|
||||
if(CreateChromaLinkEffect == NULL) return;
|
||||
|
||||
CreateChromaLinkEffect(Effect, pParam, pEffectId);
|
||||
}
|
||||
|
||||
void CChromaSDKImpl::SetEffectImpl(RZEFFECTID EffectId)
|
||||
{
|
||||
auto iterator = g_Effects.find(EffectId);
|
||||
if(iterator != g_Effects.end())
|
||||
{
|
||||
if(iterator->second.repeat == FALSE)
|
||||
{
|
||||
HANDLE hThread = CreateThread(NULL, 0, Thread_RenderEffects, (LPVOID)&iterator->first, 0, NULL);
|
||||
if(hThread != NULL)
|
||||
{
|
||||
CloseHandle(hThread);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
HANDLE hThread = CreateThread(NULL, 0, Thread_RenderEffects, (LPVOID)&iterator->first, 0, NULL);
|
||||
if(hThread != NULL)
|
||||
{
|
||||
iterator->second.thread = hThread;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(SetEffect == NULL) return;
|
||||
|
||||
SetEffect(EffectId);
|
||||
}
|
||||
}
|
||||
|
||||
void CChromaSDKImpl::DeleteEffectImpl(RZEFFECTID EffectId)
|
||||
{
|
||||
auto iterator = g_Effects.find(EffectId);
|
||||
if(iterator != g_Effects.end())
|
||||
{
|
||||
EFFECTDATATYPE EffectData = iterator->second;
|
||||
for(int i=0; i<EffectData.numEffects; i++)
|
||||
{
|
||||
DeleteEffect(EffectData.Effect[i].id);
|
||||
}
|
||||
|
||||
g_Effects.erase(iterator);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(DeleteEffect == NULL) return;
|
||||
|
||||
DeleteEffect(EffectId);
|
||||
}
|
||||
}
|
||||
|
||||
void CChromaSDKImpl::StopEffectImpl(RZEFFECTID EffectId)
|
||||
{
|
||||
auto iterator = g_Effects.find(EffectId);
|
||||
if(iterator != g_Effects.end())
|
||||
{
|
||||
if((iterator->second.repeat == TRUE) &&
|
||||
(iterator->second.thread != NULL))
|
||||
{
|
||||
iterator->second.repeat = FALSE;
|
||||
|
||||
CloseHandle(iterator->second.thread);
|
||||
|
||||
iterator->second.thread = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CChromaSDKImpl::CreateEffectGroup(RZEFFECTID *pGroupEffectId, BOOL Repeat)
|
||||
{
|
||||
RZEFFECTID EffectId = GUID_NULL;
|
||||
if(SUCCEEDED(::CoCreateGuid(&EffectId)))
|
||||
{
|
||||
EFFECTDATATYPE EffectData = {};
|
||||
|
||||
EffectData.numEffects = 0;
|
||||
EffectData.repeat = Repeat;
|
||||
|
||||
g_Effects.insert(make_pair(EffectId, EffectData));
|
||||
|
||||
*pGroupEffectId = EffectId;
|
||||
}
|
||||
}
|
||||
|
||||
void CChromaSDKImpl::AddToGroup(RZEFFECTID GroupEffectId, RZEFFECTID EffectId, long DelayMS)
|
||||
{
|
||||
auto iterator = g_Effects.find(GroupEffectId);
|
||||
if(iterator != g_Effects.end())
|
||||
{
|
||||
long lIndex = iterator->second.numEffects;
|
||||
|
||||
iterator->second.Effect[lIndex].id = EffectId;
|
||||
iterator->second.Effect[lIndex].delay = DelayMS;
|
||||
|
||||
iterator->second.numEffects++;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
|
||||
#ifndef _CHROMASDKIMPL2_H_
|
||||
#define _CHROMASDKIMPL2_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RzChromaSDKDefines.h"
|
||||
#include "RzChromaSDKTypes.h"
|
||||
#include "RzErrors.h"
|
||||
|
||||
const COLORREF BLACK = RGB(0,0,0);
|
||||
const COLORREF WHITE = RGB(255,255,255);
|
||||
const COLORREF RED = RGB(255,0,0);
|
||||
const COLORREF GREEN = RGB(0,255,0);
|
||||
const COLORREF BLUE = RGB(0,0,255);
|
||||
const COLORREF YELLOW = RGB(255,255,0);
|
||||
const COLORREF PURPLE = RGB(128,0,128);
|
||||
const COLORREF CYAN = RGB(00,255,255);
|
||||
const COLORREF ORANGE = RGB(255,165,00);
|
||||
const COLORREF PINK = RGB(255,192,203);
|
||||
const COLORREF GREY = RGB(125, 125, 125);
|
||||
|
||||
class CChromaSDKImpl
|
||||
{
|
||||
public:
|
||||
CChromaSDKImpl();
|
||||
~CChromaSDKImpl();
|
||||
|
||||
public:
|
||||
void Initialize();
|
||||
void UnInitialize();
|
||||
|
||||
void CreateEffectImpl(RZDEVICEID DeviceId, ChromaSDK::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId=NULL);
|
||||
void CreateKeyboardEffectImpl(ChromaSDK::Keyboard::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId=NULL);
|
||||
void CreateMouseEffectImpl(ChromaSDK::Mouse::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId=NULL);
|
||||
void CreateMousematEffectImpl(ChromaSDK::Mousepad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId=NULL);
|
||||
void CreateKeypadEffectImpl(ChromaSDK::Keypad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId=NULL);
|
||||
void CreateHeadsetEffectImpl(ChromaSDK::Headset::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId=NULL);
|
||||
void CreateChromaLinkEffectImpl(ChromaSDK::ChromaLink::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID *pEffectId=NULL);
|
||||
void SetEffectImpl(RZEFFECTID EffectId);
|
||||
void DeleteEffectImpl(RZEFFECTID EffectId);
|
||||
void StopEffectImpl(RZEFFECTID EffectId);
|
||||
|
||||
void CreateEffectGroup(RZEFFECTID *pGroupEffectId, BOOL Repeat=FALSE);
|
||||
void AddToGroup(RZEFFECTID GroupEffectId, RZEFFECTID EffectId, LONG DelayMS=100);
|
||||
|
||||
private:
|
||||
HMODULE m_hModule;
|
||||
HANDLE m_hEvent;
|
||||
};
|
||||
|
||||
extern CChromaSDKImpl g_ChromaSDKImpl;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
|
||||
#include "FrameController.h"
|
||||
#include <windows.h>
|
||||
|
||||
int g_dwCurrentTickCount = 0;
|
||||
|
||||
// CFrameController
|
||||
CFrameController::CFrameController():
|
||||
m_FramesPerSec(-1),
|
||||
m_OneFrame(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CFrameController::CFrameController(long FramePerSec):
|
||||
m_FramesPerSec(FramePerSec),
|
||||
m_OneFrame(1000.0/m_FramesPerSec)
|
||||
{
|
||||
}
|
||||
|
||||
CFrameController::~CFrameController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CFrameController::Begin()
|
||||
{
|
||||
g_dwCurrentTickCount = GetTickCount();
|
||||
}
|
||||
|
||||
void CFrameController::End()
|
||||
{
|
||||
static int dwSleep = 0;
|
||||
static int dwDiff = 0;
|
||||
|
||||
dwDiff = GetTickCount() - g_dwCurrentTickCount;
|
||||
dwSleep = (int)(m_OneFrame - (double)dwDiff);
|
||||
|
||||
if (dwDiff < m_OneFrame)
|
||||
{
|
||||
Sleep(dwSleep);
|
||||
}
|
||||
}
|
||||
|
||||
void CFrameController::SetRate(long FramePerSec)
|
||||
{
|
||||
m_FramesPerSec = FramePerSec;
|
||||
m_OneFrame = 1000.0 / m_FramesPerSec;
|
||||
}
|
||||
|
||||
long CFrameController::GetRate(void)
|
||||
{
|
||||
return m_FramesPerSec;
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef _FRAMECONTROLLER_H_
|
||||
#define _FRAMECONTROLLER_H_
|
||||
|
||||
#pragma once
|
||||
|
||||
class CFrameController
|
||||
{
|
||||
public:
|
||||
CFrameController();
|
||||
CFrameController(long FramePerSec);
|
||||
~CFrameController();
|
||||
|
||||
void Begin();
|
||||
void End();
|
||||
void SetRate(long FramePerSec);
|
||||
long GetRate();
|
||||
|
||||
private:
|
||||
long m_FramesPerSec;
|
||||
double m_OneFrame;
|
||||
};
|
||||
|
||||
#endif
|
||||
9
mkxp.pro
9
mkxp.pro
|
|
@ -157,11 +157,10 @@ HEADERS += \
|
|||
src/sdl-util.h \
|
||||
src/oneshot.h \
|
||||
src/pipe.h \
|
||||
chromasdk/FrameController.h \
|
||||
chromasdk/ChromaSDKImpl.h \
|
||||
chromasdk/RzChromaSDKDefines.h \
|
||||
chromasdk/RzChromaSDKTypes.h \
|
||||
chromasdk/RzErrors.h \
|
||||
chromasdk/ChromaApi.h \
|
||||
src/i18n.h
|
||||
|
||||
SOURCES += \
|
||||
|
|
@ -203,10 +202,6 @@ SOURCES += \
|
|||
src/vorbissource.cpp \
|
||||
src/oneshot.cpp \
|
||||
src/screen.cpp \
|
||||
binding-mri/journal-binding.cpp \
|
||||
chromasdk/FrameController.cpp \
|
||||
chromasdk/ChromaSdkImpl.cpp \
|
||||
binding-mri/chroma-binding.cpp \
|
||||
src/i18n.cpp
|
||||
|
||||
STEAM {
|
||||
|
|
@ -305,6 +300,8 @@ BINDING_MRI {
|
|||
binding-mri/oneshot-binding.cpp \
|
||||
binding-mri/steam-binding.cpp \
|
||||
binding-mri/wallpaper-binding.cpp \
|
||||
binding-mri/journal-binding.cpp \
|
||||
binding-mri/chroma-binding.cpp \
|
||||
binding-mri/niko-binding.cpp
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue