- Refactoring;
 - Fixed mouse bug;
 - Added middle mouse button support.


git-svn-id: svn://kolibrios.org@9785 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2022-04-25 19:55:00 +00:00
parent 2f58880d77
commit 1d446821e9
4 changed files with 216 additions and 262 deletions

View File

@ -33,7 +33,7 @@ static char rcsid =
#include "SDL_error.h" #include "SDL_error.h"
#include "SDL_timer.h" #include "SDL_timer.h"
#include "SDL_timer_c.h" #include "SDL_timer_c.h"
#include "kos32sys.h" #include <sys/ksys.h>
#if _POSIX_THREAD_SYSCALL_SOFT #if _POSIX_THREAD_SYSCALL_SOFT
#include <pthread.h> #include <pthread.h>
@ -43,52 +43,24 @@ static char rcsid =
#define USE_ITIMER #define USE_ITIMER
#endif #endif
/* The first ticks value of the application */
//static struct timeval start;
//static unsigned startlo,starthi;
//static unsigned clockrate;
static unsigned starttime; static unsigned starttime;
void SDL_StartTicks(void) void SDL_StartTicks(void)
{ {
// gettimeofday(&start, NULL); starttime = _ksys_get_tick_count();
// __asm__ ("int $0x40" : "=a"(clockrate) : "a"(18),"b"(5));
// __asm__ ("rdtsc" : "=a"(startlo),"=d"(starthi));
__asm__ ("int $0x40" : "=a"(starttime) : "a"(26),"b"(9));
} }
Uint32 SDL_GetTicks (void) Uint32 SDL_GetTicks (void)
{ {
/* struct timeval now; unsigned curtime = _ksys_get_tick_count();
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));
return (curtime-starttime)*10; return (curtime-starttime)*10;
} }
void SDL_Delay(unsigned ms){ void SDL_Delay(unsigned ms){
unsigned start = SDL_GetTicks(); unsigned start = SDL_GetTicks();
do{ do{
delay(1); _ksys_delay(1);
}while (SDL_GetTicks()-start < ms); }while (SDL_GetTicks()-start < ms);
} }

View File

@ -1,8 +1,8 @@
#include <menuet/os.h> #include <stdint.h>
#include <kos32sys.h>
#include <sys/ksys.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <sys/ksys.h>
#include "SDL.h" #include "SDL.h"
#include "SDL_sysevents.h" #include "SDL_sysevents.h"
#include "SDL_sysvideo.h" #include "SDL_sysvideo.h"
@ -11,240 +11,221 @@
extern void kos_SDL_RepaintWnd(void); 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 SHIFT (LSHIFT+RSHIFT)
#define CTRL (LCTRL+RCTRL) #define CTRL (LCTRL+RCTRL)
#define ALT (LALT+RALT) #define ALT (LALT+RALT)
static SDLMod GetModState(void) static SDLMod GetModState(void)
{ {
unsigned controlstate; unsigned controlstate = _ksys_get_control_key_state();
__asm__("int $0x40":"=a"(controlstate):"a"(66),"b"(3)); SDLMod res = 0;
SDLMod res = 0; if (controlstate & KSYS_CONTROL_LSHIFT)
if (controlstate & LSHIFT) res |= KMOD_LSHIFT;
res |= KMOD_LSHIFT; if (controlstate & KSYS_CONTROL_RSHIFT)
if (controlstate & RSHIFT) res |= KMOD_RSHIFT;
res |= KMOD_RSHIFT; if (controlstate & KSYS_CONTROL_LCTRL)
if (controlstate & LCTRL) res |= KMOD_LCTRL;
res |= KMOD_LCTRL; if (controlstate & KSYS_CONTROL_RCTRL)
if (controlstate & RCTRL) res |= KMOD_RCTRL;
res |= KMOD_RCTRL; if (controlstate & KSYS_CONTROL_LALT)
if (controlstate & LALT) res |= KMOD_LALT;
res |= KMOD_LALT; if (controlstate & KSYS_CONTROL_RALT)
if (controlstate & RALT) res |= KMOD_RALT;
res |= KMOD_RALT; if (controlstate & KSYS_CONTROL_CAPS)
if (controlstate & CAPS) res |= KMOD_CAPS;
res |= KMOD_CAPS; if (controlstate & KSYS_CONTROL_NUM_LOCK)
if (controlstate & NUML) res |= KMOD_NUM;
res |= KMOD_NUM; return res;
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] = static SDLKey sdlkeys[0x80] =
{ {
// 0x0* // 0x0*
0, SDLK_ESCAPE, SDLK_1, SDLK_2, SDLK_3, SDLK_4, SDLK_5, SDLK_6, 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, SDLK_7, SDLK_8, SDLK_9, SDLK_0, SDLK_MINUS, SDLK_EQUALS, SDLK_BACKSPACE, SDLK_TAB,
// 0x1* // 0x1*
SDLK_q, SDLK_w, SDLK_e, SDLK_r, SDLK_t, SDLK_y, SDLK_u, SDLK_i, 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, SDLK_o, SDLK_p, SDLK_LEFTBRACKET, SDLK_RIGHTBRACKET, SDLK_RETURN, SDLK_LCTRL, SDLK_a, SDLK_s,
// 0x2* // 0x2*
SDLK_d, SDLK_f, SDLK_g, SDLK_h, SDLK_j, SDLK_k, SDLK_l, SDLK_SEMICOLON, 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, SDLK_QUOTE, SDLK_BACKQUOTE, SDLK_LSHIFT, SDLK_BACKSLASH, SDLK_z, SDLK_x, SDLK_c, SDLK_v,
// 0x3* // 0x3*
SDLK_b, SDLK_n, SDLK_m, SDLK_COMMA, SDLK_PERIOD, SDLK_SLASH, SDLK_RSHIFT, SDLK_KP_MULTIPLY, 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, SDLK_LALT, SDLK_SPACE, SDLK_CAPSLOCK, SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5,
// 0x4* // 0x4*
SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9, SDLK_F10, SDLK_NUMLOCK, SDLK_SCROLLOCK, SDLK_KP7, 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, SDLK_KP8, SDLK_KP9, SDLK_KP_MINUS, SDLK_KP4, SDLK_KP5, SDLK_KP6, SDLK_KP_PLUS, SDLK_KP1,
// 0x5* // 0x5*
SDLK_KP2, SDLK_KP3, SDLK_KP0, SDLK_KP_PERIOD, 0, 0, 0, SDLK_F11, SDLK_KP2, SDLK_KP3, SDLK_KP0, SDLK_KP_PERIOD, 0, 0, 0, SDLK_F11,
SDLK_F12, 0, 0, 0, 0, 0, 0, 0, SDLK_F12, 0, 0, 0, 0, 0, 0, 0,
// 0x6* // 0x6*
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
// 0x7* // 0x7*
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
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 KolibriOS_CheckMouseMode(_THIS); static SDLKey sdlkeys_shift[0x80] =
void MenuetOS_PumpEvents(_THIS)
{ {
int i; // 0x0*
SDL_keysym key; 0, SDLK_ESCAPE, SDLK_EXCLAIM, SDLK_AT, SDLK_HASH, SDLK_DOLLAR, '%', SDLK_CARET,
static int ext_code=0; SDLK_AMPERSAND, SDLK_ASTERISK, SDLK_LEFTPAREN, SDLK_RIGHTPAREN, SDLK_UNDERSCORE, SDLK_PLUS, SDLK_BACKSPACE, SDLK_TAB,
static __u8 old_mode=0; // 0x1*
for (;;) { SDLK_q, SDLK_w, SDLK_e, SDLK_r, SDLK_t, SDLK_y, SDLK_u, SDLK_i,
i=__menuet__check_for_event(); SDLK_o, SDLK_p, '{', '}', SDLK_RETURN, SDLK_LCTRL, SDLK_a, SDLK_s,
switch(i) // 0x2*
{ SDLK_d, SDLK_f, SDLK_g, SDLK_h, SDLK_j, SDLK_k, SDLK_l, SDLK_COLON,
case 0: SDLK_QUOTEDBL, '~', SDLK_LSHIFT, '|', SDLK_z, SDLK_x, SDLK_c, SDLK_v,
return; // 0x3*
case 1: SDLK_b, SDLK_n, SDLK_m, SDLK_LESS, SDLK_GREATER, SDLK_QUESTION, SDLK_RSHIFT, SDLK_KP_MULTIPLY,
kos_SDL_RepaintWnd(); SDLK_LALT, SDLK_SPACE, SDLK_CAPSLOCK, SDLK_F1, SDLK_F2, SDLK_F3, SDLK_F4, SDLK_F5,
break; // 0x4*
case 2: SDLK_F6, SDLK_F7, SDLK_F8, SDLK_F9, SDLK_F10, SDLK_NUMLOCK, SDLK_SCROLLOCK, SDLK_KP7,
key.scancode = __menuet__getkey(); SDLK_KP8, SDLK_KP9, SDLK_KP_MINUS, SDLK_KP4, SDLK_KP5, SDLK_KP6, SDLK_KP_PLUS, SDLK_KP1,
if (key.scancode == 0xE0 || key.scancode == 0xE1) // 0x5*
{ext_code=key.scancode;break;} SDLK_KP2, SDLK_KP3, SDLK_KP0, SDLK_KP_PERIOD, 0, 0, 0, SDLK_F11,
if (ext_code == 0xE1 && (key.scancode & 0x7F) == 0x1D) break; SDLK_F12, 0, 0, 0, 0, 0, 0, 0,
if (ext_code == 0xE1 && key.scancode == 0xC5) {ext_code=0;break;} // 0x6*
key.mod = GetModState(); 0, 0, 0, 0, 0, 0, 0, 0,
if (ext_code == 0xE1) key.mod &= ~KMOD_CTRL; 0, 0, 0, 0, 0, 0, 0, 0,
if (!(key.scancode&0x80)) // 0x7*
old_mode = key.mod; 0, 0, 0, 0, 0, 0, 0, 0,
SDL_SetModState(key.mod); 0, 0, 0, 0, 0, 0, 0, 0
int code = (key.scancode & 0x80) ? SDL_RELEASED : SDL_PRESSED; };
key.scancode &= 0x7F;
// key.sym = scan2ascii(key.scancode,key.mod); static SDLKey sdlkeys_e0[0x80] =
if (ext_code == 0xE1 && key.scancode == 0x45) {
key.sym = SDLK_PAUSE; // 0x0*
else if (ext_code == 0xE0) 0, 0, 0, 0, 0, 0, 0, 0,
key.sym = sdlkeys_e0[key.scancode]; 0, 0, 0, 0, 0, 0, 0, 0,
else if (old_mode & KMOD_SHIFT) // 0x1*
key.sym = sdlkeys_shift[key.scancode]; 0, 0, 0, 0, 0, 0, 0, 0,
else 0, 0, 0, 0, SDLK_KP_ENTER, SDLK_RCTRL, 0, 0,
key.sym = sdlkeys[key.scancode]; // 0x2*
key.unicode=key.sym; 0, 0, 0, 0, 0, 0, 0, 0,
ext_code = 0; 0, 0, 0, 0, 0, 0, 0, 0,
if (!key.sym) break; // 0x3*
SDL_PrivateKeyboard(code,&key); 0, 0, 0, 0, 0, SDLK_KP_DIVIDE, 0, SDLK_PRINT,
break; SDLK_RALT, 0, 0, 0, 0, 0, 0, 0,
case 3: // 0x4*
if (_ksys_get_button()==1) { 0, 0, 0, 0, 0, 0, 0, SDLK_HOME,
SDL_CloseAudio(); SDLK_UP, SDLK_PAGEUP, 0, SDLK_LEFT, 0, SDLK_RIGHT, 0, SDLK_END,
exit(0); // 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);
}
}
}
}
} }
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);
kos_CheckMouseMode(this);
}
}
else
SDL_PrivateMouseMotion(0,0,mx,my);
__asm__("int $0x40":"=a"(__tmp):"a"(37),"b"(2));
if ((__tmp^oldmousestate)&1) {
if(__tmp&1)
{
SDL_PrivateMouseButton(SDL_PRESSED,SDL_BUTTON_LEFT,0,0);
} else {
SDL_PrivateMouseButton(SDL_RELEASED,SDL_BUTTON_LEFT,0,0);
} }
if ((__tmp^oldmousestate)&2) {
if(__tmp&2)
{
SDL_PrivateMouseButton(SDL_PRESSED,SDL_BUTTON_RIGHT,0,0);
} else {
SDL_PrivateMouseButton(SDL_RELEASED,SDL_BUTTON_RIGHT,0,0);
} }
oldmousestate = __tmp;
}
}
}
}
}

View File

@ -199,7 +199,7 @@ int kos_ShowWMCursor(_THIS, WMcursor* cursor)
if (!has_null_cursor) { if (!has_null_cursor) {
unsigned* u = malloc(32*32*4); unsigned* u = malloc(32*32*4);
if (!u) return 1; if (!u) return 1;
memset(u,0,32*32*4); memset(u, 0, 32*32*4);
null_cursor = _ksys_load_cursor(u, KSYS_CURSOR_INDIRECT); null_cursor = _ksys_load_cursor(u, KSYS_CURSOR_INDIRECT);
free(u); free(u);
has_null_cursor = 1; has_null_cursor = 1;
@ -219,8 +219,9 @@ void kos_CheckMouseMode(_THIS)
if (this->input_grab == SDL_GRAB_OFF) if (this->input_grab == SDL_GRAB_OFF)
return; return;
ksys_thread_t thread_info; ksys_thread_t thread_info;
int res = _ksys_thread_info(&thread_info, -1); int top = _ksys_thread_info(&thread_info, -1);
if (res == thread_info.window_pos_info) {
if (top == thread_info.pos_in_window_stack) {
int x = thread_info.winx_start + thread_info.clientx + this->hidden->win_size_x/2; 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; int y = thread_info.winy_start + thread_info.clienty + this->hidden->win_size_y/2;
_ksys_set_mouse_pos(x, y); _ksys_set_mouse_pos(x, y);
@ -268,8 +269,8 @@ static SDL_VideoDevice *kos_CreateDevice(int indx)
dev->IconifyWindow = NULL; dev->IconifyWindow = NULL;
dev->GrabInput = NULL; dev->GrabInput = NULL;
dev->GetWMInfo = NULL; dev->GetWMInfo = NULL;
dev->InitOSKeymap = MenuetOS_InitOSKeymap; dev->InitOSKeymap = kos_InitOSKeymap;
dev->PumpEvents = MenuetOS_PumpEvents; dev->PumpEvents = kos_PumpEvents;
dev->free = kos_DeleteDevice; dev->free = kos_DeleteDevice;
dev->CreateWMCursor = kos_CreateWMCursor; dev->CreateWMCursor = kos_CreateWMCursor;
dev->FreeWMCursor = kos_FreeWMCursor; dev->FreeWMCursor = kos_FreeWMCursor;

View File

@ -14,7 +14,7 @@ struct SDL_PrivateVideoData {
unsigned char** __lines; unsigned char** __lines;
}; };
void MenuetOS_InitOSKeymap(_THIS); void kos_InitOSKeymap(_THIS);
void MenuetOS_PumpEvents(_THIS); void kos_PumpEvents(_THIS);
#endif #endif