ios stuff
This commit is contained in:
1 parent
c0d8650da2
commit
ec2e6830aa
9 files changed
+172
-62
No files matched your search
@@ -11,6 +11,17 @@
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
struct TTouchHashData
|
||||
{
|
||||
CGPoint first;
|
||||
bool second;
|
||||
int number;
|
||||
};
|
||||
|
||||
std::map<UITouch*, TTouchHashData> touchHash;
|
||||
|
||||
namespace SE
|
||||
{
|
||||
void ShowKeyboard(std::string text);
|
||||
@@ -23,53 +34,116 @@ void ShowKeyboard(std::string text);
|
||||
self = [super initWithFrame:frame];
|
||||
if (self)
|
||||
{
|
||||
touchMoved = false;
|
||||
self.multipleTouchEnabled = YES;
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) AddTouchToHash:(UITouch*)touch
|
||||
{
|
||||
touchHash[touch].first = [touch locationInView:self];
|
||||
touchHash[touch].second = false;
|
||||
|
||||
for (int n = 0; n < 255; n++)
|
||||
{
|
||||
bool nExists = false;
|
||||
|
||||
for (auto i = touchHash.begin(); i != touchHash.end(); ++i)
|
||||
{
|
||||
if (i->second.number == n)
|
||||
{
|
||||
nExists = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (nExists == false)
|
||||
{
|
||||
touchHash[touch].number = n;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void) RemoveTouchFromHash:(UITouch*)touch
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
|
||||
CGPoint location = [[[touches allObjects] objectAtIndex:0] locationInView:self];
|
||||
//NSLog(@"touchesBegan");
|
||||
|
||||
touchBeganLocation = location;
|
||||
|
||||
touchMoved = false;
|
||||
|
||||
SE::AppOnTapDown(location.x, self.bounds.size.height - location.y);
|
||||
for (NSUInteger i = 0; i < [[touches allObjects] count]; i++)
|
||||
{
|
||||
UITouch *aTouch = [[touches allObjects] objectAtIndex:i];
|
||||
|
||||
CGPoint location = [aTouch locationInView:self];
|
||||
|
||||
[self AddTouchToHash:aTouch];
|
||||
|
||||
SE::AppOnTapDown(location.x, self.bounds.size.height - location.y, touchHash[aTouch].number);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
CGPoint location = [[[touches allObjects] objectAtIndex:0] locationInView:self];
|
||||
|
||||
CGPoint prevLocation = [[[touches allObjects] objectAtIndex:0] previousLocationInView:self];
|
||||
|
||||
if (abs(touchBeganLocation.x - location.x) > 10 || abs(touchBeganLocation.y - location.y) > 10)
|
||||
for (NSUInteger i = 0; i < [[touches allObjects] count]; i++)
|
||||
{
|
||||
touchMoved = true;
|
||||
}
|
||||
UITouch *aTouch = [[touches allObjects] objectAtIndex:i];
|
||||
|
||||
|
||||
|
||||
CGPoint location = [aTouch locationInView:self];
|
||||
|
||||
SE::AppOnScroll(prevLocation.x - location.x, -(prevLocation.y - location.y));
|
||||
CGPoint prevLocation = [aTouch previousLocationInView:self];
|
||||
|
||||
if (abs(touchHash[aTouch].first.x - location.x) > 10 || abs(touchHash[aTouch].first.y - location.y) > 10)
|
||||
{
|
||||
touchHash[aTouch].second = true;
|
||||
}
|
||||
|
||||
SE::AppOnScroll(prevLocation.x - location.x, -(prevLocation.y - location.y), touchHash[aTouch].number);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
CGPoint location = [[[touches allObjects] objectAtIndex:0] locationInView:self];
|
||||
//NSLog(@"touchesEnded");
|
||||
|
||||
if (touchMoved)
|
||||
for (NSUInteger i = 0; i < [[touches allObjects] count]; i++)
|
||||
{
|
||||
SE::AppOnTapUpAfterMove(location.x, self.bounds.size.height - location.y);
|
||||
UITouch *aTouch = [[touches allObjects] objectAtIndex:i];
|
||||
|
||||
CGPoint location = [aTouch locationInView:self];
|
||||
|
||||
if (touchHash[aTouch].second)
|
||||
{
|
||||
SE::AppOnTapUpAfterMove(location.x, self.bounds.size.height - location.y, touchHash[aTouch].number);
|
||||
}
|
||||
else
|
||||
{
|
||||
SE::AppOnTapUp(location.x, self.bounds.size.height - location.y);
|
||||
SE::AppOnTapUp(location.x, self.bounds.size.height - location.y, touchHash[aTouch].number);
|
||||
}
|
||||
touchHash.erase(aTouch);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
//NSLog(@"touchesCancelled");
|
||||
|
||||
|
||||
for (NSUInteger i = 0; i < [[touches allObjects] count]; i++)
|
||||
{
|
||||
UITouch *aTouch = [[touches allObjects] objectAtIndex:i];
|
||||
|
||||
touchHash.erase(aTouch);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -65,8 +65,13 @@ void SetKeyboardText(const char* newText);
|
||||
UIPinchGestureRecognizer *recognizer = [[UIPinchGestureRecognizer alloc]
|
||||
initWithTarget:self action:@selector(respondToPinch:)];
|
||||
|
||||
|
||||
recognizer.delaysTouchesEnded = NO;
|
||||
|
||||
[self.view addGestureRecognizer:recognizer];
|
||||
|
||||
self.view.multipleTouchEnabled = YES;
|
||||
|
||||
//Keyboard
|
||||
|
||||
_hiddenTextField = [[UITextField alloc] initWithFrame:CGRectMake(-200,-200,0,0)];
|
||||
|
||||
Reference in new issue
Block a user