Skip to content

Commit

Permalink
Code refactoring and api bump, includes hack for corsair glaive.
Browse files Browse the repository at this point in the history
  • Loading branch information
MartB committed May 12, 2019
1 parent 61ea3b3 commit 62eb8f1
Show file tree
Hide file tree
Showing 21 changed files with 471 additions and 425 deletions.
13 changes: 7 additions & 6 deletions rpc-midl/rpc_retc.idl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ midl_pragma warning(disable: 2111)
import "oaidl.idl";

[
uuid(4b0af0e2-325a-4305-af21-1a611e55a196),
version(2.4)
uuid(5f4db48f-188e-4243-8570-5a9835640b95),
version(2.5)
]

interface rpc_retc
Expand Down Expand Up @@ -40,13 +40,14 @@ interface rpc_retc
} RETCClientConfig;

typedef [context_handle] void* CONTEXT_HANDLE;
typedef [ptr] RETCClientConfig* CONFIG_PTR;

CONTEXT_HANDLE initialize([in] handle_t hBinding, [out] RETCClientConfig* config);
CONTEXT_HANDLE initialize([in] handle_t hBinding, [in, out] CONFIG_PTR config);

RZRESULT playEffect(RETCDeviceType deviceType, [in] int type, [in, out, unique]RZEFFECTID *pEffectID, efsize_t effectSize, [size_is(effectSize)] char effectData[*], CONTEXT_HANDLE hContext);
RZRESULT playEffect(const RETCDeviceType deviceType, [in] const int type, [in, out, unique]RZEFFECTID *pEffectID, const efsize_t effectSize, [size_is(effectSize)] char effectData[*], CONTEXT_HANDLE hContext);

RZRESULT setEffect([in] RZEFFECTID effID, CONTEXT_HANDLE hContext);
RZRESULT deleteEffect([in] RZEFFECTID effID, CONTEXT_HANDLE hContext);
RZRESULT setEffect([in] const RZEFFECTID effID, CONTEXT_HANDLE hContext);
RZRESULT deleteEffect([in] const RZEFFECTID effID, CONTEXT_HANDLE hContext);

