Skip to content

Commit f2d4c18

Browse files
committed
added keyboard support!
1 parent 3455963 commit f2d4c18

13 files changed

Lines changed: 23376 additions & 12 deletions

File tree

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"thread": "cpp",
5555
"cinttypes": "cpp",
5656
"typeinfo": "cpp",
57-
"valarray": "cpp"
57+
"valarray": "cpp",
58+
"forward_list": "cpp"
5859
}
5960
}

GPATH

0 Bytes
Binary file not shown.

GRTAGS

176 KB
Binary file not shown.

GTAGS

240 KB
Binary file not shown.

config.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"1":4,"12":6,"13":5,"16":7,"17":10,"18":14,"19":11,"2":2,"20":13,"21":3,"22":8,"23":1,"24":12,"25":0,"28":19,"29":20,"3":15,"31":21,"32":22,"33":23,"4":9,"6":16,"7":17,"9":18}

include/MainWindow.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include "Button.h"
77
#include "Key.h"
88
#include "Piano.h"
9+
#include "Settings.h"
10+
#include <unordered_set>
911
/* ViewWindow: class that creates and renders the main GUI window */
1012
class MainWindow : public sf::RenderWindow{
1113
///////////////////////
@@ -23,13 +25,14 @@ class MainWindow : public sf::RenderWindow{
2325

2426
sf::Text adLabel;
2527

26-
//TODO remove
27-
/*sf::Sprite key;
28-
sf::Sprite key2;
29-
sf::Texture keyTexture2;
30-
sf::Sprite key3;*/
28+
////////////////////////
29+
/// Settings ///
30+
////////////////////////
31+
Settings settings;
32+
3133

3234
Piano *piano = piano->getInstance();
35+
std::unordered_set<Key*> activeKeys;
3336
public:
3437
MainWindow(sf::VideoMode v, std::string title);
3538
void loadLayout();

include/Piano.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class Piano
4242
void setPositions();
4343
std::vector<Key *> &getKeys();
4444
Key* findKeyClicked(sf::Vector2f mouse);
45+
Key* findKeyPressed(int keyIndex);
4546
};
4647

4748
#endif

include/Settings.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include <map>
2+
#include "Key.h"
3+
#include "json.hpp"
4+
#include <fstream>
5+
6+
using json = nlohmann::json;
7+
class Settings {
8+
private:
9+
std::map<char,Key*> controls;
10+
std::ifstream settingsPath;
11+
json settingsJson;
12+
public:
13+
Settings();
14+
void generateConfig();
15+
json& getKbKeys();
16+
};

0 commit comments

Comments
 (0)