palladium/include/pd/controls/hid.hpp
tobid7 b4a4b6a426 # Rewrite Stage 1.5
- Added Overlays (Performance / Keyboaed)
- Keyboard has Gamepad Movement WIP (kinda)
- Work on UI7 Started
- Added Input Manager
- Added Message Boxes (Animated)
- Added Signle Header Tween func for animated stuff (Keyboard Messages, etc)
- Add FastHash (Maybe useful later)
- Using const & for vec in lithium
- Add ability to copy a command by a Ref
- Make Lists in Commands OpenAccess for Modification (StaticObject)
- Add Static Object (System to PreRender Suff that never changes) but can still be recolored or moved
- Add Layer and Font change functions
- Make Renderer Tools (RotateCorner, CreateRect, CreateLine, InBox, OptiCommandList) static (OpenAccess)
- Add ReIndexing to PushCommand
- Add Ability to Init vec3 and vec4 with vec2 and add .xy and .zw to vec4
- Fully Animated Keyboard that currently has problem of Top Down GamePad movement
- Add Func to Get GamePad Icon Codepoints for TextRenderer
- Made deltatime a float
- Using filesystem::path().wstring for convertation (works)
- Add a New InBox to Renderer that only checks if a point is inside a boundingbox
- Disable Font loading on Renderer Init due to 3ds Freezes when using SystemFont
- Make SystemFont lineheight 10% larger than it is to be nearly the same size as the ttf fonts
- Fix Some SpaceOffsets between TTF and SystemFont Rendering
- Cleanup the Update Rendermode Func
- Use LayerRenderSystem by default now as it now runs faster even with ttf fonts
2025-01-19 20:16:43 +01:00

95 lines
1.9 KiB
C++

#pragma once
#include <pd/common/common.hpp>
#include <pd/maths/vec.hpp>
namespace PD {
class Hid : public SmartCtor<Hid> {
public:
enum Key : u32 {
No = 0,
A = 1 << 0,
B = 1 << 1,
X = 1 << 2,
Y = 1 << 3,
Start = 1 << 4,
Select = 1 << 5,
L = 1 << 6,
R = 1 << 7,
DUp = 1 << 8,
DDown = 1 << 9,
DLeft = 1 << 10,
DRight = 1 << 11,
CPUp = 1 << 12,
CPDown = 1 << 13,
CPLeft = 1 << 14,
CPRight = 1 << 15,
CSUp = 1 << 16,
CSDown = 1 << 17,
CSLeft = 1 << 18,
CSRight = 1 << 19,
ZL = 1 << 20,
ZR = 1 << 21,
Touch = 1 << 22,
Up = DUp | CPUp,
Down = DDown | CPDown,
Left = DLeft | CPLeft,
Right = DRight | CPRight,
};
enum Event {
Event_Down,
Event_Held,
Event_Up,
};
Hid();
~Hid() {}
vec2 TouchPos() const { return touch[0]; }
vec2 TouchPosLast() const { return touch[1]; }
bool IsEvent(Event e, Key keys);
bool IsDown(Key keys) const { return key_events[0].at(Event_Down) & keys; }
bool IsHeld(Key keys) const { return key_events[0].at(Event_Held) & keys; }
bool IsUp(Key keys) const { return key_events[0].at(Event_Up) & keys; }
void Clear() {
for (int i = 0; i < 2; i++) {
key_events[i][Event_Down] = 0;
key_events[i][Event_Up] = 0;
key_events[i][Event_Held] = 0;
}
}
void Lock(bool v) {
if (v != locked) {
SwappyTable();
}
locked = v;
}
bool Locked() const { return locked; }
void Lock() {
if (!locked) {
SwappyTable();
}
locked = true;
}
void Unlock() {
if (locked) {
SwappyTable();
}
locked = false;
}
/// @brief Get the New Keystates etc
/// @note WOW not using the deltatime
void Update();
private:
void SwappyTable();
/// Using 2 Touch positions for current and last frame
vec2 touch[2];
bool locked = false;
std::unordered_map<Event, u32> key_events[2];
std::unordered_map<u32, u32> binds;
};
} // namespace PD