Skip to content

Commit

Permalink
reformat CMakeLists.txt
Browse files Browse the repository at this point in the history
enable string representations for Buttons too
add comparison operators for Keys and Buttons
fix union member assignement
  • Loading branch information
skaupper committed Feb 27, 2017
1 parent efca7db commit f2ca5a2
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 194 deletions.
47 changes: 24 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,38 @@ SET (SDL_LIBS ${SDL2_LIBRARY}
${SDL2_TTF_LIBRARIES}
${SDL2_MIXER_LIBRARIES})

SET(SOURCES src/Core.cpp
src/Game.cpp
src/Timer.cpp
src/Scene.cpp
src/Element.cpp
src/Animation.cpp
src/Texture.cpp
src/Scene.cpp
src/Logger.cpp
src/Misc.cpp
src/Fonts.cpp
src/Entity.cpp
src/Event.cpp
src/Keys.cpp
src/SDLEventInterface.cpp)
SET (SOURCES src/Core.cpp
src/Game.cpp
src/Timer.cpp
src/Scene.cpp
src/Element.cpp
src/Animation.cpp
src/Texture.cpp
src/Scene.cpp
src/Logger.cpp
src/Misc.cpp
src/Fonts.cpp
src/Entity.cpp
src/Event.cpp
src/Keys.cpp
src/SDLEventInterface.cpp)

IF(ENABLE_TESTS)
IF (ENABLE_TESTS)
SET (SOURCES ${SOURCES} src/SDLWrapper.cpp)
ENDIF()

