From: notaz Date: Mon, 11 Jun 2007 21:12:33 +0000 (+0000) Subject: usbjoy fix X-Git-Tag: r1~23 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ee0ae39373065c2afa6ddd823a0f667d5875d8a;p=fceu.git usbjoy fix git-svn-id: file:///home/notaz/opt/svn/fceu@163 be3aeb3a-fb24-0410-a615-afba39da0efa --- diff --git a/drivers/gp2x/cpuctrl.c b/drivers/gp2x/cpuctrl.c index b75cc66..b2cc395 100644 --- a/drivers/gp2x/cpuctrl.c +++ b/drivers/gp2x/cpuctrl.c @@ -162,12 +162,12 @@ static reg_setting rate_50[] = // 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 } }; @@ -175,12 +175,12 @@ static reg_setting rate_120_20[] = // 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 } }; diff --git a/drivers/gp2x/usbjoy.c b/drivers/gp2x/usbjoy.c index de1178a..041f2e1 100644 --- a/drivers/gp2x/usbjoy.c +++ b/drivers/gp2x/usbjoy.c @@ -34,6 +34,8 @@ #include "usbjoy.h" +/* This is a try to support analog joys. Untested. */ +#define DEAD_ZONE (8*1024) /* 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) { - 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) { - 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; @@ -418,6 +422,7 @@ void gp2x_usbjoy_deinit (void) { int i; for (i=0; i