-
Notifications
You must be signed in to change notification settings - Fork 226
/
FrontPanelManager.h
91 lines (72 loc) · 2.91 KB
/
FrontPanelManager.h
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//--------------------------------------------------------------------------------------
// FrontPanelManager.h
//
// Advanced Technology Group (ATG)
// Copyright (C) Microsoft Corporation. All rights reserved.
//--------------------------------------------------------------------------------------
#pragma once
#include "FrontPanel/FrontPanelDisplay.h"
#include "FrontPanel/FrontPanelInput.h"
#include <functional>
#include <array>
#include "StepTimer.h"
#include "PanelScreen.h"
class FrontPanelManager
{
public:
FrontPanelManager();
void CreateScreens();
template<typename child_t, typename... args>
child_t &CreateChild(args... params)
{
child_t *child = new child_t( this, params... );
AddChild(child);
return *child;
}
void Update(DX::StepTimer const& timer);
void Navigate(const PanelScreen &navToChild);
struct ActionRecord
{
unsigned id;
bool operator==(const ActionRecord &other) const
{
return id == other.id;
}
std::wstring name;
std::wstring description;
};
static size_t GetIndexForButtonId(XBOX_FRONT_PANEL_BUTTONS buttonId);
size_t ButtonActionCount() const;
const ActionRecord &operator[] (size_t idx) const;
const ActionRecord &CreateButtonAction(const wchar_t *name, const wchar_t *description, std::function<void()> op);
bool IsActionAssigned(XBOX_FRONT_PANEL_BUTTONS buttonId) const;
const ActionRecord &GetActionAssignment(XBOX_FRONT_PANEL_BUTTONS buttonId) const;
void AssignActionToButton(const ActionRecord &action, XBOX_FRONT_PANEL_BUTTONS buttonId);
void ClearActionAssignment(XBOX_FRONT_PANEL_BUTTONS buttonId);
XBOX_FRONT_PANEL_LIGHTS GetAssignedLights() const;
void SetAssignedLigts() const;
void CreateDeviceDependentResources(DX::DeviceResources *deviceResources);
void CreateWindowSizeDependentResources(DX::DeviceResources *deviceResources);
void GPURender(DX::DeviceResources *deviceResources);
bool IsAvailable() const
{
return m_frontPanelControl;
}
private:
void AddChild(PanelScreen *child);
bool OnButtonPressed(XBOX_FRONT_PANEL_BUTTONS whichButton);
bool InvokeButtonAction(int buttonId);
std::vector<std::unique_ptr<PanelScreen>> m_children;
PanelScreen *m_currentPanelScreen;
struct ButtonAction : public ActionRecord
{
std::function<void()> Invoke;
};
std::vector<std::unique_ptr<ButtonAction>> m_buttonActions;
std::array<const ButtonAction *, 5> m_buttonActionAssignments;
// FrontPanel objects
Microsoft::WRL::ComPtr<IXboxFrontPanelControl> m_frontPanelControl;
std::unique_ptr<ATG::FrontPanelDisplay> m_frontPanelDisplay;
std::unique_ptr<ATG::FrontPanelInput> m_frontPanelInput;
ATG::FrontPanelInput::ButtonStateTracker m_frontPanelInputButtons;
};