1 /*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "../../SDL_internal.h"
22
23 #if SDL_VIDEO_DRIVER_HAIKU
24
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #include "SDL_bkeyboard.h"
31 #include "SDL_bwindow.h"
32 #include "SDL_bclipboard.h"
33 #include "SDL_bvideo.h"
34 #include "SDL_bopengl.h"
35 #include "SDL_bmodes.h"
36 #include "SDL_bframebuffer.h"
37 #include "SDL_bevents.h"
38
39 /* FIXME: Undefined functions */
40 // #define BE_PumpEvents NULL
41 #define BE_StartTextInput NULL
42 #define BE_StopTextInput NULL
43 #define BE_SetTextInputRect NULL
44
45 // #define BE_DeleteDevice NULL
46
47 /* End undefined functions */
48
49 static SDL_VideoDevice *
BE_CreateDevice(int devindex)50 BE_CreateDevice(int devindex)
51 {
52 SDL_VideoDevice *device;
53 /*SDL_VideoData *data;*/
54
55 /* Initialize all variables that we clean on shutdown */
56 device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
57
58 device->driverdata = NULL; /* FIXME: Is this the cause of some of the
59 SDL_Quit() errors? */
60
61 /* TODO: Figure out if any initialization needs to go here */
62
63 /* Set the function pointers */
64 device->VideoInit = BE_VideoInit;
65 device->VideoQuit = BE_VideoQuit;
66 device->GetDisplayBounds = BE_GetDisplayBounds;
67 device->GetDisplayModes = BE_GetDisplayModes;
68 device->SetDisplayMode = BE_SetDisplayMode;
69 device->PumpEvents = BE_PumpEvents;
70
71 device->CreateWindow = BE_CreateWindow;
72 device->CreateWindowFrom = BE_CreateWindowFrom;
73 device->SetWindowTitle = BE_SetWindowTitle;
74 device->SetWindowIcon = BE_SetWindowIcon;
75 device->SetWindowPosition = BE_SetWindowPosition;
76 device->SetWindowSize = BE_SetWindowSize;
77 device->ShowWindow = BE_ShowWindow;
78 device->HideWindow = BE_HideWindow;
79 device->RaiseWindow = BE_RaiseWindow;
80 device->MaximizeWindow = BE_MaximizeWindow;
81 device->MinimizeWindow = BE_MinimizeWindow;
82 device->RestoreWindow = BE_RestoreWindow;
83 device->SetWindowBordered = BE_SetWindowBordered;
84 device->SetWindowResizable = BE_SetWindowResizable;
85 device->SetWindowFullscreen = BE_SetWindowFullscreen;
86 device->SetWindowGammaRamp = BE_SetWindowGammaRamp;
87 device->GetWindowGammaRamp = BE_GetWindowGammaRamp;
88 device->SetWindowGrab = BE_SetWindowGrab;
89 device->DestroyWindow = BE_DestroyWindow;
90 device->GetWindowWMInfo = BE_GetWindowWMInfo;
91 device->CreateWindowFramebuffer = BE_CreateWindowFramebuffer;
92 device->UpdateWindowFramebuffer = BE_UpdateWindowFramebuffer;
93 device->DestroyWindowFramebuffer = BE_DestroyWindowFramebuffer;
94
95 device->shape_driver.CreateShaper = NULL;
96 device->shape_driver.SetWindowShape = NULL;
97 device->shape_driver.ResizeWindowShape = NULL;
98
99
100 device->GL_LoadLibrary = BE_GL_LoadLibrary;
101 device->GL_GetProcAddress = BE_GL_GetProcAddress;
102 device->GL_UnloadLibrary = BE_GL_UnloadLibrary;
103 device->GL_CreateContext = BE_GL_CreateContext;
104 device->GL_MakeCurrent = BE_GL_MakeCurrent;
105 device->GL_SetSwapInterval = BE_GL_SetSwapInterval;
106 device->GL_GetSwapInterval = BE_GL_GetSwapInterval;
107 device->GL_SwapWindow = BE_GL_SwapWindow;
108 device->GL_DeleteContext = BE_GL_DeleteContext;
109
110 device->StartTextInput = BE_StartTextInput;
111 device->StopTextInput = BE_StopTextInput;
112 device->SetTextInputRect = BE_SetTextInputRect;
113
114 device->SetClipboardText = BE_SetClipboardText;
115 device->GetClipboardText = BE_GetClipboardText;
116 device->HasClipboardText = BE_HasClipboardText;
117
118 device->free = BE_DeleteDevice;
119
120 return device;
121 }
122
123 VideoBootStrap HAIKU_bootstrap = {
124 "haiku", "Haiku graphics",
125 BE_Available, BE_CreateDevice
126 };
127
BE_DeleteDevice(SDL_VideoDevice * device)128 void BE_DeleteDevice(SDL_VideoDevice * device)
129 {
130 SDL_free(device->driverdata);
131 SDL_free(device);
132 }
133
BE_VideoInit(_THIS)134 int BE_VideoInit(_THIS)
135 {
136 /* Initialize the Be Application for appserver interaction */
137 if (SDL_InitBeApp() < 0) {
138 return -1;
139 }
140
141 /* Initialize video modes */
142 BE_InitModes(_this);
143
144 /* Init the keymap */
145 BE_InitOSKeymap();
146
147
148 #if SDL_VIDEO_OPENGL
149 /* testgl application doesn't load library, just tries to load symbols */
150 /* is it correct? if so we have to load library here */
151 BE_GL_LoadLibrary(_this, NULL);
152 #endif
153
154 /* We're done! */
155 return (0);
156 }
157
BE_Available(void)158 int BE_Available(void)
159 {
160 return (1);
161 }
162
BE_VideoQuit(_THIS)163 void BE_VideoQuit(_THIS)
164 {
165
166 BE_QuitModes(_this);
167
168 SDL_QuitBeApp();
169 }
170
171 #ifdef __cplusplus
172 }
173 #endif
174
175 #endif /* SDL_VIDEO_DRIVER_HAIKU */
176