mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 00:26:56 +00:00
Add mouse event handling
This commit is contained in:
parent
b5b6329c9d
commit
4db53bd4ed
1
Makefile
1
Makefile
@ -20,6 +20,7 @@ SOURCES = \
|
||||
$(COMMON_C_SOURCE) \
|
||||
libchelper.c \
|
||||
main.cpp \
|
||||
input.cpp \
|
||||
|
||||
# Build rules generated by macros from common.mk:
|
||||
|
||||
|
58
input.cpp
Normal file
58
input.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
#include "moonlight.hpp"
|
||||
|
||||
#include "ppapi/c/ppb_input_event.h"
|
||||
|
||||
#include "ppapi/cpp/input_event.h"
|
||||
|
||||
#include <Limelight.h>
|
||||
|
||||
static int ConvertPPButtonToLiButton(PP_InputEvent_MouseButton ppButton) {
|
||||
switch (ppButton) {
|
||||
case PP_INPUTEVENT_MOUSEBUTTON_LEFT:
|
||||
return BUTTON_LEFT;
|
||||
case PP_INPUTEVENT_MOUSEBUTTON_MIDDLE:
|
||||
return BUTTON_MIDDLE;
|
||||
case PP_INPUTEVENT_MOUSEBUTTON_RIGHT:
|
||||
return BUTTON_RIGHT;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool MoonlightInstance::HandleInputEvent(const pp::InputEvent& event) {
|
||||
switch (event.GetType()) {
|
||||
case PP_INPUTEVENT_TYPE_MOUSEDOWN: {
|
||||
pp::MouseInputEvent mouseEvent(event);
|
||||
|
||||
LiSendMouseButtonEvent(ConvertPPButtonToLiButton(mouseEvent.GetButton()), BUTTON_ACTION_PRESS);
|
||||
return true;
|
||||
}
|
||||
|
||||
case PP_INPUTEVENT_TYPE_MOUSEMOVE: {
|
||||
pp::MouseInputEvent mouseEvent(event);
|
||||
pp::Point posDelta = mouseEvent.GetMovement();
|
||||
|
||||
LiSendMouseMoveEvent(posDelta.x(), posDelta.y());
|
||||
return true;
|
||||
}
|
||||
|
||||
case PP_INPUTEVENT_TYPE_MOUSEUP: {
|
||||
pp::MouseInputEvent mouseEvent(event);
|
||||
|
||||
LiSendMouseButtonEvent(ConvertPPButtonToLiButton(mouseEvent.GetButton()), BUTTON_ACTION_RELEASE);
|
||||
return true;
|
||||
}
|
||||
|
||||
case PP_INPUTEVENT_TYPE_WHEEL: {
|
||||
pp::WheelInputEvent wheelEvent(event);
|
||||
|
||||
// FIXME: Handle fractional scroll ticks
|
||||
LiSendScrollEvent((signed char) wheelEvent.GetTicks().y());
|
||||
return true;
|
||||
}
|
||||
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -12,4 +12,6 @@ class MoonlightInstance : public pp::Instance {
|
||||
}
|
||||
|
||||
virtual ~MoonlightInstance();
|
||||
|
||||
bool HandleInputEvent(const pp::InputEvent& event);
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user