mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 06:53:43 +00:00
Refactoring
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "Environ.h"
|
#include "Environ.h"
|
||||||
#include "HostDisplayDriver.h"
|
#include "HostDisplayDriver.h"
|
||||||
|
#include "HostSystemServices.h"
|
||||||
|
|
||||||
|
|
||||||
#define kSwitchDepthAlert 130
|
#define kSwitchDepthAlert 130
|
||||||
@@ -393,7 +394,7 @@ void CheckMemorySize (void)
|
|||||||
{
|
{
|
||||||
#define kBaseBytesNeeded 614400L // 600K Base memory
|
#define kBaseBytesNeeded 614400L // 600K Base memory
|
||||||
#define kPaddingBytes 204800L // 200K Padding
|
#define kPaddingBytes 204800L // 200K Padding
|
||||||
long bytesNeeded, bytesAvail;
|
long bytesNeeded;
|
||||||
long soundBytes, musicBytes;
|
long soundBytes, musicBytes;
|
||||||
|
|
||||||
dontLoadMusic = false;
|
dontLoadMusic = false;
|
||||||
@@ -484,7 +485,7 @@ void CheckMemorySize (void)
|
|||||||
bytesNeeded += sizeof(objDataType) * kMaxMasterObjects;
|
bytesNeeded += sizeof(objDataType) * kMaxMasterObjects;
|
||||||
bytesNeeded += kDemoLength; SpinCursor(1);
|
bytesNeeded += kDemoLength; SpinCursor(1);
|
||||||
|
|
||||||
bytesAvail = FreeMem(); SpinCursor(1);
|
SpinCursor(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetDeviceRect(Rect *rect)
|
void GetDeviceRect(Rect *rect)
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "Environ.h"
|
#include "Environ.h"
|
||||||
#include "House.h"
|
#include "House.h"
|
||||||
|
#include "InputManager.h"
|
||||||
#include "ObjectEdit.h"
|
#include "ObjectEdit.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -162,9 +163,9 @@ void HandleMouseEvent (const GpMouseInputEvent &theEvent, uint32_t tick)
|
|||||||
void HandleKeyEvent (const KeyDownStates &keyStates, const GpKeyboardInputEvent &theEvent)
|
void HandleKeyEvent (const KeyDownStates &keyStates, const GpKeyboardInputEvent &theEvent)
|
||||||
{
|
{
|
||||||
const intptr_t theChar = PackVOSKeyCode(theEvent);
|
const intptr_t theChar = PackVOSKeyCode(theEvent);
|
||||||
const bool shiftDown = BitTst(keyStates, PL_KEY_EITHER_SPECIAL(kShift));
|
const bool shiftDown = keyStates.IsSet(PL_KEY_EITHER_SPECIAL(kShift));
|
||||||
const bool commandDown = BitTst(keyStates, PL_KEY_EITHER_SPECIAL(kControl));
|
const bool commandDown = keyStates.IsSet(PL_KEY_EITHER_SPECIAL(kControl));
|
||||||
const bool optionDown = BitTst(keyStates, PL_KEY_EITHER_SPECIAL(kAlt));
|
const bool optionDown = keyStates.IsSet(PL_KEY_EITHER_SPECIAL(kAlt));
|
||||||
|
|
||||||
if ((commandDown) && (!optionDown))
|
if ((commandDown) && (!optionDown))
|
||||||
DoMenuChoice(MenuKey(static_cast<int>(theChar)));
|
DoMenuChoice(MenuKey(static_cast<int>(theChar)));
|
||||||
@@ -458,18 +459,17 @@ void HandleIdleTask (void)
|
|||||||
|
|
||||||
void HandleEvent (void)
|
void HandleEvent (void)
|
||||||
{
|
{
|
||||||
KeyDownStates eventKeys;
|
|
||||||
TimeTaggedVOSEvent theEvent;
|
TimeTaggedVOSEvent theEvent;
|
||||||
uint32_t sleep = 2;
|
uint32_t sleep = 2;
|
||||||
bool itHappened = true;
|
bool itHappened = true;
|
||||||
|
|
||||||
GetKeys(eventKeys);
|
const KeyDownStates *eventKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
if ((BitTst(eventKeys, PL_KEY_EITHER_SPECIAL(kControl))) &&
|
if ((eventKeys->IsSet(PL_KEY_EITHER_SPECIAL(kControl))) &&
|
||||||
(BitTst(eventKeys, PL_KEY_EITHER_SPECIAL(kAlt))))
|
(eventKeys->IsSet(PL_KEY_EITHER_SPECIAL(kAlt))))
|
||||||
{
|
{
|
||||||
HiliteAllObjects();
|
HiliteAllObjects();
|
||||||
}
|
}
|
||||||
else if ((BitTst(eventKeys, PL_KEY_EITHER_SPECIAL(kAlt))) && (theMode == kEditMode) &&
|
else if ((eventKeys->IsSet(PL_KEY_EITHER_SPECIAL(kAlt))) && (theMode == kEditMode) &&
|
||||||
(houseUnlocked))
|
(houseUnlocked))
|
||||||
{
|
{
|
||||||
EraseSelectedTool();
|
EraseSelectedTool();
|
||||||
@@ -497,7 +497,7 @@ void HandleEvent (void)
|
|||||||
{
|
{
|
||||||
case GpKeyboardInputEventTypes::kDown:
|
case GpKeyboardInputEventTypes::kDown:
|
||||||
case GpKeyboardInputEventTypes::kAuto:
|
case GpKeyboardInputEventTypes::kAuto:
|
||||||
HandleKeyEvent(eventKeys, theEvent.m_vosEvent.m_event.m_keyboardInputEvent);
|
HandleKeyEvent(*eventKeys, theEvent.m_vosEvent.m_event.m_keyboardInputEvent);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
#include "Environ.h"
|
#include "Environ.h"
|
||||||
#include "FontManager.h"
|
#include "FontManager.h"
|
||||||
#include "FontFamily.h"
|
#include "FontFamily.h"
|
||||||
|
#include "InputManager.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "Objects.h"
|
#include "Objects.h"
|
||||||
#include "RectUtils.h"
|
#include "RectUtils.h"
|
||||||
@@ -141,7 +142,6 @@ void DoGameOverStarAnimation (void)
|
|||||||
{
|
{
|
||||||
#define kStarFalls 8
|
#define kStarFalls 8
|
||||||
TimeTaggedVOSEvent theEvent;
|
TimeTaggedVOSEvent theEvent;
|
||||||
KeyDownStates theKeys;
|
|
||||||
Rect angelDest;
|
Rect angelDest;
|
||||||
long nextLoop;
|
long nextLoop;
|
||||||
short which, i, count, pass;
|
short which, i, count, pass;
|
||||||
@@ -212,8 +212,9 @@ void DoGameOverStarAnimation (void)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
GetKeys(theKeys);
|
const KeyDownStates *theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
if ((BitTst(theKeys, PL_KEY_EITHER_SPECIAL(kControl))) || (BitTst(theKeys, PL_KEY_EITHER_SPECIAL(kAlt))) || (BitTst(theKeys, PL_KEY_EITHER_SPECIAL(kShift))))
|
|
||||||
|
if ((theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kControl))) || (theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kAlt))) || (theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kShift))))
|
||||||
noInteruption = false;
|
noInteruption = false;
|
||||||
|
|
||||||
if (PortabilityLayer::EventQueue::GetInstance()->Dequeue(&theEvent))
|
if (PortabilityLayer::EventQueue::GetInstance()->Dequeue(&theEvent))
|
||||||
@@ -442,7 +443,6 @@ void DrawPages (void)
|
|||||||
void DoDiedGameOver (void)
|
void DoDiedGameOver (void)
|
||||||
{
|
{
|
||||||
TimeTaggedVOSEvent theEvent;
|
TimeTaggedVOSEvent theEvent;
|
||||||
KeyDownStates theKeys;
|
|
||||||
long nextLoop;
|
long nextLoop;
|
||||||
Boolean userAborted;
|
Boolean userAborted;
|
||||||
|
|
||||||
@@ -459,8 +459,9 @@ void DoDiedGameOver (void)
|
|||||||
DrawPages();
|
DrawPages();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
GetKeys(theKeys);
|
const KeyDownStates *theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
if ((BitTst(theKeys, PL_KEY_EITHER_SPECIAL(kAlt))) || (BitTst(theKeys, PL_KEY_EITHER_SPECIAL(kControl))) || (BitTst(theKeys, PL_KEY_EITHER_SPECIAL(kShift))))
|
|
||||||
|
if ((theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kAlt))) || (theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kControl))) || (theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kShift))))
|
||||||
{
|
{
|
||||||
pagesStuck = 8;
|
pagesStuck = 8;
|
||||||
userAborted = true;
|
userAborted = true;
|
||||||
|
@@ -89,7 +89,7 @@ void OpenHouseMovie (void)
|
|||||||
if (theErr != PLErrors::kNone)
|
if (theErr != PLErrors::kNone)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
theErr = OpenMovieFile(theSpec, &movieRefNum, fsCurPerm);
|
theErr = OpenMovieFile(theSpec, &movieRefNum, 0);
|
||||||
if (theErr != PLErrors::kNone)
|
if (theErr != PLErrors::kNone)
|
||||||
{
|
{
|
||||||
YellowAlert(kYellowQTMovieNotLoaded, theErr);
|
YellowAlert(kYellowQTMovieNotLoaded, theErr);
|
||||||
|
@@ -31,7 +31,6 @@ Boolean QuerySaveGame (void);
|
|||||||
|
|
||||||
|
|
||||||
demoPtr demoData;
|
demoPtr demoData;
|
||||||
KeyDownStates theKeys;
|
|
||||||
Dialog *saveDial;
|
Dialog *saveDial;
|
||||||
short demoIndex, batteryFrame;
|
short demoIndex, batteryFrame;
|
||||||
Boolean isEscPauseKey, paused, batteryWasEngaged;
|
Boolean isEscPauseKey, paused, batteryWasEngaged;
|
||||||
@@ -54,8 +53,10 @@ void LogDemoKey (char keyIs)
|
|||||||
//-------------------------------------------------------------- DoCommandKey
|
//-------------------------------------------------------------- DoCommandKey
|
||||||
|
|
||||||
void DoCommandKey (void)
|
void DoCommandKey (void)
|
||||||
{
|
{
|
||||||
if (BitTst(theKeys, PL_KEY_ASCII('Q')))
|
const KeyDownStates *theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
|
|
||||||
|
if (theKeys->IsSet(PL_KEY_ASCII('Q')))
|
||||||
{
|
{
|
||||||
playing = false;
|
playing = false;
|
||||||
paused = false;
|
paused = false;
|
||||||
@@ -65,7 +66,7 @@ void DoCommandKey (void)
|
|||||||
SaveGame2(); // New save game.
|
SaveGame2(); // New save game.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((BitTst(theKeys, PL_KEY_ASCII('S'))) && (!twoPlayerGame))
|
else if ((theKeys->IsSet(PL_KEY_ASCII('S'))) && (!twoPlayerGame))
|
||||||
{
|
{
|
||||||
RefreshScoreboard(kSavingTitleMode);
|
RefreshScoreboard(kSavingTitleMode);
|
||||||
SaveGame2(); // New save game.
|
SaveGame2(); // New save game.
|
||||||
@@ -89,23 +90,27 @@ void DoPause (void)
|
|||||||
LoadScaledGraphic(surface, kEscPausePictID, &bounds);
|
LoadScaledGraphic(surface, kEscPausePictID, &bounds);
|
||||||
else
|
else
|
||||||
LoadScaledGraphic(surface, kTabPausePictID, &bounds);
|
LoadScaledGraphic(surface, kTabPausePictID, &bounds);
|
||||||
|
|
||||||
|
const KeyDownStates *theKeys = nullptr;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
GetKeys(theKeys);
|
theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
|
|
||||||
Delay(1, nullptr);
|
Delay(1, nullptr);
|
||||||
}
|
}
|
||||||
while ((isEscPauseKey && BitTst(theKeys, PL_KEY_SPECIAL(kEscape))) ||
|
while ((isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kEscape))) ||
|
||||||
(!isEscPauseKey && BitTst(theKeys, PL_KEY_SPECIAL(kTab))));
|
(!isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kTab))));
|
||||||
|
|
||||||
paused = true;
|
paused = true;
|
||||||
while (paused)
|
while (paused)
|
||||||
{
|
{
|
||||||
GetKeys(theKeys);
|
theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
if ((isEscPauseKey && BitTst(theKeys, PL_KEY_SPECIAL(kEscape))) ||
|
|
||||||
(!isEscPauseKey && BitTst(theKeys, PL_KEY_SPECIAL(kTab))))
|
if ((isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kEscape))) ||
|
||||||
|
(!isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kTab))))
|
||||||
paused = false;
|
paused = false;
|
||||||
else if (BitTst(theKeys, PL_KEY_EITHER_SPECIAL(kControl)))
|
else if (theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kControl)))
|
||||||
DoCommandKey();
|
DoCommandKey();
|
||||||
|
|
||||||
Delay(1, nullptr);
|
Delay(1, nullptr);
|
||||||
@@ -117,11 +122,11 @@ void DoPause (void)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
GetKeys(theKeys);
|
theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
Delay(1, nullptr);
|
Delay(1, nullptr);
|
||||||
}
|
}
|
||||||
while ((isEscPauseKey && BitTst(theKeys, PL_KEY_SPECIAL(kEscape))) ||
|
while ((isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kEscape))) ||
|
||||||
(!isEscPauseKey && BitTst(theKeys, PL_KEY_SPECIAL(kTab))));
|
(!isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kTab))));
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- DoBatteryEngaged
|
//-------------------------------------------------------------- DoBatteryEngaged
|
||||||
@@ -193,20 +198,21 @@ void DoHeliumEngaged (gliderPtr thisGlider)
|
|||||||
|
|
||||||
void GetDemoInput (gliderPtr thisGlider)
|
void GetDemoInput (gliderPtr thisGlider)
|
||||||
{
|
{
|
||||||
|
const KeyDownStates *theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
|
|
||||||
if (thisGlider->which == kPlayer1)
|
if (thisGlider->which == kPlayer1)
|
||||||
{
|
{
|
||||||
GetKeys(theKeys);
|
|
||||||
|
|
||||||
#if BUILD_ARCADE_VERSION
|
#if BUILD_ARCADE_VERSION
|
||||||
|
|
||||||
if ((BitTst(theKeys, thisGlider->leftKey)) ||
|
if ((theKeys->IsSet(thisGlider->leftKey)) ||
|
||||||
(BitTst(theKeys, thisGlider->gamepadLeftKey)) ||
|
(theKeys->IsSet(thisGlider->gamepadLeftKey)) ||
|
||||||
(BitTst(theKeys, thisGlider->rightKey)) ||
|
(theKeys->IsSet(thisGlider->rightKey)) ||
|
||||||
(BitTst(theKeys, thisGlider->gamepadRightKey)) ||
|
(theKeys->IsSet(thisGlider->gamepadRightKey)) ||
|
||||||
(BitTst(theKeys, thisGlider->battKey)) ||
|
(theKeys->IsSet(thisGlider->battKey)) ||
|
||||||
(BitTst(theKeys, thisGlider->gamepadBattKey)) ||
|
(theKeys->IsSet(thisGlider->gamepadBattKey)) ||
|
||||||
(BitTst(theKeys, thisGlider->bandKey)) ||
|
(theKeys->IsSet(thisGlider->bandKey)) ||
|
||||||
(BitTst(theKeys, thisGlider->gamepadBandKey)))
|
(theKeys->IsSet(thisGlider->gamepadBandKey)))
|
||||||
{
|
{
|
||||||
playing = false;
|
playing = false;
|
||||||
paused = false;
|
paused = false;
|
||||||
@@ -214,7 +220,7 @@ void DoHeliumEngaged (gliderPtr thisGlider)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
if (BitTst(&theKeys, kCommandKeyMap))
|
if (theKeys->IsSet(kCommandKeyMap))
|
||||||
DoCommandKey();
|
DoCommandKey();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -280,8 +286,8 @@ void DoHeliumEngaged (gliderPtr thisGlider)
|
|||||||
else
|
else
|
||||||
thisGlider->fireHeld = false;
|
thisGlider->fireHeld = false;
|
||||||
|
|
||||||
if ((isEscPauseKey && BitTst(theKeys, PL_KEY_SPECIAL(kEscape))) ||
|
if ((isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kEscape))) ||
|
||||||
(!isEscPauseKey && BitTst(theKeys, PL_KEY_SPECIAL(kTab))))
|
(!isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kTab))))
|
||||||
{
|
{
|
||||||
DoPause();
|
DoPause();
|
||||||
}
|
}
|
||||||
@@ -294,8 +300,9 @@ void GetInput (gliderPtr thisGlider)
|
|||||||
{
|
{
|
||||||
if (thisGlider->which == kPlayer1)
|
if (thisGlider->which == kPlayer1)
|
||||||
{
|
{
|
||||||
GetKeys(theKeys);
|
const KeyDownStates *theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
if (BitTst(theKeys, PL_KEY_EITHER_SPECIAL(kControl)))
|
|
||||||
|
if (theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kControl)))
|
||||||
DoCommandKey();
|
DoCommandKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,33 +320,35 @@ void GetInput (gliderPtr thisGlider)
|
|||||||
bool leftState = false;
|
bool leftState = false;
|
||||||
bool rightState = false;
|
bool rightState = false;
|
||||||
|
|
||||||
if (BitTst(theKeys, thisGlider->rightKey) || BitTst(theKeys, thisGlider->gamepadRightKey)) // right key
|
const KeyDownStates *theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
|
|
||||||
|
if (theKeys->IsSet(thisGlider->rightKey) || theKeys->IsSet(thisGlider->gamepadRightKey)) // right key
|
||||||
{
|
{
|
||||||
PL_NotYetImplemented_TODO("FixDemo"); // Flips aren't recorded in the demo properly
|
PL_NotYetImplemented_TODO("FixDemo"); // Flips aren't recorded in the demo properly
|
||||||
|
|
||||||
if (BitTst(theKeys, thisGlider->leftKey) || BitTst(theKeys, thisGlider->gamepadLeftKey))
|
if (theKeys->IsSet(thisGlider->leftKey) || theKeys->IsSet(thisGlider->gamepadLeftKey))
|
||||||
continuousFlipState = true;
|
continuousFlipState = true;
|
||||||
else
|
else
|
||||||
rightState = true;
|
rightState = true;
|
||||||
}
|
}
|
||||||
else if (BitTst(theKeys, thisGlider->leftKey) || BitTst(theKeys, thisGlider->gamepadLeftKey)) // left key
|
else if (theKeys->IsSet(thisGlider->leftKey) || theKeys->IsSet(thisGlider->gamepadLeftKey)) // left key
|
||||||
leftState = true;
|
leftState = true;
|
||||||
else
|
else
|
||||||
thisGlider->tipped = false;
|
thisGlider->tipped = false;
|
||||||
|
|
||||||
if (BitTst(theKeys, thisGlider->gamepadRightKey))
|
if (theKeys->IsSet(thisGlider->gamepadRightKey))
|
||||||
rightState = true;
|
rightState = true;
|
||||||
|
|
||||||
if (BitTst(theKeys, thisGlider->gamepadLeftKey))
|
if (theKeys->IsSet(thisGlider->gamepadLeftKey))
|
||||||
leftState = true;
|
leftState = true;
|
||||||
|
|
||||||
if (BitTst(theKeys, thisGlider->gamepadFaceLeftKey) && thisGlider->facing == kFaceRight)
|
if (theKeys->IsSet(thisGlider->gamepadFaceLeftKey) && thisGlider->facing == kFaceRight)
|
||||||
continuousFlipState = true;
|
continuousFlipState = true;
|
||||||
|
|
||||||
if (BitTst(theKeys, thisGlider->gamepadFaceRightKey) && thisGlider->facing == kFaceLeft)
|
if (theKeys->IsSet(thisGlider->gamepadFaceRightKey) && thisGlider->facing == kFaceLeft)
|
||||||
continuousFlipState = true;
|
continuousFlipState = true;
|
||||||
|
|
||||||
if (BitTst(theKeys, thisGlider->gamepadFlipKey))
|
if (theKeys->IsSet(thisGlider->gamepadFlipKey))
|
||||||
holdFlipState = true;
|
holdFlipState = true;
|
||||||
|
|
||||||
if (thisGlider->which == kPlayer1 || thisGlider->which == kPlayer2)
|
if (thisGlider->which == kPlayer1 || thisGlider->which == kPlayer2)
|
||||||
@@ -397,7 +406,7 @@ void GetInput (gliderPtr thisGlider)
|
|||||||
if (!leftState && !rightState)
|
if (!leftState && !rightState)
|
||||||
thisGlider->tipped = false;
|
thisGlider->tipped = false;
|
||||||
|
|
||||||
if ((BitTst(theKeys, thisGlider->battKey) || BitTst(theKeys, thisGlider->gamepadBattKey)) && (batteryTotal != 0) &&
|
if ((theKeys->IsSet(thisGlider->battKey) || theKeys->IsSet(thisGlider->gamepadBattKey)) && (batteryTotal != 0) &&
|
||||||
(thisGlider->mode == kGliderNormal))
|
(thisGlider->mode == kGliderNormal))
|
||||||
{
|
{
|
||||||
#ifdef CREATEDEMODATA
|
#ifdef CREATEDEMODATA
|
||||||
@@ -411,7 +420,7 @@ void GetInput (gliderPtr thisGlider)
|
|||||||
else
|
else
|
||||||
batteryWasEngaged = false;
|
batteryWasEngaged = false;
|
||||||
|
|
||||||
if ((BitTst(theKeys, thisGlider->bandKey) || BitTst(theKeys, thisGlider->gamepadBandKey)) && (bandsTotal > 0) &&
|
if ((theKeys->IsSet(thisGlider->bandKey) || theKeys->IsSet(thisGlider->gamepadBandKey)) && (bandsTotal > 0) &&
|
||||||
(thisGlider->mode == kGliderNormal))
|
(thisGlider->mode == kGliderNormal))
|
||||||
{
|
{
|
||||||
#ifdef CREATEDEMODATA
|
#ifdef CREATEDEMODATA
|
||||||
@@ -434,14 +443,14 @@ void GetInput (gliderPtr thisGlider)
|
|||||||
thisGlider->fireHeld = false;
|
thisGlider->fireHeld = false;
|
||||||
|
|
||||||
if ((otherPlayerEscaped != kNoOneEscaped) &&
|
if ((otherPlayerEscaped != kNoOneEscaped) &&
|
||||||
(BitTst(theKeys, PL_KEY_SPECIAL(kDelete))) &&
|
(theKeys->IsSet(PL_KEY_SPECIAL(kDelete))) &&
|
||||||
(thisGlider->which) && (!onePlayerLeft))
|
(thisGlider->which) && (!onePlayerLeft))
|
||||||
{
|
{
|
||||||
ForceKillGlider();
|
ForceKillGlider();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((isEscPauseKey && BitTst(theKeys, PL_KEY_SPECIAL(kEscape))) ||
|
if ((isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kEscape))) ||
|
||||||
(!isEscPauseKey && BitTst(theKeys, PL_KEY_SPECIAL(kTab))))
|
(!isEscPauseKey && theKeys->IsSet(PL_KEY_SPECIAL(kTab))))
|
||||||
{
|
{
|
||||||
DoPause();
|
DoPause();
|
||||||
}
|
}
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#include "Environ.h"
|
#include "Environ.h"
|
||||||
#include "FontFamily.h"
|
#include "FontFamily.h"
|
||||||
#include "House.h"
|
#include "House.h"
|
||||||
|
#include "InputManager.h"
|
||||||
#include "MenuManager.h"
|
#include "MenuManager.h"
|
||||||
#include "RectUtils.h"
|
#include "RectUtils.h"
|
||||||
#include "PLKeyEncoding.h"
|
#include "PLKeyEncoding.h"
|
||||||
@@ -378,7 +379,6 @@ void UpdateEditWindowTitle (void)
|
|||||||
|
|
||||||
void HandleMainClick (Point wherePt, Boolean isDoubleClick)
|
void HandleMainClick (Point wherePt, Boolean isDoubleClick)
|
||||||
{
|
{
|
||||||
KeyDownStates theseKeys;
|
|
||||||
|
|
||||||
if ((theMode != kEditMode) || (mainWindow == nil) ||
|
if ((theMode != kEditMode) || (mainWindow == nil) ||
|
||||||
(!houseUnlocked))
|
(!houseUnlocked))
|
||||||
@@ -393,9 +393,10 @@ void HandleMainClick (Point wherePt, Boolean isDoubleClick)
|
|||||||
DoSelectionClick(mainWindowSurface, wherePt, isDoubleClick);
|
DoSelectionClick(mainWindowSurface, wherePt, isDoubleClick);
|
||||||
else
|
else
|
||||||
DoNewObjectClick(wherePt);
|
DoNewObjectClick(wherePt);
|
||||||
|
|
||||||
GetKeys(theseKeys);
|
const KeyDownStates *theseKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
if (!BitTst(theseKeys, PL_KEY_EITHER_SPECIAL(kShift)))
|
|
||||||
|
if (!theseKeys->IsSet(PL_KEY_EITHER_SPECIAL(kShift)))
|
||||||
{
|
{
|
||||||
EraseSelectedTool();
|
EraseSelectedTool();
|
||||||
SelectTool(kSelectTool);
|
SelectTool(kSelectTool);
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
#include "PLToolUtils.h"
|
#include "PLToolUtils.h"
|
||||||
#include "PLKeyEncoding.h"
|
#include "PLKeyEncoding.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
|
#include "InputManager.h"
|
||||||
#include "ObjectEdit.h"
|
#include "ObjectEdit.h"
|
||||||
#include "RectUtils.h"
|
#include "RectUtils.h"
|
||||||
|
|
||||||
@@ -48,7 +49,6 @@ short wasFlower;
|
|||||||
|
|
||||||
Boolean AddNewObject (Point where, short what, Boolean showItNow)
|
Boolean AddNewObject (Point where, short what, Boolean showItNow)
|
||||||
{
|
{
|
||||||
KeyDownStates theseKeys;
|
|
||||||
Rect srcRect, newRect;
|
Rect srcRect, newRect;
|
||||||
short direction, dist;
|
short direction, dist;
|
||||||
Boolean handled, drawWholeRoom;
|
Boolean handled, drawWholeRoom;
|
||||||
@@ -738,13 +738,16 @@ Boolean AddNewObject (Point where, short what, Boolean showItNow)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kFlower:
|
case kFlower:
|
||||||
GetKeys(theseKeys);
|
{
|
||||||
if (!BitTst(theseKeys, PL_KEY_EITHER_SPECIAL(kShift)))
|
const KeyDownStates *theseKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
wasFlower = RandomInt(kNumFlowers);
|
|
||||||
newRect = flowerSrc[wasFlower];
|
if (!theseKeys->IsSet(PL_KEY_EITHER_SPECIAL(kShift)))
|
||||||
CenterRectOnPoint(&newRect, where);
|
wasFlower = RandomInt(kNumFlowers);
|
||||||
thisRoom->objects[objActive].data.i.bounds = newRect;
|
newRect = flowerSrc[wasFlower];
|
||||||
thisRoom->objects[objActive].data.i.pict = wasFlower;
|
CenterRectOnPoint(&newRect, where);
|
||||||
|
thisRoom->objects[objActive].data.i.bounds = newRect;
|
||||||
|
thisRoom->objects[objActive].data.i.pict = wasFlower;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kOzma:
|
case kOzma:
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#include "PLPasStr.h"
|
#include "PLPasStr.h"
|
||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "House.h"
|
#include "House.h"
|
||||||
|
#include "InputManager.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "Marquee.h"
|
#include "Marquee.h"
|
||||||
#include "ObjectEdit.h"
|
#include "ObjectEdit.h"
|
||||||
@@ -2683,7 +2684,7 @@ void DrawThisRoomsObjects (void)
|
|||||||
void HiliteAllObjects (void)
|
void HiliteAllObjects (void)
|
||||||
{
|
{
|
||||||
#ifndef COMPILEDEMO
|
#ifndef COMPILEDEMO
|
||||||
KeyDownStates theseKeys;
|
const KeyDownStates *theseKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
short i;
|
short i;
|
||||||
Pattern dummyPattern;
|
Pattern dummyPattern;
|
||||||
|
|
||||||
@@ -2701,10 +2702,10 @@ void HiliteAllObjects (void)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
GetKeys(theseKeys);
|
Delay(1, nullptr);
|
||||||
}
|
}
|
||||||
while ((BitTst(theseKeys, PL_KEY_EITHER_SPECIAL(kControl))) &&
|
while ((theseKeys->IsSet(PL_KEY_EITHER_SPECIAL(kControl))) &&
|
||||||
(BitTst(theseKeys, PL_KEY_EITHER_SPECIAL(kAlt))));
|
(theseKeys->IsSet(PL_KEY_EITHER_SPECIAL(kAlt))));
|
||||||
|
|
||||||
for (i = 0; i < kMaxRoomObs; i++)
|
for (i = 0; i < kMaxRoomObs; i++)
|
||||||
surface->InvertFrameRect(roomObjectRects[i], dummyPattern);
|
surface->InvertFrameRect(roomObjectRects[i], dummyPattern);
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
#include "Externs.h"
|
#include "Externs.h"
|
||||||
#include "FontFamily.h"
|
#include "FontFamily.h"
|
||||||
#include "House.h"
|
#include "House.h"
|
||||||
|
#include "InputManager.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "RectUtils.h"
|
#include "RectUtils.h"
|
||||||
|
|
||||||
@@ -161,7 +162,6 @@ void SetInitialTiles (short background, Boolean doRoom)
|
|||||||
#ifndef COMPILEDEMO
|
#ifndef COMPILEDEMO
|
||||||
Boolean CreateNewRoom (short h, short v)
|
Boolean CreateNewRoom (short h, short v)
|
||||||
{
|
{
|
||||||
KeyDownStates theKeys;
|
|
||||||
long howMuch;
|
long howMuch;
|
||||||
PLError_t theErr;
|
PLError_t theErr;
|
||||||
short i, availableRoom;
|
short i, availableRoom;
|
||||||
@@ -221,9 +221,10 @@ Boolean CreateNewRoom (short h, short v)
|
|||||||
noRoomAtAll = false;
|
noRoomAtAll = false;
|
||||||
fileDirty = true;
|
fileDirty = true;
|
||||||
UpdateMenus(false);
|
UpdateMenus(false);
|
||||||
|
|
||||||
GetKeys(theKeys);
|
const KeyDownStates *theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
if (BitTst(theKeys, PL_KEY_EITHER_SPECIAL(kShift)))
|
|
||||||
|
if (theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kShift)))
|
||||||
newRoomNow = false;
|
newRoomNow = false;
|
||||||
else
|
else
|
||||||
newRoomNow = autoRoomEdit; // Flag to bring up RoomInfo
|
newRoomNow = autoRoomEdit; // Flag to bring up RoomInfo
|
||||||
|
@@ -379,7 +379,6 @@ long LongSquareRoot (long theNumber)
|
|||||||
Boolean WaitForInputEvent (short seconds)
|
Boolean WaitForInputEvent (short seconds)
|
||||||
{
|
{
|
||||||
TimeTaggedVOSEvent theEvent;
|
TimeTaggedVOSEvent theEvent;
|
||||||
KeyDownStates theKeys;
|
|
||||||
long timeToBail;
|
long timeToBail;
|
||||||
Boolean waiting, didResume;
|
Boolean waiting, didResume;
|
||||||
|
|
||||||
@@ -387,11 +386,13 @@ Boolean WaitForInputEvent (short seconds)
|
|||||||
FlushEvents(everyEvent, 0);
|
FlushEvents(everyEvent, 0);
|
||||||
waiting = true;
|
waiting = true;
|
||||||
didResume = false;
|
didResume = false;
|
||||||
|
|
||||||
|
|
||||||
while (waiting)
|
while (waiting)
|
||||||
{
|
{
|
||||||
GetKeys(theKeys);
|
const KeyDownStates *theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
if (BitTst(theKeys, PL_KEY_EITHER_SPECIAL(kControl)) || BitTst(theKeys, PL_KEY_EITHER_SPECIAL(kAlt)) || BitTst(theKeys, PL_KEY_EITHER_SPECIAL(kShift)))
|
|
||||||
|
if (theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kControl)) || theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kAlt)) || theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kShift)))
|
||||||
waiting = false;
|
waiting = false;
|
||||||
|
|
||||||
if (PortabilityLayer::EventQueue::GetInstance()->Dequeue(&theEvent))
|
if (PortabilityLayer::EventQueue::GetInstance()->Dequeue(&theEvent))
|
||||||
@@ -414,15 +415,15 @@ Boolean WaitForInputEvent (short seconds)
|
|||||||
|
|
||||||
void WaitCommandQReleased (void)
|
void WaitCommandQReleased (void)
|
||||||
{
|
{
|
||||||
KeyDownStates theKeys;
|
|
||||||
Boolean waiting;
|
Boolean waiting;
|
||||||
|
|
||||||
waiting = true;
|
waiting = true;
|
||||||
|
|
||||||
while (waiting)
|
while (waiting)
|
||||||
{
|
{
|
||||||
GetKeys(theKeys);
|
const KeyDownStates *theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
if (!BitTst(theKeys, PL_KEY_EITHER_SPECIAL(kControl)) || !BitTst(theKeys, PL_KEY_ASCII('Q')))
|
|
||||||
|
if (!theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kControl)) || !theKeys->IsSet(PL_KEY_ASCII('Q')))
|
||||||
waiting = false;
|
waiting = false;
|
||||||
|
|
||||||
Delay(1, nullptr);
|
Delay(1, nullptr);
|
||||||
@@ -464,10 +465,9 @@ void GetKeyName (intptr_t message, StringPtr theName)
|
|||||||
|
|
||||||
Boolean OptionKeyDown (void)
|
Boolean OptionKeyDown (void)
|
||||||
{
|
{
|
||||||
KeyDownStates theKeys;
|
const KeyDownStates *theKeys = PortabilityLayer::InputManager::GetInstance()->GetKeys();
|
||||||
|
|
||||||
GetKeys(theKeys);
|
if (theKeys->IsSet(PL_KEY_EITHER_SPECIAL(kAlt)))
|
||||||
if (BitTst(theKeys, PL_KEY_EITHER_SPECIAL(kAlt)))
|
|
||||||
return (true);
|
return (true);
|
||||||
else
|
else
|
||||||
return (false);
|
return (false);
|
||||||
|
@@ -12,7 +12,7 @@ namespace PortabilityLayer
|
|||||||
public:
|
public:
|
||||||
InputManagerImpl();
|
InputManagerImpl();
|
||||||
|
|
||||||
void GetKeys(KeyDownStates &keyMap) const override;
|
const KeyDownStates *GetKeys() const override;
|
||||||
void ApplyKeyboardEvent(const GpKeyboardInputEvent &vosEvent) override;
|
void ApplyKeyboardEvent(const GpKeyboardInputEvent &vosEvent) override;
|
||||||
void ApplyGamepadEvent(const GpGamepadInputEvent &vosEvent) override;
|
void ApplyGamepadEvent(const GpGamepadInputEvent &vosEvent) override;
|
||||||
int16_t GetGamepadAxis(unsigned int playerNum, GpGamepadAxis_t gamepadAxis) override;
|
int16_t GetGamepadAxis(unsigned int playerNum, GpGamepadAxis_t gamepadAxis) override;
|
||||||
@@ -30,9 +30,9 @@ namespace PortabilityLayer
|
|||||||
static InputManagerImpl ms_instance;
|
static InputManagerImpl ms_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
void InputManagerImpl::GetKeys(KeyDownStates &keyMap) const
|
const KeyDownStates *InputManagerImpl::GetKeys() const
|
||||||
{
|
{
|
||||||
keyMap = m_keyMap;
|
return &m_keyMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputManagerImpl::ApplyKeyboardEvent(const GpKeyboardInputEvent &vosEvent)
|
void InputManagerImpl::ApplyKeyboardEvent(const GpKeyboardInputEvent &vosEvent)
|
||||||
|
@@ -11,7 +11,7 @@ namespace PortabilityLayer
|
|||||||
class InputManager
|
class InputManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void GetKeys(KeyDownStates &keys16) const = 0;
|
virtual const KeyDownStates *GetKeys() const = 0;
|
||||||
virtual void ApplyKeyboardEvent(const GpKeyboardInputEvent &vosEvent) = 0;
|
virtual void ApplyKeyboardEvent(const GpKeyboardInputEvent &vosEvent) = 0;
|
||||||
virtual void ApplyGamepadEvent(const GpGamepadInputEvent &vosEvent) = 0;
|
virtual void ApplyGamepadEvent(const GpGamepadInputEvent &vosEvent) = 0;
|
||||||
virtual int16_t GetGamepadAxis(unsigned int playerNum, GpGamepadAxis_t gamepadAxis) = 0;
|
virtual int16_t GetGamepadAxis(unsigned int playerNum, GpGamepadAxis_t gamepadAxis) = 0;
|
||||||
|
@@ -274,11 +274,6 @@ long TickCount()
|
|||||||
return PortabilityLayer::DisplayDeviceManager::GetInstance()->GetTickCount();
|
return PortabilityLayer::DisplayDeviceManager::GetInstance()->GetTickCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetKeys(KeyDownStates &keyMap)
|
|
||||||
{
|
|
||||||
PortabilityLayer::InputManager::GetInstance()->GetKeys(keyMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
short LoWord(Int32 v)
|
short LoWord(Int32 v)
|
||||||
{
|
{
|
||||||
return ((v ^ 0x8000) & 0xffff) - 0x8000;
|
return ((v ^ 0x8000) & 0xffff) - 0x8000;
|
||||||
@@ -289,60 +284,6 @@ short HiWord(Int32 v)
|
|||||||
return (((v >> 16) ^ 0x8000) & 0xffff) - 0x8000;
|
return (((v >> 16) ^ 0x8000) & 0xffff) - 0x8000;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool BitTestEitherSpecial(const KeyDownStates &keyMap, int eitherSpecial)
|
|
||||||
{
|
|
||||||
switch (eitherSpecial)
|
|
||||||
{
|
|
||||||
case KeyEventEitherSpecialCategories::kAlt:
|
|
||||||
return keyMap.m_special.Get(GpKeySpecials::kLeftAlt) || keyMap.m_special.Get(GpKeySpecials::kRightAlt);
|
|
||||||
case KeyEventEitherSpecialCategories::kShift:
|
|
||||||
return keyMap.m_special.Get(GpKeySpecials::kLeftShift) || keyMap.m_special.Get(GpKeySpecials::kRightShift);
|
|
||||||
case KeyEventEitherSpecialCategories::kControl:
|
|
||||||
return keyMap.m_special.Get(GpKeySpecials::kLeftCtrl) || keyMap.m_special.Get(GpKeySpecials::kRightCtrl);
|
|
||||||
default:
|
|
||||||
assert(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BitTst(const KeyDownStates &keyMap, int encodedKey)
|
|
||||||
{
|
|
||||||
const KeyEventType evtType = PL_KEY_GET_EVENT_TYPE(encodedKey);
|
|
||||||
const int evtValue = PL_KEY_GET_VALUE(encodedKey);
|
|
||||||
|
|
||||||
switch (evtType)
|
|
||||||
{
|
|
||||||
case KeyEventType_Special:
|
|
||||||
return keyMap.m_special.Get(evtValue);
|
|
||||||
case KeyEventType_ASCII:
|
|
||||||
return keyMap.m_ascii.Get(evtValue);
|
|
||||||
case KeyEventType_MacRoman:
|
|
||||||
assert(evtValue >= 128 && evtValue < 256);
|
|
||||||
return keyMap.m_macRoman.Get(evtValue - 128);
|
|
||||||
case KeyEventType_NumPadNumber:
|
|
||||||
return keyMap.m_numPadNumber.Get(evtValue);
|
|
||||||
case KeyEventType_NumPadSpecial:
|
|
||||||
return keyMap.m_numPadSpecial.Get(evtValue);
|
|
||||||
case KeyEventType_FKey:
|
|
||||||
assert(evtValue >= 1 && evtValue <= GpFKeyMaximumInclusive);
|
|
||||||
return keyMap.m_fKey.Get(evtValue - 1);
|
|
||||||
case KeyEventType_EitherSpecial:
|
|
||||||
return BitTestEitherSpecial(keyMap, evtValue);
|
|
||||||
case KeyEventType_GamepadButton:
|
|
||||||
{
|
|
||||||
unsigned int playerNum = evtValue & ((1 << PL_INPUT_PLAYER_INDEX_BITS) - 1);
|
|
||||||
assert(playerNum < PL_INPUT_MAX_PLAYERS);
|
|
||||||
unsigned int button = evtValue >> PL_INPUT_PLAYER_INDEX_BITS;
|
|
||||||
|
|
||||||
return keyMap.m_gamepadButtons[playerNum].Get(button);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(false);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void NumToString(long number, unsigned char *str)
|
void NumToString(long number, unsigned char *str)
|
||||||
{
|
{
|
||||||
unsigned char *firstChar = str + 1;
|
unsigned char *firstChar = str + 1;
|
||||||
@@ -408,13 +349,6 @@ void ParamText(const PLPasStr &title, const PLPasStr &a, const PLPasStr &b, cons
|
|||||||
PL_NotYetImplemented();
|
PL_NotYetImplemented();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UInt32 FreeMem()
|
|
||||||
{
|
|
||||||
PL_NotYetImplemented_Minor();
|
|
||||||
return 256 * 1024 * 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
PLError_t AEProcessAppleEvent(EventRecord *evt)
|
PLError_t AEProcessAppleEvent(EventRecord *evt)
|
||||||
{
|
{
|
||||||
PL_NotYetImplemented();
|
PL_NotYetImplemented();
|
||||||
@@ -446,13 +380,6 @@ void GetIndString(unsigned char *str, int stringsID, int fnameIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PLError_t PBDirCreate(HFileParam *fileParam, bool asynchronous)
|
|
||||||
{
|
|
||||||
PL_NotYetImplemented();
|
|
||||||
return PLErrors::kNone;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VFileSpec MakeVFileSpec(PortabilityLayer::VirtualDirectory_t dir, const PLPasStr &fileName)
|
VFileSpec MakeVFileSpec(PortabilityLayer::VirtualDirectory_t dir, const PLPasStr &fileName)
|
||||||
{
|
{
|
||||||
VFileSpec spec;
|
VFileSpec spec;
|
||||||
|
@@ -232,18 +232,6 @@ static const int everyEvent = -1;
|
|||||||
static const int iBeamCursor = 1;
|
static const int iBeamCursor = 1;
|
||||||
static const int watchCursor = 4;
|
static const int watchCursor = 4;
|
||||||
|
|
||||||
static const int shiftKey = 0x1;
|
|
||||||
static const int cmdKey = 0x2; // Ctrl
|
|
||||||
static const int optionKey = 0x4; // Alt
|
|
||||||
|
|
||||||
static const bool kCreateFolder = true;
|
|
||||||
static const bool kDontCreateFolder = false;
|
|
||||||
|
|
||||||
static const int fsRdPerm = 1;
|
|
||||||
static const int fsWrPerm = 2;
|
|
||||||
static const int fsRdWrPerm = (fsRdPerm | fsWrPerm);
|
|
||||||
static const int fsCurPerm = 4; // Any allowed permission
|
|
||||||
|
|
||||||
static const Boolean TRUE = 1;
|
static const Boolean TRUE = 1;
|
||||||
static const Boolean FALSE = 0;
|
static const Boolean FALSE = 0;
|
||||||
|
|
||||||
@@ -290,28 +278,21 @@ long MenuSelect(Point point); // Breaks into menu select routine (in practice we
|
|||||||
|
|
||||||
long MenuKey(int charCode);
|
long MenuKey(int charCode);
|
||||||
long TickCount();
|
long TickCount();
|
||||||
void GetKeys(KeyDownStates &keyMap);
|
|
||||||
|
|
||||||
short LoWord(Int32 v);
|
short LoWord(Int32 v);
|
||||||
short HiWord(Int32 v);
|
short HiWord(Int32 v);
|
||||||
bool BitTst(const KeyDownStates &keyMap, int bit);
|
|
||||||
|
|
||||||
void NumToString(long number, unsigned char *str);
|
void NumToString(long number, unsigned char *str);
|
||||||
void ParamText(const PLPasStr &title, const PLPasStr &a, const PLPasStr &b, const PLPasStr &c);
|
void ParamText(const PLPasStr &title, const PLPasStr &a, const PLPasStr &b, const PLPasStr &c);
|
||||||
|
|
||||||
UInt32 FreeMem();
|
|
||||||
|
|
||||||
PLError_t AEProcessAppleEvent(EventRecord *evt);
|
PLError_t AEProcessAppleEvent(EventRecord *evt);
|
||||||
|
|
||||||
void GetIndString(unsigned char *str, int stringsID, int fnameIndex); // Fetches a string resource of some sort
|
void GetIndString(unsigned char *str, int stringsID, int fnameIndex); // Fetches a string resource of some sort
|
||||||
PLError_t PBDirCreate(HFileParam *fileParam, bool asynchronous);
|
|
||||||
|
|
||||||
VFileSpec MakeVFileSpec(PortabilityLayer::VirtualDirectory_t dir, const PLPasStr &fileName);
|
VFileSpec MakeVFileSpec(PortabilityLayer::VirtualDirectory_t dir, const PLPasStr &fileName);
|
||||||
|
|
||||||
PLError_t FSpGetFInfo(const VFileSpec &spec, VFileInfo &finfoOut);
|
PLError_t FSpGetFInfo(const VFileSpec &spec, VFileInfo &finfoOut);
|
||||||
|
|
||||||
PLError_t PBGetCatInfo(CInfoPBPtr paramBlock, Boolean async);
|
|
||||||
|
|
||||||
DirectoryFileListEntry *GetDirectoryFiles(PortabilityLayer::VirtualDirectory_t dirID);
|
DirectoryFileListEntry *GetDirectoryFiles(PortabilityLayer::VirtualDirectory_t dirID);
|
||||||
void DisposeDirectoryFiles(DirectoryFileListEntry *firstDFL);
|
void DisposeDirectoryFiles(DirectoryFileListEntry *firstDFL);
|
||||||
|
|
||||||
|
57
PortabilityLayer/PLKeyEncoding.cpp
Normal file
57
PortabilityLayer/PLKeyEncoding.cpp
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
#include "PLKeyEncoding.h"
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
static bool BitTestEitherSpecial(const KeyDownStates &keyMap, int eitherSpecial)
|
||||||
|
{
|
||||||
|
switch (eitherSpecial)
|
||||||
|
{
|
||||||
|
case KeyEventEitherSpecialCategories::kAlt:
|
||||||
|
return keyMap.m_special.Get(GpKeySpecials::kLeftAlt) || keyMap.m_special.Get(GpKeySpecials::kRightAlt);
|
||||||
|
case KeyEventEitherSpecialCategories::kShift:
|
||||||
|
return keyMap.m_special.Get(GpKeySpecials::kLeftShift) || keyMap.m_special.Get(GpKeySpecials::kRightShift);
|
||||||
|
case KeyEventEitherSpecialCategories::kControl:
|
||||||
|
return keyMap.m_special.Get(GpKeySpecials::kLeftCtrl) || keyMap.m_special.Get(GpKeySpecials::kRightCtrl);
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KeyDownStates::IsSet(intptr_t encodedKey) const
|
||||||
|
{
|
||||||
|
const KeyEventType evtType = PL_KEY_GET_EVENT_TYPE(encodedKey);
|
||||||
|
const int evtValue = PL_KEY_GET_VALUE(encodedKey);
|
||||||
|
|
||||||
|
switch (evtType)
|
||||||
|
{
|
||||||
|
case KeyEventType_Special:
|
||||||
|
return m_special.Get(evtValue);
|
||||||
|
case KeyEventType_ASCII:
|
||||||
|
return m_ascii.Get(evtValue);
|
||||||
|
case KeyEventType_MacRoman:
|
||||||
|
assert(evtValue >= 128 && evtValue < 256);
|
||||||
|
return m_macRoman.Get(evtValue - 128);
|
||||||
|
case KeyEventType_NumPadNumber:
|
||||||
|
return m_numPadNumber.Get(evtValue);
|
||||||
|
case KeyEventType_NumPadSpecial:
|
||||||
|
return m_numPadSpecial.Get(evtValue);
|
||||||
|
case KeyEventType_FKey:
|
||||||
|
assert(evtValue >= 1 && evtValue <= GpFKeyMaximumInclusive);
|
||||||
|
return m_fKey.Get(evtValue - 1);
|
||||||
|
case KeyEventType_EitherSpecial:
|
||||||
|
return BitTestEitherSpecial(*this, evtValue);
|
||||||
|
case KeyEventType_GamepadButton:
|
||||||
|
{
|
||||||
|
unsigned int playerNum = evtValue & ((1 << PL_INPUT_PLAYER_INDEX_BITS) - 1);
|
||||||
|
assert(playerNum < PL_INPUT_MAX_PLAYERS);
|
||||||
|
unsigned int button = evtValue >> PL_INPUT_PLAYER_INDEX_BITS;
|
||||||
|
|
||||||
|
return m_gamepadButtons[playerNum].Get(button);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@@ -60,4 +60,6 @@ struct KeyDownStates
|
|||||||
GpBitfield<GpNumPadSpecials::kCount> m_numPadSpecial;
|
GpBitfield<GpNumPadSpecials::kCount> m_numPadSpecial;
|
||||||
GpBitfield<GpFKeyMaximumInclusive> m_fKey;
|
GpBitfield<GpFKeyMaximumInclusive> m_fKey;
|
||||||
GpBitfield<GpGamepadButtons::kCount> m_gamepadButtons[PL_INPUT_MAX_PLAYERS];
|
GpBitfield<GpGamepadButtons::kCount> m_gamepadButtons[PL_INPUT_MAX_PLAYERS];
|
||||||
|
|
||||||
|
bool IsSet(intptr_t packedVOSCode) const;
|
||||||
};
|
};
|
||||||
|
@@ -319,6 +319,7 @@
|
|||||||
<ClCompile Include="PLIconWidget.cpp" />
|
<ClCompile Include="PLIconWidget.cpp" />
|
||||||
<ClCompile Include="PLImageWidget.cpp" />
|
<ClCompile Include="PLImageWidget.cpp" />
|
||||||
<ClCompile Include="PLInvisibleWidget.cpp" />
|
<ClCompile Include="PLInvisibleWidget.cpp" />
|
||||||
|
<ClCompile Include="PLKeyEncoding.cpp" />
|
||||||
<ClCompile Include="PLLabelWidget.cpp" />
|
<ClCompile Include="PLLabelWidget.cpp" />
|
||||||
<ClCompile Include="PLMenus.cpp" />
|
<ClCompile Include="PLMenus.cpp" />
|
||||||
<ClCompile Include="PLMovies.cpp" />
|
<ClCompile Include="PLMovies.cpp" />
|
||||||
|
@@ -692,5 +692,8 @@
|
|||||||
<ClCompile Include="PLRadioButtonWidget.cpp">
|
<ClCompile Include="PLRadioButtonWidget.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="PLKeyEncoding.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Reference in New Issue
Block a user