예제 #1
0
func (device Device) GetPredefinedGuidAndPathProperty(
	prop, obj, how int,
) (
	guid GUID,
	path string,
	err error,
) {
	var cProp C.DIPROPGUIDANDPATH
	cProp.diph.dwSize = C.sizeof_DIPROPGUIDANDPATH
	cProp.diph.dwHeaderSize = C.sizeof_DIPROPHEADER
	cProp.diph.dwObj = C.DWORD(obj)
	cProp.diph.dwHow = C.DWORD(how)
	err = toGetPropError(C.IDirectInputDevice8GetPredefinedProperty(
		device.handle,
		unsafe.Pointer(uintptr(prop)),
		&cProp.diph,
	))
	guid.fromC(&cProp.guidClass)
	var buf [maxPath]uint16
	length := 0
	for ; length < maxPath; length++ {
		buf[length] = uint16(cProp.wszPath[length])
		if cProp.wszPath[length] == 0 {
			break
		}
	}
	path = syscall.UTF16ToString(buf[:length])
	return
}
예제 #2
0
func (device Device) GetPredefinedStringProperty(
	prop, obj, how int,
) (
	value string,
	err error,
) {
	var cProp C.DIPROPSTRING
	cProp.diph.dwSize = C.sizeof_DIPROPSTRING
	cProp.diph.dwHeaderSize = C.sizeof_DIPROPHEADER
	cProp.diph.dwObj = C.DWORD(obj)
	cProp.diph.dwHow = C.DWORD(how)
	err = toGetPropError(C.IDirectInputDevice8GetPredefinedProperty(
		device.handle,
		unsafe.Pointer(uintptr(prop)),
		&cProp.diph,
	))
	var buf [maxPath]uint16
	length := 0
	for ; length < maxPath; length++ {
		buf[length] = uint16(cProp.wsz[length])
		if cProp.wsz[length] == 0 {
			break
		}
	}
	value = syscall.UTF16ToString(buf[:length])
	return
}
예제 #3
0
func (device Device) GetPredefinedRangeProperty(
	prop, obj, how int,
) (
	min, max int,
	err error,
) {
	var cProp C.DIPROPRANGE
	cProp.diph.dwSize = C.sizeof_DIPROPRANGE
	cProp.diph.dwHeaderSize = C.sizeof_DIPROPHEADER
	cProp.diph.dwObj = C.DWORD(obj)
	cProp.diph.dwHow = C.DWORD(how)
	err = toGetPropError(C.IDirectInputDevice8GetPredefinedProperty(
		device.handle,
		unsafe.Pointer(uintptr(prop)),
		&cProp.diph,
	))
	min, max = int(cProp.lMin), int(cProp.lMax)
	return
}
예제 #4
0
func (device Device) GetPredefinedPointerProperty(
	prop, obj, how int,
) (
	value uintptr,
	err error,
) {
	var cProp C.DIPROPPOINTER
	cProp.diph.dwSize = C.sizeof_DIPROPPOINTER
	cProp.diph.dwHeaderSize = C.sizeof_DIPROPHEADER
	cProp.diph.dwObj = C.DWORD(obj)
	cProp.diph.dwHow = C.DWORD(how)
	err = toGetPropError(C.IDirectInputDevice8GetPredefinedProperty(
		device.handle,
		unsafe.Pointer(uintptr(prop)),
		&cProp.diph,
	))
	value = uintptr(cProp.uData)
	return
}