@@ -61,8 +61,7 @@ namespace input {
6161 * @note regarding the NOLINT: the destructor just cleans up the SDL_Joystick, it has nothing to do with class members that would need special member functions to be explicitly defined
6262 *
6363 */
64- struct JoystickInput // NOLINT(cppcoreguidelines-special-member-functions)
65- : Input {
64+ struct JoystickInput : Input {
6665 private:
6766 SDL_Joystick* m_joystick;
6867 SDL_JoystickID m_instance_id;
@@ -76,7 +75,14 @@ namespace input {
7675
7776 public:
7877 JoystickInput (SDL_Joystick* joystick, SDL_JoystickID instance_id, const std::string& name);
79- ~JoystickInput ();
78+
79+ ~JoystickInput () override ;
80+
81+ JoystickInput (const JoystickInput& input) noexcept ;
82+ JoystickInput& operator =(const JoystickInput& input) noexcept ;
83+
84+ JoystickInput (JoystickInput&& input) noexcept ;
85+ JoystickInput& operator =(JoystickInput&& input) noexcept ;
8086
8187 [[nodiscard]] static helper::expected<std::unique_ptr<JoystickInput>, std::string> get_by_device_index (
8288 int device_index
@@ -204,21 +210,21 @@ namespace input {
204210 X_LIST_MACRO (open_settings)
205211
206212
207- #define TRY_CONVERT (original, target, map, key ) \
208- do /* NOLINT(cppcoreguidelines-avoid-do-while)*/ { \
209- if (map.contains (original.key )) { \
210- target.key = map.at (original.key ); \
211- } else { \
212- return helper::unexpected<std::string>{ \
213- fmt::format (" While parsing key '{}': '{}' is not a valid joystick input" , #key, original.key ) \
214- }; \
215- } \
213+ #define TRY_CONVERT (original, target, map, key ) /* NOLINT(cppcoreguidelines-macro-usage) */ \
214+ do /* NOLINT(cppcoreguidelines-avoid-do-while)*/ { \
215+ if (( map) .contains (( original) .key )) { \
216+ ( target) .key = ( map) .at (( original) .key ); \
217+ } else { \
218+ return helper::unexpected<std::string>{ \
219+ fmt::format (" While parsing key '{}': '{}' is not a valid joystick input" , #key, ( original) .key ) \
220+ }; \
221+ } \
216222 } while (false )
217223
218224
219- #define SETTINGS_TO_STRING (original, target, fn, key ) \
220- do /* NOLINT(cppcoreguidelines-avoid-do-while)*/ { \
221- target.key = fn (original.key ); \
225+ #define SETTINGS_TO_STRING (original, target, fn, key ) /* NOLINT(cppcoreguidelines-macro-usage) */ \
226+ do /* NOLINT(cppcoreguidelines-avoid-do-while)*/ { \
227+ ( target) .key = fn (( original) .key ); \
222228 } while (false )
223229
224230
@@ -227,20 +233,23 @@ namespace input {
227233 std::vector<SDL_Event> m_event_buffer;
228234 EventDispatcher* m_event_dispatcher;
229235
230- protected:
236+
231237 JoystickInput* m_underlying_input;
232238
239+ protected:
240+ [[nodiscard]] const JoystickInput* underlying_input () const ;
241+
242+
233243 public:
234- JoystickGameInput (EventDispatcher* event_dispatcher, JoystickInput* underlying_input)
235- : GameInput{ GameInputType::Controller },
236- m_event_dispatcher{ event_dispatcher },
237- m_underlying_input{ underlying_input } {
238- m_event_dispatcher->register_listener (this );
239- }
244+ JoystickGameInput (EventDispatcher* event_dispatcher, JoystickInput* underlying_input);
240245
241- ~JoystickGameInput () override {
242- m_event_dispatcher->unregister_listener (this );
243- }
246+ ~JoystickGameInput () override ;
247+
248+ JoystickGameInput (const JoystickGameInput& input) = delete ;
249+ [[nodiscard]] JoystickGameInput& operator =(const JoystickGameInput& input) = delete ;
250+
251+ JoystickGameInput (JoystickGameInput&& input) noexcept ;
252+ [[nodiscard]] JoystickGameInput& operator =(JoystickGameInput&& input) noexcept ;
244253
245254 void handle_event (const SDL_Event& event) override ;
246255
@@ -264,7 +273,7 @@ namespace input {
264273 AbstractJoystickSettings<T> result{};
265274
266275
267- #define X_LIST_MACRO (x ) TRY_CONVERT(settings, result, map, x);
276+ #define X_LIST_MACRO (x ) TRY_CONVERT(settings, result, map, x); // NOLINT(cppcoreguidelines-macro-usage)
268277
269278 X_LIST_OF_SETTINGS_KEYS
270279
@@ -343,8 +352,8 @@ namespace nlohmann {
343352 return input::JoystickIdentification{ .guid = value.value (), .name = name };
344353 }
345354
346- static void to_json (json& j , const input::JoystickIdentification& identification) {
347- j = nlohmann::json{
355+ static void to_json (json& obj , const input::JoystickIdentification& identification) {
356+ obj = nlohmann::json{
348357 { " guid" , identification.guid .to_string (), { " name" , identification.name } },
349358 };
350359 }
@@ -359,7 +368,7 @@ namespace nlohmann {
359368 " move_down" , " drop" , " hold" , " menu" }
360369 );
361370
362- input::JoystickIdentification identification =
371+ const input::JoystickIdentification identification =
363372 adl_serializer<input::JoystickIdentification>::from_json (obj.at (" identification" ));
364373
365374 const auto rotate_left = json_helper::get_key_from_object (obj, " rotate_left" );
0 commit comments