Added Timer & dodgy unicode support (for basic latin)

This commit is contained in:
Andrew Pamment 2016-02-11 17:34:00 +10:00
parent f440e2a105
commit f6a7f37ecf
6 changed files with 192 additions and 3 deletions

6
configure vendored
View File

@ -21706,6 +21706,12 @@ case "$host" in
SOURCES="$SOURCES $srcdir/src/video/quinn/*.c"
SDL_LIBS="$SDL_LIBS -lquinn -lpng -lz -lm -lfreetype"
if test x$enable_timers = xyes; then
$as_echo "#define SDL_TIMER_QUINN 1" >>confdefs.h
SOURCES="$SOURCES $srcdir/src/timer/quinn/*.c"
have_timers=yes
fi
;;
*-*-cygwin* | *-*-mingw32*)
ARCH=win32

View File

@ -2509,6 +2509,12 @@ case "$host" in
AC_DEFINE(SDL_VIDEO_DRIVER_QUINN)
SOURCES="$SOURCES $srcdir/src/video/quinn/*.c"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lquinn"
if test x$enable_timers = xyes; then
AC_DEFINE(SDL_TIMER_QUINN)
SOURCES="$SOURCES $srcdir/src/timer/quinn/*.c"
have_timers=yes
fi
;;
*-*-cygwin* | *-*-mingw32*)
ARCH=win32

View File

@ -251,6 +251,7 @@
#undef SDL_TIMER_UNIX
#undef SDL_TIMER_WIN32
#undef SDL_TIMER_WINCE
#undef SDL_TIMER_QUINN
/* Enable various video drivers */
#undef SDL_VIDEO_DRIVER_AALIB

View File

@ -0,0 +1,118 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#ifdef SDL_TIMER_QUINN
#include <stdio.h>
#include <time.h>
#include <string.h>
#include "SDL_timer.h"
#include "../SDL_timer_c.h"
static Uint32 start;
static Uint32 timerStart;
void SDL_StartTicks(void)
{
/* Set first ticks value */
__asm__ volatile ("int $0x30" : "=a" (start) : "0" (46));
}
Uint32 SDL_GetTicks (void)
{
Uint32 ticks;
Uint32 now;
__asm__ volatile ("int $0x30" : "=a" (now) : "0" (46));
ticks= now - start;
return(ticks);
}
void SDL_Delay (Uint32 ms)
{
Uint32 then, now, elapsed;
/* Set the timeout interval */
then = SDL_GetTicks();
do {
/* Calculate the time interval left (in case of interrupt) */
now = SDL_GetTicks();
elapsed = (now-then);
then = now;
if ( elapsed >= (ms / 10) ) {
break;
}
ms -= elapsed;
quinn_yield();
} while (1);
}
/* This is only called if the event thread is not running */
int SDL_SYS_TimerInit(void)
{
return 0;
}
void SDL_SYS_TimerQuit(void)
{
SDL_SetTimer(0, NULL);
}
int SDL_SYS_StartTimer(void)
{
timerStart = SDL_GetTicks();
return(0);
}
void SDL_SYS_StopTimer(void)
{
return;
}
void QUINN_CheckTimer()
{
if (SDL_timer_running && SDL_GetTicks() - timerStart >= SDL_alarm_interval)
{
Uint32 ms;
ms = SDL_alarm_callback(SDL_alarm_interval);
if ( ms != SDL_alarm_interval )
{
if ( ms )
{
SDL_alarm_interval = ROUND_RESOLUTION(ms);
} else
{
SDL_alarm_interval = 0;
SDL_timer_running = 0;
}
}
if (SDL_alarm_interval) timerStart = SDL_GetTicks();
}
}
#endif

View File

@ -30,6 +30,55 @@
#include "quinn.h"
static const int sdl_unicode_shift[] = {
0, 0, 0x21, 0x40,
0x23, 0x24, 0x25, 0x5e,
0x26, 0x2a, 0x28, 0x29,
0x5f, 0x2b, 0x08, 0x09,
0x51, 0x57, 0x45, 0x52,
0x54, 0x59, 0x55, 0x49,
0x4F, 0x50, 0x7b, 0x7d,
0x0d, 0, 0x41, 0x53,
0x44, 0x46, 0x47, 0x48,
0x4a, 0x4b, 0x4c, 0x3A,
0x22, 0x7e, 0, 0x7c,
0x5a, 0x58, 0x43, 0x56,
0x42, 0x4e, 0x4d, 0x3c,
0x3e, 0x3f, 0, 0,
0, 0x20, 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 const int sdl_unicode[] = {
0, 0, 0x31, 0x32,
0x33, 0x34, 0x35, 0x36,
0x37, 0x38, 0x39, 0x30,
0x2d, 0x3d, 0x08, 0x09,
0x71, 0x77, 0x65, 0x72,
0x74, 0x79, 0x75, 0x69,
0x6F, 0x70, 0x5b, 0x5d,
0x0d, 0, 0x61, 0x73,
0x64, 0x66, 0x67, 0x68,
0x6a, 0x6b, 0x6c, 0x3B,
0x27, 0x60, 0, 0x5c,
0x7a, 0x78, 0x63, 0x76,
0x62, 0x6e, 0x6d, 0x2c,
0x2e, 0x2f, 0, 0,
0, 0x20, 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 const int sdl_keyset[] = {
0, SDLK_ESCAPE, SDLK_1, SDLK_2,
@ -92,6 +141,10 @@ void QUINN_recv_event(struct window_update_req *req) {
void QUINN_PumpEvents(_THIS) {
int i;
if (this->hidden->doexit == 1) {
SDL_PrivateQuit();
}
if (current_req_current) {
if (current_req.lclick != _lmstate) {
if (current_req.lclick) {
@ -128,7 +181,11 @@ void QUINN_PumpEvents(_THIS) {
for (i=0;i<88;i++) {
if (_k_last_state[i] != current_req.key_codes[i]) {
keysym.scancode = i;
keysym.unicode = 0;
if (current_req.key_codes[42] == 1 || current_req.key_codes[54] == 1) {
keysym.unicode = sdl_unicode_shift[i];
} else {
keysym.unicode = sdl_unicode[i];
}
keysym.mod = make_mod(current_req.key_codes);
if (current_req.key_codes[i] == 1) {
// key down
@ -139,12 +196,13 @@ void QUINN_PumpEvents(_THIS) {
keysym.sym = sdl_keyset[i];
SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
}
}
_k_last_state[i] = current_req.key_codes[i];
}
}
current_req_current = 0;
}
quinn_process_input();
}
void QUINN_InitOSKeymap(_THIS)

View File

@ -245,7 +245,7 @@ static void QUINN_UnlockHWSurface(_THIS, SDL_Surface *surface)
static void QUINN_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
{
quinn_process();
quinn_update_window();
quinn_yield();
}