コード例 #1
0
ファイル: driver_windows.go プロジェクト: hajimehoshi/ebiten
func NewPlayer(sampleRate, channelNum, bytesPerSample int) (*Player, error) {
	numBlockAlign := channelNum * bytesPerSample
	f := C.WAVEFORMATEX{
		wFormatTag:      C.WAVE_FORMAT_PCM,
		nChannels:       C.WORD(channelNum),
		nSamplesPerSec:  C.DWORD(sampleRate),
		nAvgBytesPerSec: C.DWORD(sampleRate * numBlockAlign),
		wBitsPerSample:  C.WORD(bytesPerSample * 8),
		nBlockAlign:     C.WORD(numBlockAlign),
	}
	var w C.HWAVEOUT
	if err := C.waveOutOpen(&w, C.WAVE_MAPPER, &f, 0, 0, C.CALLBACK_NULL); err != C.MMSYSERR_NOERROR {
		return nil, fmt.Errorf("driver: waveOutOpen error: %d", err)
	}
	p := &Player{
		out:     w,
		buffer:  []byte{},
		headers: make([]*header, numHeader),
	}
	for i := 0; i < numHeader; i++ {
		var err error
		p.headers[i], err = newHeader(w, bufferSize)
		if err != nil {
			return nil, err
		}
	}
	return p, nil
}
コード例 #2
0
ファイル: hikka.go プロジェクト: DeadNumbers/hikka-x86_64
func checkLogin(ip string, login string, password string, results chan DeviceInfo) bool {
	var device C.NET_DVR_DEVICEINFO

	uid := (int64)(C.NET_DVR_Login(
		C.CString(ip),
		C.WORD(port),
		C.CString(login),
		C.CString(password),
		(*C.NET_DVR_DEVICEINFO)(unsafe.Pointer(&device)),
	))

	if uid >= 0 {
		succ.Printf("Logged in: %s:%s@%s\n", login, password, ip)

		if shoots_path != "" {
			processSnapshots(ip, uid, login, password, device)
		}

		results <- DeviceInfo{
			login,
			password,
			(uint8)(device.byStartChan),
			(uint8)(device.byChanNum),
			CameraAddress{ip, port},
		}

		C.NET_DVR_Logout((C.LONG)(uid))

		return true
	} else {
		return false
	}
}
コード例 #3
0
ファイル: console_win.go プロジェクト: ajbowen249/GoSandbox
// WriteToBuffer writes the given characters and colors to the buffer with the
// given handle.
func WriteToBuffer(handle ScreenBufferHandle, chars [][]rune, colors [][]int) {
	height := len(chars)
	if height == 0 {
		return
	}

	width := len(chars[0])

	charInfoBuffer := make([]C.CHAR_INFO, height*width)
	k := 0
	for i := 0; i < height; i++ {
		for j := 0; j < width; j++ {
			info := C.MakeCharInfo(C.CHAR(chars[i][j]), C.WORD(colors[i][j]))
			charInfoBuffer[k] = info
			k++
		}
	}

	C.WriteToBuffer(handle.handle, C.SHORT(width), C.SHORT(height), &charInfoBuffer[0])
}
コード例 #4
0
ファイル: windows.go プロジェクト: vblazhnov/RemoteControl
	// #include <Winuser.h>
	"C"
	"syscall"
)
import "unsafe"

var (
	user32         = syscall.NewLazyDLL("user32.dll")
	keybdEventInfo = user32.NewProc("SendInput")
)

// for const bellow see https://msdn.microsoft.com/en-us/library/windows/desktop/ms646271(v=vs.85).aspx

// virtual key consts
const (
	vkSpace      = C.WORD(0x20)
	vkLeft       = 0x25
	vkUp         = 0x26
	vkRight      = 0x27
	vkDown       = 0x28
	vkVolumeDown = 0xAE
	vkVolumeUp   = 0xAF
)

// input type consts
const (
	inputTypeKeyboard = C.DWORD(1)
)

// input flags
const (