usbjoy fix
authornotaz <notasas@gmail.com>
Mon, 11 Jun 2007 21:12:33 +0000 (21:12 +0000)
committernotaz <notasas@gmail.com>
Mon, 11 Jun 2007 21:12:33 +0000 (21:12 +0000)
git-svn-id: file:///home/notaz/opt/svn/fceu@163 be3aeb3a-fb24-0410-a615-afba39da0efa

drivers/gp2x/cpuctrl.c
drivers/gp2x/usbjoy.c
drivers/gp2x/usbjoy.h
out_gp2x/readme.txt

index b75cc66..b2cc395 100644 (file)
@@ -162,12 +162,12 @@ static reg_setting rate_50[] =
 // 16639/2 ~120.20
 static reg_setting rate_120_20[] =
 {
 // 16639/2 ~120.20
 static reg_setting rate_120_20[] =
 {
-       { 0x0914, 0xffff, (203<<8)|(2<<2)|1 },  /* UPLLSETVREG */
-       { 0x0924, 0xff00, (2<<14)|(14<<8) },    /* DISPCSETREG */
-       { 0x281A, 0x00ff, 29 },                 /* .HSWID(T2) */
-       { 0x281C, 0x00ff, 19 },                 /* .HSSTR(T8) */
-       { 0x281E, 0x00ff, 19 },                 /* .HSEND(T7) */
-       { 0x2822, 0x01ff, 11 },                 /* .VSEND (T9) */
+       { 0x0914, 0xffff, (96<<8)|(0<<2)|2 },   /* UPLLSETVREG */
+       { 0x0924, 0xff00, (2<<14)|(7<<8) },     /* DISPCSETREG */
+       { 0x281A, 0x00ff, 19 },                 /* .HSWID(T2) */
+       { 0x281C, 0x00ff, 7 },                  /* .HSSTR(T8) */
+       { 0x281E, 0x00ff, 7 },                  /* .HSEND(T7) */
+       { 0x2822, 0x01ff, 12 },                 /* .VSEND (T9) */
        { 0x2826, 0x0ff0, 37<<4 },              /* .DESTR(T3) */
        { 0, 0, 0 }
 };
        { 0x2826, 0x0ff0, 37<<4 },              /* .DESTR(T3) */
        { 0, 0, 0 }
 };
@@ -175,12 +175,12 @@ static reg_setting rate_120_20[] =
 // 19997/2 ~100.02
 static reg_setting rate_100_02[] =
 {
 // 19997/2 ~100.02
 static reg_setting rate_100_02[] =
 {
-       { 0x0914, 0xffff, (63<<8)|(1<<2)|1 },   /* UPLLSETVREG */
-       { 0x0924, 0xff00, (2<<14)|(7<<8) },     /* DISPCSETREG */
-       { 0x281A, 0x00ff, 29 },                 /* .HSWID(T2) */
-       { 0x281C, 0x00ff, 21 },                 /* .HSSTR(T8) */
-       { 0x281E, 0x00ff, 20 },                 /* .HSEND(T7) */
-       { 0x2822, 0x01ff, 12 },                 /* .VSEND (T9) */
+       { 0x0914, 0xffff, (98<<8)|(0<<2)|2 },   /* UPLLSETVREG */
+       { 0x0924, 0xff00, (2<<14)|(8<<8) },     /* DISPCSETREG */
+       { 0x281A, 0x00ff, 26 },                 /* .HSWID(T2) */
+       { 0x281C, 0x00ff, 6 },                  /* .HSSTR(T8) */
+       { 0x281E, 0x00ff, 6 },                  /* .HSEND(T7) */
+       { 0x2822, 0x01ff, 31 },                 /* .VSEND (T9) */
        { 0x2826, 0x0ff0, 37<<4 },              /* .DESTR(T3) */
        { 0, 0, 0 }
 };
        { 0x2826, 0x0ff0, 37<<4 },              /* .DESTR(T3) */
        { 0, 0, 0 }
 };
index de1178a..041f2e1 100644 (file)
@@ -34,6 +34,8 @@
 
 #include "usbjoy.h"
 
 
 #include "usbjoy.h"
 
+/* This is a try to support analog joys. Untested. */
+#define DEAD_ZONE (8*1024)
 
 /*
   Function: joy_open
 
 /*
   Function: joy_open
@@ -210,14 +212,16 @@ int joy_update (struct usbjoy * joy) {
        switch (events[i].type & ~JS_EVENT_INIT) {
        case JS_EVENT_AXIS:
          if (events[i].number == 0) {
        switch (events[i].type & ~JS_EVENT_INIT) {
        case JS_EVENT_AXIS:
          if (events[i].number == 0) {
-           if (events[i].value == 0) joy->stateaxes[JOYLEFT] = joy->stateaxes[JOYRIGHT] = 0;
-           else if (events[i].value < 0) joy->stateaxes[JOYLEFT] = 1;
-           else joy->stateaxes[JOYRIGHT] = 1;
+           joy->stateaxes[JOYLEFT] = joy->stateaxes[JOYRIGHT] = 0;
+           if      (events[i].value < -DEAD_ZONE) joy->stateaxes[JOYLEFT] = 1;
+           else if (events[i].value >  DEAD_ZONE) joy->stateaxes[JOYRIGHT] = 1;
+           joy->axevals[0] = events[i].value;
          }
          else if (events[i].number == 1) {
          }
          else if (events[i].number == 1) {
-           if (events[i].value == 0) joy->stateaxes[JOYUP] = joy->stateaxes[JOYDOWN] = 0;
-           else if (events[i].value < 0) joy->stateaxes[JOYUP] = 1;
-           else joy->stateaxes[JOYDOWN] = 1;
+           joy->stateaxes[JOYUP] = joy->stateaxes[JOYDOWN] = 0;
+           if      (events[i].value < -DEAD_ZONE) joy->stateaxes[JOYUP] = 1;
+           else if (events[i].value >  DEAD_ZONE) joy->stateaxes[JOYDOWN] = 1;
+           joy->axevals[1] = events[i].value;
          }
          event = 1;
          break;
          }
          event = 1;
          break;
@@ -418,6 +422,7 @@ void gp2x_usbjoy_deinit (void) {
        int i;
        for (i=0; i<num_of_joys; i++) {
                joy_close (joys[i]);
        int i;
        for (i=0; i<num_of_joys; i++) {
                joy_close (joys[i]);
+               joys[i] = NULL;
        }
        num_of_joys = 0;
 }
        }
        num_of_joys = 0;
 }
index 3d8810a..cdcc654 100644 (file)
@@ -72,6 +72,7 @@ struct usbjoy {
   int numhats;
   int statebuttons[32];
   int stateaxes[4];
   int numhats;
   int statebuttons[32];
   int stateaxes[4];
+  int axevals[2];
   joy_type type;
 };
 
   joy_type type;
 };
 
index a6cf045..4931dcf 100644 (file)
@@ -188,6 +188,10 @@ extension instead of .ips.
 \r
 \r
 ver 0.4 (by notaz)\r
 \r
 \r
 ver 0.4 (by notaz)\r
+  rev 163\r
+          - Added A r k's fast-direction-change fix for usbjoy lib.\r
+          - Fixed an issue of usbjoys stopping to work when "Perfect vsync"\r
+            is enabled.\r
   rev 162\r
           - Fixed savestate subsections (were causing some mapper data not\r
             to be saved).\r
   rev 162\r
           - Fixed savestate subsections (were causing some mapper data not\r
             to be saved).\r