Improvements for SDL & Quinn

This commit is contained in:
Andrew Pamment 2021-12-14 22:14:27 +10:00
parent a7a7ed17b0
commit 418f03c4de
2 changed files with 43 additions and 19 deletions

View File

@ -80,6 +80,11 @@ static const int SDLK_unicode[] = {
0, 0, 0, 0, 0
};
#define KEYBOARD_KEY_ARROW_UP 0x48
#define KEYBOARD_KEY_ARROW_LEFT 0x4B
#define KEYBOARD_KEY_ARROW_RIGHT 0x4D
#define KEYBOARD_KEY_ARROW_DOWN 0x50
static const int SDLK_keyset[] = {
0, SDLK_ESCAPE, SDLK_1, SDLK_2,
SDLK_3, SDLK_4, SDLK_5, SDLK_6,
@ -191,20 +196,35 @@ void QUINN_PumpEvents(_THIS) {
}
keysym.mod = make_mod(_k_last_state);
switch (current_req.event_msgs[l].code) {
case KEYBOARD_KEY_ARROW_UP:
keysym.sym = SDLK_UP;
break;
case KEYBOARD_KEY_ARROW_DOWN:
keysym.sym = SDLK_DOWN;
break;
case KEYBOARD_KEY_ARROW_LEFT:
keysym.sym = SDLK_LEFT;
break;
case KEYBOARD_KEY_ARROW_RIGHT:
keysym.sym = SDLK_RIGHT;
break;
default:
if (current_req.event_msgs[l].code < 0x57) {
if (_k_e0) {
keysym.sym = SDLK_keyset_e0[current_req.event_msgs[l].code];
} else {
keysym.sym = SDLK_keyset[current_req.event_msgs[l].code];
}
}
break;
}
if (current_req.event_msgs[l].state == 1) {
if (_k_e0) {
keysym.sym = SDLK_keyset_e0[current_req.event_msgs[l].code];
} else {
keysym.sym = SDLK_keyset[current_req.event_msgs[l].code];
}
SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
} else {
// key up
if (_k_e0) {
keysym.sym = SDLK_keyset_e0[current_req.event_msgs[l].code];
} else {
keysym.sym = SDLK_keyset[current_req.event_msgs[l].code];
}
SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
}
}

View File

@ -50,6 +50,8 @@
#define QUINNVID_DRIVER_NAME "quinn"
unsigned char *QUINN_Icon = NULL;
extern QUINN_recv_event(struct window_req_t *req);
struct SDL_VideoDevice *__quinn_device;
@ -167,7 +169,6 @@ SDL_Rect **QUINN_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
}
void QUINN_WinExit(int wh) {
fprintf(stderr, "I Should Quit\n");
__quinn_device->hidden->doexit = 1;
}
@ -175,7 +176,6 @@ SDL_Surface *QUINN_SetVideoMode(_THIS, SDL_Surface *current,
int width, int height, int bpp, Uint32 flags)
{
if ( this->hidden->wh != -1) {
fprintf(stderr, "Resize request to %d x %d.\n", width, height);
// close window and open a new one the requested sizeo
quinn_remove_window(this->hidden->wh);
}
@ -184,32 +184,36 @@ SDL_Surface *QUINN_SetVideoMode(_THIS, SDL_Surface *current,
req = (struct window_req_t *)malloc(sizeof(struct window_req_t));
if (flags & SDL_NOFRAME) {
fprintf(stderr, "Initializing without borders.\n");
req->flags = WIN_REQ_FLAG_NO_TITLE;
req->x = 0;
req->y = 0;
} else {
fprintf(stderr, "Initializing with borders.\n");
req->flags = 0;
req->x = 0;
req->y = 25;
}
fprintf(stderr, "Initializing window %dx%d (%d bpp)\n", width, height, bpp);
sprintf(req->name, "SDL Window");
req->width = width;
req->height = height;
req->icon = NULL;
if (QUINN_Icon == NULL) {
req->icon = NULL;
} else {
req->icon = QUINN_Icon;
}
this->hidden->bpp = bpp;
this->hidden->doexit = 0;
this->hidden->wh = quinn_req_window(req, QUINN_WinExit);
this->hidden->surface = quinn_add_sdl_surface(this->hidden->wh, 0, 0, width, height, QUINN_recv_event);
if (QUINN_Icon == NULL) {
free(QUINN_Icon);
QUINN_Icon = NULL;
}
fprintf(stderr, "Window output initialized...\n");
this->hidden->surface = quinn_add_sdl_surface(this->hidden->wh, 0, 0, width, height, QUINN_recv_event);
/* Set up the new mode framebuffer */
current->flags = flags;
@ -246,7 +250,7 @@ static void QUINN_UnlockHWSurface(_THIS, SDL_Surface *surface)
static void QUINN_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
{
quinn_update_window();
quinn_yield();
// quinn_yield();
}
int QUINN_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)