Cemu/src/input/api/InputAPI.h
2026-07-02 22:39:35 +03:00

92 lines
1.7 KiB
C++

#pragma once
#include "util/helpers/helpers.h"
namespace InputAPI
{
enum Type
{
Keyboard,
SDLController,
XInput,
DirectInput,
DSUClient,
GameCube,
Wiimote,
Android,
Device,
WGIGamepad,
WGIRawController,
MAX
};
constexpr std::string_view to_string(Type type)
{
switch (type)
{
case Keyboard:
return "Keyboard";
case DirectInput:
return "DirectInput";
case XInput:
return "XInput";
case Wiimote:
return "Wiimote";
case GameCube:
return "GameCube";
case DSUClient:
return "DSUController";
case WGIGamepad:
return "WGIGamepad";
case WGIRawController:
return "WGIRawController";
case SDLController:
return "SDLController";
case Android:
return "Android";
case Device:
return "Device";
default:
break;
}
throw std::runtime_error(fmt::format("unknown input api: {}", stdx::to_underlying(type)));
}
constexpr Type from_string(std::string_view str)
{
if (str == to_string(Keyboard))
return Keyboard;
else if (str == to_string(DirectInput))
return DirectInput;
else if (str == to_string(XInput))
return XInput;
else if (str == to_string(Wiimote))
return Wiimote;
else if (str == to_string(GameCube))
return GameCube;
else if (str == to_string(DSUClient))
return DSUClient;
else if (str == to_string(SDLController))
return SDLController;
else if (str == to_string(Android))
return Android;
else if (str == to_string(Device))
return Device;
else if (str == "DSU") // legacy
return DSUClient;
//else if (str == "WGIGamepad")
// return WGIGamepad;
//
//else if (str == "WGIRawController")
// return WGIRawController;
throw std::runtime_error(fmt::format("unknown input api: {}", str));
}
}