Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 9784 → Rev 9785

/contrib/sdk/sources/SDL-1.2.2_newlib/src/timer/dummy/SDL_systimer.c
33,7 → 33,7
#include "SDL_error.h"
#include "SDL_timer.h"
#include "SDL_timer_c.h"
#include "kos32sys.h"
#include <sys/ksys.h>
 
#if _POSIX_THREAD_SYSCALL_SOFT
#include <pthread.h>
43,45 → 43,17
#define USE_ITIMER
#endif
 
 
/* The first ticks value of the application */
//static struct timeval start;
//static unsigned startlo,starthi;
//static unsigned clockrate;
static unsigned starttime;
 
void SDL_StartTicks(void)
{
// gettimeofday(&start, NULL);
// __asm__ ("int $0x40" : "=a"(clockrate) : "a"(18),"b"(5));
// __asm__ ("rdtsc" : "=a"(startlo),"=d"(starthi));
__asm__ ("int $0x40" : "=a"(starttime) : "a"(26),"b"(9));
starttime = _ksys_get_tick_count();
}
 
 
Uint32 SDL_GetTicks (void)
{
/* struct timeval now;
Uint32 ticks;
gettimeofday(&now, NULL);
ticks=(now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000;
return(ticks);*/
/*int res;
__asm__ ("rdtsc\n\t"
"sub (_startlo),%%eax\n\t"
"sbb (_starthi),%%edx\n\t"
"push %%eax\n\t"
"mov %%edx,%%eax\n\t"
"mov $1000,%%ecx\n\t"
"mul %%ecx\n\t"
"xchg (%%esp),%%eax\n\t"
"mul %%ecx\n\t"
"add %%edx,(%%esp)\n\t"
"pop %%edx\n\t"
"divl (_clockrate)\n\t" : "=a"(res));
return res;*/
unsigned curtime;
__asm__ ("int $0x40" : "=a"(curtime) : "a"(26),"b"(9));
unsigned curtime = _ksys_get_tick_count();
return (curtime-starttime)*10;
}
 
88,7 → 60,7
void SDL_Delay(unsigned ms){
unsigned start = SDL_GetTicks();
do{
delay(1);
_ksys_delay(1);
}while (SDL_GetTicks()-start < ms);
}
 
/contrib/sdk/sources/SDL-1.2.2_newlib/src/video/menuetos/SDL_menuetevents.c
1,8 → 1,8
#include <menuet/os.h>
#include <kos32sys.h>
#include <sys/ksys.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/ksys.h>
 
#include "SDL.h"
#include "SDL_sysevents.h"
#include "SDL_sysvideo.h"
11,21 → 11,11
 
extern void kos_SDL_RepaintWnd(void);
 
void MenuetOS_InitOSKeymap(_THIS)
void kos_InitOSKeymap(_THIS)
{
__asm__("int $0x40"::"a"(66),"b"(1),"c"(1));
_ksys_set_key_input_mode(KSYS_KEY_INPUT_MODE_SCANC);
}
 
#define LSHIFT 1
#define RSHIFT 2
#define LCTRL 4
#define RCTRL 8
#define LALT 0x10
#define RALT 0x20
#define CAPS 0x40
#define NUML 0x80
#define SCRL 0x100
 
#define SHIFT (LSHIFT+RSHIFT)
#define CTRL (LCTRL+RCTRL)
#define ALT (LALT+RALT)
32,49 → 22,27
 
static SDLMod GetModState(void)
{
unsigned controlstate;
__asm__("int $0x40":"=a"(controlstate):"a"(66),"b"(3));
unsigned controlstate = _ksys_get_control_key_state();
SDLMod res = 0;
if (controlstate & LSHIFT)
if (controlstate & KSYS_CONTROL_LSHIFT)
res |= KMOD_LSHIFT;
if (controlstate & RSHIFT)
if (controlstate & KSYS_CONTROL_RSHIFT)
res |= KMOD_RSHIFT;
if (controlstate & LCTRL)
if (controlstate & KSYS_CONTROL_LCTRL)
res |= KMOD_LCTRL;
if (controlstate & RCTRL)
if (controlstate & KSYS_CONTROL_RCTRL)
res |= KMOD_RCTRL;
if (controlstate & LALT)
if (controlstate & KSYS_CONTROL_LALT)
res |= KMOD_LALT;
if (controlstate & RALT)
if (controlstate & KSYS_CONTROL_RALT)
res |= KMOD_RALT;
if (controlstate & CAPS)
if (controlstate & KSYS_CONTROL_CAPS)
res |= KMOD_CAPS;
if (controlstate & NUML)
if (controlstate & KSYS_CONTROL_NUM_LOCK)
res |= KMOD_NUM;
return res;
}
 
