Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3ba5aad
Implemented InputManager
LumpBloom7 Oct 10, 2018
24cc6d8
Improve some odd code formatting
LumpBloom7 Oct 10, 2018
140cbc9
Add mouse testing in Test Bench
LumpBloom7 Oct 11, 2018
d13487a
Merge branch 'master' into feature/InputManager
LumpBloom7 Oct 14, 2018
db48ccb
Merge branch 'master' into feature/InputManager
LumpBloom7 Oct 24, 2018
288af72
Merge branch 'master' into feature/InputManager
LumpBloom7 Nov 12, 2018
9e5ad2c
Some tidying
LumpBloom7 Nov 12, 2018
6a8c66e
Merge branch 'master' into feature/InputManager
LumpBloom7 Feb 24, 2019
9c81617
Optimizations
LumpBloom7 Mar 1, 2019
4f8c3bb
More optimizations
LumpBloom7 Mar 1, 2019
7795077
Much more optimizations
Mar 1, 2019
8094157
Use cref for SDL_Rect in isMouseInside
Mar 1, 2019
43e1c71
Use some internal defines to check keys/buttons
Mar 1, 2019
d12e5ba
Fit all keyboard and mouse stuff into their respective nested class
LumpBloom7 Mar 2, 2019
38afcf2
Use usings to keep some lines short and readable
LumpBloom7 Mar 2, 2019
544fdfe
Fix printable character not being updated
LumpBloom7 Mar 2, 2019
2177f71
[WIP] Small reorganization
Mar 4, 2019
705f704
[WIP] Small optimization
Mar 8, 2019
69b8c16
[WIP] Another update
Mar 8, 2019
da95825
Implement state change and reuse wasUp and wasDown
Mar 10, 2019
64c732c
Add some simple tests
LumpBloom7 Mar 11, 2019
2b84888
Merge branch 'master' into feature/InputManager
LumpBloom7 Apr 1, 2019
0745451
Merge branch 'master' into feature/InputManager
LumpBloom7 Aug 16, 2019
66f130d
Some improvements and optimizations (#4)
Oct 2, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions BloomFramework/BloomFramework.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,14 @@
<ClInclude Include="include\Audio\SoundChunk.h" />
<ClInclude Include="include\GameObject.h" />
<ClInclude Include="include\Graphics\Animation.h" />
<ClInclude Include="include\Input\InputEvents.h" />
<ClInclude Include="include\Systems\AnimationSystem.h" />
<ClInclude Include="include\Graphics\Drawable.h" />
<ClInclude Include="include\Graphics\Font.h" />
<ClInclude Include="include\Graphics\FontStore.h" />
<ClInclude Include="include\Graphics\SpriteText.h" />
<ClInclude Include="include\Input\InputDefinitions.h" />
<ClInclude Include="include\Input\InputManager.h" />
<ClInclude Include="include\Systems\DefaultSystem.h" />
<ClInclude Include="include\Systems\RenderSystem.h" />
<ClInclude Include="include\Systems\Systems.h" />
Expand All @@ -220,6 +223,8 @@
<ClCompile Include="src\Graphics\SpriteText.cpp" />
<ClCompile Include="src\Graphics\Texture.cpp" />
<ClCompile Include="src\Graphics\TextureStore.cpp" />
<ClCompile Include="src\Input\InputEvents.cpp" />
<ClCompile Include="src\Input\InputManager.cpp" />
<ClCompile Include="src\Timer.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
21 changes: 21 additions & 0 deletions BloomFramework/BloomFramework.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
<Filter Include="Source Files\Graphics">
<UniqueIdentifier>{901b4a12-4da2-4795-b576-f703b5eb63bc}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Input">
<UniqueIdentifier>{bc7594da-4383-42e6-9da9-5122304c4bfa}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\Input">
<UniqueIdentifier>{1f775a83-4d98-4f93-bf11-b69ad3949381}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Audio">
<UniqueIdentifier>{91153568-16e8-4684-82a5-dce4be5c6640}</UniqueIdentifier>
</Filter>
Expand Down Expand Up @@ -69,6 +75,9 @@
<ClCompile Include="src\Graphics\TextureStore.cpp">
<Filter>Source Files\Graphics</Filter>
</ClCompile>
<ClCompile Include="src\Input\InputManager.cpp">
<Filter>Source Files\Input</Filter>
</ClCompile>
<ClCompile Include="src\Graphics\Animation.cpp">
<Filter>Source Files\Graphics</Filter>
</ClCompile>
Expand All @@ -87,6 +96,9 @@
<ClCompile Include="src\Graphics\FontStore.cpp">
<Filter>Source Files\Graphics</Filter>
</ClCompile>
<ClCompile Include="src\Input\InputEvents.cpp">
<Filter>Source Files\Input</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\Framework.h">
Expand Down Expand Up @@ -161,6 +173,12 @@
<ClInclude Include="include\Graphics\TextureStore.h">
<Filter>Header Files\Graphics</Filter>
</ClInclude>
<ClInclude Include="include\Input\InputManager.h">
<Filter>Header Files\Input</Filter>
</ClInclude>
<ClInclude Include="include\Input\InputDefinitions.h">
<Filter>Header Files\Input</Filter>
</ClInclude>
<ClInclude Include="include\Components\Animation.h">
<Filter>Header Files\Components</Filter>
</ClInclude>
Expand Down Expand Up @@ -194,6 +212,9 @@
<ClInclude Include="include\Graphics\FontStore.h">
<Filter>Header Files\Graphics</Filter>
</ClInclude>
<ClInclude Include="include\Input\InputEvents.h">
<Filter>Header Files\Input</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
Expand Down
1 change: 1 addition & 0 deletions BloomFramework/include/Framework.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
#include "Graphics/Font.h"
#include "Graphics/FontStore.h"
#include "Graphics/SpriteText.h"
#include "Input/InputManager.h"
3 changes: 2 additions & 1 deletion BloomFramework/include/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "stdIncludes.h"
#include "Graphics/TextureStore.h"
#include "Timer.h"

#include "Input/InputManager.h"
namespace bloom {
class BLOOMFRAMEWORK_API Game {
using TextureStore = bloom::graphics::TextureStore;
Expand Down Expand Up @@ -44,6 +44,7 @@ namespace bloom {

TextureStore textures = TextureStore(m_renderer);
Timer timer;
input::InputManager input;

protected:
SDL_Renderer * m_renderer = nullptr;
Expand Down
260 changes: 260 additions & 0 deletions BloomFramework/include/Input/InputDefinitions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,260 @@
#pragma once

#include "stdIncludes.h"

namespace bloom::input {
enum class KeyboardKey {
Unknown = SDL_SCANCODE_UNKNOWN,
A = SDL_SCANCODE_A,
B = SDL_SCANCODE_B,
C = SDL_SCANCODE_C,
D = SDL_SCANCODE_D,
E = SDL_SCANCODE_E,
F = SDL_SCANCODE_F,
G = SDL_SCANCODE_G,
H = SDL_SCANCODE_H,
I = SDL_SCANCODE_I,
J = SDL_SCANCODE_J,
K = SDL_SCANCODE_K,
L = SDL_SCANCODE_L,
M = SDL_SCANCODE_M,
N = SDL_SCANCODE_N,
O = SDL_SCANCODE_O,
P = SDL_SCANCODE_P,
Q = SDL_SCANCODE_Q,
R = SDL_SCANCODE_R,
S = SDL_SCANCODE_S,
T = SDL_SCANCODE_T,
U = SDL_SCANCODE_U,
V = SDL_SCANCODE_V,
W = SDL_SCANCODE_W,
X = SDL_SCANCODE_X,
Y = SDL_SCANCODE_Y,
Z = SDL_SCANCODE_Z,
Num1 = SDL_SCANCODE_1,
Num2 = SDL_SCANCODE_2,
Num3 = SDL_SCANCODE_3,
Num4 = SDL_SCANCODE_4,
Num5 = SDL_SCANCODE_5,
Num6 = SDL_SCANCODE_6,
Num7 = SDL_SCANCODE_7,
Num8 = SDL_SCANCODE_8,
Num9 = SDL_SCANCODE_9,
Num0 = SDL_SCANCODE_0,
Return = SDL_SCANCODE_RETURN,
Escape = SDL_SCANCODE_ESCAPE,
Backspace = SDL_SCANCODE_BACKSPACE,
Tab = SDL_SCANCODE_TAB,
Space = SDL_SCANCODE_SPACE,
Minus = SDL_SCANCODE_MINUS,
Equals = SDL_SCANCODE_EQUALS,
LeftBracket = SDL_SCANCODE_LEFTBRACKET,
RightBracket = SDL_SCANCODE_RIGHTBRACKET,
Backslash = SDL_SCANCODE_BACKSLASH,
NonUsHash = SDL_SCANCODE_NONUSHASH,
Semicolon = SDL_SCANCODE_SEMICOLON,
Apostrophe = SDL_SCANCODE_APOSTROPHE,
Grave = SDL_SCANCODE_GRAVE,
Comma = SDL_SCANCODE_COMMA,
Period = SDL_SCANCODE_PERIOD,
Slash = SDL_SCANCODE_SLASH,
CapsLock = SDL_SCANCODE_CAPSLOCK,
F1 = SDL_SCANCODE_F1,
F2 = SDL_SCANCODE_F2,
F3 = SDL_SCANCODE_F3,
F4 = SDL_SCANCODE_F4,
F5 = SDL_SCANCODE_F5,
F6 = SDL_SCANCODE_F6,
F7 = SDL_SCANCODE_F7,
F8 = SDL_SCANCODE_F8,
F9 = SDL_SCANCODE_F9,
F10 = SDL_SCANCODE_F10,
F11 = SDL_SCANCODE_F11,
F12 = SDL_SCANCODE_F12,
PrintScreen = SDL_SCANCODE_PRINTSCREEN,
ScrollLock = SDL_SCANCODE_SCROLLLOCK,
Pause = SDL_SCANCODE_PAUSE,
Insert = SDL_SCANCODE_INSERT,
Home = SDL_SCANCODE_HOME,
PageUp = SDL_SCANCODE_PAGEUP,
Delete = SDL_SCANCODE_DELETE,
End = SDL_SCANCODE_END,
PageDown = SDL_SCANCODE_PAGEDOWN,
Right = SDL_SCANCODE_RIGHT,
Left = SDL_SCANCODE_LEFT,
Down = SDL_SCANCODE_DOWN,
Up = SDL_SCANCODE_UP,
NumLockClear = SDL_SCANCODE_NUMLOCKCLEAR,
KpDivide = SDL_SCANCODE_KP_DIVIDE,
KpMultiply = SDL_SCANCODE_KP_MULTIPLY,
KpMinus = SDL_SCANCODE_KP_MINUS,
KpPlus = SDL_SCANCODE_KP_PLUS,
KpEnter = SDL_SCANCODE_KP_ENTER,
Kp1 = SDL_SCANCODE_KP_1,
Kp2 = SDL_SCANCODE_KP_2,
Kp3 = SDL_SCANCODE_KP_3,
Kp4 = SDL_SCANCODE_KP_4,
Kp5 = SDL_SCANCODE_KP_5,
Kp6 = SDL_SCANCODE_KP_6,
Kp7 = SDL_SCANCODE_KP_7,
Kp8 = SDL_SCANCODE_KP_8,
Kp9 = SDL_SCANCODE_KP_9,
Kp0 = SDL_SCANCODE_KP_0,
KpPeriod = SDL_SCANCODE_KP_PERIOD,
NonUsBackslash = SDL_SCANCODE_NONUSBACKSLASH,
Application = SDL_SCANCODE_APPLICATION,
Power = SDL_SCANCODE_POWER,
KpEquals = SDL_SCANCODE_KP_EQUALS,
F13 = SDL_SCANCODE_F13,
F14 = SDL_SCANCODE_F14,
F15 = SDL_SCANCODE_F15,
F16 = SDL_SCANCODE_F16,
F17 = SDL_SCANCODE_F17,
F18 = SDL_SCANCODE_F18,
F19 = SDL_SCANCODE_F19,
F20 = SDL_SCANCODE_F20,
F21 = SDL_SCANCODE_F21,
F22 = SDL_SCANCODE_F22,
F23 = SDL_SCANCODE_F23,
F24 = SDL_SCANCODE_F24,
Execute = SDL_SCANCODE_EXECUTE,
Help = SDL_SCANCODE_HELP,
Menu = SDL_SCANCODE_MENU,
Select = SDL_SCANCODE_SELECT,
Stop = SDL_SCANCODE_STOP,
Again = SDL_SCANCODE_AGAIN,
Undo = SDL_SCANCODE_UNDO,
Cut = SDL_SCANCODE_CUT,
Copy = SDL_SCANCODE_COPY,
Paste = SDL_SCANCODE_PASTE,
Find = SDL_SCANCODE_FIND,
Mute = SDL_SCANCODE_MUTE,
VolumeUp = SDL_SCANCODE_VOLUMEUP,
VolumeDown = SDL_SCANCODE_VOLUMEDOWN,
KpComma = SDL_SCANCODE_KP_COMMA,
KpEqualsAS400 = SDL_SCANCODE_KP_EQUALSAS400,
International1 = SDL_SCANCODE_INTERNATIONAL1,
International2 = SDL_SCANCODE_INTERNATIONAL2,
International3 = SDL_SCANCODE_INTERNATIONAL3,
International4 = SDL_SCANCODE_INTERNATIONAL4,
International5 = SDL_SCANCODE_INTERNATIONAL5,
International6 = SDL_SCANCODE_INTERNATIONAL6,
International7 = SDL_SCANCODE_INTERNATIONAL7,
International8 = SDL_SCANCODE_INTERNATIONAL8,
International9 = SDL_SCANCODE_INTERNATIONAL9,
Lang1 = SDL_SCANCODE_LANG1,
Lang2 = SDL_SCANCODE_LANG2,
Lang3 = SDL_SCANCODE_LANG3,
Lang4 = SDL_SCANCODE_LANG4,
Lang5 = SDL_SCANCODE_LANG5,
Lang6 = SDL_SCANCODE_LANG6,
Lang7 = SDL_SCANCODE_LANG7,
Lang8 = SDL_SCANCODE_LANG8,
Lang9 = SDL_SCANCODE_LANG9,
AltErase = SDL_SCANCODE_ALTERASE,
SysReq = SDL_SCANCODE_SYSREQ,
Cancel = SDL_SCANCODE_CANCEL,
Clear = SDL_SCANCODE_CLEAR,
Prior = SDL_SCANCODE_PRIOR,
Return2 = SDL_SCANCODE_RETURN2,
Separator = SDL_SCANCODE_SEPARATOR,
Out = SDL_SCANCODE_OUT,
Oper = SDL_SCANCODE_OPER,
ClearAgain = SDL_SCANCODE_CLEARAGAIN,
CrSel = SDL_SCANCODE_CRSEL,
ExSel = SDL_SCANCODE_EXSEL,
Kp00 = SDL_SCANCODE_KP_00,
Kp000 = SDL_SCANCODE_KP_000,
ThousandsSeparator = SDL_SCANCODE_THOUSANDSSEPARATOR,
DecimalSeparator = SDL_SCANCODE_DECIMALSEPARATOR,
CurrencyUnit = SDL_SCANCODE_CURRENCYUNIT,
CurrencySubUnit = SDL_SCANCODE_CURRENCYSUBUNIT,
KpLeftParen = SDL_SCANCODE_KP_LEFTPAREN,
KpRightParen = SDL_SCANCODE_KP_RIGHTPAREN,
KpLeftBrace = SDL_SCANCODE_KP_LEFTBRACE,
KpRightBrace = SDL_SCANCODE_KP_RIGHTBRACE,
KpTab = SDL_SCANCODE_KP_TAB,
KpBackspace = SDL_SCANCODE_KP_BACKSPACE,
KpA = SDL_SCANCODE_KP_A,
KpB = SDL_SCANCODE_KP_B,
KpC = SDL_SCANCODE_KP_C,
KpD = SDL_SCANCODE_KP_D,
KpE = SDL_SCANCODE_KP_E,
KpF = SDL_SCANCODE_KP_F,
KpXor = SDL_SCANCODE_KP_XOR,
KpPower = SDL_SCANCODE_KP_POWER,
KpPercent = SDL_SCANCODE_KP_PERCENT,
KpLess = SDL_SCANCODE_KP_LESS,
KpGreater = SDL_SCANCODE_KP_GREATER,
KpAmpersand = SDL_SCANCODE_KP_AMPERSAND,
KpDblAmpersand = SDL_SCANCODE_KP_DBLAMPERSAND,
KpVerticalBar = SDL_SCANCODE_KP_VERTICALBAR,
KpDblVerticalBar = SDL_SCANCODE_KP_DBLVERTICALBAR,
KpColon = SDL_SCANCODE_KP_COLON,
KpHash = SDL_SCANCODE_KP_HASH,
KpSpace = SDL_SCANCODE_KP_SPACE,
KpAt = SDL_SCANCODE_KP_AT,
KpExclam = SDL_SCANCODE_KP_EXCLAM,
KpMemStore = SDL_SCANCODE_KP_MEMSTORE,
KpMemRecall = SDL_SCANCODE_KP_MEMRECALL,
KpMemClear = SDL_SCANCODE_KP_MEMCLEAR,
KpMemAdd = SDL_SCANCODE_KP_MEMADD,
KpMemSubtract = SDL_SCANCODE_KP_MEMSUBTRACT,
KpMemMultiply = SDL_SCANCODE_KP_MEMMULTIPLY,
KpMemDivide = SDL_SCANCODE_KP_MEMDIVIDE,
KpPlusMinus = SDL_SCANCODE_KP_PLUSMINUS,
KpClear = SDL_SCANCODE_KP_CLEAR,
KpClearEntry = SDL_SCANCODE_KP_CLEARENTRY,
KpBinary = SDL_SCANCODE_KP_BINARY,
KpOctal = SDL_SCANCODE_KP_OCTAL,
KpDecimal = SDL_SCANCODE_KP_DECIMAL,
KpHexadecimal = SDL_SCANCODE_KP_HEXADECIMAL,
LCtrl = SDL_SCANCODE_LCTRL,
LShift = SDL_SCANCODE_LSHIFT,
LAlt = SDL_SCANCODE_LALT,
LGui = SDL_SCANCODE_LGUI,
RCtrl = SDL_SCANCODE_RCTRL,
RShift = SDL_SCANCODE_RSHIFT,
RAlt = SDL_SCANCODE_RALT,
RGui = SDL_SCANCODE_RGUI,
Mode = SDL_SCANCODE_MODE,
AudioNext = SDL_SCANCODE_AUDIONEXT,
AudioPrev = SDL_SCANCODE_AUDIOPREV,
AudioStop = SDL_SCANCODE_AUDIOSTOP,
AudioPlay = SDL_SCANCODE_AUDIOPLAY,
AudioMute = SDL_SCANCODE_AUDIOMUTE,
MediaSelect = SDL_SCANCODE_MEDIASELECT,
Www = SDL_SCANCODE_WWW,
Mail = SDL_SCANCODE_MAIL,
Calculator = SDL_SCANCODE_CALCULATOR,
Computer = SDL_SCANCODE_COMPUTER,
AcSearch = SDL_SCANCODE_AC_SEARCH,
AcHome = SDL_SCANCODE_AC_HOME,
AcBack = SDL_SCANCODE_AC_BACK,
AcForward = SDL_SCANCODE_AC_FORWARD,
AcStop = SDL_SCANCODE_AC_STOP,
AcRefresh = SDL_SCANCODE_AC_REFRESH,
AcBookmarks = SDL_SCANCODE_AC_BOOKMARKS,
BrightnessDown = SDL_SCANCODE_BRIGHTNESSDOWN,
BrightnessUp = SDL_SCANCODE_BRIGHTNESSUP,
DisplaySwitch = SDL_SCANCODE_DISPLAYSWITCH,
KbdIllumToggle = SDL_SCANCODE_KBDILLUMTOGGLE,
KbdIllumDown = SDL_SCANCODE_KBDILLUMDOWN,
KbdIllumUp = SDL_SCANCODE_KBDILLUMUP,
Eject = SDL_SCANCODE_EJECT,
Sleep = SDL_SCANCODE_SLEEP,

KEYBOARD_SIZE = SDL_NUM_SCANCODES // This defines the keyboard size
};

enum class MouseButton {
Left = SDL_BUTTON_LEFT,
Middle = SDL_BUTTON_MIDDLE,
Right = SDL_BUTTON_RIGHT,
X1 = SDL_BUTTON_X1,
X2 = SDL_BUTTON_X2,

MOUSE_SIZE // No button, just to define max
// array size.
};
}
Loading