31template <
typename Service>
41 if constexpr (!::std::is_default_constructible<Service>::value)
49 _singleton =
new Service();
52 throw ::std::runtime_error(
"Service provider not injected");
62 template <
class Provider,
typename... _Args>
63 static void inject(_Args &&...__args)
67 std::is_base_of<Service, Provider>::value,
68 "Provider does not implement Service");
69 inject(
new Provider(::std::forward<_Args>(__args)...));
77 static void inject(Service *provider)
82 _singleton = provider;
84 throw ::std::runtime_error(
85 "Provider already injected to service");
88 throw ::std::runtime_error(
"A null provider is not allowed");
103 inline static Service *_singleton =
nullptr;
157 return (PulseWidthMultiplier::X1);
177 int &maxRight) {
return (
false); }
204 bool &leftAxisReversed,
205 bool &rightAxisReversed) {}
215 bool leftAxisReversed,
216 bool rightAxisReversed,
265 return (ClutchWorkingMode::_DEFAULT_VALUE);
275 return (AltButtonsWorkingMode::_DEFAULT_VALUE);
285 return (DPadWorkingMode::_DEFAULT_VALUE);
360 uint8_t firmware_defined,
361 uint8_t user_defined,
362 uint8_t user_defined_alt) {}
374 uint8_t firmware_defined,
375 uint8_t &user_defined,
376 uint8_t &user_defined_alt)
378 user_defined = firmware_defined;
379 user_defined_alt = firmware_defined + 64;
536 uint8_t index, uint16_t data,
579 uint16_t &customPID) {}
630 friend void firmwareSetIsRunningState(
bool state);
638 return (_is_running);
642 inline static bool _is_running =
false;
Types and constants used everywhere for firmware implementation.
ClutchWorkingMode
User-selected working mode of the clutch paddles.
PulseWidthMultiplier
User-selected pulse width multiplier.
AltButtonsWorkingMode
User-selected working mode of "ALT" buttons.
DPadWorkingMode
User-selected working mode of directional pads.
#define CLUTCH_DEFAULT_VALUE
Default bite point value.
Battery calibration service.
virtual void setAutoCalibrationParameter(int value, bool save=true)
Set the auto-calibration parameter.
virtual int getAutoCalibrationParameter()
Get the auto-calibration parameter.
virtual void restartAutoCalibration()
Restart autocalibration algorithm.
virtual uint16_t getCalibrationData(uint8_t index)
Get calibration data.
virtual uint8_t getCalibrationDataCount()
Get the count of calibration data items.
virtual int getBatteryLevelAutoCalibrated(int reading)
Get a percentage of battery charge using auto-calibration. Will provide incorrect battery levels (hig...
virtual int getBatteryLevel(int reading)
Get a percentage of battery charge based on calibration data.
virtual void setCalibrationData(uint8_t index, uint16_t data, bool save=true)
Set calibration data.
virtual void getStatus(BatteryStatus &status)
Get the full battery status.
virtual bool isBatteryPresent()
Check if the battery is detected.
virtual int getLastBatteryLevel()
Get the last known battery level (SoC)
virtual bool hasBattery()
Check if the device can be powered by a battery.
virtual bool isRunning()
Check if the firmware daemons are already running.
virtual void getCustomHardwareID(uint16_t &customVID, uint16_t &customPID)
Get the user-defined custom hardware ID.
virtual void setCustomHardwareID(uint16_t customVID, uint16_t customPID, bool save=true)
Set the user-defiend custom hardware ID.
virtual void shutdown()
Command a system shutdown.
virtual uint8_t getMaxFPS()
Get the maximum frames per seconds value required by UI instances.
static Service & call()
Get the service provider implementing the service.
static void inject(Service *provider)
Inject a service provider.
static void reset()
Remove the injected service provider (for testing)
static void inject(_Args &&...__args)
Inject a service provider.