-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI.h
More file actions
56 lines (44 loc) · 1.42 KB
/
GUI.h
File metadata and controls
56 lines (44 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#pragma once
#include "Window.h"
#include "GamepadManager.h"
#include "imgui.h"
#include "imgui/backends/imgui_impl_sdl3.h"
#include "imgui/backends/imgui_impl_sdlrenderer3.h"
#include "TextureLoader.h"
#include <iomanip>
#include <vector>
/*static const unsigned char controller_map[] = {
#embed "assets/noun-xbox-controller-7424807.png"
};*/
struct ButtonElement {
SDL_GamepadButton button;
float x; // Offset from anchor.x
float y; // Offset from anchor.y
float radius = 15.0f; // Default size for ABXY
};
static const ButtonElement CONTROLLER_MAP[] = {
{ SDL_GAMEPAD_BUTTON_SOUTH, 460.0f, 200.0f }, // A
{ SDL_GAMEPAD_BUTTON_EAST, 500.0f, 160.0f }, // B
{ SDL_GAMEPAD_BUTTON_WEST, 420.0f, 160.0f }, // X
{ SDL_GAMEPAD_BUTTON_NORTH, 460.0f, 120.0f }, // Y
// Smaller buttons (View/Menu)
{ SDL_GAMEPAD_BUTTON_BACK, 263.0f, 160.0f, 10.0f },
{ SDL_GAMEPAD_BUTTON_START, 351.0f, 160.0f, 10.0f },
// Stick clicks (L3/R3)
{ SDL_GAMEPAD_BUTTON_LEFT_STICK, 155.0f, 160.0f, 30.0f },
{ SDL_GAMEPAD_BUTTON_RIGHT_STICK, 380.0f, 250.0f, 30.0f }
};
class GUI {
public:
GUI(Window& window, GamepadManager& gamepadManager);
~GUI();
void newFrame();
void render();
void updateUI();
private:
Window& m_window;
GamepadManager& m_gamepad;
float m_weakValue = 0.0f;
float m_strongValue = 0.0f;
SDL_Texture* m_texture{ nullptr };
};