Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 9786 → Rev 9787

/contrib/sdk/sources/SDL-1.2.2_newlib/src/Tupfile.lua
20,7 → 20,7
"timer/",
"timer/dummy/",
"video/",
"video/menuetos/",
"video/kolibrios/",
"SYSCALL/src/"
}
 
/contrib/sdk/sources/SDL-1.2.2_newlib/src/video/menuetos/SDL_menuetvideo.h
File deleted
Property changes:
Deleted: svn:executable
-*
\ No newline at end of property
/contrib/sdk/sources/SDL-1.2.2_newlib/src/video/menuetos/SDL_menuetevents.c
File deleted
\ No newline at end of file
Property changes:
Deleted: svn:executable
-*
\ No newline at end of property
/contrib/sdk/sources/SDL-1.2.2_newlib/src/video/menuetos/SDL_menuetvideo.c
File deleted
Property changes:
Deleted: svn:executable
-*
\ No newline at end of property
/contrib/sdk/sources/SDL-1.2.2_newlib/src/video/SDL_sysvideo.h
387,7 → 387,7
extern VideoBootStrap CGX_bootstrap;
#endif
#ifdef ENABLE_KOLIBRIOS
extern VideoBootStrap mosvideo_bootstrab;
extern VideoBootStrap kos_video_bootstrab;
#endif
/* This is the current video device */
extern SDL_VideoDevice *current_video;
/contrib/sdk/sources/SDL-1.2.2_newlib/src/video/SDL_video.c
97,7 → 97,7
&ph_bootstrap,
#endif
#ifdef ENABLE_KOLIBRIOS
&mosvideo_bootstrab,
&kos_video_bootstrab,
#endif
NULL
};
/contrib/sdk/sources/SDL-1.2.2_newlib/src/video/kolibrios/SDL_kolibri_events.c
0,0 → 1,231
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/ksys.h>
 
#include "SDL.h"
#include "SDL_sysevents.h"
#include "SDL_sysvideo.h"
#include "SDL_events_c.h"
#include "SDL_kolibri_video.h"
 
extern void kos_SDL_RepaintWnd(void);
 
void kos_InitOSKeymap(_THIS)
{
_ksys_set_key_input_mode(KSYS_KEY_INPUT_MODE_SCANC);
}
 
#define SHIFT (LSHIFT+RSHIFT)
#define CTRL (LCTRL+RCTRL)
#define ALT (LALT+RALT)
 
static SDLMod GetModState(void)
{
unsigned controlstate = _ksys_get_control_key_state();
SDLMod 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;
}
 
static SDLKey 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_NUMLOCK, SDLK_SCROLLOCK, SDLK_KP7,
SDLK_KP8, SDLK_KP9, SDLK_KP_MINUS, SDLK_KP4, SDLK_KP5, SDLK_KP6, SDLK_KP_PLUS, SDLK_KP1,
// 0x5*
SDLK_KP2, SDLK_KP3, SDLK_KP0, 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 SDLKey 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_NUMLOCK, SDLK_SCROLLOCK, SDLK_KP7,
SDLK_KP8, SDLK_KP9, SDLK_KP_MINUS, SDLK_KP4, SDLK_KP5, SDLK_KP6, SDLK_KP_PLUS, SDLK_KP1,
// 0x5*
SDLK_KP2, SDLK_KP3, SDLK_KP0, 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 SDLKey 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_PRINT,
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, SDLK_LSUPER, SDLK_RSUPER, 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,
};
 
extern void kos_CheckMouseMode(_THIS);
 
