Oolite 1.91.0.7699-250829-cea269d
Loading...
Searching...
No Matches
MyOpenGLView Class Reference

#include <MyOpenGLView.h>

Inheritance diagram for MyOpenGLView:
Collaboration diagram for MyOpenGLView:

Instance Methods

(void) - initKeyMappingData
(void) - setStringInput:
(void) - allowStringInput:
(enum StringInput- allowingStringInput
(NSString *) - typedString
(void) - resetTypedString
(void) - setTypedString:
(NSSize) - viewSize
(NSSize) - backingViewSize
(GLfloat) - display_z
(GLfloat) - x_offset
(GLfloat) - y_offset
(GameController *) - gameController
(void) - setGameController:
(void) - noteMouseInteractionModeChangedFrom:to:
(void) - initialiseGLWithSize:
(NSData *) - pixelFormatAttributes
(void) - drawRect:
(void) - updateScreen
(void) - pollControls
(void) - stringToClipboard:
(BOOL) - snapShot:
(void) - mouseDown:
(void) - mouseUp:
(void) - resetMouse
(void) - setVirtualJoystick:vmx:
(NSPoint) - virtualJoystickPosition
(void) - clearKeys
(void) - clearMouse
(void) - clearKey:
(BOOL) - isAlphabetKeyDown
(void) - suppressKeysUntilKeyUp
(BOOL) - isDown:
(BOOL) - isOptDown
(BOOL) - isCtrlDown
(BOOL) - isCommandDown
(BOOL) - isShiftDown
(BOOL) - isCapsLockOn
(BOOL) - lastKeyWasShifted
(int- numKeys
(int- mouseWheelState
(float) - mouseWheelDelta
(void) - setMouseWheelDelta:
(BOOL) - isCommandQDown
(BOOL) - isCommandFDown
(void) - clearCommandF
(OOOpenGLMatrixManager *) - getOpenGLMatrixManager
(void) - dumpRGBAToFileNamed:bytes:width:height:rowBytes:
(void) - dumpRGBToFileNamed:bytes:width:height:rowBytes:
(void) - dumpGrayToFileNamed:bytes:width:height:rowBytes:
(void) - dumpGrayAlphaToFileNamed:bytes:width:height:rowBytes:
(void) - dumpRGBAToRGBFileNamed:andGrayFileNamed:bytes:width:height:rowBytes:
(void) - setGammaValue:
(float) - gammaValue
(void) - setFov:fromFraction:
(float) - fov:
(id) - init
(void) - initSplashScreen
(void) - endSplashScreen
(void) - autoShowMouse
(void) - initKeyMappingData
(void) - setStringInput:
(void) - allowStringInput:
(enum StringInput- allowingStringInput
(NSString *) - typedString
(void) - resetTypedString
(void) - setTypedString:
(NSSize) - viewSize
(NSSize) - backingViewSize
(GLfloat) - display_z
(GLfloat) - x_offset
(GLfloat) - y_offset
(GameController *) - gameController
(void) - setGameController:
(void) - noteMouseInteractionModeChangedFrom:to:
(void) - initialiseGLWithSize:
(void) - initialiseGLWithSize:useVideoMode:
(BOOL) - isRunningOnPrimaryDisplayDevice
(OOSDRToneMapper- sdrToneMapper
(void) - setSDRToneMapper:
(float) - colorSaturation
(void) - adjustColorSaturation:
(BOOL) - hdrOutput
(BOOL) - isOutputDisplayHDREnabled
(void) - grabMouseInsideGameWindow:
(void) - stringToClipboard:
(void) - drawRect:
(void) - updateScreen
(void) - updateScreenWithVideoMode:
(void) - display
(BOOL) - snapShot:
(BOOL) - pngSaveSurface:withSurface:
(NSRect) - bounds
(void) - setFullScreenMode:
(BOOL) - inFullScreenMode
(void) - toggleScreenMode
(void) - setDisplayMode:fullScreen:
(int- indexOfCurrentSize
(void) - setScreenSize:
(NSMutableArray *) - getScreenSizeArray
(void) - populateFullScreenModelist
(NSSize) - modeAsSize:
(void) - saveWindowSize:
(NSSize) - loadWindowSize
(int- loadFullscreenSettings
(int- findDisplayModeForWidth:Height:Refresh:
(NSSize) - currentScreenSize
(void) - pollControls
(void) - setVirtualJoystick:vmx:
(NSPoint) - virtualJoystickPosition
(void) - clearKeys
(void) - clearMouse
(void) - clearKey:
(void) - resetMouse
(BOOL) - isAlphabetKeyDown
(void) - suppressKeysUntilKeyUp
(BOOL) - isDown:
(BOOL) - isOptDown
(BOOL) - isCtrlDown
(BOOL) - isCommandDown
(BOOL) - isShiftDown
(BOOL) - isCapsLockOn
(BOOL) - lastKeyWasShifted
(int- numKeys
(int- mouseWheelState
(float) - mouseWheelDelta
(void) - setMouseWheelDelta:
(BOOL) - isCommandQDown
(BOOL) - isCommandFDown
(void) - clearCommandF
(void) - setMouseInDeltaMode:
(void) - setGammaValue:
(float) - gammaValue
(void) - setFov:fromFraction:
(float) - fov:
(void) - setMsaa:
(BOOL) - msaa
(OOOpenGLMatrixManager *) - getOpenGLMatrixManager
(void) - dumpRGBAToFileNamed:bytes:width:height:rowBytes:
(void) - dumpRGBToFileNamed:bytes:width:height:rowBytes:
(void) - dumpGrayToFileNamed:bytes:width:height:rowBytes:
(void) - dumpGrayAlphaToFileNamed:bytes:width:height:rowBytes:
(void) - dumpRGBAToRGBFileNamed:andGrayFileNamed:bytes:width:height:rowBytes:
(id) - initWithFrame: [implementation]
(void) - dealloc [implementation]
(void) - noteMovedToBadDisplay [implementation]
(void) - update [implementation]
(BOOL) - acceptsFirstResponder [implementation]
(void) - keyUp: [implementation]
(void) - keyDown: [implementation]
(void) - flagsChanged: [implementation]
(void) - mouseMoved: [implementation]
(void) - mouseDragged: [implementation]
(void) - scrollWheel: [implementation]
(void) - otherMouseDragged: [implementation]
(void) - rightMouseDown: [implementation]
(void) - rightMouseUp: [implementation]
(void) - touchesEndedWithEvent: [implementation]
(void) - recenterVirtualJoystick [implementation]
(int- translateKeyCode: [implementation]
(void) - createSurface [implementation]
(void) - resetSDLKeyModifiers [implementation]
(void) - setWindowBorderless: [implementation]
(void) - handleStringInput:keyID: [implementation]
(BOOL) - isCommandModifierKeyDown [implementation]

Class Methods

(BOOL) + pollShiftKey
(NSMutableDictionary *) + getNativeSize
(BOOL) + pollShiftKey
(static void) + GetDesiredCursorState [implementation]
(static void) + ApplyCursorState [implementation]
(static void) + UnapplyCursorState [implementation]

Protected Attributes

NSPoint mouseDragStartPoint
BOOL mouseWarped
NSTimeInterval timeSinceLastMouseWheel
float _mouseVirtualStickSensitivityFactor
double squareX
double squareY
NSRect bounds
float _gamma
BOOL _msaa
NSMutableArray * screenSizes
int currentSize
BOOL fullScreen
NSSize currentWindowSize
SDL_Surface * surface
BOOL showSplashScreen
int _sdrToneMapper
float _colorSaturation
BOOL _hdrOutput
BOOL grabMouseStatus
NSSize firstScreen
BOOL mouseInDeltaMode

Private Attributes

GameControllergameController
BOOL keys [NUM_KEYS]
int scancode2Unicode [NUM_KEYS]
NSDictionary * keyMappings_normal
NSDictionary * keyMappings_shifted
BOOL suppressKeys
BOOL opt
BOOL ctrl
BOOL command
BOOL shift
BOOL capsLockOn
BOOL lastKeyShifted
BOOL allowingStringInput
BOOL isAlphabetKeyDown
BOOL commandQ
BOOL commandF
BOOL f12
int keycodetrans [255]
BOOL m_glContextInitialized
NSTimeInterval timeIntervalAtLastClick
NSTimeInterval timeIntervalAtLastMouseWheel
BOOL doubleClick
NSMutableString * typedString
NSPoint virtualJoystickPosition
float _mouseWheelDelta
NSSize viewSize
NSSize backingViewSize
GLfloat display_z
GLfloat x_offset
GLfloat y_offset
float _fov
int _virtualScreen
NSData * _pixelFormatAttributes
OOOpenGLMatrixManagermatrixManager

Detailed Description

Definition at line 123 of file MyOpenGLView.h.

Method Documentation

◆ acceptsFirstResponder

- (BOOL) acceptsFirstResponder
implementation

Definition at line 547 of file MyOpenGLView.m.

548{
549 return YES;
550}

References acceptsFirstResponder.

Referenced by acceptsFirstResponder.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ adjustColorSaturation:

- (void) adjustColorSaturation: (float) colorSaturationAdjustment

Definition at line 1657 of file MyOpenGLView.m.

1657 :(float)colorSaturationAdjustment;
1658{
1659 _colorSaturation += colorSaturationAdjustment;
1661}
#define MAX_COLOR_SATURATION
float _colorSaturation

References _colorSaturation, and MAX_COLOR_SATURATION.

Referenced by PlayerEntity(OOPrivate)::gameOverFadeToBW, and OoliteSetProperty().

Here is the caller graph for this function:

◆ allowingStringInput [1/2]

- (enum StringInput) allowingStringInput

References allowingStringInput.

◆ allowingStringInput [2/2]

- (enum StringInput) allowingStringInput

References allowingStringInput.

◆ allowStringInput: [1/2]

- (void) allowStringInput: (BOOL) value

Definition at line 588 of file MyOpenGLView.m.

588 : (BOOL) value
589{
590 if (value)
592 else
594}
@ gvStringInputAlpha
@ gvStringInputNo
BOOL allowingStringInput

References allowingStringInput, gvStringInputAlpha, and gvStringInputNo.

Referenced by PlayerEntity(OOControlsPrivate)::pollApplicationControls, PlayerEntity(OOControlsPrivate)::pollDemoControls:, PlayerEntity(OOControlsPrivate)::pollDockedControls:, PlayerEntity(OOControlsPrivate)::pollFlightControls:, PlayerEntity(OOControlsPrivate)::pollGuiArrowKeyControls:, and PlayerEntity(Controls)::switchToMainView.

Here is the caller graph for this function:

◆ allowStringInput: [2/2]

- (void) allowStringInput: (BOOL) value

◆ ApplyCursorState

+ (void) ApplyCursorState (OOMouseInteractionMode) mode
implementation

Definition at line 1341 of file MyOpenGLView.m.

1342{
1343 BOOL hidden, obscured;
1344 GetDesiredCursorState(mode, &hidden, &obscured);
1345 if (hidden) [NSCursor hide];
1346 if (obscured) [NSCursor setHiddenUntilMouseMoves:YES];
1347}
static void GetDesiredCursorState(OOMouseInteractionMode mode, BOOL *outHidden, BOOL *outObscured)
const char int mode
Definition ioapi.h:133

References GetDesiredCursorState().

Here is the call graph for this function:

◆ autoShowMouse

- (void) autoShowMouse

Definition at line 567 of file MyOpenGLView.m.

568{
569 //don't touch the 'please wait...' cursor.
570 if (fullScreen)
571 {
572 if (SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE)
573 SDL_ShowCursor(SDL_DISABLE);
574 }
575 else
576 {
577 if (SDL_ShowCursor(SDL_QUERY) == SDL_DISABLE)
578 SDL_ShowCursor(SDL_ENABLE);
579 }
580}

References autoShowMouse, and fullScreen.

Referenced by autoShowMouse, endSplashScreen, init, initialiseGLWithSize:useVideoMode:, and noteMouseInteractionModeChangedFrom:to:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ backingViewSize [1/2]

- (NSSize) backingViewSize

References backingViewSize.

◆ backingViewSize [2/2]

- (NSSize) backingViewSize

References backingViewSize.

◆ bounds

- (NSRect) bounds

References bounds, and getNativeSize.

Here is the call graph for this function:

◆ clearCommandF [1/2]

- (void) clearCommandF

Definition at line 2109 of file MyOpenGLView.m.

2110{
2111 // SDL stub for the mac function.
2112}

References clearCommandF.

Referenced by clearCommandF, isAlphabetKeyDown, and PlayerEntity(OOControlsPrivate)::pollApplicationControls.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearCommandF [2/2]

- (void) clearCommandF

References clearCommandF.

Here is the call graph for this function:

◆ clearKey: [1/2]

- (void) clearKey: (int) theKey

Definition at line 1971 of file MyOpenGLView.m.

1971 : (int)theKey
1972{
1973 if (theKey >= 0 && theKey < [self numKeys])
1974 {
1975 keys[theKey] = NO;
1976 }
1977}
BOOL keys[NUM_KEYS]
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque

References keys, and numKeys.

Referenced by PlayerEntity(OOControlsPrivate)::pollFlightControls:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearKey: [2/2]

- (void) clearKey: (int) theKey

◆ clearKeys [1/2]

◆ clearKeys [2/2]

- (void) clearKeys

References clearKeys.

Here is the call graph for this function:

◆ clearMouse [1/2]

◆ clearMouse [2/2]

- (void) clearMouse

References clearMouse.

Here is the call graph for this function:

◆ colorSaturation

- (float) colorSaturation

Definition at line 1651 of file MyOpenGLView.m.

1652{
1653 return _colorSaturation;
1654}

References _colorSaturation, and colorSaturation.

Referenced by colorSaturation, PlayerEntity(OOPrivate)::gameOverFadeToBW, initialiseGLWithSize:, and OoliteSetProperty().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createSurface

- (void) createSurface
implementation

Definition at line 122 of file MyOpenGLView.m.

123{
124 // Changing these flags can trigger texture bugs.
125 const int videoModeFlags = SDL_HWSURFACE | SDL_OPENGL | SDL_RESIZABLE;
126
128 {
129#if OOLITE_WINDOWS
130 // Pre setVideoMode adjustments.
131 NSSize tmp = currentWindowSize;
132 ShowWindow(SDL_Window,SW_SHOWMINIMIZED);
133 updateContext = NO; //don't update the (splash screen) window yet!
134
135 // Initialise the SDL surface. (need custom SDL.dll)
136 surface = SDL_SetVideoMode(firstScreen.width, firstScreen.height, 32, videoModeFlags);
137
138 // Post setVideoMode adjustments.
140#else
141 // Changing the flags can trigger texture bugs.
142 surface = SDL_SetVideoMode(8, 8, 32, videoModeFlags);
143#endif
144 if (!surface) {
145 return;
146 }
147 }
148 else
149 {
150#if OOLITE_WINDOWS
151 updateContext = YES;
152#endif
153 surface = SDL_SetVideoMode(firstScreen.width, firstScreen.height, 32, videoModeFlags);
154 if (!surface) {
155 return;
156 }
157 // blank the surface / go to fullscreen
158 [self initialiseGLWithSize: firstScreen];
159 }
160
161 _gamma = 1.0f;
162 if (SDL_SetGamma(_gamma, _gamma, _gamma) < 0 )
163 {
164 char * errStr = SDL_GetError();
165 OOLogWARN(@"gamma.set.failed", @"Could not set gamma: %s", errStr);
166 // CIM: this doesn't seem to necessarily be fatal. Gamma settings
167 // mostly work on mine despite this function failing.
168 // exit(1);
169 }
170 SDL_EnableUNICODE(1);
171}
#define OOLogWARN(class, format,...)
Definition OOLogging.h:113
BOOL showSplashScreen
SDL_Surface * surface
NSSize currentWindowSize
NSSize firstScreen

References _gamma, createSurface, currentWindowSize, firstScreen, initialiseGLWithSize:, OOLogWARN, showSplashScreen, and surface.

Referenced by createSurface, and init.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ currentScreenSize

- (NSSize) currentScreenSize

Definition at line 2920 of file MyOpenGLView.m.

2921{
2922 NSDictionary *mode=[screenSizes objectAtIndex: currentSize];
2923
2924 if(mode)
2925 {
2926 return NSMakeSize([[mode objectForKey: kOODisplayWidth] intValue],
2927 [[mode objectForKey: kOODisplayHeight] intValue]);
2928 }
2929 OOLog(@"display.mode.unknown", @"%@", @"Screen size unknown!");
2931}
#define kOODisplayHeight
#define kOODisplayWidth
#define OOLog(class, format,...)
Definition OOLogging.h:88
#define WINDOW_SIZE_DEFAULT_HEIGHT
#define WINDOW_SIZE_DEFAULT_WIDTH

References currentScreenSize, kOODisplayHeight, kOODisplayWidth, OOLog, WINDOW_SIZE_DEFAULT_HEIGHT, and WINDOW_SIZE_DEFAULT_WIDTH.

Referenced by currentScreenSize, and modeAsSize:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dealloc

- (void) dealloc
implementation

Definition at line 173 of file MyOpenGLView.m.

174{
178
180 [keyMappings_normal release];
182 [keyMappings_shifted release];
183
184 [super dealloc];
185}
#define DESTROY(x)
Definition OOCocoa.h:77
NSDictionary * keyMappings_shifted
NSMutableString * typedString
NSData * _pixelFormatAttributes
OOOpenGLMatrixManager * matrixManager
NSDictionary * keyMappings_normal

References _pixelFormatAttributes, dealloc, DESTROY, keyMappings_normal, keyMappings_shifted, matrixManager, and typedString.

Referenced by dealloc, and init.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ display

- (void) display

Definition at line 761 of file MyOpenGLView.m.

762{
763 [self updateScreen];
764}

References display, and updateScreen.

Referenced by display, and updateScreen.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ display_z [1/2]

- (GLfloat) display_z

References display_z.

◆ display_z [2/2]

- (GLfloat) display_z

References display_z.

◆ drawRect: [1/2]

- (void) drawRect: (NSRect) rect

Definition at line 771 of file MyOpenGLView.m.

771 :(NSRect)rect
772{
773 [self updateScreenWithVideoMode:YES];
774}

References updateScreenWithVideoMode:.

Referenced by updateScreen.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawRect: [2/2]

- (void) drawRect: (NSRect) rect

◆ dumpGrayAlphaToFileNamed:bytes:width:height:rowBytes: [1/2]

- (void) dumpGrayAlphaToFileNamed: (NSString *) name
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

Definition at line 3050 of file MyOpenGLView.m.

3050 :(NSString *)name
3051 bytes:(uint8_t *)bytes
3052 width:(NSUInteger)width
3053 height:(NSUInteger)height
3054 rowBytes:(NSUInteger)rowBytes
3055{
3056 if (name == nil || bytes == NULL || width == 0 || height == 0 || rowBytes < width * 2) return;
3057
3058 // use the snapshots directory
3059 NSString *dumpFile = [[NSHomeDirectory() stringByAppendingPathComponent:@SAVEDIR] stringByAppendingPathComponent:@SNAPSHOTDIR];
3060 dumpFile = [dumpFile stringByAppendingPathComponent: [NSString stringWithFormat:@"%@.bmp", name]];
3061
3062 SDL_Surface* tmpSurface = SDL_CreateRGBSurfaceFrom(bytes, width, height, 16, rowBytes, 0xFF, 0xFF, 0xFF, 0xFF);
3063 SDL_SaveBMP(tmpSurface, [dumpFile UTF8String]);
3064 SDL_FreeSurface(tmpSurface);
3065}
return nil

References nil.

Referenced by OODumpPixMap().

Here is the caller graph for this function:

◆ dumpGrayAlphaToFileNamed:bytes:width:height:rowBytes: [2/2]

- (void) dumpGrayAlphaToFileNamed: (NSString *) name
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

◆ dumpGrayToFileNamed:bytes:width:height:rowBytes: [1/2]

- (void) dumpGrayToFileNamed: (NSString *) name
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

Definition at line 3032 of file MyOpenGLView.m.

3032 :(NSString *)name
3033 bytes:(uint8_t *)bytes
3034 width:(NSUInteger)width
3035 height:(NSUInteger)height
3036 rowBytes:(NSUInteger)rowBytes
3037{
3038 if (name == nil || bytes == NULL || width == 0 || height == 0 || rowBytes < width) return;
3039
3040 // use the snapshots directory
3041 NSString *dumpFile = [[NSHomeDirectory() stringByAppendingPathComponent:@SAVEDIR] stringByAppendingPathComponent:@SNAPSHOTDIR];
3042 dumpFile = [dumpFile stringByAppendingPathComponent: [NSString stringWithFormat:@"%@.bmp", name]];
3043
3044 SDL_Surface* tmpSurface = SDL_CreateRGBSurfaceFrom(bytes, width, height, 8, rowBytes, 0xFF, 0xFF, 0xFF, 0x0);
3045 SDL_SaveBMP(tmpSurface, [dumpFile UTF8String]);
3046 SDL_FreeSurface(tmpSurface);
3047}

References nil.

Referenced by dumpRGBAToRGBFileNamed:andGrayFileNamed:bytes:width:height:rowBytes:, and OODumpPixMap().

Here is the caller graph for this function:

◆ dumpGrayToFileNamed:bytes:width:height:rowBytes: [2/2]

- (void) dumpGrayToFileNamed: (NSString *) name
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

◆ dumpRGBAToFileNamed:bytes:width:height:rowBytes: [1/2]

- (void) dumpRGBAToFileNamed: (NSString *) name
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

Definition at line 2995 of file MyOpenGLView.m.

2995 :(NSString *)name
2996 bytes:(uint8_t *)bytes
2997 width:(NSUInteger)width
2998 height:(NSUInteger)height
2999 rowBytes:(NSUInteger)rowBytes
3000{
3001 if (name == nil || bytes == NULL || width == 0 || height == 0 || rowBytes < width * 4) return;
3002
3003 // use the snapshots directory
3004 NSString *dumpFile = [[NSHomeDirectory() stringByAppendingPathComponent:@SAVEDIR] stringByAppendingPathComponent:@SNAPSHOTDIR];
3005 dumpFile = [dumpFile stringByAppendingPathComponent: [NSString stringWithFormat:@"%@.bmp", name]];
3006
3007 // convert transparency to black before saving to bmp
3008 SDL_Surface* tmpSurface = SDL_CreateRGBSurfaceFrom(bytes, width, height, 32, rowBytes, 0xFF, 0xFF00, 0xFF0000, 0xFF000000);
3009 SDL_SaveBMP(tmpSurface, [dumpFile UTF8String]);
3010 SDL_FreeSurface(tmpSurface);
3011}

References nil.

◆ dumpRGBAToFileNamed:bytes:width:height:rowBytes: [2/2]

- (void) dumpRGBAToFileNamed: (NSString *) name
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

◆ dumpRGBAToRGBFileNamed:andGrayFileNamed:bytes:width:height:rowBytes: [1/2]

- (void) dumpRGBAToRGBFileNamed: (NSString *) rgbName
andGrayFileNamed: (NSString *) grayName
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

Definition at line 3068 of file MyOpenGLView.m.

3068 :(NSString *)rgbName
3069 andGrayFileNamed:(NSString *)grayName
3070 bytes:(uint8_t *)bytes
3071 width:(NSUInteger)width
3072 height:(NSUInteger)height
3073 rowBytes:(NSUInteger)rowBytes
3074{
3075 if ((rgbName == nil && grayName == nil) || bytes == NULL || width == 0 || height == 0 || rowBytes < width * 4) return;
3076
3077 uint8_t *rgbBytes, *rgbPx, *grayBytes, *grayPx, *srcPx;
3078 NSUInteger x, y;
3079 BOOL trivalAlpha = YES;
3080
3081 rgbPx = rgbBytes = malloc(width * height * 3);
3082 if (rgbBytes == NULL) return;
3083
3084 grayPx = grayBytes = malloc(width * height);
3085 if (grayBytes == NULL)
3086 {
3087 free(rgbBytes);
3088 return;
3089 }
3090
3091 for (y = 0; y < height; y++)
3092 {
3093 srcPx = bytes + rowBytes * y;
3094
3095 for (x = 0; x < width; x++)
3096 {
3097 *rgbPx++ = *srcPx++;
3098 *rgbPx++ = *srcPx++;
3099 *rgbPx++ = *srcPx++;
3100 trivalAlpha = trivalAlpha && ((*srcPx == 0xFF) || (*srcPx == 0x00)); // Look for any "interesting" pixels in alpha.
3101 *grayPx++ = *srcPx++;
3102 }
3103 }
3104
3105 [self dumpRGBToFileNamed:rgbName
3106 bytes:rgbBytes
3107 width:width
3108 height:height
3109 rowBytes:width * 3];
3110 free(rgbBytes);
3111
3112 if (!trivalAlpha)
3113 {
3114 [self dumpGrayToFileNamed:grayName
3115 bytes:grayBytes
3116 width:width
3117 height:height
3118 rowBytes:width];
3119 }
3120 free(grayBytes);
3121}
float y
float x

References dumpGrayToFileNamed:bytes:width:height:rowBytes:, dumpRGBToFileNamed:bytes:width:height:rowBytes:, nil, x, and y.

Referenced by OODumpPixMap().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dumpRGBAToRGBFileNamed:andGrayFileNamed:bytes:width:height:rowBytes: [2/2]

- (void) dumpRGBAToRGBFileNamed: (NSString *) rgbName
andGrayFileNamed: (NSString *) grayName
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

◆ dumpRGBToFileNamed:bytes:width:height:rowBytes: [1/2]

- (void) dumpRGBToFileNamed: (NSString *) name
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

Definition at line 3014 of file MyOpenGLView.m.

3014 :(NSString *)name
3015 bytes:(uint8_t *)bytes
3016 width:(NSUInteger)width
3017 height:(NSUInteger)height
3018 rowBytes:(NSUInteger)rowBytes
3019{
3020 if (name == nil || bytes == NULL || width == 0 || height == 0 || rowBytes < width * 3) return;
3021
3022 // use the snapshots directory
3023 NSString *dumpFile = [[NSHomeDirectory() stringByAppendingPathComponent:@SAVEDIR] stringByAppendingPathComponent:@SNAPSHOTDIR];
3024 dumpFile = [dumpFile stringByAppendingPathComponent: [NSString stringWithFormat:@"%@.bmp", name]];
3025
3026 SDL_Surface* tmpSurface = SDL_CreateRGBSurfaceFrom(bytes, width, height, 24, rowBytes, 0xFF, 0xFF00, 0xFF0000, 0x0);
3027 SDL_SaveBMP(tmpSurface, [dumpFile UTF8String]);
3028 SDL_FreeSurface(tmpSurface);
3029}

References nil.

Referenced by dumpRGBAToRGBFileNamed:andGrayFileNamed:bytes:width:height:rowBytes:.

Here is the caller graph for this function:

◆ dumpRGBToFileNamed:bytes:width:height:rowBytes: [2/2]

- (void) dumpRGBToFileNamed: (NSString *) name
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

◆ endSplashScreen

- (void) endSplashScreen

Definition at line 452 of file MyOpenGLView.m.

453{
454#if OOLITE_WINDOWS
455 if ([self hdrOutput] && ![self isOutputDisplayHDREnabled])
456 {
457 if (MessageBox(NULL, "No primary display in HDR mode was detected.\n\n"
458 "If you continue, graphics will not be rendered as intended.\n"
459 "Click OK to launch anyway, or Cancel to exit.", "oolite.exe - HDR requested",
460 MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL)
461 {
462 exit (1);
463 }
464 }
465#endif // OOLITE_WINDOWS
466
467 if (!showSplashScreen) return;
468
469#if OOLITE_WINDOWS
470
471 wasFullScreen = !fullScreen;
472 updateContext = YES;
473 ShowWindow(SDL_Window,SW_RESTORE);
474 [self initialiseGLWithSize: firstScreen];
475
476#else
477
478 int videoModeFlags = SDL_HWSURFACE | SDL_OPENGL;
479
480 videoModeFlags |= (fullScreen) ? SDL_FULLSCREEN : SDL_RESIZABLE;
481 surface = SDL_SetVideoMode(firstScreen.width, firstScreen.height, 32, videoModeFlags);
482
483 if (!surface && fullScreen == YES)
484 {
485 [self setFullScreenMode: NO];
486 videoModeFlags &= ~SDL_FULLSCREEN;
487 videoModeFlags |= SDL_RESIZABLE;
488 surface = SDL_SetVideoMode(currentWindowSize.width, currentWindowSize.height, 32, videoModeFlags);
489 }
490
491 SDL_putenv ("SDL_VIDEO_WINDOW_POS=none"); //stop linux from auto centering on resize
492
493 /* MKW 2011.11.11
494 * Eat all SDL events to gobble up any resize events while the
495 * splash-screen was visible. They affected the main window after 1.74.
496 * TODO: should really process SDL events while showing the splash-screen
497
498 int numEvents = 0;
499 */
500 SDL_Event dummyEvent;
501 while (SDL_PollEvent(&dummyEvent))
502 {
503 /* Do nothing; the below is for development info
504 numEvents++;
505 OOLog(@"display.splash", @"Suppressed splash-screen event %d: %d ", numEvents, dummyEvent.type);
506 */
507 }
508
509
510#endif
511
512 [self updateScreen];
513 [self autoShowMouse];
514}
BOOL isOutputDisplayHDREnabled()

References autoShowMouse, currentWindowSize, endSplashScreen, firstScreen, fullScreen, hdrOutput, initialiseGLWithSize:, isOutputDisplayHDREnabled, setFullScreenMode:, showSplashScreen, surface, and updateScreen.

Referenced by GameController::endSplashScreen, endSplashScreen, and initSplashScreen.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ findDisplayModeForWidth:Height:Refresh:

- (int) findDisplayModeForWidth: (unsigned int) d_width
Height: (unsigned int) d_height
Refresh: (unsigned int) d_refresh 

Definition at line 2893 of file MyOpenGLView.m.

2893 :(unsigned int) d_width Height:(unsigned int) d_height Refresh:(unsigned int) d_refresh
2894{
2895 int i, modeCount;
2896 NSDictionary *mode;
2897 unsigned int modeWidth, modeHeight, modeRefresh;
2898
2899 modeCount = [screenSizes count];
2900
2901 for (i = 0; i < modeCount; i++)
2902 {
2903 mode = [screenSizes objectAtIndex: i];
2904 modeWidth = [[mode objectForKey: kOODisplayWidth] intValue];
2905 modeHeight = [[mode objectForKey: kOODisplayHeight] intValue];
2906 modeRefresh = [[mode objectForKey: kOODisplayRefreshRate] intValue];
2907 if ((modeWidth == d_width)&&(modeHeight == d_height)&&(modeRefresh == d_refresh))
2908 {
2909 OOLog(@"display.mode.found", @"Found mode %@", mode);
2910 return i;
2911 }
2912 }
2913
2914 OOLog(@"display.mode.found.failed", @"Failed to find mode: width=%d height=%d refresh=%d", d_width, d_height, d_refresh);
2915 OOLog(@"display.mode.found.failed.list", @"Contents of list: %@", screenSizes);
2916 return 0;
2917}
NSMutableArray * screenSizes

References int(), OOLog, and screenSizes.

Referenced by loadFullscreenSettings.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flagsChanged:

- (void) flagsChanged: (NSEvent *) theEvent
implementation

Definition at line 743 of file MyOpenGLView.m.

743 :(NSEvent *)theEvent
744{
745 NSUInteger flags = [theEvent modifierFlags];
746 opt = (flags & NSAlternateKeyMask) ? YES : NO;
747 ctrl = (flags & NSControlKeyMask) ? YES : NO;
748 command = (flags & NSCommandKeyMask) ? YES : NO;
749 shift = ( flags & NSShiftKeyMask ) ? YES : NO;
750 if ([theEvent keyCode] == 0x39) // 57 = key code for caps lock
751 {
752 capsLockOn = (flags & NSAlphaShiftKeyMask) ? YES : NO;
753 }
754}

References capsLockOn, command, ctrl, opt, and shift.

◆ fov: [1/2]

- (float) fov: (BOOL) inFraction

Definition at line 2964 of file MyOpenGLView.m.

2964 :(BOOL)inFraction
2965{
2966 return inFraction ? _fov : 2 * atan(_fov) * 180 / M_PI;
2967}
#define M_PI
Definition OOMaths.h:73

References _fov, and M_PI.

Referenced by HeadUpDisplay::drawScannerGrid, Universe::drawUniverse, Universe::gameSettings, PlayerEntity(OOControlsPrivate)::handleGameOptionsScreenKeys, and PlayerEntity::setGuiToGameOptionsScreen.

Here is the caller graph for this function:

◆ fov: [2/2]

- (float) fov: (BOOL) inFraction

References msaa.

Here is the call graph for this function:

◆ gameController [1/2]

- (GameController *) gameController

References gameController, pixelFormatAttributes, pollControls, resetMouse, and updateScreen.

Here is the call graph for this function:

◆ gameController [2/2]

- (GameController *) gameController

References gameController.

◆ gammaValue [1/2]

- (float) gammaValue

Definition at line 2952 of file MyOpenGLView.m.

2953{
2954 return _gamma;
2955}

References _gamma, and gammaValue.

Referenced by Universe::gameSettings, gammaValue, PlayerEntity(OOControlsPrivate)::handleGameOptionsScreenKeys, isAlphabetKeyDown, and PlayerEntity::setGuiToGameOptionsScreen.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ gammaValue [2/2]

- (float) gammaValue

References gammaValue.

Here is the call graph for this function:

◆ GetDesiredCursorState

+ (void) GetDesiredCursorState (OOMouseInteractionMode) mode
(BOOL *) outHidden
(BOOL *) outObscured 
implementation

Definition at line 1332 of file MyOpenGLView.m.

1333{
1334 NSCParameterAssert(outHidden != NULL && outObscured != NULL);
1335
1337 *outObscured = (mode == MOUSE_MODE_FLIGHT_NO_MOUSE_CONTROL);
1338}
@ MOUSE_MODE_FLIGHT_WITH_MOUSE_CONTROL
@ MOUSE_MODE_FLIGHT_NO_MOUSE_CONTROL

References MOUSE_MODE_FLIGHT_NO_MOUSE_CONTROL, and MOUSE_MODE_FLIGHT_WITH_MOUSE_CONTROL.

◆ getNativeSize

+ (NSMutableDictionary *) getNativeSize

Definition at line 88 of file MyOpenGLView.m.

89{
90 NSMutableDictionary *mode=[[NSMutableDictionary alloc] init];
91 int nativeDisplayWidth = 1024;
92 int nativeDisplayHeight = 768;
93
94#if OOLITE_LINUX
95 SDL_SysWMinfo dpyInfo;
96 SDL_VERSION(&dpyInfo.version);
97 if(SDL_GetWMInfo(&dpyInfo))
98 {
99 nativeDisplayWidth = DisplayWidth(dpyInfo.info.x11.display, 0);
100 nativeDisplayHeight = DisplayHeight(dpyInfo.info.x11.display, 0);
101 OOLog(@"display.mode.list.native", @"X11 native resolution detected: %d x %d", nativeDisplayWidth, nativeDisplayHeight);
102 }
103 else
104 {
105 OOLog(@"display.mode.list.native.failed", @"%@", @"SDL_GetWMInfo failed, defaulting to 1024x768 for native size");
106 }
107#elif OOLITE_WINDOWS
108 nativeDisplayWidth = GetSystemMetrics(SM_CXSCREEN);
109 nativeDisplayHeight = GetSystemMetrics(SM_CYSCREEN);
110 OOLog(@"display.mode.list.native", @"Windows native resolution detected: %d x %d", nativeDisplayWidth, nativeDisplayHeight);
111#else
112 OOLog(@"display.mode.list.native.unknown", @"Unknown architecture, defaulting to 1024x768");
113#endif
114 [mode setValue: [NSNumber numberWithInt: nativeDisplayWidth] forKey:kOODisplayWidth];
115 [mode setValue: [NSNumber numberWithInt: nativeDisplayHeight] forKey: kOODisplayHeight];
116 [mode setValue: [NSNumber numberWithInt: 0] forKey: kOODisplayRefreshRate];
117
118 return [mode autorelease];
119}

References getNativeSize, and OOLog.

Referenced by bounds, getNativeSize, and populateFullScreenModelist.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOpenGLMatrixManager [1/2]

- (OOOpenGLMatrixManager *) getOpenGLMatrixManager

Definition at line 2982 of file MyOpenGLView.m.

2983{
2984 return matrixManager;
2985}

References getOpenGLMatrixManager, and matrixManager.

Referenced by getOpenGLMatrixManager, and isAlphabetKeyDown.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOpenGLMatrixManager [2/2]

- (OOOpenGLMatrixManager *) getOpenGLMatrixManager

References getOpenGLMatrixManager.

Here is the call graph for this function:

◆ getScreenSizeArray

- (NSMutableArray *) getScreenSizeArray

References getScreenSizeArray, and populateFullScreenModelist.

Referenced by getScreenSizeArray.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ grabMouseInsideGameWindow:

- (void) grabMouseInsideGameWindow: (BOOL) value

Definition at line 1366 of file MyOpenGLView.m.

1366 :(BOOL) value
1367{
1368 // do nothing
1369}

Referenced by PlayerEntity(OOControlsPrivate)::pollApplicationControls, and pollControls.

Here is the caller graph for this function:

◆ handleStringInput:keyID:

- (void) handleStringInput: (SDL_KeyboardEvent *) kbd_event
keyID: (Uint16) key_id 
implementation

Provided by category MyOpenGLView(OOPrivate).

Definition at line 2728 of file MyOpenGLView.m.

2728 : (SDL_KeyboardEvent *) kbd_event keyID:(Uint16)key_id;
2729{
2730 SDLKey key=kbd_event->keysym.sym;
2731
2732 // Del, Backspace
2733 if((key == SDLK_BACKSPACE || key == SDLK_DELETE) && [typedString length] > 0)
2734 {
2735 // delete
2736 [typedString deleteCharactersInRange:NSMakeRange([typedString length]-1, 1)];
2737 }
2738
2740
2741 // TODO: a more flexible mechanism for max. string length ?
2742 if([typedString length] < 40)
2743 {
2746 {
2747 // inputAlpha - limited input for planet find screen
2748 if(key >= SDLK_a && key <= SDLK_z)
2749 {
2751 [typedString appendFormat:@"%c", key];
2752 // if in inputAlpha, keep in lower case.
2753 }
2754 }
2755 else
2756 {
2757 //Uint16 unicode = kbd_event->keysym.unicode;
2758 // printable range
2759 if (key_id >= 32 && key_id <= 255) // 126
2760 {
2761 if ((char)key_id != '/' || allowingStringInput == gvStringInputAll)
2762 {
2764 [typedString appendFormat:@"%c", key_id];
2765 }
2766 }
2767 }
2768 }
2769}
@ gvStringInputAll

References gvStringInputAll, and gvStringInputAlpha.

Referenced by pollControls.

Here is the caller graph for this function:

◆ hdrOutput

- (BOOL) hdrOutput

Definition at line 1390 of file MyOpenGLView.m.

1391{
1392 return NO;
1393}

References hdrOutput.

Referenced by endSplashScreen, hdrOutput, initialiseGLWithSize:, pngSaveSurface:withSurface:, and snapShot:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ indexOfCurrentSize

- (int) indexOfCurrentSize

References indexOfCurrentSize, and int().

Referenced by indexOfCurrentSize.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ inFullScreenMode

- (BOOL) inFullScreenMode

Definition at line 675 of file MyOpenGLView.m.

676{
677 return fullScreen;
678}

References fullScreen, and inFullScreenMode.

Referenced by inFullScreenMode, setFullScreenMode:, and update.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialiseGLWithSize: [1/2]

- (void) initialiseGLWithSize: (NSSize) v_size

Definition at line 1418 of file MyOpenGLView.m.

1418 :(NSSize) v_size
1419{
1420 [self initialiseGLWithSize:v_size useVideoMode:YES];
1421}

References initialiseGLWithSize:useVideoMode:.

Referenced by createSurface, endSplashScreen, and pollControls.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initialiseGLWithSize: [2/2]

- (void) initialiseGLWithSize: (NSSize) v_size

References colorSaturation, hdrOutput, isOutputDisplayHDREnabled, isRunningOnPrimaryDisplayDevice, and sdrToneMapper.

Here is the call graph for this function:

◆ initialiseGLWithSize:useVideoMode:

- (void) initialiseGLWithSize: (NSSize) v_size
useVideoMode: (BOOL) v_mode 

Definition at line 1424 of file MyOpenGLView.m.

1424 :(NSSize) v_size useVideoMode:(BOOL) v_mode
1425{
1426#if OOLITE_LINUX
1427 NSSize oldViewSize = viewSize;
1428#endif
1429 viewSize = v_size;
1430 OOLog(@"display.initGL", @"Requested a new surface of %d x %d, %@.", (int)viewSize.width, (int)viewSize.height,(fullScreen ? @"fullscreen" : @"windowed"));
1431 SDL_GL_SwapBuffers(); // clear the buffer before resize
1432
1433#if OOLITE_WINDOWS
1434 if (!updateContext) return;
1435
1436 DEVMODE settings;
1437 settings.dmSize = sizeof(DEVMODE);
1438 settings.dmDriverExtra = 0;
1439 EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &settings);
1440
1441 WINDOWPLACEMENT windowPlacement;
1442 windowPlacement.length = sizeof(WINDOWPLACEMENT);
1443 GetWindowPlacement(SDL_Window, &windowPlacement);
1444
1445 static BOOL lastWindowPlacementMaximized = NO;
1446 if (fullScreen && (windowPlacement.showCmd == SW_SHOWMAXIMIZED))
1447 {
1448 if (!wasFullScreen)
1449 {
1450 lastWindowPlacementMaximized = YES;
1451 }
1452 }
1453
1454 if (lastWindowPlacementMaximized)
1455 {
1456 windowPlacement.showCmd = SW_SHOWMAXIMIZED;
1457 }
1458
1459 // are we attempting to go to a different screen resolution? Note: this also takes care of secondary monitor situations because
1460 // by design the only resolution available for fullscreen on a secondary display device is its native one - Nikos 20150605
1461 BOOL changingResolution = [self isRunningOnPrimaryDisplayDevice] &&
1462 ((fullScreen && (settings.dmPelsWidth != viewSize.width || settings.dmPelsHeight != viewSize.height)) ||
1463 (wasFullScreen && (settings.dmPelsWidth != [[[screenSizes objectAtIndex:0] objectForKey: kOODisplayWidth] intValue]
1464 || settings.dmPelsHeight != [[[screenSizes objectAtIndex:0] objectForKey: kOODisplayHeight] intValue])));
1465
1466 RECT wDC;
1467
1468 if (fullScreen)
1469 {
1470 /*NOTE: If we ever decide to change the default behaviour of launching
1471 always on primary monitor to launching on the monitor the program was
1472 started on, all that needs to be done is comment out the line below, as
1473 well as the identical one in the else branch further down.
1474 Nikos 20141222
1475 */
1476 [self getCurrentMonitorInfo: &monitorInfo];
1477
1478 settings.dmPelsWidth = viewSize.width;
1479 settings.dmPelsHeight = viewSize.height;
1480 settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
1481
1482 // just before going fullscreen, save the location of the current window. It
1483 // may be needed in case of potential attempts to move our fullscreen window
1484 // in a maximized state (yes, in Windows this is entirely possible).
1485 if(lastWindowPlacementMaximized)
1486 {
1487 CopyRect(&lastGoodRect, &windowPlacement.rcNormalPosition);
1488 // if maximized, switch to normal placement before going full screen
1489 windowPlacement.showCmd = SW_SHOWNORMAL;
1490 SetWindowPlacement(SDL_Window, &windowPlacement);
1491 }
1492 else GetWindowRect(SDL_Window, &lastGoodRect);
1493
1494 // ok, can go fullscreen now
1495 SetForegroundWindow(SDL_Window);
1496 if (changingResolution)
1497 {
1498 if (ChangeDisplaySettingsEx(monitorInfo.szDevice, &settings, NULL, CDS_FULLSCREEN, NULL) != DISP_CHANGE_SUCCESSFUL)
1499 {
1501 OOLogERR(@"displayMode.change.error", @"Could not switch to requested display mode.");
1502 return;
1503 }
1504 atDesktopResolution = settings.dmPelsWidth == [[[screenSizes objectAtIndex:0] objectForKey: kOODisplayWidth] intValue]
1505 && settings.dmPelsHeight == [[[screenSizes objectAtIndex:0] objectForKey: kOODisplayHeight] intValue];
1506 }
1507
1508 MoveWindow(SDL_Window, monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top, (int)viewSize.width, (int)viewSize.height, TRUE);
1509 if(!wasFullScreen)
1510 {
1511 [self setWindowBorderless:YES];
1512 }
1513 }
1514
1515 else if ( wasFullScreen )
1516 {
1517 if (changingResolution)
1518 {
1519 // restore original desktop resolution
1520 if (ChangeDisplaySettingsEx(NULL, NULL, NULL, 0, NULL) == DISP_CHANGE_SUCCESSFUL)
1521 {
1522 atDesktopResolution = YES;
1523 }
1524 }
1525
1526 /*NOTE: If we ever decide to change the default behaviour of launching
1527 always on primary monitor to launching on the monitor the program was
1528 started on, we need to comment out the line below.
1529 For now, this line is needed for correct positioning of our window in case
1530 we return from a non-native resolution fullscreen and has to come after the
1531 display settings have been reverted.
1532 Nikos 20141222
1533 */
1534 [self getCurrentMonitorInfo: &monitorInfo];
1535
1536 if (lastWindowPlacementMaximized) CopyRect(&windowPlacement.rcNormalPosition, &lastGoodRect);
1537 SetWindowPlacement(SDL_Window, &windowPlacement);
1538 if (!lastWindowPlacementMaximized)
1539 {
1540 MoveWindow(SDL_Window, (monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left - (int)viewSize.width)/2 +
1541 monitorInfo.rcMonitor.left,
1542 (monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top - (int)viewSize.height)/2 +
1543 monitorInfo.rcMonitor.top,
1544 (int)viewSize.width, (int)viewSize.height, TRUE);
1545 }
1546
1547 [self setWindowBorderless:NO];
1548
1549 lastWindowPlacementMaximized = NO;
1550 ShowWindow(SDL_Window,SW_SHOW);
1551 }
1552
1553 // stop saveWindowSize from reacting to caption & frame if necessary
1554 saveSize = !wasFullScreen;
1555
1556 GetClientRect(SDL_Window, &wDC);
1557
1558 if (!fullScreen && (bounds.size.width != wDC.right - wDC.left
1559 || bounds.size.height != wDC.bottom - wDC.top))
1560 {
1561 // Resize the game window if needed. When we ask for a W x H
1562 // window, we intend that the client area be W x H. The actual
1563 // window itself must become big enough to accomodate an area
1564 // of such size.
1565 if (wasFullScreen) // this is true when switching from full screen or when starting in windowed mode
1566 //after the splash screen has ended
1567 {
1568 RECT desiredClientRect;
1569 GetWindowRect(SDL_Window, &desiredClientRect);
1570 AdjustWindowRect(&desiredClientRect, WS_CAPTION | WS_THICKFRAME, FALSE);
1571 SetWindowPos(SDL_Window, NULL, desiredClientRect.left, desiredClientRect.top,
1572 desiredClientRect.right - desiredClientRect.left,
1573 desiredClientRect.bottom - desiredClientRect.top, 0);
1574 }
1575 GetClientRect(SDL_Window, &wDC);
1576 viewSize.width = wDC.right - wDC.left;
1577 viewSize.height = wDC.bottom - wDC.top;
1578 }
1579
1580 // Reset bounds and viewSize to current values
1581 bounds.size.width = viewSize.width = wDC.right - wDC.left;
1582 bounds.size.height = viewSize.height = wDC.bottom - wDC.top;
1583
1584 if (fullScreen) // bounds on fullscreen coincide with client area, since we are borderless
1585 {
1586 bounds.origin.x = monitorInfo.rcMonitor.left;
1587 bounds.origin.y = monitorInfo.rcMonitor.top;
1588 }
1589 wasFullScreen=fullScreen;
1590
1591#else //OOLITE_LINUX
1592
1593 int videoModeFlags = SDL_HWSURFACE | SDL_OPENGL;
1594
1595 if (v_mode == NO)
1596 videoModeFlags |= SDL_NOFRAME;
1597 if (fullScreen == YES)
1598 {
1599 videoModeFlags |= SDL_FULLSCREEN;
1600 }
1601 else
1602 {
1603 videoModeFlags |= SDL_RESIZABLE;
1604 }
1605 surface = SDL_SetVideoMode((int)viewSize.width, (int)viewSize.height, 32, videoModeFlags);
1606
1607 if (!surface && fullScreen == YES)
1608 {
1609 [self setFullScreenMode: NO];
1610 viewSize = oldViewSize;
1611 videoModeFlags &= ~SDL_FULLSCREEN;
1612 videoModeFlags |= SDL_RESIZABLE;
1613 surface = SDL_SetVideoMode((int)viewSize.width, (int)viewSize.height, 32, videoModeFlags);
1614 }
1615
1616 if (!surface)
1617 {
1618 // we should always have a valid surface, but in case we don't
1619 OOLogERR(@"display.mode.error",@"Unable to change display mode: %s",SDL_GetError());
1620 exit(1);
1621 }
1622
1623 bounds.size.width = surface->w;
1624 bounds.size.height = surface->h;
1625
1626#endif
1627 OOLog(@"display.initGL", @"Created a new surface of %d x %d, %@.", (int)viewSize.width, (int)viewSize.height,(fullScreen ? @"fullscreen" : @"windowed"));
1628
1629 if (viewSize.width/viewSize.height > 4.0/3.0) {
1630 display_z = 480.0 * bounds.size.width/bounds.size.height;
1631 x_offset = 240.0 * bounds.size.width/bounds.size.height;
1632 y_offset = 240.0;
1633 } else {
1634 display_z = 640.0;
1635 x_offset = 320.0;
1636 y_offset = 320.0 * bounds.size.height/bounds.size.width;
1637 }
1638
1639 if (surface != 0) SDL_FreeSurface(surface);
1640
1641 [self autoShowMouse];
1642
1643 [[self gameController] setUpBasicOpenGLStateWithSize:viewSize];
1644 SDL_GL_SwapBuffers();
1645 squareX = 0.0f;
1646
1648}
#define OOLogERR(class, format,...)
Definition OOLogging.h:112
BOOL m_glContextInitialized
GLfloat display_z
GLfloat x_offset
GLfloat y_offset

References autoShowMouse, bounds, display_z, fullScreen, gameController, isRunningOnPrimaryDisplayDevice, m_glContextInitialized, OOLog, OOLogERR, setFullScreenMode:, GameController::setUpBasicOpenGLStateWithSize:, setWindowBorderless:, squareX, surface, viewSize, x_offset, and y_offset.

Referenced by initialiseGLWithSize:, and updateScreenWithVideoMode:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initKeyMappingData [1/2]

- (void) initKeyMappingData

Definition at line 517 of file MyOpenGLView.m.

518{
519 NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
520 // load in our keyboard scancode mappings
521#if OOLITE_WINDOWS
522 NSDictionary *kmap = [NSDictionary dictionaryWithDictionary:[ResourceManager dictionaryFromFilesNamed:@"keymappings_windows.plist" inFolder:@"Config" mergeMode:MERGE_BASIC cache:NO]];
523#else
524 NSDictionary *kmap = [NSDictionary dictionaryWithDictionary:[ResourceManager dictionaryFromFilesNamed:@"keymappings_linux.plist" inFolder:@"Config" mergeMode:MERGE_BASIC cache:NO]];
525#endif
526 // get the stored keyboard code from preferences
527 NSString *kbd = [prefs oo_stringForKey:@"keyboard-code" defaultValue:@"default"];
528 NSDictionary *subset = [kmap objectForKey:kbd];
529
530 [keyMappings_normal release];
531 keyMappings_normal = [[subset objectForKey:@"mapping_normal"] copy];
532 [keyMappings_shifted release];
533 keyMappings_shifted = [[subset objectForKey:@"mapping_shifted"] copy];
534}
NSDictionary * dictionaryFromFilesNamed:inFolder:mergeMode:cache:(NSString *fileName,[inFolder] NSString *folderName,[mergeMode] OOResourceMergeMode mergeMode,[cache] BOOL useCache)

References ResourceManager::dictionaryFromFilesNamed:inFolder:mergeMode:cache:, initKeyMappingData, keyMappings_normal, and keyMappings_shifted.

Referenced by init, initKeyMappingData, and initWithFrame:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initKeyMappingData [2/2]

- (void) initKeyMappingData

References initKeyMappingData.

Here is the call graph for this function:

◆ initSplashScreen

- (void) initSplashScreen

Definition at line 808 of file MyOpenGLView.m.

809{
810 if (!showSplashScreen) return;
811
812 //too early for OOTexture!
813 SDL_Surface *image=NULL;
814 SDL_Rect dest;
815
816 NSString *imagesDir = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Images"];
817
818 image = SDL_LoadBMP([[imagesDir stringByAppendingPathComponent:@"splash.bmp"] UTF8String]);
819
820 if (image == NULL)
821 {
822 SDL_FreeSurface(image);
823 OOLogWARN(@"sdl.gameStart", @"%@", @"image 'splash.bmp' not found!");
824 [self endSplashScreen];
825 return;
826 }
827
828 dest.x = 0;
829 dest.y = 0;
830 dest.w = image->w;
831 dest.h = image->h;
832
833 #if OOLITE_WINDOWS
834
835 dest.x = (GetSystemMetrics(SM_CXSCREEN)- dest.w)/2;
836 dest.y = (GetSystemMetrics(SM_CYSCREEN)-dest.h)/2;
837 SetWindowLong(SDL_Window,GWL_STYLE,GetWindowLong(SDL_Window,GWL_STYLE) & ~WS_CAPTION & ~WS_THICKFRAME);
838 ShowWindow(SDL_Window,SW_RESTORE);
839 MoveWindow(SDL_Window,dest.x,dest.y,dest.w,dest.h,TRUE);
840
841 #else
842
843 /* MKW 2011.11.11
844 * According to Marc using the NOFRAME flag causes trouble under Ubuntu 8.04.
845 *
846 * The current Ubuntu LTS is 10.04, which doesn't seem to have that problem.
847 * 12.04 LTS is going to be released soon, also without apparent problems.
848 * Changed to SDL_NOFRAME, throwing caution to the wind - Kaks 2012.03.23
849 * Took SDL_NOFRAME out, since it still causes strange problems here - cim 2012.04.09
850 */
851 surface = SDL_SetVideoMode(dest.w, dest.h, 32, SDL_HWSURFACE | SDL_OPENGL);
852
853 #endif
854
856
857 glViewport( 0, 0, dest.w, dest.h);
858
859 glEnable( GL_TEXTURE_2D );
860 glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
861 glClear( GL_COLOR_BUFFER_BIT );
862
863 [matrixManager resetProjection];
864 [matrixManager orthoLeft: 0.0f right: dest.w bottom: dest.h top: 0.0 near: -1.0 far: 1.0];
865 [matrixManager syncProjection];
866
867 [matrixManager resetModelView];
868 [matrixManager syncModelView];
869
870 GLuint texture;
871 GLenum texture_format;
872 GLint nOfColors;
873
874 // get the number of channels in the SDL image
875 nOfColors = image->format->BytesPerPixel;
876 if (nOfColors == 4) // contains an alpha channel
877 {
878 if (image->format->Rmask == 0x000000ff)
879 texture_format = GL_RGBA;
880 else
881 texture_format = GL_BGRA;
882 }
883 else if (nOfColors == 3) // no alpha channel
884 {
885 if (image->format->Rmask == 0x000000ff)
886 texture_format = GL_RGB;
887 else
888 texture_format = GL_BGR;
889 } else {
890 SDL_FreeSurface(image);
891 OOLog(@"Sdl.GameStart", @"%@", @"----- Encoding error within image 'splash.bmp'");
892 [self endSplashScreen];
893 return;
894 }
895
896 glGenTextures( 1, &texture );
897 glBindTexture( GL_TEXTURE_2D, texture );
898
899 // Set the texture's stretching properties
900 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
901 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
902
903 // Set the texture image data with the information from SDL_Surface
904 glTexImage2D( GL_TEXTURE_2D, 0, nOfColors, image->w, image->h, 0,
905 texture_format, GL_UNSIGNED_BYTE, image->pixels );
906
907 glBindTexture( GL_TEXTURE_2D, texture );
908 glBegin( GL_QUADS );
909
910 glTexCoord2i( 0, 0 );
911 glVertex2i( 0, 0 );
912 glTexCoord2i( 1, 0 );
913 glVertex2i( dest.w, 0 );
914 glTexCoord2i( 1, 1 );
915 glVertex2i( dest.w, dest.h );
916 glTexCoord2i( 0, 1 );
917 glVertex2i( 0, dest.h );
918
919 glEnd();
920
921 SDL_GL_SwapBuffers();
922 [matrixManager resetModelView];
923 [matrixManager syncModelView];
924
925 if ( image ) {
926 SDL_FreeSurface( image );
927 }
928 glDeleteTextures(1, &texture);
929
930 glDisable( GL_TEXTURE_2D );
932}
@ OPENGL_STATE_OVERLAY
Definition OOOpenGL.h:126
#define OOVerifyOpenGLState()
Definition OOOpenGL.h:136
#define OOSetOpenGLState(STATE)
Definition OOOpenGL.h:135

References endSplashScreen, initSplashScreen, OOLog, OOLogWARN, OOSetOpenGLState, OOVerifyOpenGLState, OPENGL_STATE_OVERLAY, OOOpenGLMatrixManager::orthoLeft:right:bottom:top:near:far:, OOOpenGLMatrixManager::resetModelView, OOOpenGLMatrixManager::resetProjection, showSplashScreen, surface, OOOpenGLMatrixManager::syncModelView, and OOOpenGLMatrixManager::syncProjection.

Referenced by GameController::beginSplashScreen, and initSplashScreen.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initWithFrame:

- (id) initWithFrame: (NSRect) frameRect
implementation

Definition at line 81 of file MyOpenGLView.m.

81 :(NSRect)frameRect
82{
83#ifndef NDEBUG
84 if (NSZombieEnabled)
85 {
86 OOLog(@"debug.zombieEnabled", @"*** ZOMBIES WILL EAT YOUR BRAIN ***");
87 }
88#endif
89
90 // Pixel Format Attributes for the View-based (non-FullScreen) NSOpenGLContext
91 NSOpenGLPixelFormatAttribute attrs[] =
92 {
93 // Specify that we want a windowed OpenGL context.
94 // Must be first or we'll hit an assert in the legacy fullscreen controller.
95 NSOpenGLPFAWindow,
96
97 // We may be on a multi-display system (and each screen may be driven by a different renderer), so we need to specify which screen we want to take over.
98 // For this demo, we'll specify the main screen.
99 NSOpenGLPFAScreenMask, CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay),
100
101 // Specifying "NoRecovery" gives us a context that cannot fall back to the software renderer.
102 // This makes the View-based context a compatible with the fullscreen context, enabling us to use the "shareContext"
103 // feature to share textures, display lists, and other OpenGL objects between the two.
104 NSOpenGLPFANoRecovery,
105
106 // Attributes Common to FullScreen and non-FullScreen
107 NSOpenGLPFACompliant,
108
109 NSOpenGLPFAColorSize, 32,
110 NSOpenGLPFADepthSize, 32,
111 NSOpenGLPFADoubleBuffer,
112 NSOpenGLPFAAccelerated,
113#if FSAA
114 // Need a preference or other sane way to activate this
115 NSOpenGLPFAMultisample,
116 NSOpenGLPFASampleBuffers, 1,
117 NSOpenGLPFASamples,4,
118#endif
119 0
120 };
121
122 // Create our non-FullScreen pixel format.
123 NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] autorelease];
124
125 if ((self = [super initWithFrame:frameRect pixelFormat:pixelFormat]))
126 {
127 if ([self respondsToSelector:@selector(setAcceptsTouchEvents:)])
128 {
129 [self setAcceptsTouchEvents:YES];
130 }
131
132 if ([self respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)])
133 {
134 // Enable high resolution on Retina displays.
135 [self setWantsBestResolutionOpenGLSurface:YES];
136 }
137
138 matrixManager = [[OOOpenGLMatrixManager alloc] init];
139 _pixelFormatAttributes = [[NSData alloc] initWithBytes:attrs length:sizeof attrs];
140 virtualJoystickPosition = NSMakePoint(0.0,0.0);
141
142 typedString = [[NSMutableString alloc] initWithString:@""];
145
146 timeIntervalAtLastClick = [NSDate timeIntervalSinceReferenceDate];
147
148 _virtualScreen = [[self openGLContext] currentVirtualScreen];
149 }
150
151 // preload the printscreen key into our translation array because SDLK_PRINTSCREEN isn't available
153 [self initKeyMappingData];
154
155 return self;
156}
@ gvPrintScreenKey
int scancode2Unicode[NUM_KEYS]
NSPoint virtualJoystickPosition
NSTimeInterval timeIntervalAtLastClick

References _pixelFormatAttributes, _virtualScreen, allowingStringInput, gvPrintScreenKey, gvStringInputNo, initKeyMappingData, isAlphabetKeyDown, matrixManager, OOLog, scancode2Unicode, timeIntervalAtLastClick, typedString, and virtualJoystickPosition.

Here is the call graph for this function:

◆ isAlphabetKeyDown [1/2]

- (BOOL) isAlphabetKeyDown

References clearCommandF, gammaValue, getOpenGLMatrixManager, int(), isAlphabetKeyDown, isCapsLockOn, isCommandDown, isCommandFDown, isCommandQDown, isCtrlDown, isOptDown, isShiftDown, lastKeyWasShifted, mouseWheelDelta, mouseWheelState, numKeys, pollShiftKey, and suppressKeysUntilKeyUp.

Here is the call graph for this function:

◆ isAlphabetKeyDown [2/2]

- (BOOL) isAlphabetKeyDown

References isAlphabetKeyDown.

◆ isCapsLockOn [1/2]

- (BOOL) isCapsLockOn

Definition at line 2051 of file MyOpenGLView.m.

2052{
2053 /* Caps Lock state check - This effectively gives us
2054 an alternate keyboard state to play with and, in
2055 the future, we could assign different behaviours
2056 to existing controls, depending on the state of
2057 Caps Lock. - Nikos 20160304
2058 */
2059 return (SDL_GetModState() & KMOD_CAPS) == KMOD_CAPS;
2060}

References isCapsLockOn.

Referenced by isAlphabetKeyDown, isCapsLockOn, pollControls, and PlayerEntity(OOControlsPrivate)::pollFlightArrowKeyControls:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isCapsLockOn [2/2]

- (BOOL) isCapsLockOn

References isCapsLockOn.

Here is the call graph for this function:

◆ isCommandDown [1/2]

- (BOOL) isCommandDown

Definition at line 2039 of file MyOpenGLView.m.

2040{
2041 return command;
2042}

References command, and isCommandDown.

Referenced by isAlphabetKeyDown, and isCommandDown.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isCommandDown [2/2]

- (BOOL) isCommandDown

References isCommandDown.

Here is the call graph for this function:

◆ isCommandFDown [1/2]

- (BOOL) isCommandFDown

Definition at line 2103 of file MyOpenGLView.m.

2104{
2105 return NO;
2106}

References isCommandFDown.

Referenced by isAlphabetKeyDown, and isCommandFDown.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isCommandFDown [2/2]

- (BOOL) isCommandFDown

References isCommandFDown.

Here is the call graph for this function:

◆ isCommandModifierKeyDown

- (BOOL) isCommandModifierKeyDown
implementation

Provided by category MyOpenGLView(OOLoadSaveExtensions).

Definition at line 1354 of file PlayerEntityLoadSave.m.

1355{
1356 return [self isCtrlDown];
1357}

◆ isCommandQDown [1/2]

- (BOOL) isCommandQDown

Definition at line 2097 of file MyOpenGLView.m.

2098{
2099 return NO;
2100}

References isCommandQDown.

Referenced by isAlphabetKeyDown, and isCommandQDown.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isCommandQDown [2/2]

- (BOOL) isCommandQDown

References isCommandQDown.

Here is the call graph for this function:

◆ isCtrlDown [1/2]

- (BOOL) isCtrlDown

Definition at line 2033 of file MyOpenGLView.m.

2034{
2035 return ctrl;
2036}

References ctrl, and isCtrlDown.

Referenced by isAlphabetKeyDown, MyOpenGLView(OOLoadSaveExtensions)::isCommandModifierKeyDown, isCtrlDown, PlayerEntity(OOControlsPrivate)::pollCustomViewControls, PlayerEntity(OOControlsPrivate)::pollFlightArrowKeyControls:, and PlayerEntity(OOControlsPrivate)::pollGuiArrowKeyControls:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isCtrlDown [2/2]

- (BOOL) isCtrlDown

References isCtrlDown.

Here is the call graph for this function:

◆ isDown: [1/2]

- (BOOL) isDown: (int) key

Definition at line 2015 of file MyOpenGLView.m.

2015 : (int) key
2016{
2017 if ( suppressKeys )
2018 return NO;
2019 if ( key < 0 )
2020 return NO;
2021 if ( key >= [self numKeys] )
2022 return NO;
2023 return keys[key];
2024}

References keys, numKeys, and suppressKeys.

Referenced by PlayerEntity(OOControlsPrivate)::handleGameOptionsScreenKeys, PlayerEntity(Controls)::handleGUIUpDownArrowKeys, PlayerEntity(KeyMapper)::handleKeyboardLayoutEntryKeys:view:, PlayerEntity(KeyMapper)::handleKeyConfigKeys:view:, PlayerEntity(KeyMapper)::handleKeyMapperConfirmClearKeys:view:, PlayerEntity(KeyMapper)::keyMapperInputHandler:view:, and PlayerEntity(OOControlsPrivate)::pollGuiArrowKeyControls:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isDown: [2/2]

- (BOOL) isDown: (int) key

◆ isOptDown [1/2]

- (BOOL) isOptDown

Definition at line 2027 of file MyOpenGLView.m.

2028{
2029 return opt;
2030}

References isOptDown, and opt.

Referenced by isAlphabetKeyDown, isOptDown, and PlayerEntity(OOControlsPrivate)::pollGuiArrowKeyControls:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isOptDown [2/2]

- (BOOL) isOptDown

References isOptDown.

Here is the call graph for this function:

◆ isOutputDisplayHDREnabled

- (BOOL) isOutputDisplayHDREnabled

Definition at line 1396 of file MyOpenGLView.m.

1397{
1398 return NO;
1399}

References isOutputDisplayHDREnabled.

Referenced by endSplashScreen, initialiseGLWithSize:, and isOutputDisplayHDREnabled.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isRunningOnPrimaryDisplayDevice

- (BOOL) isRunningOnPrimaryDisplayDevice

Definition at line 1360 of file MyOpenGLView.m.

1361{
1362 return YES;
1363}

References isRunningOnPrimaryDisplayDevice.

Referenced by initialiseGLWithSize:, initialiseGLWithSize:useVideoMode:, isRunningOnPrimaryDisplayDevice, and PlayerEntity::setGuiToGameOptionsScreen.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isShiftDown [1/2]

- (BOOL) isShiftDown

Definition at line 2045 of file MyOpenGLView.m.

2046{
2047 return shift;
2048}

References isShiftDown, and shift.

Referenced by isAlphabetKeyDown, isShiftDown, PlayerEntity(OOControlsPrivate)::pollCustomViewControls, and PlayerEntity(OOControlsPrivate)::pollGuiArrowKeyControls:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isShiftDown [2/2]

- (BOOL) isShiftDown

References isShiftDown.

Here is the call graph for this function:

◆ keyDown:

- (void) keyDown: (NSEvent *) theEvent
implementation

Definition at line 616 of file MyOpenGLView.m.

616 :(NSEvent *)theEvent
617{
618 NSString *stringValue = nil;
619 int key;
620 int keycode;
621
622 stringValue = [theEvent charactersIgnoringModifiers];
623
624 /* Bug: exception when pressing accent key.
625 Analysis: Dead keys (accents and similar) return an empty string.
626 Fix: reject zero-length strings. This is the Wrong Thing - we should
627 really be using KeyTranslate()/UCKeyTranslate() to find out what the
628 string would be if you pressed the key and then space.
629 -- Ahruman 20070714
630 */
631 //if ([stringValue length] < 1) return;
632
633 keycode = [theEvent keyCode] & 255;
634
635 if ([stringValue length] < 1)
636 {
637 if (!shift)
638 {
639 NSString *keyNormal = [keyMappings_normal objectForKey:[NSString stringWithFormat:@"%d", keycode]];
640 if (keyNormal) stringValue = [NSString stringWithFormat:@"%c", [keyNormal integerValue]];
641 }
642 else
643 {
644 NSString *keyShifted = [keyMappings_shifted objectForKey:[NSString stringWithFormat:@"%d", keycode]];
645 if (keyShifted) stringValue = [NSString stringWithFormat:@"%c", [keyShifted integerValue]];
646 }
647 // if we still have a zero-length string, return at this point
648 if ([stringValue length] < 1) return;
649 }
650
651 key = [stringValue characterAtIndex:0];
652 key = [self translateKeyCode:key];
653
654 OOLog(kOOLogKeyDown, @"Key down: stringValue = \"%@\", keyCode = %d, key = %u", stringValue, keycode, key);
655
656 // Special handling of command keys used in full-screen mode.
657 if ([theEvent modifierFlags] & NSCommandKeyMask)
658 {
659 switch (key)
660 {
661 case 'q':
662 commandQ = YES;
663 break;
664
665 case 'f':
666 commandF = YES;
667 break;
668 }
669
670 return;
671 }
672
673 keycodetrans[keycode] = key; // record the character we got for pressing the hardware at key location 'keycode'
674
675 /* HACK: treat f12 as alias to cmd-F for compatibility with helpful forum
676 advice etc.
677 */
678 if (key == NSF12FunctionKey)
679 {
680 if (!f12)
681 {
682 f12 = YES;
683 [gameController performSelector:@selector(toggleFullScreenAction:) withObject:nil afterDelay:0.0];
684 }
685
686 return;
687 };
688
689 if ((key >= 0)&&(key < [self numKeys])&&(!keys[key]))
690 {
691 keys[key] = YES;
692
694 {
695 if ((key == gvDeleteKey || key == gvBackspaceKey) && [typedString length] > 0)
696 {
697 // delete
698 [typedString deleteCharactersInRange:NSMakeRange([typedString length] - 1, 1)];
699 }
700
703
704 // limited input for planet find screen
706 {
707 if (isalpha(key))
708 {
709 isAlphabetKeyDown = YES;
710 // convert to lower case
711 [typedString appendFormat:@"%c", tolower(key)];
712 }
713 }
714
715 // full input for load-save screen or 'all' input
717 {
718 // except '/' for loadsave
719 if (isprint(key) && key != '/')
720 {
721 isAlphabetKeyDown = YES;
722 [typedString appendFormat:@"%c", key];
723 }
724 else if (key == '/' && allowingStringInput == gvStringInputAll)
725 {
726 isAlphabetKeyDown = YES;
727 [typedString appendFormat:@"%c", key];
728 }
729 }
730
731 }
732 }
733 else
734 {
735 if (key > [self numKeys])
736 {
737 OOLog(kOOLogKeyCodeOutOfRange, @"Translated key: %d out of range", key);
738 }
739 }
740}
static NSString * kOOLogKeyCodeOutOfRange
static NSString * kOOLogKeyDown
@ gvBackspaceKey
@ gvDeleteKey
@ gvStringInputLoadSave
int keycodetrans[255]

References allowingStringInput, commandF, commandQ, f12, gvBackspaceKey, gvDeleteKey, gvStringInputAll, gvStringInputAlpha, gvStringInputLoadSave, isAlphabetKeyDown, keycodetrans, keys, kOOLogKeyCodeOutOfRange, kOOLogKeyDown, lastKeyShifted, nil, numKeys, OOLog, shift, translateKeyCode:, and typedString.

Referenced by OoliteApp::sendEvent:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ keyUp:

- (void) keyUp: (NSEvent *) theEvent
implementation

Definition at line 553 of file MyOpenGLView.m.

553 :(NSEvent *)theEvent
554{
555 NSString *stringValue = nil;
556 int key;
557 int keycode;
558
559 stringValue = [theEvent charactersIgnoringModifiers];
560
561 /* Bug: exception when releasing accent key.
562 Analysis: Dead keys (accents and similar) return an empty string.
563 Fix: reject zero-length strings. This is the Wrong Thing - we should
564 really be using KeyTranslate()/UCKeyTranslate() to find out what the
565 string would be if you pressed the key and then space.
566 -- Ahruman 20070714
567 */
568 if ([stringValue length] < 1) return;
569
570 suppressKeys = NO;
571
572 keycode = [theEvent keyCode] & 255;
573 key = keycodetrans[keycode]; // retrieve the character we got for pressing the hardware at key location 'keycode'
574
575 OOLog(kOOLogKeyUp, @"Key up: stringValue = \"%@\", keyCode = %d, key = %u", stringValue, keycode, key);
576
577 // Special handling of command keys used in full-screen mode.
578 if ([theEvent modifierFlags] & NSCommandKeyMask)
579 {
580 switch (key)
581 {
582 case 'q':
583 commandQ = NO;
584 break;
585
586 case 'f':
587 commandF = NO;
588 break;
589 }
590 // Pass through to allow clearing of normal key as well.
591 }
592
593 /* HACK: treat f12 as alias to cmd-F for compatibility with helpful forum
594 advice etc.
595 */
596 if (key == NSF12FunctionKey)
597 {
598 commandF = NO;
599 f12 = NO;
600 return;
601 };
602
604 if ((key >= 0)&&(key < [self numKeys])&&(keys[key]))
605 {
606 keys[key] = NO;
607 }
608 else
609 {
610 if (key > [self numKeys])
611 OOLog(kOOLogKeyCodeOutOfRange, @"Translated key: %d out of range", key);
612 }
613}
static NSString * kOOLogKeyUp

References commandF, commandQ, f12, isAlphabetKeyDown, keycodetrans, keys, kOOLogKeyCodeOutOfRange, kOOLogKeyUp, nil, numKeys, OOLog, and suppressKeys.

Referenced by OoliteApp::sendEvent:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lastKeyWasShifted [1/2]

- (BOOL) lastKeyWasShifted

Definition at line 2063 of file MyOpenGLView.m.

2064{
2065 return lastKeyShifted;
2066}

References lastKeyShifted, and lastKeyWasShifted.

Referenced by isAlphabetKeyDown, and lastKeyWasShifted.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lastKeyWasShifted [2/2]

- (BOOL) lastKeyWasShifted

References lastKeyWasShifted.

Here is the call graph for this function:

◆ loadFullscreenSettings

- (int) loadFullscreenSettings

Definition at line 2857 of file MyOpenGLView.m.

2858{
2859 currentSize=0;
2860 int width=0, height=0, refresh=0;
2861 unsigned i;
2862
2863 NSArray* cmdline_arguments = [[NSProcessInfo processInfo] arguments];
2864
2865 NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
2866 if ([userDefaults objectForKey:@"display_width"])
2867 width = [userDefaults integerForKey:@"display_width"];
2868 if ([userDefaults objectForKey:@"display_height"])
2869 height = [userDefaults integerForKey:@"display_height"];
2870 if ([userDefaults objectForKey:@"display_refresh"])
2871 refresh = [userDefaults integerForKey:@"display_refresh"];
2872 if([userDefaults objectForKey:@"fullscreen"])
2873 fullScreen=[userDefaults boolForKey:@"fullscreen"];
2874
2875 // Check if -fullscreen or -windowed has been passed on the command line. If yes,
2876 // set it regardless of what is set by .GNUstepDefaults. If both are found in the
2877 // arguments list, the one that comes last wins.
2878 for (i = 0; i < [cmdline_arguments count]; i++)
2879 {
2880 if ([[cmdline_arguments objectAtIndex:i] isEqual:@"-fullscreen"]) fullScreen = YES;
2881 if ([[cmdline_arguments objectAtIndex:i] isEqual:@"-windowed"]) fullScreen = NO;
2882 }
2883
2884 if(width && height)
2885 {
2886 currentSize=[self findDisplayModeForWidth: width Height: height Refresh: refresh];
2887 return currentSize;
2888 }
2889 return currentSize;
2890}

References currentSize, findDisplayModeForWidth:Height:Refresh:, fullScreen, int(), and loadFullscreenSettings.

Referenced by init, loadFullscreenSettings, and modeAsSize:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadWindowSize

- (NSSize) loadWindowSize

Definition at line 2839 of file MyOpenGLView.m.

2840{
2841 NSSize windowSize;
2842 NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
2843 if([defaults objectForKey:@"window_width"] && [defaults objectForKey:@"window_height"])
2844 {
2845 windowSize=NSMakeSize([defaults integerForKey: @"window_width"],
2846 [defaults integerForKey: @"window_height"]);
2847 }
2848 else
2849 {
2851 }
2852 currentWindowSize=windowSize;
2853 return windowSize;
2854}

References currentWindowSize, loadWindowSize, WINDOW_SIZE_DEFAULT_HEIGHT, and WINDOW_SIZE_DEFAULT_WIDTH.

Referenced by init, loadWindowSize, and modeAsSize:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ modeAsSize:

- (NSSize) modeAsSize: (int) sizeIndex

References currentScreenSize, int(), loadFullscreenSettings, and loadWindowSize.

Here is the call graph for this function:

◆ mouseDown:

- (void) mouseDown: (NSEvent *) theEvent

Definition at line 757 of file MyOpenGLView.m.

757 :(NSEvent *)theEvent
758{
759 if (doubleClick)
760 {
761 doubleClick = NO;
762 keys[gvMouseDoubleClick] = NO;
763 }
764 keys[gvMouseLeftButton] = YES; // 'a' down
765}

References doubleClick, and keys.

◆ mouseDragged:

- (void) mouseDragged: (NSEvent *) theEvent
implementation

Definition at line 811 of file MyOpenGLView.m.

811 :(NSEvent *)theEvent
812{
813 [self mouseMoved:theEvent];
814}

References mouseMoved:.

Here is the call graph for this function:

◆ mouseMoved:

- (void) mouseMoved: (NSEvent *) theEvent
implementation

Definition at line 791 of file MyOpenGLView.m.

791 :(NSEvent *)theEvent
792{
793 double mx = [theEvent locationInWindow].x - viewSize.width/2.0;
794 double my = [theEvent locationInWindow].y - viewSize.height/2.0;
795
796 if (display_z > 640.0)
797 {
799 my /= viewSize.height;
800 }
801 else
802 {
803 mx /= MAIN_GUI_PIXEL_WIDTH * viewSize.width / 640.0;
804 my /= MAIN_GUI_PIXEL_HEIGHT * viewSize.width / 640.0;
805 }
806
807 [self setVirtualJoystick:mx :-my];
808}
#define MAIN_GUI_PIXEL_WIDTH
#define MAIN_GUI_PIXEL_HEIGHT

References display_z, MAIN_GUI_PIXEL_HEIGHT, MAIN_GUI_PIXEL_WIDTH, and viewSize.

Referenced by mouseDragged:, and otherMouseDragged:.

Here is the caller graph for this function:

◆ mouseUp:

- (void) mouseUp: (NSEvent *) theEvent

Definition at line 768 of file MyOpenGLView.m.

768 :(NSEvent *)theEvent
769{
770 NSTimeInterval timeBetweenClicks = [NSDate timeIntervalSinceReferenceDate] - timeIntervalAtLastClick;
771 timeIntervalAtLastClick += timeBetweenClicks;
772
773 if (!doubleClick)
774 {
775 doubleClick = (timeBetweenClicks < MOUSE_DOUBLE_CLICK_INTERVAL); // One fifth of a second
776 keys[gvMouseDoubleClick] = doubleClick;
777 }
778
779 keys[gvMouseLeftButton] = NO; // 'a' up
780}
#define MOUSE_DOUBLE_CLICK_INTERVAL

References doubleClick, keys, MOUSE_DOUBLE_CLICK_INTERVAL, and timeIntervalAtLastClick.

◆ mouseWheelDelta [1/2]

- (float) mouseWheelDelta

Definition at line 2085 of file MyOpenGLView.m.

2086{
2088}
#define OOMOUSEWHEEL_DELTA
float _mouseWheelDelta

References _mouseWheelDelta, mouseWheelDelta, and OOMOUSEWHEEL_DELTA.

Referenced by PlayerEntity::doBookkeeping:, isAlphabetKeyDown, and mouseWheelDelta.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouseWheelDelta [2/2]

- (float) mouseWheelDelta

References mouseWheelDelta.

Here is the call graph for this function:

◆ mouseWheelState [1/2]

- (int) mouseWheelState

Definition at line 2074 of file MyOpenGLView.m.

2075{
2076 if (_mouseWheelDelta > 0.0f)
2077 return gvMouseWheelUp;
2078 else if (_mouseWheelDelta < 0.0f)
2079 return gvMouseWheelDown;
2080 else
2081 return gvMouseWheelNeutral;
2082}
@ gvMouseWheelDown
@ gvMouseWheelNeutral
@ gvMouseWheelUp

References _mouseWheelDelta, gvMouseWheelDown, gvMouseWheelNeutral, gvMouseWheelUp, int(), and mouseWheelState.

Referenced by isAlphabetKeyDown, and mouseWheelState.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mouseWheelState [2/2]

- (int) mouseWheelState

References int(), and mouseWheelState.

Here is the call graph for this function:

◆ msaa

- (BOOL) msaa

Definition at line 2970 of file MyOpenGLView.m.

2971{
2972 return _msaa;
2973}

References _msaa, and msaa.

Referenced by fov:, and msaa.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ noteMouseInteractionModeChangedFrom:to: [1/2]

- (void) noteMouseInteractionModeChangedFrom: (OOMouseInteractionMode) oldMode
to: (OOMouseInteractionMode) newMode 

Definition at line 668 of file MyOpenGLView.m.

669{
670 [self autoShowMouse];
671 [self setMouseInDeltaMode:OOMouseInteractionModeIsFlightMode(newMode)];
672}
OOMouseInteractionMode

References autoShowMouse, and setMouseInDeltaMode:.

Referenced by GameController::setMouseInteractionMode:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ noteMouseInteractionModeChangedFrom:to: [2/2]

- (void) noteMouseInteractionModeChangedFrom: (OOMouseInteractionMode) oldMode
to: (OOMouseInteractionMode) newMode 

◆ noteMovedToBadDisplay

- (void) noteMovedToBadDisplay
implementation

Definition at line 316 of file MyOpenGLView.m.

317{
318 NSRunInformationalAlertPanel(DESC(@"oolite-mac-bad-display"), @"%@", nil, nil, nil, DESC(@"oolite-mac-bad-display-2"));
319}
#define DESC(key)
Definition Universe.h:846

References DESC, nil, and noteMovedToBadDisplay.

Referenced by noteMovedToBadDisplay, and update.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ numKeys [1/2]

- (int) numKeys

Definition at line 2068 of file MyOpenGLView.m.

2069{
2070 return NUM_KEYS;
2071}
#define NUM_KEYS

References int(), NUM_KEYS, and numKeys.

Referenced by clearKey:, clearKeys, isAlphabetKeyDown, isDown:, keyDown:, keyUp:, numKeys, and pollControls.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ numKeys [2/2]

- (int) numKeys

References int(), and numKeys.

Here is the call graph for this function:

◆ otherMouseDragged:

- (void) otherMouseDragged: (NSEvent *) theEvent
implementation

Definition at line 840 of file MyOpenGLView.m.

840 :(NSEvent *)theEvent
841{
842 [self mouseMoved:theEvent];
843}

References mouseMoved:.

Here is the call graph for this function:

◆ pixelFormatAttributes

- (NSData *) pixelFormatAttributes

Definition at line 389 of file MyOpenGLView.m.

390{
392}

References _pixelFormatAttributes, and pixelFormatAttributes.

Referenced by gameController, and pixelFormatAttributes.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pngSaveSurface:withSurface:

- (BOOL) pngSaveSurface: (NSString *) fileName
withSurface: (SDL_Surface *) surf 

Definition at line 1787 of file MyOpenGLView.m.

1787 :(NSString *)fileName withSurface:(SDL_Surface *)surf
1788{
1789 FILE *fp;
1790 png_structp pngPtr;
1791 png_infop infoPtr;
1792 int i, colorType;
1793 png_bytep *rowPointers;
1794
1795 fp = fopen([fileName UTF8String], "wb");
1796 if (fp == NULL)
1797 {
1798 OOLog(@"pngSaveSurface.fileCreate.failed", @"Failed to create output screenshot file %@", fileName);
1799 return NO;
1800 }
1801
1802 // initialize png structures (no callbacks)
1803 pngPtr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1804 if (pngPtr == NULL)
1805 {
1806 return NO;
1807 }
1808
1809 infoPtr = png_create_info_struct(pngPtr);
1810 if (infoPtr == NULL) {
1811 png_destroy_write_struct(&pngPtr, (png_infopp)NULL);
1812 OOLog(@"pngSaveSurface.info_struct.failed", @"%@", @"png_create_info_struct error");
1813 exit(-1);
1814 }
1815
1816 if (setjmp(png_jmpbuf(pngPtr)))
1817 {
1818 png_destroy_write_struct(&pngPtr, &infoPtr);
1819 fclose(fp);
1820 exit(-1);
1821 }
1822
1823 png_init_io(pngPtr, fp);
1824
1825 colorType = PNG_COLOR_MASK_COLOR; /* grayscale not supported */
1826 if (surf->format->palette)
1827 {
1828 colorType |= PNG_COLOR_MASK_PALETTE;
1829 }
1830 else if (surf->format->Amask)
1831 {
1832 colorType |= PNG_COLOR_MASK_ALPHA;
1833 }
1834
1835 png_set_IHDR(pngPtr, infoPtr, surf->w, surf->h, 8, colorType, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
1836
1837 // if we are outputting HDR, our backbuffer is linear, so gamma is 1.0. Make sure our png has this info
1838 // note: some image viewers seem to ignore the gAMA chunk; still, this is better than not having it at all
1839 if ([self hdrOutput]) png_set_gAMA(pngPtr, infoPtr, 1.0f);
1840
1841 // write the image
1842 png_write_info(pngPtr, infoPtr);
1843 png_set_packing(pngPtr);
1844
1845 rowPointers = (png_bytep*) malloc(sizeof(png_bytep)*surf->h);
1846 for (i = 0; i < surf->h; i++)
1847 {
1848 rowPointers[i] = (png_bytep)(Uint8 *)surf->pixels + i*surf->pitch;
1849 }
1850 png_write_image(pngPtr, rowPointers);
1851 png_write_end(pngPtr, infoPtr);
1852
1853 free(rowPointers);
1854 png_destroy_write_struct(&pngPtr, &infoPtr);
1855 fclose(fp);
1856
1857 return YES;
1858}

References hdrOutput, and OOLog.

Here is the call graph for this function:

◆ pollControls [1/2]

- (void) pollControls

Definition at line 2115 of file MyOpenGLView.m.

2116{
2117 SDL_Event event;
2118 SDL_KeyboardEvent *kbd_event;
2119 SDL_MouseButtonEvent *mbtn_event;
2120 SDL_MouseMotionEvent *mmove_event;
2121 int mxdelta, mydelta;
2122 float mouseVirtualStickSensitivityX = viewSize.width * _mouseVirtualStickSensitivityFactor;
2123 float mouseVirtualStickSensitivityY = viewSize.height * _mouseVirtualStickSensitivityFactor;
2124 NSTimeInterval timeNow = [NSDate timeIntervalSinceReferenceDate];
2125 Uint16 key_id;
2126 int scan_code;
2127
2128 while (SDL_PollEvent(&event))
2129 {
2130 switch (event.type) {
2131 case SDL_JOYAXISMOTION:
2132 case SDL_JOYBUTTONUP:
2133 case SDL_JOYBUTTONDOWN:
2134 case SDL_JOYHATMOTION:
2136 break;
2137
2138 case SDL_MOUSEBUTTONDOWN:
2139 mbtn_event = (SDL_MouseButtonEvent*)&event;
2140#if OOLITE_LINUX
2141 short inDelta = 0;
2142#else
2143 // specially built SDL.dll is required for this
2144 short inDelta = mbtn_event->wheelDelta;
2145#endif
2146 switch(mbtn_event->button)
2147 {
2148 case SDL_BUTTON_LEFT:
2149 keys[gvMouseLeftButton] = YES;
2150 break;
2151 case SDL_BUTTON_RIGHT:
2152 // Cocoa version does this in the GameController
2153 /*
2154 The mouseWarped variable is quite important as far as mouse control is concerned. When we
2155 reset the virtual joystick (mouse) coordinates, we need to send a WarpMouse call because we
2156 must recenter the pointer physically on screen. This goes together with a mouse motion event,
2157 so we use mouseWarped to simply ignore handling of motion events in this case. - Nikos 20110721
2158 */
2159 [self resetMouse]; // Will set mouseWarped to YES
2160 break;
2161 // mousewheel stuff
2162#if OOLITE_LINUX
2163 case SDL_BUTTON_WHEELUP:
2164 inDelta = OOMOUSEWHEEL_DELTA;
2165 // allow fallthrough
2166 case SDL_BUTTON_WHEELDOWN:
2167 if (inDelta == 0) inDelta = -OOMOUSEWHEEL_DELTA;
2168#else
2169 case SDL_BUTTON_WHEELUP:
2170 case SDL_BUTTON_WHEELDOWN:
2171#endif
2172 if (inDelta > 0)
2173 {
2174 if (_mouseWheelDelta >= 0.0f)
2175 _mouseWheelDelta += inDelta;
2176 else
2177 _mouseWheelDelta = 0.0f;
2178 }
2179 else if (inDelta < 0)
2180 {
2181 if (_mouseWheelDelta <= 0.0f)
2182 _mouseWheelDelta += inDelta;
2183 else
2184 _mouseWheelDelta = 0.0f;
2185 }
2186 break;
2187 }
2188 break;
2189
2190 case SDL_MOUSEBUTTONUP:
2191 mbtn_event = (SDL_MouseButtonEvent*)&event;
2192 NSTimeInterval timeBetweenClicks = timeNow - timeIntervalAtLastClick;
2193 timeIntervalAtLastClick += timeBetweenClicks;
2194 if (mbtn_event->button == SDL_BUTTON_LEFT)
2195 {
2196 if (!doubleClick)
2197 {
2198 doubleClick = (timeBetweenClicks < MOUSE_DOUBLE_CLICK_INTERVAL); // One fifth of a second
2199 keys[gvMouseDoubleClick] = doubleClick;
2200 }
2201 keys[gvMouseLeftButton] = NO;
2202 }
2203 /*
2204 Mousewheel handling - just note time since last use here and mark as inactive,
2205 if needed, at the end of this method. Note that the mousewheel button up event is
2206 kind of special, as in, it is sent at the same time as its corresponding mousewheel
2207 button down one - Nikos 20140809
2208 */
2209 if (mbtn_event->button == SDL_BUTTON_WHEELUP || mbtn_event->button == SDL_BUTTON_WHEELDOWN)
2210 {
2211 NSTimeInterval timeBetweenMouseWheels = timeNow - timeSinceLastMouseWheel;
2212 timeSinceLastMouseWheel += timeBetweenMouseWheels;
2213 }
2214 break;
2215
2216 case SDL_MOUSEMOTION:
2217 {
2218 // Delta mode is set when the game is in 'flight' mode.
2219 // In this mode, the mouse movement delta is used rather
2220 // than absolute position. This is because if the user
2221 // clicks the right button to recentre the virtual joystick,
2222 // if we are using absolute joystick positioning, as soon
2223 // as the player touches the mouse again, the virtual joystick
2224 // will snap back to the absolute position (which can be
2225 // annoyingly fatal in battle).
2227 {
2228 // note: virtual stick sensitivity is configurable
2229 SDL_GetRelativeMouseState(&mxdelta, &mydelta);
2230 double mxd=(double)mxdelta / mouseVirtualStickSensitivityX;
2231 double myd=(double)mydelta / mouseVirtualStickSensitivityY;
2232
2233 if (!mouseWarped) // Standard event, update coordinates
2234 {
2235 virtualJoystickPosition.x += mxd;
2236 virtualJoystickPosition.y += myd;
2237
2238 // if we excceed the limits, revert changes
2240 {
2241 virtualJoystickPosition.x -= mxd;
2242 }
2244 {
2245 virtualJoystickPosition.y -= myd;
2246 }
2247 }
2248 else
2249 {
2250 // Motion event generated by WarpMouse is ignored and
2251 // we reset mouseWarped for the next time.
2252 mouseWarped = NO;
2253 }
2254 }
2255 else
2256 {
2257 // Windowed mode. Use the absolute position so the
2258 // Oolite mouse pointer appears under the X Window System
2259 // mouse pointer.
2260 mmove_event = (SDL_MouseMotionEvent*)&event;
2261
2262 int w=bounds.size.width;
2263 int h=bounds.size.height;
2264
2265 if (!mouseWarped) // standard event, handle it
2266 {
2267 double mx = mmove_event->x - w/2.0;
2268 double my = mmove_event->y - h/2.0;
2269 if (display_z > 640.0)
2270 {
2271 mx /= w * MAIN_GUI_PIXEL_WIDTH / display_z;
2272 my /= h;
2273 }
2274 else
2275 {
2276 mx /= MAIN_GUI_PIXEL_WIDTH * w / 640.0;
2277 my /= MAIN_GUI_PIXEL_HEIGHT * w / 640.0;
2278 }
2279
2280 [self setVirtualJoystick:mx :my];
2281 }
2282 else
2283 {
2284 // event coming from WarpMouse ignored, get ready for the next
2285 mouseWarped = NO;
2286 }
2287 }
2288 break;
2289 }
2290 case SDL_KEYDOWN:
2291 kbd_event = (SDL_KeyboardEvent*)&event;
2292 key_id = (Uint16)kbd_event->keysym.unicode;
2293 scan_code = kbd_event->keysym.scancode;
2294
2295 //char *keychar = SDL_GetKeyName(kbd_event->keysym.sym);
2296 // deal with modifiers first
2297 BOOL modifier_pressed = NO;
2298 BOOL special_key = NO;
2299
2300 // translate scancode to unicode equiv
2301 switch (kbd_event->keysym.sym)
2302 {
2303 case SDLK_LSHIFT:
2304 case SDLK_RSHIFT:
2305 shift = YES;
2306 modifier_pressed = YES;
2307 break;
2308
2309 case SDLK_LCTRL:
2310 case SDLK_RCTRL:
2311 ctrl = YES;
2312 modifier_pressed = YES;
2313 break;
2314
2315 case SDLK_LALT:
2316 case SDLK_RALT:
2317 opt = YES;
2318 modifier_pressed = YES;
2319 break;
2320
2321 case SDLK_KP0: key_id = (!allowingStringInput ? gvNumberPadKey0 : gvNumberKey0); special_key = YES; break;
2322 case SDLK_KP1: key_id = (!allowingStringInput ? gvNumberPadKey1 : gvNumberKey1); special_key = YES; break;
2323 case SDLK_KP2: key_id = (!allowingStringInput ? gvNumberPadKey2 : gvNumberKey2); special_key = YES; break;
2324 case SDLK_KP3: key_id = (!allowingStringInput ? gvNumberPadKey3 : gvNumberKey3); special_key = YES; break;
2325 case SDLK_KP4: key_id = (!allowingStringInput ? gvNumberPadKey4 : gvNumberKey4); special_key = YES; break;
2326 case SDLK_KP5: key_id = (!allowingStringInput ? gvNumberPadKey5 : gvNumberKey5); special_key = YES; break;
2327 case SDLK_KP6: key_id = (!allowingStringInput ? gvNumberPadKey6 : gvNumberKey6); special_key = YES; break;
2328 case SDLK_KP7: key_id = (!allowingStringInput ? gvNumberPadKey7 : gvNumberKey7); special_key = YES; break;
2329 case SDLK_KP8: key_id = (!allowingStringInput ? gvNumberPadKey8 : gvNumberKey8); special_key = YES; break;
2330 case SDLK_KP9: key_id = (!allowingStringInput ? gvNumberPadKey9 : gvNumberKey9); special_key = YES; break;
2331 case SDLK_KP_PERIOD: key_id = (!allowingStringInput ? gvNumberPadKeyPeriod : 46); special_key = YES; break;
2332 case SDLK_KP_DIVIDE: key_id = (!allowingStringInput ? gvNumberPadKeyDivide : 47); special_key = YES; break;
2333 case SDLK_KP_MULTIPLY: key_id = (!allowingStringInput ? gvNumberPadKeyMultiply : 42); special_key = YES; break;
2334 case SDLK_KP_MINUS: key_id = (!allowingStringInput ? gvNumberPadKeyMinus : 45); special_key = YES; break;
2335 case SDLK_KP_PLUS: key_id = (!allowingStringInput ? gvNumberPadKeyPlus : 43); special_key = YES; break;
2336 case SDLK_KP_EQUALS: key_id = (!allowingStringInput ? gvNumberPadKeyEquals : 61); special_key = YES; break;
2337 case SDLK_KP_ENTER: key_id = gvNumberPadKeyEnter; special_key = YES; break;
2338 case SDLK_HOME: key_id = gvHomeKey; special_key = YES; break;
2339 case SDLK_END: key_id = gvEndKey; special_key = YES; break;
2340 case SDLK_INSERT: key_id = gvInsertKey; special_key = YES; break;
2341 case SDLK_PAGEUP: key_id = gvPageUpKey; special_key = YES; break;
2342 case SDLK_PAGEDOWN: key_id = gvPageDownKey; special_key = YES; break;
2343 case SDLK_SPACE: key_id = 32; special_key = YES; break;
2344 case SDLK_RETURN: key_id = 13; special_key = YES; break;
2345 case SDLK_TAB: key_id = 9; special_key = YES; break;
2346 case SDLK_UP: key_id = gvArrowKeyUp; special_key = YES; break;
2347 case SDLK_DOWN: key_id = gvArrowKeyDown; special_key = YES; break;
2348 case SDLK_LEFT: key_id = gvArrowKeyLeft; special_key = YES; break;
2349 case SDLK_RIGHT: key_id = gvArrowKeyRight; special_key = YES; break;
2350 case SDLK_PAUSE: key_id = gvPauseKey; special_key = YES; break;
2351 case SDLK_BACKSPACE: key_id = gvBackspaceKey; special_key = YES; break;
2352 case SDLK_DELETE: key_id = gvDeleteKey; special_key = YES; break;
2353 case SDLK_F1: key_id = gvFunctionKey1; special_key = YES; break;
2354 case SDLK_F2: key_id = gvFunctionKey2; special_key = YES; break;
2355 case SDLK_F3: key_id = gvFunctionKey3; special_key = YES; break;
2356 case SDLK_F4: key_id = gvFunctionKey4; special_key = YES; break;
2357 case SDLK_F5: key_id = gvFunctionKey5; special_key = YES; break;
2358 case SDLK_F6: key_id = gvFunctionKey6; special_key = YES; break;
2359 case SDLK_F7: key_id = gvFunctionKey7; special_key = YES; break;
2360 case SDLK_F8: key_id = gvFunctionKey8; special_key = YES; break;
2361 case SDLK_F9: key_id = gvFunctionKey9; special_key = YES; break;
2362 case SDLK_F10: key_id = gvFunctionKey10; special_key = YES; break;
2363 case SDLK_F11: key_id = gvFunctionKey11; special_key = YES; break;
2364 case SDLK_F12:
2365 key_id = 327;
2366 [self toggleScreenMode];
2367 special_key = YES;
2368 break;
2369
2370 case SDLK_ESCAPE:
2371 if (shift)
2372 {
2373 SDL_FreeSurface(surface);
2374 [gameController exitAppWithContext:@"Shift-escape pressed"];
2375 }
2376 else
2377 key_id = 27;
2378 special_key = YES;
2379 break;
2380 default:
2381 //OOLog(@"keys.test", @"Unhandled Keydown scancode with unicode = 0: %d", scan_code);
2382 ;
2383 }
2384
2385 // the keyup event doesn't give us the unicode value, so store it here so it can be retrieved on keyup
2386 // the ctrl key tends to mix up the unicode values, so deal with some special cases
2387 // we also need (in most cases) to get the character without the impact of caps lock.
2388 if (((!special_key && (ctrl || key_id == 0)) || ([self isCapsLockOn] && (!special_key && !allowingStringInput))) && !modifier_pressed) //
2389 {
2390 // ctrl changes alpha characters to control codes (1-26)
2391 if (ctrl && key_id >=1 && key_id <= 26)
2392 {
2393 if (shift)
2394 key_id += 64; // A-Z is from 65, offset by -1 for the scancode start point
2395 else
2396 key_id += 96; // a-z is from 97, offset by -1 for the scancode start point
2397 }
2398 else
2399 {
2400 key_id = 0; // reset the value here to force a lookup from the keymappings data
2401 }
2402 }
2403
2404 // if we get here and we still don't have a key id, grab the unicode value from our keymappings dict
2405 if (key_id == 0)
2406 {
2407 // get unicode value for keycode from keymappings files
2408 // this handles all the non-functional keys. the function keys are handled in the switch above
2409 if (!shift)
2410 {
2411 NSString *keyNormal = [keyMappings_normal objectForKey:[NSString stringWithFormat:@"%d", scan_code]];
2412 if (keyNormal) key_id = [keyNormal integerValue];
2413 }
2414 else
2415 {
2416 NSString *keyShifted = [keyMappings_shifted objectForKey:[NSString stringWithFormat:@"%d", scan_code]];
2417 if (keyShifted) key_id = [keyShifted integerValue];
2418 }
2419 }
2420
2421 // if we've got the unicode value, we can store it in our array now
2422 if (key_id > 0) scancode2Unicode[scan_code] = key_id;
2423
2425 {
2426 [self handleStringInput:kbd_event keyID:key_id];
2427 }
2428
2429 OOLog(kOOLogKeyDown, @"Keydown scancode = %d, unicode = %i, sym = %i, character = %c, shift = %d, ctrl = %d, alt = %d", scan_code, key_id, kbd_event->keysym.sym, key_id, shift, ctrl, opt);
2430 //OOLog(kOOLogKeyDown, @"Keydown scancode = %d, unicode = %i", kbd_event->keysym.scancode, key_id);
2431
2432 if (key_id > 0 && key_id <= [self numKeys])
2433 {
2434 keys[key_id] = YES;
2435 }
2436 else
2437 {
2438 //OOLog(@"keys.test", @"Unhandled Keydown scancode/unicode: %d %i", scan_code, key_id);
2439 }
2440 break;
2441
2442 case SDL_KEYUP:
2443 suppressKeys = NO; // DJS
2444 kbd_event = (SDL_KeyboardEvent*)&event;
2445 scan_code = kbd_event->keysym.scancode;
2446
2447 // all the work should have been down on the keydown event, so all we need to do is get the unicode value from the array
2448 key_id = scancode2Unicode[scan_code];
2449
2450 // deal with modifiers first
2451 switch (kbd_event->keysym.sym)
2452 {
2453 case SDLK_LSHIFT:
2454 case SDLK_RSHIFT:
2455 shift = NO;
2456 break;
2457
2458 case SDLK_LCTRL:
2459 case SDLK_RCTRL:
2460 ctrl = NO;
2461 break;
2462
2463 case SDLK_LALT:
2464 case SDLK_RALT:
2465 opt = NO;
2466 break;
2467 default:
2468 ;
2469 }
2470 OOLog(kOOLogKeyUp, @"Keyup scancode = %d, unicode = %i, sym = %i, character = %c, shift = %d, ctrl = %d, alt = %d", scan_code, key_id, kbd_event->keysym.sym, key_id, shift, ctrl, opt);
2471 //OOLog(kOOLogKeyUp, @"Keyup scancode = %d, shift = %d, ctrl = %d, alt = %d", scan_code, shift, ctrl, opt);
2472
2473 // translate scancode to unicode equiv
2474 switch (kbd_event->keysym.sym)
2475 {
2476 case SDLK_KP0: key_id = (!allowingStringInput ? gvNumberPadKey0 : gvNumberKey0); break;
2477 case SDLK_KP1: key_id = (!allowingStringInput ? gvNumberPadKey1 : gvNumberKey1); break;
2478 case SDLK_KP2: key_id = (!allowingStringInput ? gvNumberPadKey2 : gvNumberKey2); break;
2479 case SDLK_KP3: key_id = (!allowingStringInput ? gvNumberPadKey3 : gvNumberKey3); break;
2480 case SDLK_KP4: key_id = (!allowingStringInput ? gvNumberPadKey4 : gvNumberKey4); break;
2481 case SDLK_KP5: key_id = (!allowingStringInput ? gvNumberPadKey5 : gvNumberKey5); break;
2482 case SDLK_KP6: key_id = (!allowingStringInput ? gvNumberPadKey6 : gvNumberKey6); break;
2483 case SDLK_KP7: key_id = (!allowingStringInput ? gvNumberPadKey7 : gvNumberKey7); break;
2484 case SDLK_KP8: key_id = (!allowingStringInput ? gvNumberPadKey8 : gvNumberKey8); break;
2485 case SDLK_KP9: key_id = (!allowingStringInput ? gvNumberPadKey9 : gvNumberKey9); break;
2486 case SDLK_KP_PERIOD: key_id = (!allowingStringInput ? gvNumberPadKeyPeriod : 46); break;
2487 case SDLK_KP_DIVIDE: key_id = (!allowingStringInput ? gvNumberPadKeyDivide : 47); break;
2488 case SDLK_KP_MULTIPLY: key_id = (!allowingStringInput ? gvNumberPadKeyMultiply : 42); break;
2489 case SDLK_KP_MINUS: key_id = (!allowingStringInput ? gvNumberPadKeyMinus : 45); break;
2490 case SDLK_KP_PLUS: key_id = (!allowingStringInput ? gvNumberPadKeyPlus : 43); break;
2491 case SDLK_KP_EQUALS: key_id = (!allowingStringInput ? gvNumberPadKeyEquals : 61); break;
2492 case SDLK_KP_ENTER: key_id = gvNumberPadKeyEnter; break;
2493 case SDLK_HOME: key_id = gvHomeKey; break;
2494 case SDLK_END: key_id = gvEndKey; break;
2495 case SDLK_INSERT: key_id = gvInsertKey; break;
2496 case SDLK_PAGEUP: key_id = gvPageUpKey; break;
2497 case SDLK_PAGEDOWN: key_id = gvPageDownKey; break;
2498 case SDLK_SPACE: key_id = 32; break;
2499 case SDLK_RETURN: key_id = 13; break;
2500 case SDLK_TAB: key_id = 9; break;
2501 case SDLK_ESCAPE: key_id = 27; break;
2502 case SDLK_UP: key_id = gvArrowKeyUp; break;
2503 case SDLK_DOWN: key_id = gvArrowKeyDown; break;
2504 case SDLK_LEFT: key_id = gvArrowKeyLeft; break;
2505 case SDLK_RIGHT: key_id = gvArrowKeyRight; break;
2506 case SDLK_PAUSE: key_id = gvPauseKey; break;
2507 case SDLK_F1: key_id = gvFunctionKey1; break;
2508 case SDLK_F2: key_id = gvFunctionKey2; break;
2509 case SDLK_F3: key_id = gvFunctionKey3; break;
2510 case SDLK_F4: key_id = gvFunctionKey4; break;
2511 case SDLK_F5: key_id = gvFunctionKey5; break;
2512 case SDLK_F6: key_id = gvFunctionKey6; break;
2513 case SDLK_F7: key_id = gvFunctionKey7; break;
2514 case SDLK_F8: key_id = gvFunctionKey8; break;
2515 case SDLK_F9: key_id = gvFunctionKey9; break;
2516 case SDLK_F10: key_id = gvFunctionKey10; break;
2517 case SDLK_F11: key_id = gvFunctionKey11; break;
2518 case SDLK_F12: key_id = 327; break;
2519 case SDLK_BACKSPACE: key_id = gvBackspaceKey; break;
2520 case SDLK_DELETE: key_id = gvDeleteKey; break;
2521
2522 default:
2523 //OOLog(@"keys.test", @"Unhandled Keyup scancode with unicode = 0: %d", kbd_event->keysym.scancode);
2524 ;
2525 }
2526
2527 if (key_id > 0 && key_id <= [self numKeys])
2528 {
2529 keys[key_id] = NO;
2530 }
2531 else
2532 {
2533 //OOLog(@"keys.test", @"Unhandled Keyup scancode: %d", kbd_event->keysym.scancode);
2534 }
2535 break;
2536
2537 case SDL_VIDEORESIZE:
2538 {
2539 SDL_ResizeEvent *rsevt=(SDL_ResizeEvent *)&event;
2540 NSSize newSize=NSMakeSize(rsevt->w, rsevt->h);
2541#if OOLITE_WINDOWS
2542 if (!fullScreen && updateContext)
2543 {
2544 if (saveSize == NO)
2545 {
2546 // event triggered by caption & frame
2547 // next event will be a real resize.
2548 saveSize = YES;
2549 }
2550 else
2551 {
2552 [self initialiseGLWithSize: newSize];
2553 [self saveWindowSize: newSize];
2554 }
2555 }
2556#else
2557 [self initialiseGLWithSize: newSize];
2558 [self saveWindowSize: newSize];
2559#endif
2560 // certain gui screens will require an immediate redraw after
2561 // a resize event - Nikos 20140129
2562 if ([PlayerEntity sharedPlayer])
2563 {
2565 }
2566 break;
2567 }
2568
2569#if OOLITE_WINDOWS
2570 // if we minimize the window while in fullscreen (e.g. via
2571 // Win+M or Win+DownArrow), restore the non-borderless window
2572 // style before minimuzing and reset it when we return, otherwise
2573 // there might be issues with the game window remaining stuck on
2574 // top in some cases (seen with some Intel gfx chips).
2575 // N.B. active event gain of zero means app is iconified
2576 case SDL_ACTIVEEVENT:
2577 {
2578 if ((event.active.state & SDL_APPACTIVE) && fullScreen)
2579 {
2580 [self setWindowBorderless:event.active.gain];
2581 }
2582 break;
2583 }
2584
2585 // need to track this because the user may move the game window
2586 // to a secondary monitor, in which case we must potentially
2587 // refresh the information displayed (e.g. Game Options screen)
2588 // Nikos - 20140920
2589 case SDL_SYSWMEVENT:
2590 {
2591 DWORD dwLastError = 0;
2592 switch (event.syswm.msg->msg)
2593 {
2594 case WM_WINDOWPOSCHANGING:
2595 /* if we are in fullscreen mode we normally don't worry about having the window moved.
2596 However, when using multiple monitors, one can use hotkey combinations to make the
2597 window "jump" from one monitor to the next. We don't want this to happen, so if we
2598 detect that our (fullscreen) window has moved, we immediately bring it back to its
2599 original position. Nikos - 20140922
2600 */
2601 if (fullScreen)
2602 {
2603 RECT rDC;
2604
2605 /* attempting to move our fullscreen window while in maximized state can freak
2606 Windows out and the window may not return to its original position properly.
2607 Solution: if such a move takes place, first change the window placement to
2608 normal, move it normally, then restore its placement to maximized again.
2609 Additionally, the last good known window position seems to be lost in such
2610 a case. While at it, update also the coordinates of the non-maximized window
2611 so that it can return to its original position - this is why we need lastGoodRect.
2612 */
2613 WINDOWPLACEMENT wp;
2614 wp.length = sizeof(WINDOWPLACEMENT);
2615 GetWindowPlacement(SDL_Window, &wp);
2616
2617 GetWindowRect(SDL_Window, &rDC);
2618 if (rDC.left != monitorInfo.rcMonitor.left || rDC.top != monitorInfo.rcMonitor.top)
2619 {
2620 BOOL fullScreenMaximized = NO;
2621 if (wp.showCmd == SW_SHOWMAXIMIZED && !fullScreenMaximized)
2622 {
2623 fullScreenMaximized = YES;
2624 wp.showCmd = SW_SHOWNORMAL;
2625 SetWindowPlacement(SDL_Window, &wp);
2626 }
2627
2628 if (wp.showCmd != SW_SHOWMINIMIZED && wp.showCmd != SW_MINIMIZE)
2629 {
2630 MoveWindow(SDL_Window, monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top,
2631 (int)viewSize.width, (int)viewSize.height, TRUE);
2632 }
2633
2634 if (fullScreenMaximized)
2635 {
2636 GetWindowPlacement(SDL_Window, &wp);
2637 wp.showCmd = SW_SHOWMAXIMIZED;
2638 CopyRect(&wp.rcNormalPosition, &lastGoodRect);
2639 SetWindowPlacement(SDL_Window, &wp);
2640 }
2641 }
2642 else if (wp.showCmd == SW_SHOWMAXIMIZED)
2643 {
2644 CopyRect(&wp.rcNormalPosition, &lastGoodRect);
2645 SetWindowPlacement(SDL_Window, &wp);
2646 }
2647 }
2648 // it is important that this gets done after we've dealt with possible fullscreen movements,
2649 // because -doGuiScreenResizeUpdates does itself an update on current monitor
2650 if ([PlayerEntity sharedPlayer])
2651 {
2653 }
2654 /*
2655 deliberately no break statement here - moving or resizing the window changes its bounds
2656 rectangle. Therefore we must check whether to clip the mouse or not inside the newly
2657 updated rectangle, so just let it fall through
2658 */
2659
2660 case WM_ACTIVATEAPP:
2661 if(grabMouseStatus) [self grabMouseInsideGameWindow:YES];
2662 break;
2663
2664 case WM_SETTINGCHANGE:
2665 // TODO: we really should be checking the status of event.syswm.msg->lParam here and run our
2666 // dark / light mode refresh check only if the lParam LPCTSTR matches "ImmersiveColorSet".
2667 // However, for some reason I cannot get an actual string on lParam. This means that the
2668 // mode refresh check runs every time something changes the Windows Registry while the game
2669 // is running. Still, should be OK because our refreshDarKOrLightMode will be transparent in
2670 // such cases, plus we would not practically expect too many events doing things to the Registry
2671 // while we are running. If in the future we need to respond to a different event which changes
2672 // system settings in real time, then yes, we will have to find a way to decode lParam properly.
2673 // Nikos, 20230805
2674 [self refreshDarKOrLightMode];
2675 break;
2676
2677 case WM_SETFOCUS:
2678 /*
2679 ` make sure that all modifier keys like Shift, Alt, Ctrl and Caps Lock
2680 ` are set correctly to what they should be when we get focus. We have
2681 ` to do it ourselves because SDL on Windows has problems with this
2682 ` when focus change events occur, like e.g. Alt-Tab in/out of the
2683 application
2684 ` */
2685 [self resetSDLKeyModifiers];
2686 if (!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL))
2687 {
2688 dwLastError = GetLastError();
2689 OOLog(@"wm_setfocus.message", @"Setting thread priority to time critical failed! (error code: %d)", dwLastError);
2690 }
2691 break;
2692
2693 case WM_KILLFOCUS:
2694 if (!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_NORMAL))
2695 {
2696 dwLastError = GetLastError();
2697 OOLog(@"wm_killfocus.message", @"Setting thread priority to normal failed! (error code: %d)", dwLastError);
2698 }
2699 break;
2700
2701 default:
2702 ;
2703 }
2704 break;
2705 }
2706#endif
2707
2708 // caused by INTR or someone hitting close
2709 case SDL_QUIT:
2710 {
2711 SDL_FreeSurface(surface);
2712 [gameController exitAppWithContext:@"SDL_QUIT event received"];
2713 }
2714 }
2715 }
2716 // check if enough time has passed since last use of the mousewheel and act
2717 // if needed
2719 {
2720 _mouseWheelDelta = 0.0f;
2721 }
2722}
@ gvNumberKey4
@ gvNumberPadKeyDivide
@ gvNumberPadKeyMultiply
@ gvNumberKey9
@ gvNumberKey5
@ gvNumberPadKeyPeriod
@ gvFunctionKey2
@ gvInsertKey
@ gvNumberPadKeyPlus
@ gvNumberPadKey9
@ gvNumberPadKey1
@ gvFunctionKey10
@ gvFunctionKey5
@ gvNumberKey2
@ gvArrowKeyDown
@ gvNumberPadKey2
@ gvFunctionKey9
@ gvNumberPadKey3
@ gvFunctionKey4
@ gvEndKey
@ gvNumberKey0
@ gvNumberKey7
@ gvHomeKey
@ gvNumberPadKeyEquals
@ gvNumberPadKey6
@ gvNumberPadKeyEnter
@ gvNumberPadKey5
@ gvNumberPadKey4
@ gvNumberKey8
@ gvNumberKey3
@ gvNumberKey6
@ gvPauseKey
@ gvNumberPadKeyMinus
@ gvNumberPadKey7
@ gvFunctionKey11
@ gvFunctionKey8
@ gvNumberKey1
@ gvPageDownKey
@ gvNumberPadKey8
@ gvFunctionKey3
@ gvArrowKeyUp
@ gvArrowKeyRight
@ gvFunctionKey6
@ gvArrowKeyLeft
@ gvFunctionKey7
@ gvPageUpKey
@ gvNumberPadKey0
@ gvFunctionKey1
#define MOUSEY_MAXIMUM
#define OOMOUSEWHEEL_EVENTS_DELAY_INTERVAL
#define MOUSEX_MAXIMUM
BOOL mouseInDeltaMode
float _mouseVirtualStickSensitivityFactor
NSTimeInterval timeSinceLastMouseWheel
BOOL handleSDLEvent:(SDL_Event *evt)
void doGuiScreenResizeUpdates()
PlayerEntity * sharedPlayer()

References _mouseVirtualStickSensitivityFactor, _mouseWheelDelta, allowingStringInput, bounds, ctrl, display_z, PlayerEntity::doGuiScreenResizeUpdates, doubleClick, GameController::exitAppWithContext:, fullScreen, grabMouseInsideGameWindow:, grabMouseStatus, gvArrowKeyDown, gvArrowKeyLeft, gvArrowKeyRight, gvArrowKeyUp, gvBackspaceKey, gvDeleteKey, gvEndKey, gvFunctionKey1, gvFunctionKey10, gvFunctionKey11, gvFunctionKey2, gvFunctionKey3, gvFunctionKey4, gvFunctionKey5, gvFunctionKey6, gvFunctionKey7, gvFunctionKey8, gvFunctionKey9, gvHomeKey, gvInsertKey, gvNumberKey0, gvNumberKey1, gvNumberKey2, gvNumberKey3, gvNumberKey4, gvNumberKey5, gvNumberKey6, gvNumberKey7, gvNumberKey8, gvNumberKey9, gvNumberPadKey0, gvNumberPadKey1, gvNumberPadKey2, gvNumberPadKey3, gvNumberPadKey4, gvNumberPadKey5, gvNumberPadKey6, gvNumberPadKey7, gvNumberPadKey8, gvNumberPadKey9, gvNumberPadKeyDivide, gvNumberPadKeyEnter, gvNumberPadKeyEquals, gvNumberPadKeyMinus, gvNumberPadKeyMultiply, gvNumberPadKeyPeriod, gvNumberPadKeyPlus, gvPageDownKey, gvPageUpKey, gvPauseKey, OOSDLJoystickManager::handleSDLEvent:, handleStringInput:keyID:, initialiseGLWithSize:, isCapsLockOn, keys, kOOLogKeyDown, kOOLogKeyUp, MAIN_GUI_PIXEL_HEIGHT, MAIN_GUI_PIXEL_WIDTH, MOUSE_DOUBLE_CLICK_INTERVAL, mouseInDeltaMode, mouseWarped, MOUSEX_MAXIMUM, MOUSEY_MAXIMUM, numKeys, OOLog, OOMOUSEWHEEL_DELTA, OOMOUSEWHEEL_EVENTS_DELAY_INTERVAL, opt, pollControls, resetMouse, resetSDLKeyModifiers, saveWindowSize:, scancode2Unicode, setWindowBorderless:, PlayerEntity::sharedPlayer, OOJoystickManager::sharedStickHandler, shift, suppressKeys, surface, timeIntervalAtLastClick, timeSinceLastMouseWheel, toggleScreenMode, viewSize, and virtualJoystickPosition.

Referenced by gameController, GameController::performGameTick:, and pollControls.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pollControls [2/2]

- (void) pollControls

References pollControls.

Here is the call graph for this function:

◆ pollShiftKey [1/2]

+ (BOOL) pollShiftKey

Definition at line 2988 of file MyOpenGLView.m.

2989{
2990 return 0 != (SDL_GetModState() & (KMOD_LSHIFT | KMOD_RSHIFT));
2991}

References pollShiftKey.

Referenced by isAlphabetKeyDown, and pollShiftKey.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pollShiftKey [2/2]

+ (BOOL) pollShiftKey

References pollShiftKey.

Here is the call graph for this function:

◆ populateFullScreenModelist

- (void) populateFullScreenModelist

Definition at line 2773 of file MyOpenGLView.m.

2774{
2775 int i;
2776 SDL_Rect **modes;
2777 NSMutableDictionary *mode;
2778
2779 screenSizes=[[NSMutableArray alloc] init];
2780
2781 // The default resolution (slot 0) is the resolution we are
2782 // already in since this is guaranteed to work.
2784 [screenSizes addObject: mode];
2785
2786 modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
2787 if(modes == (SDL_Rect **)NULL)
2788 {
2789 OOLog(@"display.mode.list.none", @"%@", @"SDL didn't return any screen modes");
2790 return;
2791 }
2792
2793 if(modes == (SDL_Rect **)-1)
2794 {
2795 OOLog(@"display.mode.list.none", @"%@", @"SDL claims 'all resolutions available' which is unhelpful in the extreme");
2796 return;
2797 }
2798
2799 int lastw=[[mode objectForKey: kOODisplayWidth] intValue];
2800 int lasth=[[mode objectForKey: kOODisplayHeight] intValue];
2801 for(i=0; modes[i]; i++)
2802 {
2803 // SDL_ListModes often lists a mode several times,
2804 // presumably because each mode has several refresh rates.
2805 // But the modes pointer is an SDL_Rect which can't represent
2806 // refresh rates. WHY!?
2807 if(modes[i]->w != lastw || modes[i]->h != lasth)
2808 {
2809 // new resolution, save it
2810 mode=[NSMutableDictionary dictionary];
2811 [mode setValue: [NSNumber numberWithInt: (int)modes[i]->w]
2812 forKey: kOODisplayWidth];
2813 [mode setValue: [NSNumber numberWithInt: (int)modes[i]->h]
2814 forKey: kOODisplayHeight];
2815 [mode setValue: [NSNumber numberWithInt: 0]
2816 forKey: kOODisplayRefreshRate];
2817 if (![screenSizes containsObject:mode])
2818 {
2819 [screenSizes addObject: mode];
2820 OOLog(@"display.mode.list", @"Added res %d x %d", modes[i]->w, modes[i]->h);
2821 lastw=modes[i]->w;
2822 lasth=modes[i]->h;
2823 }
2824 }
2825 }
2826}
NSMutableDictionary * getNativeSize()

References getNativeSize, OOLog, populateFullScreenModelist, and screenSizes.

Referenced by getScreenSizeArray, init, and populateFullScreenModelist.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ recenterVirtualJoystick

- (void) recenterVirtualJoystick
implementation

Provided by category MyOpenGLView(Internal).

Definition at line 864 of file MyOpenGLView.m.

865{
866 if ([PLAYER guiScreen] == GUI_SCREEN_MAIN)
867 {
869 }
870}
#define PLAYER
GameController * sharedController()
void recenterVirtualJoystick()

References PLAYER, GameController::recenterVirtualJoystick, MyOpenGLView(Internal)::recenterVirtualJoystick, and GameController::sharedController.

Referenced by MyOpenGLView(Internal)::recenterVirtualJoystick, rightMouseUp:, and touchesEndedWithEvent:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetMouse [1/2]

- (void) resetMouse

Definition at line 1980 of file MyOpenGLView.m.

1981{
1982 [self setVirtualJoystick:0.0 :0.0];
1983 if ([[PlayerEntity sharedPlayer] isMouseControlOn])
1984 {
1985 SDL_WarpMouse([self viewSize].width / 2, [self viewSize].height / 2);
1986 mouseWarped = YES;
1987 }
1988}

References mouseWarped, resetMouse, and viewSize.

Referenced by gameController, PlayerEntity(OOControlsPrivate)::pollApplicationControls, pollControls, PlayerEntity(OOControlsPrivate)::pollCustomViewControls, resetMouse, and rightMouseDown:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetMouse [2/2]

- (void) resetMouse

References resetMouse.

Here is the call graph for this function:

◆ resetSDLKeyModifiers

- (void) resetSDLKeyModifiers
implementation

Provided by category MyOpenGLView(OOPrivate).

Definition at line 1378 of file MyOpenGLView.m.

1379{
1380 // probably not needed for Linux
1381}

References MyOpenGLView(OOPrivate)::resetSDLKeyModifiers.

Referenced by pollControls, and MyOpenGLView(OOPrivate)::resetSDLKeyModifiers.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetTypedString [1/2]

- (void) resetTypedString

Definition at line 608 of file MyOpenGLView.m.

609{
610 [typedString setString:@""];
611}

References resetTypedString.

Referenced by PlayerEntity(OOControlsPrivate)::pollGuiArrowKeyControls:, resetTypedString, PlayerEntity(KeyMapper)::setGuiToKeyConfigEntryScreen, PlayerEntity(Scripting)::setMissionChoiceByTextEntry:, and typedString.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetTypedString [2/2]

- (void) resetTypedString

References resetTypedString.

Here is the call graph for this function:

◆ rightMouseDown:

- (void) rightMouseDown: (NSEvent *) theEvent
implementation

Definition at line 846 of file MyOpenGLView.m.

846 :(NSEvent *)theEvent
847{
848 [self resetMouse];
849}

References resetMouse.

Here is the call graph for this function:

◆ rightMouseUp:

- (void) rightMouseUp: (NSEvent *) theEvent
implementation

Definition at line 852 of file MyOpenGLView.m.

852 :(NSEvent *)theEvent
853{
854 [self recenterVirtualJoystick];
855}

References recenterVirtualJoystick.

Here is the call graph for this function:

◆ saveWindowSize:

- (void) saveWindowSize: (NSSize) windowSize

Definition at line 2830 of file MyOpenGLView.m.

2830 : (NSSize) windowSize
2831{
2832 NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
2833 [defaults setInteger: (int)windowSize.width forKey: @"window_width"];
2834 [defaults setInteger: (int)windowSize.height forKey: @"window_height"];
2835 currentWindowSize=windowSize;
2836}

References currentWindowSize.

Referenced by pollControls.

Here is the caller graph for this function:

◆ scrollWheel:

- (void) scrollWheel: (NSEvent *) theEvent
implementation

Definition at line 816 of file MyOpenGLView.m.

816 :(NSEvent *)theEvent
817{
818 float dy = [theEvent scrollingDeltaY];
819
820 if (dy == 0)
821 return;
822
823 if (dy > 0)
824 {
825 if (_mouseWheelDelta >= 0)
826 _mouseWheelDelta += dy;
827 else
829 }
830 else
831 {
832 if (_mouseWheelDelta <= 0)
833 _mouseWheelDelta += dy;
834 else
836 }
837 timeIntervalAtLastMouseWheel = [NSDate timeIntervalSinceReferenceDate];
838}
NSTimeInterval timeIntervalAtLastMouseWheel

References _mouseWheelDelta, and timeIntervalAtLastMouseWheel.

◆ sdrToneMapper

- (OOSDRToneMapper) sdrToneMapper

Definition at line 1404 of file MyOpenGLView.m.

1405{
1406 return _sdrToneMapper;
1407}

References _sdrToneMapper, and sdrToneMapper.

Referenced by Universe::gameSettings, initialiseGLWithSize:, and sdrToneMapper.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDisplayMode:fullScreen:

- (void) setDisplayMode: (int) mode
fullScreen: (BOOL) fsm 

◆ setFov:fromFraction: [1/2]

- (void) setFov: (float) value
fromFraction: (BOOL) fromFraction 

Definition at line 2958 of file MyOpenGLView.m.

2958 :(float)value fromFraction:(BOOL)fromFraction
2959{
2960 _fov = fromFraction ? value : tan((value / 2) * M_PI / 180);
2961}

References _fov, and M_PI.

Referenced by PlayerEntity(OOControlsPrivate)::handleGameOptionsScreenKeys, and Universe::initWithGameView:.

Here is the caller graph for this function:

◆ setFov:fromFraction: [2/2]

- (void) setFov: (float) value
fromFraction: (BOOL) fromFraction 

◆ setFullScreenMode:

- (void) setFullScreenMode: (BOOL) fsm

References inFullScreenMode.

Referenced by endSplashScreen, and initialiseGLWithSize:useVideoMode:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setGameController: [1/2]

- (void) setGameController: (GameController *) controller

Definition at line 662 of file MyOpenGLView.m.

662 :(GameController *) controller
663{
664 gameController = controller;
665}
GameController * gameController

References gameController.

Referenced by GameController::beginSplashScreen, and GameController::setGameView:.

Here is the caller graph for this function:

◆ setGameController: [2/2]

- (void) setGameController: (GameController *) controller

◆ setGammaValue: [1/2]

- (void) setGammaValue: (float) value

Definition at line 2940 of file MyOpenGLView.m.

2940 : (float) value
2941{
2942 if (value < 0.2f) value = 0.2f;
2943 if (value > 4.0f) value = 4.0f;
2944
2945 _gamma = value;
2946 SDL_SetGamma(_gamma, _gamma, _gamma);
2947
2948 [[NSUserDefaults standardUserDefaults] setFloat:_gamma forKey:@"gamma-value"];
2949}

References _gamma.

Referenced by PlayerEntity(OOControlsPrivate)::handleGameOptionsScreenKeys, and Universe::initWithGameView:.

Here is the caller graph for this function:

◆ setGammaValue: [2/2]

- (void) setGammaValue: (float) value

◆ setMouseInDeltaMode:

- (void) setMouseInDeltaMode: (BOOL) inDelta

Definition at line 2934 of file MyOpenGLView.m.

2934 : (BOOL) inDelta
2935{
2936 mouseInDeltaMode=inDelta;
2937}

References mouseInDeltaMode.

Referenced by noteMouseInteractionModeChangedFrom:to:.

Here is the caller graph for this function:

◆ setMouseWheelDelta: [1/2]

- (void) setMouseWheelDelta: (float) newWheelDelta

Definition at line 2091 of file MyOpenGLView.m.

2091 : (float) newWheelDelta
2092{
2093 _mouseWheelDelta = newWheelDelta * OOMOUSEWHEEL_DELTA;
2094}

References _mouseWheelDelta, and OOMOUSEWHEEL_DELTA.

Referenced by PlayerEntity::doBookkeeping:.

Here is the caller graph for this function:

◆ setMouseWheelDelta: [2/2]

- (void) setMouseWheelDelta: (float) newWheelDelta

◆ setMsaa:

- (void) setMsaa: (BOOL) newMsaa

Definition at line 2976 of file MyOpenGLView.m.

2976 :(BOOL)newMsaa
2977{
2978 _msaa = !!newMsaa;
2979}

References _msaa.

Referenced by Universe::initWithGameView:.

Here is the caller graph for this function:

◆ setScreenSize:

- (void) setScreenSize: (int) sizeIndex

Referenced by PlayerEntity(OOControlsPrivate)::handleGameOptionsScreenKeys.

Here is the caller graph for this function:

◆ setSDRToneMapper:

- (void) setSDRToneMapper: (OOSDRToneMapper) newToneMapper

Definition at line 1410 of file MyOpenGLView.m.

1410 : (OOSDRToneMapper)newToneMapper
1411{
1412 if (newToneMapper > OOSDR_TONEMAPPER_REINHARD) newToneMapper = OOSDR_TONEMAPPER_REINHARD;
1413 if (newToneMapper < OOSDR_TONEMAPPER_NONE) newToneMapper = OOSDR_TONEMAPPER_NONE;
1414 _sdrToneMapper = newToneMapper;
1415}
OOSDRToneMapper
@ OOSDR_TONEMAPPER_REINHARD
@ OOSDR_TONEMAPPER_NONE

References _sdrToneMapper, OOSDR_TONEMAPPER_NONE, and OOSDR_TONEMAPPER_REINHARD.

Referenced by OoliteSetProperty().

Here is the caller graph for this function:

◆ setStringInput: [1/2]

- (void) setStringInput: (enum StringInput) value

Definition at line 582 of file MyOpenGLView.m.

582 : (enum StringInput) value
583{
584 allowingStringInput = value;
585}
StringInput

References allowingStringInput.

Referenced by PlayerEntity(OOControlsPrivate)::pollDemoControls:, PlayerEntity(OOControlsPrivate)::pollGuiArrowKeyControls:, PlayerEntity(KeyMapper)::setGuiToKeyConfigEntryScreen, and PlayerEntity(OOLoadSavePrivate)::setGuiToOverwriteScreen:.

Here is the caller graph for this function:

◆ setStringInput: [2/2]

- (void) setStringInput: (enum StringInput) value

◆ setTypedString: [1/2]

- (void) setTypedString: (NSString*) value

Definition at line 614 of file MyOpenGLView.m.

614 :(NSString*) value
615{
616 [typedString setString:value];
617}

Referenced by PlayerEntity(LoadSave)::saveCommanderInputHandler, PlayerEntity(KeyMapper)::setGuiToKeyConfigEntryScreen, and PlayerEntity(OOLoadSavePrivate)::setGuiToSaveCommanderScreen:.

Here is the caller graph for this function:

◆ setTypedString: [2/2]

- (void) setTypedString: (NSString *) value

◆ setVirtualJoystick:vmx: [1/2]

- (void) setVirtualJoystick: (double)
vmx: (double) vmy 

Definition at line 1939 of file MyOpenGLView.m.

1939 :(double) vmx :(double) vmy
1940{
1943}

References virtualJoystickPosition.

◆ setVirtualJoystick:vmx: [2/2]

- (void) setVirtualJoystick: (double)
vmx: (double) vmy 

◆ setWindowBorderless:

- (void) setWindowBorderless: (BOOL) borderless
implementation

Provided by category MyOpenGLView(OOPrivate).

Definition at line 1384 of file MyOpenGLView.m.

1384 :(BOOL)borderless
1385{
1386 // do nothing on Linux
1387}

Referenced by initialiseGLWithSize:useVideoMode:, and pollControls.

Here is the caller graph for this function:

◆ snapShot: [1/2]

- (BOOL) snapShot: (NSString *) filename

Definition at line 1664 of file MyOpenGLView.m.

1664 :(NSString *)filename
1665{
1666 BOOL snapShotOK = YES;
1667 SDL_Surface* tmpSurface;
1668
1669 // backup the previous directory
1670 NSString* originalDirectory = [[NSFileManager defaultManager] currentDirectoryPath];
1671 // use the snapshots directory
1672 [[NSFileManager defaultManager] chdirToSnapshotPath];
1673
1674 BOOL withFilename = (filename != nil);
1675 static unsigned imageNo = 0;
1676 unsigned tmpImageNo = 0;
1677 NSString *pathToPic = nil;
1678 NSString *baseName = @"oolite";
1679
1680#if SNAPSHOTS_PNG_FORMAT
1681 NSString *extension = @".png";
1682#else
1683 NSString *extension = @".bmp";
1684#endif
1685
1686 if (withFilename)
1687 {
1688 baseName = filename;
1689 pathToPic = [filename stringByAppendingString:extension];
1690 }
1691 else
1692 {
1693 tmpImageNo = imageNo;
1694 }
1695
1696 if (withFilename && [[NSFileManager defaultManager] fileExistsAtPath:pathToPic])
1697 {
1698 OOLog(@"screenshot.filenameExists", @"Snapshot \"%@%@\" already exists - adding numerical sequence.", pathToPic, extension);
1699 pathToPic = nil;
1700 }
1701
1702 if (pathToPic == nil)
1703 {
1704 do
1705 {
1706 tmpImageNo++;
1707 pathToPic = [NSString stringWithFormat:@"%@-%03d%@", baseName, tmpImageNo, extension];
1708 } while ([[NSFileManager defaultManager] fileExistsAtPath:pathToPic]);
1709 }
1710
1711 if (!withFilename)
1712 {
1713 imageNo = tmpImageNo;
1714 }
1715
1716 OOLog(@"screenshot", @"Saving screen shot \"%@\" (%u x %u pixels).", pathToPic, surface->w, surface->h);
1717
1718 int pitch = surface->w * 3;
1719 unsigned char *pixls = malloc(pitch * surface->h);
1720 int y;
1721 int off;
1722
1723 if (surface->w % 4) glPixelStorei(GL_PACK_ALIGNMENT,1);
1724 else glPixelStorei(GL_PACK_ALIGNMENT,4);
1725 for (y=surface->h-1, off=0; y>=0; y--, off+=pitch)
1726 {
1727 glReadPixels(0, y, surface->w, 1, GL_RGB, GL_UNSIGNED_BYTE, pixls + off);
1728 }
1729
1730 tmpSurface=SDL_CreateRGBSurfaceFrom(pixls,surface->w,surface->h,24,surface->w*3,0xFF,0xFF00,0xFF0000,0x0);
1731#if SNAPSHOTS_PNG_FORMAT
1732 if(![self pngSaveSurface:pathToPic withSurface:tmpSurface])
1733 {
1734 OOLog(@"screenshotPNG", @"Failed to save %@", pathToPic);
1735 snapShotOK = NO;
1736 }
1737#else
1738 if (SDL_SaveBMP(tmpSurface, [pathToPic UTF8String]) == -1)
1739 {
1740 OOLog(@"screenshotBMP", @"Failed to save %@", pathToPic);
1741 snapShotOK = NO;
1742 }
1743#endif
1744 SDL_FreeSurface(tmpSurface);
1745 free(pixls);
1746
1747 // if outputting HDR signal, save also either an .exr or a Radiance .hdr snapshot
1748 if ([self hdrOutput])
1749 {
1750 NSString *fileExtension = [[NSUserDefaults standardUserDefaults] oo_stringForKey:@"hdr-snapshot-format" defaultValue:SNAPSHOTHDR_EXTENSION_DEFAULT];
1751
1752 // we accept file extension with or without a leading dot; if it is without, insert it at the beginning now
1753 if (![[fileExtension substringToIndex:1] isEqual:@"."]) fileExtension = [@"." stringByAppendingString:fileExtension];
1754
1755 if (![fileExtension isEqual:SNAPSHOTHDR_EXTENSION_EXR] && ![fileExtension isEqual:SNAPSHOTHDR_EXTENSION_HDR])
1756 {
1757 OOLog(@"screenshotHDR", @"Unrecognized HDR file format requested, defaulting to %@", SNAPSHOTHDR_EXTENSION_DEFAULT);
1758 fileExtension = SNAPSHOTHDR_EXTENSION_DEFAULT;
1759 }
1760
1761 NSString *pathToPicHDR = [pathToPic stringByReplacingString:@".png" withString:fileExtension];
1762 OOLog(@"screenshot", @"Saving screen shot \"%@\" (%u x %u pixels).", pathToPicHDR, surface->w, surface->h);
1763 GLfloat *pixlsf = (GLfloat *)malloc(pitch * surface->h * sizeof(GLfloat));
1764 for (y=surface->h-1, off=0; y>=0; y--, off+=pitch)
1765 {
1766 glReadPixels(0, y, surface->w, 1, GL_RGB, GL_FLOAT, pixlsf + off);
1767 }
1768
1769 if (([fileExtension isEqual:SNAPSHOTHDR_EXTENSION_EXR] && SaveEXRSnapshot([pathToPicHDR cStringUsingEncoding:NSUTF8StringEncoding], surface->w, surface->h, pixlsf) != 0) //TINYEXR_SUCCESS
1770 || ([fileExtension isEqual:SNAPSHOTHDR_EXTENSION_HDR] && !stbi_write_hdr([pathToPicHDR cStringUsingEncoding:NSUTF8StringEncoding], surface->w, surface->h, 3, pixlsf)))
1771 {
1772 OOLog(@"screenshotHDR", @"Failed to save %@", pathToPicHDR);
1773 snapShotOK = NO;
1774 }
1775
1776 free(pixlsf);
1777 }
1778
1779 // return to the previous directory
1780 [[NSFileManager defaultManager] changeCurrentDirectoryPath:originalDirectory];
1781 return snapShotOK;
1782}
int SaveEXRSnapshot(const char *outfilename, int width, int height, const float *rgb)
#define SNAPSHOTHDR_EXTENSION_HDR
#define SNAPSHOTHDR_EXTENSION_DEFAULT
#define SNAPSHOTHDR_EXTENSION_EXR
const char * filename
Definition ioapi.h:133
STBIWDEF int stbi_write_hdr(char const *filename, int w, int h, int comp, const float *data)

References hdrOutput, nil, OOLog, SaveEXRSnapshot(), SNAPSHOTHDR_EXTENSION_DEFAULT, SNAPSHOTHDR_EXTENSION_EXR, SNAPSHOTHDR_EXTENSION_HDR, stbi_write_hdr(), surface, and y.

Referenced by PlayerEntity(OOControlsPrivate)::pollApplicationControls.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ snapShot: [2/2]

- (BOOL) snapShot: (NSString *) filename

◆ stringToClipboard: [1/2]

- (void) stringToClipboard: (NSString *) stringToCopy

Definition at line 1372 of file MyOpenGLView.m.

1372 :(NSString *)stringToCopy
1373{
1374 // TODO: implement string clipboard copy for Linux
1375}

◆ stringToClipboard: [2/2]

- (void) stringToClipboard: (NSString *) stringToCopy

◆ suppressKeysUntilKeyUp [1/2]

- (void) suppressKeysUntilKeyUp

Definition at line 2000 of file MyOpenGLView.m.

2001{
2002 if (keys[gvMouseDoubleClick] == NO)
2003 {
2004 suppressKeys = YES;
2005 [self clearKeys];
2006 }
2007 else
2008 {
2009 [self clearMouse];
2010 }
2011
2012}
@ gvMouseDoubleClick

References clearKeys, clearMouse, gvMouseDoubleClick, keys, suppressKeys, and suppressKeysUntilKeyUp.

Referenced by PlayerEntity(LoadSave)::commanderSelector, PlayerEntity(KeyMapper)::handleKeyConfigEntryKeys:view:, PlayerEntity(KeyMapper)::handleKeyMapperConfirmClearKeys:view:, isAlphabetKeyDown, PlayerEntity(LoadSave)::saveCommanderInputHandler, PlayerEntity(OOLoadSavePrivate)::setGuiToSaveCommanderScreen:, and suppressKeysUntilKeyUp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ suppressKeysUntilKeyUp [2/2]

- (void) suppressKeysUntilKeyUp

References suppressKeysUntilKeyUp.

Here is the call graph for this function:

◆ toggleScreenMode

- (void) toggleScreenMode

References toggleScreenMode.

Referenced by PlayerEntity(OOControlsPrivate)::handleGameOptionsScreenKeys, pollControls, and toggleScreenMode.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ touchesEndedWithEvent:

- (void) touchesEndedWithEvent: (NSEvent *) theEvent
implementation

Definition at line 858 of file MyOpenGLView.m.

858 :(NSEvent *)theEvent
859{
860 [self recenterVirtualJoystick];
861}

References recenterVirtualJoystick.

Here is the call graph for this function:

◆ translateKeyCode:

- (int) translateKeyCode: (int) input
implementation

Provided by category MyOpenGLView(Internal).

Definition at line 875 of file MyOpenGLView.m.

875 : (int) input
876{
877 int key = input;
878 switch ( input )
879 {
880 case NSUpArrowFunctionKey:
881 key = gvArrowKeyUp;
882 break;
883
884 case NSDownArrowFunctionKey:
885 key = gvArrowKeyDown;
886 break;
887
888 case NSLeftArrowFunctionKey:
889 key = gvArrowKeyLeft;
890 break;
891
892 case NSRightArrowFunctionKey:
893 key = gvArrowKeyRight;
894 break;
895
896 case NSF1FunctionKey:
897 key = gvFunctionKey1;
898 break;
899
900 case NSF2FunctionKey:
901 key = gvFunctionKey2;
902 break;
903
904 case NSF3FunctionKey:
905 key = gvFunctionKey3;
906 break;
907
908 case NSF4FunctionKey:
909 key = gvFunctionKey4;
910 break;
911
912 case NSF5FunctionKey:
913 key = gvFunctionKey5;
914 break;
915
916 case NSF6FunctionKey:
917 key = gvFunctionKey6;
918 break;
919
920 case NSF7FunctionKey:
921 key = gvFunctionKey7;
922 break;
923
924 case NSF8FunctionKey:
925 key = gvFunctionKey8;
926 break;
927
928 case NSF9FunctionKey:
929 key = gvFunctionKey9;
930 break;
931
932 case NSF10FunctionKey:
933 key = gvFunctionKey10;
934 break;
935
936 case NSF11FunctionKey:
937 key = gvFunctionKey11;
938 break;
939
940 case NSHomeFunctionKey:
941 key = gvHomeKey;
942 break;
943
944 case NSBackspaceCharacter:
945 key = gvBackspaceKey;
946 break;
947
948 case NSDeleteCharacter:
949 key = gvDeleteKey;
950 break;
951
952 case NSInsertFunctionKey:
953 key = gvInsertKey;
954 break;
955
956 case NSEndFunctionKey:
957 key = gvEndKey;
958 break;
959
960 case NSPageUpFunctionKey:
961 key = gvPageUpKey;
962 break;
963
964 case NSPageDownFunctionKey:
965 key = gvPageDownKey;
966 break;
967
968 case NSPrintScreenFunctionKey:
969 key = gvPrintScreenKey;
970 break;
971
972 case NSPauseFunctionKey:
973 key = gvPauseKey;
974 break;
975
976 default:
977 break;
978 }
979 return key;
980}

References gvArrowKeyDown, gvArrowKeyLeft, gvArrowKeyRight, gvArrowKeyUp, gvBackspaceKey, gvDeleteKey, gvEndKey, gvFunctionKey1, gvFunctionKey10, gvFunctionKey11, gvFunctionKey2, gvFunctionKey3, gvFunctionKey4, gvFunctionKey5, gvFunctionKey6, gvFunctionKey7, gvFunctionKey8, gvFunctionKey9, gvHomeKey, gvInsertKey, gvPageDownKey, gvPageUpKey, gvPauseKey, gvPrintScreenKey, and int().

Referenced by keyDown:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ typedString [1/2]

- (NSString *) typedString

References resetTypedString, and typedString.

Here is the call graph for this function:

◆ typedString [2/2]

- (NSString *) typedString

References typedString.

◆ UnapplyCursorState

+ (void) UnapplyCursorState (OOMouseInteractionMode) mode
implementation

Definition at line 1350 of file MyOpenGLView.m.

1351{
1352 BOOL hidden, obscured;
1353 GetDesiredCursorState(mode, &hidden, &obscured);
1354 if (hidden) [NSCursor unhide];
1355 if (obscured) [NSCursor setHiddenUntilMouseMoves:NO];
1356}

References GetDesiredCursorState().

Here is the call graph for this function:

◆ update

- (void) update
implementation

Definition at line 322 of file MyOpenGLView.m.

323{
324 NSOpenGLContext *context = [self openGLContext];
325
326 [context update];
327 int virtualScreen = [context currentVirtualScreen];
328 if (virtualScreen != _virtualScreen)
329 {
330 @try
331 {
333 _virtualScreen = virtualScreen;
334 }
335 @catch (NSException *exception)
336 {
337 /* Graphics reset failed, most likely because of OpenGL context
338 incompatibility. Reset to previous "virtual screen" (i.e.,
339 renderer). OS X's OpenGL implementation will take care of
340 copying
341 */
342 [context setCurrentVirtualScreen:_virtualScreen];
343 [[OOGraphicsResetManager sharedManager] resetGraphicsState]; // If this throws, we're screwed.
344
345 if ([[self gameController] inFullScreenMode])
346 {
347 [[self gameController] pauseFullScreenModeToPerform:@selector(noteMovedToBadDisplay) onTarget:self];
348 }
349 else
350 {
351 [self noteMovedToBadDisplay];
352 }
353 }
354 }
355}
BOOL inFullScreenMode()
OOGraphicsResetManager * sharedManager()

References _virtualScreen, gameController, inFullScreenMode, noteMovedToBadDisplay, GameController::pauseFullScreenModeToPerform:onTarget:, OOGraphicsResetManager::resetGraphicsState, OOGraphicsResetManager::sharedManager, and update.

Referenced by update.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateScreen [1/2]

- (void) updateScreen

Definition at line 766 of file MyOpenGLView.m.

767{
768 [self drawRect: NSMakeRect(0, 0, viewSize.width, viewSize.height)];
769}

References drawRect:, and updateScreen.

Referenced by GameController::beginSplashScreen, display, endSplashScreen, gameController, updateScreen, and GameController::windowDidResize:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateScreen [2/2]

- (void) updateScreen

References display, and updateScreen.

Here is the call graph for this function:

◆ updateScreenWithVideoMode:

- (void) updateScreenWithVideoMode: (BOOL) v_mode

Definition at line 776 of file MyOpenGLView.m.

776 :(BOOL) v_mode
777{
778 if ((viewSize.width != surface->w)||(viewSize.height != surface->h)) // resized
779 {
780#if OOLITE_LINUX
781 m_glContextInitialized = NO; //probably not needed
782#endif
783 viewSize.width = surface->w;
784 viewSize.height = surface->h;
785 }
786
787 if (m_glContextInitialized == NO)
788 {
789 [self initialiseGLWithSize:viewSize useVideoMode:v_mode];
790 }
791
792 if (surface == 0)
793 return;
794
795 // do all the drawing!
796 //
797 if (UNIVERSE) [UNIVERSE drawUniverse];
798 else
799 {
800 // not set up yet, draw a black screen
801 glClearColor( 0.0, 0.0, 0.0, 0.0);
802 glClear( GL_COLOR_BUFFER_BIT);
803 }
804
805 SDL_GL_SwapBuffers();
806}
#define UNIVERSE
Definition Universe.h:840

References initialiseGLWithSize:useVideoMode:, m_glContextInitialized, surface, UNIVERSE, and viewSize.

Referenced by drawRect:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ viewSize [1/2]

- (NSSize) viewSize

References viewSize.

◆ viewSize [2/2]

- (NSSize) viewSize

References viewSize.

◆ virtualJoystickPosition [1/2]

- (NSPoint) virtualJoystickPosition

References clearKeys, clearMouse, and virtualJoystickPosition.

Here is the call graph for this function:

◆ virtualJoystickPosition [2/2]

- (NSPoint) virtualJoystickPosition

◆ x_offset [1/2]

- (GLfloat) x_offset

References x_offset.

◆ x_offset [2/2]

- (GLfloat) x_offset

References x_offset.

◆ y_offset [1/2]

- (GLfloat) y_offset

References y_offset.

◆ y_offset [2/2]

- (GLfloat) y_offset

References y_offset.

Member Data Documentation

◆ _colorSaturation

- (float) _colorSaturation
protected

Definition at line 242 of file MyOpenGLView.h.

Referenced by adjustColorSaturation:, colorSaturation, and init.

◆ _fov

- (float) _fov
private

Definition at line 160 of file MyOpenGLView.h.

Referenced by fov:, and setFov:fromFraction:.

◆ _gamma

- (float) _gamma
protected

Definition at line 209 of file MyOpenGLView.h.

Referenced by createSurface, gammaValue, and setGammaValue:.

◆ _hdrOutput

- (BOOL) _hdrOutput
protected

Definition at line 244 of file MyOpenGLView.h.

Referenced by init.

◆ _mouseVirtualStickSensitivityFactor

- (float) _mouseVirtualStickSensitivityFactor
protected

Definition at line 200 of file MyOpenGLView.h.

Referenced by init, and pollControls.

◆ _mouseWheelDelta

- (float) _mouseWheelDelta
private

◆ _msaa

- (BOOL) _msaa
protected

Definition at line 211 of file MyOpenGLView.h.

Referenced by msaa, and setMsaa:.

◆ _pixelFormatAttributes

- (NSData*) _pixelFormatAttributes
private

Definition at line 163 of file MyOpenGLView.h.

Referenced by dealloc, initWithFrame:, and pixelFormatAttributes.

◆ _sdrToneMapper

- (int) _sdrToneMapper
protected

Definition at line 240 of file MyOpenGLView.h.

Referenced by init, sdrToneMapper, and setSDRToneMapper:.

◆ _virtualScreen

- (int) _virtualScreen
private

Definition at line 162 of file MyOpenGLView.h.

Referenced by initWithFrame:, and update.

◆ allowingStringInput

- (enum StringInput) allowingStringInput
private

Definition at line 596 of file MyOpenGLView.m.

597{
598 return allowingStringInput;
599}

Referenced by allowingStringInput, allowStringInput:, init, initWithFrame:, keyDown:, pollControls, and setStringInput:.

◆ backingViewSize

- (NSSize) backingViewSize
private

Definition at line 632 of file MyOpenGLView.m.

633{
634 return viewSize;
635}

Referenced by backingViewSize.

◆ bounds

- (NSRect) bounds
protected

Definition at line 620 of file MyOpenGLView.m.

621{
622 return bounds;
623}

Referenced by bounds, init, initialiseGLWithSize:useVideoMode:, and pollControls.

◆ capsLockOn

- (BOOL) capsLockOn
private

Definition at line 135 of file MyOpenGLView.h.

Referenced by flagsChanged:.

◆ command

- (BOOL) command
private

Definition at line 135 of file MyOpenGLView.h.

Referenced by flagsChanged:, and isCommandDown.

◆ commandF

- (BOOL) commandF
private

Definition at line 139 of file MyOpenGLView.h.

Referenced by keyDown:, and keyUp:.

◆ commandQ

- (BOOL) commandQ
private

Definition at line 138 of file MyOpenGLView.h.

Referenced by keyDown:, and keyUp:.

◆ ctrl

- (BOOL) ctrl
private

Definition at line 135 of file MyOpenGLView.h.

Referenced by flagsChanged:, isCtrlDown, and pollControls.

◆ currentSize

- (int) currentSize
protected

Definition at line 215 of file MyOpenGLView.h.

Referenced by init, and loadFullscreenSettings.

◆ currentWindowSize

- (NSSize) currentWindowSize
protected

Definition at line 219 of file MyOpenGLView.h.

Referenced by createSurface, endSplashScreen, init, loadWindowSize, and saveWindowSize:.

◆ display_z

- (GLfloat) display_z
private

◆ doubleClick

- (BOOL) doubleClick
private

Definition at line 148 of file MyOpenGLView.h.

Referenced by clearMouse, mouseDown:, mouseUp:, and pollControls.

◆ f12

- (BOOL) f12
private

Definition at line 140 of file MyOpenGLView.h.

Referenced by keyDown:, and keyUp:.

◆ firstScreen

- (NSSize) firstScreen
protected

Definition at line 248 of file MyOpenGLView.h.

Referenced by createSurface, endSplashScreen, and init.

◆ fullScreen

- (BOOL) fullScreen
protected

◆ gameController

◆ grabMouseStatus

- (BOOL) grabMouseStatus
protected

Definition at line 246 of file MyOpenGLView.h.

Referenced by init, and pollControls.

◆ isAlphabetKeyDown

- (BOOL) isAlphabetKeyDown
private

Definition at line 1991 of file MyOpenGLView.m.

1992{
1993 return isAlphabetKeyDown = NO;;
1994}

Referenced by init, initWithFrame:, isAlphabetKeyDown, keyDown:, and keyUp:.

◆ keycodetrans

- (int) keycodetrans
private

Definition at line 142 of file MyOpenGLView.h.

Referenced by keyDown:, and keyUp:.

◆ keyMappings_normal

- (NSDictionary *) keyMappings_normal
private

Definition at line 130 of file MyOpenGLView.h.

Referenced by dealloc, and initKeyMappingData.

◆ keyMappings_shifted

- (NSDictionary *) keyMappings_shifted
private

Definition at line 131 of file MyOpenGLView.h.

Referenced by dealloc, and initKeyMappingData.

◆ keys

- (BOOL) keys
private

◆ lastKeyShifted

- (BOOL) lastKeyShifted
private

Definition at line 135 of file MyOpenGLView.h.

Referenced by clearKeys, keyDown:, and lastKeyWasShifted.

◆ m_glContextInitialized

- (BOOL) m_glContextInitialized
private

Definition at line 144 of file MyOpenGLView.h.

Referenced by init, initialiseGLWithSize:useVideoMode:, and updateScreenWithVideoMode:.

◆ matrixManager

- (OOOpenGLMatrixManager *) matrixManager
private

Definition at line 165 of file MyOpenGLView.h.

Referenced by dealloc, getOpenGLMatrixManager, init, and initWithFrame:.

◆ mouseDragStartPoint

- (NSPoint) mouseDragStartPoint
protected

Definition at line 188 of file MyOpenGLView.h.

◆ mouseInDeltaMode

- (BOOL) mouseInDeltaMode
protected

Definition at line 253 of file MyOpenGLView.h.

Referenced by pollControls, and setMouseInDeltaMode:.

◆ mouseWarped

- (BOOL) mouseWarped
protected

Definition at line 190 of file MyOpenGLView.h.

Referenced by init, pollControls, and resetMouse.

◆ opt

- (BOOL) opt
private

Definition at line 135 of file MyOpenGLView.h.

Referenced by flagsChanged:, isOptDown, and pollControls.

◆ scancode2Unicode

- (int) scancode2Unicode
private

Definition at line 129 of file MyOpenGLView.h.

Referenced by init, initWithFrame:, and pollControls.

◆ screenSizes

- (NSMutableArray*) screenSizes
protected

◆ shift

- (BOOL) shift
private

Definition at line 135 of file MyOpenGLView.h.

Referenced by flagsChanged:, isShiftDown, keyDown:, and pollControls.

◆ showSplashScreen

- (BOOL) showSplashScreen
protected

Definition at line 222 of file MyOpenGLView.h.

Referenced by createSurface, endSplashScreen, init, and initSplashScreen.

◆ squareX

- (double) squareX
protected

Definition at line 206 of file MyOpenGLView.h.

Referenced by initialiseGLWithSize:useVideoMode:.

◆ squareY

- (double) squareY
protected

Definition at line 206 of file MyOpenGLView.h.

◆ suppressKeys

- (BOOL) suppressKeys
private

Definition at line 133 of file MyOpenGLView.h.

Referenced by isDown:, keyUp:, pollControls, and suppressKeysUntilKeyUp.

◆ surface

- (SDL_Surface*) surface
protected

◆ timeIntervalAtLastClick

- (NSTimeInterval) timeIntervalAtLastClick
private

Definition at line 146 of file MyOpenGLView.h.

Referenced by init, initWithFrame:, mouseUp:, and pollControls.

◆ timeIntervalAtLastMouseWheel

- (NSTimeInterval) timeIntervalAtLastMouseWheel
private

Definition at line 147 of file MyOpenGLView.h.

Referenced by scrollWheel:.

◆ timeSinceLastMouseWheel

- (NSTimeInterval) timeSinceLastMouseWheel
protected

Definition at line 193 of file MyOpenGLView.h.

Referenced by init, and pollControls.

◆ typedString

◆ viewSize

◆ virtualJoystickPosition

◆ x_offset

- (GLfloat) x_offset
private

Definition at line 644 of file MyOpenGLView.m.

645{
646 return x_offset;
647}

Referenced by initialiseGLWithSize:useVideoMode:, and x_offset.

◆ y_offset

- (GLfloat) y_offset
private

Definition at line 650 of file MyOpenGLView.m.

651{
652 return y_offset;
653}

Referenced by initialiseGLWithSize:useVideoMode:, and y_offset.


The documentation for this class was generated from the following files: