summaryrefslogtreecommitdiff
path: root/indra/llwindow
diff options
context:
space:
mode:
authorGeenz <geenz@geenzo.com>2013-01-23 09:29:32 -0500
committerGeenz <geenz@geenzo.com>2013-01-23 09:29:32 -0500
commitc52e6f9c597c67637045134d808a9039f85efc5c (patch)
tree60b7d1eaf6199046cbec99e568b95e1e577b7c36 /indra/llwindow
parent7ead8fceeb84f984aa5c363e058d274984bfb03c (diff)
Refactor the key input handling to make it easier to filter out keys we don't need unicode characters for (such as the arrow keys).
Diffstat (limited to 'indra/llwindow')
-rw-r--r--indra/llwindow/llopenglview-objc.h1
-rw-r--r--indra/llwindow/llopenglview-objc.mm67
-rw-r--r--indra/llwindow/llwindowmacosx-objc.mm6
3 files changed, 44 insertions, 30 deletions
diff --git a/indra/llwindow/llopenglview-objc.h b/indra/llwindow/llopenglview-objc.h
index 1592e6e01d..cc1618b3bc 100644
--- a/indra/llwindow/llopenglview-objc.h
+++ b/indra/llwindow/llopenglview-objc.h
@@ -14,7 +14,6 @@
@interface LLOpenGLView : NSOpenGLView
{
- NSPoint mousePos;
std::string mLastDraggedUrl;
}
diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm
index 763cf0c981..b79b7b3fa5 100644
--- a/indra/llwindow/llopenglview-objc.mm
+++ b/indra/llwindow/llopenglview-objc.mm
@@ -294,37 +294,48 @@
- (void) keyDown:(NSEvent *)theEvent
{
- callKeyDown([theEvent keyCode], mModifiers);
- NSLog(@"Keycode: %hu", [theEvent keyCode]);
- NSString *chars = [theEvent characters];
- for (uint i = 0; i < [chars length]; i++)
- {
- // Enter and Return are special cases.
- unichar returntest = [chars characterAtIndex:i];
- if ((returntest == NSCarriageReturnCharacter || returntest == NSEnterCharacter) &&
- !([theEvent modifierFlags] & NSCommandKeyMask) &&
- !([theEvent modifierFlags] & NSAlternateKeyMask) &&
- !([theEvent modifierFlags] & NSControlKeyMask))
- {
- callUnicodeCallback(13, 0);
- } else {
- // The command key being pressed is also a special case.
- // Control + <character> produces an ASCII control character code.
- // Command + <character> produces just the character's code.
- // Check to see if the command key is pressed, then filter through the different character ranges that are relevant to control characters, and subtract the appropriate range.
- if ([theEvent modifierFlags] & NSCommandKeyMask)
- {
- if (returntest >= 64 && returntest <= 95)
- {
- callUnicodeCallback(returntest - 63, mModifiers);
- } else if (returntest >= 97 && returntest <= 122)
+ uint keycode = [theEvent keyCode];
+
+ switch (keycode) {
+ case 0x7b:
+ case 0x7c:
+ case 0x7d:
+ case 0x7e:
+ callKeyDown(keycode, mModifiers);
+ break;
+
+ default:
+ callKeyDown(keycode, mModifiers);
+ NSString *chars = [theEvent characters];
+ for (uint i = 0; i < [chars length]; i++) {
+ // Enter and Return are special cases.
+ unichar returntest = [chars characterAtIndex:i];
+ if ((returntest == NSCarriageReturnCharacter || returntest == NSEnterCharacter) &&
+ !([theEvent modifierFlags] & NSCommandKeyMask) &&
+ !([theEvent modifierFlags] & NSAlternateKeyMask) &&
+ !([theEvent modifierFlags] & NSControlKeyMask))
{
- callUnicodeCallback(returntest - 96, mModifiers);
+ callUnicodeCallback(13, 0);
+ } else {
+ // The command key being pressed is also a special case.
+ // Control + <character> produces an ASCII control character code.
+ // Command + <character> produces just the character's code.
+ // Check to see if the command key is pressed, then filter through the different character ranges that are relevant to control characters, and subtract the appropriate range.
+ if ([theEvent modifierFlags] & NSCommandKeyMask)
+ {
+ if (returntest >= 64 && returntest <= 95)
+ {
+ callUnicodeCallback(returntest - 63, mModifiers);
+ } else if (returntest >= 97 && returntest <= 122)
+ {
+ callUnicodeCallback(returntest - 96, mModifiers);
+ }
+ } else {
+ callUnicodeCallback(returntest, mModifiers);
+ }
}
- } else {
- callUnicodeCallback(returntest, mModifiers);
}
- }
+ break;
}
}
diff --git a/indra/llwindow/llwindowmacosx-objc.mm b/indra/llwindow/llwindowmacosx-objc.mm
index 7867226476..b123ba0711 100644
--- a/indra/llwindow/llwindowmacosx-objc.mm
+++ b/indra/llwindow/llwindowmacosx-objc.mm
@@ -64,11 +64,12 @@ void setupCocoa()
bool copyToPBoard(const unsigned short *str, unsigned int len)
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
[pboard clearContents];
NSArray *contentsToPaste = [[NSArray alloc] initWithObjects:[NSString stringWithCharacters:str length:len], nil];
-
+ [pool release];
return [pboard writeObjects:contentsToPaste];
}
@@ -80,6 +81,7 @@ bool pasteBoardAvailable()
const unsigned short *copyFromPBoard()
{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
NSPasteboard *pboard = [NSPasteboard generalPasteboard];
NSArray *classArray = [NSArray arrayWithObject:[NSString class]];
NSString *str = NULL;
@@ -91,6 +93,7 @@ const unsigned short *copyFromPBoard()
}
unichar* temp = (unichar*)calloc([str length], sizeof(unichar));
[str getCharacters:temp];
+ [pool release];
return temp;
}
@@ -312,6 +315,7 @@ void convertWindowToScreen(NSWindowRef window, float *coord)
void closeWindow(NSWindowRef window)
{
[(LLNSWindow*)window close];
+ [(LLNSWindow*)window release];
}
void removeGLView(GLViewRef view)