diff --git a/sunshine/platform/linux_evdev.cpp b/sunshine/platform/linux_evdev.cpp index 0668d813..9ba08682 100644 --- a/sunshine/platform/linux_evdev.cpp +++ b/sunshine/platform/linux_evdev.cpp @@ -122,7 +122,7 @@ uint16_t keysym(uint16_t modcode) { case 0x2B: return XK_Execute; case 0x2C: - return XK_Print; //FIXME: is this correct? (printscreen) + return XK_Print; case 0x2D: return XK_Insert; case 0x2E: @@ -134,15 +134,15 @@ uint16_t keysym(uint16_t modcode) { case 0x6B: return XK_KP_Add; case 0x6C: - return XK_KP_Decimal; //FIXME: is this correct? (Comma) + return XK_KP_Decimal; case 0x6D: return XK_KP_Subtract; case 0x6E: - return XK_KP_Separator; //FIXME: is this correct? (Period) + return XK_KP_Separator; case 0x6F: return XK_KP_Divide; case 0x90: - return XK_Num_Lock; //FIXME: is this correct: (NumlockClear) + return XK_Num_Lock; case 0x91: return XK_Scroll_Lock; case 0xA0: diff --git a/sunshine/platform/windows.cpp b/sunshine/platform/windows.cpp index af8ce551..b90a4cb1 100755 --- a/sunshine/platform/windows.cpp +++ b/sunshine/platform/windows.cpp @@ -1,5 +1,9 @@ #include +#include +#include + +#include "sunshine/main.h" #include "common.h" namespace platf { @@ -10,10 +14,80 @@ input_t input() { return nullptr; } -void move_mouse(input_t &input, int deltaX, int deltaY) {} -void button_mouse(input_t &input, int button, bool release) {} -void scroll(input_t &input, int distance) {} -void keyboard(input_t &input, uint16_t modcode, bool release) {} +void move_mouse(input_t &input, int deltaX, int deltaY) { + INPUT i {}; + + i.type = INPUT_MOUSE; + auto &mi = i.mi; + + mi.dwFlags = MOUSEEVENTF_MOVE; + mi.dx = deltaX; + mi.dy = deltaY; + + auto send = SendInput(1, &i, sizeof(INPUT)); + if(send != 1) { + BOOST_LOG(warning) << "Couldn't send mouse movement input"sv; + } +} + +void button_mouse(input_t &input, int button, bool release) { + INPUT i {}; + + i.type = INPUT_MOUSE; + auto &mi = i.mi; + + if(button == 1) { + mi.dwFlags = release ? MOUSEEVENTF_LEFTUP : MOUSEEVENTF_LEFTDOWN; + } + else if(button == 2) { + mi.dwFlags = release ? MOUSEEVENTF_MIDDLEUP : MOUSEEVENTF_MIDDLEDOWN; + } + else { + mi.dwFlags = release ? MOUSEEVENTF_RIGHTUP : MOUSEEVENTF_RIGHTDOWN; + } + + auto send = SendInput(1, &i, sizeof(INPUT)); + if(send != 1) { + BOOST_LOG(warning) << "Couldn't send mouse button input"sv; + } +} + +void scroll(input_t &input, int distance) { + INPUT i {}; + + i.type = INPUT_MOUSE; + auto &mi = i.mi; + + mi.dwFlags = MOUSEEVENTF_WHEEL; + mi.mouseData = distance / 120; + + auto send = SendInput(1, &i, sizeof(INPUT)); + if(send != 1) { + BOOST_LOG(warning) << "Couldn't send moue movement input"sv; + } +} + +void keyboard(input_t &input, uint16_t modcode, bool release) { + if(modcode == VK_RMENU) { + modcode = VK_LBUTTON; + } + + INPUT i {}; + i.type = INPUT_KEYBOARD; + auto &ki = i.ki; + +// ki.dwFlags = KEYEVENTF_SCANCODE; + if(release) { + ki.dwFlags = KEYEVENTF_KEYUP; + } + + ki.wVk = modcode; + + auto send = SendInput(1, &i, sizeof(INPUT)); + if(send != 1) { + BOOST_LOG(warning) << "Couldn't send moue movement input"sv; + } +} namespace gp { void dpad_y(input_t &input, int button_state) {} // up pressed == -1, down pressed == 1, else 0