Skip to content

Commit 6d589d8

Browse files
committed
Fixed rumble control in controller test
1 parent 16da127 commit 6d589d8

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

driveRoot/rvloader/theme/scripts/controllersSettings.lua

+7
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,15 @@ end
359359
function buttonsTester:handleInputs(onFocus)
360360
local held = Pad.genheld(0)
361361

362+
if held.BUTTON_A and held.BUTTON_B then
363+
Pad.setRumble(0, true)
364+
end else
365+
Pad.setRumble(0, false)
366+
end
367+
362368
if held.TRIGGER_R and held.TRIGGER_L then
363369
self.controllerSettings.runningButtonsTester = false
370+
Pad.setRumble(0, false)
364371
end
365372
end
366373

main/source/luasupport/luapadlib.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,24 @@ static int lua_Pad_triggers(lua_State* L) {
223223
return 1;
224224
}
225225

226+
static int lua_Pad_setRumble(lua_State* L) {
227+
int argc = lua_gettop(L);
228+
if (argc != 2) {
229+
return luaL_error(L, "wrong number of arguments");
230+
}
231+
232+
u32 channel = luaL_checkinteger(L, 1);
233+
if (channel > 3) {
234+
return luaL_error(L, "pad channel must be 0-3");
235+
}
236+
237+
bool rumbleState = lua_toboolean(L, 2);
238+
239+
PAD_ControlMotor(channel, rumbleState ? 1 : 0);
240+
241+
return 0;
242+
}
243+
226244
static const luaL_Reg Pad_functions[] = {
227245
{"isConnected", lua_Pad_isConnected},
228246
{"held", lua_Pad_held},
@@ -236,6 +254,7 @@ static const luaL_Reg Pad_functions[] = {
236254
{"genstick", lua_Pad_genstick},
237255
{"gensubStick", lua_Pad_gensubStick},
238256
{"triggers", lua_Pad_triggers},
257+
{"setRumble", lua_Pad_setRumble},
239258
{NULL, NULL}
240259
};
241260

0 commit comments

Comments
 (0)