2022-04-23 01:59:50 -07:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2021-09-20 14:29:43 -07:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-11-01 13:17:53 -07:00
|
|
|
namespace Common::Input {
|
2021-09-20 14:29:43 -07:00
|
|
|
struct CallbackStatus;
|
2021-11-01 13:17:53 -07:00
|
|
|
enum class BatteryLevel : u32;
|
|
|
|
using BatteryStatus = BatteryLevel;
|
|
|
|
struct AnalogStatus;
|
|
|
|
struct ButtonStatus;
|
|
|
|
struct MotionStatus;
|
|
|
|
struct StickStatus;
|
|
|
|
struct TouchStatus;
|
|
|
|
struct TriggerStatus;
|
|
|
|
}; // namespace Common::Input
|
2021-09-20 14:29:43 -07:00
|
|
|
|
|
|
|
namespace Core::HID {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts raw input data into a valid battery status.
|
|
|
|
*
|
2021-11-29 13:16:05 -08:00
|
|
|
* @param callback Supported callbacks: Analog, Battery, Trigger.
|
2021-09-20 14:29:43 -07:00
|
|
|
* @return A valid BatteryStatus object.
|
|
|
|
*/
|
2021-10-30 20:23:10 -07:00
|
|
|
Common::Input::BatteryStatus TransformToBattery(const Common::Input::CallbackStatus& callback);
|
2021-09-20 14:29:43 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts raw input data into a valid button status. Applies invert properties to the output.
|
|
|
|
*
|
2021-11-29 13:16:05 -08:00
|
|
|
* @param callback Supported callbacks: Analog, Button, Trigger.
|
2021-09-20 14:29:43 -07:00
|
|
|
* @return A valid TouchStatus object.
|
|
|
|
*/
|
2021-10-30 20:23:10 -07:00
|
|
|
Common::Input::ButtonStatus TransformToButton(const Common::Input::CallbackStatus& callback);
|
2021-09-20 14:29:43 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts raw input data into a valid motion status.
|
|
|
|
*
|
2021-11-29 13:16:05 -08:00
|
|
|
* @param callback Supported callbacks: Motion.
|
2021-09-20 14:29:43 -07:00
|
|
|
* @return A valid TouchStatus object.
|
|
|
|
*/
|
2021-10-30 20:23:10 -07:00
|
|
|
Common::Input::MotionStatus TransformToMotion(const Common::Input::CallbackStatus& callback);
|
2021-09-20 14:29:43 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts raw input data into a valid stick status. Applies offset, deadzone, range and invert
|
|
|
|
* properties to the output.
|
|
|
|
*
|
2021-11-29 13:16:05 -08:00
|
|
|
* @param callback Supported callbacks: Stick.
|
2021-09-20 14:29:43 -07:00
|
|
|
* @return A valid StickStatus object.
|
|
|
|
*/
|
2021-10-30 20:23:10 -07:00
|
|
|
Common::Input::StickStatus TransformToStick(const Common::Input::CallbackStatus& callback);
|
2021-09-20 14:29:43 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts raw input data into a valid touch status.
|
|
|
|
*
|
2021-11-29 13:16:05 -08:00
|
|
|
* @param callback Supported callbacks: Touch.
|
2021-09-20 14:29:43 -07:00
|
|
|
* @return A valid TouchStatus object.
|
|
|
|
*/
|
2021-10-30 20:23:10 -07:00
|
|
|
Common::Input::TouchStatus TransformToTouch(const Common::Input::CallbackStatus& callback);
|
2021-09-20 14:29:43 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts raw input data into a valid trigger status. Applies offset, deadzone, range and
|
|
|
|
* invert properties to the output. Button status uses the threshold property if necessary.
|
|
|
|
*
|
2021-11-29 13:16:05 -08:00
|
|
|
* @param callback Supported callbacks: Analog, Button, Trigger.
|
2021-09-20 14:29:43 -07:00
|
|
|
* @return A valid TriggerStatus object.
|
|
|
|
*/
|
2021-10-30 20:23:10 -07:00
|
|
|
Common::Input::TriggerStatus TransformToTrigger(const Common::Input::CallbackStatus& callback);
|
2021-09-20 14:29:43 -07:00
|
|
|
|
2021-11-14 12:09:29 -08:00
|
|
|
/**
|
|
|
|
* Converts raw input data into a valid analog status. Applies offset, deadzone, range and
|
|
|
|
* invert properties to the output.
|
|
|
|
*
|
2021-11-29 13:16:05 -08:00
|
|
|
* @param callback Supported callbacks: Analog.
|
2021-11-14 12:09:29 -08:00
|
|
|
* @return A valid AnalogStatus object.
|
|
|
|
*/
|
|
|
|
Common::Input::AnalogStatus TransformToAnalog(const Common::Input::CallbackStatus& callback);
|
|
|
|
|
2022-06-18 21:36:29 -07:00
|
|
|
/**
|
|
|
|
* Converts raw input data into a valid camera status.
|
|
|
|
*
|
|
|
|
* @param callback Supported callbacks: Camera.
|
|
|
|
* @return A valid CameraObject object.
|
|
|
|
*/
|
|
|
|
Common::Input::CameraStatus TransformToCamera(const Common::Input::CallbackStatus& callback);
|
|
|
|
|
2022-09-24 18:36:40 -07:00
|
|
|
/**
|
|
|
|
* Converts raw input data into a valid nfc status.
|
|
|
|
*
|
|
|
|
* @param callback Supported callbacks: Nfc.
|
|
|
|
* @return A valid CameraObject object.
|
|
|
|
*/
|
|
|
|
Common::Input::NfcStatus TransformToNfc(const Common::Input::CallbackStatus& callback);
|
|
|
|
|
2021-09-20 14:29:43 -07:00
|
|
|
/**
|
|
|
|
* Converts raw analog data into a valid analog value
|
2021-11-29 13:16:05 -08:00
|
|
|
* @param analog An analog object containing raw data and properties
|
|
|
|
* @param clamp_value determines if the value needs to be clamped between -1.0f and 1.0f.
|
2021-09-20 14:29:43 -07:00
|
|
|
*/
|
2021-10-30 20:23:10 -07:00
|
|
|
void SanitizeAnalog(Common::Input::AnalogStatus& analog, bool clamp_value);
|
2021-09-20 14:29:43 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Converts raw stick data into a valid stick value
|
2021-11-29 13:16:05 -08:00
|
|
|
* @param analog_x raw analog data and properties for the x-axis
|
|
|
|
* @param analog_y raw analog data and properties for the y-axis
|
|
|
|
* @param clamp_value bool that determines if the value needs to be clamped into the unit circle.
|
2021-09-20 14:29:43 -07:00
|
|
|
*/
|
2021-10-30 20:23:10 -07:00
|
|
|
void SanitizeStick(Common::Input::AnalogStatus& analog_x, Common::Input::AnalogStatus& analog_y,
|
|
|
|
bool clamp_value);
|
2021-09-20 14:29:43 -07:00
|
|
|
|
|
|
|
} // namespace Core::HID
|