mirror of https://github.com/mgba-emu/mgba.git
Scripting: Expose gamepad name to scripts
This commit is contained in:
parent
a62a3eb811
commit
c0d4e2c347
|
@ -220,6 +220,9 @@ struct mScriptTriggerEvent {
|
|||
struct mScriptGamepad {
|
||||
unsigned pad;
|
||||
|
||||
char visibleName[128];
|
||||
char internalName[64];
|
||||
|
||||
struct mScriptList axes;
|
||||
struct mScriptList buttons;
|
||||
struct mScriptList hats;
|
||||
|
|
|
@ -13,6 +13,7 @@ function readPad()
|
|||
local buttons = gamepad.buttons
|
||||
local hats = gamepad.hats
|
||||
|
||||
inputBuffer:print(gamepad.visibleName .. "\n")
|
||||
inputBuffer:print(string.format("%i buttons, %i axes, %i hats\n", #buttons, #axes, #hats))
|
||||
|
||||
local sbuttons = {}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <mgba/script/input.h>
|
||||
#include <mgba-util/math.h>
|
||||
#include <mgba-util/string.h>
|
||||
|
||||
using namespace QGBA;
|
||||
|
||||
|
@ -237,6 +238,11 @@ void ScriptingController::updateGamepad() {
|
|||
detachGamepad();
|
||||
return;
|
||||
}
|
||||
|
||||
QString name = gamepad->name();
|
||||
strlcpy(m_gamepad.internalName, name.toUtf8().constData(), sizeof(m_gamepad.internalName));
|
||||
name = gamepad->visibleName();
|
||||
strlcpy(m_gamepad.visibleName, name.toUtf8().constData(), sizeof(m_gamepad.visibleName));
|
||||
attachGamepad();
|
||||
|
||||
QList<bool> buttons = gamepad->currentButtons();
|
||||
|
|
|
@ -95,6 +95,8 @@ mSCRIPT_DEFINE_STRUCT(mScriptGamepadHatEvent)
|
|||
mSCRIPT_DEFINE_END;
|
||||
|
||||
mSCRIPT_DEFINE_STRUCT(mScriptGamepad)
|
||||
mSCRIPT_DEFINE_STRUCT_MEMBER(mScriptGamepad, CHARP, visibleName)
|
||||
mSCRIPT_DEFINE_STRUCT_MEMBER(mScriptGamepad, CHARP, internalName)
|
||||
mSCRIPT_DEFINE_STRUCT_MEMBER(mScriptGamepad, LIST, axes)
|
||||
mSCRIPT_DEFINE_STRUCT_MEMBER(mScriptGamepad, LIST, buttons)
|
||||
mSCRIPT_DEFINE_STRUCT_MEMBER(mScriptGamepad, LIST, hats)
|
||||
|
|
Loading…
Reference in New Issue