summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hdaps-tux.c21
-rw-r--r--hdaps-tux.h5
2 files changed, 16 insertions, 10 deletions
diff --git a/hdaps-tux.c b/hdaps-tux.c
index 0ef145b..38ddf1a 100644
--- a/hdaps-tux.c
+++ b/hdaps-tux.c
@@ -63,9 +63,10 @@ int main(int argc, char *argv[])
SDL_Rect dst, dstwhite;
SDL_Event event;
Uint8 *keys;
- int tuxX = 270, tuxY = 170;
+ int tuxX = 180, tuxY = 170;
int hdapsX = 0, hdapsY = 0;
int hdapsXprev = 0, hdapsYprev = 0;
+ int vel = 4;
unsigned int timeout = TIMEOUT_VAL;
char done = 0;
@@ -78,7 +79,7 @@ int main(int argc, char *argv[])
SDL_WM_SetCaption ("hdaps-tux - Move tux with your Thinkpad (press q to exit)", "hdaps-tux");
- screen = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE | SDL_DOUBLEBUF);
+ screen = SDL_SetVideoMode(W_WIDTH, W_HEIGHT, 16, SDL_HWSURFACE | SDL_DOUBLEBUF);
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, 255, 255, 255));
if (!screen) {
printf("Can't set video mode: %s\n", SDL_GetError());
@@ -124,8 +125,8 @@ int main(int argc, char *argv[])
dprintf("xdiff/ydiff: %d/%d\n", xdiff, ydiff);
- tuxX += xdiff * 3;
- tuxY += ydiff * 3;
+ tuxX += xdiff * vel;
+ tuxY += ydiff * vel;
timeout = TIMEOUT_VAL;
}
@@ -135,10 +136,10 @@ int main(int argc, char *argv[])
if (tuxY > 5)
tuxY--;
if (keys[SDLK_DOWN]) /* Manually move tux down */
- if (tuxY < 475 - image->h)
+ if (tuxY < W_HEIGHT - 5 - image->h)
tuxY++;
if (keys[SDLK_RIGHT]) /* Manually move tux right */
- if (tuxX < 635 - image->w)
+ if (tuxX < W_WIDTH - 5 - image->w)
tuxX++;
if (keys[SDLK_LEFT]) /* Manually move tux left */
if (tuxX > 5)
@@ -148,12 +149,12 @@ int main(int argc, char *argv[])
if (tuxX < 5)
tuxX = 5;
- if (tuxX > 635 - image->w)
- tuxX = 635 - image->w;
+ if (tuxX > W_WIDTH - image->w)
+ tuxX = W_WIDTH - image->w;
if (tuxY < 5)
tuxY = 5;
- if (tuxY > 475 - image->h)
- tuxY = 475 - image->h;
+ if (tuxY > W_HEIGHT - image->h)
+ tuxY = W_HEIGHT - image->h;
dprintf("tuxX/tuxY: %d/%d\n", tuxX, tuxY);
diff --git a/hdaps-tux.h b/hdaps-tux.h
index 258e398..1c041f1 100644
--- a/hdaps-tux.h
+++ b/hdaps-tux.h
@@ -4,6 +4,11 @@
#define POSITION_FILE "/sys/devices/platform/hdaps/position"
#define TUX_FILE "tux.bmp"
+/* UI constants */
+#define W_WIDTH 480
+#define W_HEIGHT 480
+
+/* Polling constants */
#define TIMEOUT_VAL 15
#ifdef DEBUG