SDL  2.0
SDL_bvideo.cc
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2020 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 #include "../../main/haiku/SDL_BApp.h"
23 
24 #if SDL_VIDEO_DRIVER_HAIKU
25 
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #include "SDL_bkeyboard.h"
32 #include "SDL_bwindow.h"
33 #include "SDL_bclipboard.h"
34 #include "SDL_bvideo.h"
35 #include "SDL_bopengl.h"
36 #include "SDL_bmodes.h"
37 #include "SDL_bframebuffer.h"
38 #include "SDL_bevents.h"
39 
40 /* FIXME: Undefined functions */
41 // #define HAIKU_PumpEvents NULL
42  #define HAIKU_StartTextInput NULL
43  #define HAIKU_StopTextInput NULL
44  #define HAIKU_SetTextInputRect NULL
45 
46 // #define HAIKU_DeleteDevice NULL
47 
48 /* End undefined functions */
49 
50 static SDL_VideoDevice *
51 HAIKU_CreateDevice(int devindex)
52 {
54  /*SDL_VideoData *data;*/
55 
56  /* Initialize all variables that we clean on shutdown */
58 
59  device->driverdata = NULL; /* FIXME: Is this the cause of some of the
60  SDL_Quit() errors? */
61 
62 /* TODO: Figure out if any initialization needs to go here */
63 
64  /* Set the function pointers */
65  device->VideoInit = HAIKU_VideoInit;
66  device->VideoQuit = HAIKU_VideoQuit;
67  device->GetDisplayBounds = HAIKU_GetDisplayBounds;
68  device->GetDisplayModes = HAIKU_GetDisplayModes;
69  device->SetDisplayMode = HAIKU_SetDisplayMode;
70  device->PumpEvents = HAIKU_PumpEvents;
71 
72  device->CreateSDLWindow = HAIKU_CreateWindow;
73  device->CreateSDLWindowFrom = HAIKU_CreateWindowFrom;
74  device->SetWindowTitle = HAIKU_SetWindowTitle;
75  device->SetWindowIcon = HAIKU_SetWindowIcon;
76  device->SetWindowPosition = HAIKU_SetWindowPosition;
77  device->SetWindowSize = HAIKU_SetWindowSize;
78  device->ShowWindow = HAIKU_ShowWindow;
79  device->HideWindow = HAIKU_HideWindow;
80  device->RaiseWindow = HAIKU_RaiseWindow;
81  device->MaximizeWindow = HAIKU_MaximizeWindow;
82  device->MinimizeWindow = HAIKU_MinimizeWindow;
83  device->RestoreWindow = HAIKU_RestoreWindow;
84  device->SetWindowBordered = HAIKU_SetWindowBordered;
85  device->SetWindowResizable = HAIKU_SetWindowResizable;
86  device->SetWindowFullscreen = HAIKU_SetWindowFullscreen;
87  device->SetWindowGammaRamp = HAIKU_SetWindowGammaRamp;
88  device->GetWindowGammaRamp = HAIKU_GetWindowGammaRamp;
89  device->SetWindowGrab = HAIKU_SetWindowGrab;
90  device->DestroyWindow = HAIKU_DestroyWindow;
91  device->GetWindowWMInfo = HAIKU_GetWindowWMInfo;
92  device->CreateWindowFramebuffer = HAIKU_CreateWindowFramebuffer;
93  device->UpdateWindowFramebuffer = HAIKU_UpdateWindowFramebuffer;
94  device->DestroyWindowFramebuffer = HAIKU_DestroyWindowFramebuffer;
95 
96  device->shape_driver.CreateShaper = NULL;
97  device->shape_driver.SetWindowShape = NULL;
98  device->shape_driver.ResizeWindowShape = NULL;
99 
100 #if SDL_VIDEO_OPENGL
101  device->GL_LoadLibrary = HAIKU_GL_LoadLibrary;
102  device->GL_GetProcAddress = HAIKU_GL_GetProcAddress;
103  device->GL_UnloadLibrary = HAIKU_GL_UnloadLibrary;
104  device->GL_CreateContext = HAIKU_GL_CreateContext;
105  device->GL_MakeCurrent = HAIKU_GL_MakeCurrent;
106  device->GL_SetSwapInterval = HAIKU_GL_SetSwapInterval;
107  device->GL_GetSwapInterval = HAIKU_GL_GetSwapInterval;
108  device->GL_SwapWindow = HAIKU_GL_SwapWindow;
109  device->GL_DeleteContext = HAIKU_GL_DeleteContext;
110 #endif
111 
112  device->StartTextInput = HAIKU_StartTextInput;
113  device->StopTextInput = HAIKU_StopTextInput;
114  device->SetTextInputRect = HAIKU_SetTextInputRect;
115 
116  device->SetClipboardText = HAIKU_SetClipboardText;
117  device->GetClipboardText = HAIKU_GetClipboardText;
118  device->HasClipboardText = HAIKU_HasClipboardText;
119 
120  device->free = HAIKU_DeleteDevice;
121 
122  return device;
123 }
124 
126  "haiku", "Haiku graphics",
127  HAIKU_Available, HAIKU_CreateDevice
128 };
129 
131 {
132  SDL_free(device->driverdata);
133  SDL_free(device);
134 }
135 
136 static int HAIKU_ShowCursor(SDL_Cursor *cur)
137 {
138  SDL_Mouse *mouse = SDL_GetMouse();
139  int show;
140  if (!mouse)
141  return 0;
142  show = (cur || !mouse->focus);
143  if (show) {
144  if (be_app->IsCursorHidden())
145  be_app->ShowCursor();
146  } else {
147  if (!be_app->IsCursorHidden())
148  be_app->HideCursor();
149  }
150  return 0;
151 }
152 
153 static void HAIKU_MouseInit(_THIS)
154 {
155  SDL_Mouse *mouse = SDL_GetMouse();
156  if (!mouse)
157  return;
158  mouse->ShowCursor = HAIKU_ShowCursor;
159  mouse->cur_cursor = (SDL_Cursor*)0x1;
160  mouse->def_cursor = (SDL_Cursor*)0x2;
161 }
162 
164 {
165  /* Initialize the Be Application for appserver interaction */
166  if (SDL_InitBeApp() < 0) {
167  return -1;
168  }
169 
170  /* Initialize video modes */
172 
173  /* Init the keymap */
175 
176  HAIKU_MouseInit(_this);
177 
178 #if SDL_VIDEO_OPENGL
179  /* testgl application doesn't load library, just tries to load symbols */
180  /* is it correct? if so we have to load library here */
181  HAIKU_GL_LoadLibrary(_this, NULL);
182 #endif
183 
184  /* We're done! */
185  return (0);
186 }
187 
188 int HAIKU_Available(void)
189 {
190  return (1);
191 }
192 
194 {
195 
197 
198  SDL_QuitBeApp();
199 }
200 
201 #ifdef __cplusplus
202 }
203 #endif
204 
205 #endif /* SDL_VIDEO_DRIVER_HAIKU */
206 
207 /* vi: set ts=4 sw=4 expandtab: */
SDL_GetMouse
SDL_Mouse * SDL_GetMouse(void)
Definition: SDL_mouse.c:170
HAIKU_SetWindowTitle
void HAIKU_SetWindowTitle(_THIS, SDL_Window *window)
SDL_bframebuffer.h
SDL_InitBeApp
int SDL_InitBeApp(void)
HAIKU_CreateWindow
int HAIKU_CreateWindow(_THIS, SDL_Window *window)
HAIKU_QuitModes
int HAIKU_QuitModes(_THIS)
HAIKU_InitModes
int HAIKU_InitModes(_THIS)
HAIKU_RaiseWindow
void HAIKU_RaiseWindow(_THIS, SDL_Window *window)
SDL_Cursor
Definition: SDL_mouse_c.h:31
HAIKU_MinimizeWindow
void HAIKU_MinimizeWindow(_THIS, SDL_Window *window)
HAIKU_SetWindowGammaRamp
int HAIKU_SetWindowGammaRamp(_THIS, SDL_Window *window, const Uint16 *ramp)
NULL
#define NULL
Definition: begin_code.h:167
HAIKU_CreateWindowFrom
int HAIKU_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
HAIKU_Available
int HAIKU_Available(void)
HAIKU_VideoInit
int HAIKU_VideoInit(_THIS)
SDL_bmodes.h
HAIKU_RestoreWindow
void HAIKU_RestoreWindow(_THIS, SDL_Window *window)
x1
GLuint GLfloat GLfloat GLfloat x1
Definition: SDL_opengl_glext.h:8586
HAIKU_SetWindowGrab
void HAIKU_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
SDL_bevents.h
HAIKU_SetWindowResizable
void HAIKU_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable)
HAIKU_MaximizeWindow
void HAIKU_MaximizeWindow(_THIS, SDL_Window *window)
HAIKU_PumpEvents
void HAIKU_PumpEvents(_THIS)
HAIKU_SetClipboardText
int HAIKU_SetClipboardText(_THIS, const char *text)
_this
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
HAIKU_VideoQuit
void HAIKU_VideoQuit(_THIS)
HAIKU_ShowWindow
void HAIKU_ShowWindow(_THIS, SDL_Window *window)
HAIKU_GetWindowWMInfo
SDL_bool HAIKU_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
SDL_bwindow.h
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
SDL_QuitBeApp
void SDL_QuitBeApp(void)
HAIKU_InitOSKeymap
void HAIKU_InitOSKeymap(void)
HAIKU_SetWindowIcon
void HAIKU_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
HAIKU_DestroyWindow
void HAIKU_DestroyWindow(_THIS, SDL_Window *window)
SDL_Mouse::def_cursor
SDL_Cursor * def_cursor
Definition: SDL_mouse_c.h:104
HAIKU_CreateWindowFramebuffer
int HAIKU_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
HAIKU_GetWindowGammaRamp
int HAIKU_GetWindowGammaRamp(_THIS, SDL_Window *window, Uint16 *ramp)
_THIS
#define _THIS
Definition: SDL_alsa_audio.h:31
HAIKU_SetWindowSize
void HAIKU_SetWindowSize(_THIS, SDL_Window *window)
HAIKU_UpdateWindowFramebuffer
int HAIKU_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
SDL_Mouse
Definition: SDL_mouse_c.h:44
HAIKU_SetWindowBordered
void HAIKU_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
SDL_Mouse::focus
SDL_Window * focus
Definition: SDL_mouse_c.h:77
HAIKU_SetWindowPosition
void HAIKU_SetWindowPosition(_THIS, SDL_Window *window)
SDL_VideoDevice
Definition: SDL_sysvideo.h:150
SDL_Mouse::ShowCursor
int(* ShowCursor)(SDL_Cursor *cursor)
Definition: SDL_mouse_c.h:52
HAIKU_GetClipboardText
char * HAIKU_GetClipboardText(_THIS)
HAIKU_bootstrap
VideoBootStrap HAIKU_bootstrap
SDL_bopengl.h
SDL_calloc
#define SDL_calloc
Definition: SDL_dynapi_overrides.h:375
HAIKU_GetDisplayBounds
int HAIKU_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect)
HAIKU_HasClipboardText
SDL_bool HAIKU_HasClipboardText(_THIS)
x2
GLfixed GLfixed x2
Definition: SDL_opengl_glext.h:4586
HAIKU_SetDisplayMode
int HAIKU_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
SDL_bkeyboard.h
SDL_bclipboard.h
SDL_bvideo.h
HAIKU_HideWindow
void HAIKU_HideWindow(_THIS, SDL_Window *window)
HAIKU_DeleteDevice
void HAIKU_DeleteDevice(_THIS)
HAIKU_SetWindowFullscreen
void HAIKU_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
VideoBootStrap
Definition: SDL_sysvideo.h:406
device
static SDL_AudioDeviceID device
Definition: loopwave.c:37
HAIKU_GetDisplayModes
void HAIKU_GetDisplayModes(_THIS, SDL_VideoDisplay *display)
HAIKU_DestroyWindowFramebuffer
void HAIKU_DestroyWindowFramebuffer(_THIS, SDL_Window *window)
SDL_Mouse::cur_cursor
SDL_Cursor * cur_cursor
Definition: SDL_mouse_c.h:105