LCOV - code coverage report
Current view: top level - platform/joystick - joystick.hpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 1 0
Test Date: 2025-06-11 17:47:30 Functions: - 0 0
Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : #pragma once
       2                 :             : 
       3                 :             : #include <SDL2/SDL.h>
       4                 :             : #include <SDL2/SDL_gamecontroller.h>
       5                 :             : 
       6                 :             : #include <array>
       7                 :             : #include <functional>
       8                 :             : #include <iostream>
       9                 :             : #include <map>
      10                 :             : #include <utility>
      11                 :             : 
      12                 :             : #include "platform/carMove/carMove.hpp"
      13                 :             : #include "platform/remoteMove/remoteMove.hpp"
      14                 :             : 
      15                 :             : struct Actions {
      16                 :             :     std::function<void()> onPress;
      17                 :             :     std::function<void()> onRelease;
      18                 :             : };
      19                 :             : 
      20                 :             : class Joystick {
      21                 :             :    public:
      22                 :             :     explicit Joystick(CarMove& car);
      23                 :             :     ~Joystick();
      24                 :             :     void setButtonAction(int button, Actions actions);
      25                 :             :     void setAxisAction(int axis, std::function<void(int)> action);
      26                 :             :     void setAxisMapping(CarMove& car);
      27                 :             :     void listen();
      28                 :             :     void printButtonStates();
      29                 :             : 
      30                 :             :    private:
      31                 :             :     SDL_GameController* gameController;
      32                 :             :     std::map<int, Actions> buttonActions;
      33                 :             :     std::map<int, std::function<void(int)>> axisActions;
      34                 :             :     std::array<bool, SDL_CONTROLLER_BUTTON_MAX> buttonStates{};
      35                 :             :     void processEvent(const SDL_Event& event);
      36                 :             :     RemoteMove* remote;
      37                 :             : 
      38                 :             :     int shutdownButton = 7;
      39                 :             :     std::chrono::steady_clock::time_point shutdownButtonPressTime;
      40                 :             :     bool isShutdownButtonHeld = false;
      41                 :           0 :     const std::chrono::seconds shutdownHoldDuration{3};
      42                 :             : 
      43                 :             :     CarMove* car_ref;
      44                 :             : };
        

Generated by: LCOV version 2.0-1