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 {
|
struct mScriptGamepad {
|
||||||
unsigned pad;
|
unsigned pad;
|
||||||
|
|
||||||
|
char visibleName[128];
|
||||||
|
char internalName[64];
|
||||||
|
|
||||||
struct mScriptList axes;
|
struct mScriptList axes;
|
||||||
struct mScriptList buttons;
|
struct mScriptList buttons;
|
||||||
struct mScriptList hats;
|
struct mScriptList hats;
|
||||||
|
|
|
@ -13,6 +13,7 @@ function readPad()
|
||||||
local buttons = gamepad.buttons
|
local buttons = gamepad.buttons
|
||||||
local hats = gamepad.hats
|
local hats = gamepad.hats
|
||||||
|
|
||||||
|
inputBuffer:print(gamepad.visibleName .. "\n")
|
||||||
inputBuffer:print(string.format("%i buttons, %i axes, %i hats\n", #buttons, #axes, #hats))
|
inputBuffer:print(string.format("%i buttons, %i axes, %i hats\n", #buttons, #axes, #hats))
|
||||||
|
|
||||||
local sbuttons = {}
|
local sbuttons = {}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include <mgba/script/input.h>
|
#include <mgba/script/input.h>
|
||||||
#include <mgba-util/math.h>
|
#include <mgba-util/math.h>
|
||||||
|
#include <mgba-util/string.h>
|
||||||
|
|
||||||
using namespace QGBA;
|
using namespace QGBA;
|
||||||
|
|
||||||
|
@ -237,6 +238,11 @@ void ScriptingController::updateGamepad() {
|
||||||
detachGamepad();
|
detachGamepad();
|
||||||
return;
|
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();
|
attachGamepad();
|
||||||
|
|
||||||
QList<bool> buttons = gamepad->currentButtons();
|
QList<bool> buttons = gamepad->currentButtons();
|
||||||
|
|
|
@ -95,6 +95,8 @@ mSCRIPT_DEFINE_STRUCT(mScriptGamepadHatEvent)
|
||||||
mSCRIPT_DEFINE_END;
|
mSCRIPT_DEFINE_END;
|
||||||
|
|
||||||
mSCRIPT_DEFINE_STRUCT(mScriptGamepad)
|
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, axes)
|
||||||
mSCRIPT_DEFINE_STRUCT_MEMBER(mScriptGamepad, LIST, buttons)
|
mSCRIPT_DEFINE_STRUCT_MEMBER(mScriptGamepad, LIST, buttons)
|
||||||
mSCRIPT_DEFINE_STRUCT_MEMBER(mScriptGamepad, LIST, hats)
|
mSCRIPT_DEFINE_STRUCT_MEMBER(mScriptGamepad, LIST, hats)
|
||||||
|
|
Loading…
Reference in New Issue