rewrite mouse motion code, change vres when display size changes

This commit is contained in:
dborth 2009-10-14 06:22:27 +00:00
parent 4f9aadb9bb
commit b935d83ec9
2 changed files with 9 additions and 22 deletions

View file

@ -33,8 +33,6 @@
#include "SDL_wiivideo.h"
#include "SDL_wiievents_c.h"
static int lastX = 0;
static int lastY = 0;
static Uint8 lastButtonStateA = SDL_RELEASED;
static Uint8 lastButtonStateB = SDL_RELEASED;
@ -42,6 +40,7 @@ static SDLKey keymap[232];
static s32 stat;
static s32 mstat;
static WPADData *wd;
static keyboard_event ke;
static mouse_event me;
@ -56,25 +55,13 @@ void PumpEvents()
#ifdef HW_RVL
if (TerminateRequested) Terminate();
#endif
WPADData *wd = WPAD_Data(0);
wd = WPAD_Data(0);
stat = KEYBOARD_GetEvent(&ke);
mstat = MOUSE_GetEvent(&me);
int x, y;
SDL_GetMouseState(&x, &y);
if (wd->ir.valid)
{
x = wd->ir.x;
y = wd->ir.y;
if (lastX != x || lastY != y)
{
posted += SDL_PrivateMouseMotion(0, 0, x, y);
lastX = x;
lastY = y;
}
posted += SDL_PrivateMouseMotion(0, 0, (int)wd->ir.x, (int)wd->ir.y);
Uint8 stateA = SDL_RELEASED;
Uint8 stateB = SDL_RELEASED;
@ -87,16 +74,15 @@ void PumpEvents()
{
stateB = SDL_PRESSED;
}
if (stateA != lastButtonStateA)
{
lastButtonStateA = stateA;
posted += SDL_PrivateMouseButton(stateA, SDL_BUTTON_LEFT, x, y);
posted += SDL_PrivateMouseButton(stateA, SDL_BUTTON_LEFT, 0, 0);
}
if (stateB != lastButtonStateB)
{
lastButtonStateB = stateB;
posted += SDL_PrivateMouseButton(stateB, SDL_BUTTON_RIGHT, x, y);
posted += SDL_PrivateMouseButton(stateB, SDL_BUTTON_RIGHT, 0, 0);
}
}

View file

@ -62,6 +62,7 @@ unsigned int *xfb[2] = { NULL, NULL }; // Double buffered
int whichfb = 0; // Switch
GXRModeObj* vmode = 0;
u8 * screenTex = NULL; // screen capture
static int quit_flip_thread = 0;
static unsigned char texturemem[TEXTUREMEM_SIZE] __attribute__((aligned(32))); // GX texture
static unsigned char textureconvert[TEXTUREMEM_SIZE] __attribute__((aligned(32))); // 565 mem
@ -194,8 +195,7 @@ static void TakeScreenshot()
DCFlushRange(screenTex, texSize);
}
static int quit_flip_thread = 0;
int flip_thread(void * arg)
static void * flip_thread (void *arg)
{
while(1)
{
@ -232,7 +232,7 @@ int flip_thread(void * arg)
VIDEO_Flush();
VIDEO_WaitVSync();
}
return 0;
return NULL;
}
static void
@ -435,6 +435,7 @@ SDL_Surface *WII_SetVideoMode(_THIS, SDL_Surface *current,
currentwidth = current->w;
currentheight = current->h;
currentbpp = bpp;
WPAD_SetVRes(WPAD_CHAN_ALL, currentwidth, currentheight);
draw_init();
StartVideoThread();
/* We're done */