NAP
sdleventconverter.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4 
5 #pragma once
6 
7 // Local Includes
8 #include "sdlinputservice.h"
9 
10 // External Includes
11 #include <utility/dllexport.h>
12 #include <keyboard.h>
13 #include <SDL_events.h>
14 #include <inputevent.h>
15 #include <windowevent.h>
16 
17 namespace nap
18 {
22  class NAPAPI SDLEventConverter final
23  {
24  public:
28  SDLEventConverter(SDLInputService& service) : mService(service) { }
29 
33  virtual ~SDLEventConverter() = default;
34 
39  SDLEventConverter& operator=(const SDLEventConverter&) = delete;
40 
45  SDLEventConverter& operator=(SDLEventConverter&&) = delete;
46 
52  bool isInputEvent(SDL_Event& sdlEvent) const;
53 
59  nap::InputEventPtr translateInputEvent(SDL_Event& sdlEvent);
60 
66  bool isKeyEvent(SDL_Event& sdlEvent) const;
67 
75  nap::InputEventPtr translateKeyEvent(SDL_Event& sdlEvent);
76 
82  bool isMouseEvent(SDL_Event& sdlEvent) const;
83 
91  nap::InputEventPtr translateMouseEvent(SDL_Event& sdlEvent);
92 
98  bool isTouchEvent(SDL_Event& sdlEvent) const;
99 
107  nap::InputEventPtr translateTouchEvent(SDL_Event& sdlEvent);
108 
114  bool isControllerEvent(SDL_Event& sdlEvent) const;
115 
124  nap::InputEventPtr translateControllerEvent(SDL_Event& sdlEvent);
125 
131  bool isWindowEvent(SDL_Event& sdlEvent) const;
132 
138  nap::WindowEventPtr translateWindowEvent(SDL_Event& sdlEvent);
139 
140  private:
141  SDLInputService& mService;
142 
149  nap::InputEvent* translateSDLControllerEvent(SDL_Event& sdlEvent, uint32 sdlType, const rtti::TypeInfo& eventType);
150  };
151 }
nap::SDLInputService
Definition: sdlinputservice.h:27
nap::SDLEventConverter
Definition: sdleventconverter.h:22
nap::uint32
uint32_t uint32
Definition: numeric.h:20
nap::WindowEventPtr
std::unique_ptr< WindowEvent > WindowEventPtr
Definition: windowevent.h:189
nap
Definition: templateapp.h:17
nap::SDLEventConverter::SDLEventConverter
SDLEventConverter(SDLInputService &service)
Definition: sdleventconverter.h:28
nap::InputEventPtr
std::unique_ptr< nap::InputEvent > InputEventPtr
Definition: inputevent.h:414
nap::rtti::TypeInfo
rttr::type TypeInfo
Definition: typeinfo.h:140
nap::InputEvent
Definition: inputevent.h:27