Fix touch screen flip

This commit is contained in:
elasota
2020-10-14 18:26:13 -04:00
parent b682004f29
commit 64ce75caa8

View File

@@ -103,9 +103,9 @@ void DoPause (void)
Delay(1, nullptr); Delay(1, nullptr);
} }
while ((isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kEscape))) || while ((isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kEscape))) ||
(!isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kTab)))); (!isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kTab))));
paused = true; paused = true;
while (paused) while (paused)
{ {
@@ -119,11 +119,11 @@ void DoPause (void)
Delay(1, nullptr); Delay(1, nullptr);
} }
CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap), CopyBits((BitMap *)*GetGWorldPixMap(workSrcMap),
GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()), GetPortBitMapForCopyBits(mainWindow->GetDrawSurface()),
&bounds, &bounds, srcCopy); &bounds, &bounds, srcCopy);
do do
{ {
theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys(); theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
@@ -151,9 +151,9 @@ void DoBatteryEngaged (gliderPtr thisGlider)
else else
thisGlider->hVel += kHyperThrust; thisGlider->hVel += kHyperThrust;
} }
batteryTotal--; batteryTotal--;
if (batteryTotal == 0) if (batteryTotal == 0)
{ {
QuickBatteryRefresh(false); QuickBatteryRefresh(false);
@@ -178,7 +178,7 @@ void DoHeliumEngaged (gliderPtr thisGlider)
{ {
thisGlider->vDesiredVel = -kHeliumLift; thisGlider->vDesiredVel = -kHeliumLift;
batteryTotal++; batteryTotal++;
if (batteryTotal == 0) if (batteryTotal == 0)
{ {
QuickBatteryRefresh(false); QuickBatteryRefresh(false);
@@ -206,9 +206,9 @@ void DoHeliumEngaged (gliderPtr thisGlider)
if (thisGlider->which == kPlayer1) if (thisGlider->which == kPlayer1)
{ {
#if BUILD_ARCADE_VERSION #if BUILD_ARCADE_VERSION
if ((theKeys->IsSet(thisGlider->leftKey)) || if ((theKeys->IsSet(thisGlider->leftKey)) ||
(theKeys->IsSet(thisGlider->gamepadLeftKey)) || (theKeys->IsSet(thisGlider->gamepadLeftKey)) ||
(theKeys->IsSet(thisGlider->rightKey)) || (theKeys->IsSet(thisGlider->rightKey)) ||
@@ -221,15 +221,15 @@ void DoHeliumEngaged (gliderPtr thisGlider)
playing = false; playing = false;
paused = false; paused = false;
} }
#else #else
if (theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kControl))) if (theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kControl)))
DoCommandKey(); DoCommandKey();
#endif #endif
} }
if (thisGlider->mode == kGliderBurning) if (thisGlider->mode == kGliderBurning)
{ {
if (thisGlider->facing == kFaceLeft) if (thisGlider->facing == kFaceLeft)
@@ -242,7 +242,7 @@ void DoHeliumEngaged (gliderPtr thisGlider)
thisGlider->heldLeft = false; thisGlider->heldLeft = false;
thisGlider->heldRight = false; thisGlider->heldRight = false;
thisGlider->tipped = false; thisGlider->tipped = false;
if (gameFrame == (long)demoData[demoIndex].frame) if (gameFrame == (long)demoData[demoIndex].frame)
{ {
switch (demoData[demoIndex].key) switch (demoData[demoIndex].key)
@@ -253,14 +253,14 @@ void DoHeliumEngaged (gliderPtr thisGlider)
thisGlider->heldRight = true; thisGlider->heldRight = true;
thisGlider->fireHeld = false; thisGlider->fireHeld = false;
break; break;
case 1: // right key case 1: // right key
thisGlider->hDesiredVel -= kNormalThrust; thisGlider->hDesiredVel -= kNormalThrust;
thisGlider->tipped = (thisGlider->facing == kFaceRight); thisGlider->tipped = (thisGlider->facing == kFaceRight);
thisGlider->heldLeft = true; thisGlider->heldLeft = true;
thisGlider->fireHeld = false; thisGlider->fireHeld = false;
break; break;
case 2: // battery key case 2: // battery key
if (batteryTotal > 0) if (batteryTotal > 0)
DoBatteryEngaged(thisGlider); DoBatteryEngaged(thisGlider);
@@ -268,28 +268,28 @@ void DoHeliumEngaged (gliderPtr thisGlider)
DoHeliumEngaged(thisGlider); DoHeliumEngaged(thisGlider);
thisGlider->fireHeld = false; thisGlider->fireHeld = false;
break; break;
case 3: // rubber band key case 3: // rubber band key
if (!thisGlider->fireHeld) if (!thisGlider->fireHeld)
{ {
if (AddBand(thisGlider, thisGlider->dest.left + 24, if (AddBand(thisGlider, thisGlider->dest.left + 24,
thisGlider->dest.top + 10, thisGlider->facing)) thisGlider->dest.top + 10, thisGlider->facing))
{ {
bandsTotal--; bandsTotal--;
if (bandsTotal <= 0) if (bandsTotal <= 0)
QuickBandsRefresh(false); QuickBandsRefresh(false);
thisGlider->fireHeld = true; thisGlider->fireHeld = true;
} }
} }
break; break;
} }
demoIndex++; demoIndex++;
} }
else else
thisGlider->fireHeld = false; thisGlider->fireHeld = false;
if ((isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kEscape))) || if ((isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kEscape))) ||
(!isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kTab)))) (!isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kTab))))
{ {
@@ -297,7 +297,7 @@ void DoHeliumEngaged (gliderPtr thisGlider)
} }
} }
} }
//-------------------------------------------------------------- GetInput //-------------------------------------------------------------- GetInput
void GetInput (gliderPtr thisGlider) void GetInput (gliderPtr thisGlider)
@@ -309,7 +309,7 @@ void GetInput (gliderPtr thisGlider)
if (theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kControl))) if (theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kControl)))
DoCommandKey(); DoCommandKey();
} }
if (thisGlider->mode == kGliderBurning) if (thisGlider->mode == kGliderBurning)
{ {
if (thisGlider->facing == kFaceLeft) if (thisGlider->facing == kFaceLeft)
@@ -344,6 +344,9 @@ void GetInput (gliderPtr thisGlider)
if (thisMac.isTouchscreen) if (thisMac.isTouchscreen)
{ {
bool touchLeftState = false;
bool touchRightState = false;
for (int fi = 0; fi < touchScreenControlState::kMaxFingers; fi++) for (int fi = 0; fi < touchScreenControlState::kMaxFingers; fi++)
{ {
const touchScreenFingerState &fstate = touchScreen.fingers[fi]; const touchScreenFingerState &fstate = touchScreen.fingers[fi];
@@ -360,21 +363,10 @@ void GetInput (gliderPtr thisGlider)
case TouchScreenCtrlIDs::Movement: case TouchScreenCtrlIDs::Movement:
{ {
int32_t screenWidth = mainWindowRect.Width(); int32_t screenWidth = mainWindowRect.Width();
const bool touchLeftState = (touchScreenPoint.h * 2 <= screenWidth); if (touchScreenPoint.h * 2 <= screenWidth)
const bool touchRightState = (touchScreenPoint.h * 2 - screenWidth >= 0); touchLeftState = true;
if (touchScreenPoint.h * 2 - screenWidth >= 0)
if (touchLeftState) touchRightState = true;
{
if (touchRightState)
continuousFlipState = true;
else
leftState = true;
}
else
{
if (touchRightState)
rightState = true;
}
} }
break; break;
case TouchScreenCtrlIDs::Flip: case TouchScreenCtrlIDs::Flip:
@@ -390,6 +382,16 @@ void GetInput (gliderPtr thisGlider)
break; break;
} }
} }
if (touchLeftState)
{
if (touchRightState)
continuousFlipState = true;
else
leftState = true;
}
else if (touchRightState)
rightState = true;
} }
if (theKeys->IsSet(thisGlider->gamepadRightKey)) if (theKeys->IsSet(thisGlider->gamepadRightKey))
@@ -475,7 +477,7 @@ void GetInput (gliderPtr thisGlider)
} }
else else
batteryWasEngaged = false; batteryWasEngaged = false;
if ((theKeys->IsSet(thisGlider->bandKey) || theKeys->IsSet(thisGlider->gamepadBandKey) || bandsState) && (bandsTotal > 0) && if ((theKeys->IsSet(thisGlider->bandKey) || theKeys->IsSet(thisGlider->gamepadBandKey) || bandsState) && (bandsTotal > 0) &&
(thisGlider->mode == kGliderNormal)) (thisGlider->mode == kGliderNormal))
{ {
@@ -484,27 +486,27 @@ void GetInput (gliderPtr thisGlider)
#endif #endif
if (!thisGlider->fireHeld) if (!thisGlider->fireHeld)
{ {
if (AddBand(thisGlider, thisGlider->dest.left + 24, if (AddBand(thisGlider, thisGlider->dest.left + 24,
thisGlider->dest.top + 10, thisGlider->facing)) thisGlider->dest.top + 10, thisGlider->facing))
{ {
bandsTotal--; bandsTotal--;
if (bandsTotal <= 0) if (bandsTotal <= 0)
QuickBandsRefresh(false); QuickBandsRefresh(false);
thisGlider->fireHeld = true; thisGlider->fireHeld = true;
} }
} }
} }
else else
thisGlider->fireHeld = false; thisGlider->fireHeld = false;
if ((otherPlayerEscaped != kNoOneEscaped) && if ((otherPlayerEscaped != kNoOneEscaped) &&
(theKeys->IsSet(PL_KEY_SPECIAL(kDelete))) && (theKeys->IsSet(PL_KEY_SPECIAL(kDelete))) &&
(thisGlider->which) && (!onePlayerLeft)) (thisGlider->which) && (!onePlayerLeft))
{ {
ForceKillGlider(); ForceKillGlider();
} }
if ((isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kEscape))) || if ((isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kEscape))) ||
(!isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kTab)))) (!isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kTab))))
{ {
@@ -520,7 +522,7 @@ Boolean QuerySaveGame (void)
#define kSaveGameAlert 1041 #define kSaveGameAlert 1041
#define kYesSaveGameButton 1 #define kYesSaveGameButton 1
short hitWhat; short hitWhat;
InitCursor(); InitCursor();
FlushEvents(); FlushEvents();
// CenterAlert(kSaveGameAlert); // CenterAlert(kSaveGameAlert);