mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2025-07-21 03:32:43 +00:00
Added scrolling and right click
This commit is contained in:
parent
c3b44a32d5
commit
5f800b7901
@ -19,36 +19,64 @@
|
|||||||
touchLocation = [touch locationInView:self];
|
touchLocation = [touch locationInView:self];
|
||||||
touchMoved = false;
|
touchMoved = false;
|
||||||
|
|
||||||
printf("Touch down\n");
|
NSLog(@"Touch down");
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||||
UITouch *touch = [[event allTouches] anyObject];
|
|
||||||
CGPoint currentLocation = [touch locationInView:self];
|
|
||||||
|
|
||||||
if (touchLocation.x != currentLocation.x ||
|
if ([[event allTouches] count] == 1) {
|
||||||
touchLocation.y != currentLocation.y)
|
UITouch *touch = [[event allTouches] anyObject];
|
||||||
{
|
CGPoint currentLocation = [touch locationInView:self];
|
||||||
LiSendMouseMoveEvent(currentLocation.x - touchLocation.x,
|
|
||||||
currentLocation.y - touchLocation.y );
|
|
||||||
|
|
||||||
|
if (touchLocation.x != currentLocation.x ||
|
||||||
|
touchLocation.y != currentLocation.y)
|
||||||
|
{
|
||||||
|
LiSendMouseMoveEvent(currentLocation.x - touchLocation.x,
|
||||||
|
currentLocation.y - touchLocation.y );
|
||||||
|
|
||||||
|
touchMoved = true;
|
||||||
|
touchLocation = currentLocation;
|
||||||
|
}
|
||||||
|
} else if ([[event allTouches] count] == 2) {
|
||||||
|
CGPoint firstLocation = [[[[event allTouches] allObjects] objectAtIndex:0] locationInView:self];
|
||||||
|
CGPoint secondLocation = [[[[event allTouches] allObjects] objectAtIndex:1] locationInView:self];
|
||||||
|
|
||||||
|
CGPoint avgLocation = CGPointMake((firstLocation.x + secondLocation.x) / 2, (firstLocation.y + secondLocation.y) / 2);
|
||||||
|
if (touchLocation.y != avgLocation.y) {
|
||||||
|
LiSendScrollEvent(avgLocation.y - touchLocation.y);
|
||||||
|
}
|
||||||
touchMoved = true;
|
touchMoved = true;
|
||||||
touchLocation = currentLocation;
|
touchLocation = avgLocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||||
printf("Touch up\n");
|
NSLog(@"Touch up");
|
||||||
|
|
||||||
|
|
||||||
if (!touchMoved) {
|
if (!touchMoved) {
|
||||||
printf("Sending left mouse button press\n");
|
if ([[event allTouches] count] == 2) {
|
||||||
|
NSLog(@"Sending right mouse button press");
|
||||||
|
|
||||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT);
|
||||||
|
|
||||||
// Wait 100 ms to simulate a real button press
|
// Wait 100 ms to simulate a real button press
|
||||||
usleep(100 * 1000);
|
usleep(100 * 1000);
|
||||||
|
|
||||||
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT);
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
NSLog(@"Sending left mouse button press");
|
||||||
|
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
||||||
|
|
||||||
|
// Wait 100 ms to simulate a real button press
|
||||||
|
usleep(100 * 1000);
|
||||||
|
|
||||||
|
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +130,7 @@
|
|||||||
<scene sceneID="RuD-qk-7nb">
|
<scene sceneID="RuD-qk-7nb">
|
||||||
<objects>
|
<objects>
|
||||||
<viewController storyboardIdentifier="MainFrame" id="OIm-0n-i9v" customClass="StreamFrameViewController" sceneMemberID="viewController">
|
<viewController storyboardIdentifier="MainFrame" id="OIm-0n-i9v" customClass="StreamFrameViewController" sceneMemberID="viewController">
|
||||||
<view key="view" contentMode="scaleToFill" id="VPm-Ae-rc4" userLabel="RenderView" customClass="StreamView">
|
<view key="view" multipleTouchEnabled="YES" contentMode="scaleToFill" id="VPm-Ae-rc4" userLabel="RenderView" customClass="StreamView">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="1024" height="768"/>
|
<rect key="frame" x="0.0" y="0.0" width="1024" height="768"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
@ -165,7 +165,7 @@
|
|||||||
</scene>
|
</scene>
|
||||||
</scenes>
|
</scenes>
|
||||||
<resources>
|
<resources>
|
||||||
<image name="Settings" width="17" height="17"/>
|
<image name="Settings" width="25" height="25"/>
|
||||||
</resources>
|
</resources>
|
||||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||||
<simulatedStatusBarMetrics key="statusBar" statusBarStyle="lightContent"/>
|
<simulatedStatusBarMetrics key="statusBar" statusBarStyle="lightContent"/>
|
||||||
|
@ -132,7 +132,7 @@
|
|||||||
<scene sceneID="5Eb-q2-vjt">
|
<scene sceneID="5Eb-q2-vjt">
|
||||||
<objects>
|
<objects>
|
||||||
<viewController id="mI3-9F-XwU" customClass="StreamFrameViewController" sceneMemberID="viewController">
|
<viewController id="mI3-9F-XwU" customClass="StreamFrameViewController" sceneMemberID="viewController">
|
||||||
<view key="view" contentMode="scaleToFill" id="eir-e9-IPE" customClass="StreamView">
|
<view key="view" multipleTouchEnabled="YES" contentMode="scaleToFill" id="eir-e9-IPE" customClass="StreamView">
|
||||||
<rect key="frame" x="0.0" y="0.0" width="568" height="320"/>
|
<rect key="frame" x="0.0" y="0.0" width="568" height="320"/>
|
||||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||||
<subviews>
|
<subviews>
|
||||||
@ -166,7 +166,7 @@
|
|||||||
</scene>
|
</scene>
|
||||||
</scenes>
|
</scenes>
|
||||||
<resources>
|
<resources>
|
||||||
<image name="Settings" width="17" height="17"/>
|
<image name="Settings" width="25" height="25"/>
|
||||||
</resources>
|
</resources>
|
||||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||||
<simulatedStatusBarMetrics key="statusBar"/>
|
<simulatedStatusBarMetrics key="statusBar"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user