summaryrefslogtreecommitdiffstats
path: root/src/input_common/drivers/android.h
blob: 3f01817f62817b7c4003e38db9017a1efc4942a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later

#pragma once

#include "input_common/input_engine.h"

namespace InputCommon {

/**
 * A virtual controller that is always assigned to the game input
 */
class Android final : public InputEngine {
public:
    explicit Android(std::string input_engine_);

    /**
     * Registers controller number to accept new inputs
     * @param controller_number the controller number that will take this action
     */
    void RegisterController(std::size_t controller_number);

    /**
     * Sets the status of all buttons bound with the key to pressed
     * @param controller_number the controller number that will take this action
     * @param button_id the id of the button
     * @param value indicates if the button is pressed or not
     */
    void SetButtonState(std::size_t controller_number, int button_id, bool value);

    /**
     * Sets the status of a analog input to a specific player index
     * @param controller_number the controller number that will take this action
     * @param axis_id the id of the axis to move
     * @param value the analog position of the axis
     */
    void SetAxisState(std::size_t controller_number, int axis_id, float value);

    /**
     * Sets the status of the motion sensor to a specific player index
     * @param controller_number the controller number that will take this action
     * @param delta_timestamp time passed since last reading
     * @param gyro_x,gyro_y,gyro_z the gyro sensor readings
     * @param accel_x,accel_y,accel_z the accelerometer reading
     */
    void SetMotionState(std::size_t controller_number, u64 delta_timestamp, float gyro_x,
                        float gyro_y, float gyro_z, float accel_x, float accel_y, float accel_z);

private:
    /// Returns the correct identifier corresponding to the player index
    PadIdentifier GetIdentifier(std::size_t controller_number) const;
};

} // namespace InputCommon