Hi all,
Below is a code fragment that tries to sample the mouse from
within a mouse-down event. I’m trying to implement a drag-scroll
mechanism. Unfortunately, the variable ‘btn’ is permanently set
to 1, even though I’m calling SDL_GetMouseState() within the
loop…
The docs say you can call SDL_GetMouseState() at any time, but
does that depend on the event loop ? This is with the latest
.tar.gz file from the CVS page, running on Redhat 6.1.
Thanks in advance for any help,
ATB,
Simon.
case PART_IMAGES:
{
int ox = -1;
Part *thePart = _skin->getPart(part);
int pw = thePart->getW();
int px = thePart->getX();
int mx,my;
int btn = SDL_GetMouseState(&mx, &my);
while ((btn & SDL_BUTTON_LMASK) == SDL_BUTTON_LMASK)
{
cerr << "[" << btn << "]";
if (mx < px) mx = px;
if (mx >= pw+px) mx = px + pw;
if (ox != mx)
{
ox = mx;
float prange = ((float)mx - px)/pw;
int currentFrame = (int)(frange * prange);
if (currentFrame >=0 && currentFrame < frange)
_frameIdx = currentFrame;
}
btn = SDL_GetMouseState(&mx, &my);
cerr << "(" << btn << ") ";
}
}--
Physicists get hadrons!