mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 12:09:36 +00:00
XInput support
This commit is contained in:
@@ -89,6 +89,10 @@ typedef struct
|
||||
// long encrypted, fakeLong;
|
||||
long wasLeftMap, wasRightMap;
|
||||
long wasBattMap, wasBandMap;
|
||||
long wasGPLeftMap, wasGPRightMap;
|
||||
long wasGPBattMap, wasGPBandMap;
|
||||
long wasGPFlipMap;
|
||||
long wasGPFaceLeftMap, wasGPFaceRightMap;
|
||||
short wasVolume;
|
||||
short prefVersion;
|
||||
short wasMaxFiles;
|
||||
|
||||
@@ -551,8 +551,8 @@
|
||||
#define kGliderBurningHigh 26
|
||||
#define kShadowHigh 9
|
||||
#define kShadowTop 306
|
||||
#define kFaceRight TRUE
|
||||
#define kFaceLeft FALSE
|
||||
static const Boolean kFaceRight = TRUE; // Conflicts with GP input driver
|
||||
static const Boolean kFaceLeft = FALSE; // Conflicts with GP input driver
|
||||
#define kPlayer1 TRUE
|
||||
#define kPlayer2 FALSE
|
||||
#define kNumGliderSrcRects 31
|
||||
@@ -623,3 +623,5 @@
|
||||
#define kScoreboardPictID 1997
|
||||
|
||||
#define kDemoLength 6702
|
||||
|
||||
#define kGamepadDeadzone 4096 // Out of 32768
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
#include "PLQDOffscreen.h"
|
||||
|
||||
#include "GpVOSEvent.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -208,6 +208,10 @@ typedef struct
|
||||
Rect clip, enteredRect;
|
||||
Int32 leftKey, rightKey;
|
||||
Int32 battKey, bandKey;
|
||||
Int32 gamepadLeftKey, gamepadRightKey;
|
||||
Int32 gamepadBattKey, gamepadBandKey;
|
||||
Int32 gamepadFlipKey;
|
||||
Int32 gamepadFaceLeftKey, gamepadFaceRightKey;
|
||||
short hVel, vVel;
|
||||
short wasHVel, wasVVel;
|
||||
short vDesiredVel, hDesiredVel;
|
||||
@@ -215,7 +219,7 @@ typedef struct
|
||||
Boolean facing, tipped;
|
||||
Boolean sliding, ignoreLeft, ignoreRight;
|
||||
Boolean fireHeld, which;
|
||||
Boolean heldLeft, heldRight;
|
||||
Boolean heldLeft, heldRight, heldFlip;
|
||||
Boolean dontDraw, ignoreGround;
|
||||
} gliderType, *gliderPtr;
|
||||
|
||||
|
||||
111
GpApp/Input.cpp
111
GpApp/Input.cpp
@@ -9,6 +9,7 @@
|
||||
#include "PLDialogs.h"
|
||||
#include "PLKeyEncoding.h"
|
||||
#include "Externs.h"
|
||||
#include "InputManager.h"
|
||||
#include "MainWindow.h"
|
||||
#include "RectUtils.h"
|
||||
|
||||
@@ -197,10 +198,14 @@ void DoHeliumEngaged (gliderPtr thisGlider)
|
||||
|
||||
#if BUILD_ARCADE_VERSION
|
||||
|
||||
if ((BitTst(theKeys, thisGlider->leftKey)) ||
|
||||
(BitTst(theKeys, thisGlider->rightKey)) ||
|
||||
(BitTst(theKeys, thisGlider->battKey)) ||
|
||||
(BitTst(theKeys, thisGlider->bandKey)))
|
||||
if ((BitTst(theKeys, thisGlider->leftKey)) ||
|
||||
(BitTst(theKeys, thisGlider->gamepadLeftKey)) ||
|
||||
(BitTst(theKeys, thisGlider->rightKey)) ||
|
||||
(BitTst(theKeys, thisGlider->gamepadRightKey)) ||
|
||||
(BitTst(theKeys, thisGlider->battKey)) ||
|
||||
(BitTst(theKeys, thisGlider->gamepadBattKey)) ||
|
||||
(BitTst(theKeys, thisGlider->bandKey)) ||
|
||||
(BitTst(theKeys, thisGlider->gamepadBandKey)))
|
||||
{
|
||||
playing = false;
|
||||
paused = false;
|
||||
@@ -302,38 +307,96 @@ void GetInput (gliderPtr thisGlider)
|
||||
}
|
||||
else
|
||||
{
|
||||
bool continuousFlipState = false;
|
||||
bool holdFlipState = false;
|
||||
bool leftState = false;
|
||||
bool rightState = false;
|
||||
|
||||
if (BitTst(theKeys, thisGlider->rightKey) || BitTst(theKeys, thisGlider->gamepadRightKey)) // right key
|
||||
{
|
||||
PL_NotYetImplemented_TODO("FixDemo"); // Flips aren't recorded in the demo properly
|
||||
|
||||
if (BitTst(theKeys, thisGlider->leftKey) || BitTst(theKeys, thisGlider->gamepadLeftKey))
|
||||
continuousFlipState = true;
|
||||
else
|
||||
rightState = true;
|
||||
}
|
||||
else if (BitTst(theKeys, thisGlider->leftKey) || BitTst(theKeys, thisGlider->gamepadLeftKey)) // left key
|
||||
leftState = true;
|
||||
else
|
||||
thisGlider->tipped = false;
|
||||
|
||||
if (BitTst(theKeys, thisGlider->gamepadRightKey))
|
||||
rightState = true;
|
||||
|
||||
if (BitTst(theKeys, thisGlider->gamepadLeftKey))
|
||||
leftState = true;
|
||||
|
||||
if (BitTst(theKeys, thisGlider->gamepadFaceLeftKey) && thisGlider->facing == kFaceRight)
|
||||
continuousFlipState = true;
|
||||
|
||||
if (BitTst(theKeys, thisGlider->gamepadFaceRightKey) && thisGlider->facing == kFaceLeft)
|
||||
continuousFlipState = true;
|
||||
|
||||
if (BitTst(theKeys, thisGlider->gamepadFlipKey))
|
||||
holdFlipState = true;
|
||||
|
||||
if (thisGlider->which == kPlayer1 || thisGlider->which == kPlayer2)
|
||||
{
|
||||
unsigned int playerNum = 0;
|
||||
if (thisGlider->which == kPlayer1)
|
||||
playerNum = 0;
|
||||
else if (thisGlider->which == kPlayer2)
|
||||
playerNum = 1;
|
||||
|
||||
int16_t inputAxis = PortabilityLayer::InputManager::GetInstance()->GetGamepadAxis(playerNum, GpGamepadAxes::kLeftStickX);
|
||||
if (inputAxis <= -kGamepadDeadzone)
|
||||
leftState = true;
|
||||
else if (inputAxis >= kGamepadDeadzone)
|
||||
rightState = true;
|
||||
}
|
||||
|
||||
// gamepad flip key
|
||||
//if (BitTst(theKeys, thisGlider->gamepadFlipKey))
|
||||
// holdFlipState = true;
|
||||
|
||||
thisGlider->heldLeft = false;
|
||||
thisGlider->heldRight = false;
|
||||
if (BitTst(theKeys, thisGlider->rightKey)) // right key
|
||||
if (continuousFlipState)
|
||||
{
|
||||
#ifdef CREATEDEMODATA
|
||||
LogDemoKey(0);
|
||||
#endif
|
||||
if (BitTst(theKeys, thisGlider->leftKey))
|
||||
leftState = false;
|
||||
rightState = false;
|
||||
ToggleGliderFacing(thisGlider);
|
||||
}
|
||||
else if (holdFlipState)
|
||||
{
|
||||
if (!thisGlider->heldFlip)
|
||||
{
|
||||
ToggleGliderFacing(thisGlider);
|
||||
thisGlider->heldLeft = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
thisGlider->hDesiredVel += kNormalThrust;
|
||||
thisGlider->tipped = (thisGlider->facing == kFaceLeft);
|
||||
thisGlider->heldRight = true;
|
||||
thisGlider->heldFlip = true;
|
||||
}
|
||||
}
|
||||
else if (BitTst(theKeys, thisGlider->leftKey)) // left key
|
||||
else
|
||||
thisGlider->heldFlip = false;
|
||||
|
||||
if (rightState && !leftState)
|
||||
{
|
||||
thisGlider->hDesiredVel += kNormalThrust;
|
||||
thisGlider->tipped = (thisGlider->facing == kFaceLeft);
|
||||
thisGlider->heldRight = true;
|
||||
}
|
||||
|
||||
if (leftState && !rightState)
|
||||
{
|
||||
#ifdef CREATEDEMODATA
|
||||
LogDemoKey(1);
|
||||
#endif
|
||||
thisGlider->hDesiredVel -= kNormalThrust;
|
||||
thisGlider->tipped = (thisGlider->facing == kFaceRight);
|
||||
thisGlider->heldLeft = true;
|
||||
}
|
||||
else
|
||||
|
||||
if (!leftState && !rightState)
|
||||
thisGlider->tipped = false;
|
||||
|
||||
if ((BitTst(theKeys, thisGlider->battKey)) && (batteryTotal != 0) &&
|
||||
|
||||
if ((BitTst(theKeys, thisGlider->battKey) || BitTst(theKeys, thisGlider->gamepadBattKey)) && (batteryTotal != 0) &&
|
||||
(thisGlider->mode == kGliderNormal))
|
||||
{
|
||||
#ifdef CREATEDEMODATA
|
||||
@@ -347,7 +410,7 @@ void GetInput (gliderPtr thisGlider)
|
||||
else
|
||||
batteryWasEngaged = false;
|
||||
|
||||
if ((BitTst(theKeys, thisGlider->bandKey)) && (bandsTotal > 0) &&
|
||||
if ((BitTst(theKeys, thisGlider->bandKey) || BitTst(theKeys, thisGlider->gamepadBandKey)) && (bandsTotal > 0) &&
|
||||
(thisGlider->mode == kGliderNormal))
|
||||
{
|
||||
#ifdef CREATEDEMODATA
|
||||
|
||||
@@ -140,6 +140,10 @@ void VariableInit (void)
|
||||
theGlider2.rightKey = PL_KEY_ASCII('D');
|
||||
theGlider2.battKey = PL_KEY_ASCII('S');
|
||||
theGlider2.bandKey = PL_KEY_ASCII('W');
|
||||
theGlider2.gamepadLeftKey = PL_KEY_GAMEPAD_BUTTON(kDPadLeft, 1);
|
||||
theGlider2.gamepadRightKey = PL_KEY_GAMEPAD_BUTTON(kDPadRight, 1);
|
||||
theGlider2.gamepadBandKey = PL_KEY_GAMEPAD_BUTTON(kFaceDown, 1);
|
||||
theGlider2.gamepadBattKey = PL_KEY_GAMEPAD_BUTTON(kFaceLeft, 1);
|
||||
theGlider2.which = kPlayer2;
|
||||
|
||||
theMode = kSplashMode;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "House.h"
|
||||
|
||||
|
||||
#define kPrefsVersion 0x0034
|
||||
#define kPrefsVersion 0x0035
|
||||
|
||||
|
||||
void ReadInPrefs (void);
|
||||
@@ -72,6 +72,13 @@ void ReadInPrefs (void)
|
||||
theGlider.rightKey = thePrefs.wasRightMap;
|
||||
theGlider.battKey = thePrefs.wasBattMap;
|
||||
theGlider.bandKey = thePrefs.wasBandMap;
|
||||
theGlider.gamepadLeftKey = thePrefs.wasGPLeftMap;
|
||||
theGlider.gamepadRightKey = thePrefs.wasGPRightMap;
|
||||
theGlider.gamepadBandKey = thePrefs.wasGPBandMap;
|
||||
theGlider.gamepadBattKey = thePrefs.wasGPBattMap;
|
||||
theGlider.gamepadFlipKey = thePrefs.wasGPFlipMap;
|
||||
theGlider.gamepadFaceRightKey = thePrefs.wasGPFaceRightMap;
|
||||
theGlider.gamepadFaceLeftKey = thePrefs.wasGPFaceLeftMap;
|
||||
#ifndef COMPILEDEMO
|
||||
#ifndef COMPILENOCP
|
||||
encryptedNumber = thePrefs.encrypted;
|
||||
@@ -138,7 +145,14 @@ void ReadInPrefs (void)
|
||||
theGlider.rightKey = PL_KEY_SPECIAL(kRightArrow);
|
||||
theGlider.battKey = PL_KEY_SPECIAL(kDownArrow);
|
||||
theGlider.bandKey = PL_KEY_SPECIAL(kUpArrow);
|
||||
|
||||
theGlider.gamepadLeftKey = PL_KEY_GAMEPAD_BUTTON(kDPadLeft, 0);
|
||||
theGlider.gamepadRightKey = PL_KEY_GAMEPAD_BUTTON(kDPadRight, 0);
|
||||
theGlider.gamepadBandKey = PL_KEY_GAMEPAD_BUTTON(kFaceDown, 0);
|
||||
theGlider.gamepadBattKey = PL_KEY_GAMEPAD_BUTTON(kFaceLeft, 0);
|
||||
theGlider.gamepadFlipKey = PL_KEY_GAMEPAD_BUTTON(kFaceUp, 0);
|
||||
theGlider.gamepadFaceRightKey = PL_KEY_GAMEPAD_BUTTON(kRightBumper, 0);
|
||||
theGlider.gamepadFaceLeftKey = PL_KEY_GAMEPAD_BUTTON(kLeftBumper, 0);
|
||||
|
||||
UnivGetSoundVolume(&isVolume, thisMac.hasSM3);
|
||||
if (isVolume < 1)
|
||||
isVolume = 1;
|
||||
@@ -228,6 +242,13 @@ void WriteOutPrefs (void)
|
||||
thePrefs.wasRightMap = theGlider.rightKey;
|
||||
thePrefs.wasBattMap = theGlider.battKey;
|
||||
thePrefs.wasBandMap = theGlider.bandKey;
|
||||
thePrefs.wasGPLeftMap = theGlider.gamepadLeftKey;
|
||||
thePrefs.wasGPRightMap = theGlider.gamepadRightKey;
|
||||
thePrefs.wasGPBattMap = theGlider.gamepadBattKey;
|
||||
thePrefs.wasGPBandMap = theGlider.gamepadBandKey;
|
||||
thePrefs.wasGPFlipMap = theGlider.gamepadFlipKey;
|
||||
thePrefs.wasGPFaceLeftMap = theGlider.gamepadFaceLeftKey;
|
||||
thePrefs.wasGPFaceRightMap = theGlider.gamepadFaceRightKey;
|
||||
#ifndef COMPILEDEMO
|
||||
#ifndef COMPILENOCP
|
||||
thePrefs.encrypted = encryptedNumber;
|
||||
|
||||
@@ -1225,6 +1225,13 @@ void SetAllDefaults (void)
|
||||
theGlider.rightKey = PL_KEY_SPECIAL(kRightArrow);
|
||||
theGlider.battKey = PL_KEY_SPECIAL(kDownArrow);
|
||||
theGlider.bandKey = PL_KEY_SPECIAL(kUpArrow);
|
||||
theGlider.gamepadLeftKey = PL_KEY_GAMEPAD_BUTTON(kDPadLeft, 0);
|
||||
theGlider.gamepadRightKey = PL_KEY_GAMEPAD_BUTTON(kDPadRight, 0);
|
||||
theGlider.gamepadBandKey = PL_KEY_GAMEPAD_BUTTON(kFaceDown, 0);
|
||||
theGlider.gamepadBattKey = PL_KEY_GAMEPAD_BUTTON(kFaceLeft, 0);
|
||||
theGlider.gamepadFlipKey = PL_KEY_GAMEPAD_BUTTON(kFaceUp, 0);
|
||||
theGlider.gamepadFaceRightKey = PL_KEY_GAMEPAD_BUTTON(kRightBumper, 0);
|
||||
theGlider.gamepadFaceLeftKey = PL_KEY_GAMEPAD_BUTTON(kLeftBumper, 0);
|
||||
isEscPauseKey = false;
|
||||
// Default sound settings
|
||||
isPlayMusicIdle = true;
|
||||
|
||||
Reference in New Issue
Block a user