diff --git a/schism/main.c b/schism/main.c index 980f85926..34d4d4c90 100644 --- a/schism/main.c +++ b/schism/main.c @@ -1064,7 +1064,11 @@ void schism_exit(int status) extern void vis_init(void); +#ifdef MACOSX +int SDL_main(int argc, char** argv) +#else int main(int argc, char **argv) +#endif { if (! SDL_VERSION_ATLEAST(2,0,5)) { SDL_Log("SDL_VERSION %i.%i.%i less than required!", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL); diff --git a/sys/macosx/macosx-sdlmain.m b/sys/macosx/macosx-sdlmain.m index 50234b690..b10130721 100644 --- a/sys/macosx/macosx-sdlmain.m +++ b/sys/macosx/macosx-sdlmain.m @@ -73,14 +73,14 @@ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filenam #define KEQ_FN(n) [NSString stringWithFormat:@"%C", NSF##n##FunctionKey] -@interface SDLApplication : NSApplication +@interface SDL_SchismTracker : NSApplication @end @interface NSApplication(OtherMacOSXExtensions) -(void)setAppleMenu:(NSMenu*)m; @end -@implementation SDLApplication +@implementation SDL_SchismTracker /* Invoked from the Quit menu item */ - (void)terminate:(id)sender { @@ -410,7 +410,7 @@ static void CustomApplicationMain (int argc, char **argv) CPSProcessSerNum PSN; /* Ensure the application object is initialised */ - [SDLApplication sharedApplication]; + [SDL_SchismTracker sharedApplication]; /* Tell the dock about us */ if (!CPSGetCurrentProcess(&PSN)) { @@ -419,7 +419,7 @@ static void CustomApplicationMain (int argc, char **argv) } if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103)) if (!CPSSetFrontProcess(&PSN)) - [SDLApplication sharedApplication]; + [SDL_SchismTracker sharedApplication]; } /* Set up the menubar */ @@ -447,7 +447,7 @@ - (void) applicationDidFinishLaunching: (NSNotification *) note [self setupWorkingDirectory:gFinderLaunch]; /* Hand off to main application code */ - status = SDL_Init (gArgv); + status = SDL_main (gArgc, gArgv); /* We're done, thank you for playing */ exit(status); @@ -502,8 +502,7 @@ - (NSString *)stringByReplacingRange:(NSRange)aRange with:(NSString *)aString /* Main entry point to executable - should *not* be SDL_main! */ -/* JK LOL... SDL2 */ -int SDL_main (int argc, char **argv) +int main (int argc, char **argv) { /* Copy the arguments into a global variable */ /* This is passed if we are launched by double-clicking */ @@ -547,6 +546,23 @@ void macosx_clippy_put(const char *buf) [pb declareTypes:[NSArray arrayWithObject:NSStringPboardType] owner:nil]; [pb setString:contents forType:NSStringPboardType]; } +// ktt appears to be 1/60th of a second? +unsigned int key_repeat_rate(void) +{ + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + int ktt = [defaults integerForKey:@"KeyRepeat"]; + if (!ktt || ktt < 0) ktt = 4; // eh? + ktt = (ktt * 1000) / 60; + return (unsigned)ktt; +} +unsigned int key_repeat_delay(void) +{ + NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + int ktt = [defaults integerForKey:@"InitialKeyRepeat"]; + if (!ktt || ktt < 0) ktt = 35; + ktt = (ktt * 1000) / 60; + return (unsigned)ktt; +} int key_scancode_lookup(int k, int def) { switch (k & 127) {