diff -urN gpm-orig/src/headers/gpmInt.h gpm/src/headers/gpmInt.h
--- gpm-orig/src/headers/gpmInt.h	2003-10-21 15:38:38.000000000 -0500
+++ gpm/src/headers/gpmInt.h	2003-10-21 16:39:10.000000000 -0500
@@ -121,7 +121,7 @@
    protocol_setup    *setup;
    protocol_init     *init;
    protocol_cleanup  *cleanup;
-   protovol_destroy  *destroy;
+   protocol_destroy  *destroy;
    
    unsigned short    flags;
    unsigned char     proto[4];
diff -urN gpm-orig/src/protocol/joystick.c gpm/src/protocol/joystick.c
--- gpm-orig/src/protocol/joystick.c	2003-10-21 15:38:38.000000000 -0500
+++ gpm/src/protocol/joystick.c	2003-10-21 16:40:38.000000000 -0500
@@ -5,6 +5,7 @@
  * Copyright (C) 1994-2000   Alessandro Rubini <rubini@linux.it>
  * Copyright (C) 1998,1999   Ian Zimmerman <itz@rahul.net>
  * Copyright (C) 2001,2002   Nico Schottelius <nicos@pcsystems.de>
+ * Copyright (C) 2003        Dmitry Torokhov <dtor@mail.ru>
  *
  *   This program is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -32,39 +33,63 @@
 #include <linux/joystick.h>
 
 #include "headers/gpmInt.h"
+#include "headers/report.h"
 #include "headers/protocol/joystick.h"
 
 /* Joystick mouse emulation (David Given) */
+struct joystick_state {
+   int centerx;
+   int centery;
+   int olbuttons;
+   int count;
+};
+
+int S_joystick(struct micedev *dev, struct miceopt *opt, struct Gpm_Type *type)
+{
+   dev->private = malloc(sizeof(struct joystick_state));
+   
+   if (!dev->private)
+      gpm_report(GPM_PR_OOPS,
+                 "%s: Can't allocate memory for internal data", type->name);
+
+   memset(dev->private, 0, sizeof(struct joystick_state));
+
+   if (check_no_options(type->name, opt->text, ',') != 0) {
+      free(dev->private);
+      dev->private = NULL;
+      return -1;
+   }
+ 
+   return 0;
+}
+
 int M_joystick(struct micedev *dev, struct miceopt *opt, unsigned char *data, Gpm_Event *state)
 {
    struct JS_DATA_TYPE *jdata = (void*)data;
-   static int centerx = 0;
-   static int centery = 0;
-   static int oldbuttons = 0;
-   static int count = 0;
+   struct joystick_state *joy_state = &dev->private;
    int dx;
    int dy;
 
-   count++;
-   if (count < 200) {
-      state->buttons = oldbuttons;
+   if (++joy_state->count < 200) {
+      state->buttons = joystate->oldbuttons;
       state->dx = 0;
       state->dy = 0;
       return 0;
    }
-   count = 0;
 
-   if (centerx == 0) {
-      centerx = jdata->x;
-      centery = jdata->y;
+   joy_state->count = 0;
+
+   if (joy_state->centerx == 0) {
+      joy_state->centerx = jdata->x;
+      joy_state->centery = jdata->y;
    }
 
    state->buttons = ((jdata->buttons & 1) * GPM_B_LEFT) |
                     ((jdata->buttons & 2) * GPM_B_RIGHT);
-   oldbuttons     = state->buttons;
+   joy_state->oldbuttons = state->buttons;
 
-   dx             = (jdata->x - centerx) >> 6;
-   dy             = (jdata->y - centery) >> 6;
+   dx = (jdata->x - centerx) >> 6;
+   dy = (jdata->y - centery) >> 6;
 
    if (dx > 0) state->dx =   dx * dx;
    else        state->dx = -(dx * dx);
@@ -82,8 +107,3 @@
    return 0;
 }
 
-/* indent: use three spaces. no tab. not two or four. three */
-
-/* Local Variables: */
-/* c-indent-level: 3 */
-/* End: */
