mirror of
https://github.com/arnavbhatt288/sdl-2.30.3-kolibri.git
synced 2025-09-21 02:50:08 +02:00
5
Makefile
5
Makefile
@@ -80,8 +80,9 @@ video_OBJS = src/video/SDL_blit_0.o src/video/SDL_blit_1.o src/video/SDL_blit_A.
|
|||||||
src/video/SDL_shape.o src/video/SDL_stretch.o src/video/SDL_surface.o \
|
src/video/SDL_shape.o src/video/SDL_stretch.o src/video/SDL_surface.o \
|
||||||
src/video/SDL_video.o src/video/SDL_yuv.o src/video/yuv2rgb/yuv_rgb_lsx.o \
|
src/video/SDL_video.o src/video/SDL_yuv.o src/video/yuv2rgb/yuv_rgb_lsx.o \
|
||||||
src/video/yuv2rgb/yuv_rgb_sse.o src/video/yuv2rgb/yuv_rgb_std.o \
|
src/video/yuv2rgb/yuv_rgb_sse.o src/video/yuv2rgb/yuv_rgb_std.o \
|
||||||
src/video/dummy/SDL_nullevents.o src/video/dummy/SDL_nullframebuffer.o \
|
src/video/kolibri/SDL_kolibrievents.o src/video/kolibri/SDL_kolibriframebuffer.o \
|
||||||
src/video/dummy/SDL_nullvideo.o
|
src/video/kolibri/SDL_kolibrivideo.o src/video/kolibri/SDL_kolibriwindow.o \
|
||||||
|
src/video/kolibri/SDL_kolibrimouse.o
|
||||||
|
|
||||||
curr_OBJS = src/SDL_assert.o src/SDL_dataqueue.o src/SDL_error.o src/SDL_guid.o \
|
curr_OBJS = src/SDL_assert.o src/SDL_dataqueue.o src/SDL_error.o src/SDL_guid.o \
|
||||||
src/SDL_hints.o src/SDL_list.o src/SDL_log.o src/SDL_utils.o src/SDL.o
|
src/SDL_hints.o src/SDL_list.o src/SDL_log.o src/SDL_utils.o src/SDL.o
|
||||||
|
@@ -46,7 +46,6 @@
|
|||||||
#define HAVE_TAN 1
|
#define HAVE_TAN 1
|
||||||
#define HAVE_MALLOC 1
|
#define HAVE_MALLOC 1
|
||||||
#define LACKS_SYS_MMAN_H 1
|
#define LACKS_SYS_MMAN_H 1
|
||||||
|
|
||||||
#define HAVE_MALLOC 1
|
#define HAVE_MALLOC 1
|
||||||
#define HAVE_CALLOC 1
|
#define HAVE_CALLOC 1
|
||||||
#define HAVE_REALLOC 1
|
#define HAVE_REALLOC 1
|
||||||
@@ -96,8 +95,8 @@
|
|||||||
/* Enable the dummy timer support (src/timer/dummy/\*.c) */
|
/* Enable the dummy timer support (src/timer/dummy/\*.c) */
|
||||||
#define SDL_TIMER_DUMMY 1
|
#define SDL_TIMER_DUMMY 1
|
||||||
|
|
||||||
/* Enable the dummy video driver (src/video/dummy/\*.c) */
|
/* Enable the Kolibri video driver (src/video/kolibri/\*.c) */
|
||||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
#define SDL_VIDEO_DRIVER_KOLIBRI 1
|
||||||
|
|
||||||
/* Enable the Kolibri audio driver (src/audio/kolibri/\*.c) */
|
/* Enable the Kolibri audio driver (src/audio/kolibri/\*.c) */
|
||||||
#define SDL_AUDIO_DRIVER_KOLIBRI 1
|
#define SDL_AUDIO_DRIVER_KOLIBRI 1
|
||||||
|
@@ -24,10 +24,10 @@
|
|||||||
#define SDL_sysvideo_h_
|
#define SDL_sysvideo_h_
|
||||||
|
|
||||||
#include "SDL_messagebox.h"
|
#include "SDL_messagebox.h"
|
||||||
|
#include "SDL_metal.h"
|
||||||
#include "SDL_mouse.h"
|
#include "SDL_mouse.h"
|
||||||
#include "SDL_shape.h"
|
#include "SDL_shape.h"
|
||||||
#include "SDL_thread.h"
|
#include "SDL_thread.h"
|
||||||
#include "SDL_metal.h"
|
|
||||||
|
|
||||||
#include "SDL_vulkan_internal.h"
|
#include "SDL_vulkan_internal.h"
|
||||||
|
|
||||||
@@ -484,6 +484,7 @@ extern VideoBootStrap OFFSCREEN_bootstrap;
|
|||||||
extern VideoBootStrap NGAGE_bootstrap;
|
extern VideoBootStrap NGAGE_bootstrap;
|
||||||
extern VideoBootStrap OS2DIVE_bootstrap;
|
extern VideoBootStrap OS2DIVE_bootstrap;
|
||||||
extern VideoBootStrap OS2VMAN_bootstrap;
|
extern VideoBootStrap OS2VMAN_bootstrap;
|
||||||
|
extern VideoBootStrap KOLIBRI_bootstrap;
|
||||||
|
|
||||||
/* Use SDL_OnVideoThread() sparingly, to avoid regressions in use cases that currently happen to work */
|
/* Use SDL_OnVideoThread() sparingly, to avoid regressions in use cases that currently happen to work */
|
||||||
extern SDL_bool SDL_OnVideoThread(void);
|
extern SDL_bool SDL_OnVideoThread(void);
|
||||||
|
@@ -23,14 +23,14 @@
|
|||||||
|
|
||||||
/* The high-level video driver subsystem */
|
/* The high-level video driver subsystem */
|
||||||
|
|
||||||
|
#include "../events/SDL_events_c.h"
|
||||||
|
#include "../timer/SDL_timer_c.h"
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
#include "SDL_video.h"
|
|
||||||
#include "SDL_sysvideo.h"
|
|
||||||
#include "SDL_blit.h"
|
#include "SDL_blit.h"
|
||||||
#include "SDL_pixels_c.h"
|
#include "SDL_pixels_c.h"
|
||||||
#include "SDL_rect_c.h"
|
#include "SDL_rect_c.h"
|
||||||
#include "../events/SDL_events_c.h"
|
#include "SDL_sysvideo.h"
|
||||||
#include "../timer/SDL_timer_c.h"
|
#include "SDL_video.h"
|
||||||
|
|
||||||
#include "SDL_syswm.h"
|
#include "SDL_syswm.h"
|
||||||
|
|
||||||
@@ -58,10 +58,10 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __LINUX__
|
#ifdef __LINUX__
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Available video drivers */
|
/* Available video drivers */
|
||||||
@@ -144,6 +144,9 @@ static VideoBootStrap *bootstrap[] = {
|
|||||||
#ifdef SDL_INPUT_LINUXEV
|
#ifdef SDL_INPUT_LINUXEV
|
||||||
&DUMMY_evdev_bootstrap,
|
&DUMMY_evdev_bootstrap,
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
#ifdef SDL_VIDEO_DRIVER_KOLIBRI
|
||||||
|
&KOLIBRI_bootstrap,
|
||||||
#endif
|
#endif
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
@@ -2878,7 +2881,6 @@ int SDL_SetWindowInputFocus(SDL_Window *window)
|
|||||||
return _this->SetWindowInputFocus(_this, window);
|
return _this->SetWindowInputFocus(_this, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SDL_SetWindowGammaRamp(SDL_Window *window, const Uint16 *red,
|
int SDL_SetWindowGammaRamp(SDL_Window *window, const Uint16 *red,
|
||||||
const Uint16 *green,
|
const Uint16 *green,
|
||||||
const Uint16 *blue)
|
const Uint16 *blue)
|
||||||
@@ -4513,10 +4515,7 @@ int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *messag
|
|||||||
if (!message) {
|
if (!message) {
|
||||||
message = "";
|
message = "";
|
||||||
}
|
}
|
||||||
EM_ASM({
|
EM_ASM({ alert(UTF8ToString($0) + "\n\n" + UTF8ToString($1)); }, title, message);
|
||||||
alert(UTF8ToString($0) + "\n\n" + UTF8ToString($1));
|
|
||||||
},
|
|
||||||
title, message);
|
|
||||||
return 0;
|
return 0;
|
||||||
#else
|
#else
|
||||||
SDL_MessageBoxData data;
|
SDL_MessageBoxData data;
|
||||||
|
357
src/video/kolibri/SDL_kolibrievents.c
Normal file
357
src/video/kolibri/SDL_kolibrievents.c
Normal file
@@ -0,0 +1,357 @@
|
|||||||
|
|
||||||
|
#include "../../SDL_internal.h"
|
||||||
|
|
||||||
|
#ifdef SDL_VIDEO_DRIVER_KOLIBRI
|
||||||
|
|
||||||
|
#include <sys/ksys.h>
|
||||||
|
|
||||||
|
#include "SDL.h"
|
||||||
|
|
||||||
|
#include "../../events/SDL_events_c.h"
|
||||||
|
#include "../../events/SDL_keyboard_c.h"
|
||||||
|
#include "../SDL_sysvideo.h"
|
||||||
|
|
||||||
|
#include "SDL_kolibrievents.h"
|
||||||
|
#include "SDL_kolibrivideo.h"
|
||||||
|
#include "SDL_kolibriwindow.h"
|
||||||
|
|
||||||
|
static SDL_Keycode sdlkeys[0x80] = {
|
||||||
|
// 0x0*
|
||||||
|
0, SDLK_ESCAPE, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6,
|
||||||
|
SDLK_7, SDLK_8, SDLK_9, SDLK_0, SDLK_MINUS, SDLK_EQUALS, SDLK_BACKSPACE, SDLK_TAB,
|
||||||
|
// 0x1*
|
||||||
|
SDLK_q, SDLK_w, SDLK_e, SDLK_r, SDLK_t, SDLK_y, SDLK_u, SDLK_i,
|
||||||
|
SDLK_o, SDLK_p, SDLK_LEFTBRACKET, SDLK_RIGHTBRACKET, SDLK_RETURN, SDLK_LCTRL, SDLK_a, SDLK_s,
|
||||||
|
// 0x2*
|
||||||
|
SDLK_d, SDLK_f, SDLK_g, SDLK_h, SDLK_j, SDLK_k, SDLK_l, SDLK_SEMICOLON,
|
||||||
|
SDLK_QUOTE, SDLK_BACKQUOTE, SDLK_LSHIFT, SDLK_BACKSLASH, SDLK_z, SDLK_x, SDLK_c, SDLK_v,
|
||||||
|
// 0x3*
|
||||||
|
SDLK_b, SDLK_n, SDLK_m, SDLK_COMMA, SDLK_PERIOD, SDLK_SLASH, SDLK_RSHIFT, SDLK_KP_MULTIPLY,
|
||||||
|
SDLK_LALT, SDLK_SPACE, SDLK_CAPSLOCK, SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5,
|
||||||
|
// 0x4*
|
||||||
|
SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9, SDLK_F10, SDLK_NUMLOCKCLEAR, SDLK_SCROLLLOCK, SDLK_KP_7,
|
||||||
|
SDLK_KP_8, SDLK_KP_9, SDLK_KP_MINUS, SDLK_KP_4, SDLK_KP_5, SDLK_KP_6, SDLK_KP_PLUS, SDLK_KP_1,
|
||||||
|
// 0x5*
|
||||||
|
SDLK_KP_2, SDLK_KP_3, SDLK_KP_0, SDLK_KP_PERIOD, 0, 0, 0, SDLK_F11,
|
||||||
|
SDLK_F12, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
// 0x6*
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
// 0x7*
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
static SDL_Keycode sdlkeys_shift[0x80] = {
|
||||||
|
// 0x0*
|
||||||
|
0, SDLK_ESCAPE, SDLK_EXCLAIM, SDLK_AT, SDLK_HASH, SDLK_DOLLAR, '%', SDLK_CARET,
|
||||||
|
SDLK_AMPERSAND, SDLK_ASTERISK, SDLK_LEFTPAREN, SDLK_RIGHTPAREN, SDLK_UNDERSCORE, SDLK_PLUS, SDLK_BACKSPACE, SDLK_TAB,
|
||||||
|
// 0x1*
|
||||||
|
SDLK_q, SDLK_w, SDLK_e, SDLK_r, SDLK_t, SDLK_y, SDLK_u, SDLK_i,
|
||||||
|
SDLK_o, SDLK_p, '{', '}', SDLK_RETURN, SDLK_LCTRL, SDLK_a, SDLK_s,
|
||||||
|
// 0x2*
|
||||||
|
SDLK_d, SDLK_f, SDLK_g, SDLK_h, SDLK_j, SDLK_k, SDLK_l, SDLK_COLON,
|
||||||
|
SDLK_QUOTEDBL, '~', SDLK_LSHIFT, '|', SDLK_z, SDLK_x, SDLK_c, SDLK_v,
|
||||||
|
// 0x3*
|
||||||
|
SDLK_b, SDLK_n, SDLK_m, SDLK_LESS, SDLK_GREATER, SDLK_QUESTION, SDLK_RSHIFT, SDLK_KP_MULTIPLY,
|
||||||
|
SDLK_LALT, SDLK_SPACE, SDLK_CAPSLOCK, SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5,
|
||||||
|
// 0x4*
|
||||||
|
SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9, SDLK_F10, SDLK_NUMLOCKCLEAR, SDLK_SCROLLLOCK, SDLK_KP_7,
|
||||||
|
SDLK_KP_8, SDLK_KP_9, SDLK_KP_MINUS, SDLK_KP_4, SDLK_KP_5, SDLK_KP_6, SDLK_KP_PLUS, SDLK_KP_1,
|
||||||
|
// 0x5*
|
||||||
|
SDLK_KP_2, SDLK_KP_3, SDLK_KP_0, SDLK_KP_PERIOD, 0, 0, 0, SDLK_F11,
|
||||||
|
SDLK_F12, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
// 0x6*
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
// 0x7*
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
static SDL_Keycode sdlkeys_e0[0x80] = {
|
||||||
|
// 0x0*
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
// 0x1*
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
SDLK_KP_ENTER,
|
||||||
|
SDLK_RCTRL,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
// 0x2*
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
// 0x3*
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
SDLK_KP_DIVIDE,
|
||||||
|
0,
|
||||||
|
SDLK_PRINTSCREEN,
|
||||||
|
SDLK_RALT,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
// 0x4*
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
SDLK_HOME,
|
||||||
|
SDLK_UP,
|
||||||
|
SDLK_PAGEUP,
|
||||||
|
0,
|
||||||
|
SDLK_LEFT,
|
||||||
|
0,
|
||||||
|
SDLK_RIGHT,
|
||||||
|
0,
|
||||||
|
SDLK_END,
|
||||||
|
// 0x5*
|
||||||
|
SDLK_DOWN,
|
||||||
|
SDLK_PAGEDOWN,
|
||||||
|
SDLK_INSERT,
|
||||||
|
SDLK_DELETE,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
SDLK_MENU,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
// 0x6*
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
// 0x7*
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
|
||||||
|
static SDL_Keymod SDL_KOLIBRI_get_mod_state(void)
|
||||||
|
{
|
||||||
|
unsigned controlstate = _ksys_get_control_key_state();
|
||||||
|
SDL_Keymod res = 0;
|
||||||
|
if (controlstate & KSYS_CONTROL_LSHIFT)
|
||||||
|
res |= KMOD_LSHIFT;
|
||||||
|
if (controlstate & KSYS_CONTROL_RSHIFT)
|
||||||
|
res |= KMOD_RSHIFT;
|
||||||
|
if (controlstate & KSYS_CONTROL_LCTRL)
|
||||||
|
res |= KMOD_LCTRL;
|
||||||
|
if (controlstate & KSYS_CONTROL_RCTRL)
|
||||||
|
res |= KMOD_RCTRL;
|
||||||
|
if (controlstate & KSYS_CONTROL_LALT)
|
||||||
|
res |= KMOD_LALT;
|
||||||
|
if (controlstate & KSYS_CONTROL_RALT)
|
||||||
|
res |= KMOD_RALT;
|
||||||
|
if (controlstate & KSYS_CONTROL_CAPS)
|
||||||
|
res |= KMOD_CAPS;
|
||||||
|
if (controlstate & KSYS_CONTROL_NUM_LOCK)
|
||||||
|
res |= KMOD_NUM;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KOLIBRI_InitOSKeymap(void)
|
||||||
|
{
|
||||||
|
_ksys_set_key_input_mode(KSYS_KEY_INPUT_MODE_SCANC);
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void kos_CheckMouseMode(_THIS);
|
||||||
|
|
||||||
|
void KOLIBRI_PumpEvents(_THIS)
|
||||||
|
{
|
||||||
|
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
|
||||||
|
SDL_Window *window = SDL_GetWindowFromID(data->window_id);
|
||||||
|
uint32_t kos_event;
|
||||||
|
ksys_pos_t mouse_pos;
|
||||||
|
ksys_pos_t center_pos;
|
||||||
|
ksys_thread_t thread_info;
|
||||||
|
int scancode = 0;
|
||||||
|
int pressed = 0;
|
||||||
|
SDL_Keycode keycode = SDLK_UNKNOWN;
|
||||||
|
SDL_Keymod mod = 0;
|
||||||
|
static int ext_code = 0;
|
||||||
|
static uint8_t old_mode = 0;
|
||||||
|
static uint32_t old_mouse_but = 0;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
kos_event = _ksys_check_event();
|
||||||
|
switch (kos_event) {
|
||||||
|
case KSYS_EVENT_NONE:
|
||||||
|
return;
|
||||||
|
case KSYS_EVENT_REDRAW:
|
||||||
|
KOLIBRI_RepaintWnd(_this);
|
||||||
|
break;
|
||||||
|
case KSYS_EVENT_KEY:
|
||||||
|
scancode = _ksys_get_key().code;
|
||||||
|
if (scancode == 0xE0 || scancode == 0xE1) {
|
||||||
|
ext_code = scancode;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ext_code == 0xE1 && (scancode & 0x7F) == 0x1D) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ext_code == 0xE1 && scancode == 0xC5) {
|
||||||
|
ext_code = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mod = SDL_KOLIBRI_get_mod_state();
|
||||||
|
if (ext_code == 0xE1)
|
||||||
|
mod &= ~KMOD_CTRL;
|
||||||
|
if (!(scancode & 0x80))
|
||||||
|
old_mode = mod;
|
||||||
|
SDL_SetModState(mod);
|
||||||
|
|
||||||
|
pressed = (scancode & 0x80) ? SDL_RELEASED : SDL_PRESSED;
|
||||||
|
scancode &= 0x7F;
|
||||||
|
|
||||||
|
if (ext_code == 0xE1 && scancode == 0x45)
|
||||||
|
keycode = SDLK_PAUSE;
|
||||||
|
else if (ext_code == 0xE0)
|
||||||
|
keycode = sdlkeys_e0[scancode];
|
||||||
|
else if (old_mode & KMOD_SHIFT)
|
||||||
|
keycode = sdlkeys_shift[scancode];
|
||||||
|
else
|
||||||
|
keycode = sdlkeys[scancode];
|
||||||
|
|
||||||
|
ext_code = 0;
|
||||||
|
if (!keycode)
|
||||||
|
break;
|
||||||
|
|
||||||
|
SDL_SendKeyboardKey(pressed, SDL_GetScancodeFromKey(keycode));
|
||||||
|
break;
|
||||||
|
case KSYS_EVENT_BUTTON:
|
||||||
|
if (_ksys_get_button() == 1)
|
||||||
|
exit(0);
|
||||||
|
break;
|
||||||
|
case KSYS_EVENT_MOUSE:
|
||||||
|
{
|
||||||
|
mouse_pos = _ksys_get_mouse_pos(KSYS_MOUSE_WINDOW_POS);
|
||||||
|
if (mouse_pos.x >= 0 && mouse_pos.x < window->w && mouse_pos.y >= 0 && mouse_pos.y < window->h || SDL_GetMouse()->relative_mode) {
|
||||||
|
if (SDL_GetMouse()->relative_mode) {
|
||||||
|
center_pos.x = mouse_pos.x - window->w / 2;
|
||||||
|
center_pos.y = mouse_pos.y - window->h / 2;
|
||||||
|
if (center_pos.x || center_pos.y) {
|
||||||
|
SDL_SendMouseMotion(window, 0, SDL_TRUE, center_pos.x, center_pos.y);
|
||||||
|
|
||||||
|
int top = _ksys_thread_info(&thread_info, KSYS_THIS_SLOT);
|
||||||
|
if (top == thread_info.pos_in_window_stack) {
|
||||||
|
int x = thread_info.winx_start + thread_info.clientx + window->w / 2;
|
||||||
|
int y = thread_info.winy_start + thread_info.clienty + window->h / 2;
|
||||||
|
_ksys_set_mouse_pos(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
SDL_SendMouseMotion(window, 0, SDL_FALSE, mouse_pos.x, mouse_pos.y);
|
||||||
|
|
||||||
|
uint32_t mouse_but = _ksys_get_mouse_buttons();
|
||||||
|
if ((mouse_but ^ old_mouse_but) & KSYS_MOUSE_LBUTTON_PRESSED) {
|
||||||
|
if (mouse_but & KSYS_MOUSE_LBUTTON_PRESSED)
|
||||||
|
SDL_SendMouseButton(window, 0, SDL_PRESSED, SDL_BUTTON_LEFT);
|
||||||
|
else
|
||||||
|
SDL_SendMouseButton(window, 0, SDL_RELEASED, SDL_BUTTON_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((mouse_but ^ old_mouse_but) & KSYS_MOUSE_RBUTTON_PRESSED) {
|
||||||
|
if (mouse_but & KSYS_MOUSE_RBUTTON_PRESSED)
|
||||||
|
SDL_SendMouseButton(window, 0, SDL_PRESSED, SDL_BUTTON_RIGHT);
|
||||||
|
else
|
||||||
|
SDL_SendMouseButton(window, 0, SDL_RELEASED, SDL_BUTTON_RIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((mouse_but ^ old_mouse_but) & KSYS_MOUSE_MBUTTON_PRESSED) {
|
||||||
|
if (mouse_but & KSYS_MOUSE_MBUTTON_PRESSED)
|
||||||
|
SDL_SendMouseButton(window, 0, SDL_PRESSED, SDL_BUTTON_MIDDLE);
|
||||||
|
else
|
||||||
|
SDL_SendMouseButton(window, 0, SDL_RELEASED, SDL_BUTTON_MIDDLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
old_mouse_but = mouse_but;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
10
src/video/kolibri/SDL_kolibrievents.h
Normal file
10
src/video/kolibri/SDL_kolibrievents.h
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
#ifndef SDL_kolibrievents_c_h_
|
||||||
|
#define SDL_kolibrievents_c_h_
|
||||||
|
|
||||||
|
#include "../../SDL_internal.h"
|
||||||
|
|
||||||
|
extern void KOLIBRI_InitOSKeymap(void);
|
||||||
|
extern void KOLIBRI_PumpEvents(_THIS);
|
||||||
|
|
||||||
|
#endif
|
70
src/video/kolibri/SDL_kolibriframebuffer.c
Normal file
70
src/video/kolibri/SDL_kolibriframebuffer.c
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
|
||||||
|
#include "../../SDL_internal.h"
|
||||||
|
|
||||||
|
#ifdef SDL_VIDEO_DRIVER_KOLIBRI
|
||||||
|
|
||||||
|
#include <sys/ksys.h>
|
||||||
|
|
||||||
|
#include "SDL.h"
|
||||||
|
|
||||||
|
#include "../SDL_sysvideo.h"
|
||||||
|
|
||||||
|
#include "SDL_kolibriframebuffer.h"
|
||||||
|
#include "SDL_kolibrivideo.h"
|
||||||
|
#include "SDL_kolibriwindow.h"
|
||||||
|
|
||||||
|
void FreeOldFramebuffer(SDL_Window *window)
|
||||||
|
{
|
||||||
|
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||||
|
SDL_FreeSurface(data->surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
int SDL_KOLIBRI_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch)
|
||||||
|
{
|
||||||
|
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||||
|
SDL_Surface *surface;
|
||||||
|
const Uint32 surface_format = SDL_PIXELFORMAT_RGB24;
|
||||||
|
int w, h;
|
||||||
|
|
||||||
|
/* Free the old framebuffer surface */
|
||||||
|
FreeOldFramebuffer(window);
|
||||||
|
|
||||||
|
/* Create a new one */
|
||||||
|
SDL_GetWindowSizeInPixels(window, &w, &h);
|
||||||
|
surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format);
|
||||||
|
if (!surface)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
/* Save the info and return! */
|
||||||
|
data->surface = surface;
|
||||||
|
*format = surface_format;
|
||||||
|
*pixels = surface->pixels;
|
||||||
|
*pitch = surface->pitch;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SDL_KOLIBRI_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
|
||||||
|
{
|
||||||
|
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||||
|
SDL_Surface *surface;
|
||||||
|
|
||||||
|
static int frame_number;
|
||||||
|
|
||||||
|
surface = data->surface;
|
||||||
|
if (!surface)
|
||||||
|
return SDL_SetError("Couldn't find surface for window");
|
||||||
|
|
||||||
|
/* Send the data to the display */
|
||||||
|
_ksys_draw_bitmap(surface->pixels, 0, 0, surface->w, surface->h);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SDL_KOLIBRI_DestroyWindowFramebuffer(_THIS, SDL_Window *window)
|
||||||
|
{
|
||||||
|
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
|
||||||
|
SDL_Surface *surface;
|
||||||
|
|
||||||
|
SDL_FreeSurface(data->surface);
|
||||||
|
data->surface = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
11
src/video/kolibri/SDL_kolibriframebuffer.h
Normal file
11
src/video/kolibri/SDL_kolibriframebuffer.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
#include "../../SDL_internal.h"
|
||||||
|
|
||||||
|
#ifndef SDL_kolibriframebuffer_h_
|
||||||
|
#define SDL_kolibriframebuffer_h_
|
||||||
|
|
||||||
|
extern int SDL_KOLIBRI_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, void **pixels, int *pitch);
|
||||||
|
extern int SDL_KOLIBRI_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects);
|
||||||
|
extern void SDL_KOLIBRI_DestroyWindowFramebuffer(_THIS, SDL_Window *window);
|
||||||
|
|
||||||
|
#endif
|
141
src/video/kolibri/SDL_kolibrimouse.c
Normal file
141
src/video/kolibri/SDL_kolibrimouse.c
Normal file
@@ -0,0 +1,141 @@
|
|||||||
|
|
||||||
|
#include "../../SDL_internal.h"
|
||||||
|
|
||||||
|
#ifdef SDL_VIDEO_DRIVER_KOLIBRI
|
||||||
|
|
||||||
|
#include <sys/ksys.h>
|
||||||
|
|
||||||
|
#include "SDL_hints.h"
|
||||||
|
#include "SDL_surface.h"
|
||||||
|
|
||||||
|
#include "../../events/SDL_mouse_c.h"
|
||||||
|
#include "../../events/default_cursor.h"
|
||||||
|
#include "../SDL_sysvideo.h"
|
||||||
|
|
||||||
|
#include "SDL_kolibrimouse.h"
|
||||||
|
#include "SDL_kolibrivideo.h"
|
||||||
|
|
||||||
|
static SDL_Cursor *KOLIBRI_CreateDefaultCursor(void)
|
||||||
|
{
|
||||||
|
KOLIBRI_CursorData *curdata;
|
||||||
|
SDL_Cursor *cursor;
|
||||||
|
Uint32 *temp;
|
||||||
|
|
||||||
|
cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor));
|
||||||
|
if (!cursor) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
curdata = (KOLIBRI_CursorData *)SDL_calloc(1, sizeof(*curdata));
|
||||||
|
if (!curdata) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
SDL_free(cursor);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert default SDL cursor to 32x32 */
|
||||||
|
temp = (Uint32 *)SDL_malloc(32 * 32 * 4);
|
||||||
|
if (!temp)
|
||||||
|
return NULL;
|
||||||
|
for (int i = 0; i < 32; i++) {
|
||||||
|
for (int j = 0; j < 32; j++) {
|
||||||
|
if (i >= 16 || j >= 16) {
|
||||||
|
temp[i * 32 + j] = 0x00000000;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (default_cmask[i * 16 / 8 + j / 8] & (0x80 >> (j & 7)))
|
||||||
|
temp[i * 32 + j] = (default_cdata[i * 16 / 8 + j / 8] & (0x80 >> (j & 7)))
|
||||||
|
? 0xFF000000
|
||||||
|
: 0xFFFFFFFF;
|
||||||
|
else
|
||||||
|
temp[i * 32 + j] = 0x00000000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
curdata->cursor = _ksys_load_cursor(temp, (DEFAULT_CHOTX << 24) + (DEFAULT_CHOTY << 16) + KSYS_CURSOR_INDIRECT);
|
||||||
|
cursor->driverdata = curdata;
|
||||||
|
SDL_free(temp);
|
||||||
|
|
||||||
|
return cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Create a cursor from a surface */
|
||||||
|
static SDL_Cursor *KOLIBRI_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y)
|
||||||
|
{
|
||||||
|
KOLIBRI_CursorData *curdata;
|
||||||
|
SDL_Cursor *cursor;
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
/* Size of cursor must be 32x32 */
|
||||||
|
if (surface->w == 32 || surface->h == 32) {
|
||||||
|
SDL_SetError("Size of the cursor must be 32x32");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor));
|
||||||
|
if (!cursor) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
curdata = (KOLIBRI_CursorData *)SDL_calloc(1, sizeof(*curdata));
|
||||||
|
if (!curdata) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
SDL_free(cursor);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
curdata->cursor = _ksys_load_cursor(surface->pixels, (hot_x << 24) + (hot_y << 16) + KSYS_CURSOR_INDIRECT);
|
||||||
|
cursor->driverdata = curdata;
|
||||||
|
|
||||||
|
return cursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int KOLIBRI_ShowCursor(SDL_Cursor *cursor)
|
||||||
|
{
|
||||||
|
KOLIBRI_CursorData *curdata;
|
||||||
|
if (cursor) {
|
||||||
|
curdata = (KOLIBRI_CursorData *)cursor->driverdata;
|
||||||
|
if (!curdata->cursor) {
|
||||||
|
if (!curdata->has_null_cursor) {
|
||||||
|
unsigned *u = SDL_malloc(32 * 32 * 4);
|
||||||
|
if (!u)
|
||||||
|
return 0;
|
||||||
|
SDL_memset(u, 0, 32 * 32 * 4);
|
||||||
|
curdata->null_cursor = _ksys_load_cursor(u, KSYS_CURSOR_INDIRECT);
|
||||||
|
free(u);
|
||||||
|
curdata->has_null_cursor = 1;
|
||||||
|
}
|
||||||
|
curdata->cursor = curdata->null_cursor;
|
||||||
|
}
|
||||||
|
_ksys_set_cursor(curdata->cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void KOLIBRI_FreeCursor(SDL_Cursor *cursor)
|
||||||
|
{
|
||||||
|
KOLIBRI_CursorData *curdata;
|
||||||
|
|
||||||
|
if (cursor) {
|
||||||
|
curdata = (KOLIBRI_CursorData *)cursor->driverdata;
|
||||||
|
if (curdata) {
|
||||||
|
SDL_free(curdata->cursor);
|
||||||
|
SDL_free(curdata);
|
||||||
|
}
|
||||||
|
SDL_free(cursor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KOLIBRI_InitMouse(void)
|
||||||
|
{
|
||||||
|
SDL_Mouse *mouse = SDL_GetMouse();
|
||||||
|
|
||||||
|
mouse->CreateCursor = KOLIBRI_CreateCursor;
|
||||||
|
mouse->ShowCursor = KOLIBRI_ShowCursor;
|
||||||
|
mouse->FreeCursor = KOLIBRI_FreeCursor;
|
||||||
|
|
||||||
|
SDL_SetDefaultCursor(KOLIBRI_CreateDefaultCursor());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
16
src/video/kolibri/SDL_kolibrimouse.h
Normal file
16
src/video/kolibri/SDL_kolibrimouse.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
#include "../../SDL_internal.h"
|
||||||
|
|
||||||
|
#ifndef SDL_kolibrimouse_h_
|
||||||
|
#define SDL_kolibrimouse_h_
|
||||||
|
|
||||||
|
typedef struct _KOLIBRI_CursorData
|
||||||
|
{
|
||||||
|
int has_null_cursor;
|
||||||
|
void *cursor;
|
||||||
|
void *null_cursor;
|
||||||
|
} KOLIBRI_CursorData;
|
||||||
|
|
||||||
|
extern void KOLIBRI_InitMouse(void);
|
||||||
|
|
||||||
|
#endif
|
110
src/video/kolibri/SDL_kolibrivideo.c
Normal file
110
src/video/kolibri/SDL_kolibrivideo.c
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
|
||||||
|
#include "../../SDL_internal.h"
|
||||||
|
|
||||||
|
#ifdef SDL_VIDEO_DRIVER_KOLIBRI
|
||||||
|
|
||||||
|
#include <sys/ksys.h>
|
||||||
|
|
||||||
|
#include "../../events/SDL_events_c.h"
|
||||||
|
#include "../SDL_pixels_c.h"
|
||||||
|
#include "../SDL_sysvideo.h"
|
||||||
|
#include "SDL_video.h"
|
||||||
|
|
||||||
|
#include "SDL_kolibrievents.h"
|
||||||
|
#include "SDL_kolibriframebuffer.h"
|
||||||
|
#include "SDL_kolibrimouse.h"
|
||||||
|
#include "SDL_kolibrivideo.h"
|
||||||
|
#include "SDL_kolibriwindow.h"
|
||||||
|
|
||||||
|
#define KOLIBRIVID_DRIVER_NAME "kolibri"
|
||||||
|
|
||||||
|
static void KOLIBRI_DeleteDevice(SDL_VideoDevice *device)
|
||||||
|
{
|
||||||
|
SDL_free(device->driverdata);
|
||||||
|
SDL_free(device);
|
||||||
|
}
|
||||||
|
|
||||||
|
int KOLIBRI_VideoInit(_THIS)
|
||||||
|
{
|
||||||
|
SDL_DisplayMode mode;
|
||||||
|
SDL_VideoData *data = _this->driverdata;
|
||||||
|
data->screen_size = _ksys_screen_size();
|
||||||
|
|
||||||
|
/* Use 24-bpp desktop mode */
|
||||||
|
mode.format = SDL_PIXELFORMAT_RGB24;
|
||||||
|
mode.w = data->screen_size.x;
|
||||||
|
mode.h = data->screen_size.y;
|
||||||
|
mode.refresh_rate = 0;
|
||||||
|
mode.driverdata = NULL;
|
||||||
|
if (SDL_AddBasicVideoDisplay(&mode) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
SDL_zero(mode);
|
||||||
|
SDL_AddDisplayMode(&_this->displays[0], &mode);
|
||||||
|
|
||||||
|
KOLIBRI_InitMouse();
|
||||||
|
KOLIBRI_InitOSKeymap();
|
||||||
|
|
||||||
|
/* We're done! */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int KOLIBRI_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KOLIBRI_VideoQuit(_THIS)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static SDL_VideoDevice *KOLIBRI_CreateDevice(void)
|
||||||
|
{
|
||||||
|
SDL_VideoDevice *device;
|
||||||
|
SDL_VideoData *data;
|
||||||
|
|
||||||
|
/* Initialize all variables that we clean on shutdown */
|
||||||
|
device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice));
|
||||||
|
if (!device) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Initialize internal Kolibri specific data */
|
||||||
|
data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData));
|
||||||
|
if (!data) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
SDL_free(device);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* General video */
|
||||||
|
device->VideoInit = KOLIBRI_VideoInit;
|
||||||
|
device->VideoQuit = KOLIBRI_VideoQuit;
|
||||||
|
device->SetDisplayMode = KOLIBRI_SetDisplayMode;
|
||||||
|
device->PumpEvents = KOLIBRI_PumpEvents;
|
||||||
|
device->free = KOLIBRI_DeleteDevice;
|
||||||
|
|
||||||
|
/* Framebuffer */
|
||||||
|
device->CreateWindowFramebuffer = SDL_KOLIBRI_CreateWindowFramebuffer;
|
||||||
|
device->UpdateWindowFramebuffer = SDL_KOLIBRI_UpdateWindowFramebuffer;
|
||||||
|
device->DestroyWindowFramebuffer = SDL_KOLIBRI_DestroyWindowFramebuffer;
|
||||||
|
|
||||||
|
/* "Window" */
|
||||||
|
device->CreateSDLWindow = KOLIBRI_CreateWindow;
|
||||||
|
device->SetWindowTitle = KOLIBRI_SetWindowTitle;
|
||||||
|
device->DestroyWindow = KOLIBRI_DestroyWindow;
|
||||||
|
|
||||||
|
/* KolibriOS specific data */
|
||||||
|
device->driverdata = data;
|
||||||
|
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
|
VideoBootStrap KOLIBRI_bootstrap = {
|
||||||
|
KOLIBRIVID_DRIVER_NAME, "SDL kolibri video driver",
|
||||||
|
KOLIBRI_CreateDevice,
|
||||||
|
NULL /* no ShowMessageBox implementation */
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
11
src/video/kolibri/SDL_kolibrivideo.h
Normal file
11
src/video/kolibri/SDL_kolibrivideo.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
#ifndef _SDL_kolibri_video_h
|
||||||
|
#define _SDL_kolibri_video_h
|
||||||
|
|
||||||
|
typedef struct SDL_VideoData
|
||||||
|
{
|
||||||
|
Uint32 window_id;
|
||||||
|
ksys_pos_t screen_size;
|
||||||
|
} SDL_VideoData;
|
||||||
|
|
||||||
|
#endif
|
73
src/video/kolibri/SDL_kolibriwindow.c
Normal file
73
src/video/kolibri/SDL_kolibriwindow.c
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
|
||||||
|
#include "../../SDL_internal.h"
|
||||||
|
|
||||||
|
#ifdef SDL_VIDEO_DRIVER_KOLIBRI
|
||||||
|
|
||||||
|
#include <sys/ksys.h>
|
||||||
|
|
||||||
|
#include "../../events/SDL_keyboard_c.h"
|
||||||
|
#include "../../events/SDL_mouse_c.h"
|
||||||
|
#include "../SDL_sysvideo.h"
|
||||||
|
|
||||||
|
#include "SDL_kolibrivideo.h"
|
||||||
|
#include "SDL_kolibriwindow.h"
|
||||||
|
|
||||||
|
#define WINDOW_BORDER_H 4
|
||||||
|
#define WINDOW_BORDER_W 9
|
||||||
|
|
||||||
|
void KOLIBRI_RepaintWnd(_THIS)
|
||||||
|
{
|
||||||
|
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
|
||||||
|
SDL_Window *window = SDL_GetWindowFromID(data->window_id);
|
||||||
|
SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata;
|
||||||
|
int win_pos_x, win_pos_y;
|
||||||
|
int win_size_w, win_size_h;
|
||||||
|
|
||||||
|
win_size_w = window->w + WINDOW_BORDER_W;
|
||||||
|
win_size_h = window->h + _ksys_get_skin_height() + WINDOW_BORDER_H;
|
||||||
|
win_pos_x = data->screen_size.x / 2 - win_size_w / 2;
|
||||||
|
win_pos_y = data->screen_size.y / 2 - win_size_h / 2;
|
||||||
|
|
||||||
|
_ksys_start_draw();
|
||||||
|
_ksys_create_window(win_pos_x, win_pos_y, win_size_w, win_size_h, window->title, 0, 0x34);
|
||||||
|
if (wdata->surface->pixels)
|
||||||
|
_ksys_draw_bitmap(wdata->surface->pixels, 0, 0, wdata->surface->w, wdata->surface->h);
|
||||||
|
_ksys_end_draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
int KOLIBRI_CreateWindow(_THIS, SDL_Window *window)
|
||||||
|
{
|
||||||
|
SDL_VideoData *data = (SDL_VideoData *)_this->driverdata;
|
||||||
|
SDL_WindowData *wdata;
|
||||||
|
|
||||||
|
/* Allocate window internal data */
|
||||||
|
wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData));
|
||||||
|
if (!wdata)
|
||||||
|
return SDL_OutOfMemory();
|
||||||
|
|
||||||
|
/* Setup driver data for this window */
|
||||||
|
window->driverdata = wdata;
|
||||||
|
data->window_id = SDL_GetWindowID(window);
|
||||||
|
|
||||||
|
_ksys_set_event_mask(0x27);
|
||||||
|
KOLIBRI_RepaintWnd(_this);
|
||||||
|
|
||||||
|
SDL_SetMouseFocus(window);
|
||||||
|
SDL_SetKeyboardFocus(window);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KOLIBRI_SetWindowTitle(_THIS, SDL_Window *window)
|
||||||
|
{
|
||||||
|
_ksys_set_window_title(window->title);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KOLIBRI_DestroyWindow(_THIS, SDL_Window *window)
|
||||||
|
{
|
||||||
|
if (!window)
|
||||||
|
return;
|
||||||
|
SDL_free(window->driverdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
18
src/video/kolibri/SDL_kolibriwindow.h
Normal file
18
src/video/kolibri/SDL_kolibriwindow.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
|
||||||
|
#include "../../SDL_internal.h"
|
||||||
|
|
||||||
|
#ifndef SDL_kolibriwindow_h_
|
||||||
|
#define SDL_kolibriwindow_h_
|
||||||
|
|
||||||
|
typedef struct SDL_WindowData
|
||||||
|
{
|
||||||
|
SDL_Surface *surface;
|
||||||
|
} SDL_WindowData;
|
||||||
|
|
||||||
|
extern int KOLIBRI_CreateWindow(_THIS, SDL_Window *window);
|
||||||
|
extern void KOLIBRI_RepaintWnd(_THIS);
|
||||||
|
extern void KOLIBRI_SetWindowTitle(_THIS, SDL_Window *window);
|
||||||
|
extern void KOLIBRI_DestroyWindow(_THIS, SDL_Window *window);
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user