Debian Codegraph @

target-ethos/input/hotkeys.cpp

raw symbols SCIP
1 void InputManager::appendHotkeys() {
2 {
3 auto hotkey = new HotkeyInput;
4 hotkey->name = "Toggle Fullscreen Mode";
5 hotkey->mapping = "1/Button/F11";
6
7 hotkey->press = [] {
8 utility->toggleFullScreen();
9 };
10 }
11
12 {
13 auto hotkey = new HotkeyInput;
14 hotkey->name = "Toggle Mouse Capture";
15 hotkey->mapping = "1/Button/F12";
16
17 hotkey->press = [] {
18 input.acquired() ? input.unacquire() : input.acquire();
19 };
20 }
21
22 {
23 auto hotkey = new HotkeyInput;
24 hotkey->name = "Show Library";
25 hotkey->mapping = "1/Button/L";
26
27 hotkey->press = [] {
28 libraryManager->show();
29 };
30 }
31
32 {
33 auto hotkey = new HotkeyInput;
34 hotkey->name = "Pause Emulation";
35 hotkey->mapping = "1/Button/P";
36
37 hotkey->press = [] {
38 program->pause = !program->pause;
39 };
40 }
41
42 {
43 auto hotkey = new HotkeyInput;
44 hotkey->name = "Fast Forward";
45 hotkey->mapping = "1/Button/Tilde";
46
47 hotkey->press = [] {
48 video.set(Video::Synchronize, false);
49 audio.set(Audio::Synchronize, false);
50 };
51
52 hotkey->release = [] {
53 video.set(Video::Synchronize, ::config->video.synchronize);
54 audio.set(Audio::Synchronize, ::config->audio.synchronize);
55 };
56 }
57
58 {
59 auto hotkey = new HotkeyInput;
60 hotkey->name = "Power Cycle";
61 hotkey->mapping = "None";
62
63 hotkey->press = [] {
64 utility->power();
65 };
66 }
67
68 {
69 auto hotkey = new HotkeyInput;
70 hotkey->name = "Soft Reset";
71 hotkey->mapping = "None";
72
73 hotkey->press = [] {
74 utility->reset();
75 };
76 }
77
78 static unsigned activeSlot = 1;
79
80 {
81 auto hotkey = new HotkeyInput;
82 hotkey->name = "Save State";
83 hotkey->mapping = "1/Button/F5";
84
85 hotkey->press = [&] {
86 utility->saveState(activeSlot);
87 };
88 }
89
90 {
91 auto hotkey = new HotkeyInput;
92 hotkey->name = "Load State";
93 hotkey->mapping = "1/Button/F7";
94
95 hotkey->press = [&] {
96 utility->loadState(activeSlot);
97 };
98 }
99
100 {
101 auto hotkey = new HotkeyInput;
102 hotkey->name = "Decrement Slot";
103 hotkey->mapping = "1/Button/F6";
104
105 hotkey->press = [&] {
106 if(--activeSlot == 0) activeSlot = 5;
107 utility->showMessage({"Selected slot ", activeSlot});
108 };
109 }
110
111 {
112 auto hotkey = new HotkeyInput;
113 hotkey->name = "Increment Slot";
114 hotkey->mapping = "1/Button/F8";
115
116 hotkey->press = [&] {
117 if(++activeSlot == 6) activeSlot = 1;
118 utility->showMessage({"Selected slot ", activeSlot});
119 };
120 }
121
122 {
123 auto hotkey = new HotkeyInput;
124 hotkey->name = "Close Emulator";
125 hotkey->mapping = "None";
126
127 hotkey->press = [] {
128 Application::quit();
129 };
130 }
131
132 {
133 auto hotkey = new HotkeyInput;
134 hotkey->name = "Toggle Tracer";
135 hotkey->mapping = "None";
136
137 hotkey->press = [&] {
138 utility->tracerToggle();
139 };
140 }
141
142 {
143 auto hotkey = new HotkeyInput;
144 hotkey->name = "Export Memory";
145 hotkey->mapping = "None";
146
147 hotkey->press = [&] {
148 if(program->active == nullptr) return;
149 system().exportMemory();
150 utility->showMessage("Memory exported");
151 };
152 }
153
154 Configuration::Node node;
155 for(auto& hotkey : hotkeyMap) {
156 node.append(hotkey->mapping, string{hotkey->name}.replace(" ", ""));
157 }
158 config.append(node, "Hotkey");
159 }
160
161 void InputManager::pollHotkeys() {
162 for(auto& hotkey : hotkeyMap) {
163 bool state = hotkey->poll();
164 if(hotkey->state == 0 && state == 1) if(hotkey->press) hotkey->press();
165 if(hotkey->state == 1 && state == 0) if(hotkey->release) hotkey->release();
166 hotkey->state = state;
167 }
168 }