[nostalgia/core/gba] Add user input support
This commit is contained in:
parent
72883285f2
commit
e8151ac037
@ -28,6 +28,7 @@ install(
|
|||||||
context.hpp
|
context.hpp
|
||||||
core.hpp
|
core.hpp
|
||||||
gfx.hpp
|
gfx.hpp
|
||||||
|
input.hpp
|
||||||
media.hpp
|
media.hpp
|
||||||
mem.hpp
|
mem.hpp
|
||||||
DESTINATION
|
DESTINATION
|
||||||
|
@ -62,6 +62,11 @@ using interrupt_handler = void (*)(void);
|
|||||||
#define REG_BG2VOFS *reinterpret_cast<volatile uint32_t*>(0x0400001a)
|
#define REG_BG2VOFS *reinterpret_cast<volatile uint32_t*>(0x0400001a)
|
||||||
#define REG_BG3VOFS *reinterpret_cast<volatile uint32_t*>(0x0400001e)
|
#define REG_BG3VOFS *reinterpret_cast<volatile uint32_t*>(0x0400001e)
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////
|
||||||
|
// User Input
|
||||||
|
|
||||||
|
#define REG_GAMEPAD *reinterpret_cast<volatile uint16_t*>(0x04000130)
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
// Memory Addresses
|
// Memory Addresses
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <nostalgia/core/config.hpp>
|
#include <nostalgia/core/config.hpp>
|
||||||
#include <nostalgia/core/core.hpp>
|
#include <nostalgia/core/core.hpp>
|
||||||
|
#include <nostalgia/core/input.hpp>
|
||||||
|
|
||||||
#include "addresses.hpp"
|
#include "addresses.hpp"
|
||||||
#include "bios.hpp"
|
#include "bios.hpp"
|
||||||
@ -54,4 +55,8 @@ uint64_t ticksMs() {
|
|||||||
return g_timerMs;
|
return g_timerMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool buttonDown(Key k) {
|
||||||
|
return !(REG_GAMEPAD & k);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
29
src/nostalgia/core/input.hpp
Normal file
29
src/nostalgia/core/input.hpp
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 - 2020 gary@drinkingtea.net
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace nostalgia::core {
|
||||||
|
|
||||||
|
enum Key {
|
||||||
|
// GBA implementation currently relies on GamePad entry order
|
||||||
|
GamePad_A = 1,
|
||||||
|
GamePad_B = 2,
|
||||||
|
GamePad_Select = 4,
|
||||||
|
GamePad_Start = 8,
|
||||||
|
GamePad_Right = 16,
|
||||||
|
GamePad_Left = 32,
|
||||||
|
GamePad_Up = 64,
|
||||||
|
GamePad_Down = 128,
|
||||||
|
GamePad_R = 256,
|
||||||
|
GamePad_L = 512,
|
||||||
|
};
|
||||||
|
|
||||||
|
[[nodiscard]] bool buttonDown(Key);
|
||||||
|
|
||||||
|
}
|
@ -9,6 +9,7 @@
|
|||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#include <nostalgia/core/gfx.hpp>
|
#include <nostalgia/core/gfx.hpp>
|
||||||
|
#include <nostalgia/core/input.hpp>
|
||||||
#include <nostalgia/core/core.hpp>
|
#include <nostalgia/core/core.hpp>
|
||||||
|
|
||||||
namespace nostalgia::core {
|
namespace nostalgia::core {
|
||||||
@ -52,4 +53,8 @@ uint64_t ticksMs() {
|
|||||||
return SDL_GetTicks();;
|
return SDL_GetTicks();;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool buttonDown(Key) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user