Added scrolling and right click

This commit is contained in:
Diego Waxemberg 2014-11-26 23:51:43 -05:00
parent c3b44a32d5
commit 5f800b7901
3 changed files with 50 additions and 22 deletions

View File

@ -19,10 +19,12 @@
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 {
if ([[event allTouches] count] == 1) {
UITouch *touch = [[event allTouches] anyObject]; UITouch *touch = [[event allTouches] anyObject];
CGPoint currentLocation = [touch locationInView:self]; CGPoint currentLocation = [touch locationInView:self];
@ -35,13 +37,38 @@
touchMoved = true; touchMoved = true;
touchLocation = currentLocation; 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;
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_RIGHT);
// Wait 100 ms to simulate a real button press
usleep(100 * 1000);
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT);
} else {
NSLog(@"Sending left mouse button press");
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT); LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
@ -50,6 +77,7 @@
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT); LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
} }
}
} }
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {

View File

@ -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"/>

View File

@ -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"/>