From ae4d356dbf97f50c350c25009690d6fc914c5aff Mon Sep 17 00:00:00 2001 From: Thomas Edvalson Date: Sat, 3 May 2014 11:44:37 -0400 Subject: [PATCH] Starting to phase-out Input.hpp in favor of SFML-named input headers --- include/cpp3ds/Window.hpp | 5 +-- include/cpp3ds/Window/Input.hpp | 48 ----------------------------- include/cpp3ds/Window/Input_sim.hpp | 44 -------------------------- include/cpp3ds/Window/Scene.hpp | 7 +++-- src/cpp3ds/Graphics/Stage.cpp | 4 +-- src/cpp3ds/Window/Input.cpp | 2 +- src/cpp3ds/Window/Scene.cpp | 3 +- src/cpp3ds/Window/TopScreen.cpp | 4 +-- src/sim3ds/Window/Input.cpp | 2 +- src/sim3ds/Window/Scene.cpp | 2 +- src/sim3ds/Window/TopScreen.cpp | 4 +-- 11 files changed, 19 insertions(+), 106 deletions(-) delete mode 100644 include/cpp3ds/Window/Input.hpp delete mode 100644 include/cpp3ds/Window/Input_sim.hpp diff --git a/include/cpp3ds/Window.hpp b/include/cpp3ds/Window.hpp index f3f27d7..68bcd89 100644 --- a/include/cpp3ds/Window.hpp +++ b/include/cpp3ds/Window.hpp @@ -5,10 +5,11 @@ //#include //#include #include +#include -#include +//#include //#include -//#include +#include //#include //#include //#include diff --git a/include/cpp3ds/Window/Input.hpp b/include/cpp3ds/Window/Input.hpp deleted file mode 100644 index 37e5e6e..0000000 --- a/include/cpp3ds/Window/Input.hpp +++ /dev/null @@ -1,48 +0,0 @@ -#ifdef SIMULATION -#include -#endif - -#ifndef CPP3DS_INPUT_HPP -#define CPP3DS_INPUT_HPP - -#define HID 0x10146000 - -#define SLIDERSTATE 0x10144000 - -namespace cpp3ds { - - enum Button { - BUTTON_A = 1, - BUTTON_B = 2, - BUTTON_X = 1024, - BUTTON_Y = 2048, - BUTTON_UP = 64, - BUTTON_DOWN = 128, - BUTTON_LEFT = 32, - BUTTON_RIGHT = 16, - BUTTON_L1 = 512, - BUTTON_R1 = 256, - BUTTON_START = 8, - BUTTON_SELECT = 4 - }; - - typedef void (*InputCallback)(Button button); - - class Input { - protected: - int getHID(); - int last_hid; - public: - static float slider; - static bool isDown(Button button); - static void update(float deltaTime); - static float get3DSlider(){ return Input::slider; } - // int bind(Button button, Event event); - // void unbind(int binding); - // void unbindAll(); - // void unbindAll(Button button); - }; - -} - -#endif diff --git a/include/cpp3ds/Window/Input_sim.hpp b/include/cpp3ds/Window/Input_sim.hpp deleted file mode 100644 index d96d4ef..0000000 --- a/include/cpp3ds/Window/Input_sim.hpp +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef CPP3DS_INPUT_HPP -#define CPP3DS_INPUT_HPP - -#include - -namespace cpp3ds { - - typedef sf::Keyboard::Key Button; - - // enum Button { - // BUTTON_A = 1, - // BUTTON_B = 2, - // BUTTON_X = 1024, - // BUTTON_Y = 2048, - const Button BUTTON_UP = sf::Keyboard::Up; - const Button BUTTON_DOWN = sf::Keyboard::Down; - const Button BUTTON_LEFT = sf::Keyboard::Left; - const Button BUTTON_RIGHT = sf::Keyboard::Right; - // BUTTON_L1 = 512, - // BUTTON_R1 = 256, - // BUTTON_START = 8, - // BUTTON_SELECT = 4 - // }; - - typedef void (*InputCallback)(Button button); - - class Input { - protected: - int getHID(); - int last_hid; - public: - static float slider; - static bool isDown(Button button); - static void update(float deltaTime); - static float get3DSlider(){ return Input::slider; } - // int bind(Button button, Event event); - // void unbind(int binding); - // void unbindAll(); - // void unbindAll(Button button); - }; - -} - -#endif diff --git a/include/cpp3ds/Window/Scene.hpp b/include/cpp3ds/Window/Scene.hpp index 543ab3c..566bcad 100644 --- a/include/cpp3ds/Window/Scene.hpp +++ b/include/cpp3ds/Window/Scene.hpp @@ -4,7 +4,8 @@ #include #include #include -#include +//#include +#include namespace cpp3ds { @@ -15,9 +16,11 @@ namespace cpp3ds { protected: uint64_t lastTime; public: + virtual ~Scene() {} BottomScreen bottomScreen; TopScreen topScreen; - Input input; +// Input input; + EventManager events; void display(); virtual int update(float deltaTime) = 0; virtual void render() = 0; diff --git a/src/cpp3ds/Graphics/Stage.cpp b/src/cpp3ds/Graphics/Stage.cpp index 525d80c..0ad689f 100644 --- a/src/cpp3ds/Graphics/Stage.cpp +++ b/src/cpp3ds/Graphics/Stage.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include namespace cpp3ds { @@ -48,7 +48,7 @@ namespace cpp3ds { while (cur != nullptr) { Actor& actor = *cur->actor; if (use3D) { - float slider = Input::get3DSlider() * actor.depth3d; + float slider = Keyboard::get3DSlider() * actor.depth3d; actor.draw(screen, (isLeftside) ? x-slider : x+slider, y, use3D, isLeftside); } else { actor.draw(screen, x, y, use3D, isLeftside); diff --git a/src/cpp3ds/Window/Input.cpp b/src/cpp3ds/Window/Input.cpp index be2aa84..2c8b2e4 100644 --- a/src/cpp3ds/Window/Input.cpp +++ b/src/cpp3ds/Window/Input.cpp @@ -1,4 +1,4 @@ -#include +#include #include namespace cpp3ds { diff --git a/src/cpp3ds/Window/Scene.cpp b/src/cpp3ds/Window/Scene.cpp index 77dd5f4..1f6e4ba 100644 --- a/src/cpp3ds/Window/Scene.cpp +++ b/src/cpp3ds/Window/Scene.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include namespace cpp3ds { @@ -16,7 +17,7 @@ namespace cpp3ds { display(); deltaTime = (float)(GetSystemTick() - lastTime) / TICKS_PER_SEC; lastTime = GetSystemTick(); - Input::update(deltaTime); + Keyboard::update(); ret = update(deltaTime); } return ret; diff --git a/src/cpp3ds/Window/TopScreen.cpp b/src/cpp3ds/Window/TopScreen.cpp index cbd82ad..8343fd0 100644 --- a/src/cpp3ds/Window/TopScreen.cpp +++ b/src/cpp3ds/Window/TopScreen.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include @@ -12,7 +12,7 @@ namespace cpp3ds { void TopScreen::draw(Drawable& obj, float x, float y, bool use3D) { if (use3D) { - float slider = Input::get3DSlider() * obj.depth3d; + float slider = Keyboard::get3DSlider() * obj.depth3d; obj.draw(left_screen, x - slider, y, use3D, true); obj.draw(right_screen, x + slider, y, use3D, false); } else { diff --git a/src/sim3ds/Window/Input.cpp b/src/sim3ds/Window/Input.cpp index f12d0c6..cda493d 100644 --- a/src/sim3ds/Window/Input.cpp +++ b/src/sim3ds/Window/Input.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include namespace cpp3ds { diff --git a/src/sim3ds/Window/Scene.cpp b/src/sim3ds/Window/Scene.cpp index abc2b7f..d1523eb 100644 --- a/src/sim3ds/Window/Scene.cpp +++ b/src/sim3ds/Window/Scene.cpp @@ -19,7 +19,7 @@ namespace cpp3ds { if (useDisplay) display(); deltaTime = clock.restart(); - Input::update(deltaTime.asSeconds()); + Keyboard::update(); ret = update(deltaTime.asSeconds()); } return ret; diff --git a/src/sim3ds/Window/TopScreen.cpp b/src/sim3ds/Window/TopScreen.cpp index 2a48e45..2e8204d 100644 --- a/src/sim3ds/Window/TopScreen.cpp +++ b/src/sim3ds/Window/TopScreen.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include @@ -12,7 +12,7 @@ namespace cpp3ds { void TopScreen::draw(Drawable& obj, float x, float y, bool use3D) { if (use3D) { - float slider = Input::get3DSlider() * obj.depth3d; + float slider = Keyboard::get3DSlider() * obj.depth3d; obj.draw(left_screen, x - slider, y, use3D, true); obj.draw(right_screen, x + slider, y, use3D, false); } else {