Added controller support
This commit is contained in:
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -696,4 +696,3 @@ namespace Nuake {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user