openMSX
InputEventGenerator.hh
Go to the documentation of this file.
1#ifndef INPUTEVENTGENERATOR_HH
2#define INPUTEVENTGENERATOR_HH
3
4#include "BooleanSetting.hh"
5#include "Command.hh"
6#include "EventListener.hh"
7#include "JoystickManager.hh"
8
9#include "SDLKey.hh"
10#include <SDL.h>
11
12namespace openmsx {
13
14class CommandController;
15class EventDistributor;
16class GlobalSettings;
17
19{
20public:
23
24 InputEventGenerator(CommandController& commandController,
25 EventDistributor& eventDistributor,
26 GlobalSettings& globalSettings);
28
32 void wait();
33
35 [[nodiscard]] BooleanSetting& getGrabInput() { return grabInput; }
37 void updateGrab(bool grab);
38
39 void poll();
40
41 [[nodiscard]] JoystickManager& getJoystickManager() { return joystickManager; }
42
43private:
44 void handle(const SDL_Event& evt);
45 void handleKeyDown(const SDL_KeyboardEvent& key, uint32_t unicode);
46 void splitText(uint32_t timestamp, const char* utf8);
47 void setGrabInput(bool grab);
48
49 // EventListener
50 int signalEvent(const Event& event) override;
51
52 EventDistributor& eventDistributor;
53 GlobalSettings& globalSettings;
54 JoystickManager joystickManager;
55 BooleanSetting grabInput;
56
57 struct EscapeGrabCmd final : Command {
58 explicit EscapeGrabCmd(CommandController& commandController);
59 void execute(std::span<const TclObject> tokens, TclObject& result) override;
60 [[nodiscard]] std::string help(std::span<const TclObject> tokens) const override;
61 } escapeGrabCmd;
62
63 enum EscapeGrabState {
64 ESCAPE_GRAB_WAIT_CMD,
65 ESCAPE_GRAB_WAIT_LOST,
66 ESCAPE_GRAB_WAIT_GAIN
67 } escapeGrabState = ESCAPE_GRAB_WAIT_CMD;
68
69 // OsdControl
70 void setNewOsdControlButtonState(unsigned newState);
71 void triggerOsdControlEventsFromJoystickAxisMotion(unsigned axis, int value);
72 void triggerOsdControlEventsFromJoystickHat(int value);
73 void osdControlChangeButton(bool down, unsigned changedButtonMask);
74 void triggerOsdControlEventsFromJoystickButtonEvent(unsigned button, bool down);
75 void triggerOsdControlEventsFromKeyEvent(SDLKey key, bool repeat);
76
77private:
78 unsigned osdControlButtonsState = unsigned(~0); // 0 is pressed, 1 is released
79
80 // only for Android
81 static inline bool androidButtonA = false;
82 static inline bool androidButtonB = false;
83};
84
85} // namespace openmsx
86
87#endif
This class contains settings that are used by several other class (including some singletons).
InputEventGenerator(const InputEventGenerator &)=delete
BooleanSetting & getGrabInput()
Input Grab on or off.
JoystickManager & getJoystickManager()
void updateGrab(bool grab)
Must be called when 'grabinput' or 'fullscreen' setting changes.
void wait()
Wait for event(s) and handle it.
InputEventGenerator & operator=(const InputEventGenerator &)=delete
This file implemented 3 utility functions:
Definition Autofire.cc:9
std::variant< KeyUpEvent, KeyDownEvent, MouseMotionEvent, MouseButtonUpEvent, MouseButtonDownEvent, MouseWheelEvent, JoystickAxisMotionEvent, JoystickHatEvent, JoystickButtonUpEvent, JoystickButtonDownEvent, OsdControlReleaseEvent, OsdControlPressEvent, WindowEvent, TextEvent, FileDropEvent, QuitEvent, FinishFrameEvent, CliCommandEvent, GroupEvent, BootEvent, FrameDrawnEvent, BreakEvent, SwitchRendererEvent, TakeReverseSnapshotEvent, AfterTimedEvent, MachineLoadedEvent, MachineActivatedEvent, MachineDeactivatedEvent, MidiInReaderEvent, MidiInWindowsEvent, MidiInCoreMidiEvent, MidiInCoreMidiVirtualEvent, MidiInALSAEvent, Rs232TesterEvent, Rs232NetEvent, ImGuiDelayedActionEvent, ImGuiActiveEvent > Event
Definition Event.hh:454
constexpr void repeat(T n, Op op)
Repeat the given operation 'op' 'n' times.
Definition xrange.hh:147