summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSascha Hlusiak <saschahlusiak@arcor.de>2007-04-19 12:39:53 -0400
committerSascha Hlusiak <saschahlusiak@arcor.de>2007-04-19 12:39:53 -0400
commite1871e21955d5403c2751e83b5c00b2fa4886f22 (patch)
treeef4e95ab5e042d7dc94efa221cd92c070e8b999e /src
parent44aafff9e99ff02091580978a2dd7306eb9ad910 (diff)
Fixed accelerated axis movement not working the first time after startup
Modified used algorithm to produce slower and smoother acceleration
Diffstat (limited to 'src')
-rw-r--r--src/jstk_axis.c13
-rw-r--r--src/jstk_options.c6
2 files changed, 11 insertions, 8 deletions
diff --git a/src/jstk_axis.c b/src/jstk_axis.c
index d71dc9b..4840ade 100644
--- a/src/jstk_axis.c
+++ b/src/jstk_axis.c
@@ -89,9 +89,9 @@ jstkAxisTimer(OsTimerPtr timer,
} else if (axis->type == TYPE_ACCELERATED) {
/* Stop to accelerate at a certain speed */
- if (axis->currentspeed < 100.0f) axis->currentspeed *= 1.15f;
-
- p1 = (axis->currentspeed - 0.1f) * (float)NEXTTIMER / 180.0f;
+ if (axis->currentspeed < 100.0f) axis->currentspeed =
+ (axis->currentspeed + 3.0) * 1.07f - 3.0;
+ p1 = axis->currentspeed * (float)NEXTTIMER / 180.0f;
p2 = p1 / 8.0f;
}
if (axis->value < 0) {
@@ -124,9 +124,10 @@ jstkAxisTimer(OsTimerPtr timer,
float p1;
float p2;
- if (priv->button[i].currentspeed < 100.0f) priv->button[i].currentspeed *= 1.15f;
- p1 = (priv->button[i].currentspeed - 0.1) * (float)NEXTTIMER / 180.0f *
- priv->button[i].amplify;
+ if (priv->button[i].currentspeed < 100.0f) priv->button[i].currentspeed =
+ (priv->button[i].currentspeed + 3.0) * 1.07f - 3.0;
+ p1 = priv->button[i].currentspeed * (float)NEXTTIMER / 180.0f *
+ priv->button[i].amplify;
p1 *= priv->amplify;
p2 = p1 / 8.0f;
diff --git a/src/jstk_options.c b/src/jstk_options.c
index 191cb24..a45c883 100644
--- a/src/jstk_options.c
+++ b/src/jstk_options.c
@@ -100,6 +100,7 @@ jstkParseButtonOption(const char* org,
} else if (sscanf(param, "axis=%15s", p) == 1) {
button->mapping = jstkGetAxisMapping(&fvalue, p, name);
button->amplify = fvalue;
+ button->currentspeed = 1.0;
if (button->mapping == MAPPING_NONE)
xf86Msg(X_WARNING, "%s: error parsing axis: %s.\n",
name, p);
@@ -160,9 +161,10 @@ jstkParseAxisOption(const char* org, AXIS *axis, const char *name)
p[15]='\0';
if (strcmp(p, "relative") == 0)
axis->type = TYPE_BYVALUE;
- else if (strcmp(p, "accelerated") == 0)
+ else if (strcmp(p, "accelerated") == 0) {
axis->type = TYPE_ACCELERATED;
- else if (strcmp(p, "absolute") == 0)
+ axis->currentspeed = 1.0;
+ } else if (strcmp(p, "absolute") == 0)
axis->type = TYPE_ABSOLUTE;
else if (strcmp(p, "none") == 0)
axis->type = TYPE_NONE;