# compile library
ADD_LIBRARY (bkengine STATIC ${SOURCES})
TARGET_INCLUDE_DIRECTORIES (bkengine PUBLIC include/bkengine ${SDL2_INCLUDE_DIR}
${SDL2_IMAGE_INCLUDE_DIR}
${SDL2_TTF_INCLUDE_DIR}
${SDL2_MIXER_INCLUDE_DIRS})
TARGET_INCLUDE_DIRECTORIES (bkengine PUBLIC include/bkengine
${SDL2_INCLUDE_DIR}
${SDL2_IMAGE_INCLUDE_DIR}
${SDL2_TTF_INCLUDE_DIR}
${SDL2_MIXER_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES (bkengine ${SDL_LIBS})
TARGET_COMPILE_OPTIONS (bkengine PRIVATE -pedantic -Wall -Wextra -Werror -Wno-unused-parameter -Wno-missing-braces)

IF(${ENABLE_TESTS})
TARGET_COMPILE_DEFINITIONS(bkengine PRIVATE TEST)
IF (${ENABLE_TESTS})
TARGET_COMPILE_DEFINITIONS (bkengine PRIVATE TEST)
SET (TEST_SOURCES tests/main.cpp
tests/CoreTest.cpp
tests/TextureTest.cpp)
Expand All @@ -63,7 +64,7 @@ IF(${ENABLE_TESTS})
ENDIF ()

ENABLE_TESTING()
FIND_PACKAGE(GTest REQUIRED)
FIND_PACKAGE (GTest REQUIRED)

# compile test
ADD_EXECUTABLE (bkengine_tests ${TEST_SOURCES})
Expand Down
316 changes: 166 additions & 150 deletions include/bkengine/Keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,157 +7,173 @@ namespace bkengine
{
class Keys
{
private:
std::string keyString;

public:
Keys() : Keys("UNKNOWN") {}
Keys(const std::string &keyString) : keyString(keyString) {}

static Keys UNKNOWN;

/* Control keys */
static Keys RETURN;
static Keys ESCAPE;
static Keys BACKSPACE;
static Keys TAB;
static Keys SPACE;
static Keys CAPSLOCK;

/* Number keys */
static Keys ZERO;
static Keys ONE;
static Keys TWO;
static Keys THREE;
static Keys FOUR;
static Keys FIVE;
static Keys SIX;
static Keys SEVEN;
static Keys EIGHT;
static Keys NINE;

/* Letter keys */
static Keys A;
static Keys B;
static Keys C;
static Keys D;
static Keys E;
static Keys F;
static Keys G;
static Keys H;
static Keys I;
static Keys J;
static Keys K;
static Keys L;
static Keys M;
static Keys N;
static Keys O;
static Keys P;
static Keys Q;
static Keys R;
static Keys S;
static Keys T;
static Keys U;
static Keys V;
static Keys W;
static Keys X;
static Keys Y;
static Keys Z;

/* Function keys */
static Keys F1;
static Keys F2;
static Keys F3;
static Keys F4;
static Keys F5;
static Keys F6;
static Keys F7;
static Keys F8;
static Keys F9;
static Keys F10;
static Keys F11;
static Keys F12;
static Keys F13;
static Keys F14;
static Keys F15;
static Keys F16;
static Keys F17;
static Keys F18;
static Keys F19;
static Keys F20;
static Keys F21;
static Keys F22;
static Keys F23;
static Keys F24;

/* Arrow keys */
static Keys RIGHT;
static Keys LEFT;
static Keys DOWN;
static Keys UP;

static Keys PRINTSCREEN;
static Keys SCROLLLOCK;
static Keys PAUSE;
static Keys INSERT;
static Keys HOME;
static Keys PAGEUP;
static Keys DELETE;
static Keys END;
static Keys PAGEDOWN;

/* Numpad keys */
static Keys NUMLOCKCLEAR;
static Keys NP_DIVIDE;
static Keys NP_MULTIPLY;
static Keys NP_MINUS;
static Keys NP_PLUS;
static Keys NP_ENTER;
static Keys NP_ONE;
static Keys NP_TWO;
static Keys NP_THREE;
static Keys NP_FOUR;
static Keys NP_FIVE;
static Keys NP_SIX;
static Keys NP_SEVEN;
static Keys NP_EIGHT;
static Keys NP_NINE;
static Keys NP_ZERO;
static Keys NP_SEPARATOR;

/* Modifier keys */
static Keys LCTRL;
static Keys LSHIFT;
static Keys LALT;
static Keys LGUI;
static Keys RCTRL;
static Keys RSHIFT;
static Keys RALT;
static Keys RGUI;

/* Media keys */
static Keys MUTE;
static Keys VOLUMEUP;
static Keys VOLUMEDOWN;
static Keys AUDIONEXT;
static Keys AUDIOPREV;
static Keys AUDIOSTOP;
static Keys AUDIOPLAY;
static Keys AUDIOMUTE;

/* Special keys */
static Keys APPLICATION;
static Keys MENU;
static Keys BRIGHTNESSDOWN;
static Keys BRIGHTNESSUP;
static Keys SLEEP;
static Keys POWER;
private:
std::string keyString;

public:
Keys() : Keys("UNKNOWN") {}
Keys(const std::string &keyString) : keyString(keyString) {}
bool operator==(const Keys &) const;
bool operator!=(const Keys &) const;
std::string toString() const;

static Keys UNKNOWN;

/* Control keys */
static Keys RETURN;
static Keys ESCAPE;
static Keys BACKSPACE;
static Keys TAB;
static Keys SPACE;
static Keys CAPSLOCK;

/* Number keys */
static Keys ZERO;
static Keys ONE;
static Keys TWO;
static Keys THREE;
static Keys FOUR;
static Keys FIVE;
static Keys SIX;
static Keys SEVEN;
static Keys EIGHT;
static Keys NINE;

/* Letter keys */
static Keys A;
static Keys B;
static Keys C;
static Keys D;
static Keys E;
static Keys F;
static Keys G;
static Keys H;
static Keys I;
static Keys J;
static Keys K;
static Keys L;
static Keys M;
static Keys N;
static Keys O;
static Keys P;
static Keys Q;
static Keys R;
static Keys S;
static Keys T;
static Keys U;
static Keys V;
static Keys W;
static Keys X;
static Keys Y;
static Keys Z;

/* Function keys */
static Keys F1;
static Keys F2;
static Keys F3;
static Keys F4;
static Keys F5;
static Keys F6;
static Keys F7;
static Keys F8;
static Keys F9;
static Keys F10;
static Keys F11;
static Keys F12;
static Keys F13;
static Keys F14;
static Keys F15;
static Keys F16;
static Keys F17;
static Keys F18;
static Keys F19;
static Keys F20;
static Keys F21;
static Keys F22;
static Keys F23;
static Keys F24;

/* Arrow keys */
static Keys RIGHT;
static Keys LEFT;
static Keys DOWN;
static Keys UP;

static Keys PRINTSCREEN;
static Keys SCROLLLOCK;
static Keys PAUSE;
static Keys INSERT;
static Keys HOME;
static Keys PAGEUP;
static Keys DELETE;
static Keys END;
static Keys PAGEDOWN;

/* Numpad keys */
static Keys NUMLOCKCLEAR;
static Keys NP_DIVIDE;
static Keys NP_MULTIPLY;
static Keys NP_MINUS;
static Keys NP_PLUS;
static Keys NP_ENTER;
static Keys NP_ONE;
static Keys NP_TWO;
static Keys NP_THREE;
static Keys NP_FOUR;
static Keys NP_FIVE;
static Keys NP_SIX;
static Keys NP_SEVEN;
static Keys NP_EIGHT;
static Keys NP_NINE;
static Keys NP_ZERO;
static Keys NP_SEPARATOR;

/* Modifier keys */
static Keys LCTRL;
static Keys LSHIFT;
static Keys LALT;
static Keys LGUI;
static Keys RCTRL;
static Keys RSHIFT;
static Keys RALT;
static Keys RGUI;

/* Media keys */
static Keys MUTE;
static Keys VOLUMEUP;
static Keys VOLUMEDOWN;
static Keys AUDIONEXT;
static Keys AUDIOPREV;
static Keys AUDIOSTOP;
static Keys AUDIOPLAY;
static Keys AUDIOMUTE;

/* Special keys */
static Keys APPLICATION;
static Keys MENU;
static Keys BRIGHTNESSDOWN;
static Keys BRIGHTNESSUP;
static Keys SLEEP;
static Keys POWER;
};
enum class Buttons {
LEFT,
MIDDLE,
RIGHT,
SPECIAL

class Buttons
{
private:
std::string buttonString;

public:
Buttons() : Buttons("UNKNOWN") {}
Buttons(const std::string &buttonString) : buttonString(buttonString) {}
bool operator==(const Buttons &) const;
bool operator!=(const Buttons &) const;
std::string toString();

static Buttons UNKNOWN;
static Buttons LEFT;
static Buttons RIGHT;
static Buttons MIDDLE;
static Buttons SPECIAL;
};
}

Expand Down
Loading

0 comments on commit f2ca5a2

Please sign in to comment.