mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-08-08 11:39:06 +00:00
aurora: Implement Controller events
This commit is contained in:
parent
cbe268a0fc
commit
8863003855
@ -16,6 +16,7 @@ add_library(aurora STATIC
|
|||||||
lib/aurora.cpp
|
lib/aurora.cpp
|
||||||
lib/gpu.cpp
|
lib/gpu.cpp
|
||||||
lib/imgui.cpp
|
lib/imgui.cpp
|
||||||
|
lib/input.cpp
|
||||||
lib/dawn/BackendBinding.cpp
|
lib/dawn/BackendBinding.cpp
|
||||||
lib/gfx/common.cpp
|
lib/gfx/common.cpp
|
||||||
lib/gfx/texture.cpp
|
lib/gfx/texture.cpp
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <aurora/aurora.hpp>
|
#include <aurora/aurora.hpp>
|
||||||
|
|
||||||
#include "gfx/common.hpp"
|
#include "gfx/common.hpp"
|
||||||
#include "gpu.hpp"
|
#include "gpu.hpp"
|
||||||
|
#include "input.hpp"
|
||||||
#include "imgui.hpp"
|
#include "imgui.hpp"
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
@ -123,18 +123,27 @@ static bool poll_events() noexcept {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_CONTROLLERDEVICEADDED: {
|
case SDL_CONTROLLERDEVICEADDED: {
|
||||||
|
auto instance = input::add_controller(event.cdevice.which);
|
||||||
|
if (instance != -1) {
|
||||||
|
g_AppDelegate->onControllerAdded(instance);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_CONTROLLERDEVICEREMOVED: {
|
case SDL_CONTROLLERDEVICEREMOVED: {
|
||||||
|
input::remove_controller(event.cdevice.which);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SDL_CONTROLLERBUTTONUP:
|
||||||
case SDL_CONTROLLERBUTTONDOWN: {
|
case SDL_CONTROLLERBUTTONDOWN: {
|
||||||
break;
|
g_AppDelegate->onControllerButton(
|
||||||
}
|
event.cbutton.which, input::translate_button(static_cast<SDL_GameControllerButton>(event.cbutton.button)),
|
||||||
case SDL_CONTROLLERBUTTONUP: {
|
event.cbutton.state == SDL_PRESSED);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_CONTROLLERAXISMOTION: {
|
case SDL_CONTROLLERAXISMOTION: {
|
||||||
|
g_AppDelegate->onControllerAxis(event.caxis.which,
|
||||||
|
input::translate_axis(static_cast<SDL_GameControllerAxis>(event.caxis.axis)),
|
||||||
|
event.caxis.value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SDL_KEYDOWN: {
|
case SDL_KEYDOWN: {
|
||||||
@ -335,18 +344,16 @@ void set_fullscreen(bool fullscreen) noexcept {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t get_controller_player_index(uint32_t which) noexcept {
|
int32_t get_controller_player_index(uint32_t which) noexcept {
|
||||||
return -1; // TODO
|
return input::player_index(which); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_controller_player_index(uint32_t which, int32_t index) noexcept {
|
void set_controller_player_index(uint32_t which, int32_t index) noexcept { input::set_player_index(which, index); }
|
||||||
// TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
bool is_controller_gamecube(uint32_t which) noexcept {
|
bool is_controller_gamecube(uint32_t which) noexcept {
|
||||||
return true; // TODO
|
return input::is_gamecube(which); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string get_controller_name(uint32_t which) noexcept {
|
std::string get_controller_name(uint32_t instance) noexcept {
|
||||||
return ""; // TODO
|
return input::name(instance); // TODO
|
||||||
}
|
}
|
||||||
} // namespace aurora
|
} // namespace aurora
|
||||||
|
Loading…
x
Reference in New Issue
Block a user