Moved DirectInput joystick code to 1.3 branch
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%401821
This commit is contained in:
parent
fe915b7a0a
commit
f2d67baf34
7 changed files with 108 additions and 626 deletions
|
@ -17,7 +17,7 @@ void WatchJoystick(SDL_Joystick *joystick)
|
|||
int i, done;
|
||||
SDL_Event event;
|
||||
int x, y, draw;
|
||||
SDL_Rect axis_area[6][2];
|
||||
SDL_Rect axis_area[2];
|
||||
|
||||
/* Set a video mode to display joystick axis position */
|
||||
screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16, 0);
|
||||
|
@ -110,38 +110,36 @@ void WatchJoystick(SDL_Joystick *joystick)
|
|||
SDL_UpdateRects(screen, 1, &area);
|
||||
}
|
||||
|
||||
for ( i=0; i<SDL_JoystickNumAxes(joystick)/2 && i < SDL_arraysize(axis_area); ++i ) {
|
||||
/* Erase previous axes */
|
||||
SDL_FillRect(screen, &axis_area[i][draw], 0x0000);
|
||||
/* Erase previous axes */
|
||||
SDL_FillRect(screen, &axis_area[draw], 0x0000);
|
||||
|
||||
/* Draw the X/Y axis */
|
||||
draw = !draw;
|
||||
x = (((int)SDL_JoystickGetAxis(joystick, i*2+0))+32768);
|
||||
x *= SCREEN_WIDTH;
|
||||
x /= 65535;
|
||||
if ( x < 0 ) {
|
||||
x = 0;
|
||||
} else
|
||||
if ( x > (SCREEN_WIDTH-16) ) {
|
||||
x = SCREEN_WIDTH-16;
|
||||
}
|
||||
y = (((int)SDL_JoystickGetAxis(joystick, i*2+1))+32768);
|
||||
y *= SCREEN_HEIGHT;
|
||||
y /= 65535;
|
||||
if ( y < 0 ) {
|
||||
y = 0;
|
||||
} else
|
||||
if ( y > (SCREEN_HEIGHT-16) ) {
|
||||
y = SCREEN_HEIGHT-16;
|
||||
}
|
||||
axis_area[i][draw].x = (Sint16)x;
|
||||
axis_area[i][draw].y = (Sint16)y;
|
||||
axis_area[i][draw].w = 16;
|
||||
axis_area[i][draw].h = 16;
|
||||
SDL_FillRect(screen, &axis_area[i][draw], 0xFFFF);
|
||||
|
||||
SDL_UpdateRects(screen, 2, axis_area[i]);
|
||||
/* Draw the X/Y axis */
|
||||
draw = !draw;
|
||||
x = (((int)SDL_JoystickGetAxis(joystick, 0))+32768);
|
||||
x *= SCREEN_WIDTH;
|
||||
x /= 65535;
|
||||
if ( x < 0 ) {
|
||||
x = 0;
|
||||
} else
|
||||
if ( x > (SCREEN_WIDTH-16) ) {
|
||||
x = SCREEN_WIDTH-16;
|
||||
}
|
||||
y = (((int)SDL_JoystickGetAxis(joystick, 1))+32768);
|
||||
y *= SCREEN_HEIGHT;
|
||||
y /= 65535;
|
||||
if ( y < 0 ) {
|
||||
y = 0;
|
||||
} else
|
||||
if ( y > (SCREEN_HEIGHT-16) ) {
|
||||
y = SCREEN_HEIGHT-16;
|
||||
}
|
||||
axis_area[draw].x = (Sint16)x;
|
||||
axis_area[draw].y = (Sint16)y;
|
||||
axis_area[draw].w = 16;
|
||||
axis_area[draw].h = 16;
|
||||
SDL_FillRect(screen, &axis_area[draw], 0xFFFF);
|
||||
|
||||
SDL_UpdateRects(screen, 2, axis_area);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue