Merge pull request #429 from FlagBrew/fix_compilation

Fix compilation
This commit is contained in:
Allen 2021-11-11 18:19:40 -04:00 committed by GitHub
commit dd98ddea4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
55 changed files with 354 additions and 355 deletions

View file

@ -204,7 +204,7 @@ endif
@cd $(SHARKIVE)/$(BUILD) && mv 3ds.json.bz2 ../../3ds/$(ROMFS)/$(CHEATS)/$(CHEATS).json.bz2
#---------------------------------------------------------------------------------
format:
clang-format -i -style=file $(foreach dir,$(FORMATSOURCES),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cpp)) $(foreach dir,$(FORMATINCLUDES),$(wildcard $(dir)/*.h) $(wildcard $(dir)/*.hpp))
clang-format -i -style=file $(foreach dir,$(FORMATSOURCES),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cpp) $(wildcard $(dir)/*.tcc)) $(foreach dir,$(FORMATINCLUDES),$(wildcard $(dir)/*.h) $(wildcard $(dir)/*.hpp))
#---------------------------------------------------------------------------------
else

View file

@ -45,7 +45,7 @@ public:
~CheatManagerOverlay(void);
void drawTop(void) const override;
void drawBottom(void) const override;
void update(touchPosition* touch) override;
void update(const InputState& input) override;
protected:
void save(const std::string& key, Scrollable* s);

View file

@ -43,7 +43,7 @@ public:
~ErrorOverlay(void);
void drawTop(void) const override;
void drawBottom(void) const override;
void update(touchPosition* touch) override;
void update(const InputState& input) override;
private:
u32 posx, posy;

View file

@ -43,7 +43,7 @@ public:
~InfoOverlay(void);
void drawTop(void) const override;
void drawBottom(void) const override;
void update(touchPosition* touch) override;
void update(const InputState& input) override;
private:
u32 posx, posy;

View file

@ -0,0 +1,34 @@
/*
* This file is part of Checkpoint
* Copyright (C) 2017-2019 Bernardo Giordano, FlagBrew
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef INPUTSTATE_HPP
#define INPUTSTATE_HPP
#include <3ds.h>
using InputState = touchPosition;
#endif

View file

@ -46,13 +46,13 @@ public:
~MainScreen(void);
void drawTop(void) const override;
void drawBottom(void) const override;
void update(touchPosition* touch) override;
void update(const InputState& input) override;
protected:
int selectorX(size_t i) const;
int selectorY(size_t i) const;
void drawSelector(void) const;
void handleEvents(touchPosition* touch);
void handleEvents(const InputState& input);
void updateSelector(void);
void updateButtons(void);
std::string nameFromCell(size_t index) const;

View file

@ -44,7 +44,7 @@ public:
~YesNoOverlay(void);
void drawTop(void) const override;
void drawBottom(void) const override;
void update(touchPosition* touch) override;
void update(const InputState& input) override;
private:
u32 posx, posy;

View file

@ -52,7 +52,7 @@ public:
private:
CheatManager(void);
~CheatManager(void){};
~CheatManager() = default;
CheatManager(CheatManager const&) = delete;
void operator=(CheatManager const&) = delete;

View file

@ -53,7 +53,7 @@ public:
private:
Configuration(void);
~Configuration(void){};
~Configuration() = default;
void store(void);
nlohmann::json loadJson(const std::string& path);

View file

@ -35,7 +35,7 @@
class Directory {
public:
Directory(FS_Archive archive, const std::u16string& root);
~Directory(void){};
~Directory() = default;
Result error(void);
std::u16string entry(size_t index);

View file

@ -34,7 +34,7 @@ class FSStream {
public:
FSStream(FS_Archive archive, const std::u16string& path, u32 flags);
FSStream(FS_Archive archive, const std::u16string& path, u32 flags, u32 size);
~FSStream(void){};
~FSStream() = default;
Result close(void);
bool eof(void);

View file

@ -33,8 +33,7 @@
#define DELAY_TICKS 50000000
template <HidDirection ListDirection, HidDirection PageDirection>
class Hid : public IHid<ListDirection, PageDirection, DELAY_TICKS>
{
class Hid : public IHid<ListDirection, PageDirection, DELAY_TICKS> {
public:
Hid(size_t entries, size_t columns) : IHid<ListDirection, PageDirection, DELAY_TICKS>(entries, columns) {}

View file

@ -39,7 +39,7 @@ class Scrollable : public IScrollable<u32> {
public:
Scrollable(int x, int y, u32 w, u32 h, size_t visibleEntries) : IScrollable(x, y, w, h, visibleEntries), mHid(visibleEntries, 1) {}
virtual ~Scrollable(void) {}
virtual ~Scrollable() = default;
void c2dText(size_t i, const std::string& v);
void draw(bool condition = false) override;

View file

@ -90,8 +90,9 @@ void CheatManagerOverlay::drawBottom(void) const
C2D_DrawRectSolid(0, 0, 0.5f, 320, 240, COLOR_OVERLAY);
}
void CheatManagerOverlay::update(touchPosition* touch)
void CheatManagerOverlay::update(const InputState& input)
{
(void)input;
if (hidKeysDown() & KEY_A) {
std::string cellName = scrollable->cellName(scrollable->index());
if (cellName.compare(0, MAGIC_LEN, SELECTED_MAGIC) == 0) {

View file

@ -61,8 +61,9 @@ void ErrorOverlay::drawBottom(void) const
Gui::drawPulsingOutline(42, 162, 236, 36, 2, COLOR_RED);
}
void ErrorOverlay::update(touchPosition* touch)
void ErrorOverlay::update(const InputState& input)
{
(void)input;
if (button->released() || (hidKeysDown() & KEY_A) || (hidKeysDown() & KEY_B)) {
screen.removeOverlay();
}

View file

@ -57,8 +57,9 @@ void InfoOverlay::drawBottom(void) const
Gui::drawPulsingOutline(42, 162, 236, 36, 2, COLOR_BLUE);
}
void InfoOverlay::update(touchPosition* touch)
void InfoOverlay::update(const InputState& input)
{
(void)input;
if (button->released() || (hidKeysDown() & KEY_A) || (hidKeysDown() & KEY_B)) {
screen.removeOverlay();
}

View file

@ -264,10 +264,10 @@ void MainScreen::drawBottom(void) const
}
}
void MainScreen::update(touchPosition* touch)
void MainScreen::update(const InputState& input)
{
updateSelector();
handleEvents(touch);
handleEvents(input);
}
void MainScreen::updateSelector(void)
@ -284,7 +284,7 @@ void MainScreen::updateSelector(void)
}
}
void MainScreen::handleEvents(touchPosition* touch)
void MainScreen::handleEvents(const InputState& input)
{
u32 kDown = hidKeysDown();
u32 kHeld = hidKeysHeld();
@ -466,7 +466,7 @@ void MainScreen::handleEvents(touchPosition* touch)
if (getTitleCount() > 0) {
Title title;
getTitle(title, hid.fullIndex());
if ((title.isActivityLog() && buttonPlayCoins->released()) || ((hidKeysDown() & KEY_TOUCH) && touch->py < 20 && touch->px > 294)) {
if ((title.isActivityLog() && buttonPlayCoins->released()) || ((hidKeysDown() & KEY_TOUCH) && input.py < 20 && input.px > 294)) {
if (!Archive::setPlayCoins()) {
currentOverlay = std::make_shared<ErrorOverlay>(*this, -1, "Failed to set play coins.");
}

View file

@ -72,8 +72,9 @@ void YesNoOverlay::drawBottom(void) const
}
}
void YesNoOverlay::update(touchPosition* touch)
void YesNoOverlay::update(const InputState& input)
{
(void)input;
hid.update(2);
hid.index(buttonYes->held() ? 0 : buttonNo->held() ? 1 : hid.index());

View file

@ -61,7 +61,7 @@ int main()
C2D_SceneBegin(g_bottom);
g_screen->doDrawBottom();
Gui::frameEnd();
g_screen->doUpdate(&touch);
g_screen->doUpdate(InputState{touch});
}
Logger::getInstance().flush();

View file

@ -8379,7 +8379,7 @@ scan_number_done:
std::string result;
for (const auto c : token_string)
{
if ('\x00' <= c and c <= '\x1F')
if (c <= '\x1F')
{
// escape control characters
std::array<char, 9> cs{{}};

View file

@ -29,18 +29,12 @@
#include "Screen.hpp"
#include <memory>
#include <string>
#if defined(_3DS)
#include <3ds.h>
#elif defined(__SWITCH__)
#include <switch.h>
#endif
class Overlay {
public:
Overlay(Screen& screen) : screen(screen), me(screen.currentOverlay) {}
virtual ~Overlay() {}
virtual void update(touchPosition* touch) = 0;
virtual ~Overlay() = default;
virtual void update(const InputState&) = 0;
#if defined(_3DS)
virtual void drawTop() const = 0;
virtual void drawBottom() const = 0;

View file

@ -44,7 +44,6 @@ void Screen::doDrawBottom() const
currentOverlay->drawBottom();
}
}
#elif defined(__SWITCH__)
void Screen::doDraw() const
@ -57,12 +56,12 @@ void Screen::doDraw() const
#endif
void Screen::doUpdate(touchPosition* touch)
void Screen::doUpdate(const InputState& input)
{
if (currentOverlay) {
currentOverlay->update(touch);
currentOverlay->update(input);
}
else {
update(touch);
update(input);
}
}
}

View file

@ -27,11 +27,7 @@
#ifndef SCREEN_HPP
#define SCREEN_HPP
#if defined(_3DS)
#include <3ds.h>
#elif defined(__SWITCH__)
#include <switch.h>
#endif
#include "InputState.hpp"
#include <memory>
class Overlay;
@ -40,28 +36,27 @@ class Screen {
friend class Overlay;
public:
Screen(void) {}
virtual ~Screen(void) {}
// Call currentOverlay->update if it exists, and update if it doesn't
virtual void doUpdate(touchPosition* touch) final;
virtual void update(touchPosition* touch) = 0;
virtual ~Screen() = default;
// Call draw, then currentOverlay->draw if it exists
#if defined(_3DS)
virtual void doDrawTop(void) const final;
virtual void doDrawBottom(void) const final;
void doDrawTop(void) const;
void doDrawBottom(void) const;
virtual void drawTop(void) const = 0;
virtual void drawBottom(void) const = 0;
#elif defined(__SWITCH__)
virtual void doDraw() const final;
void doDraw() const;
virtual void draw() const = 0;
#endif
void removeOverlay() { currentOverlay = nullptr; }
// Call currentOverlay->update if it exists, and update if it doesn't
void doUpdate(const InputState&);
virtual void update(const InputState&) = 0;
void removeOverlay() { currentOverlay.reset(); }
void setOverlay(std::shared_ptr<Overlay>& overlay) { currentOverlay = overlay; }
protected:
// No point in restricting this to only being editable during update, especially since it's drawn afterwards. Allows setting it before the first
// draw loop is done
mutable std::shared_ptr<Overlay> currentOverlay = nullptr;
mutable std::shared_ptr<Overlay> currentOverlay;
};
#endif

View file

@ -28,6 +28,7 @@
#define ICLICKABLE_HPP
#include <string>
#include "InputState.hpp"
typedef uint8_t u8;
typedef uint16_t u16;
@ -44,8 +45,7 @@ public:
mCanChangeColorWhenSelected = false;
}
virtual ~IClickable(void) {}
virtual ~IClickable() = default;
virtual void draw(float size, T overlay) = 0;
virtual void drawOutline(T color) = 0;
virtual bool held(void) = 0;

View file

@ -33,11 +33,7 @@
typedef uint64_t u64;
enum class HidDirection
{
VERTICAL,
HORIZONTAL
};
enum class HidDirection { VERTICAL, HORIZONTAL };
template <HidDirection ListDirection, HidDirection PageDirection, u64 Delay>
class IHid {
@ -67,23 +63,19 @@ public:
}
void pageBack()
{
if (mPage > 0)
{
if (mPage > 0) {
mPage--;
}
else if (mPage == 0)
{
else if (mPage == 0) {
mPage = mMaxPages - 1;
}
}
void pageForward()
{
if (mPage < (int)mMaxPages - 1)
{
if (mPage < (int)mMaxPages - 1) {
mPage++;
}
else if (mPage == (int)mMaxPages - 1)
{
else if (mPage == (int)mMaxPages - 1) {
mPage = 0;
}
}
@ -94,19 +86,15 @@ public:
}
void correctIndex(size_t count)
{
if (mIndex > maxEntries(count))
{
if constexpr (ListDirection == HidDirection::HORIZONTAL)
{
if (mIndex > maxEntries(count)) {
if constexpr (ListDirection == HidDirection::HORIZONTAL) {
mIndex = mIndex % mColumns;
}
else
{
else {
mIndex = mIndex % mRows;
}
// If the above doesn't fix, then forcibly fix
if (mIndex > maxEntries(count))
{
if (mIndex > maxEntries(count)) {
mIndex = maxEntries(count);
}
}

View file

@ -35,333 +35,247 @@ void IHid<ListDirection, PageDirection, Delay>::update(size_t count)
mMaxPages = (count % mMaxVisibleEntries == 0) ? count / mMaxVisibleEntries : count / mMaxVisibleEntries + 1;
if (leftTriggerDown())
{
if (leftTriggerDown()) {
pageBack();
}
else if (rightTriggerDown())
{
else if (rightTriggerDown()) {
pageForward();
}
else if (leftTriggerHeld())
{
if (currentTime <= mLastTime + Delay)
{
else if (leftTriggerHeld()) {
if (currentTime <= mLastTime + Delay) {
return;
}
pageBack();
}
else if (rightTriggerHeld())
{
if (currentTime <= mLastTime + Delay)
{
else if (rightTriggerHeld()) {
if (currentTime <= mLastTime + Delay) {
return;
}
pageForward();
}
if constexpr (ListDirection == HidDirection::HORIZONTAL)
{
if (upDown())
{
if (mIndex < mColumns)
{
if constexpr (PageDirection == HidDirection::VERTICAL)
{
if constexpr (ListDirection == HidDirection::HORIZONTAL) {
if (upDown()) {
if (mIndex < mColumns) {
if constexpr (PageDirection == HidDirection::VERTICAL) {
pageBack();
}
mIndex += mColumns * (mRows - 1);
}
else
{
else {
mIndex -= mColumns;
}
}
else if (downDown())
{
else if (downDown()) {
mIndex += mColumns;
if (mIndex > maxEntries(count))
{
if (mIndex > maxEntries(count)) {
mIndex %= mColumns;
if constexpr (PageDirection == HidDirection::VERTICAL)
{
if constexpr (PageDirection == HidDirection::VERTICAL) {
pageForward();
}
}
}
else if (upHeld())
{
if (currentTime <= mLastTime + Delay)
{
else if (upHeld()) {
if (currentTime <= mLastTime + Delay) {
return;
}
if (mIndex < mColumns)
{
if constexpr (PageDirection == HidDirection::VERTICAL)
{
if (mIndex < mColumns) {
if constexpr (PageDirection == HidDirection::VERTICAL) {
pageBack();
}
mIndex += mColumns * (mRows - 1);
}
else
{
else {
mIndex -= mColumns;
}
}
else if (downHeld())
{
if (currentTime <= mLastTime + Delay)
{
else if (downHeld()) {
if (currentTime <= mLastTime + Delay) {
return;
}
mIndex += mColumns;
if (mIndex > maxEntries(count))
{
if (mIndex > maxEntries(count)) {
mIndex %= mColumns;
if constexpr (PageDirection == HidDirection::VERTICAL)
{
if constexpr (PageDirection == HidDirection::VERTICAL) {
pageForward();
}
}
}
if (leftDown())
{
if (mIndex % mColumns != 0)
{
if (leftDown()) {
if (mIndex % mColumns != 0) {
mIndex--;
}
else
{
else {
mIndex += mColumns - 1;
if constexpr (PageDirection == HidDirection::HORIZONTAL)
{
if constexpr (PageDirection == HidDirection::HORIZONTAL) {
pageBack();
}
}
}
else if (rightDown())
{
if (mIndex % mColumns != mColumns - 1)
{
else if (rightDown()) {
if (mIndex % mColumns != mColumns - 1) {
mIndex++;
if (mIndex > maxEntries(count))
{
if constexpr (PageDirection == HidDirection::HORIZONTAL)
{
if (mIndex > maxEntries(count)) {
if constexpr (PageDirection == HidDirection::HORIZONTAL) {
pageForward();
}
mIndex = mIndex - (mIndex % mColumns);
}
}
else
{
if constexpr (PageDirection == HidDirection::HORIZONTAL)
{
else {
if constexpr (PageDirection == HidDirection::HORIZONTAL) {
pageForward();
}
mIndex -= mColumns - 1;
}
}
else if (leftHeld())
{
if (currentTime <= mLastTime + Delay)
{
else if (leftHeld()) {
if (currentTime <= mLastTime + Delay) {
return;
}
if (mIndex % mColumns != 0)
{
if (mIndex % mColumns != 0) {
mIndex--;
}
else
{
if constexpr (PageDirection == HidDirection::HORIZONTAL)
{
else {
if constexpr (PageDirection == HidDirection::HORIZONTAL) {
pageBack();
}
mIndex += mColumns - 1;
}
}
else if (rightHeld())
{
if (currentTime <= mLastTime + Delay)
{
else if (rightHeld()) {
if (currentTime <= mLastTime + Delay) {
return;
}
if (mIndex % mColumns != mColumns - 1)
{
if (mIndex % mColumns != mColumns - 1) {
mIndex++;
if (mIndex > maxEntries(count))
{
if constexpr (PageDirection == HidDirection::HORIZONTAL)
{
if (mIndex > maxEntries(count)) {
if constexpr (PageDirection == HidDirection::HORIZONTAL) {
pageForward();
}
mIndex = mIndex - (mIndex % mColumns);
}
}
else
{
if constexpr (PageDirection == HidDirection::HORIZONTAL)
{
else {
if constexpr (PageDirection == HidDirection::HORIZONTAL) {
pageForward();
}
mIndex -= mColumns - 1;
}
}
}
else
{
if (leftDown())
{
if (mIndex / mRows != 0)
{
else {
if (leftDown()) {
if (mIndex / mRows != 0) {
mIndex -= mRows;
}
else
{
if constexpr (PageDirection == HidDirection::HORIZONTAL)
{
else {
if constexpr (PageDirection == HidDirection::HORIZONTAL) {
pageBack();
}
mIndex += mRows * (mColumns - 1);
}
}
else if (rightDown())
{
else if (rightDown()) {
mIndex += mRows;
if (mIndex > maxEntries(count))
{
if constexpr (PageDirection == HidDirection::HORIZONTAL)
{
if (mIndex > maxEntries(count)) {
if constexpr (PageDirection == HidDirection::HORIZONTAL) {
pageForward();
}
mIndex %= mRows;
}
}
else if (leftHeld())
{
if (currentTime <= mLastTime + Delay)
{
else if (leftHeld()) {
if (currentTime <= mLastTime + Delay) {
return;
}
if (mIndex / mRows != 0)
{
if (mIndex / mRows != 0) {
mIndex -= mRows;
}
else
{
if constexpr (PageDirection == HidDirection::HORIZONTAL)
{
else {
if constexpr (PageDirection == HidDirection::HORIZONTAL) {
pageBack();
}
mIndex += mRows * (mColumns - 1);
}
}
else if (rightHeld())
{
if (currentTime <= mLastTime + Delay)
{
else if (rightHeld()) {
if (currentTime <= mLastTime + Delay) {
return;
}
mIndex += mRows;
if (mIndex > maxEntries(count))
{
if constexpr (PageDirection == HidDirection::HORIZONTAL)
{
if (mIndex > maxEntries(count)) {
if constexpr (PageDirection == HidDirection::HORIZONTAL) {
pageForward();
}
mIndex %= mRows;
}
}
if (upDown())
{
if (mIndex % mRows > 0)
{
if (upDown()) {
if (mIndex % mRows > 0) {
mIndex -= 1;
}
else
{
if constexpr (PageDirection == HidDirection::VERTICAL)
{
else {
if constexpr (PageDirection == HidDirection::VERTICAL) {
pageBack();
}
mIndex = mIndex + mRows - 1;
}
}
else if (downDown())
{
if ((mIndex % mRows) < mRows - 1)
{
if (mIndex + mPage * mMaxVisibleEntries == count - 1)
{
if constexpr (PageDirection == HidDirection::VERTICAL)
{
else if (downDown()) {
if ((mIndex % mRows) < mRows - 1) {
if (mIndex + mPage * mMaxVisibleEntries == count - 1) {
if constexpr (PageDirection == HidDirection::VERTICAL) {
pageForward();
}
mIndex = mIndex - (mIndex % mRows);
}
else
{
else {
mIndex += 1;
}
}
else
{
if constexpr (PageDirection == HidDirection::VERTICAL)
{
else {
if constexpr (PageDirection == HidDirection::VERTICAL) {
pageForward();
}
mIndex = mIndex + 1 - mRows;
}
}
else if (upHeld())
{
if (currentTime <= mLastTime + Delay)
{
else if (upHeld()) {
if (currentTime <= mLastTime + Delay) {
return;
}
if (mIndex % mRows > 0)
{
if (mIndex % mRows > 0) {
mIndex -= 1;
}
else
{
if constexpr (PageDirection == HidDirection::VERTICAL)
{
else {
if constexpr (PageDirection == HidDirection::VERTICAL) {
pageBack();
}
mIndex = mIndex + mRows - 1;
}
}
else if (downHeld())
{
if (currentTime <= mLastTime + Delay)
{
else if (downHeld()) {
if (currentTime <= mLastTime + Delay) {
return;
}
if ((mIndex % mRows) < mRows - 1)
{
if (mIndex + mPage * mMaxVisibleEntries == count - 1)
{
if constexpr (PageDirection == HidDirection::VERTICAL)
{
if ((mIndex % mRows) < mRows - 1) {
if (mIndex + mPage * mMaxVisibleEntries == count - 1) {
if constexpr (PageDirection == HidDirection::VERTICAL) {
pageForward();
}
mIndex = mIndex - (mIndex % mRows);
}
else
{
else {
mIndex += 1;
}
}
else
{
if constexpr (PageDirection == HidDirection::VERTICAL)
{
else {
if constexpr (PageDirection == HidDirection::VERTICAL) {
pageForward();
}
mIndex = mIndex + 1 - mRows;

View file

@ -28,6 +28,7 @@
#define ISCROLLABLE_HPP
#include "iclickable.hpp"
#include "InputState.hpp"
#include <vector>
template <typename T>
@ -39,7 +40,7 @@ public:
mPage = 0;
}
virtual ~IScrollable(void) { flush(); }
virtual ~IScrollable() { flush(); }
virtual void draw(bool condition = false) = 0;
virtual void push_back(T color, T colorMessage, const std::string& message, bool selected) = 0;

View file

@ -25,6 +25,7 @@
*/
#include <vector>
#include <cstddef>
namespace MS {
std::vector<size_t> selectedEntries(void);

@ -1 +1 @@
Subproject commit 9877a65d8c62be7a6b8bc7674bd1216be05d5f02
Subproject commit 6ae2763c22609d4ff00ab6d67c2ec9f0f48f0383

View file

@ -190,7 +190,7 @@ endif
@cd $(SHARKIVE)/$(BUILD) && mv switch.json.bz2 ../../switch/$(ROMFS)/$(CHEATS)/$(CHEATS).json.bz2
#---------------------------------------------------------------------------------
format:
clang-format -i -style=file $(foreach dir,$(FORMATSOURCES),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cpp)) $(foreach dir,$(FORMATINCLUDES),$(wildcard $(dir)/*.h) $(wildcard $(dir)/*.hpp))
clang-format -i -style=file $(foreach dir,$(FORMATSOURCES),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cpp) $(wildcard $(dir)/*.tcc)) $(foreach dir,$(FORMATINCLUDES),$(wildcard $(dir)/*.h) $(wildcard $(dir)/*.hpp))
#---------------------------------------------------------------------------------
else

View file

@ -44,9 +44,9 @@ class Scrollable;
class CheatManagerOverlay : public Overlay {
public:
CheatManagerOverlay(Screen& screen, const std::string& mtext);
~CheatManagerOverlay(void) {}
~CheatManagerOverlay() = default;
void draw(void) const override;
void update(touchPosition* touch) override;
void update(const InputState&) override;
protected:
void save(const std::string& key, Scrollable* s);

View file

@ -39,9 +39,9 @@ class Clickable;
class ErrorOverlay : public Overlay {
public:
ErrorOverlay(Screen& screen, Result res, const std::string& mtext);
~ErrorOverlay(void) {}
~ErrorOverlay() = default;
void draw(void) const override;
void update(touchPosition* touch) override;
void update(const InputState&) override;
private:
u32 textw, texth;

View file

@ -39,9 +39,9 @@ class Clickable;
class InfoOverlay : public Overlay {
public:
InfoOverlay(Screen& screen, const std::string& mtext);
~InfoOverlay(void) {}
~InfoOverlay() = default;
void draw(void) const override;
void update(touchPosition* touch) override;
void update(const InputState&) override;
private:
u32 textw, texth;

View file

@ -0,0 +1,39 @@
/*
* This file is part of Checkpoint
* Copyright (C) 2017-2019 Bernardo Giordano, FlagBrew
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#ifndef INPUTSTATE_HPP
#define INPUTSTATE_HPP
#include <switch.h>
struct InputState {
HidTouchScreenState touch;
u64 kDown;
u64 kHeld;
u64 kUp;
};
#endif

View file

@ -44,13 +44,13 @@ public:
std::pair<bool, std::string> keyboard(const std::string& suggestion);
std::pair<bool, Result> isSystemKeyboardAvailable(void) { return std::make_pair(systemKeyboardAvailable, res); }
std::pair<bool, Result> isSystemKeyboardAvailable() { return std::make_pair(systemKeyboardAvailable, res); }
static const size_t CUSTOM_PATH_LEN = 49;
private:
KeyboardManager(void);
virtual ~KeyboardManager(void){};
virtual ~KeyboardManager() = default;
Result res;
bool systemKeyboardAvailable;

View file

@ -48,15 +48,15 @@ class Scrollable;
class MainScreen : public Screen {
public:
MainScreen(void);
MainScreen(const InputState&);
void draw(void) const override;
void update(touchPosition* touch) override;
void update(const InputState& input) override;
protected:
int selectorX(size_t i) const;
int selectorY(size_t i) const;
void updateSelector(touchPosition* touch);
void handleEvents(touchPosition* touch);
void updateSelector(const InputState& input);
void handleEvents(const InputState& input);
std::string nameFromCell(size_t index) const;
void entryType(entryType_t type);
size_t index(entryType_t type) const;
@ -71,6 +71,7 @@ private:
entryType_t type;
int selectionTimer;
bool pksmBridge;
bool wantInstructions;
Hid<HidDirection::HORIZONTAL, HidDirection::HORIZONTAL> hid;
std::unique_ptr<Scrollable> backupList;
std::unique_ptr<Clickable> buttonCheats, buttonBackup, buttonRestore;

View file

@ -41,9 +41,9 @@ class Clickable;
class YesNoOverlay : public Overlay {
public:
YesNoOverlay(Screen& screen, const std::string& mtext, const std::function<void()>& callbackYes, const std::function<void()>& callbackNo);
~YesNoOverlay(void) {}
~YesNoOverlay() = default;
void draw(void) const override;
void update(touchPosition* touch) override;
void update(const InputState&) override;
private:
u32 textw, texth;

View file

@ -50,11 +50,11 @@ public:
bool areCheatsAvailable(const std::string& key);
void save(const std::string& key, const std::vector<std::string>& s);
std::shared_ptr<nlohmann::json> cheats(void) { return mCheats; }
std::shared_ptr<nlohmann::json> cheats() { return mCheats; }
private:
CheatManager(void);
~CheatManager(void){};
CheatManager();
~CheatManager() = default;
CheatManager(CheatManager const&) = delete;
void operator=(CheatManager const&) = delete;

View file

@ -39,7 +39,7 @@ public:
: IClickable(x, y, w, h, colorBg, colorText, message, centered)
{
}
virtual ~Clickable(void){};
virtual ~Clickable() = default;
void draw(float font, SDL_Color overlay) override;
bool held(void) override;

View file

@ -41,7 +41,7 @@ struct DirectoryEntry {
class Directory {
public:
Directory(const std::string& root);
~Directory(void){};
~Directory() = default;
Result error(void);
std::string entry(size_t index);

View file

@ -28,29 +28,33 @@
#define HID_HPP
#include "ihid.hpp"
#include "InputState.hpp"
#include <switch.h>
#define DELAY_TICKS 2500000
template <HidDirection ListDirection, HidDirection PageDirection>
class Hid : public IHid<ListDirection, PageDirection, DELAY_TICKS>
{
class Hid : public IHid<ListDirection, PageDirection, DELAY_TICKS> {
public:
Hid(size_t entries, size_t columns) : IHid<ListDirection, PageDirection, DELAY_TICKS>(entries, columns) {}
Hid(size_t entries, size_t columns) : IHid<ListDirection, PageDirection, DELAY_TICKS>(entries, columns), input(g_input) {}
Hid(size_t entries, size_t columns, const InputState& _input) : IHid<ListDirection, PageDirection, DELAY_TICKS>(entries, columns), input(&_input) {}
private:
bool downDown() const override { return hidKeysDown(CONTROLLER_P1_AUTO) & KEY_DOWN; }
bool upDown() const override { return hidKeysDown(CONTROLLER_P1_AUTO) & KEY_UP; }
bool leftDown() const override { return hidKeysDown(CONTROLLER_P1_AUTO) & KEY_LEFT; }
bool rightDown() const override { return hidKeysDown(CONTROLLER_P1_AUTO) & KEY_RIGHT; }
bool leftTriggerDown() const override { return hidKeysDown(CONTROLLER_P1_AUTO) & KEY_L; }
bool rightTriggerDown() const override { return hidKeysDown(CONTROLLER_P1_AUTO) & KEY_R; }
bool downHeld() const override { return hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_DOWN; }
bool upHeld() const override { return hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_UP; }
bool leftHeld() const override { return hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_LEFT; }
bool rightHeld() const override { return hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_RIGHT; }
bool leftTriggerHeld() const override { return hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_L; }
bool rightTriggerHeld() const override { return hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_R; }
const InputState* input;
bool downDown() const override { return input && input->kDown & HidNpadButton_Down; }
bool upDown() const override { return input && input->kDown & HidNpadButton_Up; }
bool leftDown() const override { return input && input->kDown & HidNpadButton_Left; }
bool rightDown() const override { return input && input->kDown & HidNpadButton_Right; }
bool leftTriggerDown() const override { return input && input->kDown & HidNpadButton_L; }
bool rightTriggerDown() const override { return input && input->kDown & HidNpadButton_R; }
bool downHeld() const override { return input && input->kHeld & HidNpadButton_Down; }
bool upHeld() const override { return input && input->kHeld & HidNpadButton_Up; }
bool leftHeld() const override { return input && input->kHeld & HidNpadButton_Left; }
bool rightHeld() const override { return input && input->kHeld & HidNpadButton_Right; }
bool leftTriggerHeld() const override { return input && input->kHeld & HidNpadButton_L; }
bool rightTriggerHeld() const override { return input && input->kHeld & HidNpadButton_R; }
u64 tick() const override { return armGetSystemTick(); }
};

View file

@ -31,6 +31,7 @@
#include "account.hpp"
#include "title.hpp"
#include "util.hpp"
#include "InputState.hpp"
#include <memory>
#include <switch.h>
@ -47,7 +48,7 @@ inline std::string g_selectedCheatKey;
inline std::vector<std::string> g_selectedCheatCodes;
inline u32 g_username_dotsize;
inline sort_t g_sortMode = SORT_ALPHA;
inline const InputState* g_input = nullptr;
inline std::string g_currentFile = "";
inline bool g_isTransferringFile = false;

View file

@ -39,7 +39,7 @@ class Scrollable : public IScrollable<SDL_Color> {
public:
Scrollable(u32 x, u32 y, u32 w, u32 h, size_t visibleEntries) : IScrollable(x, y, w, h, visibleEntries), mHid(visibleEntries, 1) {}
virtual ~Scrollable(void) {}
virtual ~Scrollable() = default;
void draw(bool condition = false) override;
void setIndex(size_t i);

View file

@ -43,7 +43,7 @@
class Title {
public:
void init(u8 saveDataType, u64 titleid, AccountUid userID, const std::string& name, const std::string& author);
~Title(void){};
~Title() = default;
std::string author(void);
std::pair<std::string, std::string> displayName(void);

View file

@ -83,9 +83,10 @@ void CheatManagerOverlay::draw(void) const
20, 94, ceilf(664 + (32 - height) / 2), COLOR_WHITE, multiSelected ? "\ue003 to deselect all cheats" : "\ue003 to select all cheats");
}
void CheatManagerOverlay::update(touchPosition* touch)
void CheatManagerOverlay::update(const InputState& input)
{
if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_A) {
u64 kDown = input.kDown;
if (kDown & HidNpadButton_A) {
std::string cellName = scrollable->cellName(scrollable->index());
if (cellName.compare(0, MAGIC_LEN, SELECTED_MAGIC) == 0) {
// cheat was already selected
@ -97,7 +98,7 @@ void CheatManagerOverlay::update(touchPosition* touch)
scrollable->text(scrollable->index(), cellName);
}
if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_Y) {
if (kDown & HidNpadButton_Y) {
if (multiSelected) {
for (size_t j = 0; j < scrollable->size(); j++) {
std::string cellName = scrollable->cellName(j);
@ -125,7 +126,7 @@ void CheatManagerOverlay::update(touchPosition* touch)
scrollable->selectRow(scrollable->index(), true);
currentIndex = scrollable->index();
if (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_B) {
if (kDown & HidNpadButton_B) {
g_selectedCheatKey = key;
g_selectedCheatCodes.clear();
for (size_t i = 0; i < scrollable->size(); i++) {

View file

@ -45,9 +45,10 @@ void ErrorOverlay::draw(void) const
drawPulsingOutline(322, 462, 636, 56, 4, COLOR_RED);
}
void ErrorOverlay::update(touchPosition* touch)
void ErrorOverlay::update(const InputState& input)
{
if (button->released() || (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_A) || (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_B)) {
const u64 kDown = input.kDown;
if (button->released() || (kDown & HidNpadButton_A) || (kDown & HidNpadButton_B)) {
screen.removeOverlay();
}
}

View file

@ -43,9 +43,10 @@ void InfoOverlay::draw(void) const
drawPulsingOutline(322, 462, 636, 56, 4, COLOR_BLUE);
}
void InfoOverlay::update(touchPosition* touch)
void InfoOverlay::update(const InputState& input)
{
if (button->released() || (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_A) || (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_B)) {
const u64 kDown = input.kDown;
if (button->released() || (kDown & HidNpadButton_A) || (kDown & HidNpadButton_B)) {
screen.removeOverlay();
}
}

View file

@ -28,10 +28,11 @@
static constexpr size_t rowlen = 5, collen = 4, rows = 10, SIDEBAR_w = 96;
MainScreen::MainScreen() : hid(rowlen * collen, collen)
MainScreen::MainScreen(const InputState& input) : hid(rowlen * collen, collen, input)
{
pksmBridge = false;
selectionTimer = 0;
pksmBridge = false;
wantInstructions = false;
selectionTimer = 0;
sprintf(ver, "v%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_MICRO);
backupList = std::make_unique<Scrollable>(538, 276, 414, 380, rows);
buttonBackup = std::make_unique<Clickable>(956, 276, 220, 80, theme().c2, theme().c6, "Backup \ue004", true);
@ -183,7 +184,7 @@ void MainScreen::draw() const
SDLH_GetTextDimensions(26, "checkpoint", &checkpoint_w, &checkpoint_h);
SDLH_GetTextDimensions(24, "\ue046 Instructions", &inst_w, &inst_h);
if (hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_MINUS && currentOverlay == nullptr) {
if (wantInstructions && currentOverlay == nullptr) {
SDLH_DrawRect(0, 0, 1280, 720, COLOR_OVERLAY);
SDLH_DrawText(27, 1205, 646, theme().c6, "\ue085\ue086");
SDLH_DrawText(24, 58, 69, theme().c6, "\ue058 Tap to select title");
@ -223,13 +224,13 @@ void MainScreen::draw() const
}
}
void MainScreen::update(touchPosition* touch)
void MainScreen::update(const InputState& input)
{
updateSelector(touch);
handleEvents(touch);
updateSelector(input);
handleEvents(input);
}
void MainScreen::updateSelector(touchPosition* touch)
void MainScreen::updateSelector(const InputState& input)
{
if (!g_backupScrollEnabled) {
size_t count = getTitleCount(g_currentUId);
@ -245,7 +246,8 @@ void MainScreen::updateSelector(touchPosition* touch)
u32 x = selectorX(index);
u32 y = selectorY(index);
if (hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_TOUCH && touch->px >= x && touch->px <= x + 128 && touch->py >= y && touch->py <= y + 128) {
if (input.touch.count > 0 && input.touch.touches[0].x >= x && input.touch.touches[0].x <= x + 128 && input.touch.touches[0].y >= y &&
input.touch.touches[0].y <= y + 128) {
hid.index(index);
}
}
@ -261,11 +263,14 @@ void MainScreen::updateSelector(touchPosition* touch)
}
}
void MainScreen::handleEvents(touchPosition* touch)
void MainScreen::handleEvents(const InputState& input)
{
u32 kdown = hidKeysDown(CONTROLLER_P1_AUTO);
u32 kheld = hidKeysHeld(CONTROLLER_P1_AUTO);
if (kdown & KEY_ZL || kdown & KEY_ZR) {
const u64 kheld = input.kHeld;
const u64 kdown = input.kDown;
wantInstructions = (kheld & HidNpadButton_Minus);
if (kdown & HidNpadButton_ZL || kdown & HidNpadButton_ZR) {
while ((g_currentUId = Account::selectAccount()) == 0)
;
this->index(TITLES, 0);
@ -277,7 +282,7 @@ void MainScreen::handleEvents(touchPosition* touch)
Title title;
getTitle(title, g_currentUId, this->index(TITLES));
if (!getPKSMBridgeFlag()) {
if ((kheld & KEY_L) && (kheld & KEY_R) && isPKSMBridgeTitle(title.id())) {
if ((kheld & HidNpadButton_L) && (kheld & HidNpadButton_R) && isPKSMBridgeTitle(title.id())) {
setPKSMBridgeFlag(true);
updateButtons();
}
@ -285,8 +290,8 @@ void MainScreen::handleEvents(touchPosition* touch)
}
// handle touchscreen
if (!g_backupScrollEnabled && hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_TOUCH && touch->px >= 1200 && touch->px <= 1200 + USER_ICON_SIZE &&
touch->py >= 626 && touch->py <= 626 + USER_ICON_SIZE) {
if (!g_backupScrollEnabled && input.touch.count > 0 && input.touch.touches[0].x >= 1200 && input.touch.touches[0].x <= 1200 + USER_ICON_SIZE &&
input.touch.touches[0].y >= 626 && input.touch.touches[0].y <= 626 + USER_ICON_SIZE) {
while ((g_currentUId = Account::selectAccount()) == 0)
;
this->index(TITLES, 0);
@ -295,8 +300,7 @@ void MainScreen::handleEvents(touchPosition* touch)
}
// Handle touching the backup list
if ((hidKeysDown(CONTROLLER_P1_AUTO) & KEY_TOUCH && (int)touch->px > 538 && (int)touch->px < 952 && (int)touch->py > 276 &&
(int)touch->py < 656)) {
if (input.touch.count > 0 && input.touch.touches[0].x > 538 && input.touch.touches[0].x < 952 && input.touch.touches[0].y > 276 && input.touch.touches[0].y < 656) {
// Activate backup list only if multiple selections are enabled
if (!MS::multipleSelectionEnabled()) {
g_backupScrollEnabled = true;
@ -309,7 +313,7 @@ void MainScreen::handleEvents(touchPosition* touch)
// Backup list active: Backup/Restore
// Backup list inactive: Activate backup list only if multiple
// selections are enabled
if (kdown & KEY_A) {
if (kdown & HidNpadButton_A) {
// If backup list is active...
if (g_backupScrollEnabled) {
// If the "New..." entry is selected...
@ -361,8 +365,7 @@ void MainScreen::handleEvents(touchPosition* touch)
}
// Handle pressing B
if (kdown & KEY_B || (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_TOUCH && (int)touch->px >= 0 && (int)touch->px <= 532 && (int)touch->py >= 0 &&
(int)touch->py <= 664)) {
if ((kdown & HidNpadButton_B) || (input.touch.count > 0 && input.touch.touches[0].x <= 532 && input.touch.touches[0].y <= 664)) {
this->index(CELLS, 0);
g_backupScrollEnabled = false;
entryType(TITLES);
@ -372,7 +375,7 @@ void MainScreen::handleEvents(touchPosition* touch)
}
// Handle pressing X
if (kdown & KEY_X) {
if (kdown & HidNpadButton_X) {
if (g_backupScrollEnabled) {
size_t index = this->index(CELLS);
if (index > 0) {
@ -399,7 +402,7 @@ void MainScreen::handleEvents(touchPosition* touch)
// Backup list active: Deactivate backup list, select title, and
// enable backup button
// Backup list inactive: Select title and enable backup button
if (kdown & KEY_Y) {
if (kdown & HidNpadButton_Y) {
if (g_backupScrollEnabled) {
this->index(CELLS, 0);
g_backupScrollEnabled = false;
@ -411,7 +414,7 @@ void MainScreen::handleEvents(touchPosition* touch)
}
// Handle holding Y
if (hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_Y && !(g_backupScrollEnabled)) {
if (kheld & HidNpadButton_Y && !(g_backupScrollEnabled)) {
selectionTimer++;
}
else {
@ -427,7 +430,7 @@ void MainScreen::handleEvents(touchPosition* touch)
}
// Handle pressing/touching L
if (buttonBackup->released() || (kdown & KEY_L)) {
if (buttonBackup->released() || (kdown & HidNpadButton_L)) {
if (MS::multipleSelectionEnabled()) {
resetIndex(CELLS);
std::vector<size_t> list = MS::selectedEntries();
@ -481,7 +484,7 @@ void MainScreen::handleEvents(touchPosition* touch)
}
// Handle pressing/touching R
if (buttonRestore->released() || (kdown & KEY_R)) {
if (buttonRestore->released() || (kdown & HidNpadButton_R)) {
if (g_backupScrollEnabled) {
if (getPKSMBridgeFlag() && this->index(CELLS) != 0) {
currentOverlay = std::make_shared<YesNoOverlay>(
@ -516,7 +519,7 @@ void MainScreen::handleEvents(touchPosition* touch)
}
}
if ((buttonCheats->released() || (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_RSTICK)) && CheatManager::getInstance().cheats() != nullptr) {
if ((buttonCheats->released() || (kdown & HidNpadButton_StickR)) && CheatManager::getInstance().cheats() != nullptr) {
if (MS::multipleSelectionEnabled()) {
MS::clearSelectedEntries();
updateButtons();

View file

@ -56,7 +56,7 @@ void YesNoOverlay::draw(void) const
}
}
void YesNoOverlay::update(touchPosition* touch)
void YesNoOverlay::update(const InputState& input)
{
hid.update(2);
@ -64,10 +64,12 @@ void YesNoOverlay::update(touchPosition* touch)
buttonYes->selected(hid.index() == 0);
buttonNo->selected(hid.index() == 1);
if (buttonYes->released() || ((hidKeysDown(CONTROLLER_P1_AUTO) & KEY_A) && hid.index() == 0)) {
const u64 kDown = input.kDown;
if (buttonYes->released() || ((kDown & HidNpadButton_A) && hid.index() == 0)) {
yesFunc();
}
else if (buttonNo->released() || (hidKeysDown(CONTROLLER_P1_AUTO) & KEY_B) || ((hidKeysDown(CONTROLLER_P1_AUTO) & KEY_A) && hid.index() == 1)) {
else if (buttonNo->released() || (kDown & HidNpadButton_B) || ((kDown & HidNpadButton_A) && hid.index() == 1)) {
noFunc();
}
}

View file

@ -119,7 +119,7 @@ AccountUid Account::selectAccount(void)
u8 st_out[0x18] = {0};
size_t repsz;
Result res = libappletLaunch(AppletId_playerSelect, &args, st_in, 0xA0, st_out, 0x18, &repsz);
Result res = libappletLaunch(AppletId_LibraryAppletPlayerSelect, &args, st_in, 0xA0, st_out, 0x18, &repsz);
if (R_SUCCEEDED(res)) {
u64 lres = *(u64*)st_out;
AccountUid uid = *(AccountUid*)&st_out[8];

View file

@ -28,23 +28,23 @@
bool Clickable::held()
{
touchPosition touch;
hidTouchRead(&touch, 0);
return ((hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_TOUCH) && (int)touch.px > mx && (int)touch.px < mx + mw && (int)touch.py > my &&
(int)touch.py < my + mh);
return g_input->touch.count > 0 && g_input->touch.touches[0].y > (unsigned)my && g_input->touch.touches[0].y < (unsigned)(my + mh) &&
g_input->touch.touches[0].x > (unsigned)mx && g_input->touch.touches[0].x < (unsigned)(mx + mw);
}
bool Clickable::released(void)
bool Clickable::released()
{
touchPosition touch;
hidTouchRead(&touch, 0);
const bool on = (int)touch.px > mx && (int)touch.px < mx + mw && (int)touch.py > my && (int)touch.py < my + mh;
const auto [on, currentlyTouching] = [this]() {
return std::make_pair(g_input->touch.count > 0 && g_input->touch.touches[0].y > (unsigned)my && g_input->touch.touches[0].y < (unsigned)(my + mh) &&
g_input->touch.touches[0].x > (unsigned)mx && g_input->touch.touches[0].x < (unsigned)(mx + mw),
g_input->touch.count > 0);
}();
if (on) {
mOldPressed = true;
}
else {
if (mOldPressed && !(touch.px > 0 || touch.py > 0)) {
if (mOldPressed && !currentlyTouching) {
mOldPressed = false;
return true;
}

View file

@ -33,6 +33,7 @@ static const char* s_http_port = "8000";
static void handle_populate(struct mg_connection* nc, struct http_message* hm)
{
(void)hm;
// populate gets called at startup, assume a new connection has been started
blinkLed(2);

View file

@ -48,7 +48,12 @@ int main(void)
exit(res);
}
g_screen = std::make_unique<MainScreen>();
InputState input;
g_input = &input;
PadState pad;
padInitializeDefault(&pad);
g_screen = std::make_unique<MainScreen>(input);
loadTitles();
// get the user IDs
@ -57,23 +62,31 @@ int main(void)
if (g_currentUId == 0)
g_currentUId = userIds.at(0);
Thread networkThread;
threadCreate(&networkThread, (ThreadFunc)networkLoop, nullptr, nullptr, 16 * 1000, 0x2C, -2);
threadStart(&networkThread);
// TODO: UNCOMMENT ME
// Thread networkThread;
// threadCreate(&networkThread, (ThreadFunc)networkLoop, nullptr, nullptr, 16 * 1000, 0x2C, -2);
// threadStart(&networkThread);
while (appletMainLoop() && !(hidKeysDown(CONTROLLER_P1_AUTO) & KEY_PLUS)) {
touchPosition touch;
hidScanInput();
hidTouchRead(&touch, 0);
while (appletMainLoop()) {
padUpdate(&pad);
input.kDown = padGetButtonsDown(&pad);
if (input.kDown & HidNpadButton_Plus)
break;
input.kHeld = padGetButtons(&pad);
input.kUp = padGetButtonsUp(&pad);
hidGetTouchScreenStates(&input.touch, 1);
g_screen->doDraw();
g_screen->doUpdate(&touch);
g_screen->doUpdate(input);
SDLH_Render();
}
g_shouldExitNetworkLoop = true;
threadWaitForExit(&networkThread);
threadClose(&networkThread);
// TODO: uncomment me
// g_shouldExitNetworkLoop = true;
// threadWaitForExit(&networkThread);
// threadClose(&networkThread);
servicesExit();
exit(0);

View file

@ -54,13 +54,11 @@ void Scrollable::push_back(SDL_Color color, SDL_Color colorMessage, const std::s
void Scrollable::updateSelection(void)
{
touchPosition touch;
hidTouchRead(&touch, 0);
const int hu = (mHid.maxEntries(size()) + 1) * mh / mVisibleEntries;
if (hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_TOUCH && touch.py > (float)my && touch.py < (float)(my + hu) && touch.px > (float)mx &&
touch.px < (float)(mx + mw)) {
mHid.index(ceilf((touch.py - my) * mVisibleEntries / mh));
if (g_input->touch.count > 0 && g_input->touch.touches[0].y > (float)my && g_input->touch.touches[0].y < (float)(my + hu) && g_input->touch.touches[0].x > (float)mx &&
g_input->touch.touches[0].x < (float)(mx + mw)) {
mHid.index(ceilf((g_input->touch.touches[0].y - my) * mVisibleEntries / mh));
}
mHid.update(size());

View file

@ -70,6 +70,9 @@ Result servicesInit(void)
romfsInit();
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
hidInitializeTouchScreen();
if (R_FAILED(res = plInitialize(PlServiceType_User))) {
Logger::getInstance().log(Logger::ERROR, "plInitialize failed. Result code 0x%08lX.", res);
return res;
@ -176,11 +179,13 @@ HidsysNotificationLedPattern blinkLedPattern(u8 times)
void blinkLed(u8 times)
{
if (g_notificationLedAvailable) {
PadState pad;
padInitializeDefault(&pad);
s32 n;
u64 uniquePadIds[2];
HidsysUniquePadId uniquePadIds[2] = {0};
HidsysNotificationLedPattern pattern = blinkLedPattern(times);
memset(uniquePadIds, 0, sizeof(uniquePadIds));
Result res = hidsysGetUniquePadsFromNpad(hidGetHandheldMode() ? CONTROLLER_HANDHELD : CONTROLLER_PLAYER_1, uniquePadIds, 2, &n);
Result res = hidsysGetUniquePadsFromNpad(padIsHandheld(&pad) ? HidNpadIdType_Handheld : HidNpadIdType_No1, uniquePadIds, 2, &n);
if (R_SUCCEEDED(res)) {
for (s32 i = 0; i < n; i++) {
hidsysSetNotificationLedPattern(&pattern, uniquePadIds[i]);