mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
internal/gamepad: cast returning values to uint32
This commit is contained in:
parent
532b476c4e
commit
124f233de0
@ -221,7 +221,7 @@ func setWindowLongPtrW(hWnd uintptr, nIndex int32, dwNewLong uintptr) (uintptr,
|
||||
type directInputError uint32
|
||||
|
||||
func (d directInputError) Error() string {
|
||||
return fmt.Sprintf("DirectInput error: %d", d)
|
||||
return fmt.Sprintf("DirectInput error: HRESULT(%d)", d)
|
||||
}
|
||||
|
||||
type _DIDATAFORMAT struct {
|
||||
@ -339,7 +339,7 @@ func (d *iDirectInput8W) CreateDevice(rguid *windows.GUID, lplpDirectInputDevice
|
||||
uintptr(unsafe.Pointer(rguid)), uintptr(unsafe.Pointer(lplpDirectInputDevice)), uintptr(pUnkOuter),
|
||||
0, 0)
|
||||
if uint32(r) != _DI_OK {
|
||||
return fmt.Errorf("gamepad: IDirectInput8::CreateDevice failed: %w", directInputError(syscall.Errno(r)))
|
||||
return fmt.Errorf("gamepad: IDirectInput8::CreateDevice failed: %w", directInputError(r))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -350,7 +350,7 @@ func (d *iDirectInput8W) EnumDevices(dwDevType uint32, lpCallback uintptr, pvRef
|
||||
uintptr(dwDevType), lpCallback, uintptr(pvRef), uintptr(dwFlags),
|
||||
0)
|
||||
if uint32(r) != _DI_OK {
|
||||
return fmt.Errorf("gamepad: IDirectInput8::EnumDevices failed: %w", directInputError(syscall.Errno(r)))
|
||||
return fmt.Errorf("gamepad: IDirectInput8::EnumDevices failed: %w", directInputError(r))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -398,7 +398,7 @@ type iDirectInputDevice8W_Vtbl struct {
|
||||
func (d *iDirectInputDevice8W) Acquire() error {
|
||||
r, _, _ := syscall.Syscall(d.vtbl.Acquire, 1, uintptr(unsafe.Pointer(d)), 0, 0)
|
||||
if uint32(r) != _DI_OK && uint32(r) != _SI_FALSE {
|
||||
return fmt.Errorf("gamepad: IDirectInputDevice8::Acquire failed: %w", directInputError(syscall.Errno(r)))
|
||||
return fmt.Errorf("gamepad: IDirectInputDevice8::Acquire failed: %w", directInputError(r))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -409,7 +409,7 @@ func (d *iDirectInputDevice8W) EnumObjects(lpCallback uintptr, pvRef unsafe.Poin
|
||||
lpCallback, uintptr(pvRef), uintptr(dwFlags),
|
||||
0, 0)
|
||||
if uint32(r) != _DI_OK {
|
||||
return fmt.Errorf("gamepad: IDirectInputDevice8::EnumObjects failed: %w", directInputError(syscall.Errno(r)))
|
||||
return fmt.Errorf("gamepad: IDirectInputDevice8::EnumObjects failed: %w", directInputError(r))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -417,7 +417,7 @@ func (d *iDirectInputDevice8W) EnumObjects(lpCallback uintptr, pvRef unsafe.Poin
|
||||
func (d *iDirectInputDevice8W) GetCapabilities(lpDIDevCaps *_DIDEVCAPS) error {
|
||||
r, _, _ := syscall.Syscall(d.vtbl.GetCapabilities, 2, uintptr(unsafe.Pointer(d)), uintptr(unsafe.Pointer(lpDIDevCaps)), 0)
|
||||
if uint32(r) != _DI_OK {
|
||||
return fmt.Errorf("gamepad: IDirectInputDevice8::GetCapabilities failed: %w", directInputError(syscall.Errno(r)))
|
||||
return fmt.Errorf("gamepad: IDirectInputDevice8::GetCapabilities failed: %w", directInputError(r))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -425,7 +425,7 @@ func (d *iDirectInputDevice8W) GetCapabilities(lpDIDevCaps *_DIDEVCAPS) error {
|
||||
func (d *iDirectInputDevice8W) GetDeviceState(cbData uint32, lpvData unsafe.Pointer) error {
|
||||
r, _, _ := syscall.Syscall(d.vtbl.GetDeviceState, 3, uintptr(unsafe.Pointer(d)), uintptr(cbData), uintptr(lpvData))
|
||||
if uint32(r) != _DI_OK {
|
||||
return fmt.Errorf("gamepad: IDirectInputDevice8::GetDeviceState failed: %w", directInputError(syscall.Errno(r)))
|
||||
return fmt.Errorf("gamepad: IDirectInputDevice8::GetDeviceState failed: %w", directInputError(r))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -433,7 +433,7 @@ func (d *iDirectInputDevice8W) GetDeviceState(cbData uint32, lpvData unsafe.Poin
|
||||
func (d *iDirectInputDevice8W) Poll() error {
|
||||
r, _, _ := syscall.Syscall(d.vtbl.Poll, 1, uintptr(unsafe.Pointer(d)), 0, 0)
|
||||
if uint32(r) != _DI_OK && uint32(r) != _DI_NOEFFECT {
|
||||
return fmt.Errorf("gamepad: IDirectInputDevice8::Poll failed: %w", directInputError(syscall.Errno(r)))
|
||||
return fmt.Errorf("gamepad: IDirectInputDevice8::Poll failed: %w", directInputError(r))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -446,7 +446,7 @@ func (d *iDirectInputDevice8W) Release() uint32 {
|
||||
func (d *iDirectInputDevice8W) SetDataFormat(lpdf *_DIDATAFORMAT) error {
|
||||
r, _, _ := syscall.Syscall(d.vtbl.SetDataFormat, 2, uintptr(unsafe.Pointer(d)), uintptr(unsafe.Pointer(lpdf)), 0)
|
||||
if uint32(r) != _DI_OK {
|
||||
return fmt.Errorf("gamepad: IDirectInputDevice8::SetDataFormat failed: %w", directInputError(syscall.Errno(r)))
|
||||
return fmt.Errorf("gamepad: IDirectInputDevice8::SetDataFormat failed: %w", directInputError(r))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -454,7 +454,7 @@ func (d *iDirectInputDevice8W) SetDataFormat(lpdf *_DIDATAFORMAT) error {
|
||||
func (d *iDirectInputDevice8W) SetProperty(rguidProp uintptr, pdiph *_DIPROPHEADER) error {
|
||||
r, _, _ := syscall.Syscall(d.vtbl.SetProperty, 3, uintptr(unsafe.Pointer(d)), rguidProp, uintptr(unsafe.Pointer(pdiph)))
|
||||
if uint32(r) != _DI_OK && uint32(r) != _DI_PROPNOEFFECT {
|
||||
return fmt.Errorf("gamepad: IDirectInputDevice8::SetProperty failed: %w", directInputError(syscall.Errno(r)))
|
||||
return fmt.Errorf("gamepad: IDirectInputDevice8::SetProperty failed: %w", directInputError(r))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -197,25 +197,27 @@ func (g *nativeGamepads) directInput8Create(hinst uintptr, dwVersion uint32, rii
|
||||
r, _, _ := syscall.Syscall6(g.procDirectInput8Create, 5,
|
||||
hinst, uintptr(dwVersion), uintptr(unsafe.Pointer(riidltf)), uintptr(unsafe.Pointer(ppvOut)), uintptr(punkOuter),
|
||||
0)
|
||||
if r != _DI_OK {
|
||||
return fmt.Errorf("gamepad: DirectInput8Create failed: %w", directInputError(syscall.Errno(r)))
|
||||
if uint32(r) != _DI_OK {
|
||||
return fmt.Errorf("gamepad: DirectInput8Create failed: %w", directInputError(r))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *nativeGamepads) xinputGetCapabilities(dwUserIndex uint32, dwFlags uint32, pCapabilities *xinputCapabilities) error {
|
||||
// XInputGetCapabilities doesn't call SetLastError and returns an error code directly.
|
||||
r, _, _ := syscall.Syscall(g.procXInputGetCapabilities, 3,
|
||||
uintptr(dwUserIndex), uintptr(dwFlags), uintptr(unsafe.Pointer(pCapabilities)))
|
||||
if e := syscall.Errno(r); e != windows.ERROR_SUCCESS {
|
||||
if e := syscall.Errno(uint32(r)); e != windows.ERROR_SUCCESS {
|
||||
return fmt.Errorf("gamepad: XInputGetCapabilities failed: %w", e)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *nativeGamepads) xinputGetState(dwUserIndex uint32, pState *xinputState) error {
|
||||
// XInputGetState doesn't call SetLastError and returns an error code directly.
|
||||
r, _, _ := syscall.Syscall(g.procXInputGetState, 2,
|
||||
uintptr(dwUserIndex), uintptr(unsafe.Pointer(pState)), 0)
|
||||
if e := syscall.Errno(r); e != windows.ERROR_SUCCESS {
|
||||
if e := syscall.Errno(uint32(r)); e != windows.ERROR_SUCCESS {
|
||||
return fmt.Errorf("gamepad: XInputGetCapabilities failed: %w", e)
|
||||
}
|
||||
return nil
|
||||
|
Loading…
Reference in New Issue
Block a user