Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
InputAggregatorInterface.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_INPUT_AGGREGATOR_INIT_H_
34#define DVD_INPUT_AGGREGATOR_INIT_H_
35
36#include "Input.h"
37
38#include <SDL2/SDL_keycode.h>
39
40namespace Divide {
41
42class Kernel;
43class DisplayWindow;
44namespace Input
45{
46
47class InputHandler;
48
49namespace Attorney {
50 class MouseEventKernel;
52};
53
55{
56 explicit InputEvent(DisplayWindow* sourceWindow, U8 deviceIndex) noexcept;
57
60};
61
62struct MouseEvent : public InputEvent
63{
66
67
68 explicit MouseEvent( DisplayWindow* sourceWindow, U8 deviceIndex ) noexcept;
69
70 [[nodiscard]] inline const MouseState& state() const noexcept { return _state; }
71
72 PROPERTY_RW(bool, inScenePreviewRect, false);
73
74protected:
76};
77
79{
81
82 explicit MouseButtonEvent(DisplayWindow* sourceWindow, U8 deviceIndex) noexcept;
83
84 PROPERTY_RW(bool, pressed, false);
86 PROPERTY_RW(U8, numCliks, 0u);
87};
88
90{
92
93 explicit MouseMoveEvent(DisplayWindow* sourceWindow, U8 deviceIndex, bool wheelEvent) noexcept;
94
95 const bool _wheelEvent { false };
96};
97namespace Attorney {
99 private:
100 static MouseState& state(MouseEvent& evt) noexcept
101 {
102 return evt._state;
103 }
104
105 friend class Divide::Kernel;
106 };
107
109 private:
110 static MouseState& state(MouseEvent& evt) noexcept
111 {
112 return evt._state;
113 }
114
116 };
117} //Attorney
118
119struct JoystickEvent final : InputEvent {
120 explicit JoystickEvent(DisplayWindow* sourceWindow, U8 deviceIndex) noexcept;
121
123};
124
125struct TextEvent final : InputEvent {
126 explicit TextEvent(DisplayWindow* sourceWindow, U8 deviceIndex, const char* text) noexcept;
127
129};
130
131struct KeyEvent final : InputEvent {
132
133 explicit KeyEvent(DisplayWindow* sourceWindow, U8 deviceIndex) noexcept;
134
136 bool _pressed{ false };
137 bool _isRepeat{ false };
139 //Native data:
140 SDL_Scancode scancode{};
141 SDL_Keycode sym{};
142};
143
145 public:
146 virtual ~InputAggregatorInterface() = default;
148 virtual bool onKeyDown(const KeyEvent &arg) = 0;
149 virtual bool onKeyUp(const KeyEvent &arg) = 0;
151 virtual bool mouseMoved(const MouseMoveEvent &arg) = 0;
152 virtual bool mouseButtonPressed(const MouseButtonEvent& arg) = 0;
153 virtual bool mouseButtonReleased(const MouseButtonEvent& arg) = 0;
154
156 virtual bool joystickButtonPressed(const JoystickEvent &arg) = 0;
157 virtual bool joystickButtonReleased(const JoystickEvent &arg) = 0;
158 virtual bool joystickAxisMoved(const JoystickEvent &arg) = 0;
159 virtual bool joystickPovMoved(const JoystickEvent &arg) = 0;
160 virtual bool joystickBallMoved(const JoystickEvent &arg) = 0;
161 virtual bool joystickAddRemove(const JoystickEvent &arg) = 0;
162 virtual bool joystickRemap(const JoystickEvent &arg) = 0;
163
164 virtual bool onTextEvent(const TextEvent& arg) = 0;
165};
166
167}; // namespace Input
168}; // namespace Divide
169
170#endif //DVD_INPUT_AGGREGATOR_INIT_H_
static MouseState & state(MouseEvent &evt) noexcept
static MouseState & state(MouseEvent &evt) noexcept
virtual bool joystickPovMoved(const JoystickEvent &arg)=0
virtual bool mouseButtonPressed(const MouseButtonEvent &arg)=0
virtual bool mouseMoved(const MouseMoveEvent &arg)=0
Mouse: return true if input was consumed.
virtual bool onKeyUp(const KeyEvent &arg)=0
virtual bool joystickAxisMoved(const JoystickEvent &arg)=0
virtual bool joystickAddRemove(const JoystickEvent &arg)=0
virtual bool mouseButtonReleased(const MouseButtonEvent &arg)=0
virtual bool joystickButtonReleased(const JoystickEvent &arg)=0
virtual bool onKeyDown(const KeyEvent &arg)=0
Keyboard: return true if input was consumed.
virtual bool joystickRemap(const JoystickEvent &arg)=0
virtual bool joystickButtonPressed(const JoystickEvent &arg)=0
Joystick or Gamepad: return true if input was consumed.
virtual bool joystickBallMoved(const JoystickEvent &arg)=0
virtual bool onTextEvent(const TextEvent &arg)=0
The kernel is the main system that connects all of our various systems: windows, gfx,...
Definition: Kernel.h:81
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
uint8_t U8
uint16_t U16
PROPERTY_RW(bool, pressed, false)
PROPERTY_RW(MouseButton, button, MouseButton::MB_Left)
PROPERTY_RW(bool, inScenePreviewRect, false)
const MouseState & state() const noexcept