void kos_PumpEvents(_THIS)
{
uint32_t kos_event;
ksys_pos_t mouse_pos;
ksys_pos_t center_pos;
SDL_keysym key;
static int ext_code = 0;
static uint8_t old_mode = 0;
// static uint32_t old_mouse_but = 0;
static uint32_t mouse_but = 0;
while (1) {
kos_event = _ksys_check_event();
switch (kos_event) {
case KSYS_EVENT_NONE:
return;
case KSYS_EVENT_REDRAW:
kos_SDL_RepaintWnd();
break;
case KSYS_EVENT_KEY:
key.scancode = _ksys_get_key().code;
if (key.scancode == 0xE0 || key.scancode == 0xE1) {
ext_code = key.scancode;
break;
}
if (ext_code == 0xE1 && (key.scancode & 0x7F) == 0x1D) {
break;
}
if (ext_code == 0xE1 && key.scancode == 0xC5) {
ext_code=0;
break;
}
key.mod = GetModState();
if (ext_code == 0xE1) key.mod &= ~KMOD_CTRL;
if (!(key.scancode & 0x80))
old_mode = key.mod;
SDL_SetModState(key.mod);
int code = (key.scancode & 0x80) ? SDL_RELEASED : SDL_PRESSED;
key.scancode &= 0x7F;
 
if (ext_code == 0xE1 && key.scancode == 0x45)
key.sym = SDLK_PAUSE;
else if (ext_code == 0xE0)
key.sym = sdlkeys_e0[key.scancode];
else if (old_mode & KMOD_SHIFT)
key.sym = sdlkeys_shift[key.scancode];
else
key.sym = sdlkeys[key.scancode];
 
key.unicode=key.sym;
ext_code = 0;
if (!key.sym) break;
 
SDL_PrivateKeyboard(code, &key);
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 < this->hidden->win_size_x &&
mouse_pos.y >= 0 && mouse_pos.y < this->hidden->win_size_y ||
this->input_grab != SDL_GRAB_OFF) {
if (this->input_grab != SDL_GRAB_OFF) {
center_pos.x = mouse_pos.x-this->hidden->win_size_x/2;
center_pos.y = mouse_pos.y-this->hidden->win_size_y/2;
if (center_pos.x || center_pos.y) {
SDL_PrivateMouseMotion(0, 1, center_pos.x, center_pos.y);
kos_CheckMouseMode(this);
}
} else {
SDL_PrivateMouseMotion(0, 0, mouse_pos.x, mouse_pos.y);
}
 
mouse_but = _ksys_get_mouse_buttons();
if (mouse_but & KSYS_MOUSE_LBUTTON_PRESSED) {
SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0);
return;
} else {
SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0);
}
if (mouse_but & KSYS_MOUSE_RBUTTON_PRESSED) {
SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0);
return;
} else {
SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0);
}
if (mouse_but & KSYS_MOUSE_MBUTTON_PRESSED) {
SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0);
return;
} else {
SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0);
}
}
}
}
}
}
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/contrib/sdk/sources/SDL-1.2.2_newlib/src/video/kolibrios/SDL_kolibri_video.c
0,0 → 1,285
#include <stdlib.h>
#include <stdio.h>
#include <sys/ksys.h>
#include "SDL.h"
#include "SDL_error.h"
#include "SDL_video.h"
#include "SDL_mouse.h"
#include "SDL_sysvideo.h"
#include "SDL_pixels_c.h"
#include "SDL_kolibri_video.h"
#include <string.h>
 
static SDL_VideoDevice * vm_suf=NULL;
static int was_initialized = 0;
static int scrn_size_defined = 0;
 
static int has_null_cursor=0;
static void* null_cursor;
 
#define WINDOW_BORDER_H 4
#define WINDOW_BORDER_W 9
 
ksys_pos_t screen_size = {0};
 
void kos_SDL_RepaintWnd(void)
{
int win_pos_x, win_pos_y;
int win_size_w = vm_suf->hidden->win_size_x+WINDOW_BORDER_W;
int win_size_h = vm_suf->hidden->win_size_y+_ksys_get_skin_height()+WINDOW_BORDER_H;
 
if (!screen_size.val) {
screen_size = _ksys_screen_size();
win_pos_x = screen_size.x/2-win_size_w/2;
win_pos_y = 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, vm_suf->hidden->__title, 0, 0x34);
 
if (vm_suf && vm_suf->hidden->__video_buffer) {
_ksys_draw_bitmap(vm_suf->hidden->__video_buffer, 0, 0,
vm_suf->hidden->win_size_x, vm_suf->hidden->win_size_y);
}
_ksys_end_draw();
}
 
static int kos_AllocHWSurface(_THIS,SDL_Surface * surface)
{
return -1;
}
 
static void kos_FreeHWSurface(_THIS,SDL_Surface * surface) {/*STUB*/}
 
static int kos_LockHWSurface(_THIS,SDL_Surface * surface)
{
return 0;
}
 
static void kos_UnlockHWSurface(_THIS,SDL_Surface * surface) {/*STUB*/}
 
