Skip to content

Commit

Permalink
From 17405e261a96bdf3489b73f22dd493210df90bb4 Mon Sep 17 00:00:00 2001
Browse files Browse the repository at this point in the history
Subject: [PATCH] ignore a misbehaving joystick, like the fake one vmware tools
 puts in a linux vm
  • Loading branch information
jv4779 authored and smcameron committed Dec 6, 2013
1 parent 8423d8d commit 4896cfd
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions snis_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -2431,12 +2431,14 @@ static joystick_button_fn do_joystick_button[] = {
NULL,
};

/* client joystick status */
static struct wwvi_js_event jse = { { 0 } };

static void deal_with_joystick()
{

#define FRAME_RATE_HZ 30
static const int joystick_throttle = (int) ((FRAME_RATE_HZ / 15.0) + 0.5);
static struct wwvi_js_event jse = { { 0 } };
int i, rc;

if (joystick_fd < 0) /* no joystick */
Expand Down Expand Up @@ -11525,8 +11527,24 @@ static void setup_joystick(GtkWidget *window)
joystick_fd = open_joystick(joystick_device, window->window);
if (joystick_fd < 0)
printf("No joystick...\n");
else
else {
/* pull all the events off the joystick */
memset(&jse.button, 0, sizeof(jse.button));
int rc = get_joystick_status(&jse);
if (rc != 0) {
printf("Joystick '%s' not sending events, ignoring...\n", joystick_device);
joystick_fd = -1;
return;
}

if ( jse.stick_x <= -32767 || jse.stick_y <= -32767) {
printf("Joystick '%s' stuck at neg limits, ignoring...\n", joystick_device);
joystick_fd = -1;
return;
}

check_for_screensaver();
}
}

static struct mesh *snis_read_stl_file(char *directory, char *filename)
Expand Down

0 comments on commit 4896cfd

Please sign in to comment.