Closed niluan304 closed 2 years ago
Hey!
I don't see the difference between the two pictures. A C struct is used because we call a C function provided by VIGem, and thus we have to use its struct definition to ensure the layout we use is the same as what VIGem expects.
Hey!
I don't see the difference between the two pictures. A C struct is used because we call a C function provided by VIGem, and thus we have to use its struct definition to ensure the layout we use is the same as what VIGem expects.
Thank you for your answer.
So, maybe C function provided by VIGem can’t parse the go struct?
About the two pictures, they are .gif
file.
I mean that
I want the virtual xbox to do the following in order :
Send ThumbRY 32767 (R Stick Up)
Send ThumbRX 32767 (R Stick Right)
Send ThumbRY -32767 (R Stick Down)
Send ThumbRX -32767 (R Stick Left)
when I use go struct, the order is incorrect, the virtual xbox work:
About the two pictures, they are .gif file.
Ah, indeed, they only play once when opening the page so I missed the animation.
I want the virtual xbox to do the following in order
Ah so you're using the Go library, not the .exe
?
when I use go struct, the order is incorrect, the virtual xbox work
So you're using Xbox360ControllerReport
with the Go API rather than C.xusb_report
directly? Without seeing more code it will be hard for my to troubleshoot it. Given how weird the actual results are, I'm guessing that the report isn't actually compatible with VIGem (are you sure that you configured VIGem for the X360 controller?) or that some data race is happening.
I've never seen CGO before, so I'm curious.
the report isn't actually compatible with VIGem
I have learned a lot from it. Thank you very much.
In fact, I added a method to the GO library, And my code:
// the GO struct I use
type GoReport struct {
WButtons uint16
SThumbRX int16
SThumbRY int16
SThumbLX int16
SThumbLY int16
BRightTrigger uint8
BLeftTrigger uint8
}
func (c *Xbox360Controller) SendGoStruct(report *Xbox360ControllerReport) error {
goReport := GoReport{
WButtons: uint16(report.native.wButtons),
SThumbRX: int16(report.native.sThumbRX),
SThumbRY: int16(report.native.sThumbRY),
SThumbLX: int16(report.native.sThumbLX),
SThumbLY: int16(report.native.sThumbLY),
BRightTrigger: uint8(report.native.bRightTrigger),
BLeftTrigger: uint8(report.native.bLeftTrigger),
}
libErr, _, err := procTargetX360Update.Call(c.emulator.handle, c.handle, uintptr(unsafe.Pointer(&goReport)))
// ...
return nil
}
I ask for the stupid question, In the
Send(report *Xbox360ControllerReport) method
,report.native
is C struct, why not use go struct?yeah, I try to use go struct, but fail.
I want the virtual xbox to work like this:
And I get :
I'm confused, I'd appreciate it if I could get some advice.