mirror of
https://github.com/Ale32bit/Capy64.git
synced 2025-01-18 10:36:44 +00:00
Add machine.vibrate to vibrate gamepad.
This location is temporary.
This commit is contained in:
parent
8cdf2148ed
commit
dc51203d3e
1 changed files with 21 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
|||
using Capy64.API;
|
||||
using KeraLua;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
@ -43,6 +45,11 @@ public class Machine : IPlugin
|
|||
name = "setRPC",
|
||||
function = L_SetRPC,
|
||||
},
|
||||
new()
|
||||
{
|
||||
name = "vibrate",
|
||||
function = L_Vibrate,
|
||||
},
|
||||
new(),
|
||||
};
|
||||
|
||||
|
@ -122,4 +129,18 @@ public class Machine : IPlugin
|
|||
return 1;
|
||||
}
|
||||
|
||||
private static int L_Vibrate(IntPtr state)
|
||||
{
|
||||
var L = Lua.FromIntPtr(state);
|
||||
|
||||
var left = (float)L.CheckNumber(1);
|
||||
var right = (float)L.OptNumber(2, left);
|
||||
|
||||
left = Math.Clamp(left, 0, 1);
|
||||
right = Math.Clamp(right, 0, 1);
|
||||
|
||||
GamePad.SetVibration(PlayerIndex.One, left, right);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue