Add keyboard handling functionality

Added function that creates settings.ini file but it creates empty file :) I will deal with it later.
This commit is contained in:
Jadis0x
2024-05-26 23:08:00 +03:00
parent ad4bf3e659
commit 231087da51
4 changed files with 234 additions and 17 deletions

View File

@@ -1,6 +1,32 @@
#include "pch-il2cpp.h"
#include "pch-il2cpp.h"
#include "utils.hpp"
#include "helpers.h"
#include <map>
#include <fstream>
#include <sstream>
#include <Windows.h>
int GetKey(KeyCode code)
{
return static_cast<int>(code);
}
bool GetKeyDown(KeyCode key)
{
// Convert KeyCode enum value to virtual keycode
int vkey = GetKey(key);
// Check key state with GetKeyState
return (GetKeyState(vkey) & 0x8000) != 0;
}
bool GetKeyDownAsync(KeyCode key) {
// Convert KeyCode enum value to virtual keycode
int vkey = GetKey(key);
// Check key state with GetAsyncKeyState
return (GetAsyncKeyState(vkey) & 0x8000) != 0;
}
std::string ToString(app::Object* object) {
std::string type = il2cppi_to_string(app::Object_ToString(object, NULL));
@@ -10,3 +36,35 @@ std::string ToString(app::Object* object) {
return type;
}
std::string ReadValueFromIni(const std::string& filename, const std::string& key, const std::string& defaultValue)
{
std::ifstream file(filename);
std::string line, value = defaultValue;
if (file.is_open()) {
while (getline(file, line)) {
std::istringstream is_line(line);
std::string currentKey;
if (getline(is_line, currentKey, '=')) {
std::string currentValue;
if (getline(is_line, currentValue)) {
if (currentKey == key) {
value = currentValue;
break;
}
}
}
}
file.close();
}
else {
// Create if file does not exist
std::ofstream outFile(filename);
outFile.close();
}
return value;
}