mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-24 17:18:50 -05:00
commit
60eb1382e0
@ -87,6 +87,7 @@ set(Source_Files__Controller
|
||||
"KeyboardController.cpp"
|
||||
"KeyboardController.h"
|
||||
"UltraController.h"
|
||||
"DummyController.cpp"
|
||||
"DummyController.h"
|
||||
)
|
||||
|
||||
|
@ -389,4 +389,20 @@ namespace Ship {
|
||||
Commands[command] = entry;
|
||||
}
|
||||
}
|
||||
|
||||
std::string Console::GetCurrentChannel() {
|
||||
return currentChannel;
|
||||
}
|
||||
|
||||
bool Console::IsOpened() {
|
||||
return opened;
|
||||
}
|
||||
|
||||
void Console::Close() {
|
||||
opened = false;
|
||||
}
|
||||
|
||||
void Console::Open() {
|
||||
opened = true;
|
||||
}
|
||||
}
|
@ -93,10 +93,9 @@ namespace Ship {
|
||||
void Append(const std::string& channel, spdlog::level::level_enum priority, const char* fmt, ...);
|
||||
bool HasCommand(const std::string& command);
|
||||
void AddCommand(const std::string& command, CommandEntry entry);
|
||||
|
||||
std::string GetCurrentChannel() { return currentChannel; }
|
||||
bool IsOpened() { return opened; }
|
||||
void Close() { opened = false; }
|
||||
void Open() { opened = true; }
|
||||
std::string GetCurrentChannel();
|
||||
bool IsOpened();
|
||||
void Close();
|
||||
void Open();
|
||||
};
|
||||
}
|
@ -21,7 +21,7 @@ namespace Ship {
|
||||
size_t GetNumVirtualDevices();
|
||||
uint8_t* GetControllerBits();
|
||||
private:
|
||||
std::vector<int> virtualDevices = {};
|
||||
std::vector<int32_t> virtualDevices = {};
|
||||
std::vector<std::shared_ptr<Controller>> physicalDevices = {};
|
||||
uint8_t* controllerBits = nullptr;
|
||||
};
|
||||
|
@ -112,4 +112,16 @@ namespace Ship {
|
||||
std::shared_ptr<DeviceProfile> Controller::getProfile(int32_t virtualSlot) {
|
||||
return profiles[virtualSlot];
|
||||
}
|
||||
|
||||
std::shared_ptr<ControllerAttachment> Controller::GetAttachment() {
|
||||
return Attachment;
|
||||
}
|
||||
|
||||
bool Controller::IsRumbling() {
|
||||
return isRumbling;
|
||||
}
|
||||
|
||||
std::string Controller::GetGuid() {
|
||||
return GUID;
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ namespace Ship {
|
||||
public:
|
||||
virtual ~Controller() = default;
|
||||
Controller();
|
||||
void Read(OSContPad* pad, int32_t virtualSlot);
|
||||
virtual void ReadFromSource(int32_t virtualSlot) = 0;
|
||||
virtual void WriteToSource(int32_t virtualSlot, ControllerCallback* controller) = 0;
|
||||
virtual bool Connected() const = 0;
|
||||
@ -49,8 +48,12 @@ namespace Ship {
|
||||
virtual void CreateDefaultBinding(int32_t virtualSlot) = 0;
|
||||
virtual void ClearRawPress() = 0;
|
||||
virtual int32_t ReadRawPress() = 0;
|
||||
virtual const std::string GetButtonName(int32_t virtualSlot, int32_t n64Button) = 0;
|
||||
virtual const std::string GetControllerName() = 0;
|
||||
void Read(OSContPad* pad, int32_t virtualSlot);
|
||||
void SetButtonMapping(int32_t virtualSlot, int32_t n64Button, int32_t dwScancode);
|
||||
std::shared_ptr<ControllerAttachment> GetAttachment() { return Attachment; }
|
||||
std::shared_ptr<ControllerAttachment> GetAttachment();
|
||||
std::shared_ptr<DeviceProfile> getProfile(int32_t virtualSlot);
|
||||
int8_t& getLeftStickX(int32_t virtualSlot);
|
||||
int8_t& getLeftStickY(int32_t virtualSlot);
|
||||
int8_t& getRightStickX(int32_t virtualSlot);
|
||||
@ -58,11 +61,8 @@ namespace Ship {
|
||||
int32_t& getPressedButtons(int32_t virtualSlot);
|
||||
float& getGyroX(int32_t virtualSlot);
|
||||
float& getGyroY(int32_t virtualSlot);
|
||||
std::shared_ptr<DeviceProfile> getProfile(int32_t virtualSlot);
|
||||
bool IsRumbling() { return isRumbling; }
|
||||
std::string GetGuid() { return GUID; }
|
||||
virtual const std::string GetButtonName(int32_t virtualSlot, int32_t n64Button) = 0;
|
||||
virtual const std::string GetControllerName() = 0;
|
||||
bool IsRumbling();
|
||||
std::string GetGuid();
|
||||
|
||||
protected:
|
||||
std::shared_ptr<ControllerAttachment> Attachment;
|
||||
|
61
libultraship/libultraship/DummyController.cpp
Normal file
61
libultraship/libultraship/DummyController.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
#include "DummyController.h"
|
||||
|
||||
namespace Ship {
|
||||
DummyController::DummyController(const std::string& CUID, const std::string& KeyName, bool Connected) {
|
||||
GUID = CUID;
|
||||
isConnected = Connected;
|
||||
ButtonName = KeyName;
|
||||
}
|
||||
|
||||
void DummyController::ReadFromSource(int32_t virtualSlot) {
|
||||
|
||||
}
|
||||
|
||||
const std::string DummyController::GetControllerName() {
|
||||
return GUID;
|
||||
}
|
||||
|
||||
const std::string DummyController::GetButtonName(int32_t virtualSlot, int32_t n64Button) {
|
||||
return ButtonName;
|
||||
}
|
||||
|
||||
void DummyController::WriteToSource(int32_t virtualSlot, ControllerCallback* controller){
|
||||
|
||||
}
|
||||
|
||||
bool DummyController::Connected() const {
|
||||
return isConnected;
|
||||
}
|
||||
|
||||
bool DummyController::CanRumble() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DummyController::CanGyro() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void DummyController::CreateDefaultBinding(int32_t slot) {
|
||||
|
||||
}
|
||||
|
||||
std::string DummyController::GetControllerType() {
|
||||
return "Unk";
|
||||
}
|
||||
|
||||
std::string DummyController::GetConfSection() {
|
||||
return "Unk";
|
||||
}
|
||||
|
||||
std::string DummyController::GetBindingConfSection() {
|
||||
return "Unk";
|
||||
}
|
||||
|
||||
void DummyController::ClearRawPress() {
|
||||
|
||||
}
|
||||
|
||||
int32_t DummyController::ReadRawPress() {
|
||||
return -1;
|
||||
}
|
||||
}
|
@ -7,31 +7,25 @@
|
||||
namespace Ship {
|
||||
class DummyController final : public Controller {
|
||||
public:
|
||||
DummyController(const std::string& CUID, const std::string& KeyName, bool Connected) {
|
||||
GUID = CUID;
|
||||
isConnected = Connected;
|
||||
ButtonName = KeyName;
|
||||
}
|
||||
|
||||
DummyController(const std::string& CUID, const std::string& KeyName, bool Connected);
|
||||
std::map<std::vector<std::string>, int32_t> ReadButtonPress();
|
||||
void ReadFromSource(int32_t slot) override {}
|
||||
const std::string GetControllerName() override { return GUID; }
|
||||
const std::string GetButtonName(int slot, int n64Button) override { return ButtonName; }
|
||||
void WriteToSource(int32_t slot, ControllerCallback* controller) override { }
|
||||
bool Connected() const override { return isConnected; }
|
||||
bool CanRumble() const override { return false; }
|
||||
bool CanGyro() const override { return false; }
|
||||
|
||||
void ClearRawPress() override {}
|
||||
int32_t ReadRawPress() override { return -1; }
|
||||
bool HasPadConf() const { return true; }
|
||||
std::optional<std::string> GetPadConfSection() { return "Unk"; }
|
||||
void CreateDefaultBinding(int32_t slot) override {}
|
||||
void ReadFromSource(int32_t virtualSlot) override;
|
||||
const std::string GetControllerName() override;
|
||||
const std::string GetButtonName(int32_t virtualSlot, int32_t n64Button) override;
|
||||
void WriteToSource(int32_t slot, ControllerCallback* controller) override;
|
||||
bool Connected() const override;
|
||||
bool CanRumble() const override;
|
||||
bool CanGyro() const override;
|
||||
void ClearRawPress() override;
|
||||
int32_t ReadRawPress() override;
|
||||
bool HasPadConf() const;
|
||||
std::optional<std::string> GetPadConfSection();
|
||||
void CreateDefaultBinding(int32_t virtualSlot) override;
|
||||
protected:
|
||||
std::string ButtonName;
|
||||
bool isConnected = false;
|
||||
std::string GetControllerType() { return "Unk"; }
|
||||
std::string GetConfSection() { return "Unk"; }
|
||||
std::string GetBindingConfSection() { return "Unk"; }
|
||||
std::string GetControllerType();
|
||||
std::string GetConfSection();
|
||||
std::string GetBindingConfSection();
|
||||
};
|
||||
}
|
5
libultraship/libultraship/Hooks.cpp
Normal file
5
libultraship/libultraship/Hooks.cpp
Normal file
@ -0,0 +1,5 @@
|
||||
#include "Hooks.h"
|
||||
|
||||
namespace Ship {
|
||||
|
||||
}
|
@ -100,4 +100,28 @@ namespace Ship {
|
||||
const std::string KeyboardController::GetControllerName() {
|
||||
return "Keyboard";
|
||||
}
|
||||
|
||||
bool KeyboardController::Connected() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool KeyboardController::CanRumble() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool KeyboardController::CanGyro() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void KeyboardController::ClearRawPress() {
|
||||
lastKey = -1;
|
||||
}
|
||||
|
||||
void KeyboardController::SetLastScancode(int32_t key) {
|
||||
lastScancode = key;
|
||||
}
|
||||
|
||||
int32_t KeyboardController::GetLastScancode() {
|
||||
return lastScancode;
|
||||
}
|
||||
}
|
||||
|
@ -9,26 +9,18 @@ namespace Ship {
|
||||
|
||||
void ReadFromSource(int32_t virtualSlot) override;
|
||||
void WriteToSource(int32_t virtualSlot, ControllerCallback* controller) override;
|
||||
bool Connected() const override { return true; }
|
||||
bool CanRumble() const override { return false; }
|
||||
bool CanGyro() const override { return false; }
|
||||
const std::string GetControllerName() override;
|
||||
const std::string GetButtonName(int32_t virtualSlot, int32_t n64Button) override;
|
||||
bool PressButton(int32_t dwScancode);
|
||||
bool ReleaseButton(int32_t dwScancode);
|
||||
|
||||
void ClearRawPress() override {
|
||||
lastKey = -1;
|
||||
}
|
||||
|
||||
bool Connected() const override;
|
||||
bool CanRumble() const override;
|
||||
bool CanGyro() const override;
|
||||
void ClearRawPress() override;
|
||||
int32_t ReadRawPress() override;
|
||||
void ReleaseAllButtons();
|
||||
|
||||
void SetLastScancode(int32_t key) {
|
||||
lastScancode = key;
|
||||
}
|
||||
|
||||
int32_t GetLastScancode() { return lastScancode; }
|
||||
void SetLastScancode(int32_t key);
|
||||
int32_t GetLastScancode();
|
||||
void CreateDefaultBinding(int32_t virtualSlot) override;
|
||||
|
||||
protected:
|
||||
|
@ -333,4 +333,17 @@ namespace Ship {
|
||||
const std::string* ResourceMgr::HashToString(uint64_t Hash) const {
|
||||
return OTR->HashToString(Hash);
|
||||
}
|
||||
|
||||
std::shared_ptr<Archive> ResourceMgr::GetArchive() {
|
||||
return OTR;
|
||||
}
|
||||
|
||||
std::shared_ptr<Window> ResourceMgr::GetContext() {
|
||||
return Context;
|
||||
}
|
||||
|
||||
std::shared_ptr<Resource> ResourceMgr::LoadResource(const std::string& FilePath) {
|
||||
return LoadResource(FilePath.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,20 +23,17 @@ namespace Ship {
|
||||
bool IsRunning();
|
||||
bool DidLoadSuccessfully();
|
||||
|
||||
std::shared_ptr<Archive> GetArchive() { return OTR; }
|
||||
std::shared_ptr<Window> GetContext() { return Context; }
|
||||
|
||||
std::shared_ptr<Archive> GetArchive();
|
||||
std::shared_ptr<Window> GetContext();
|
||||
const std::string* HashToString(uint64_t Hash) const;
|
||||
|
||||
void InvalidateResourceCache();
|
||||
|
||||
uint32_t GetGameVersion();
|
||||
void SetGameVersion(uint32_t newGameVersion);
|
||||
std::shared_ptr<File> LoadFileAsync(const std::string& FilePath);
|
||||
std::shared_ptr<File> LoadFile(const std::string& FilePath);
|
||||
std::shared_ptr<Resource> GetCachedFile(const char* FilePath) const;
|
||||
std::shared_ptr<Resource> LoadResource(const char* FilePath);
|
||||
std::shared_ptr<Resource> LoadResource(const std::string& FilePath) { return LoadResource(FilePath.c_str()); }
|
||||
std::shared_ptr<Resource> LoadResource(const std::string& FilePath);
|
||||
std::variant<std::shared_ptr<Resource>, std::shared_ptr<ResourcePromise>> LoadResourceAsync(const char* FilePath);
|
||||
std::shared_ptr<std::vector<std::shared_ptr<Resource>>> CacheDirectory(const std::string& SearchMask);
|
||||
std::shared_ptr<std::vector<std::shared_ptr<ResourcePromise>>> CacheDirectoryAsync(const std::string& SearchMask);
|
||||
|
@ -12,6 +12,10 @@ extern "C" uint8_t __osMaxControllers;
|
||||
|
||||
namespace Ship {
|
||||
|
||||
SDLController::SDLController(int32_t physicalSlot) : Controller(), Cont(nullptr), physicalSlot(physicalSlot) {
|
||||
|
||||
}
|
||||
|
||||
bool SDLController::Open() {
|
||||
const auto NewCont = SDL_GameControllerOpen(physicalSlot);
|
||||
|
||||
@ -450,4 +454,23 @@ namespace Ship {
|
||||
profile->GyroData[DRIFT_Y] = 0.0f;
|
||||
profile->GyroData[GYRO_SENSITIVITY] = 1.0f;
|
||||
}
|
||||
|
||||
bool SDLController::Connected() const {
|
||||
return Cont != nullptr;
|
||||
}
|
||||
|
||||
bool SDLController::CanGyro() const {
|
||||
return supportsGyro;
|
||||
}
|
||||
|
||||
bool SDLController::CanRumble() const {
|
||||
#if SDL_COMPILEDVERSION >= SDL_VERSIONNUM(2,0,18)
|
||||
return SDL_GameControllerHasRumble(Cont);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
void SDLController::ClearRawPress() {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,19 @@
|
||||
namespace Ship {
|
||||
class SDLController : public Controller {
|
||||
public:
|
||||
SDLController(int32_t physicalSlot);
|
||||
void ReadFromSource(int32_t virtualSlot) override;
|
||||
const std::string GetControllerName() override;
|
||||
const std::string GetButtonName(int32_t virtualSlot, int32_t n64Button) override;
|
||||
void WriteToSource(int32_t virtualSlot, ControllerCallback* controller) override;
|
||||
bool Connected() const override;
|
||||
bool CanGyro() const override;
|
||||
bool CanRumble() const override;
|
||||
bool Open();
|
||||
void ClearRawPress() override;
|
||||
int32_t ReadRawPress() override;
|
||||
|
||||
protected:
|
||||
inline static const char* AxisNames[] = {
|
||||
"Left Stick X",
|
||||
"Left Stick Y",
|
||||
@ -15,25 +28,6 @@ namespace Ship {
|
||||
"Start Button"
|
||||
};
|
||||
|
||||
SDLController(int32_t physicalSlot) : Controller(), Cont(nullptr), physicalSlot(physicalSlot) { }
|
||||
void ReadFromSource(int32_t virtualSlot) override;
|
||||
const std::string GetControllerName() override;
|
||||
const std::string GetButtonName(int32_t virtualSlot, int32_t n64Button) override;
|
||||
void WriteToSource(int32_t virtualSlot, ControllerCallback* controller) override;
|
||||
bool Connected() const override { return Cont != nullptr; }
|
||||
bool CanGyro() const override { return supportsGyro; }
|
||||
bool CanRumble() const override {
|
||||
#if SDL_COMPILEDVERSION >= SDL_VERSIONNUM(2,0,18)
|
||||
return SDL_GameControllerHasRumble(Cont);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Open();
|
||||
void ClearRawPress() override {}
|
||||
int32_t ReadRawPress() override;
|
||||
|
||||
protected:
|
||||
void CreateDefaultBinding(int32_t virtualSlot) override;
|
||||
|
||||
private:
|
||||
|
@ -581,4 +581,52 @@ namespace Ship {
|
||||
|
||||
saveFile.close();
|
||||
}
|
||||
|
||||
bool Window::IsFullscreen() {
|
||||
return bIsFullscreen;
|
||||
}
|
||||
|
||||
uint32_t Window::GetMenuBar() {
|
||||
return dwMenubar;
|
||||
}
|
||||
|
||||
void Window::SetMenuBar(uint32_t dwMenuBar) {
|
||||
this->dwMenubar = dwMenuBar;
|
||||
}
|
||||
|
||||
std::string Window::GetName() {
|
||||
return Name;
|
||||
}
|
||||
|
||||
std::shared_ptr<ControlDeck> Window::GetControlDeck() {
|
||||
return ControllerApi;
|
||||
}
|
||||
|
||||
std::shared_ptr<AudioPlayer> Window::GetAudioPlayer() {
|
||||
return APlayer;
|
||||
}
|
||||
|
||||
std::shared_ptr<ResourceMgr> Window::GetResourceManager() {
|
||||
return ResMan;
|
||||
}
|
||||
|
||||
std::shared_ptr<Mercury> Window::GetConfig() {
|
||||
return Config;
|
||||
}
|
||||
|
||||
std::shared_ptr<spdlog::logger> Window::GetLogger() {
|
||||
return Logger;
|
||||
}
|
||||
|
||||
const char* Window::GetKeyName(int32_t scancode) {
|
||||
return WmApi->get_key_name(scancode);
|
||||
}
|
||||
|
||||
int32_t Window::GetLastScancode() {
|
||||
return lastScancode;
|
||||
}
|
||||
|
||||
void Window::SetLastScancode(int32_t scanCode) {
|
||||
lastScancode = scanCode;
|
||||
}
|
||||
}
|
||||
|
@ -36,20 +36,20 @@ namespace Ship {
|
||||
void ToggleFullscreen();
|
||||
void SetFullscreen(bool bIsFullscreen);
|
||||
void ShowCursor(bool hide);
|
||||
bool IsFullscreen() { return bIsFullscreen; }
|
||||
uint32_t GetCurrentWidth();
|
||||
uint32_t GetCurrentHeight();
|
||||
uint32_t GetMenuBar() { return dwMenubar; }
|
||||
void SetMenuBar(uint32_t dwMenuBar) { this->dwMenubar = dwMenuBar; }
|
||||
std::string GetName() { return Name; }
|
||||
std::shared_ptr<ControlDeck> GetControlDeck() { return ControllerApi; };
|
||||
std::shared_ptr<AudioPlayer> GetAudioPlayer() { return APlayer; }
|
||||
std::shared_ptr<ResourceMgr> GetResourceManager() { return ResMan; }
|
||||
std::shared_ptr<Mercury> GetConfig() { return Config; }
|
||||
std::shared_ptr<spdlog::logger> GetLogger() { return Logger; }
|
||||
const char* GetKeyName(int32_t scancode) { return WmApi->get_key_name(scancode); }
|
||||
int32_t GetLastScancode() { return lastScancode; }
|
||||
void SetLastScancode(int32_t scanCode) { lastScancode = scanCode; }
|
||||
bool IsFullscreen();
|
||||
uint32_t GetMenuBar();
|
||||
void SetMenuBar(uint32_t dwMenuBar);
|
||||
std::string GetName();
|
||||
std::shared_ptr<ControlDeck> GetControlDeck();
|
||||
std::shared_ptr<AudioPlayer> GetAudioPlayer();
|
||||
std::shared_ptr<ResourceMgr> GetResourceManager();
|
||||
std::shared_ptr<Mercury> GetConfig();
|
||||
std::shared_ptr<spdlog::logger> GetLogger();
|
||||
const char* GetKeyName(int32_t scancode);
|
||||
int32_t GetLastScancode();
|
||||
void SetLastScancode(int32_t scanCode);
|
||||
|
||||
protected:
|
||||
Window() = default;
|
||||
|
@ -255,10 +255,10 @@ void GivePlayerRandoRewardSariaGift(GlobalContext* globalCtx, RandomizerCheck ch
|
||||
if (gSaveContext.entranceIndex == 0x05E0) {
|
||||
GetItemEntry getItemEntry = Randomizer_GetItemFromKnownCheck(check, RG_ZELDAS_LULLABY);
|
||||
|
||||
if ((!Flags_GetEventChkInf(0xC1) || (player->getItemId == getItemEntry.getItemId && getItemEntry.getItemId != GI_ICE_TRAP)) &&
|
||||
player != NULL && !Player_InBlockingCsMode(globalCtx, player)) {
|
||||
if (!Flags_GetEventChkInf(0xC1) && player != NULL && !Player_InBlockingCsMode(globalCtx, player)) {
|
||||
GiveItemEntryWithoutActor(globalCtx, getItemEntry);
|
||||
Flags_SetEventChkInf(0xC1);
|
||||
player->pendingFlag.flagType = FLAG_EVENT_CHECK_INF;
|
||||
player->pendingFlag.flagID = 0xC1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -791,7 +791,7 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx) {
|
||||
s32 giid = getItem.getItemId;
|
||||
|
||||
if (getItem.modIndex == MOD_NONE) {
|
||||
if(getItem.itemId >= ITEM_KOKIRI_EMERALD && getItem.itemId <= ITEM_MEDALLION_LIGHT) {
|
||||
if (getItem.itemId >= ITEM_MEDALLION_FOREST && getItem.itemId <= ITEM_ZORA_SAPPHIRE) {
|
||||
GiveLinkDungeonReward(getItem.getItemId);
|
||||
} else if (giid == GI_RUPEE_GREEN || giid == GI_RUPEE_BLUE || giid == GI_RUPEE_RED ||
|
||||
giid == GI_RUPEE_PURPLE || giid == GI_RUPEE_GOLD) {
|
||||
|
Loading…
Reference in New Issue
Block a user