void disconnect([in, out] CONTEXT_HANDLE* phContext);
}
27 changes: 14 additions & 13 deletions server-exe/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,21 @@ ConfigManager::ConfigManager() {

#define SUCCESS(cond) ((cond) >= SI_OK)

void ConfigManager::ReloadConfigFile() {
void ConfigManager::ReloadConfigFile() const
{
simpleIni->Reset();

// It does not matter if this fails
simpleIni->LoadFile(CONFIG_FILENAME);
}

// Please do not use these if you expect special characters > 7 bit to work
std::string ConfigManager::GetAsciiString(const wchar_t* section, const wchar_t* key, const wchar_t* def) {
std::string ConfigManager::GetAsciiString(const wchar_t* section, const wchar_t* key, const wchar_t* def) const {
const std::wstring res = GetWString(section, key, def);
return std::string(res.begin(), res.end());
}

std::string ConfigManager::GetAsciiString(const wchar_t* section, const wchar_t* key, const std::string &def) {
std::string ConfigManager::GetAsciiString(const wchar_t* section, const wchar_t* key, const std::string &def) const {
std::wstring defConv(def.begin(), def.end());
return GetAsciiString(section, key, defConv.c_str());
}
Expand All @@ -38,11 +39,11 @@ std::string ConfigManager::GetUtf8StdString(const wchar_t* section, const wchar_
return WSTR_CONVERTER.to_bytes(GetWString(section, key, WSTR_CONVERTER.from_bytes(def).c_str()));
}

const wchar_t* ConfigManager::GetWString(const wchar_t* section, const wchar_t* key, const wchar_t* def) {
const wchar_t* ConfigManager::GetWString(const wchar_t* section, const wchar_t* key, const wchar_t* def) const {
return simpleIni->GetValue(section, key, def);
}

double ConfigManager::GetDouble(const wchar_t* section, const wchar_t* key, double def) {
double ConfigManager::GetDouble(const wchar_t* section, const wchar_t* key, const double def) const {
return simpleIni->GetDoubleValue(section, key, def);
}

Expand All @@ -54,8 +55,8 @@ long ConfigManager::GetLong(const wchar_t* section, const wchar_t* key, const lo
return simpleIni->GetLongValue(section, key, def);
}

Vec3D ConfigManager::GetVec3D(const wchar_t * section, const wchar_t * key, const Vec3D &def) {
auto rawValue = GetWString(section, key, nullptr);
Vec3D ConfigManager::GetVec3D(const wchar_t * section, const wchar_t * key, const Vec3D &def) const {
const auto rawValue = GetWString(section, key, nullptr);
if (rawValue == nullptr) {
return def;
}
Expand All @@ -74,23 +75,23 @@ Vec3D ConfigManager::GetVec3D(const wchar_t * section, const wchar_t * key, cons
return ret;
}

bool ConfigManager::SetBool(const wchar_t* section, const wchar_t* key, bool value) {
bool ConfigManager::SetBool(const wchar_t* section, const wchar_t* key, const bool value) const {
return SUCCESS(simpleIni->SetBoolValue(section, key, value));
}

bool ConfigManager::SetLong(const wchar_t* section, const wchar_t* key, const long value) {
bool ConfigManager::SetLong(const wchar_t* section, const wchar_t* key, const long value) const {
return SUCCESS(simpleIni->SetLongValue(section, key, value));
}

bool ConfigManager::SetWString(const wchar_t* section, const wchar_t* key, const wchar_t* value) {
bool ConfigManager::SetWString(const wchar_t* section, const wchar_t* key, const wchar_t* value) const {
return SUCCESS(simpleIni->SetValue(section, key, value));
}

bool ConfigManager::SetDouble(const wchar_t* section, const wchar_t* key, const double value) {
bool ConfigManager::SetDouble(const wchar_t* section, const wchar_t* key, const double value) const {
return SUCCESS(simpleIni->SetDoubleValue(section, key, value));
}

bool ConfigManager::SetVec3D(const wchar_t* section, const wchar_t* key, const Vec3D &value) {
bool ConfigManager::SetVec3D(const wchar_t* section, const wchar_t* key, const Vec3D &value) const {
std::wstringstream ws;
ws << value.x;
ws << value.y;
Expand All @@ -105,7 +106,7 @@ bool ConfigManager::SetVec3D(const wchar_t* section, const wchar_t* key, const V
}


bool ConfigManager::SaveConfig() {
bool ConfigManager::SaveConfig() const {
return SUCCESS(simpleIni->SaveFile(CONFIG_FILENAME));
}

Expand Down
30 changes: 15 additions & 15 deletions server-exe/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct Vec3D {
double x, y, z;
Vec3D() : x(0.0f), y(0.0f), z(0.0f) {}

bool isZero() {
bool isZero() const {
return x == 0.0f && y == 0.0f && z == 0.0f; //-V550
}
};
Expand All @@ -19,27 +19,27 @@ class ConfigManager {
~ConfigManager();
ConfigManager();

void ReloadConfigFile();
void ReloadConfigFile() const;

std::string GetAsciiString(const wchar_t * section, const wchar_t * key, const wchar_t * def);
std::string GetAsciiString(const wchar_t * section, const wchar_t * key, const std::string &def);
std::string GetAsciiString(const wchar_t * section, const wchar_t * key, const wchar_t * def) const;
std::string GetAsciiString(const wchar_t * section, const wchar_t * key, const std::string &def) const;

std::string GetUtf8StdString(const wchar_t * section, const wchar_t * key, const std::string &def);

const wchar_t * GetWString(const wchar_t * section, const wchar_t * key, const wchar_t * def);
double GetDouble(const wchar_t * section, const wchar_t * key, double def);
bool GetBool(const wchar_t * section, const wchar_t * key, const bool def);
long GetLong(const wchar_t * section, const wchar_t * key, const long def);
Vec3D GetVec3D(const wchar_t * section, const wchar_t *key, const Vec3D &def);
const wchar_t * GetWString(const wchar_t * section, const wchar_t * key, const wchar_t * def) const;
double GetDouble(const wchar_t * section, const wchar_t * key, double def) const;
bool GetBool(const wchar_t * section, const wchar_t * key, bool def);
long GetLong(const wchar_t * section, const wchar_t * key, long def);
Vec3D GetVec3D(const wchar_t * section, const wchar_t *key, const Vec3D &def) const;

bool SetBool(const wchar_t * section, const wchar_t * key, bool value);
bool SetLong(const wchar_t * section, const wchar_t * key, const long value);
bool SetWString(const wchar_t * section, const wchar_t * key, const wchar_t * value);
bool SetBool(const wchar_t * section, const wchar_t * key, bool value) const;
bool SetLong(const wchar_t * section, const wchar_t * key, long value) const;
bool SetWString(const wchar_t * section, const wchar_t * key, const wchar_t * value) const;

bool SetDouble(const wchar_t * section, const wchar_t * key, const double value);
bool SetVec3D(const wchar_t* section, const wchar_t* key, const Vec3D &value);
bool SetDouble(const wchar_t * section, const wchar_t * key, double value) const;
bool SetVec3D(const wchar_t* section, const wchar_t* key, const Vec3D &value) const;

bool SaveConfig();
bool SaveConfig() const;

private:
std::unique_ptr<CSimpleIni> simpleIni;
Expand Down

0 comments on commit 62eb8f1

Please sign in to comment.