mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-04-09 21:45: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;
|
<< "--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) {
|
void print(PNV_KEYBOARD_PACKET packet) {
|
||||||
BOOST_LOG(debug)
|
BOOST_LOG(debug)
|
||||||
<< "--begin keyboard packet--"sv << std::endl
|
<< "--begin keyboard packet--"sv << std::endl
|
||||||
<< "keyAction ["sv << util::hex(packet->header.magic).to_string_view() << ']' << 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
|
<< "keyCode ["sv << util::hex(packet->keyCode).to_string_view() << ']' << std::endl
|
||||||
<< "modifiers ["sv << util::hex(packet->modifiers).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;
|
<< "--end keyboard packet--"sv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,6 +246,9 @@ void print(void *payload) {
|
|||||||
case SCROLL_MAGIC_GEN5:
|
case SCROLL_MAGIC_GEN5:
|
||||||
print((PNV_SCROLL_PACKET)payload);
|
print((PNV_SCROLL_PACKET)payload);
|
||||||
break;
|
break;
|
||||||
|
case SS_HSCROLL_MAGIC:
|
||||||
|
print((PSS_HSCROLL_PACKET)payload);
|
||||||
|
break;
|
||||||
case KEY_DOWN_EVENT_MAGIC:
|
case KEY_DOWN_EVENT_MAGIC:
|
||||||
case KEY_UP_EVENT_MAGIC:
|
case KEY_UP_EVENT_MAGIC:
|
||||||
print((PNV_KEYBOARD_PACKET)payload);
|
print((PNV_KEYBOARD_PACKET)payload);
|
||||||
@ -459,6 +470,10 @@ void passthrough(PNV_SCROLL_PACKET packet) {
|
|||||||
platf::scroll(platf_input, util::endian::big(packet->scrollAmt1));
|
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) {
|
void passthrough(PNV_UNICODE_PACKET packet) {
|
||||||
auto size = util::endian::big(packet->header.size) - sizeof(packet->header.magic);
|
auto size = util::endian::big(packet->header.size) - sizeof(packet->header.magic);
|
||||||
platf::unicode(platf_input, packet->text, size);
|
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:
|
case SCROLL_MAGIC_GEN5:
|
||||||
passthrough((PNV_SCROLL_PACKET)payload);
|
passthrough((PNV_SCROLL_PACKET)payload);
|
||||||
break;
|
break;
|
||||||
|
case SS_HSCROLL_MAGIC:
|
||||||
|
passthrough((PSS_HSCROLL_PACKET)payload);
|
||||||
|
break;
|
||||||
case KEY_DOWN_EVENT_MAGIC:
|
case KEY_DOWN_EVENT_MAGIC:
|
||||||
case KEY_UP_EVENT_MAGIC:
|
case KEY_UP_EVENT_MAGIC:
|
||||||
passthrough(input, (PNV_KEYBOARD_PACKET)payload);
|
passthrough(input, (PNV_KEYBOARD_PACKET)payload);
|
||||||
|
@ -31,7 +31,8 @@
|
|||||||
using namespace std::literals;
|
using namespace std::literals;
|
||||||
namespace nvhttp {
|
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";
|
constexpr auto GFE_VERSION = "3.23.0.74";
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
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 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 button_mouse(input_t &input, int button, bool release);
|
||||||
void scroll(input_t &input, int distance);
|
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 keyboard(input_t &input, uint16_t modcode, bool release);
|
||||||
void gamepad(input_t &input, int nr, const gamepad_state_t &gamepad_state);
|
void gamepad(input_t &input, int nr, const gamepad_state_t &gamepad_state);
|
||||||
void unicode(input_t &input, char *utf8, int size);
|
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);
|
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) {
|
static keycode_t keysym(std::uint16_t modcode) {
|
||||||
if(modcode <= keycodes.size()) {
|
if(modcode <= keycodes.size()) {
|
||||||
return keycodes[modcode];
|
return keycodes[modcode];
|
||||||
|
@ -417,6 +417,10 @@ void scroll(input_t &input, int high_res_distance) {
|
|||||||
CFRelease(upEvent);
|
CFRelease(upEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hscroll(input_t &input, int high_res_distance) {
|
||||||
|
// Unimplemented
|
||||||
|
}
|
||||||
|
|
||||||
input_t input() {
|
input_t input() {
|
||||||
input_t result { new macos_input_t() };
|
input_t result { new macos_input_t() };
|
||||||
|
|
||||||
|
@ -303,6 +303,18 @@ void scroll(input_t &input, int distance) {
|
|||||||
send_input(i);
|
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) {
|
void keyboard(input_t &input, uint16_t modcode, bool release) {
|
||||||
auto raw = (input_raw_t *)input.get();
|
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) {
|
void control_server_t::call(std::uint16_t type, session_t *session, const std::string_view &payload) {
|
||||||
auto cb = _map_type_cb.find(type);
|
auto cb = _map_type_cb.find(type);
|
||||||
if(cb == std::end(_map_type_cb)) {
|
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
|
<< "type [Unknown] { "sv << util::hex(type).to_string_view() << " }"sv << std::endl
|
||||||
<< "---data---"sv << std::endl
|
<< "---data---"sv << std::endl
|
||||||
<< util::hex_vec(payload) << std::endl
|
<< util::hex_vec(payload) << std::endl
|
||||||
<< "---end data---"sv;
|
<< "---end data---"sv;
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
cb->second(session, payload);
|
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