EscapeTheBackrooms_Internal/EscapeTheBackroomsGUiTest/GUI/ZeroInput.h

81 lines
1.3 KiB
C
Raw Normal View History

2024-04-20 20:19:09 +08:00
#pragma once
#include <Windows.h>
#include "../Cheat.h"
2024-04-20 20:19:09 +08:00
namespace ZeroGUI
{
bool isGameFocussed = false;
bool isInputLocked = false;
HWND CurrentWindow = NULL;
2024-04-20 20:19:09 +08:00
namespace Input
{
bool mouseDown[5];
bool mouseDownAlready[256];
bool keysDown[256];
bool keysDownAlready[256];
bool IsAnyMouseDown()
{
if (mouseDown[0]) return true;
if (mouseDown[1]) return true;
if (mouseDown[2]) return true;
if (mouseDown[3]) return true;
if (mouseDown[4]) return true;
return false;
}
bool IsMouseClicked(int button, int element_id, bool repeat)
{
if (mouseDown[button])
{
if (!mouseDownAlready[element_id])
{
mouseDownAlready[element_id] = true;
return true;
}
if (repeat)
return true;
}
else
{
mouseDownAlready[element_id] = false;
}
return false;
}
bool IsKeyPressed(int key, bool repeat)
{
if (keysDown[key])
{
if (!keysDownAlready[key])
{
keysDownAlready[key] = true;
return true;
}
if (repeat)
return true;
}
else
{
keysDownAlready[key] = false;
}
return false;
}
void Handle()
{
isGameFocussed = GetActiveWindow() == CurrentWindow;
if (GetAsyncKeyState(0x01) && !isInputLocked && isGameFocussed)
2024-04-20 20:19:09 +08:00
{
mouseDown[0] = true;
}
else
mouseDown[0] = false;
}
}
}