static void kos_DirectUpdate(_THIS,int numrects,SDL_Rect * rects)
{
if (numrects) {
_ksys_draw_bitmap(this->hidden->__video_buffer, 0,0,
vm_suf->hidden->win_size_x,vm_suf->hidden->win_size_y);
}
}
 
int kos_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
{
return 0;
}
 
void kos_VideoQuit(_THIS)
{
if (has_null_cursor) {
_ksys_delete_cursor(null_cursor);
has_null_cursor = 0;
}
}
 
void kos_FinalQuit(void) {/*STUB*/}
 
void kos_SetCaption(_THIS,const char * title, const char * icon)
{
this->hidden->__title=(char *)title;
if (was_initialized) _ksys_set_window_title(title);
}
 
SDL_Surface *kos_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags)
{
int ly;
unsigned char* lx;
if (bpp!=24) return NULL;
current->flags=flags;
current->w=width;
current->h=height;
current->pitch=width*(bpp>>3);
char info[100];
sprintf(info, "width = %d, height = %d, pitch = %d, bpp = %d\n", current->w, current->h, current->pitch, bpp);
_ksys_debug_puts(info);
 
current->pixels=this->hidden->__video_buffer=realloc(this->hidden->__video_buffer, current->pitch*current->h);
this->hidden->__lines=(unsigned char **)realloc(this->hidden->__lines, sizeof(unsigned char *)*current->h);
 
for (ly=0, lx=current->pixels; ly<current->h; ly++, lx+=current->pitch)
this->hidden->__lines[ly]=lx;
 
this->UpdateRects=kos_DirectUpdate;
this->hidden->win_size_x=width;
this->hidden->win_size_y=height;
vm_suf=this;
 
if (was_initialized) {
unsigned newheight = height+_ksys_get_skin_height()+WINDOW_BORDER_H;
unsigned newwidth = width+WINDOW_BORDER_W;
int win_pos_x = screen_size.x/2-newwidth/2;
int win_pos_y = screen_size.y/2-newheight/2;
_ksys_change_window(win_pos_x, win_pos_y, newwidth, newheight);
} else {
_ksys_set_event_mask(0x27);
was_initialized=1;
kos_SDL_RepaintWnd();
}
return current;
}
 
/*static SDL_Rect video_mode[4];
static SDL_Rect * SDL_modelist[4]={NULL,NULL,NULL,NULL};*/
 
static SDL_Rect** kos_ListModes(_THIS,SDL_PixelFormat * fmt,Uint32 flags)
{
// return (&SDL_modelist[((fmt->BitsPerPixel+7)/8)-1]);
if (fmt->BitsPerPixel==24)
return (SDL_Rect**)-1;
else
return NULL;
}
 
static int kos_Available(void)
{
return 1;
}
 
static void kos_DeleteDevice(_THIS)
{
// free(this->hidden->__video_buffer); // it will be freed as current->pixels
free(this->hidden->__lines);
}
 
static int kos_VideoInit(_THIS,SDL_PixelFormat * vformat)
{
vformat->BitsPerPixel = 24;
vformat->BytesPerPixel = 3;
this->info.wm_available = 1;
this->info.hw_available = 0;
this->info.video_mem = 0x200000;
return 0;
}
 
static int kos_FlipHWSurface(_THIS,SDL_Surface * surface)
{
_ksys_draw_bitmap(surface->pixels, 0, 0, surface->w,surface->h);
return 0;
}
 
WMcursor* kos_CreateWMCursor(_THIS, Uint8* data, Uint8* mask, int w, int h, int hot_x, int hot_y)
{
int i,j;
Uint32* cursor;
WMcursor* res;
 
if (w>32 || h>32) return NULL;
if (w%8 || h%8) return NULL;
cursor = (Uint32*)malloc(32*32*4);
if (!cursor) return NULL;
for (i=0;i<32;i++) {
for (j=0;j<32;j++) {
if (i>=h || j>=w) {
cursor[i*32+j] = 0x00000000;
continue;
}
if (mask[i*w/8+j/8] & (0x80>>(j&7)))
cursor[i*32+j] = (data[i*w/8+j/8] & (0x80>>(j&7)))?0xFF000000:0xFFFFFFFF;
else
cursor[i*32+j] = 0x00000000;
}
}
res = _ksys_load_cursor(cursor, (hot_x<<24)+(hot_y<<16)+KSYS_CURSOR_INDIRECT);
free(cursor);
return res;
}
 