/*static __u8 scan2ascii(__u8 n,SDLMod mod)
{
__u8 layout[128];
int layouttype;
int bControlLayout = 0;
if (mod & KMOD_ALT)
layouttype = 3;
else if (mod & KMOD_SHIFT)
layouttype = 2;
else
{
if (mod & KMOD_CTRL)
bControlLayout = 1;
layouttype = 1;
}
__asm__("int $0x40" :: "a"(26),"b"(2),"c"(layouttype),"d"(layout));
__u8 res = layout[n];
if (bControlLayout)
res -= 0x60;
return res;
}*/
static SDLKey sdlkeys[0x80] =
{
// 0x0*
102,6 → 70,7
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
 
static SDLKey sdlkeys_shift[0x80] =
{
// 0x0*
129,6 → 98,7
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
};
 
static SDLKey sdlkeys_e0[0x80] =
{
// 0x0*
157,29 → 127,42
0, 0, 0, 0, 0, 0, 0, 0,
};
 
extern void KolibriOS_CheckMouseMode(_THIS);
void MenuetOS_PumpEvents(_THIS)
extern void kos_CheckMouseMode(_THIS);
 
void kos_PumpEvents(_THIS)
{
int i;
uint32_t kos_event;
ksys_pos_t mouse_pos;
ksys_pos_t center_pos;
SDL_keysym key;
static int ext_code=0;
static __u8 old_mode=0;
for (;;) {
i=__menuet__check_for_event();
switch(i)
{
case 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 1:
case KSYS_EVENT_REDRAW:
kos_SDL_RepaintWnd();
break;
case 2:
key.scancode = __menuet__getkey();
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;}
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;
186,7 → 169,7
SDL_SetModState(key.mod);
int code = (key.scancode & 0x80) ? SDL_RELEASED : SDL_PRESSED;
key.scancode &= 0x7F;
// key.sym = scan2ascii(key.scancode,key.mod);
 
if (ext_code == 0xE1 && key.scancode == 0x45)
key.sym = SDLK_PAUSE;
else if (ext_code == 0xE0)
195,56 → 178,54
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 3:
if (_ksys_get_button()==1) {
SDL_CloseAudio();
exit(0);
}
case KSYS_EVENT_BUTTON:
if (_ksys_get_button() == 1) exit(0);
break;
case 6: {
int __tmp,mx,my;
static int oldmousestate = 0;
__asm__("int $0x40":"=a"(__tmp):"a"(37),"b"(1));
mx=(__tmp>>16);
my=(__tmp&0xffff);
if(mx>=0 && mx<this->hidden->win_size_x &&
my>=0 && my<this->hidden->win_size_y || this->input_grab != SDL_GRAB_OFF)
{
if (this->input_grab != SDL_GRAB_OFF)
{
int dx=mx-this->hidden->win_size_x/2;
int dy=my-this->hidden->win_size_y/2;
if (dx||dy)
{
SDL_PrivateMouseMotion(0,1,dx,dy);
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);
}
else
SDL_PrivateMouseMotion(0,0,mx,my);
__asm__("int $0x40":"=a"(__tmp):"a"(37),"b"(2));
if ((__tmp^oldmousestate)&1) {
if(__tmp&1)
{
 
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 ((__tmp^oldmousestate)&2) {
if(__tmp&2)
{
}
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);
} }
oldmousestate = __tmp;
}
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);
}
}
}
}
}
}
/contrib/sdk/sources/SDL-1.2.2_newlib/src/video/menuetos/SDL_menuetvideo.c
219,8 → 219,9
if (this->input_grab == SDL_GRAB_OFF)
return;
ksys_thread_t thread_info;
int res = _ksys_thread_info(&thread_info, -1);
if (res == thread_info.window_pos_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);
268,8 → 269,8
dev->IconifyWindow = NULL;
dev->GrabInput = NULL;
dev->GetWMInfo = NULL;
dev->InitOSKeymap = MenuetOS_InitOSKeymap;
dev->PumpEvents = MenuetOS_PumpEvents;
dev->InitOSKeymap = kos_InitOSKeymap;
dev->PumpEvents = kos_PumpEvents;
dev->free = kos_DeleteDevice;
dev->CreateWMCursor = kos_CreateWMCursor;
dev->FreeWMCursor = kos_FreeWMCursor;
/contrib/sdk/sources/SDL-1.2.2_newlib/src/video/menuetos/SDL_menuetvideo.h
14,7 → 14,7
unsigned char** __lines;
};
 
void MenuetOS_InitOSKeymap(_THIS);
void MenuetOS_PumpEvents(_THIS);
void kos_InitOSKeymap(_THIS);
void kos_PumpEvents(_THIS);
 
#endif