ScummVM API documentation
libretro-os.h
1/* Copyright (C) 2023 Giovanni Cascione <ing.cascione@gmail.com>
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17#ifndef BACKENDS_LIBRETRO_OS_H
18#define BACKENDS_LIBRETRO_OS_H
19
20#include "audio/mixer_intern.h"
21#include "base/main.h"
22//#include "backends/base-backend.h"
23#include "common/system.h"
24#include "common/mutex.h"
25#include "common/list.h"
26#include "common/events.h"
27#include "backends/modular-backend.h"
28#include "graphics/managed_surface.h"
29
30#define BASE_CURSOR_SPEED 4
31#define CURSOR_STATUS_DOING_JOYSTICK (1 << 0)
32#define CURSOR_STATUS_DOING_MOUSE (1 << 1)
33#define CURSOR_STATUS_DOING_X (1 << 2)
34#define CURSOR_STATUS_DOING_Y (1 << 3)
35#define CURSOR_STATUS_DOING_SLOWER (1 << 4)
36
37#define LIBRETRO_G_SYSTEM dynamic_cast<OSystem_libretro *>(g_system)
38
43public:
45 ~LibretroMutexInternal() override {};
46 bool lock() override {
47 return 0;
48 }
49 bool unlock() override {
50 return 0;
51 };
52};
53
55private:
56 int _relMouseX;
57 int _relMouseY;
58 float _mouseXAcc;
59 float _mouseYAcc;
60 float _dpadXAcc;
61 float _dpadYAcc;
62 float _dpadXVel;
63 float _dpadYVel;
64 float _adjusted_cursor_speed;
65 float _inverse_acceleration_time;
66 uint32 _startTime;
67 uint8 _cursorStatus;
68 Common::String s_systemDir;
69 Common::String s_saveDir;
70 Common::String s_playlistDir;
72
73public:
74 Audio::MixerImpl *_mixer;
75 bool _mouseButtons[2];
76 bool _ptrmouseButton;
77 int _mouseX;
78 int _mouseY;
79
80 /* Base */
81 OSystem_libretro(void);
82 ~OSystem_libretro(void) override;
83 void initBackend(void) override;
84 void engineInit(void) override;
85 void refreshRetroSettings(void);
86 void refreshScreen(void);
87 void destroy(void);
88 void quit() override {}
89 void resetGraphicsManager(void);
90 void getScreen(const Graphics::ManagedSurface *&screen);
91 int16 getScreenWidth(void);
92 int16 getScreenHeight(void);
93 bool inLauncher(void);
94
95#ifdef USE_OPENGL
96 void resetGraphicsContext(void);
97#ifdef USE_GLAD
98 void *getOpenGLProcAddress(const char *name) const override;
99#endif
100#endif
101
102 /* Events */
103public:
104 bool pollEvent(Common::Event &event) override;
105 uint32 getMillis(bool skipRecord = false) override;
106 void delayMillis(uint msecs) override;
108 void requestQuit(void);
109 void resetQuit(void);
110 void setMousePosition(int x, int y);
111
112 /* Utils */
113 void getTimeAndDate(TimeDate &t, bool skipRecord) const override;
114 Audio::Mixer *getMixer(void) override;
116 void logMessage(LogMessageType::Type type, const char *message) override;
117 bool hasFeature(Feature f) override;
118 bool openUrl(const Common::String &url) override;
119 int testGame(const char *filedata, bool autodetect);
120 void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0) override;
121 const char *const *buildHelpDialogData() override;
122 Common::String getSaveDir(void);
124 void applyBackendSettings() override;
125private:
126 bool parseGameName(const Common::String &gameName, Common::String &engineId, Common::String &gameId);
127 bool checkPathSetting(const char *setting, Common::String const &defaultPath, bool isDirectory = true);
128 void setLibretroDir(const char *path, Common::String &var);
129
130 /* Inputs */
131public:
132 void processInputs(void);
133 void processKeyEvent(bool down, unsigned keycode, uint32 character, uint16 key_modifiers);
134private:
135 void updateMouseXY(float deltaAcc, float *cumulativeXYAcc, int doing_x);
136 void getMouseXYFromAnalog(bool is_x, int16 coor);
137 void getMouseXYFromButton(bool is_x, int16 sign);
138};
139
140#endif
Definition: mixer.h:70
Definition: mixer_intern.h:58
Definition: base-backend.h:31
Definition: events.h:278
Definition: mutex.h:40
Definition: path.h:52
Definition: archive.h:330
Definition: str.h:59
Definition: object.h:60
Definition: widget.h:542
Definition: managed_surface.h:51
Definition: libretro-os.h:42
Definition: modular-backend.h:48
Definition: libretro-os.h:54
uint32 getMillis(bool skipRecord=false) override
void engineInit(void) override
Audio::Mixer * getMixer(void) override
bool hasFeature(Feature f) override
void logMessage(LogMessageType::Type type, const char *message) override
bool pollEvent(Common::Event &event) override
void applyBackendSettings() override
void getTimeAndDate(TimeDate &t, bool skipRecord) const override
void delayMillis(uint msecs) override
Common::Path getDefaultConfigFileName(void) override
const char *const * buildHelpDialogData() override
GUI::OptionsContainerWidget * buildBackendOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override
void addSysArchivesToSearchSet(Common::SearchSet &s, int priority=0) override
Common::MutexInternal * createMutex(void) override
void initBackend(void) override
bool openUrl(const Common::String &url) override
void quit() override
Definition: libretro-os.h:88
Feature
Definition: system.h:415
Type
Definition: log.h:33
Definition: events.h:218
Definition: system.h:111