int kos_ShowWMCursor(_THIS, WMcursor* cursor)
{
if (!cursor) {
if (!has_null_cursor) {
unsigned* u = malloc(32*32*4);
if (!u) return 1;
memset(u, 0, 32*32*4);
null_cursor = _ksys_load_cursor(u, KSYS_CURSOR_INDIRECT);
free(u);
has_null_cursor = 1;
}
cursor = (WMcursor*)null_cursor;
}
_ksys_set_cursor(cursor);
return 1;
}
void kos_FreeWMCursor(_THIS, WMcursor* cursor)
{
_ksys_delete_cursor(cursor);
}
 
void kos_CheckMouseMode(_THIS)
{
if (this->input_grab == SDL_GRAB_OFF)
return;
ksys_thread_t thread_info;
int top = _ksys_thread_info(&thread_info, -1);
if (top == thread_info.pos_in_window_stack) {
int x = thread_info.winx_start + thread_info.clientx + this->hidden->win_size_x/2;
int y = thread_info.winy_start + thread_info.clienty + this->hidden->win_size_y/2;
_ksys_set_mouse_pos(x, y);
}
}
 
char def_title[] = "KolibriOS SDL App";
 
static SDL_VideoDevice *kos_CreateDevice(int indx)
{
SDL_VideoDevice * dev;
dev = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
if (dev) {
memset(dev,0,(sizeof *dev));
dev->hidden = (struct SDL_PrivateVideoData*)malloc((sizeof *dev->hidden));
}
 
if ((dev==NULL) || (dev->hidden==NULL)) {
SDL_OutOfMemory();
if(dev) {
free(dev);
}
return(0);
}
 
memset(dev->hidden, 0, (sizeof *dev->hidden));
dev->hidden->__title = def_title;
dev->VideoInit = kos_VideoInit;
dev->ListModes = kos_ListModes;
dev->SetVideoMode = kos_SetVideoMode;
dev->SetColors = kos_SetColors;
dev->UpdateRects = NULL;
dev->VideoQuit = kos_VideoQuit;
dev->AllocHWSurface=kos_AllocHWSurface;
dev->CheckHWBlit = NULL;
dev->FillHWRect = NULL;
dev->SetHWColorKey = NULL;
dev->SetHWAlpha = NULL;
dev->LockHWSurface = kos_LockHWSurface;
dev->UnlockHWSurface = kos_UnlockHWSurface;
dev->FlipHWSurface = kos_FlipHWSurface;
dev->FreeHWSurface = kos_FreeHWSurface;
dev->SetCaption = kos_SetCaption;
dev->SetIcon = NULL;
dev->IconifyWindow = NULL;
dev->GrabInput = NULL;
dev->GetWMInfo = NULL;
dev->InitOSKeymap = kos_InitOSKeymap;
dev->PumpEvents = kos_PumpEvents;
dev->free = kos_DeleteDevice;
dev->CreateWMCursor = kos_CreateWMCursor;
dev->FreeWMCursor = kos_FreeWMCursor;
dev->ShowWMCursor = kos_ShowWMCursor;
dev->CheckMouseMode = kos_CheckMouseMode;
return dev;
}
 
VideoBootStrap kos_video_bootstrab = {
"kolibrios", "KolibriOS Device Driver",
kos_Available, kos_CreateDevice,
};
Property changes:
Added: svn:executable
+*
\ No newline at end of property
/contrib/sdk/sources/SDL-1.2.2_newlib/src/video/kolibrios/SDL_kolibri_video.h
0,0 → 1,20
#ifndef _SDL_kolibri_video_h
#define _SDL_kolibri_video_h
 
#include "SDL_mouse.h"
#include "SDL_sysvideo.h"
 
#define _THIS SDL_VideoDevice *this
 
struct SDL_PrivateVideoData {
unsigned char * __video_buffer;
char * __title;
int win_size_x,win_size_y;
int vx_ofs,vy_ofs;
unsigned char** __lines;
};
 
void kos_InitOSKeymap(_THIS);
void kos_PumpEvents(_THIS);
 
#endif
Property changes:
Added: svn:executable
+*
\ No newline at end of property