[nostalgia/core] Add Context buttonDown function
This commit is contained in:
parent
0e7a090d28
commit
41cebff5fc
@ -55,7 +55,7 @@ uint64_t ticksMs(Context*) noexcept {
|
|||||||
return g_timerMs;
|
return g_timerMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool buttonDown(Key k) noexcept {
|
bool buttonDown(Context*, Key k) noexcept {
|
||||||
return !(REG_GAMEPAD & k);
|
return !(REG_GAMEPAD & k);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,6 @@
|
|||||||
|
|
||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
|
|
||||||
void draw(Context *ctx) noexcept;
|
|
||||||
|
|
||||||
ox::Result<ox::UniquePtr<Context>> init(ox::UniquePtr<ox::FileSystem> fs, const char *appName) noexcept {
|
ox::Result<ox::UniquePtr<Context>> init(ox::UniquePtr<ox::FileSystem> fs, const char *appName) noexcept {
|
||||||
auto ctx = ox::make_unique<Context>();
|
auto ctx = ox::make_unique<Context>();
|
||||||
ctx->rom = std::move(fs);
|
ctx->rom = std::move(fs);
|
||||||
@ -72,7 +70,7 @@ uint64_t ticksMs(Context *ctx) noexcept {
|
|||||||
return static_cast<uint64_t>(now - id->startTime);
|
return static_cast<uint64_t>(now - id->startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool buttonDown(Key) noexcept {
|
bool buttonDown(Context*, Key) noexcept {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,5 +80,4 @@ ox::Error shutdown(Context *ctx) noexcept {
|
|||||||
return OxError(0);
|
return OxError(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,9 @@ enum Key {
|
|||||||
GamePad_L = 512,
|
GamePad_L = 512,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class Context;
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
bool buttonDown(Key) noexcept;
|
bool buttonDown(Context *ctx, Key) noexcept;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,14 +10,14 @@ static unsigned spriteX = 72;
|
|||||||
static unsigned spriteY = 64;
|
static unsigned spriteY = 64;
|
||||||
|
|
||||||
static int eventHandler(core::Context *ctx) noexcept {
|
static int eventHandler(core::Context *ctx) noexcept {
|
||||||
if (core::buttonDown(core::GamePad_Right)) {
|
if (core::buttonDown(ctx, core::GamePad_Right)) {
|
||||||
spriteX += 2;
|
spriteX += 2;
|
||||||
} else if (core::buttonDown(core::GamePad_Left)) {
|
} else if (core::buttonDown(ctx, core::GamePad_Left)) {
|
||||||
spriteX -= 2;
|
spriteX -= 2;
|
||||||
}
|
}
|
||||||
if (core::buttonDown(core::GamePad_Down)) {
|
if (core::buttonDown(ctx, core::GamePad_Down)) {
|
||||||
spriteY += 2;
|
spriteY += 2;
|
||||||
} else if (core::buttonDown(core::GamePad_Up)) {
|
} else if (core::buttonDown(ctx, core::GamePad_Up)) {
|
||||||
spriteY -= 2;
|
spriteY -= 2;
|
||||||
}
|
}
|
||||||
constexpr auto s = "nostalgia";
|
constexpr auto s = "nostalgia";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user