internal/cbackend: add EbitenVibrateGamepad

Updates #1452
This commit is contained in:
Hajime Hoshi 2022-01-26 03:32:49 +09:00
parent fb3a022327
commit 11d01f4de1
2 changed files with 7 additions and 0 deletions

View File

@ -49,6 +49,7 @@ package cbackend
// void EbitenGetGamepads(struct Gamepad* gamepads);
// int EbitenGetTouchNum();
// void EbitenGetTouches(struct Touch* touches);
// void EbitenVibrateGamepad(int id, double durationInSeconds, double strongMagnitude, double weakMagnitude);
//
// // Audio
// typedef void (*OnReadCallback)(float* buf, size_t length);
@ -63,6 +64,7 @@ import "C"
import (
"reflect"
"time"
"unsafe"
"github.com/hajimehoshi/ebiten/v2/internal/driver"
@ -159,6 +161,10 @@ func AppendTouches(touches []Touch) []Touch {
return touches
}
func VibrateGamepad(id driver.GamepadID, duration time.Duration, strongMagnitude float64, weakMagnitude float64) {
C.EbitenVibrateGamepad(C.int(id), C.double(float64(duration)/float64(time.Second)), C.double(strongMagnitude), C.double(weakMagnitude))
}
var onReadCallback func(buf []float32)
func OpenAudio(sampleRate, channelNum int, onRead func(buf []float32)) {

View File

@ -264,6 +264,7 @@ func (i *Input) TouchPosition(id driver.TouchID) (x, y int) {
}
func (i *Input) VibrateGamepad(id driver.GamepadID, duration time.Duration, strongMagnitude float64, weakMagnitude float64) {
cbackend.VibrateGamepad(id, duration, strongMagnitude, weakMagnitude)
}
func (i *Input) Wheel() (xoff, yoff float64) {