mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
internal/gamepad: bug fix: go-vet failed (misuse of unsafe.Pointer)
Updates #1452
This commit is contained in:
parent
580307f150
commit
a049c403cf
@ -204,7 +204,7 @@ func (g *nativeGamepad) hatState(hat int) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (g *nativeGamepads) init() {
|
func (g *nativeGamepads) init() {
|
||||||
var dicts []unsafe.Pointer
|
var dicts []C.CFDictionaryRef
|
||||||
|
|
||||||
page := C.kHIDPage_GenericDesktop
|
page := C.kHIDPage_GenericDesktop
|
||||||
for _, usage := range []uint{
|
for _, usage := range []uint{
|
||||||
@ -224,25 +224,30 @@ func (g *nativeGamepads) init() {
|
|||||||
}
|
}
|
||||||
defer C.CFRelease(C.CFTypeRef(usageRef))
|
defer C.CFRelease(C.CFTypeRef(usageRef))
|
||||||
|
|
||||||
keys := []unsafe.Pointer{
|
keys := []C.CFStringRef{
|
||||||
unsafe.Pointer(C.cfStringRefIOHIDDeviceUsagePageKey()),
|
C.cfStringRefIOHIDDeviceUsagePageKey(),
|
||||||
unsafe.Pointer(C.cfStringRefIOHIDDeviceUsageKey()),
|
C.cfStringRefIOHIDDeviceUsageKey(),
|
||||||
}
|
}
|
||||||
values := []unsafe.Pointer{
|
values := []C.CFNumberRef{
|
||||||
unsafe.Pointer(pageRef),
|
pageRef,
|
||||||
unsafe.Pointer(usageRef),
|
usageRef,
|
||||||
}
|
}
|
||||||
|
|
||||||
dict := C.CFDictionaryCreate(C.kCFAllocatorDefault, &keys[0], &values[0], C.CFIndex(len(keys)), &C.kCFTypeDictionaryKeyCallBacks, &C.kCFTypeDictionaryValueCallBacks)
|
dict := C.CFDictionaryCreate(C.kCFAllocatorDefault,
|
||||||
|
(*unsafe.Pointer)(unsafe.Pointer(&keys[0])),
|
||||||
|
(*unsafe.Pointer)(unsafe.Pointer(&values[0])),
|
||||||
|
C.CFIndex(len(keys)), &C.kCFTypeDictionaryKeyCallBacks, &C.kCFTypeDictionaryValueCallBacks)
|
||||||
if dict == 0 {
|
if dict == 0 {
|
||||||
panic("gamepad: CFDictionaryCreate returned nil")
|
panic("gamepad: CFDictionaryCreate returned nil")
|
||||||
}
|
}
|
||||||
defer C.CFRelease(C.CFTypeRef(unsafe.Pointer(dict)))
|
defer C.CFRelease(C.CFTypeRef(dict))
|
||||||
|
|
||||||
dicts = append(dicts, unsafe.Pointer(dict))
|
dicts = append(dicts, dict)
|
||||||
}
|
}
|
||||||
|
|
||||||
matching := C.CFArrayCreate(C.kCFAllocatorDefault, &dicts[0], C.CFIndex(len(dicts)), &C.kCFTypeArrayCallBacks)
|
matching := C.CFArrayCreate(C.kCFAllocatorDefault,
|
||||||
|
(*unsafe.Pointer)(unsafe.Pointer(&dicts[0])),
|
||||||
|
C.CFIndex(len(dicts)), &C.kCFTypeArrayCallBacks)
|
||||||
if matching == 0 {
|
if matching == 0 {
|
||||||
panic("gamepad: CFArrayCreateMutable returned nil")
|
panic("gamepad: CFArrayCreateMutable returned nil")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user