1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Throttling GTA V updates to improve performance

This commit is contained in:
SpoinkyNL 2016-11-13 00:16:10 +01:00
parent c9481d4442
commit b1f4461b75
5 changed files with 59 additions and 39 deletions

View File

@ -2,7 +2,6 @@
using System.Threading;
using System.Windows;
using Artemis.DeviceProviders.Logitech.Utilities;
using Artemis.Utilities;
using Artemis.Utilities.DataReaders;
using Microsoft.Win32;
@ -14,7 +13,7 @@ namespace Artemis.DeviceProviders.Logitech
{
// Check to see if VC++ 2012 x64 is installed.
if (Registry.LocalMachine.OpenSubKey(
@"SOFTWARE\Classes\Installer\Dependencies\{ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}") == null)
@"SOFTWARE\Classes\Installer\Dependencies\{ca67548a-5ebe-413a-b50c-4b9ceb6d66c6}") == null)
{
CantEnableText = "Couldn't connect to your Logitech keyboard.\n" +
"The Visual C++ 2012 Redistributable v11.0.61030.0 could not be found, which is required.\n" +

View File

@ -127,7 +127,7 @@ namespace Artemis.Profiles.Lua
return new LuaRadialGradientBrush(_layerModel.AppliedProperties.Brush);
return null;
}
set { _layerModel.AppliedProperties.Brush = value.Brush; }
set { _layerModel.AppliedProperties.Brush = value?.Brush; }
}
#endregion

View File

@ -1,27 +1,27 @@
// Original work by VRocker https://github.com/VRocker/LogiLed2Corsair
// I'm mainly a C# developer, and these modification aren't a piece of art, but it suits our needs.
// The MIT License (MIT)
//
// Copyright (c) 2015 VRocker
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
; Original work by VRocker https://github.com/VRocker/LogiLed2Corsair
; I'm mainly a C# developer, and these modification aren't a piece of art, but it suits our needs.
;
; The MIT License (MIT)
;
; Copyright (c) 2015 VRocker
;
; Permission is hereby granted, free of charge, to any person obtaining a copy
; of this software and associated documentation files (the "Software"), to deal
; in the Software without restriction, including without limitation the rights
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
; copies of the Software, and to permit persons to whom the Software is
; furnished to do so, subject to the following conditions:
;
; The above copyright notice and this permission notice shall be included in all
; copies or substantial portions of the Software.
;
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
; SOFTWARE.
LIBRARY LogiLed2Artemis.dll

View File

@ -37,29 +37,40 @@ using namespace std;
static bool g_hasInitialised = false;
static bool mustLog = false;
static int throttle = 0;
const char* game = "";
const char* GetGame()
{
CHAR divisionFind[] = ("Division");
CHAR gtaFind[] = ("GTA");
CHAR szPath[MAX_PATH];
GetModuleFileNameA(NULL, szPath, MAX_PATH);
char *output;
output = strstr(szPath, divisionFind);
if (output)
return "division";
output = strstr(szPath, gtaFind);
if (output)
return "gta";
return "bf1";
};
BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, LPVOID)
{
if (fdwReason == DLL_PROCESS_ATTACH)
{
// Get the process that loaded the DLL
TCHAR divisionFind[] = _T("Division");
TCHAR gtaFind[] = _T("GTA");
TCHAR szPath[MAX_PATH];
GetModuleFileName(NULL, szPath, MAX_PATH);
if (_tcscmp(szPath, divisionFind) != 0)
game = "division";
else if (_tcscmp(szPath, gtaFind) != 0)
game = "gta";
{
game = GetGame();
if (mustLog)
{
ofstream myfile;
myfile.open("log.txt", ios::out | ios::app);
myfile << "Main called, DLL loaded into " << szPath << "\n";
myfile << "Main called, DLL loaded into " << game << "\n";
myfile.close();
}
}
@ -120,6 +131,16 @@ void Transmit(const char* msg)
// LogiLedSetLighting appears to have an undocumented extra argument
bool LogiLedSetLighting(int redPercentage, int greenPercentage, int bluePercentage, int custom = 0)
{
// GTA goes mental on the SetLighting calls, lets only send one in every 20
if (game == "gta")
{
throttle++;
if (throttle > 20)
throttle = 0;
else
return true;
}
if (mustLog)
{
ofstream myfile;