mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-03-29 22:20:24 +00:00
Implement horizontal scrolling and Sunshine detection for Moonlight (#793)
This commit is contained in:
parent
da390c37db
commit
4b642f6e01
@ -188,12 +188,20 @@ void print(PNV_SCROLL_PACKET packet) {
|
||||
<< "--end mouse scroll packet--"sv;
|
||||
}
|
||||
|
||||
void print(PSS_HSCROLL_PACKET packet) {
|
||||
BOOST_LOG(debug)
|
||||
<< "--begin mouse hscroll packet--"sv << std::endl
|
||||
<< "scrollAmount ["sv << util::endian::big(packet->scrollAmount) << ']' << std::endl
|
||||
<< "--end mouse hscroll packet--"sv;
|
||||
}
|
||||
|
||||
void print(PNV_KEYBOARD_PACKET packet) {
|
||||
BOOST_LOG(debug)
|
||||
<< "--begin keyboard packet--"sv << std::endl
|
||||
<< "keyAction ["sv << util::hex(packet->header.magic).to_string_view() << ']' << std::endl
|
||||
<< "keyCode ["sv << util::hex(packet->keyCode).to_string_view() << ']' << std::endl
|
||||
<< "modifiers ["sv << util::hex(packet->modifiers).to_string_view() << ']' << std::endl
|
||||
<< "flags ["sv << util::hex(packet->flags).to_string_view() << ']' << std::endl
|
||||
<< "--end keyboard packet--"sv;
|
||||
}
|
||||
|
||||
@ -238,6 +246,9 @@ void print(void *payload) {
|
||||
case SCROLL_MAGIC_GEN5:
|
||||
print((PNV_SCROLL_PACKET)payload);
|
||||
break;
|
||||
case SS_HSCROLL_MAGIC:
|
||||
print((PSS_HSCROLL_PACKET)payload);
|
||||
break;
|
||||
case KEY_DOWN_EVENT_MAGIC:
|
||||
case KEY_UP_EVENT_MAGIC:
|
||||
print((PNV_KEYBOARD_PACKET)payload);
|
||||
@ -459,6 +470,10 @@ void passthrough(PNV_SCROLL_PACKET packet) {
|
||||
platf::scroll(platf_input, util::endian::big(packet->scrollAmt1));
|
||||
}
|
||||
|
||||
void passthrough(PSS_HSCROLL_PACKET packet) {
|
||||
platf::hscroll(platf_input, util::endian::big(packet->scrollAmount));
|
||||
}
|
||||
|
||||
void passthrough(PNV_UNICODE_PACKET packet) {
|
||||
auto size = util::endian::big(packet->header.size) - sizeof(packet->header.magic);
|
||||
platf::unicode(platf_input, packet->text, size);
|
||||
@ -621,6 +636,9 @@ void passthrough_helper(std::shared_ptr<input_t> input, std::vector<std::uint8_t
|
||||
case SCROLL_MAGIC_GEN5:
|
||||
passthrough((PNV_SCROLL_PACKET)payload);
|
||||
break;
|
||||
case SS_HSCROLL_MAGIC:
|
||||
passthrough((PSS_HSCROLL_PACKET)payload);
|
||||
break;
|
||||
case KEY_DOWN_EVENT_MAGIC:
|
||||
case KEY_UP_EVENT_MAGIC:
|
||||
passthrough(input, (PNV_KEYBOARD_PACKET)payload);
|
||||
|
@ -31,7 +31,8 @@
|
||||
using namespace std::literals;
|
||||
namespace nvhttp {
|
||||
|
||||
constexpr auto VERSION = "7.1.431.0";
|
||||
// The negative 4th version number tells Moonlight that this is Sunshine
|
||||
constexpr auto VERSION = "7.1.431.-1";
|
||||
constexpr auto GFE_VERSION = "3.23.0.74";
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
@ -363,6 +363,7 @@ void move_mouse(input_t &input, int deltaX, int deltaY);
|
||||
void abs_mouse(input_t &input, const touch_port_t &touch_port, float x, float y);
|
||||
void button_mouse(input_t &input, int button, bool release);
|
||||
void scroll(input_t &input, int distance);
|
||||
void hscroll(input_t &input, int distance);
|
||||
void keyboard(input_t &input, uint16_t modcode, bool release);
|
||||
void gamepad(input_t &input, int nr, const gamepad_state_t &gamepad_state);
|
||||
void unicode(input_t &input, char *utf8, int size);
|
||||
|
@ -982,6 +982,19 @@ void scroll(input_t &input, int high_res_distance) {
|
||||
libevdev_uinput_write_event(mouse, EV_SYN, SYN_REPORT, 0);
|
||||
}
|
||||
|
||||
void hscroll(input_t &input, int high_res_distance) {
|
||||
int distance = high_res_distance / 120;
|
||||
|
||||
auto mouse = ((input_raw_t *)input.get())->mouse_input.get();
|
||||
if(!mouse) {
|
||||
return;
|
||||
}
|
||||
|
||||
libevdev_uinput_write_event(mouse, EV_REL, REL_HWHEEL, distance);
|
||||
libevdev_uinput_write_event(mouse, EV_REL, REL_HWHEEL_HI_RES, high_res_distance);
|
||||
libevdev_uinput_write_event(mouse, EV_SYN, SYN_REPORT, 0);
|
||||
}
|
||||
|
||||
static keycode_t keysym(std::uint16_t modcode) {
|
||||
if(modcode <= keycodes.size()) {
|
||||
return keycodes[modcode];
|
||||
|
@ -417,6 +417,10 @@ void scroll(input_t &input, int high_res_distance) {
|
||||
CFRelease(upEvent);
|
||||
}
|
||||
|
||||
void hscroll(input_t &input, int high_res_distance) {
|
||||
// Unimplemented
|
||||
}
|
||||
|
||||
input_t input() {
|
||||
input_t result { new macos_input_t() };
|
||||
|
||||
|
@ -303,6 +303,18 @@ void scroll(input_t &input, int distance) {
|
||||
send_input(i);
|
||||
}
|
||||
|
||||
void hscroll(input_t &input, int distance) {
|
||||
INPUT i {};
|
||||
|
||||
i.type = INPUT_MOUSE;
|
||||
auto &mi = i.mi;
|
||||
|
||||
mi.dwFlags = MOUSEEVENTF_HWHEEL;
|
||||
mi.mouseData = distance;
|
||||
|
||||
send_input(i);
|
||||
}
|
||||
|
||||
void keyboard(input_t &input, uint16_t modcode, bool release) {
|
||||
auto raw = (input_raw_t *)input.get();
|
||||
|
||||
|
@ -399,13 +399,12 @@ session_t *control_server_t::get_session(const net::peer_t peer) {
|
||||
void control_server_t::call(std::uint16_t type, session_t *session, const std::string_view &payload) {
|
||||
auto cb = _map_type_cb.find(type);
|
||||
if(cb == std::end(_map_type_cb)) {
|
||||
BOOST_LOG(warning)
|
||||
BOOST_LOG(debug)
|
||||
<< "type [Unknown] { "sv << util::hex(type).to_string_view() << " }"sv << std::endl
|
||||
<< "---data---"sv << std::endl
|
||||
<< util::hex_vec(payload) << std::endl
|
||||
<< "---end data---"sv;
|
||||
}
|
||||
|
||||
else {
|
||||
cb->second(session, payload);
|
||||
}
|
||||
|
2
third-party/moonlight-common-c
vendored
2
third-party/moonlight-common-c
vendored
@ -1 +1 @@
|
||||
Subproject commit ef9ad529a493d699724d84a189cc1899afcc2d72
|
||||
Subproject commit 07beb0f0a520106c49fda7664369b29e6938ea6e
|
Loading…
x
Reference in New Issue
Block a user