chore: CRLF to LF
This commit is contained in:
+17
-17
@@ -1,17 +1,17 @@
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
#define APSTUDIO_HIDDEN_SYMBOLS
|
||||
#include "windows.h"
|
||||
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
IDR_CHANGELOG RCDATA "../changelog.txt"
|
||||
IDR_LICENSES RCDATA "../licenses.txt"
|
||||
IDR_PATCHES RCDATA "../build/patches.json"
|
||||
IDR_README RCDATA "../readme.txt"
|
||||
|
||||
#endif
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
#define APSTUDIO_HIDDEN_SYMBOLS
|
||||
#include "windows.h"
|
||||
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
IDR_CHANGELOG RCDATA "../changelog.txt"
|
||||
IDR_LICENSES RCDATA "../licenses.txt"
|
||||
IDR_PATCHES RCDATA "../build/patches.json"
|
||||
IDR_README RCDATA "../readme.txt"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,158 +1,158 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <windows.h>
|
||||
#include "option.h"
|
||||
|
||||
namespace rawinput {
|
||||
class RawInputManager;
|
||||
struct Device;
|
||||
}
|
||||
|
||||
class Button;
|
||||
class Analog;
|
||||
class Light;
|
||||
class Game;
|
||||
class Option;
|
||||
|
||||
namespace GameAPI {
|
||||
namespace Buttons {
|
||||
enum State {
|
||||
BUTTON_PRESSED = true,
|
||||
BUTTON_NOT_PRESSED = false
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses the config and returns the buttons set by the user.
|
||||
*
|
||||
* @param a std::string containing the game name OR a pointer to a Game
|
||||
* @return a vector pointer containing pointers of Button's set by the user
|
||||
*/
|
||||
std::vector<Button> getButtons(const std::string &game_name);
|
||||
std::vector<Button> getButtons(Game *);
|
||||
|
||||
/**
|
||||
* Sorts Buttons by their name
|
||||
*
|
||||
* @param a pointer to a vector pointer of Button pointers that will be sorted by the order of a vector pointer of strings
|
||||
* OR a parameter pack of std::string... can be used.
|
||||
* @return void
|
||||
*/
|
||||
std::vector<Button> sortButtons(
|
||||
const std::vector<Button> &buttons,
|
||||
const std::vector<std::string> &button_names,
|
||||
const std::vector<unsigned short> *vkey_defaults = nullptr);
|
||||
|
||||
template<typename T>
|
||||
void sortButtons(std::vector<Button> *buttons, T t) {
|
||||
const std::vector<std::string> names { t };
|
||||
|
||||
if (buttons) {
|
||||
*buttons = GameAPI::Buttons::sortButtons(*buttons, names);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename... Rest>
|
||||
void sortButtons(std::vector<Button> *buttons, T t, Rest... rest) {
|
||||
const std::vector<std::string> names { t, rest... };
|
||||
|
||||
if (buttons) {
|
||||
*buttons = GameAPI::Buttons::sortButtons(*buttons, names);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state of whether a button is pressed or not.
|
||||
* Highly recommended to use either of these two functions than the other two below them.
|
||||
*
|
||||
* @return either a GameAPI::Buttons::State::BUTTON_PRESSED or a Game::API::Buttons::State::BUTTON_NOT_PRESSED
|
||||
*/
|
||||
State getState(rawinput::RawInputManager *manager, Button &button, bool check_alts = true);
|
||||
State getState(std::unique_ptr<rawinput::RawInputManager> &manager, Button &button, bool check_alts = true);
|
||||
|
||||
/**
|
||||
* Returns the current velocity of a button.
|
||||
* When not pressed, the returned velocity is 0.
|
||||
* When pressed, the velocity can be anywhere in the range [0, 1]
|
||||
* @return velocity in the range [0, 1]
|
||||
*/
|
||||
float getVelocity(rawinput::RawInputManager *manager, Button &button);
|
||||
float getVelocity(std::unique_ptr<rawinput::RawInputManager> &manager, Button &button);
|
||||
}
|
||||
|
||||
namespace Analogs {
|
||||
std::vector<Analog> getAnalogs(const std::string &game_name);
|
||||
|
||||
std::vector<Analog> sortAnalogs(
|
||||
const std::vector<Analog> &analogs,
|
||||
const std::vector<std::string> &analog_names);
|
||||
|
||||
template<typename T>
|
||||
void sortAnalogs(std::vector<Analog> *analogs, T t) {
|
||||
const std::vector<std::string> analog_names { t };
|
||||
|
||||
if (analogs) {
|
||||
*analogs = GameAPI::Analogs::sortAnalogs(*analogs, analog_names);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename... Rest>
|
||||
void sortAnalogs(std::vector<Analog> *analogs, T t, Rest... rest) {
|
||||
const std::vector<std::string> analog_names { t, rest... };
|
||||
|
||||
if (analogs) {
|
||||
*analogs = GameAPI::Analogs::sortAnalogs(*analogs, analog_names);
|
||||
}
|
||||
}
|
||||
|
||||
float getState(rawinput::Device *device, Analog &analog);
|
||||
float getState(rawinput::RawInputManager *manager, Analog &analog);
|
||||
float getState(std::unique_ptr<rawinput::RawInputManager> &manager, Analog &analog);
|
||||
}
|
||||
|
||||
namespace Lights {
|
||||
std::vector<Light> getLights(const std::string &game_name);
|
||||
|
||||
std::vector<Light> sortLights(
|
||||
const std::vector<Light> &lights,
|
||||
const std::vector<std::string> &light_names);
|
||||
|
||||
template<typename T>
|
||||
void sortLights(std::vector<Light> *lights, T t) {
|
||||
const std::vector<std::string> light_names { t };
|
||||
|
||||
if (lights) {
|
||||
*lights = GameAPI::Lights::sortLights(*lights, light_names);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename... Rest>
|
||||
void sortLights(std::vector<Light> *lights, T t, Rest... rest) {
|
||||
const std::vector<std::string> light_names { t, rest... };
|
||||
|
||||
if (lights) {
|
||||
*lights = GameAPI::Lights::sortLights(*lights, light_names);
|
||||
}
|
||||
}
|
||||
|
||||
void writeLight(rawinput::Device *device, int index, float value);
|
||||
void writeLight(rawinput::RawInputManager *manager, Light &light, float value);
|
||||
void writeLight(std::unique_ptr<rawinput::RawInputManager> &manager, Light &light, float value);
|
||||
|
||||
float readLight(rawinput::Device *device, int index);
|
||||
float readLight(rawinput::RawInputManager *manager, Light &light);
|
||||
float readLight(std::unique_ptr<rawinput::RawInputManager> &manager, Light &light);
|
||||
}
|
||||
|
||||
namespace Options {
|
||||
std::vector<Option> getOptions(const std::string &game_name);
|
||||
|
||||
void sortOptions(std::vector<Option> &, const std::vector<OptionDefinition> &);
|
||||
}
|
||||
}
|
||||
|
||||
#include "button.h"
|
||||
#include "analog.h"
|
||||
#include "light.h"
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <windows.h>
|
||||
#include "option.h"
|
||||
|
||||
namespace rawinput {
|
||||
class RawInputManager;
|
||||
struct Device;
|
||||
}
|
||||
|
||||
class Button;
|
||||
class Analog;
|
||||
class Light;
|
||||
class Game;
|
||||
class Option;
|
||||
|
||||
namespace GameAPI {
|
||||
namespace Buttons {
|
||||
enum State {
|
||||
BUTTON_PRESSED = true,
|
||||
BUTTON_NOT_PRESSED = false
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses the config and returns the buttons set by the user.
|
||||
*
|
||||
* @param a std::string containing the game name OR a pointer to a Game
|
||||
* @return a vector pointer containing pointers of Button's set by the user
|
||||
*/
|
||||
std::vector<Button> getButtons(const std::string &game_name);
|
||||
std::vector<Button> getButtons(Game *);
|
||||
|
||||
/**
|
||||
* Sorts Buttons by their name
|
||||
*
|
||||
* @param a pointer to a vector pointer of Button pointers that will be sorted by the order of a vector pointer of strings
|
||||
* OR a parameter pack of std::string... can be used.
|
||||
* @return void
|
||||
*/
|
||||
std::vector<Button> sortButtons(
|
||||
const std::vector<Button> &buttons,
|
||||
const std::vector<std::string> &button_names,
|
||||
const std::vector<unsigned short> *vkey_defaults = nullptr);
|
||||
|
||||
template<typename T>
|
||||
void sortButtons(std::vector<Button> *buttons, T t) {
|
||||
const std::vector<std::string> names { t };
|
||||
|
||||
if (buttons) {
|
||||
*buttons = GameAPI::Buttons::sortButtons(*buttons, names);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename... Rest>
|
||||
void sortButtons(std::vector<Button> *buttons, T t, Rest... rest) {
|
||||
const std::vector<std::string> names { t, rest... };
|
||||
|
||||
if (buttons) {
|
||||
*buttons = GameAPI::Buttons::sortButtons(*buttons, names);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the state of whether a button is pressed or not.
|
||||
* Highly recommended to use either of these two functions than the other two below them.
|
||||
*
|
||||
* @return either a GameAPI::Buttons::State::BUTTON_PRESSED or a Game::API::Buttons::State::BUTTON_NOT_PRESSED
|
||||
*/
|
||||
State getState(rawinput::RawInputManager *manager, Button &button, bool check_alts = true);
|
||||
State getState(std::unique_ptr<rawinput::RawInputManager> &manager, Button &button, bool check_alts = true);
|
||||
|
||||
/**
|
||||
* Returns the current velocity of a button.
|
||||
* When not pressed, the returned velocity is 0.
|
||||
* When pressed, the velocity can be anywhere in the range [0, 1]
|
||||
* @return velocity in the range [0, 1]
|
||||
*/
|
||||
float getVelocity(rawinput::RawInputManager *manager, Button &button);
|
||||
float getVelocity(std::unique_ptr<rawinput::RawInputManager> &manager, Button &button);
|
||||
}
|
||||
|
||||
namespace Analogs {
|
||||
std::vector<Analog> getAnalogs(const std::string &game_name);
|
||||
|
||||
std::vector<Analog> sortAnalogs(
|
||||
const std::vector<Analog> &analogs,
|
||||
const std::vector<std::string> &analog_names);
|
||||
|
||||
template<typename T>
|
||||
void sortAnalogs(std::vector<Analog> *analogs, T t) {
|
||||
const std::vector<std::string> analog_names { t };
|
||||
|
||||
if (analogs) {
|
||||
*analogs = GameAPI::Analogs::sortAnalogs(*analogs, analog_names);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename... Rest>
|
||||
void sortAnalogs(std::vector<Analog> *analogs, T t, Rest... rest) {
|
||||
const std::vector<std::string> analog_names { t, rest... };
|
||||
|
||||
if (analogs) {
|
||||
*analogs = GameAPI::Analogs::sortAnalogs(*analogs, analog_names);
|
||||
}
|
||||
}
|
||||
|
||||
float getState(rawinput::Device *device, Analog &analog);
|
||||
float getState(rawinput::RawInputManager *manager, Analog &analog);
|
||||
float getState(std::unique_ptr<rawinput::RawInputManager> &manager, Analog &analog);
|
||||
}
|
||||
|
||||
namespace Lights {
|
||||
std::vector<Light> getLights(const std::string &game_name);
|
||||
|
||||
std::vector<Light> sortLights(
|
||||
const std::vector<Light> &lights,
|
||||
const std::vector<std::string> &light_names);
|
||||
|
||||
template<typename T>
|
||||
void sortLights(std::vector<Light> *lights, T t) {
|
||||
const std::vector<std::string> light_names { t };
|
||||
|
||||
if (lights) {
|
||||
*lights = GameAPI::Lights::sortLights(*lights, light_names);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename... Rest>
|
||||
void sortLights(std::vector<Light> *lights, T t, Rest... rest) {
|
||||
const std::vector<std::string> light_names { t, rest... };
|
||||
|
||||
if (lights) {
|
||||
*lights = GameAPI::Lights::sortLights(*lights, light_names);
|
||||
}
|
||||
}
|
||||
|
||||
void writeLight(rawinput::Device *device, int index, float value);
|
||||
void writeLight(rawinput::RawInputManager *manager, Light &light, float value);
|
||||
void writeLight(std::unique_ptr<rawinput::RawInputManager> &manager, Light &light, float value);
|
||||
|
||||
float readLight(rawinput::Device *device, int index);
|
||||
float readLight(rawinput::RawInputManager *manager, Light &light);
|
||||
float readLight(std::unique_ptr<rawinput::RawInputManager> &manager, Light &light);
|
||||
}
|
||||
|
||||
namespace Options {
|
||||
std::vector<Option> getOptions(const std::string &game_name);
|
||||
|
||||
void sortOptions(std::vector<Option> &, const std::vector<OptionDefinition> &);
|
||||
}
|
||||
}
|
||||
|
||||
#include "button.h"
|
||||
#include "analog.h"
|
||||
#include "light.h"
|
||||
|
||||
+60
-60
@@ -1,60 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "external/tinyxml2/tinyxml2.h"
|
||||
|
||||
#include "game.h"
|
||||
|
||||
// settings
|
||||
extern std::string CONFIG_PATH_OVERRIDE;
|
||||
|
||||
struct ConfigKeypadBindings {
|
||||
std::string keypads[2];
|
||||
std::filesystem::path card_paths[2];
|
||||
};
|
||||
|
||||
class Config {
|
||||
public:
|
||||
static Config &getInstance();
|
||||
bool getStatus();
|
||||
bool createConfigFile();
|
||||
|
||||
bool addGame(Game &game);
|
||||
|
||||
bool updateBinding(const Game &game, const Button &button, int alternative);
|
||||
bool updateBinding(const Game &game, const Analog &analog);
|
||||
bool updateBinding(const Game &game, ConfigKeypadBindings &keypads);
|
||||
bool updateBinding(const Game &game, const Light &light, int alternative);
|
||||
bool updateBinding(const Game &game, const Option &option);
|
||||
|
||||
std::vector<Button> getButtons(const std::string &game);
|
||||
std::vector<Button> getButtons(Game *);
|
||||
|
||||
std::vector<Analog> getAnalogs(const std::string &game);
|
||||
std::vector<Analog> getAnalogs(Game *);
|
||||
|
||||
ConfigKeypadBindings getKeypadBindings(const std::string &game);
|
||||
ConfigKeypadBindings getKeypadBindings(Game *);
|
||||
|
||||
std::vector<Light> getLights(const std::string &game);
|
||||
std::vector<Light> getLights(Game *);
|
||||
|
||||
std::vector<Option> getOptions(const std::string &game);
|
||||
std::vector<Option> getOptions(Game *);
|
||||
|
||||
private:
|
||||
Config();
|
||||
Config(const Config &);
|
||||
~Config() = default;
|
||||
|
||||
const Config &operator=(const Config &);
|
||||
|
||||
tinyxml2::XMLDocument configFile;
|
||||
bool status;
|
||||
std::string configLocation;
|
||||
|
||||
bool firstFillConfigFile();
|
||||
};
|
||||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "external/tinyxml2/tinyxml2.h"
|
||||
|
||||
#include "game.h"
|
||||
|
||||
// settings
|
||||
extern std::string CONFIG_PATH_OVERRIDE;
|
||||
|
||||
struct ConfigKeypadBindings {
|
||||
std::string keypads[2];
|
||||
std::filesystem::path card_paths[2];
|
||||
};
|
||||
|
||||
class Config {
|
||||
public:
|
||||
static Config &getInstance();
|
||||
bool getStatus();
|
||||
bool createConfigFile();
|
||||
|
||||
bool addGame(Game &game);
|
||||
|
||||
bool updateBinding(const Game &game, const Button &button, int alternative);
|
||||
bool updateBinding(const Game &game, const Analog &analog);
|
||||
bool updateBinding(const Game &game, ConfigKeypadBindings &keypads);
|
||||
bool updateBinding(const Game &game, const Light &light, int alternative);
|
||||
bool updateBinding(const Game &game, const Option &option);
|
||||
|
||||
std::vector<Button> getButtons(const std::string &game);
|
||||
std::vector<Button> getButtons(Game *);
|
||||
|
||||
std::vector<Analog> getAnalogs(const std::string &game);
|
||||
std::vector<Analog> getAnalogs(Game *);
|
||||
|
||||
ConfigKeypadBindings getKeypadBindings(const std::string &game);
|
||||
ConfigKeypadBindings getKeypadBindings(Game *);
|
||||
|
||||
std::vector<Light> getLights(const std::string &game);
|
||||
std::vector<Light> getLights(Game *);
|
||||
|
||||
std::vector<Option> getOptions(const std::string &game);
|
||||
std::vector<Option> getOptions(Game *);
|
||||
|
||||
private:
|
||||
Config();
|
||||
Config(const Config &);
|
||||
~Config() = default;
|
||||
|
||||
const Config &operator=(const Config &);
|
||||
|
||||
tinyxml2::XMLDocument configFile;
|
||||
bool status;
|
||||
std::string configLocation;
|
||||
|
||||
bool firstFillConfigFile();
|
||||
};
|
||||
|
||||
+26
-26
@@ -1,26 +1,26 @@
|
||||
#pragma once
|
||||
|
||||
#include "configurator_wnd.h"
|
||||
|
||||
namespace cfg {
|
||||
|
||||
enum class ConfigType {
|
||||
Config,
|
||||
KFControl,
|
||||
};
|
||||
|
||||
// globals
|
||||
extern bool CONFIGURATOR_STANDALONE;
|
||||
extern ConfigType CONFIGURATOR_TYPE;
|
||||
|
||||
class Configurator {
|
||||
private:
|
||||
ConfiguratorWindow wnd;
|
||||
|
||||
public:
|
||||
|
||||
Configurator();
|
||||
~Configurator();
|
||||
void run();
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
|
||||
#include "configurator_wnd.h"
|
||||
|
||||
namespace cfg {
|
||||
|
||||
enum class ConfigType {
|
||||
Config,
|
||||
KFControl,
|
||||
};
|
||||
|
||||
// globals
|
||||
extern bool CONFIGURATOR_STANDALONE;
|
||||
extern ConfigType CONFIGURATOR_TYPE;
|
||||
|
||||
class Configurator {
|
||||
private:
|
||||
ConfiguratorWindow wnd;
|
||||
|
||||
public:
|
||||
|
||||
Configurator();
|
||||
~Configurator();
|
||||
void run();
|
||||
};
|
||||
}
|
||||
|
||||
+173
-173
@@ -1,173 +1,173 @@
|
||||
#include "configurator_wnd.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "build/defs.h"
|
||||
#include "launcher/shutdown.h"
|
||||
#include "overlay/overlay.h"
|
||||
#include "util/logging.h"
|
||||
#include "cfg/configurator.h"
|
||||
|
||||
#include "icon.h"
|
||||
|
||||
static const char *CLASS_NAME = "ConfiguratorWindow";
|
||||
static std::string WINDOW_TITLE;
|
||||
static int WINDOW_SIZE_X = 800;
|
||||
static int WINDOW_SIZE_Y = 600;
|
||||
static HICON WINDOW_ICON = LoadIcon(GetModuleHandle(nullptr), MAKEINTRESOURCE(MAINICON));
|
||||
|
||||
cfg::ConfiguratorWindow::ConfiguratorWindow() {
|
||||
|
||||
// register the window class
|
||||
WNDCLASS wc {};
|
||||
wc.lpfnWndProc = ConfiguratorWindow::window_proc;
|
||||
wc.hInstance = GetModuleHandle(NULL);
|
||||
wc.lpszClassName = CLASS_NAME;
|
||||
wc.hbrBackground = NULL;
|
||||
wc.hIcon = WINDOW_ICON;
|
||||
RegisterClass(&wc);
|
||||
|
||||
// determine window title
|
||||
if (cfg::CONFIGURATOR_TYPE == cfg::ConfigType::Config) {
|
||||
WINDOW_TITLE = "SpiceTools Config (" + to_string(VERSION_STRING_CFG) + ")";
|
||||
WINDOW_SIZE_X = 800;
|
||||
WINDOW_SIZE_Y = 600;
|
||||
} else if (cfg::CONFIGURATOR_TYPE == cfg::ConfigType::KFControl) {
|
||||
WINDOW_TITLE = "KFControl (" + to_string(VERSION_STRING_CFG) + ")";
|
||||
WINDOW_SIZE_X = 400;
|
||||
WINDOW_SIZE_Y = 316;
|
||||
}
|
||||
|
||||
// open window
|
||||
this->hWnd = CreateWindowEx(
|
||||
0,
|
||||
CLASS_NAME,
|
||||
WINDOW_TITLE.c_str(),
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
NULL,
|
||||
NULL,
|
||||
GetModuleHandle(NULL),
|
||||
(LPVOID) this);
|
||||
}
|
||||
|
||||
cfg::ConfiguratorWindow::~ConfiguratorWindow() {
|
||||
|
||||
// close window
|
||||
DestroyWindow(this->hWnd);
|
||||
|
||||
// unregister class
|
||||
UnregisterClass(CLASS_NAME, GetModuleHandle(NULL));
|
||||
}
|
||||
|
||||
void cfg::ConfiguratorWindow::run() {
|
||||
|
||||
// show window
|
||||
SetWindowPos(this->hWnd, HWND_TOP, 0, 0, WINDOW_SIZE_X, WINDOW_SIZE_Y, 0);
|
||||
ShowWindow(this->hWnd, SW_SHOWNORMAL);
|
||||
UpdateWindow(this->hWnd);
|
||||
|
||||
// draw overlay in 60 FPS
|
||||
SetTimer(this->hWnd, 1, 1000 / 60, nullptr);
|
||||
|
||||
// window loop
|
||||
BOOL ret;
|
||||
MSG msg;
|
||||
while ((ret = GetMessage(&msg, nullptr, 0, 0)) != 0) {
|
||||
if (ret == -1) {
|
||||
break;
|
||||
} else {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CALLBACK cfg::ConfiguratorWindow::window_proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
switch (uMsg) {
|
||||
case WM_CHAR: {
|
||||
|
||||
// input characters if overlay is active
|
||||
if (overlay::OVERLAY && overlay::OVERLAY->has_focus()) {
|
||||
overlay::OVERLAY->input_char((unsigned int) wParam);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_CREATE: {
|
||||
|
||||
// set user data of window to class pointer
|
||||
auto create_struct = reinterpret_cast<LPCREATESTRUCT>(lParam);
|
||||
SetWindowLongPtrW(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(create_struct->lpCreateParams));
|
||||
|
||||
break;
|
||||
}
|
||||
case WM_CLOSE:
|
||||
case WM_DESTROY: {
|
||||
|
||||
// exit process
|
||||
launcher::shutdown();
|
||||
break;
|
||||
}
|
||||
case WM_TIMER: {
|
||||
|
||||
// update overlay
|
||||
if (overlay::OVERLAY) {
|
||||
overlay::OVERLAY->update();
|
||||
overlay::OVERLAY->set_active(true);
|
||||
overlay::OVERLAY->new_frame();
|
||||
overlay::OVERLAY->render();
|
||||
}
|
||||
|
||||
// repaint window
|
||||
InvalidateRect(hWnd, nullptr, TRUE);
|
||||
break;
|
||||
}
|
||||
case WM_ERASEBKGND: {
|
||||
return 1;
|
||||
}
|
||||
case WM_PAINT: {
|
||||
|
||||
// render overlay
|
||||
if (overlay::OVERLAY) {
|
||||
|
||||
// get pixel data
|
||||
int width, height;
|
||||
uint32_t *pixel_data = overlay::OVERLAY->sw_get_pixel_data(&width, &height);
|
||||
if (width > 0 && height > 0) {
|
||||
|
||||
// create bitmap
|
||||
HBITMAP bitmap = CreateBitmap(width, height, 1, 8 * sizeof(uint32_t), pixel_data);
|
||||
|
||||
// prepare paint
|
||||
PAINTSTRUCT paint{};
|
||||
HDC hdc = BeginPaint(hWnd, &paint);
|
||||
HDC hdcMem = CreateCompatibleDC(hdc);
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
|
||||
// draw bitmap
|
||||
SelectObject(hdcMem, bitmap);
|
||||
BitBlt(hdc, paint.rcPaint.left, paint.rcPaint.top,
|
||||
paint.rcPaint.right - paint.rcPaint.left,
|
||||
paint.rcPaint.bottom - paint.rcPaint.top,
|
||||
hdcMem, paint.rcPaint.left, paint.rcPaint.top, SRCCOPY);
|
||||
|
||||
// delete bitmap
|
||||
DeleteObject(bitmap);
|
||||
|
||||
// clean up
|
||||
DeleteDC(hdcMem);
|
||||
EndPaint(hWnd, &paint);
|
||||
} else {
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
} else {
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#include "configurator_wnd.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include "build/defs.h"
|
||||
#include "launcher/shutdown.h"
|
||||
#include "overlay/overlay.h"
|
||||
#include "util/logging.h"
|
||||
#include "cfg/configurator.h"
|
||||
|
||||
#include "icon.h"
|
||||
|
||||
static const char *CLASS_NAME = "ConfiguratorWindow";
|
||||
static std::string WINDOW_TITLE;
|
||||
static int WINDOW_SIZE_X = 800;
|
||||
static int WINDOW_SIZE_Y = 600;
|
||||
static HICON WINDOW_ICON = LoadIcon(GetModuleHandle(nullptr), MAKEINTRESOURCE(MAINICON));
|
||||
|
||||
cfg::ConfiguratorWindow::ConfiguratorWindow() {
|
||||
|
||||
// register the window class
|
||||
WNDCLASS wc {};
|
||||
wc.lpfnWndProc = ConfiguratorWindow::window_proc;
|
||||
wc.hInstance = GetModuleHandle(NULL);
|
||||
wc.lpszClassName = CLASS_NAME;
|
||||
wc.hbrBackground = NULL;
|
||||
wc.hIcon = WINDOW_ICON;
|
||||
RegisterClass(&wc);
|
||||
|
||||
// determine window title
|
||||
if (cfg::CONFIGURATOR_TYPE == cfg::ConfigType::Config) {
|
||||
WINDOW_TITLE = "SpiceTools Config (" + to_string(VERSION_STRING_CFG) + ")";
|
||||
WINDOW_SIZE_X = 800;
|
||||
WINDOW_SIZE_Y = 600;
|
||||
} else if (cfg::CONFIGURATOR_TYPE == cfg::ConfigType::KFControl) {
|
||||
WINDOW_TITLE = "KFControl (" + to_string(VERSION_STRING_CFG) + ")";
|
||||
WINDOW_SIZE_X = 400;
|
||||
WINDOW_SIZE_Y = 316;
|
||||
}
|
||||
|
||||
// open window
|
||||
this->hWnd = CreateWindowEx(
|
||||
0,
|
||||
CLASS_NAME,
|
||||
WINDOW_TITLE.c_str(),
|
||||
WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
NULL,
|
||||
NULL,
|
||||
GetModuleHandle(NULL),
|
||||
(LPVOID) this);
|
||||
}
|
||||
|
||||
cfg::ConfiguratorWindow::~ConfiguratorWindow() {
|
||||
|
||||
// close window
|
||||
DestroyWindow(this->hWnd);
|
||||
|
||||
// unregister class
|
||||
UnregisterClass(CLASS_NAME, GetModuleHandle(NULL));
|
||||
}
|
||||
|
||||
void cfg::ConfiguratorWindow::run() {
|
||||
|
||||
// show window
|
||||
SetWindowPos(this->hWnd, HWND_TOP, 0, 0, WINDOW_SIZE_X, WINDOW_SIZE_Y, 0);
|
||||
ShowWindow(this->hWnd, SW_SHOWNORMAL);
|
||||
UpdateWindow(this->hWnd);
|
||||
|
||||
// draw overlay in 60 FPS
|
||||
SetTimer(this->hWnd, 1, 1000 / 60, nullptr);
|
||||
|
||||
// window loop
|
||||
BOOL ret;
|
||||
MSG msg;
|
||||
while ((ret = GetMessage(&msg, nullptr, 0, 0)) != 0) {
|
||||
if (ret == -1) {
|
||||
break;
|
||||
} else {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LRESULT CALLBACK cfg::ConfiguratorWindow::window_proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
switch (uMsg) {
|
||||
case WM_CHAR: {
|
||||
|
||||
// input characters if overlay is active
|
||||
if (overlay::OVERLAY && overlay::OVERLAY->has_focus()) {
|
||||
overlay::OVERLAY->input_char((unsigned int) wParam);
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case WM_CREATE: {
|
||||
|
||||
// set user data of window to class pointer
|
||||
auto create_struct = reinterpret_cast<LPCREATESTRUCT>(lParam);
|
||||
SetWindowLongPtrW(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(create_struct->lpCreateParams));
|
||||
|
||||
break;
|
||||
}
|
||||
case WM_CLOSE:
|
||||
case WM_DESTROY: {
|
||||
|
||||
// exit process
|
||||
launcher::shutdown();
|
||||
break;
|
||||
}
|
||||
case WM_TIMER: {
|
||||
|
||||
// update overlay
|
||||
if (overlay::OVERLAY) {
|
||||
overlay::OVERLAY->update();
|
||||
overlay::OVERLAY->set_active(true);
|
||||
overlay::OVERLAY->new_frame();
|
||||
overlay::OVERLAY->render();
|
||||
}
|
||||
|
||||
// repaint window
|
||||
InvalidateRect(hWnd, nullptr, TRUE);
|
||||
break;
|
||||
}
|
||||
case WM_ERASEBKGND: {
|
||||
return 1;
|
||||
}
|
||||
case WM_PAINT: {
|
||||
|
||||
// render overlay
|
||||
if (overlay::OVERLAY) {
|
||||
|
||||
// get pixel data
|
||||
int width, height;
|
||||
uint32_t *pixel_data = overlay::OVERLAY->sw_get_pixel_data(&width, &height);
|
||||
if (width > 0 && height > 0) {
|
||||
|
||||
// create bitmap
|
||||
HBITMAP bitmap = CreateBitmap(width, height, 1, 8 * sizeof(uint32_t), pixel_data);
|
||||
|
||||
// prepare paint
|
||||
PAINTSTRUCT paint{};
|
||||
HDC hdc = BeginPaint(hWnd, &paint);
|
||||
HDC hdcMem = CreateCompatibleDC(hdc);
|
||||
SetBkMode(hdc, TRANSPARENT);
|
||||
|
||||
// draw bitmap
|
||||
SelectObject(hdcMem, bitmap);
|
||||
BitBlt(hdc, paint.rcPaint.left, paint.rcPaint.top,
|
||||
paint.rcPaint.right - paint.rcPaint.left,
|
||||
paint.rcPaint.bottom - paint.rcPaint.top,
|
||||
hdcMem, paint.rcPaint.left, paint.rcPaint.top, SRCCOPY);
|
||||
|
||||
// delete bitmap
|
||||
DeleteObject(bitmap);
|
||||
|
||||
// clean up
|
||||
DeleteDC(hdcMem);
|
||||
EndPaint(hWnd, &paint);
|
||||
} else {
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
} else {
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+19
-19
@@ -1,19 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
namespace cfg {
|
||||
|
||||
class ConfiguratorWindow {
|
||||
public:
|
||||
|
||||
HWND hWnd;
|
||||
|
||||
ConfiguratorWindow();
|
||||
~ConfiguratorWindow();
|
||||
|
||||
void run();
|
||||
|
||||
static LRESULT CALLBACK window_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
};
|
||||
}
|
||||
#pragma once
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
namespace cfg {
|
||||
|
||||
class ConfiguratorWindow {
|
||||
public:
|
||||
|
||||
HWND hWnd;
|
||||
|
||||
ConfiguratorWindow();
|
||||
~ConfiguratorWindow();
|
||||
|
||||
void run();
|
||||
|
||||
static LRESULT CALLBACK window_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
};
|
||||
}
|
||||
|
||||
+25
-25
@@ -1,25 +1,25 @@
|
||||
#include "game.h"
|
||||
|
||||
/////////////////////////
|
||||
/// Private Functions ///
|
||||
/////////////////////////
|
||||
|
||||
// add button items
|
||||
void Game::addItem(Button button) {
|
||||
this->buttons.push_back(std::move(button));
|
||||
}
|
||||
|
||||
// add analog items
|
||||
void Game::addItem(Analog analog) {
|
||||
this->analogs.push_back(std::move(analog));
|
||||
}
|
||||
|
||||
// add light items
|
||||
void Game::addItem(Light light) {
|
||||
this->lights.push_back(std::move(light));
|
||||
}
|
||||
|
||||
// add option items
|
||||
void Game::addItem(Option option) {
|
||||
this->options.push_back(std::move(option));
|
||||
}
|
||||
#include "game.h"
|
||||
|
||||
/////////////////////////
|
||||
/// Private Functions ///
|
||||
/////////////////////////
|
||||
|
||||
// add button items
|
||||
void Game::addItem(Button button) {
|
||||
this->buttons.push_back(std::move(button));
|
||||
}
|
||||
|
||||
// add analog items
|
||||
void Game::addItem(Analog analog) {
|
||||
this->analogs.push_back(std::move(analog));
|
||||
}
|
||||
|
||||
// add light items
|
||||
void Game::addItem(Light light) {
|
||||
this->lights.push_back(std::move(light));
|
||||
}
|
||||
|
||||
// add option items
|
||||
void Game::addItem(Option option) {
|
||||
this->options.push_back(std::move(option));
|
||||
}
|
||||
|
||||
+84
-84
@@ -1,84 +1,84 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <typeinfo>
|
||||
#include <iostream>
|
||||
|
||||
#include "button.h"
|
||||
#include "analog.h"
|
||||
#include "light.h"
|
||||
#include "option.h"
|
||||
#include "external/tinyxml2/tinyxml2.h"
|
||||
|
||||
class Game {
|
||||
public:
|
||||
explicit Game(std::string game_name) : game_name(std::move(game_name)) {};
|
||||
|
||||
/*
|
||||
template<typename T, typename... Rest>
|
||||
Game(std::string gameName) : gameName(std::move(gameName)) {};
|
||||
*/
|
||||
|
||||
~Game() = default;
|
||||
|
||||
inline const std::string &getGameName() const {
|
||||
return this->game_name;
|
||||
};
|
||||
|
||||
inline std::vector<std::string> &getDLLNames() {
|
||||
return this->dll_names;
|
||||
}
|
||||
|
||||
inline void addDLLName(std::string dll_name) {
|
||||
this->dll_names.push_back(std::move(dll_name));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void addItems(T t) {
|
||||
this->addItem(t);
|
||||
}
|
||||
|
||||
template<typename T, typename... Rest>
|
||||
void addItems(T t, Rest... rest) {
|
||||
this->addItem(t);
|
||||
this->addItems(rest...);
|
||||
}
|
||||
|
||||
inline std::vector<Button> &getButtons() {
|
||||
return this->buttons;
|
||||
}
|
||||
inline const std::vector<Button> &getButtons() const {
|
||||
return this->buttons;
|
||||
}
|
||||
inline std::vector<Analog> &getAnalogs() {
|
||||
return this->analogs;
|
||||
}
|
||||
inline const std::vector<Analog> &getAnalogs() const {
|
||||
return this->analogs;
|
||||
}
|
||||
inline std::vector<Light> &getLights() {
|
||||
return this->lights;
|
||||
}
|
||||
inline const std::vector<Light> &getLights() const {
|
||||
return this->lights;
|
||||
}
|
||||
inline std::vector<Option> &getOptions() {
|
||||
return this->options;
|
||||
}
|
||||
inline const std::vector<Option> &getOptions() const {
|
||||
return this->options;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string game_name;
|
||||
std::vector<std::string> dll_names;
|
||||
std::vector<Button> buttons;
|
||||
std::vector<Analog> analogs;
|
||||
std::vector<Light> lights;
|
||||
std::vector<Option> options;
|
||||
|
||||
void addItem(Button button);
|
||||
void addItem(Analog analog);
|
||||
void addItem(Light light);
|
||||
void addItem(Option option);
|
||||
};
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <typeinfo>
|
||||
#include <iostream>
|
||||
|
||||
#include "button.h"
|
||||
#include "analog.h"
|
||||
#include "light.h"
|
||||
#include "option.h"
|
||||
#include "external/tinyxml2/tinyxml2.h"
|
||||
|
||||
class Game {
|
||||
public:
|
||||
explicit Game(std::string game_name) : game_name(std::move(game_name)) {};
|
||||
|
||||
/*
|
||||
template<typename T, typename... Rest>
|
||||
Game(std::string gameName) : gameName(std::move(gameName)) {};
|
||||
*/
|
||||
|
||||
~Game() = default;
|
||||
|
||||
inline const std::string &getGameName() const {
|
||||
return this->game_name;
|
||||
};
|
||||
|
||||
inline std::vector<std::string> &getDLLNames() {
|
||||
return this->dll_names;
|
||||
}
|
||||
|
||||
inline void addDLLName(std::string dll_name) {
|
||||
this->dll_names.push_back(std::move(dll_name));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void addItems(T t) {
|
||||
this->addItem(t);
|
||||
}
|
||||
|
||||
template<typename T, typename... Rest>
|
||||
void addItems(T t, Rest... rest) {
|
||||
this->addItem(t);
|
||||
this->addItems(rest...);
|
||||
}
|
||||
|
||||
inline std::vector<Button> &getButtons() {
|
||||
return this->buttons;
|
||||
}
|
||||
inline const std::vector<Button> &getButtons() const {
|
||||
return this->buttons;
|
||||
}
|
||||
inline std::vector<Analog> &getAnalogs() {
|
||||
return this->analogs;
|
||||
}
|
||||
inline const std::vector<Analog> &getAnalogs() const {
|
||||
return this->analogs;
|
||||
}
|
||||
inline std::vector<Light> &getLights() {
|
||||
return this->lights;
|
||||
}
|
||||
inline const std::vector<Light> &getLights() const {
|
||||
return this->lights;
|
||||
}
|
||||
inline std::vector<Option> &getOptions() {
|
||||
return this->options;
|
||||
}
|
||||
inline const std::vector<Option> &getOptions() const {
|
||||
return this->options;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string game_name;
|
||||
std::vector<std::string> dll_names;
|
||||
std::vector<Button> buttons;
|
||||
std::vector<Analog> analogs;
|
||||
std::vector<Light> lights;
|
||||
std::vector<Option> options;
|
||||
|
||||
void addItem(Button button);
|
||||
void addItem(Analog analog);
|
||||
void addItem(Light light);
|
||||
void addItem(Option option);
|
||||
};
|
||||
|
||||
+3
-3
@@ -1,3 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define MAINICON 20
|
||||
#pragma once
|
||||
|
||||
#define MAINICON 20
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
#include "icon.h"
|
||||
|
||||
#include "icon.h"
|
||||
|
||||
MAINICON ICON "icon.ico"
|
||||
+73
-73
@@ -1,73 +1,73 @@
|
||||
#include "light.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "rawinput/piuio.h"
|
||||
#include "rawinput/rawinput.h"
|
||||
#include "rawinput/sextet.h"
|
||||
#include "util/logging.h"
|
||||
|
||||
std::string Light::getDisplayString(rawinput::RawInputManager* manager) {
|
||||
|
||||
// get index string
|
||||
std::string index_string = fmt::format("{:#x}", index);
|
||||
|
||||
// device must be existing
|
||||
if (this->deviceIdentifier.empty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// get device
|
||||
auto device = manager->devices_get(this->deviceIdentifier);
|
||||
if (!device) {
|
||||
return "Device missing (" + index_string + ")";
|
||||
}
|
||||
|
||||
// return string based on device type
|
||||
switch (device->type) {
|
||||
case rawinput::HID: {
|
||||
auto hid = device->hidInfo;
|
||||
unsigned int hid_index = index;
|
||||
|
||||
// check button output caps
|
||||
if (hid_index < hid->button_output_caps_names.size()) {
|
||||
return hid->button_output_caps_names[hid_index] +
|
||||
" (" + index_string + " - " + device->desc + ")";
|
||||
} else {
|
||||
hid_index -= hid->button_output_caps_names.size();
|
||||
}
|
||||
|
||||
// check value output caps
|
||||
if (hid_index < hid->value_output_caps_names.size()) {
|
||||
return hid->value_output_caps_names[hid_index] +
|
||||
" (" + index_string + " - " + device->desc + ")";
|
||||
}
|
||||
|
||||
// not found
|
||||
return "Invalid Light (" + index_string + ")";
|
||||
}
|
||||
case rawinput::SEXTET_OUTPUT: {
|
||||
|
||||
// get light name of sextet device
|
||||
if (index < rawinput::SextetDevice::LIGHT_COUNT) {
|
||||
return rawinput::SextetDevice::LIGHT_NAMES[index] + " (" + index_string + ")";
|
||||
}
|
||||
|
||||
// not found
|
||||
return "Invalid Sextet Light (" + index_string + ")";
|
||||
}
|
||||
case rawinput::PIUIO_DEVICE: {
|
||||
|
||||
// get light name of PIUIO device
|
||||
if (index < rawinput::PIUIO::PIUIO_MAX_NUM_OF_LIGHTS) {
|
||||
return rawinput::PIUIO::LIGHT_NAMES[index] + " (" + index_string + ")";
|
||||
}
|
||||
|
||||
return "Invalid PIUIO Light (" + index_string + ")";
|
||||
}
|
||||
case rawinput::DESTROYED:
|
||||
return "Unplugged device (" + index_string + ")";
|
||||
default:
|
||||
return "Unknown Light (" + index_string + ")";
|
||||
}
|
||||
}
|
||||
#include "light.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "rawinput/piuio.h"
|
||||
#include "rawinput/rawinput.h"
|
||||
#include "rawinput/sextet.h"
|
||||
#include "util/logging.h"
|
||||
|
||||
std::string Light::getDisplayString(rawinput::RawInputManager* manager) {
|
||||
|
||||
// get index string
|
||||
std::string index_string = fmt::format("{:#x}", index);
|
||||
|
||||
// device must be existing
|
||||
if (this->deviceIdentifier.empty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// get device
|
||||
auto device = manager->devices_get(this->deviceIdentifier);
|
||||
if (!device) {
|
||||
return "Device missing (" + index_string + ")";
|
||||
}
|
||||
|
||||
// return string based on device type
|
||||
switch (device->type) {
|
||||
case rawinput::HID: {
|
||||
auto hid = device->hidInfo;
|
||||
unsigned int hid_index = index;
|
||||
|
||||
// check button output caps
|
||||
if (hid_index < hid->button_output_caps_names.size()) {
|
||||
return hid->button_output_caps_names[hid_index] +
|
||||
" (" + index_string + " - " + device->desc + ")";
|
||||
} else {
|
||||
hid_index -= hid->button_output_caps_names.size();
|
||||
}
|
||||
|
||||
// check value output caps
|
||||
if (hid_index < hid->value_output_caps_names.size()) {
|
||||
return hid->value_output_caps_names[hid_index] +
|
||||
" (" + index_string + " - " + device->desc + ")";
|
||||
}
|
||||
|
||||
// not found
|
||||
return "Invalid Light (" + index_string + ")";
|
||||
}
|
||||
case rawinput::SEXTET_OUTPUT: {
|
||||
|
||||
// get light name of sextet device
|
||||
if (index < rawinput::SextetDevice::LIGHT_COUNT) {
|
||||
return rawinput::SextetDevice::LIGHT_NAMES[index] + " (" + index_string + ")";
|
||||
}
|
||||
|
||||
// not found
|
||||
return "Invalid Sextet Light (" + index_string + ")";
|
||||
}
|
||||
case rawinput::PIUIO_DEVICE: {
|
||||
|
||||
// get light name of PIUIO device
|
||||
if (index < rawinput::PIUIO::PIUIO_MAX_NUM_OF_LIGHTS) {
|
||||
return rawinput::PIUIO::LIGHT_NAMES[index] + " (" + index_string + ")";
|
||||
}
|
||||
|
||||
return "Invalid PIUIO Light (" + index_string + ")";
|
||||
}
|
||||
case rawinput::DESTROYED:
|
||||
return "Unplugged device (" + index_string + ")";
|
||||
default:
|
||||
return "Unknown Light (" + index_string + ")";
|
||||
}
|
||||
}
|
||||
|
||||
+68
-68
@@ -1,68 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace rawinput {
|
||||
class RawInputManager;
|
||||
}
|
||||
|
||||
class Light {
|
||||
private:
|
||||
std::vector<Light> alternatives;
|
||||
std::string lightName;
|
||||
std::string deviceIdentifier = "";
|
||||
unsigned int index = 0;
|
||||
|
||||
public:
|
||||
float last_state = 0.f;
|
||||
|
||||
// overrides
|
||||
bool override_enabled = false;
|
||||
float override_state = 0.f;
|
||||
|
||||
explicit Light(std::string lightName) : lightName(std::move(lightName)) {};
|
||||
|
||||
std::string getDisplayString(rawinput::RawInputManager* manager);
|
||||
|
||||
inline std::vector<Light> &getAlternatives() {
|
||||
return this->alternatives;
|
||||
}
|
||||
|
||||
inline bool isSet() const {
|
||||
if (this->override_enabled) {
|
||||
return true;
|
||||
}
|
||||
if (!this->deviceIdentifier.empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (auto &alternative : this->alternatives) {
|
||||
if (!alternative.deviceIdentifier.empty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline const std::string &getName() const {
|
||||
return this->lightName;
|
||||
}
|
||||
|
||||
inline const std::string &getDeviceIdentifier() const {
|
||||
return this->deviceIdentifier;
|
||||
}
|
||||
|
||||
inline void setDeviceIdentifier(std::string deviceIdentifier) {
|
||||
this->deviceIdentifier = std::move(deviceIdentifier);
|
||||
}
|
||||
|
||||
inline unsigned int getIndex() const {
|
||||
return this->index;
|
||||
}
|
||||
|
||||
inline void setIndex(unsigned int index) {
|
||||
this->index = index;
|
||||
}
|
||||
};
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace rawinput {
|
||||
class RawInputManager;
|
||||
}
|
||||
|
||||
class Light {
|
||||
private:
|
||||
std::vector<Light> alternatives;
|
||||
std::string lightName;
|
||||
std::string deviceIdentifier = "";
|
||||
unsigned int index = 0;
|
||||
|
||||
public:
|
||||
float last_state = 0.f;
|
||||
|
||||
// overrides
|
||||
bool override_enabled = false;
|
||||
float override_state = 0.f;
|
||||
|
||||
explicit Light(std::string lightName) : lightName(std::move(lightName)) {};
|
||||
|
||||
std::string getDisplayString(rawinput::RawInputManager* manager);
|
||||
|
||||
inline std::vector<Light> &getAlternatives() {
|
||||
return this->alternatives;
|
||||
}
|
||||
|
||||
inline bool isSet() const {
|
||||
if (this->override_enabled) {
|
||||
return true;
|
||||
}
|
||||
if (!this->deviceIdentifier.empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (auto &alternative : this->alternatives) {
|
||||
if (!alternative.deviceIdentifier.empty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline const std::string &getName() const {
|
||||
return this->lightName;
|
||||
}
|
||||
|
||||
inline const std::string &getDeviceIdentifier() const {
|
||||
return this->deviceIdentifier;
|
||||
}
|
||||
|
||||
inline void setDeviceIdentifier(std::string deviceIdentifier) {
|
||||
this->deviceIdentifier = std::move(deviceIdentifier);
|
||||
}
|
||||
|
||||
inline unsigned int getIndex() const {
|
||||
return this->index;
|
||||
}
|
||||
|
||||
inline void setIndex(unsigned int index) {
|
||||
this->index = index;
|
||||
}
|
||||
};
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
|
||||
#define RT_MANIFEST 24
|
||||
#pragma once
|
||||
|
||||
#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1
|
||||
#define RT_MANIFEST 24
|
||||
|
||||
+28
-28
@@ -1,29 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity
|
||||
version="1.0.0.0"
|
||||
processorArchitecture="*"
|
||||
name="spicecfg.exe"
|
||||
type="win32"
|
||||
/>
|
||||
<description>SpiceTools Config</description>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity
|
||||
version="1.0.0.0"
|
||||
processorArchitecture="*"
|
||||
name="spicecfg.exe"
|
||||
type="win32"
|
||||
/>
|
||||
<description>SpiceTools Config</description>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
</assembly>
|
||||
+30
-30
@@ -1,30 +1,30 @@
|
||||
#include "manifest.h"
|
||||
#include "winuser.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "manifest.manifest"
|
||||
#endif
|
||||
|
||||
1 VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION 1,0,0,0
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "080904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", ""
|
||||
VALUE "FileDescription", "SpiceTools Configuration Utility"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
VALUE "InternalName", "spicecfg"
|
||||
VALUE "LegalCopyright", ""
|
||||
VALUE "OriginalFilename", "spicecfg.exe"
|
||||
VALUE "ProductName", "SpiceTools Configuration"
|
||||
VALUE "ProductVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x809, 1252
|
||||
END
|
||||
END
|
||||
#include "manifest.h"
|
||||
#include "winuser.h"
|
||||
|
||||
#ifdef __GNUC__
|
||||
CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "manifest.manifest"
|
||||
#endif
|
||||
|
||||
1 VERSIONINFO
|
||||
FILEVERSION 1,0,0,0
|
||||
PRODUCTVERSION 1,0,0,0
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "080904E4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", ""
|
||||
VALUE "FileDescription", "SpiceTools Configuration Utility"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
VALUE "InternalName", "spicecfg"
|
||||
VALUE "LegalCopyright", ""
|
||||
VALUE "OriginalFilename", "spicecfg.exe"
|
||||
VALUE "ProductName", "SpiceTools Configuration"
|
||||
VALUE "ProductVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x809, 1252
|
||||
END
|
||||
END
|
||||
|
||||
+84
-84
@@ -1,84 +1,84 @@
|
||||
#include "option.h"
|
||||
|
||||
#include "util/logging.h"
|
||||
|
||||
void Option::value_add(std::string new_value) {
|
||||
|
||||
// put in primary slot if possible
|
||||
if (this->value.empty()) {
|
||||
this->value = std::move(new_value);
|
||||
return;
|
||||
}
|
||||
|
||||
// add new alternative
|
||||
this->alternatives.emplace_back(this->definition, std::move(new_value));
|
||||
}
|
||||
|
||||
bool Option::has_alternatives() const {
|
||||
return !this->alternatives.empty();
|
||||
}
|
||||
|
||||
bool Option::value_bool() const {
|
||||
if (this->definition.type != OptionType::Bool) {
|
||||
log_fatal("option", "value_bool() called on {}/{}", this->definition.title, this->definition.type);
|
||||
}
|
||||
return !this->value.empty();
|
||||
}
|
||||
|
||||
const std::string &Option::value_text() const {
|
||||
if (this->definition.type != OptionType::Text && this->definition.type != OptionType::Enum) {
|
||||
log_fatal("option", "value_text() called on {}/{}", this->definition.title, this->definition.type);
|
||||
}
|
||||
return this->value;
|
||||
}
|
||||
|
||||
std::vector<std::string> Option::values() const {
|
||||
std::vector<std::string> values;
|
||||
|
||||
if (!this->is_active()) {
|
||||
return values;
|
||||
}
|
||||
|
||||
values.push_back(this->value);
|
||||
|
||||
for (auto &alt : this->alternatives) {
|
||||
if (alt.is_active()) {
|
||||
values.push_back(alt.value);
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
std::vector<std::string> Option::values_text() const {
|
||||
std::vector<std::string> values;
|
||||
|
||||
if (!this->is_active()) {
|
||||
return values;
|
||||
}
|
||||
|
||||
values.push_back(this->value_text());
|
||||
|
||||
for (auto &alt : this->alternatives) {
|
||||
if (alt.is_active()) {
|
||||
values.push_back(alt.value_text());
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
int Option::value_int() const {
|
||||
if (this->definition.type != OptionType::Integer && this->definition.type != OptionType::Enum) {
|
||||
log_fatal("option", "value_int() called on {}/{}", this->definition.title, this->definition.type);
|
||||
return 0;
|
||||
}
|
||||
char *p;
|
||||
auto res = strtol(this->value.c_str(), &p, 10);
|
||||
if (*p) {
|
||||
log_fatal("option", "tried to convert {} to integer ({})", this->value, this->definition.title);
|
||||
return 0;
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
#include "option.h"
|
||||
|
||||
#include "util/logging.h"
|
||||
|
||||
void Option::value_add(std::string new_value) {
|
||||
|
||||
// put in primary slot if possible
|
||||
if (this->value.empty()) {
|
||||
this->value = std::move(new_value);
|
||||
return;
|
||||
}
|
||||
|
||||
// add new alternative
|
||||
this->alternatives.emplace_back(this->definition, std::move(new_value));
|
||||
}
|
||||
|
||||
bool Option::has_alternatives() const {
|
||||
return !this->alternatives.empty();
|
||||
}
|
||||
|
||||
bool Option::value_bool() const {
|
||||
if (this->definition.type != OptionType::Bool) {
|
||||
log_fatal("option", "value_bool() called on {}/{}", this->definition.title, this->definition.type);
|
||||
}
|
||||
return !this->value.empty();
|
||||
}
|
||||
|
||||
const std::string &Option::value_text() const {
|
||||
if (this->definition.type != OptionType::Text && this->definition.type != OptionType::Enum) {
|
||||
log_fatal("option", "value_text() called on {}/{}", this->definition.title, this->definition.type);
|
||||
}
|
||||
return this->value;
|
||||
}
|
||||
|
||||
std::vector<std::string> Option::values() const {
|
||||
std::vector<std::string> values;
|
||||
|
||||
if (!this->is_active()) {
|
||||
return values;
|
||||
}
|
||||
|
||||
values.push_back(this->value);
|
||||
|
||||
for (auto &alt : this->alternatives) {
|
||||
if (alt.is_active()) {
|
||||
values.push_back(alt.value);
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
std::vector<std::string> Option::values_text() const {
|
||||
std::vector<std::string> values;
|
||||
|
||||
if (!this->is_active()) {
|
||||
return values;
|
||||
}
|
||||
|
||||
values.push_back(this->value_text());
|
||||
|
||||
for (auto &alt : this->alternatives) {
|
||||
if (alt.is_active()) {
|
||||
values.push_back(alt.value_text());
|
||||
}
|
||||
}
|
||||
|
||||
return values;
|
||||
}
|
||||
|
||||
int Option::value_int() const {
|
||||
if (this->definition.type != OptionType::Integer && this->definition.type != OptionType::Enum) {
|
||||
log_fatal("option", "value_int() called on {}/{}", this->definition.title, this->definition.type);
|
||||
return 0;
|
||||
}
|
||||
char *p;
|
||||
auto res = strtol(this->value.c_str(), &p, 10);
|
||||
if (*p) {
|
||||
log_fatal("option", "tried to convert {} to integer ({})", this->value, this->definition.title);
|
||||
return 0;
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
+58
-58
@@ -1,58 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
enum class OptionType {
|
||||
Bool,
|
||||
Text,
|
||||
Integer,
|
||||
Enum,
|
||||
};
|
||||
|
||||
struct OptionDefinition {
|
||||
std::string title;
|
||||
std::string name;
|
||||
std::string desc;
|
||||
OptionType type;
|
||||
bool hidden = false;
|
||||
std::string setting_name = "";
|
||||
std::string game_name = "";
|
||||
std::string category = "Development";
|
||||
bool sensitive = false;
|
||||
std::vector<std::pair<std::string, std::string>> elements = {};
|
||||
};
|
||||
|
||||
class Option {
|
||||
private:
|
||||
OptionDefinition definition;
|
||||
|
||||
public:
|
||||
std::string value;
|
||||
std::vector<Option> alternatives;
|
||||
bool disabled = false;
|
||||
|
||||
explicit Option(OptionDefinition definition, std::string value = "") :
|
||||
definition(std::move(definition)), value(std::move(value)) {};
|
||||
|
||||
inline const OptionDefinition &get_definition() const {
|
||||
return this->definition;
|
||||
}
|
||||
inline void set_definition(OptionDefinition definition) {
|
||||
this->definition = std::move(definition);
|
||||
}
|
||||
|
||||
inline bool is_active() const {
|
||||
return !this->value.empty();
|
||||
}
|
||||
|
||||
void value_add(std::string new_value);
|
||||
|
||||
bool has_alternatives() const;
|
||||
bool value_bool() const;
|
||||
const std::string &value_text() const;
|
||||
std::vector<std::string> values() const;
|
||||
std::vector<std::string> values_text() const;
|
||||
int value_int() const;
|
||||
};
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
enum class OptionType {
|
||||
Bool,
|
||||
Text,
|
||||
Integer,
|
||||
Enum,
|
||||
};
|
||||
|
||||
struct OptionDefinition {
|
||||
std::string title;
|
||||
std::string name;
|
||||
std::string desc;
|
||||
OptionType type;
|
||||
bool hidden = false;
|
||||
std::string setting_name = "";
|
||||
std::string game_name = "";
|
||||
std::string category = "Development";
|
||||
bool sensitive = false;
|
||||
std::vector<std::pair<std::string, std::string>> elements = {};
|
||||
};
|
||||
|
||||
class Option {
|
||||
private:
|
||||
OptionDefinition definition;
|
||||
|
||||
public:
|
||||
std::string value;
|
||||
std::vector<Option> alternatives;
|
||||
bool disabled = false;
|
||||
|
||||
explicit Option(OptionDefinition definition, std::string value = "") :
|
||||
definition(std::move(definition)), value(std::move(value)) {};
|
||||
|
||||
inline const OptionDefinition &get_definition() const {
|
||||
return this->definition;
|
||||
}
|
||||
inline void set_definition(OptionDefinition definition) {
|
||||
this->definition = std::move(definition);
|
||||
}
|
||||
|
||||
inline bool is_active() const {
|
||||
return !this->value.empty();
|
||||
}
|
||||
|
||||
void value_add(std::string new_value);
|
||||
|
||||
bool has_alternatives() const;
|
||||
bool value_bool() const;
|
||||
const std::string &value_text() const;
|
||||
std::vector<std::string> values() const;
|
||||
std::vector<std::string> values_text() const;
|
||||
int value_int() const;
|
||||
};
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define IDR_CHANGELOG 130
|
||||
#define IDR_LICENSES 131
|
||||
#define IDR_PATCHES 132
|
||||
#define IDR_README 133
|
||||
#pragma once
|
||||
|
||||
#define IDR_CHANGELOG 130
|
||||
#define IDR_LICENSES 131
|
||||
#define IDR_PATCHES 132
|
||||
#define IDR_README 133
|
||||
|
||||
+122
-122
@@ -1,122 +1,122 @@
|
||||
#include "screen_resize.h"
|
||||
|
||||
#include "external/rapidjson/document.h"
|
||||
#include "external/rapidjson/writer.h"
|
||||
#include "util/utils.h"
|
||||
#include "util/fileutils.h"
|
||||
|
||||
using namespace rapidjson;
|
||||
|
||||
namespace cfg {
|
||||
|
||||
// globals
|
||||
std::unique_ptr<cfg::ScreenResize> SCREENRESIZE;
|
||||
|
||||
ScreenResize::ScreenResize() {
|
||||
this->config_path = std::string(getenv("APPDATA")) + "\\spicetools_screen_resize.json";
|
||||
if (fileutils::file_exists(this->config_path)) {
|
||||
this->config_load();
|
||||
}
|
||||
}
|
||||
|
||||
ScreenResize::~ScreenResize() {
|
||||
}
|
||||
|
||||
void ScreenResize::config_load() {
|
||||
log_info("ScreenResize", "loading config");
|
||||
|
||||
std::string config = fileutils::text_read(this->config_path);
|
||||
if (!config.empty()) {
|
||||
|
||||
// parse document
|
||||
Document doc;
|
||||
doc.Parse(config.c_str());
|
||||
|
||||
// check parse error
|
||||
auto error = doc.GetParseError();
|
||||
if (error) {
|
||||
log_warning("ScreenResize", "config parse error: {}", error);
|
||||
}
|
||||
|
||||
// verify root is a dict
|
||||
if (doc.IsObject()) {
|
||||
bool valid = true;
|
||||
auto offset_x = doc.FindMember("offset_x");
|
||||
if (offset_x == doc.MemberEnd() || !offset_x->value.IsInt()) {
|
||||
log_warning("ScreenResize", "offset_x not found");
|
||||
valid = false;
|
||||
}
|
||||
auto offset_y = doc.FindMember("offset_y");
|
||||
if (offset_y == doc.MemberEnd() || !offset_y->value.IsInt()) {
|
||||
log_warning("ScreenResize", "offset_y not found");
|
||||
valid = false;
|
||||
}
|
||||
auto scale_x = doc.FindMember("scale_x");
|
||||
if (scale_x == doc.MemberEnd() || !scale_x->value.IsDouble()) {
|
||||
log_warning("ScreenResize", "scale_x not found");
|
||||
valid = false;
|
||||
}
|
||||
auto scale_y = doc.FindMember("scale_y");
|
||||
if (scale_y == doc.MemberEnd() || !scale_y->value.IsDouble()) {
|
||||
log_warning("ScreenResize", "scale_y not found");
|
||||
valid = false;
|
||||
}
|
||||
auto enable_screen_resize = doc.FindMember("enable_screen_resize");
|
||||
if (enable_screen_resize == doc.MemberEnd() || !enable_screen_resize->value.IsBool()) {
|
||||
log_warning("ScreenResize", "enable_screen_resize not found");
|
||||
valid = false;
|
||||
}
|
||||
auto enable_linear_filter = doc.FindMember("enable_linear_filter");
|
||||
if (enable_linear_filter == doc.MemberEnd() || !enable_linear_filter->value.IsBool()) {
|
||||
log_warning("ScreenResize", "enable_linear_filter not found");
|
||||
valid = false;
|
||||
}
|
||||
auto keep_aspect_ratio = doc.FindMember("keep_aspect_ratio");
|
||||
if (keep_aspect_ratio == doc.MemberEnd() || !keep_aspect_ratio->value.IsBool()) {
|
||||
log_warning("ScreenResize", "keep_aspect_ratio not found");
|
||||
valid = false;
|
||||
}
|
||||
if (valid) {
|
||||
this->offset_x = offset_x->value.GetInt();
|
||||
this->offset_y = offset_y->value.GetInt();
|
||||
this->scale_x = (float)scale_x->value.GetDouble();
|
||||
this->scale_y = (float)scale_y->value.GetDouble();
|
||||
this->enable_screen_resize = enable_screen_resize->value.GetBool();
|
||||
this->enable_linear_filter = enable_linear_filter->value.GetBool();
|
||||
this->keep_aspect_ratio = keep_aspect_ratio->value.GetBool();
|
||||
}
|
||||
} else {
|
||||
log_warning("ScreenResize", "config not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenResize::config_save() {
|
||||
log_info("ScreenResize", "saving config");
|
||||
|
||||
// create document
|
||||
Document doc;
|
||||
doc.SetObject();
|
||||
auto &alloc = doc.GetAllocator();
|
||||
|
||||
doc.AddMember("offset_x", this->offset_x, alloc);
|
||||
doc.AddMember("offset_y", this->offset_y, alloc);
|
||||
doc.AddMember("scale_x", this->scale_x, alloc);
|
||||
doc.AddMember("scale_y", this->scale_y, alloc);
|
||||
doc.AddMember("enable_screen_resize", this->enable_screen_resize, alloc);
|
||||
doc.AddMember("enable_linear_filter", this->enable_linear_filter, alloc);
|
||||
doc.AddMember("keep_aspect_ratio", this->keep_aspect_ratio, alloc);
|
||||
|
||||
// build JSON
|
||||
StringBuffer buffer;
|
||||
Writer<StringBuffer> writer(buffer);
|
||||
doc.Accept(writer);
|
||||
|
||||
// save to file
|
||||
if (fileutils::text_write(this->config_path, buffer.GetString())) {
|
||||
// this->config_dirty = false;
|
||||
} else {
|
||||
log_warning("ScreenResize", "unable to save config file to {}", this->config_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
#include "screen_resize.h"
|
||||
|
||||
#include "external/rapidjson/document.h"
|
||||
#include "external/rapidjson/writer.h"
|
||||
#include "util/utils.h"
|
||||
#include "util/fileutils.h"
|
||||
|
||||
using namespace rapidjson;
|
||||
|
||||
namespace cfg {
|
||||
|
||||
// globals
|
||||
std::unique_ptr<cfg::ScreenResize> SCREENRESIZE;
|
||||
|
||||
ScreenResize::ScreenResize() {
|
||||
this->config_path = std::string(getenv("APPDATA")) + "\\spicetools_screen_resize.json";
|
||||
if (fileutils::file_exists(this->config_path)) {
|
||||
this->config_load();
|
||||
}
|
||||
}
|
||||
|
||||
ScreenResize::~ScreenResize() {
|
||||
}
|
||||
|
||||
void ScreenResize::config_load() {
|
||||
log_info("ScreenResize", "loading config");
|
||||
|
||||
std::string config = fileutils::text_read(this->config_path);
|
||||
if (!config.empty()) {
|
||||
|
||||
// parse document
|
||||
Document doc;
|
||||
doc.Parse(config.c_str());
|
||||
|
||||
// check parse error
|
||||
auto error = doc.GetParseError();
|
||||
if (error) {
|
||||
log_warning("ScreenResize", "config parse error: {}", error);
|
||||
}
|
||||
|
||||
// verify root is a dict
|
||||
if (doc.IsObject()) {
|
||||
bool valid = true;
|
||||
auto offset_x = doc.FindMember("offset_x");
|
||||
if (offset_x == doc.MemberEnd() || !offset_x->value.IsInt()) {
|
||||
log_warning("ScreenResize", "offset_x not found");
|
||||
valid = false;
|
||||
}
|
||||
auto offset_y = doc.FindMember("offset_y");
|
||||
if (offset_y == doc.MemberEnd() || !offset_y->value.IsInt()) {
|
||||
log_warning("ScreenResize", "offset_y not found");
|
||||
valid = false;
|
||||
}
|
||||
auto scale_x = doc.FindMember("scale_x");
|
||||
if (scale_x == doc.MemberEnd() || !scale_x->value.IsDouble()) {
|
||||
log_warning("ScreenResize", "scale_x not found");
|
||||
valid = false;
|
||||
}
|
||||
auto scale_y = doc.FindMember("scale_y");
|
||||
if (scale_y == doc.MemberEnd() || !scale_y->value.IsDouble()) {
|
||||
log_warning("ScreenResize", "scale_y not found");
|
||||
valid = false;
|
||||
}
|
||||
auto enable_screen_resize = doc.FindMember("enable_screen_resize");
|
||||
if (enable_screen_resize == doc.MemberEnd() || !enable_screen_resize->value.IsBool()) {
|
||||
log_warning("ScreenResize", "enable_screen_resize not found");
|
||||
valid = false;
|
||||
}
|
||||
auto enable_linear_filter = doc.FindMember("enable_linear_filter");
|
||||
if (enable_linear_filter == doc.MemberEnd() || !enable_linear_filter->value.IsBool()) {
|
||||
log_warning("ScreenResize", "enable_linear_filter not found");
|
||||
valid = false;
|
||||
}
|
||||
auto keep_aspect_ratio = doc.FindMember("keep_aspect_ratio");
|
||||
if (keep_aspect_ratio == doc.MemberEnd() || !keep_aspect_ratio->value.IsBool()) {
|
||||
log_warning("ScreenResize", "keep_aspect_ratio not found");
|
||||
valid = false;
|
||||
}
|
||||
if (valid) {
|
||||
this->offset_x = offset_x->value.GetInt();
|
||||
this->offset_y = offset_y->value.GetInt();
|
||||
this->scale_x = (float)scale_x->value.GetDouble();
|
||||
this->scale_y = (float)scale_y->value.GetDouble();
|
||||
this->enable_screen_resize = enable_screen_resize->value.GetBool();
|
||||
this->enable_linear_filter = enable_linear_filter->value.GetBool();
|
||||
this->keep_aspect_ratio = keep_aspect_ratio->value.GetBool();
|
||||
}
|
||||
} else {
|
||||
log_warning("ScreenResize", "config not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScreenResize::config_save() {
|
||||
log_info("ScreenResize", "saving config");
|
||||
|
||||
// create document
|
||||
Document doc;
|
||||
doc.SetObject();
|
||||
auto &alloc = doc.GetAllocator();
|
||||
|
||||
doc.AddMember("offset_x", this->offset_x, alloc);
|
||||
doc.AddMember("offset_y", this->offset_y, alloc);
|
||||
doc.AddMember("scale_x", this->scale_x, alloc);
|
||||
doc.AddMember("scale_y", this->scale_y, alloc);
|
||||
doc.AddMember("enable_screen_resize", this->enable_screen_resize, alloc);
|
||||
doc.AddMember("enable_linear_filter", this->enable_linear_filter, alloc);
|
||||
doc.AddMember("keep_aspect_ratio", this->keep_aspect_ratio, alloc);
|
||||
|
||||
// build JSON
|
||||
StringBuffer buffer;
|
||||
Writer<StringBuffer> writer(buffer);
|
||||
doc.Accept(writer);
|
||||
|
||||
// save to file
|
||||
if (fileutils::text_write(this->config_path, buffer.GetString())) {
|
||||
// this->config_dirty = false;
|
||||
} else {
|
||||
log_warning("ScreenResize", "unable to save config file to {}", this->config_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+31
-31
@@ -1,31 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace cfg {
|
||||
|
||||
class ScreenResize {
|
||||
private:
|
||||
std::string config_path;
|
||||
// bool config_dirty = false;
|
||||
|
||||
public:
|
||||
ScreenResize();
|
||||
~ScreenResize();
|
||||
|
||||
int offset_x = 0;
|
||||
int offset_y = 0;
|
||||
float scale_x = 1.0;
|
||||
float scale_y = 1.0;
|
||||
bool enable_screen_resize = false;
|
||||
bool enable_linear_filter = false;
|
||||
bool keep_aspect_ratio = false;
|
||||
|
||||
void config_load();
|
||||
void config_save();
|
||||
};
|
||||
|
||||
// globals
|
||||
extern std::unique_ptr<cfg::ScreenResize> SCREENRESIZE;
|
||||
}
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace cfg {
|
||||
|
||||
class ScreenResize {
|
||||
private:
|
||||
std::string config_path;
|
||||
// bool config_dirty = false;
|
||||
|
||||
public:
|
||||
ScreenResize();
|
||||
~ScreenResize();
|
||||
|
||||
int offset_x = 0;
|
||||
int offset_y = 0;
|
||||
float scale_x = 1.0;
|
||||
float scale_y = 1.0;
|
||||
bool enable_screen_resize = false;
|
||||
bool enable_linear_filter = false;
|
||||
bool keep_aspect_ratio = false;
|
||||
|
||||
void config_load();
|
||||
void config_save();
|
||||
};
|
||||
|
||||
// globals
|
||||
extern std::unique_ptr<cfg::ScreenResize> SCREENRESIZE;
|
||||
}
|
||||
|
||||
+70
-70
@@ -1,70 +1,70 @@
|
||||
#include "spicecfg.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <windows.h>
|
||||
#include <shlwapi.h>
|
||||
|
||||
#include "launcher/launcher.h"
|
||||
#include "launcher/logger.h"
|
||||
#include "launcher/signal.h"
|
||||
#include "launcher/options.h"
|
||||
#include "util/crypt.h"
|
||||
#include "util/libutils.h"
|
||||
#include "rawinput/rawinput.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "configurator.h"
|
||||
|
||||
// for debugging, set to 1 to allocate console
|
||||
#define ALLOC_CONSOLE 0
|
||||
|
||||
int spicecfg_run(const std::vector<std::string> &sextet_devices) {
|
||||
|
||||
// initialize config
|
||||
auto &config = Config::getInstance();
|
||||
if (!config.getStatus()) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// initialize input
|
||||
RI_MGR = std::make_unique<rawinput::RawInputManager>();
|
||||
RI_MGR->devices_print();
|
||||
for (const auto &device : sextet_devices) {
|
||||
RI_MGR->sextet_register(device);
|
||||
}
|
||||
|
||||
// run configurator
|
||||
cfg::CONFIGURATOR_STANDALONE = true;
|
||||
cfg::Configurator configurator;
|
||||
configurator.run();
|
||||
|
||||
// success
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SPICETOOLS_SPICECFG_STANDALONE
|
||||
#ifdef _MSC_VER
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nCmdShow) {
|
||||
#else
|
||||
int main(int argc, char *argv[]) {
|
||||
#endif
|
||||
|
||||
// initialize console
|
||||
if (ALLOC_CONSOLE) {
|
||||
AllocConsole();
|
||||
freopen("conin$", "r", stdin);
|
||||
freopen("conout$", "w", stdout);
|
||||
freopen("conout$", "w", stderr);
|
||||
}
|
||||
|
||||
// run launcher with configurator option
|
||||
cfg::CONFIGURATOR_STANDALONE = true;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
return main_implementation(__argc, __argv);
|
||||
#else
|
||||
return main_implementation(argc, argv);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#include "spicecfg.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <windows.h>
|
||||
#include <shlwapi.h>
|
||||
|
||||
#include "launcher/launcher.h"
|
||||
#include "launcher/logger.h"
|
||||
#include "launcher/signal.h"
|
||||
#include "launcher/options.h"
|
||||
#include "util/crypt.h"
|
||||
#include "util/libutils.h"
|
||||
#include "rawinput/rawinput.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "configurator.h"
|
||||
|
||||
// for debugging, set to 1 to allocate console
|
||||
#define ALLOC_CONSOLE 0
|
||||
|
||||
int spicecfg_run(const std::vector<std::string> &sextet_devices) {
|
||||
|
||||
// initialize config
|
||||
auto &config = Config::getInstance();
|
||||
if (!config.getStatus()) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// initialize input
|
||||
RI_MGR = std::make_unique<rawinput::RawInputManager>();
|
||||
RI_MGR->devices_print();
|
||||
for (const auto &device : sextet_devices) {
|
||||
RI_MGR->sextet_register(device);
|
||||
}
|
||||
|
||||
// run configurator
|
||||
cfg::CONFIGURATOR_STANDALONE = true;
|
||||
cfg::Configurator configurator;
|
||||
configurator.run();
|
||||
|
||||
// success
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SPICETOOLS_SPICECFG_STANDALONE
|
||||
#ifdef _MSC_VER
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nCmdShow) {
|
||||
#else
|
||||
int main(int argc, char *argv[]) {
|
||||
#endif
|
||||
|
||||
// initialize console
|
||||
if (ALLOC_CONSOLE) {
|
||||
AllocConsole();
|
||||
freopen("conin$", "r", stdin);
|
||||
freopen("conout$", "w", stdout);
|
||||
freopen("conout$", "w", stderr);
|
||||
}
|
||||
|
||||
// run launcher with configurator option
|
||||
cfg::CONFIGURATOR_STANDALONE = true;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
return main_implementation(__argc, __argv);
|
||||
#else
|
||||
return main_implementation(argc, argv);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
int spicecfg_run(const std::vector<std::string> &sextet_devices);
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
int spicecfg_run(const std::vector<std::string> &sextet_devices);
|
||||
|
||||
Reference in New Issue
Block a user