Mercurial > sdl-ios-xcode
view src/events/scancodes_darwin.h @ 3487:24d13328c44a
Eric Wing to Sam, hfutrell
This one is quite puzzling. I found a partial workaround, but I don't fully understand the reasons yet.
First, the console is complaining about not finding a nib for MainWindow.
I tried removing the entry for this in the info.plist, and the message went away, but it didn't really change anything.
Second, I stepped through this with the debugger and broke up some lines. It seems that the basic act of calling
view = [SDL_uikitopenglview alloc];
or even
view = [SDL_uikitview alloc]
will crash the program. The debugger messages plus the stack trace make me think it's not finding the SDL_uikitview classes for some reason. But I don't understand why this would be.
view = [UIView alloc] will not crash the program.
For kicks, I added a new definition of a class called SDL_object which subclasses NSObject in the same files as SDL_uikitopenglview and then call
view = [SDL_object alloc];
This does not crash the program.
So, then I modified SDL_object to subclass UIView. No crash.
Next, I made SDL_object subclass UIView<UITextFieldDelegate> . This crashes.
So it is the act of conforming to the UITextFieldDelegate protocol that is crashing things.
I don't understand why it would crash on alloc though. I'm guessing either a delegate needs to be set somewhere or one of the required methods needs to be implemented. But in the former case, I would not expect a crash, but a silent message to nil and something else doesn't work. And in the latter case, I would expect a compiler warning and an exception thrown instead of a crash.
Anyway, my temporary workaround is to change the interface declaration for SDL_uikitview to look like:
#if SDL_IPHONE_KEYBOARD
@interface SDL_uikitview : UIView<UITextFieldDelegate> {
#else
@interface SDL_uikitview : UIView {
#endif
And then disable the keyboard support in the SDL_config_iphoneos.h file.
/* enable iPhone keyboard support */
#define SDL_IPHONE_KEYBOARD 0
-Eric
On Nov 23, 2009, at 1:43 AM, Sam Lantinga wrote:
> I ran into a blocking startup crash with the Happy demo on iPhone OS 3.1.2 on my new iPhone:
>
> #0 0x323fea14 in _class_isInitialized
> #1 0x323fea68 in _class_initialize
> #2 0x32403e92 in prepareForMethodLookup
> #3 0x32401244 in lookUpMethod
> #4 0x323fea10 in _class_lookupMethodAndLoadCache
> #5 0x323fe746 in objc_msgSend_uncached
> #6 0x323feb26 in _class_initialize
> #7 0x323fea58 in _class_initialize
> #8 0x32403e92 in prepareForMethodLookup
> #9 0x32401244 in lookUpMethod
> #10 0x323fea10 in _class_lookupMethodAndLoadCache
> #11 0x323fe746 in objc_msgSend_uncached
> #12 0x000554dc in UIKit_GL_CreateContext at SDL_uikitopengles.m:103
> #13 0x0004f89e in SDL_GL_CreateContext at SDL_video.c:3155
> #14 0x000579e8 in GLES_CreateRenderer at SDL_renderer_gles.c:282
> #15 0x0004d7b8 in SDL_CreateRenderer at SDL_video.c:1509
> #16 0x00002bc2 in SDL_main at happy.c:156
> #17 0x000571b2 in -[SDLUIKitDelegate postFinishLaunch] at
> SDL_uikitappdelegate.m:77
> #18 0x313f9ef2 in __NSFireDelayedPerform
> #19 0x32567bb2 in CFRunLoopRunSpecific
> #20 0x3256735c in CFRunLoopRunInMode
> #21 0x32912cbe in GSEventRunModal
> #22 0x32912d6a in GSEventRun
> #23 0x32b6276e in -[UIApplication _run]
> #24 0x32b61472 in UIApplicationMain
> #25 0x00057088 in main at SDL_uikitappdelegate.m:50
>
> Any ideas?
>
> See ya!
> --
> -Sam Lantinga, Founder and President, Galaxy Gameworks LLC
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 24 Nov 2009 08:12:32 +0000 |
parents | dc1eb82ffdaa |
children | f7b03b6838cb |
line wrap: on
line source
/* SDL - Simple DirectMedia Layer Copyright (C) 1997-2009 Sam Lantinga This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Sam Lantinga slouken@libsdl.org */ /* Mac virtual key code to SDL scancode mapping table Sources: - Inside Macintosh: Text <http://developer.apple.com/documentation/mac/Text/Text-571.html> - Apple USB keyboard driver source <http://darwinsource.opendarwin.org/10.4.6.ppc/IOHIDFamily-172.8/IOHIDFamily/Cosmo_USB2ADB.c> - experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard */ /* *INDENT-OFF* */ static const SDL_scancode darwin_scancode_table[] = { /* 0 */ SDL_SCANCODE_A, /* 1 */ SDL_SCANCODE_S, /* 2 */ SDL_SCANCODE_D, /* 3 */ SDL_SCANCODE_F, /* 4 */ SDL_SCANCODE_H, /* 5 */ SDL_SCANCODE_G, /* 6 */ SDL_SCANCODE_Z, /* 7 */ SDL_SCANCODE_X, /* 8 */ SDL_SCANCODE_C, /* 9 */ SDL_SCANCODE_V, /* 10 */ SDL_SCANCODE_NONUSBACKSLASH, /* SDL_SCANCODE_NONUSBACKSLASH on ANSI and JIS keyboards (if this key would exist there), SDL_SCANCODE_GRAVE on ISO. (The USB keyboard driver actually translates these usage codes to different virtual key codes depending on whether the keyboard is ISO/ANSI/JIS. That's why you have to help it identify the keyboard type when you plug in a PC USB keyboard. It's a historical thing - ADB keyboards are wired this way.) */ /* 11 */ SDL_SCANCODE_B, /* 12 */ SDL_SCANCODE_Q, /* 13 */ SDL_SCANCODE_W, /* 14 */ SDL_SCANCODE_E, /* 15 */ SDL_SCANCODE_R, /* 16 */ SDL_SCANCODE_Y, /* 17 */ SDL_SCANCODE_T, /* 18 */ SDL_SCANCODE_1, /* 19 */ SDL_SCANCODE_2, /* 20 */ SDL_SCANCODE_3, /* 21 */ SDL_SCANCODE_4, /* 22 */ SDL_SCANCODE_6, /* 23 */ SDL_SCANCODE_5, /* 24 */ SDL_SCANCODE_EQUALS, /* 25 */ SDL_SCANCODE_9, /* 26 */ SDL_SCANCODE_7, /* 27 */ SDL_SCANCODE_MINUS, /* 28 */ SDL_SCANCODE_8, /* 29 */ SDL_SCANCODE_0, /* 30 */ SDL_SCANCODE_RIGHTBRACKET, /* 31 */ SDL_SCANCODE_O, /* 32 */ SDL_SCANCODE_U, /* 33 */ SDL_SCANCODE_LEFTBRACKET, /* 34 */ SDL_SCANCODE_I, /* 35 */ SDL_SCANCODE_P, /* 36 */ SDL_SCANCODE_RETURN, /* 37 */ SDL_SCANCODE_L, /* 38 */ SDL_SCANCODE_J, /* 39 */ SDL_SCANCODE_APOSTROPHE, /* 40 */ SDL_SCANCODE_K, /* 41 */ SDL_SCANCODE_SEMICOLON, /* 42 */ SDL_SCANCODE_BACKSLASH, /* 43 */ SDL_SCANCODE_COMMA, /* 44 */ SDL_SCANCODE_SLASH, /* 45 */ SDL_SCANCODE_N, /* 46 */ SDL_SCANCODE_M, /* 47 */ SDL_SCANCODE_PERIOD, /* 48 */ SDL_SCANCODE_TAB, /* 49 */ SDL_SCANCODE_SPACE, /* 50 */ SDL_SCANCODE_GRAVE, /* SDL_SCANCODE_GRAVE on ANSI and JIS keyboards, SDL_SCANCODE_NONUSBACKSLASH on ISO (see comment about virtual key code 10 above) */ /* 51 */ SDL_SCANCODE_BACKSPACE, /* 52 */ SDL_SCANCODE_KP_ENTER, /* keyboard enter on portables */ /* 53 */ SDL_SCANCODE_ESCAPE, /* 54 */ SDL_SCANCODE_RGUI, /* 55 */ SDL_SCANCODE_LGUI, /* 56 */ SDL_SCANCODE_LSHIFT, /* 57 */ SDL_SCANCODE_CAPSLOCK, /* 58 */ SDL_SCANCODE_LALT, /* 59 */ SDL_SCANCODE_LCTRL, /* 60 */ SDL_SCANCODE_RSHIFT, /* 61 */ SDL_SCANCODE_RALT, /* 62 */ SDL_SCANCODE_RCTRL, /* 63 */ SDL_SCANCODE_RGUI, /* fn on portables, acts as a hardware-level modifier already, so we don't generate events for it, also XK_Meta_R */ /* 64 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 65 */ SDL_SCANCODE_KP_PERIOD, /* 66 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 67 */ SDL_SCANCODE_KP_MULTIPLY, /* 68 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 69 */ SDL_SCANCODE_KP_PLUS, /* 70 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 71 */ SDL_SCANCODE_NUMLOCKCLEAR, /* 72 */ SDL_SCANCODE_VOLUMEUP, /* 73 */ SDL_SCANCODE_VOLUMEDOWN, /* 74 */ SDL_SCANCODE_MUTE, /* 75 */ SDL_SCANCODE_KP_DIVIDE, /* 76 */ SDL_SCANCODE_KP_ENTER, /* keypad enter on external keyboards, fn-return on portables */ /* 77 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 78 */ SDL_SCANCODE_KP_MINUS, /* 79 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 80 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 81 */ SDL_SCANCODE_KP_EQUALS, /* 82 */ SDL_SCANCODE_KP_0, /* 83 */ SDL_SCANCODE_KP_1, /* 84 */ SDL_SCANCODE_KP_2, /* 85 */ SDL_SCANCODE_KP_3, /* 86 */ SDL_SCANCODE_KP_4, /* 87 */ SDL_SCANCODE_KP_5, /* 88 */ SDL_SCANCODE_KP_6, /* 89 */ SDL_SCANCODE_KP_7, /* 90 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 91 */ SDL_SCANCODE_KP_8, /* 92 */ SDL_SCANCODE_KP_9, /* 93 */ SDL_SCANCODE_INTERNATIONAL3, /* Cosmo_USB2ADB.c says "Yen (JIS)" */ /* 94 */ SDL_SCANCODE_INTERNATIONAL1, /* Cosmo_USB2ADB.c says "Ro (JIS)" */ /* 95 */ SDL_SCANCODE_KP_COMMA, /* Cosmo_USB2ADB.c says ", JIS only" */ /* 96 */ SDL_SCANCODE_F5, /* 97 */ SDL_SCANCODE_F6, /* 98 */ SDL_SCANCODE_F7, /* 99 */ SDL_SCANCODE_F3, /* 100 */ SDL_SCANCODE_F8, /* 101 */ SDL_SCANCODE_F9, /* 102 */ SDL_SCANCODE_LANG2, /* Cosmo_USB2ADB.c says "Eisu" */ /* 103 */ SDL_SCANCODE_F11, /* 104 */ SDL_SCANCODE_LANG1, /* Cosmo_USB2ADB.c says "Kana" */ /* 105 */ SDL_SCANCODE_PRINTSCREEN, /* On ADB keyboards, this key is labeled "F13/print screen". Problem: USB has different usage codes for these two functions. On Apple USB keyboards, the key is labeled "F13" and sends the F13 usage code (SDL_SCANCODE_F13). I decided to use SDL_SCANCODE_PRINTSCREEN here nevertheless since SDL applications are more likely to assume the presence of a print screen key than an F13 key. */ /* 106 */ SDL_SCANCODE_F16, /* 107 */ SDL_SCANCODE_SCROLLLOCK, /* F14/scroll lock, see comment about F13/print screen above */ /* 108 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 109 */ SDL_SCANCODE_F10, /* 110 */ SDL_SCANCODE_APPLICATION, /* windows contextual menu key, fn-enter on portables */ /* 111 */ SDL_SCANCODE_F12, /* 112 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ /* 113 */ SDL_SCANCODE_PAUSE, /* F15/pause, see comment about F13/print screen above */ /* 114 */ SDL_SCANCODE_INSERT, /* the key is actually labeled "help" on Apple keyboards, and works as such in Mac OS, but it sends the "insert" usage code even on Apple USB keyboards */ /* 115 */ SDL_SCANCODE_HOME, /* 116 */ SDL_SCANCODE_PAGEUP, /* 117 */ SDL_SCANCODE_DELETE, /* 118 */ SDL_SCANCODE_F4, /* 119 */ SDL_SCANCODE_END, /* 120 */ SDL_SCANCODE_F2, /* 121 */ SDL_SCANCODE_PAGEDOWN, /* 122 */ SDL_SCANCODE_F1, /* 123 */ SDL_SCANCODE_LEFT, /* 124 */ SDL_SCANCODE_RIGHT, /* 125 */ SDL_SCANCODE_DOWN, /* 126 */ SDL_SCANCODE_UP, /* 127 */ SDL_SCANCODE_POWER }; /* *INDENT-ON* */