mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Added pipeserver logging
Fixed teams on default UT profile
This commit is contained in:
parent
02fe015c36
commit
47f4e5049a
Binary file not shown.
@ -15,10 +15,12 @@ namespace Artemis.Utilities.DataReaders
|
||||
private readonly ILogger _logger;
|
||||
private string _pipeName;
|
||||
private NamedPipeServerStream _pipeServer;
|
||||
private bool _closed;
|
||||
|
||||
public PipeServer(ILogger logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_closed = true;
|
||||
}
|
||||
|
||||
public event DelegateMessage PipeMessage;
|
||||
@ -34,10 +36,12 @@ namespace Artemis.Utilities.DataReaders
|
||||
PipeTransmissionMode.Byte, PipeOptions.Asynchronous, 4096, 4096, security);
|
||||
_pipeServer.BeginWaitForConnection(WaitForConnectionCallBack, _pipeServer);
|
||||
_logger.Info("Opened named pipe '{0}'", _pipeName);
|
||||
_closed = false;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_closed = true;
|
||||
_pipeServer.Close();
|
||||
_pipeServer.Dispose();
|
||||
_logger.Info("Closed named pipe '{0}'", _pipeName);
|
||||
@ -73,8 +77,8 @@ namespace Artemis.Utilities.DataReaders
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.Error(e, "Exception in named pipe '{0}'", _pipeName);
|
||||
// ignored
|
||||
if (!_closed)
|
||||
_logger.Error(e, "Exception in named pipe '{0}'", _pipeName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
67
Artemis/Razer2Artemis/Log.h
Normal file
67
Artemis/Razer2Artemis/Log.h
Normal file
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* File: Log.h
|
||||
* Author: Alberto Lepe <dev@alepe.com>
|
||||
*
|
||||
* Created on December 1, 2015, 6:00 PM
|
||||
*/
|
||||
|
||||
#ifndef LOG_H
|
||||
#define LOG_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
enum typelog {
|
||||
DEBUG,
|
||||
INFO,
|
||||
WARN,
|
||||
ERR
|
||||
};
|
||||
|
||||
struct structlog {
|
||||
bool headers = false;
|
||||
typelog level = WARN;
|
||||
};
|
||||
|
||||
extern structlog LOGCFG;
|
||||
|
||||
class LOG {
|
||||
public:
|
||||
LOG() {}
|
||||
LOG(typelog type) {
|
||||
msglevel = type;
|
||||
if (LOGCFG.headers) {
|
||||
operator << ("[" + getLabel(type) + "]");
|
||||
}
|
||||
}
|
||||
~LOG() {
|
||||
if (opened) {
|
||||
cout << endl;
|
||||
}
|
||||
opened = false;
|
||||
}
|
||||
template<class T>
|
||||
LOG &operator<<(const T &msg) {
|
||||
if (msglevel >= LOGCFG.level) {
|
||||
cout << msg;
|
||||
opened = true;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
private:
|
||||
bool opened = false;
|
||||
typelog msglevel = DEBUG;
|
||||
inline string getLabel(typelog type) {
|
||||
string label;
|
||||
switch (type) {
|
||||
case DEBUG: label = "DEBUG"; break;
|
||||
case INFO: label = "INFO "; break;
|
||||
case WARN: label = "WARN "; break;
|
||||
case ERR: label = "ERR"; break;
|
||||
}
|
||||
return label;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /* LOG_H */
|
||||
@ -1,8 +1,9 @@
|
||||
#include "main.h"
|
||||
#include <stdio.h>
|
||||
#include <fstream>
|
||||
#include <Windows.h>
|
||||
#include <filesystem>
|
||||
|
||||
using namespace std;
|
||||
TCHAR szName[] = TEXT("overwatchMmf");
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
@ -17,15 +18,15 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, LPVOID)
|
||||
{
|
||||
if (fdwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
// // Get the process that loaded the DLL
|
||||
// TCHAR overwatchFind[] = _T("Overwatch");
|
||||
// TCHAR szPath[MAX_PATH];
|
||||
// GetModuleFileName(nullptr, szPath, MAX_PATH);
|
||||
//
|
||||
// if (_tcscmp(szPath, overwatchFind) != 0)
|
||||
// game = "overwatch";
|
||||
}
|
||||
// Get the process that loaded the DLL
|
||||
TCHAR szPath[MAX_PATH];
|
||||
GetModuleFileName(nullptr, szPath, MAX_PATH);
|
||||
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "Main called, DLL loaded into " << szPath << "\n";
|
||||
myfile.close();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -44,8 +45,25 @@ void WritePipe(std::string msg)
|
||||
pipe = CreateFile(TEXT("\\\\.\\pipe\\artemis"), GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, nullptr);
|
||||
if (pipe == nullptr || pipe == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "Couldn't create pipe, nullptr or INVALID_HANDLE_VALUE\n";
|
||||
myfile.close();
|
||||
return;
|
||||
}
|
||||
auto lastError = GetLastError();
|
||||
if (lastError != 0)
|
||||
{
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "Couldn't create pipe: " << lastError << "\n";
|
||||
myfile.close();
|
||||
return;
|
||||
}
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "Created pipe and sending msg\n";
|
||||
myfile.close();
|
||||
|
||||
DWORD cbWritten;
|
||||
WriteFile(pipe, msg.c_str(), msg.size(), &cbWritten, nullptr);
|
||||
@ -53,22 +71,38 @@ void WritePipe(std::string msg)
|
||||
|
||||
RZRESULT Init()
|
||||
{
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "Init called\n";
|
||||
myfile.close();
|
||||
g_hasInitialised = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
RZRESULT UnInit()
|
||||
{
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "UnInit called\n";
|
||||
myfile.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
RZRESULT CreateEffect(RZDEVICEID DeviceId, ChromaSDK::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId)
|
||||
{
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "CreateEffect called\n";
|
||||
myfile.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
RZRESULT CreateKeyboardEffect(ChromaSDK::Keyboard::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId)
|
||||
{
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "CreateKeyboardEffect called\n";
|
||||
myfile.close();
|
||||
std::string res = "";
|
||||
if (Effect == Keyboard::CHROMA_CUSTOM)
|
||||
{
|
||||
@ -109,45 +143,81 @@ RZRESULT CreateKeyboardEffect(ChromaSDK::Keyboard::EFFECT_TYPE Effect, PRZPARAM
|
||||
|
||||
RZRESULT CreateMouseEffect(ChromaSDK::Mouse::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId)
|
||||
{
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "CreateMouseEffect called\n";
|
||||
myfile.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
RZRESULT CreateHeadsetEffect(ChromaSDK::Headset::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId)
|
||||
{
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "CreateHeadsetEffect called\n";
|
||||
myfile.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
RZRESULT CreateMousepadEffect(ChromaSDK::Mousepad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId)
|
||||
{
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "CreateMousepadEffect called\n";
|
||||
myfile.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
RZRESULT CreateKeypadEffect(ChromaSDK::Keypad::EFFECT_TYPE Effect, PRZPARAM pParam, RZEFFECTID* pEffectId)
|
||||
{
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "CreateKeypadEffect called\n";
|
||||
myfile.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
RZRESULT DeleteEffect(RZEFFECTID EffectId)
|
||||
{
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "DeleteEffect called\n";
|
||||
myfile.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
RZRESULT SetEffect(RZEFFECTID EffectId)
|
||||
{
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "SetEffect called\n";
|
||||
myfile.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
RZRESULT RegisterEventNotification(HWND hWnd)
|
||||
{
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "RegisterEventNotification called\n";
|
||||
myfile.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
RZRESULT UnregisterEventNotification()
|
||||
{
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "UnregisterEventNotification called\n";
|
||||
myfile.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
RZRESULT QueryDevice(RZDEVICEID DeviceId, DEVICE_INFO_TYPE& DeviceInfo)
|
||||
{
|
||||
ofstream myfile;
|
||||
myfile.open("log.txt", ios::out | ios::app);
|
||||
myfile << "QueryDevice called\n";
|
||||
myfile.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user