Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赤子奈落
ygopro
Commits
6982d27c
Commit
6982d27c
authored
Apr 06, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix patch
parent
342dfed1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
221 additions
and
221 deletions
+221
-221
premake/irrlicht/irrlicht-mac.patch
premake/irrlicht/irrlicht-mac.patch
+221
-221
No files found.
premake/irrlicht/irrlicht-mac.patch
100644 → 100755
View file @
6982d27c
...
@@ -3,256 +3,256 @@ index 395fb69..323c9a2 100644
...
@@ -3,256 +3,256 @@ index 395fb69..323c9a2 100644
--- a/source/Irrlicht/CGUIEditBox.cpp
--- a/source/Irrlicht/CGUIEditBox.cpp
+++ b/source/Irrlicht/CGUIEditBox.cpp
+++ b/source/Irrlicht/CGUIEditBox.cpp
@@ -287,9 +287,11 @@
bool CGUIEditBox::processKey(const SEvent& event)
@@ -287,9 +287,11 @@
bool CGUIEditBox::processKey(const SEvent& event)
const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd;
const s32 realmbgn = MarkBegin < MarkEnd ? MarkBegin : MarkEnd;
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
- core::stringc s;
- core::stringc s;
- s = Text.subString(realmbgn, realmend - realmbgn).c_str();
- s = Text.subString(realmbgn, realmend - realmbgn).c_str();
- Operator->copyToClipboard(s.c_str());
- Operator->copyToClipboard(s.c_str());
+ const int max_char_size = sizeof(wchar_t) * 3 / 2;
+ const int max_char_size = sizeof(wchar_t) * 3 / 2;
+ int max_size = (realmend - realmbgn)*max_char_size + 1;
+ int max_size = (realmend - realmbgn)*max_char_size + 1;
+ c8 *s = new char[max_size];
+ c8 *s = new char[max_size];
+ wcstombs(s, Text.subString(realmbgn, realmend-realmbgn).c_str(), max_size);
+ wcstombs(s, Text.subString(realmbgn, realmend-realmbgn).c_str(), max_size);
+ Operator->copyToClipboard(s);
+ Operator->copyToClipboard(s);
}
}
break;
break;
case KEY_KEY_X:
case KEY_KEY_X:
@@ -300,9 +302,11 @@
bool CGUIEditBox::processKey(const SEvent& event)
@@ -300,9 +302,11 @@
bool CGUIEditBox::processKey(const SEvent& event)
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
const s32 realmend = MarkBegin < MarkEnd ? MarkEnd : MarkBegin;
// copy
// copy
- core::stringc sc;
- core::stringc sc;
- sc = Text.subString(realmbgn, realmend - realmbgn).c_str();
- sc = Text.subString(realmbgn, realmend - realmbgn).c_str();
- Operator->copyToClipboard(sc.c_str());
- Operator->copyToClipboard(sc.c_str());
+ const int max_char_size = sizeof(wchar_t) * 3 / 2;
+ const int max_char_size = sizeof(wchar_t) * 3 / 2;
+ int max_size = (realmend - realmbgn)*max_char_size + 1;
+ int max_size = (realmend - realmbgn)*max_char_size + 1;
+ c8 *s = new char[max_size];
+ c8 *s = new char[max_size];
+ wcstombs(s, Text.subString(realmbgn, realmend-realmbgn).c_str(), max_size);
+ wcstombs(s, Text.subString(realmbgn, realmend-realmbgn).c_str(), max_size);
+ Operator->copyToClipboard(s);
+ Operator->copyToClipboard(s);
if (isEnabled())
if (isEnabled())
{
{
diff --git a/source/Irrlicht/MacOSX/AppDelegate.h b/source/Irrlicht/MacOSX/AppDelegate.h
diff --git a/source/Irrlicht/MacOSX/AppDelegate.h b/source/Irrlicht/MacOSX/AppDelegate.h
index ccb116d..29705f2 100644
index ccb116d..29705f2 100644
--- a/source/Irrlicht/MacOSX/AppDelegate.h
--- a/source/Irrlicht/MacOSX/AppDelegate.h
+++ b/source/Irrlicht/MacOSX/AppDelegate.h
+++ b/source/Irrlicht/MacOSX/AppDelegate.h
@@ -10,7 +10,7 @@
@@ -10,7 +10,7 @@
#import <Cocoa/Cocoa.h>
#import <Cocoa/Cocoa.h>
#import "CIrrDeviceMacOSX.h"
#import "CIrrDeviceMacOSX.h"
-@interface AppDelegate : NSObject
-@interface AppDelegate : NSObject
+@interface AppDelegate : NSTextView <NSApplicationDelegate>
+@interface AppDelegate : NSTextView <NSApplicationDelegate>
{
{
BOOL _quit;
BOOL _quit;
irr::CIrrDeviceMacOSX *_device;
irr::CIrrDeviceMacOSX *_device;
diff --git a/source/Irrlicht/MacOSX/AppDelegate.mm b/source/Irrlicht/MacOSX/AppDelegate.mm
diff --git a/source/Irrlicht/MacOSX/AppDelegate.mm b/source/Irrlicht/MacOSX/AppDelegate.mm
index 14a7f86..0ab0c43 100644
index 14a7f86..0ab0c43 100644
--- a/source/Irrlicht/MacOSX/AppDelegate.mm
--- a/source/Irrlicht/MacOSX/AppDelegate.mm
+++ b/source/Irrlicht/MacOSX/AppDelegate.mm
+++ b/source/Irrlicht/MacOSX/AppDelegate.mm
@@ -74,6 +74,30 @@
@@ -74,6 +74,30 @@
return (_quit);
return (_quit);
}
}
+
+
+- (void)keyDown:(NSEvent *)event
+- (void)keyDown:(NSEvent *)event
+{
+{
+ [self interpretKeyEvents:@[event]];
+ [self interpretKeyEvents:@[event]];
+}
+}
+
+
+- (void)insertText:(id)string
+- (void)insertText:(id)string
+{
+{
+ [self setString: @""];
+ [self setString: @""];
+ if ([string isKindOfClass:[NSAttributedString class]])
+ if ([string isKindOfClass:[NSAttributedString class]])
+ {
+ {
+ _device->handleInputEvent([[string string] UTF8String]);
+ _device->handleInputEvent([[string string] UTF8String]);
+ }
+ }
+ else
+ else
+ {
+ {
+ _device->handleInputEvent([string UTF8String]);
+ _device->handleInputEvent([string UTF8String]);
+ }
+ }
+}
+}
+
+
+- (void)doCommandBySelector:(SEL)selector
+- (void)doCommandBySelector:(SEL)selector
+{
+{
+ _device->processKeyEvent();
+ _device->processKeyEvent();
+}
+}
+
+
@end
@end
#endif // _IRR_COMPILE_WITH_OSX_DEVICE_
#endif // _IRR_COMPILE_WITH_OSX_DEVICE_
diff --git a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
diff --git a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
index f629588..d2fefae 100644
index f629588..d2fefae 100644
--- a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
--- a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
+++ b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
+++ b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.h
@@ -95,6 +95,8 @@
namespace irr
@@ -95,6 +95,8 @@
namespace irr
void setMouseLocation(int x, int y);
void setMouseLocation(int x, int y);
void setResize(int width, int height);
void setResize(int width, int height);
void setCursorVisible(bool visible);
void setCursorVisible(bool visible);
+ void handleInputEvent(const char *str);
+ void handleInputEvent(const char *str);
+ void processKeyEvent();
+ void processKeyEvent();
private:
private:
diff --git a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
diff --git a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
index ad493fc..8692d0c 100644
index ad493fc..8692d0c 100644
--- a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
--- a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
+++ b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
+++ b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm
@@ -496,7 +496,7 @@
CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
@@ -496,7 +496,7 @@
CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
{
{
[[NSAutoreleasePool alloc] init];
[[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
[NSApplication sharedApplication];
- [NSApp setDelegate:(id<NSFileManagerDelegate>)[[[AppDelegate alloc] initWithDevice:this] autorelease]];
- [NSApp setDelegate:(id<NSFileManagerDelegate>)[[[AppDelegate alloc] initWithDevice:this] autorelease]];
+ [NSApp setDelegate:[[[[AppDelegate alloc] initWithDevice:this] initWithFrame:NSZeroRect] autorelease]];
+ [NSApp setDelegate:[[[[AppDelegate alloc] initWithDevice:this] initWithFrame:NSZeroRect] autorelease]];
[NSBundle loadNibNamed:@"MainMenu" owner:[NSApp delegate]];
[NSBundle loadNibNamed:@"MainMenu" owner:[NSApp delegate]];
[NSApp finishLaunching];
[NSApp finishLaunching];
}
}
@@ -592,6 +592,38 @@
void CIrrDeviceMacOSX::closeDevice()
@@ -592,6 +592,38 @@
void CIrrDeviceMacOSX::closeDevice()
CGLContext = NULL;
CGLContext = NULL;
}
}
+void CIrrDeviceMacOSX::processKeyEvent()
+void CIrrDeviceMacOSX::processKeyEvent()
+{
+{
+ irr::SEvent ievent;
+ irr::SEvent ievent;
+ NSEvent *event = [[NSApplication sharedApplication] currentEvent];
+ NSEvent *event = [[NSApplication sharedApplication] currentEvent];
+ postKeyEvent(event, ievent, true);
+ postKeyEvent(event, ievent, true);
+}
+}
+
+
+void CIrrDeviceMacOSX::handleInputEvent(const char *cStr)
+void CIrrDeviceMacOSX::handleInputEvent(const char *cStr)
+{
+{
+ SEvent ievent;
+ SEvent ievent;
+
+
+ // TODO: we should have such a function in core::string
+ // TODO: we should have such a function in core::string
+ size_t lenOld = strlen(cStr);
+ size_t lenOld = strlen(cStr);
+ wchar_t *ws = new wchar_t[lenOld + 1];
+ wchar_t *ws = new wchar_t[lenOld + 1];
+ size_t len = mbstowcs(ws,cStr,lenOld);
+ size_t len = mbstowcs(ws,cStr,lenOld);
+ ws[len] = 0;
+ ws[len] = 0;
+ irr::core::stringw widep(ws);
+ irr::core::stringw widep(ws);
+ delete[] ws;
+ delete[] ws;
+
+
+ ievent.EventType = irr::EET_KEY_INPUT_EVENT;
+ ievent.EventType = irr::EET_KEY_INPUT_EVENT;
+ ievent.KeyInput.Key = (irr::EKEY_CODE)0;
+ ievent.KeyInput.Key = (irr::EKEY_CODE)0;
+ ievent.KeyInput.PressedDown = true;
+ ievent.KeyInput.PressedDown = true;
+ ievent.KeyInput.Shift = false;
+ ievent.KeyInput.Shift = false;
+ ievent.KeyInput.Control = false;
+ ievent.KeyInput.Control = false;
+
+
+ for (int i = 0; i < widep.size(); ++i)
+ for (int i = 0; i < widep.size(); ++i)
+ {
+ {
+ ievent.KeyInput.Char = widep[i];
+ ievent.KeyInput.Char = widep[i];
+ postEventFromUser(ievent);
+ postEventFromUser(ievent);
+ }
+ }
+}
+}
+
+
bool CIrrDeviceMacOSX::createWindow()
bool CIrrDeviceMacOSX::createWindow()
{
{
CGDisplayErr error;
CGDisplayErr error;
@@ -881,6 +913,8 @@
bool CIrrDeviceMacOSX::createWindow()
@@ -881,6 +913,8 @@
bool CIrrDeviceMacOSX::createWindow()
newSwapInterval = (CreationParams.Vsync) ? 1 : 0;
newSwapInterval = (CreationParams.Vsync) ? 1 : 0;
CGLSetParameter(CGLContext,kCGLCPSwapInterval,&newSwapInterval);
CGLSetParameter(CGLContext,kCGLCPSwapInterval,&newSwapInterval);
}
}
+
+
+ [[Window contentView] addSubview:(AppDelegate*)[NSApp delegate]];
+ [[Window contentView] addSubview:(AppDelegate*)[NSApp delegate]];
}
}
return (result);
return (result);
@@ -971,6 +1005,33 @@
bool CIrrDeviceMacOSX::run()
@@ -971,6 +1005,33 @@
bool CIrrDeviceMacOSX::run()
os::Timer::tick();
os::Timer::tick();
storeMouseLocation();
storeMouseLocation();
+ auto focusElement = getGUIEnvironment()->getFocus();
+ auto focusElement = getGUIEnvironment()->getFocus();
+ bool editing = focusElement && focusElement->getType() == irr::gui::EGUIET_EDIT_BOX;
+ bool editing = focusElement && focusElement->getType() == irr::gui::EGUIET_EDIT_BOX;
+
+
+ if (!editing)
+ if (!editing)
+ {
+ {
+ [Window makeFirstResponder:nil];
+ [Window makeFirstResponder:nil];
+ }
+ }
+ else
+ else
+ {
+ {
+ auto textView = (NSTextView*)[NSApp delegate];
+ auto textView = (NSTextView*)[NSApp delegate];
+ auto crect = focusElement->getAbsolutePosition();
+ auto crect = focusElement->getAbsolutePosition();
+
+
+ // ensure font height enough to fill the rect, otherwize ime window will overlaps the edit box
+ // ensure font height enough to fill the rect, otherwize ime window will overlaps the edit box
+ [textView setFont:[NSFont userFontOfSize:crect.getHeight()]];
+ [textView setFont:[NSFont userFontOfSize:crect.getHeight()]];
+
+
+ // change origin from top left to bottom right
+ // change origin from top left to bottom right
+ NSRect rect = {
+ NSRect rect = {
+ crect.UpperLeftCorner.X,
+ crect.UpperLeftCorner.X,
+ [[textView superview] frame].size.height - crect.LowerRightCorner.Y,
+ [[textView superview] frame].size.height - crect.LowerRightCorner.Y,
+ crect.getWidth(), crect.getHeight(),
+ crect.getWidth(), crect.getHeight(),
+ };
+ };
+ [textView setFrame:rect];
+ [textView setFrame:rect];
+
+
+ // start to receive input events
+ // start to receive input events
+ [Window makeFirstResponder:textView];
+ [Window makeFirstResponder:textView];
+ }
+ }
+
+
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
if (event != nil)
if (event != nil)
{
{
@@ -979,6 +1040,13 @@
bool CIrrDeviceMacOSX::run()
@@ -979,6 +1040,13 @@
bool CIrrDeviceMacOSX::run()
switch([(NSEvent *)event type])
switch([(NSEvent *)event type])
{
{
case NSKeyDown:
case NSKeyDown:
+ if (editing)
+ if (editing)
+ {
+ {
+ // delegate to text edit control to handle text input
+ // delegate to text edit control to handle text input
+ [NSApp sendEvent:event];
+ [NSApp sendEvent:event];
+ break;
+ break;
+ }
+ }
+
+
postKeyEvent(event,ievent,true);
postKeyEvent(event,ievent,true);
break;
break;
@@ -1199,22 +1267,22 @@
void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed
@@ -1199,22 +1267,22 @@
void CIrrDeviceMacOSX::postKeyEvent(void *event,irr::SEvent &ievent,bool pressed
}
}
else
else
{
{
- cStr = (unsigned char *)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding];
- cStr = (unsigned char *)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding];
+ cStr = (unsigned char *)[str UTF8String];
+ cStr = (unsigned char *)[str UTF8String];
if (cStr != NULL && strlen((char*)cStr) > 0)
if (cStr != NULL && strlen((char*)cStr) > 0)
{
{
mchar = cStr[0];
mchar = cStr[0];
mkey = toupper(mchar);
mkey = toupper(mchar);
- if ([(NSEvent *)event modifierFlags] & NSCommandKeyMask)
- if ([(NSEvent *)event modifierFlags] & NSCommandKeyMask)
- {
- {
- if (mkey == 'C' || mkey == 'V' || mkey == 'X')
- if (mkey == 'C' || mkey == 'V' || mkey == 'X')
- {
- {
- mchar = 0;
- mchar = 0;
- skipCommand = true;
- skipCommand = true;
- }
- }
- }
- }
}
}
}
}
}
}
+ if ([(NSEvent *)event modifierFlags] & NSCommandKeyMask)
+ if ([(NSEvent *)event modifierFlags] & NSCommandKeyMask)
+ {
+ {
+ if (mkey == 'C' || mkey == 'V' || mkey == 'X')
+ if (mkey == 'C' || mkey == 'V' || mkey == 'X')
+ {
+ {
+ mchar = 0;
+ mchar = 0;
+ skipCommand = true;
+ skipCommand = true;
+ }
+ }
+ }
+ }
ievent.EventType = irr::EET_KEY_INPUT_EVENT;
ievent.EventType = irr::EET_KEY_INPUT_EVENT;
ievent.KeyInput.Key = (irr::EKEY_CODE)mkey;
ievent.KeyInput.Key = (irr::EKEY_CODE)mkey;
diff --git a/source/Irrlicht/MacOSX/OSXClipboard.mm b/source/Irrlicht/MacOSX/OSXClipboard.mm
diff --git a/source/Irrlicht/MacOSX/OSXClipboard.mm b/source/Irrlicht/MacOSX/OSXClipboard.mm
index d549911..1925e80 100644
index d549911..1925e80 100644
--- a/source/Irrlicht/MacOSX/OSXClipboard.mm
--- a/source/Irrlicht/MacOSX/OSXClipboard.mm
+++ b/source/Irrlicht/MacOSX/OSXClipboard.mm
+++ b/source/Irrlicht/MacOSX/OSXClipboard.mm
@@ -13,7 +13,7 @@
void OSXCopyToClipboard(const char *text)
@@ -13,7 +13,7 @@
void OSXCopyToClipboard(const char *text)
if ((text != NULL) && (strlen(text) > 0))
if ((text != NULL) && (strlen(text) > 0))
{
{
- str = [NSString stringWithCString:text encoding:NSWindowsCP1252StringEncoding];
- str = [NSString stringWithCString:text encoding:NSWindowsCP1252StringEncoding];
+ str = [NSString stringWithUTF8String:text];
+ str = [NSString stringWithUTF8String:text];
board = [NSPasteboard generalPasteboard];
board = [NSPasteboard generalPasteboard];
[board declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp];
[board declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp];
[board setString:str forType:NSStringPboardType];
[board setString:str forType:NSStringPboardType];
@@ -30,7 +30,7 @@
char* OSXCopyFromClipboard()
@@ -30,7 +30,7 @@
char* OSXCopyFromClipboard()
board = [NSPasteboard generalPasteboard];
board = [NSPasteboard generalPasteboard];
str = [board stringForType:NSStringPboardType];
str = [board stringForType:NSStringPboardType];
if (str != nil)
if (str != nil)
- result = (char*)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding];
- result = (char*)[str cStringUsingEncoding:NSWindowsCP1252StringEncoding];
+ result = (char*)[str UTF8String];
+ result = (char*)[str UTF8String];
return (result);
return (result);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment