[DEV] update MacOs onput mouse to be compatible wit Linux
This commit is contained in:
parent
c6928fa591
commit
971acf0036
2
external/etk
vendored
2
external/etk
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 216f3a55280227155a8acded577dec14be5734a0
|
Subproject commit 9e93578be9d48f8cbf21de9fe56ceaf17eeb8b21
|
@ -11,62 +11,53 @@
|
|||||||
#import <ewol/renderer/MacOs/OpenglView.h>
|
#import <ewol/renderer/MacOs/OpenglView.h>
|
||||||
|
|
||||||
@implementation MacOsAppDelegate
|
@implementation MacOsAppDelegate
|
||||||
|
|
||||||
|
|
||||||
@synthesize window=_window;
|
@synthesize window=_window;
|
||||||
|
|
||||||
- (BOOL)application:(MacOsAppDelegate *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
- (BOOL)application:(MacOsAppDelegate *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||||
{
|
OpenGLView *view=[[OpenGLView alloc]initWithFrame:[[NSScreen mainScreen] bounds]];
|
||||||
OpenGLView *view=[[OpenGLView alloc]initWithFrame:[[NSScreen mainScreen] bounds]];
|
// Override point for customization after application launch.
|
||||||
// Override point for customization after application launch.
|
[self.window addSubview:view];
|
||||||
[self.window addSubview:view];
|
[self.window makeKeyAndVisible];
|
||||||
[self.window makeKeyAndVisible];
|
return YES;
|
||||||
return YES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillResignActive:(MacOsAppDelegate *)application
|
- (void)applicationWillResignActive:(MacOsAppDelegate *)application {
|
||||||
{
|
/*
|
||||||
/*
|
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.
|
||||||
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.
|
||||||
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.
|
*/
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationDidEnterBackground:(MacOsAppDelegate *)application
|
- (void)applicationDidEnterBackground:(MacOsAppDelegate *)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.
|
||||||
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.
|
||||||
If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
|
*/
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillEnterForeground:(MacOsAppDelegate *)application
|
- (void)applicationWillEnterForeground:(MacOsAppDelegate *)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.
|
||||||
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.
|
*/
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationDidBecomeActive:(MacOsAppDelegate *)application
|
- (void)applicationDidBecomeActive:(MacOsAppDelegate *)application {
|
||||||
{
|
/*
|
||||||
/*
|
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.
|
||||||
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.
|
*/
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)applicationWillTerminate:(MacOsAppDelegate *)application
|
- (void)applicationWillTerminate:(MacOsAppDelegate *)application {
|
||||||
{
|
/*
|
||||||
/*
|
Called when the application is about to terminate.
|
||||||
Called when the application is about to terminate.
|
Save data if appropriate.
|
||||||
Save data if appropriate.
|
See also applicationDidEnterBackground:.
|
||||||
See also applicationDidEnterBackground:.
|
*/
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc {
|
||||||
{
|
[_window release];
|
||||||
[_window release];
|
[super dealloc];
|
||||||
[super dealloc];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -11,9 +11,7 @@
|
|||||||
|
|
||||||
#include <ewol/key.h>
|
#include <ewol/key.h>
|
||||||
|
|
||||||
namespace MacOs
|
namespace MacOs {
|
||||||
{
|
|
||||||
|
|
||||||
// return true if a flush is needed
|
// return true if a flush is needed
|
||||||
bool draw(bool _displayEveryTime);
|
bool draw(bool _displayEveryTime);
|
||||||
/**
|
/**
|
||||||
@ -21,11 +19,9 @@ namespace MacOs
|
|||||||
* @param[in] _size new size of the windows.
|
* @param[in] _size new size of the windows.
|
||||||
*/
|
*/
|
||||||
void resize(float _x, float _y);
|
void resize(float _x, float _y);
|
||||||
|
|
||||||
void setMouseState(int32_t _id, bool _isDown, 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 setMouseMotion(int32_t _id, float _x, float _y);
|
||||||
void setKeyboard(ewol::SpecialKey _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey);
|
void setKeyboard(ewol::SpecialKey _keyboardMode, int32_t _unichar, bool _isDown, bool _isAReapeateKey);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -12,79 +12,75 @@
|
|||||||
#import <ewol/renderer/MacOs/OpenglView.h>
|
#import <ewol/renderer/MacOs/OpenglView.h>
|
||||||
#import <ewol/renderer/MacOs/AppDelegate.h>
|
#import <ewol/renderer/MacOs/AppDelegate.h>
|
||||||
|
|
||||||
int mm_main(int argc, const char *argv[])
|
int mm_main(int argc, const char *argv[]) {
|
||||||
{
|
[NSAutoreleasePool new];
|
||||||
|
|
||||||
[NSAutoreleasePool new];
|
|
||||||
|
|
||||||
[NSApplication sharedApplication];
|
|
||||||
// set the quit policy and all stadard for Mac
|
|
||||||
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
// -- basic menu bar creation :
|
|
||||||
// ---------------------------------------------------------------
|
|
||||||
// set the basic menu bar (stadard on Mac OSX)
|
|
||||||
id menubar = [[NSMenu new] autorelease];
|
|
||||||
//add an item
|
|
||||||
id appMenuItem = [[NSMenuItem new] autorelease];
|
|
||||||
// add the item to the menu bar:
|
|
||||||
[menubar addItem:appMenuItem];
|
|
||||||
// set the main menu in the menu bar ...
|
|
||||||
[NSApp setMainMenu:menubar];
|
|
||||||
|
|
||||||
id appMenu = [[NSMenu new] autorelease];
|
[NSApplication sharedApplication];
|
||||||
id appName = [[NSProcessInfo processInfo] processName];
|
// set the quit policy and all stadard for Mac
|
||||||
// create the label to qui the application :
|
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
|
||||||
id quitTitle = [@"Quit " stringByAppendingString:appName];
|
|
||||||
// create the item to quit the appllication with META+q at shortCut
|
// ---------------------------------------------------------------
|
||||||
id quitMenuItem = [ [ [NSMenuItem alloc] initWithTitle:quitTitle
|
// -- basic menu bar creation :
|
||||||
action:@selector(terminate:) keyEquivalent:@"q"] autorelease];
|
// ---------------------------------------------------------------
|
||||||
// add the item to the menu:
|
// set the basic menu bar (stadard on Mac OSX)
|
||||||
[appMenu addItem:quitMenuItem];
|
id menubar = [[NSMenu new] autorelease];
|
||||||
// set the application menu to the main app menu ...
|
//add an item
|
||||||
[appMenuItem setSubmenu:appMenu];
|
id appMenuItem = [[NSMenuItem new] autorelease];
|
||||||
|
// add the item to the menu bar:
|
||||||
// ---------------------------------------------------------------
|
[menubar addItem:appMenuItem];
|
||||||
// -- basic windows creation :
|
// set the main menu in the menu bar ...
|
||||||
// ---------------------------------------------------------------
|
[NSApp setMainMenu:menubar];
|
||||||
// create a windows of size 800/600
|
|
||||||
id window = [ [ [NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
|
id appMenu = [[NSMenu new] autorelease];
|
||||||
styleMask:(NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask) backing:NSBackingStoreBuffered defer:NO]
|
id appName = [[NSProcessInfo processInfo] processName];
|
||||||
autorelease];
|
// create the label to qui the application :
|
||||||
|
id quitTitle = [@"Quit " stringByAppendingString:appName];
|
||||||
|
// create the item to quit the appllication with META+q at shortCut
|
||||||
|
id quitMenuItem = [ [ [NSMenuItem alloc] initWithTitle:quitTitle
|
||||||
|
action:@selector(terminate:) keyEquivalent:@"q"] autorelease];
|
||||||
|
// add the item to the menu:
|
||||||
|
[appMenu addItem:quitMenuItem];
|
||||||
|
// set the application menu to the main app menu ...
|
||||||
|
[appMenuItem setSubmenu:appMenu];
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------
|
||||||
|
// -- basic windows creation :
|
||||||
|
// ---------------------------------------------------------------
|
||||||
|
// create a windows of size 800/600
|
||||||
|
id window = [ [ [NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
|
||||||
|
styleMask:(NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask) backing:NSBackingStoreBuffered defer:NO]
|
||||||
|
autorelease];
|
||||||
// set the windows at a specific position :
|
// set the windows at a specific position :
|
||||||
[window cascadeTopLeftFromPoint:NSMakePoint(50,50)];
|
[window cascadeTopLeftFromPoint:NSMakePoint(50,50)];
|
||||||
// set the windows resizable
|
// set the windows resizable
|
||||||
[window setStyleMask:[window styleMask] | NSResizableWindowMask];
|
[window setStyleMask:[window styleMask] | NSResizableWindowMask];
|
||||||
// oposite : [window setStyleMask:[window styleMask] & ~NSResizableWindowMask];
|
// oposite : [window setStyleMask:[window styleMask] & ~NSResizableWindowMask];
|
||||||
// set the title
|
// set the title
|
||||||
[window setTitle:appName];
|
[window setTitle:appName];
|
||||||
|
|
||||||
[window setAcceptsMouseMovedEvents:YES];
|
[window setAcceptsMouseMovedEvents:YES];
|
||||||
// ???
|
// ???
|
||||||
[window makeKeyAndOrderFront:nil];
|
[window makeKeyAndOrderFront:nil];
|
||||||
[NSApp activateIgnoringOtherApps:YES];
|
[NSApp activateIgnoringOtherApps:YES];
|
||||||
|
|
||||||
NSRect window_frame = [window frame];
|
NSRect window_frame = [window frame];
|
||||||
|
|
||||||
OpenGLView* view=[[OpenGLView alloc]initWithFrame:window_frame]; //NSMakeRect(0, 0, 800, 600)];
|
OpenGLView* view=[[OpenGLView alloc]initWithFrame:window_frame]; //NSMakeRect(0, 0, 800, 600)];
|
||||||
[window setContentView:view];
|
[window setContentView:view];
|
||||||
[view setAutoresizesSubviews:YES];
|
[view setAutoresizesSubviews:YES];
|
||||||
|
|
||||||
// Override point for customization after application launch.
|
// Override point for customization after application launch.
|
||||||
//[window addSubview:view];
|
//[window addSubview:view];
|
||||||
//[window addChildWindow:view];
|
//[window addChildWindow:view];
|
||||||
//[window makeKeyAndVisible];
|
//[window makeKeyAndVisible];
|
||||||
|
|
||||||
[window setDelegate:view];
|
[window setDelegate:view];
|
||||||
// return no error
|
// return no error
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mm_run(void)
|
int mm_run(void) {
|
||||||
{
|
[NSApp run];
|
||||||
[NSApp run];
|
// return no error
|
||||||
// return no error
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
@ -10,8 +10,7 @@
|
|||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
@interface OpenGLView : NSOpenGLView<NSWindowDelegate>
|
@interface OpenGLView : NSOpenGLView<NSWindowDelegate> {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
- (void)prepareOpenGL;
|
- (void)prepareOpenGL;
|
||||||
- (void)drawRect:(NSRect) bounds;
|
- (void)drawRect:(NSRect) bounds;
|
||||||
|
@ -13,18 +13,16 @@
|
|||||||
#include <ewol/debug.h>
|
#include <ewol/debug.h>
|
||||||
#include <ewol/Dimension.h>
|
#include <ewol/Dimension.h>
|
||||||
|
|
||||||
|
|
||||||
@implementation OpenGLView
|
@implementation OpenGLView
|
||||||
|
|
||||||
|
|
||||||
static ewol::SpecialKey guiKeyBoardMode;
|
static ewol::SpecialKey guiKeyBoardMode;
|
||||||
|
|
||||||
- (void) prepareOpenGL
|
- (void) prepareOpenGL
|
||||||
{
|
{
|
||||||
EWOL_ERROR("prepare");
|
EWOL_ERROR("prepare");
|
||||||
GLint swapInt = 1;
|
GLint swapInt = 1;
|
||||||
[[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; // set to vbl sync
|
[[self openGLContext] setValues:&swapInt forParameter:NSOpenGLCPSwapInterval]; // set to vbl sync
|
||||||
|
|
||||||
// set system dpi size :
|
// set system dpi size :
|
||||||
NSScreen *screen = [NSScreen mainScreen];
|
NSScreen *screen = [NSScreen mainScreen];
|
||||||
NSDictionary *description = [screen deviceDescription];
|
NSDictionary *description = [screen deviceDescription];
|
||||||
@ -33,27 +31,25 @@ static ewol::SpecialKey guiKeyBoardMode;
|
|||||||
|
|
||||||
ewol::dimension::setPixelRatio(vec2((float)displayPixelSize.width/(float)displayPhysicalSize.width,
|
ewol::dimension::setPixelRatio(vec2((float)displayPixelSize.width/(float)displayPhysicalSize.width,
|
||||||
(float)displayPixelSize.height/(float)displayPhysicalSize.height),
|
(float)displayPixelSize.height/(float)displayPhysicalSize.height),
|
||||||
ewol::Dimension::Millimeter);
|
ewol::Dimension::Millimeter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) drawRect: (NSRect) bounds
|
-(void) drawRect: (NSRect) bounds
|
||||||
{
|
{
|
||||||
MacOs::draw(true);
|
MacOs::draw(true);
|
||||||
glFlush();
|
glFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void)reshape {
|
-(void)reshape {
|
||||||
EWOL_INFO("view reshape (" << [self frame].size.width << "," << [self frame].size.height << ")" );
|
EWOL_INFO("view reshape (" << [self frame].size.width << "," << [self frame].size.height << ")" );
|
||||||
|
|
||||||
// window resize; width and height are in pixel coordinates
|
// window resize; width and height are in pixel coordinates
|
||||||
// but they are floats
|
// but they are floats
|
||||||
float width = [self frame].size.width;
|
float width = [self frame].size.width;
|
||||||
float height = [self frame].size.height;
|
float height = [self frame].size.height;
|
||||||
MacOs::resize(width,height);
|
MacOs::resize(width,height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
-(void)mouseDown:(NSEvent *)event {
|
-(void)mouseDown:(NSEvent *)event {
|
||||||
NSPoint point = [event locationInWindow];
|
NSPoint point = [event locationInWindow];
|
||||||
//float x = [event locationInWindow].x; //point.x;
|
//float x = [event locationInWindow].x; //point.x;
|
||||||
@ -100,22 +96,90 @@ static ewol::SpecialKey guiKeyBoardMode;
|
|||||||
}
|
}
|
||||||
-(void)otherMouseDown:(NSEvent *)event {
|
-(void)otherMouseDown:(NSEvent *)event {
|
||||||
NSPoint point = [event locationInWindow];
|
NSPoint point = [event locationInWindow];
|
||||||
EWOL_INFO("otherMouseDown : " << (float)point.x << " " << (float)point.y);
|
int32_t btNumber = [event buttonNumber];
|
||||||
|
switch (btNumber) {
|
||||||
|
case 2: // 2 : Middle button
|
||||||
|
btNumber = 2;
|
||||||
|
break;
|
||||||
|
case 3: // 3 : border button DOWN
|
||||||
|
btNumber = 8;
|
||||||
|
break;
|
||||||
|
case 4: // 4 : border button UP
|
||||||
|
btNumber = 9;
|
||||||
|
break;
|
||||||
|
case 5: // 5 : horizontal scroll Right to left
|
||||||
|
btNumber = 11;
|
||||||
|
break;
|
||||||
|
case 6: // 6 : horizontal scroll left to Right
|
||||||
|
btNumber = 10;
|
||||||
|
break;
|
||||||
|
case 7: // 7 : Red button
|
||||||
|
btNumber = 12;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
btNumber = 15;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//EWOL_INFO("otherMouseDown : " << (float)point.x << " " << (float)point.y);
|
||||||
|
MacOs::setMouseState(btNumber, true, point.x, point.y);
|
||||||
}
|
}
|
||||||
-(void)otherMouseDragged:(NSEvent *)event {
|
-(void)otherMouseDragged:(NSEvent *)event {
|
||||||
NSPoint point = [event locationInWindow];
|
NSPoint point = [event locationInWindow];
|
||||||
EWOL_INFO("otherMouseDragged : " << (float)point.x << " " << (float)point.y);
|
int32_t btNumber = [event buttonNumber];
|
||||||
|
switch (btNumber) {
|
||||||
|
case 2: // 2 : Middle button
|
||||||
|
btNumber = 2;
|
||||||
|
break;
|
||||||
|
case 3: // 3 : border button DOWN
|
||||||
|
btNumber = 8;
|
||||||
|
break;
|
||||||
|
case 4: // 4 : border button UP
|
||||||
|
btNumber = 9;
|
||||||
|
break;
|
||||||
|
case 5: // 5 : horizontal scroll Right to left
|
||||||
|
btNumber = 11;
|
||||||
|
break;
|
||||||
|
case 6: // 6 : horizontal scroll left to Right
|
||||||
|
btNumber = 10;
|
||||||
|
break;
|
||||||
|
case 7: // 7 : Red button
|
||||||
|
btNumber = 12;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
btNumber = 15;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//EWOL_INFO("otherMouseDragged : " << (float)point.x << " " << (float)point.y);
|
||||||
|
MacOs::setMouseMotion(btNumber, point.x, point.y);
|
||||||
}
|
}
|
||||||
-(void)otherMouseUp:(NSEvent *)event {
|
-(void)otherMouseUp:(NSEvent *)event {
|
||||||
NSPoint point = [event locationInWindow];
|
NSPoint point = [event locationInWindow];
|
||||||
int32_t btNumber = [event buttonNumber];
|
int32_t btNumber = [event buttonNumber];
|
||||||
EWOL_INFO("otherMouseUp : " << (float)point.x << " " << (float)point.y << " bt id=" << btNumber );
|
switch (btNumber) {
|
||||||
// 2 : Middle button
|
case 2: // 2 : Middle button
|
||||||
// 3 : border button DOWN
|
btNumber = 2;
|
||||||
// 4 : border button UP
|
break;
|
||||||
// 7 : Red button
|
case 3: // 3 : border button DOWN
|
||||||
// 5 : horizontal scroll Right to left
|
btNumber = 8;
|
||||||
// 6 : horizontal scroll left to Right
|
break;
|
||||||
|
case 4: // 4 : border button UP
|
||||||
|
btNumber = 9;
|
||||||
|
break;
|
||||||
|
case 5: // 5 : horizontal scroll Right to left
|
||||||
|
btNumber = 11;
|
||||||
|
break;
|
||||||
|
case 6: // 6 : horizontal scroll left to Right
|
||||||
|
btNumber = 10;
|
||||||
|
break;
|
||||||
|
case 7: // 7 : Red button
|
||||||
|
btNumber = 12;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
btNumber = 15;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//EWOL_INFO("otherMouseUp : " << (float)point.x << " " << (float)point.y << " bt id=" << btNumber );
|
||||||
|
MacOs::setMouseState(btNumber, false, point.x, point.y);
|
||||||
}
|
}
|
||||||
- (void)scrollWheel:(NSEvent *)event {
|
- (void)scrollWheel:(NSEvent *)event {
|
||||||
NSPoint point = [event locationInWindow];
|
NSPoint point = [event locationInWindow];
|
||||||
@ -144,46 +208,34 @@ static ewol::SpecialKey guiKeyBoardMode;
|
|||||||
|
|
||||||
// this generate all the event entry availlable ==> like a big keep focus ...
|
// this generate all the event entry availlable ==> like a big keep focus ...
|
||||||
- (BOOL)acceptsFirstResponder {
|
- (BOOL)acceptsFirstResponder {
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)keyDown:(NSEvent *)theEvent {
|
- (void)keyDown:(NSEvent *)theEvent {
|
||||||
bool thisIsAReapeateKey = false;
|
bool thisIsAReapeateKey = false;
|
||||||
if ([theEvent isARepeat]) {
|
if ([theEvent isARepeat]) {
|
||||||
thisIsAReapeateKey = true;
|
thisIsAReapeateKey = true;
|
||||||
}
|
}
|
||||||
NSString *str = [theEvent charactersIgnoringModifiers];
|
NSString *str = [theEvent charactersIgnoringModifiers];
|
||||||
// TODO : set if for every char in the string !!!
|
// TODO : set if for every char in the string !!!
|
||||||
unichar c = [str characterAtIndex:0];
|
unichar c = [str characterAtIndex:0];
|
||||||
/*
|
//EWOL_DEBUG("KeyDown " << (char)c);
|
||||||
if (c < ' ' || c > '~') { // only ASCII please
|
MacOs::setKeyboard(guiKeyBoardMode, (char)c, true, thisIsAReapeateKey);
|
||||||
c = 0;
|
if (true==thisIsAReapeateKey) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
//EWOL_DEBUG("KeyDown " << (char)c);
|
|
||||||
MacOs::setKeyboard(guiKeyBoardMode, (char)c, true, thisIsAReapeateKey);
|
|
||||||
if (true==thisIsAReapeateKey) {
|
|
||||||
MacOs::setKeyboard(guiKeyBoardMode, (char)c, false, thisIsAReapeateKey);
|
MacOs::setKeyboard(guiKeyBoardMode, (char)c, false, thisIsAReapeateKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)keyUp:(NSEvent *)theEvent {
|
- (void)keyUp:(NSEvent *)theEvent {
|
||||||
bool thisIsAReapeateKey = false;
|
bool thisIsAReapeateKey = false;
|
||||||
if ([theEvent isARepeat]) {
|
if ([theEvent isARepeat]) {
|
||||||
thisIsAReapeateKey = true;
|
thisIsAReapeateKey = true;
|
||||||
}
|
}
|
||||||
//EWOL_DEBUG("KeyUp ");
|
//EWOL_DEBUG("KeyUp ");
|
||||||
NSString *str = [theEvent charactersIgnoringModifiers];
|
NSString *str = [theEvent charactersIgnoringModifiers];
|
||||||
unichar c = [str characterAtIndex:0];
|
unichar c = [str characterAtIndex:0];
|
||||||
/*
|
MacOs::setKeyboard(guiKeyBoardMode, (char)c, false, thisIsAReapeateKey);
|
||||||
if (c < ' ' || c > '~') { // only ASCII please
|
if (true==thisIsAReapeateKey) {
|
||||||
c = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
MacOs::setKeyboard(guiKeyBoardMode, (char)c, false, thisIsAReapeateKey);
|
|
||||||
if (true==thisIsAReapeateKey) {
|
|
||||||
MacOs::setKeyboard(guiKeyBoardMode, (char)c, true, thisIsAReapeateKey);
|
MacOs::setKeyboard(guiKeyBoardMode, (char)c, true, thisIsAReapeateKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,30 +245,30 @@ static ewol::SpecialKey guiKeyBoardMode;
|
|||||||
static NSTimer *timer = nil;
|
static NSTimer *timer = nil;
|
||||||
|
|
||||||
- (void)windowDidResignMain:(NSNotification *)notification {
|
- (void)windowDidResignMain:(NSNotification *)notification {
|
||||||
// NSLog(@"window did resign main");
|
// NSLog(@"window did resign main");
|
||||||
[timer invalidate];
|
[timer invalidate];
|
||||||
|
|
||||||
//game_deactivate(); // freeze, pause
|
//game_deactivate(); // freeze, pause
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowDidBecomeMain:(NSNotification *)notification {
|
- (void)windowDidBecomeMain:(NSNotification *)notification {
|
||||||
// NSLog(@"window did become main");
|
// NSLog(@"window did become main");
|
||||||
|
|
||||||
//game_activate();
|
//game_activate();
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay:YES];
|
||||||
|
|
||||||
timer = [NSTimer timerWithTimeInterval:FRAME_INTERVAL
|
timer = [NSTimer timerWithTimeInterval:FRAME_INTERVAL
|
||||||
target:self
|
target:self
|
||||||
selector:@selector(timerEvent:)
|
selector:@selector(timerEvent:)
|
||||||
userInfo:nil
|
userInfo:nil
|
||||||
repeats:YES];
|
repeats:YES];
|
||||||
|
|
||||||
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
|
[[NSRunLoop mainRunLoop] addTimer:timer forMode:NSDefaultRunLoopMode];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)timerEvent:(NSTimer *)t {
|
- (void)timerEvent:(NSTimer *)t {
|
||||||
//run_game();
|
//run_game();
|
||||||
[self setNeedsDisplay:YES];
|
[self setNeedsDisplay:YES];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user