Added controller support

This commit is contained in:
antopilo
2024-12-01 20:52:34 -05:00
parent 82459a6e4c
commit d93d69d059
8 changed files with 47427 additions and 611 deletions

View File

@@ -3,6 +3,7 @@
#include "src/Core/Input.h"
#include <Coral/Array.hpp>
#include <Coral/String.hpp>
namespace Nuake {
@@ -39,6 +40,26 @@ namespace Nuake {
return Coral::Array<float>::New({ mousePosition.x, mousePosition.y });
}
bool IsControllerConnected(int id)
{
return Input::IsControllerPresent(id);
}
Coral::String GetControllerName(int id)
{
std::string controllerName = Input::GetControllerName(id);
return Coral::String::New(controllerName);
}
bool IsControllerButtonPressed(int id, int button)
{
return Input::IsControllerButtonPressed(id, (ControllerInput)button);
}
float GetControllerAxis(int id, int axis)
{
return Input::GetControllerAxis(id, (ControllerAxis)axis);
}
void InputNetAPI::RegisterMethods()
{
@@ -48,6 +69,12 @@ namespace Nuake {
RegisterMethod("Input.IsMouseButtonDownIcall", &IsMouseButtonDown);
RegisterMethod("Input.GetMousePositionIcall", &GetMousePosition);
RegisterMethod("Input.IsControllerConnectedIcall", &IsControllerConnected);
RegisterMethod("Input.GetControllerNameIcall", &GetControllerName);
RegisterMethod("Input.IsControllerButtonPressedIcall", &IsControllerButtonPressed);
RegisterMethod("Input.GetControllerAxisIcall", &GetControllerAxis);
}
}

View File

@@ -696,4 +696,3 @@ namespace Nuake {
}
}