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); |
} |
} |
} |
} |
} |
} |