[DEV] add touch event on the IOs port
This commit is contained in:
parent
bec800d4f9
commit
66b53f30f4
@ -12,6 +12,7 @@
|
||||
#import <ewol/context/IOs/OpenglView.h>
|
||||
#import <ewol/context/IOs/AppDelegate.h>
|
||||
#include <ewol/context/IOs/Context.h>
|
||||
#include <ewol/debug.h>
|
||||
|
||||
@implementation AppDelegate
|
||||
|
||||
@ -20,9 +21,9 @@
|
||||
|
||||
- (void)applicationDidFinishLaunching:(UIApplication *)application {
|
||||
|
||||
//No need for nib
|
||||
window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
||||
glView = [[OpenglView alloc] initWithFrame:window.bounds];
|
||||
CGRect screenBounds = [[UIScreen mainScreen] bounds];
|
||||
window = [[UIWindow alloc] initWithFrame:screenBounds];
|
||||
glView = [[[OpenglView alloc] initWithFrame:window.bounds] autorelease];;
|
||||
[window addSubview:glView];
|
||||
[window makeKeyAndVisible];
|
||||
// Create interface of ewol here ....
|
||||
@ -39,37 +40,38 @@
|
||||
}
|
||||
*/
|
||||
|
||||
- (void)applicationWillResignActive:(UIApplication *)application
|
||||
{
|
||||
- (void)applicationWillResignActive:(UIApplication *)application {
|
||||
glView.animationInterval = 1.0 / 5.0;
|
||||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
|
||||
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
|
||||
EWOL_INFO("move windows in applicationWillResignActive");
|
||||
}
|
||||
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application
|
||||
{
|
||||
- (void)applicationDidEnterBackground:(UIApplication *)application {
|
||||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
|
||||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
||||
EWOL_INFO("move windows in applicationDidEnterBackground");
|
||||
}
|
||||
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application
|
||||
{
|
||||
- (void)applicationWillEnterForeground:(UIApplication *)application {
|
||||
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
|
||||
EWOL_INFO("move windows in applicationWillEnterForeground");
|
||||
}
|
||||
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application
|
||||
{
|
||||
- (void)applicationDidBecomeActive:(UIApplication *)application {
|
||||
glView.animationInterval = 1.0 / 60.0;
|
||||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
|
||||
EWOL_INFO("move windows in applicationDidBecomeActive");
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminate:(UIApplication *)application
|
||||
{
|
||||
- (void)applicationWillTerminate:(UIApplication *)application {
|
||||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
|
||||
// Create interface of ewol here ....
|
||||
NSLog(@"REMOVE EWOL interface destruction\n");
|
||||
EWOL_INFO("move windows in applicationWillTerminate");
|
||||
IOs::releaseInterface();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
- (void)dealloc {
|
||||
[window release];
|
||||
|
@ -77,6 +77,12 @@ public:
|
||||
void MAC_SetMouseMotion(int32_t _id, float _x, float _y) {
|
||||
OS_SetMouseMotion(_id, vec2(_x, _y));
|
||||
}
|
||||
void MAC_SetInputState(int32_t _id, bool _isDown, float _x, float _y) {
|
||||
OS_SetInputState(_id, _isDown, vec2(_x, _y));
|
||||
}
|
||||
void MAC_SetInputMotion(int32_t _id, float _x, float _y) {
|
||||
OS_SetInputMotion(_id, vec2(_x, _y));
|
||||
}
|
||||
void MAC_SetKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) {
|
||||
if (_unichar == u32char::Delete) {
|
||||
_unichar = u32char::Suppress;
|
||||
@ -149,6 +155,20 @@ void IOs::setMouseMotion(int32_t _id, float _x, float _y) {
|
||||
interface->MAC_SetMouseMotion(_id, _x, _y);
|
||||
}
|
||||
|
||||
void IOs::setInputState(int32_t _id, bool _isDown, float _x, float _y) {
|
||||
if (interface == NULL) {
|
||||
return;
|
||||
}
|
||||
interface->MAC_SetInputState(_id, _isDown, _x, _y);
|
||||
}
|
||||
|
||||
void IOs::setInputMotion(int32_t _id, float _x, float _y) {
|
||||
if (interface == NULL) {
|
||||
return;
|
||||
}
|
||||
interface->MAC_SetInputMotion(_id, _x, _y);
|
||||
}
|
||||
|
||||
void IOs::setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey) {
|
||||
if (interface == NULL) {
|
||||
return;
|
||||
|
@ -24,6 +24,8 @@ namespace IOs {
|
||||
void resize(float _x, float _y);
|
||||
void setMouseState(int32_t _id, bool _isDown, float _x, float _y);
|
||||
void setMouseMotion(int32_t _id, float _x, float _y);
|
||||
void setInputState(int32_t _id, bool _isDown, float _x, float _y);
|
||||
void setInputMotion(int32_t _id, float _x, float _y);
|
||||
void setKeyboard(ewol::key::Special _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey);
|
||||
void setKeyboardMove(ewol::key::Special& _keyboardMode, enum ewol::key::keyboard _move, bool _isDown);
|
||||
};
|
||||
|
@ -38,6 +38,7 @@
|
||||
NSTimeInterval animationInterval;
|
||||
|
||||
CGPoint touchLocation;
|
||||
CGSize m_currentSize;
|
||||
}
|
||||
|
||||
@property (nonatomic) NSTimeInterval animationInterval;
|
||||
|
@ -15,6 +15,12 @@
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#import "OpenglView.h"
|
||||
#include <ewol/debug.h>
|
||||
|
||||
// tuto de deploiment d'appo$ilcation :
|
||||
// http://mobiforge.com/design-development/deploying-iphone-apps-real-devices
|
||||
// http://www.techotopia.com/index.php/Testing_Apps_on_the_iPhone_–_Developer_Certificates_and_Provisioning_Profiles
|
||||
|
||||
|
||||
#define USE_DEPTH_BUFFER 1
|
||||
#define DEGREES_TO_RADIANS(__ANGLE) ((__ANGLE) / 180.0 * M_PI)
|
||||
@ -137,13 +143,13 @@
|
||||
- (void)configureAspectRatio {
|
||||
CGRect screenBounds = [[UIScreen mainScreen] bounds];
|
||||
CGFloat screenScale = [[UIScreen mainScreen] scale];
|
||||
CGSize screenSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale);
|
||||
m_currentSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale);
|
||||
|
||||
NSLog(@"**** screen size : %fx%f\n", screenSize.width, screenSize.height);
|
||||
NSLog(@"**** screen size : %fx%f\n", m_currentSize.width, m_currentSize.height);
|
||||
float ratio = [self getScreenPPP];
|
||||
NSLog(@"**** pixel ratio : %f ppp \n", ratio);
|
||||
ewol::Dimension::setPixelRatio(vec2(1.0f/ratio, 1.0f/ratio), ewol::Dimension::Inch);
|
||||
IOs::resize(screenSize.width, screenSize.height);
|
||||
IOs::resize(m_currentSize.width, m_currentSize.height);
|
||||
|
||||
}
|
||||
- (void)setupLayer {
|
||||
@ -193,7 +199,7 @@
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
IOs::draw(true);
|
||||
NSLog(@"draw...");
|
||||
//NSLog(@"draw...");
|
||||
[_context presentRenderbuffer:GL_RENDERBUFFER];
|
||||
}
|
||||
|
||||
@ -228,10 +234,26 @@
|
||||
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
|
||||
{
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
UITouch *touch = [touches anyObject];
|
||||
touchLocation = [touch locationInView:self];
|
||||
CGRect localBounds = [self bounds];
|
||||
EWOL_ERROR("touchesBegan: " << vec2(touchLocation.x, localBounds.size.height - touchLocation.y));
|
||||
IOs::setInputState(1, true, touchLocation.x, localBounds.size.height - touchLocation.y);
|
||||
}
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
UITouch *touch = [touches anyObject];
|
||||
touchLocation = [touch locationInView:self];
|
||||
CGRect localBounds = [self bounds];
|
||||
EWOL_ERROR("touchesEnded: " << vec2(touchLocation.x, localBounds.size.height - touchLocation.y));
|
||||
IOs::setInputState(1, false, touchLocation.x, localBounds.size.height - touchLocation.y);
|
||||
}
|
||||
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
UITouch *touch = [touches anyObject];
|
||||
touchLocation = [touch locationInView:self];
|
||||
CGRect localBounds = [self bounds];
|
||||
EWOL_ERROR("touchesMoved: " << vec2(touchLocation.x, localBounds.size.height - touchLocation.y));
|
||||
IOs::setInputMotion(1, touchLocation.x, localBounds.size.height - touchLocation.y);
|
||||
}
|
||||
|
||||
- (void)layoutSubviews {
|
||||
@ -288,4 +310,5 @@
|
||||
//[super dealloc];
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
@ -16,11 +16,12 @@
|
||||
@synthesize window=_window;
|
||||
|
||||
- (BOOL)application:(MacOsAppDelegate *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
OpenGLView *view=[[OpenGLView alloc]initWithFrame:[[NSScreen mainScreen] bounds]];
|
||||
|
||||
CGRect screenBounds = [[UIScreen mainScreen] bounds];
|
||||
OpenGLView *view = [[[OpenGLView alloc]initWithFrame:screenBounds] autorelease];
|
||||
// Override point for customization after application launch.
|
||||
[self.window addSubview:view];
|
||||
[self.window makeKeyAndVisible];
|
||||
EWOL_INFO("lkjlkjlkj");
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user