Search
lxdream.org :: lxdream/src/maple/controller.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/maple/controller.c
changeset 1010:a506a2f66180
prev850:28782ebbd01d
next1034:7044e01148f0
author nkeynes
date Sun Apr 12 02:04:27 2009 +0000 (11 years ago)
permissions -rw-r--r--
last change Fix analogue joystick input
file annotate diff log raw
1.1 --- a/src/maple/controller.c Mon Sep 08 07:56:33 2008 +0000
1.2 +++ b/src/maple/controller.c Sun Apr 12 02:04:27 2009 +0000
1.3 @@ -41,12 +41,15 @@
1.4 #define BUTTON_RIGHT_TRIGGER 0x00FF0000 /* Bitmask */
1.5
1.6 /* Second word of controller condition (bitmasks) */
1.7 -#define JOY_X_AXIS 0x000000FF
1.8 -#define JOY_Y_AXIS 0x0000FF00
1.9 +#define JOY_X_AXIS_MASK 0x000000FF
1.10 +#define JOY_Y_AXIS_MASK 0x0000FF00
1.11 #define JOY_X_AXIS_CENTER 0x00000080
1.12 #define JOY_Y_AXIS_CENTER 0x00008000
1.13 -#define JOY2_X_AXIS 0x00FF0000 /* not on standard controller */
1.14 -#define JOY2_Y_AXIS 0xFF000000 /* not on standard controller */
1.15 +#define JOY2_X_AXIS_MASK 0x00FF0000 /* not on standard controller */
1.16 +#define JOY2_Y_AXIS_MASK 0xFF000000 /* not on standard controller */
1.17 +
1.18 +#define JOY_X_AXIS(x) ((x)&0xFF)
1.19 +#define JOY_Y_AXIS(y) (((y)&0xFF)<<8)
1.20
1.21 /* The following bits are used by the emulator for flags but don't actually
1.22 * appear in the hardware
1.23 @@ -148,16 +151,20 @@
1.24 if( isKeyDown ) {
1.25 switch( value ) {
1.26 case JOY_LEFT:
1.27 - dev->condition[1] &= ~JOY_X_AXIS;
1.28 + dev->condition[1] &= ~JOY_X_AXIS_MASK;
1.29 + dev->condition[1] |= JOY_X_AXIS(0x7F - pressure);
1.30 break;
1.31 case JOY_RIGHT:
1.32 - dev->condition[1] |= JOY_X_AXIS;
1.33 + dev->condition[1] &= ~JOY_X_AXIS_MASK;
1.34 + dev->condition[1] |= JOY_X_AXIS(0x80 + pressure);
1.35 break;
1.36 case JOY_UP:
1.37 - dev->condition[1] &= ~JOY_Y_AXIS;
1.38 + dev->condition[1] &= ~JOY_Y_AXIS_MASK;
1.39 + dev->condition[1] |= JOY_Y_AXIS(0x7F - pressure);
1.40 break;
1.41 case JOY_DOWN:
1.42 - dev->condition[1] |= JOY_Y_AXIS;
1.43 + dev->condition[1] &= ~JOY_Y_AXIS_MASK;
1.44 + dev->condition[1] |= JOY_Y_AXIS(0x80 + pressure);
1.45 break;
1.46 case BUTTON_LEFT_TRIGGER:
1.47 case BUTTON_RIGHT_TRIGGER:
1.48 @@ -170,11 +177,11 @@
1.49 switch(value ) {
1.50 case JOY_LEFT:
1.51 case JOY_RIGHT:
1.52 - dev->condition[1] = (dev->condition[1] & ~JOY_X_AXIS)| JOY_X_AXIS_CENTER;
1.53 + dev->condition[1] = (dev->condition[1] & ~JOY_X_AXIS_MASK)| JOY_X_AXIS_CENTER;
1.54 break;
1.55 case JOY_UP:
1.56 case JOY_DOWN:
1.57 - dev->condition[1] = (dev->condition[1] & ~JOY_Y_AXIS)| JOY_Y_AXIS_CENTER;
1.58 + dev->condition[1] = (dev->condition[1] & ~JOY_Y_AXIS_MASK)| JOY_Y_AXIS_CENTER;
1.59 break;
1.60 case BUTTON_LEFT_TRIGGER:
1.61 case BUTTON_RIGHT_TRIGGER:
.