2019-12-03 19:23:33 +00:00
|
|
|
//
|
|
|
|
// Created by loki on 6/20/19.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef SUNSHINE_INPUT_H
|
|
|
|
#define SUNSHINE_INPUT_H
|
|
|
|
|
2019-12-08 17:55:58 +00:00
|
|
|
#include "platform/common.h"
|
2019-12-22 22:34:12 +00:00
|
|
|
#include "thread_pool.h"
|
2019-12-03 19:23:33 +00:00
|
|
|
|
|
|
|
namespace input {
|
2020-01-20 19:39:30 +00:00
|
|
|
enum class button_state_e {
|
|
|
|
NONE,
|
|
|
|
DOWN,
|
|
|
|
UP
|
|
|
|
};
|
2019-12-03 19:23:33 +00:00
|
|
|
|
2020-01-25 00:05:43 +00:00
|
|
|
struct gamepad_t {
|
|
|
|
gamepad_t();
|
2020-01-18 22:52:22 +00:00
|
|
|
platf::gamepad_state_t gamepad_state;
|
2019-12-31 11:22:47 +00:00
|
|
|
|
2019-12-22 22:34:12 +00:00
|
|
|
util::ThreadPool::task_id_t back_timeout_id;
|
|
|
|
|
2020-01-20 19:39:30 +00:00
|
|
|
|
|
|
|
// When emulating the HOME button, we may need to artificially release the back button.
|
|
|
|
// Afterwards, the gamepad state on sunshine won't match the state on Moonlight
|
|
|
|
// To prevent Sunshine from sending erronious input data to the active application,
|
|
|
|
// Sunshine forces the button to be in a specific state until the gamepad state matches that of
|
|
|
|
// Moonlight once more.
|
2020-01-25 00:05:43 +00:00
|
|
|
button_state_e back_button_state;
|
|
|
|
};
|
|
|
|
struct input_t {
|
|
|
|
input_t();
|
|
|
|
|
|
|
|
std::unordered_map<short, bool> key_press;
|
|
|
|
std::array<std::uint8_t, 5> mouse_press;
|
|
|
|
|
|
|
|
platf::input_t input;
|
|
|
|
|
|
|
|
std::vector<gamepad_t> gamepads;
|
2019-12-22 20:24:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void print(void *input);
|
2019-12-22 22:34:12 +00:00
|
|
|
void passthrough(std::shared_ptr<input_t> &input, std::vector<std::uint8_t> &&input_data);
|
2019-12-31 11:22:47 +00:00
|
|
|
void reset(std::shared_ptr<input_t> &input);
|
2019-12-03 19:23:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif //SUNSHINE_INPUT_H
|