• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang evdev.Device类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/jteeuwen/evdev.Device的典型用法代码示例。如果您正苦于以下问题:Golang Device类的具体用法?Golang Device怎么用?Golang Device使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Device类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: listCapabilities

// listCapabilities lists Force feedback capabilities for a given device.
//
// Testing for individual effect types can be done using the
// Device.Supports() method.
func listCapabilities(dev *evdev.Device) {
	// Fetch the force feedback capabilities.
	// The number of simultaneous effects and a
	// bitset describing the type of effects.
	count, caps := dev.ForceFeedbackCaps()

	fmt.Printf("Number of simultaneous effects: %d\n", count)

	for n := 0; n < caps.Len(); n++ {
		if !caps.Test(n) {
			continue
		}

		fmt.Printf(" - Effect 0x%02x: ", n)

		switch n {
		case evdev.FFConstant:
			fmt.Printf("Constant")
		case evdev.FFPeriodic:
			fmt.Printf("Periodic")
		case evdev.FFSpring:
			fmt.Printf("Spring")
		case evdev.FFFriction:
			fmt.Printf("Friction")
		case evdev.FFRumble:
			fmt.Printf("Rumble")
		case evdev.FFDamper:
			fmt.Printf("Damper")
		case evdev.FFRamp:
			fmt.Printf("Ramp")
		}

		fmt.Println()
	}
}
开发者ID:mastercactapus,项目名称:evdev,代码行数:39,代码来源:main.go


示例2: absAxes

// Testing for support of specific axes can be
// done with the `dev.Supports()` method.
func absAxes(dev *evdev.Device) {
	axes := dev.AbsoluteAxes()
	for n := 0; n < axes.Len(); n++ {
		if !axes.Test(n) {
			continue
		}

		fmt.Printf("  Absolute axis 0x%02x ", n)

		switch n {
		case evdev.AbsX:
			fmt.Printf("X Axis: ")
		case evdev.AbsY:
			fmt.Printf("Y Axis: ")
		case evdev.AbsZ:
			fmt.Printf("Z Axis: ")
		default: // More axes types...
			fmt.Printf("Other axis\n")
		}

		// Get axis information.
		abs := dev.AbsoluteInfo(n)
		fmt.Printf("%+v\n", abs)
	}
}
开发者ID:mastercactapus,项目名称:evdev,代码行数:27,代码来源:main.go


示例3: checkDevice

func checkDevice(dev *evdev.Device) (string, bool) {
	if !correctDevice(dev) {
		return "", false
	}

	return dev.Name(), true
}
开发者ID:mikkeloscar,项目名称:lis,代码行数:7,代码来源:input.go


示例4: relAxes

// Testing for support of specific axes can be
// done with the `dev.Supports()` method.
func relAxes(dev *evdev.Device) {
	axes := dev.RelativeAxes()
	for n := 0; n < axes.Len(); n++ {
		if !axes.Test(n) {
			continue
		}

		fmt.Printf("  Relative axis 0x%02x ", n)

		switch n {
		case evdev.RelX:
			fmt.Printf("X Axis: ")
		case evdev.RelY:
			fmt.Printf("Y Axis: ")
		case evdev.RelZ:
			fmt.Printf("Z Axis: ")
		default: // More axes types...
			fmt.Printf("Other axis\n")
		}

		fmt.Println()
	}
}
开发者ID:mastercactapus,项目名称:evdev,代码行数:25,代码来源:main.go


示例5: OpenFLIRC

func OpenFLIRC(grab bool) {
	i := 0
	var dev *evdev.Device
	var err error
	for {
		node := fmt.Sprintf("/dev/input/event%d", i)
		dev, err = evdev.Open(node)
		i++
		if err != nil {
			if os.IsNotExist(err) {
				log.Fatalln("could not find FLIRC device")
			}
			log.Fatalln(err)
		}
		if strings.TrimRight(dev.Name(), "\x00") != FLIRCName {
			dev.Close()
			continue
		}
		break
	}

	if grab && !dev.Grab() {
		log.Warnln("failed to grab device")
	}
	log.Infoln("using device:", strings.TrimRight(dev.Path(), "\x00"))
	for event := range dev.Inbox {
		if event.Type != evdev.EvKeys {
			continue
		}
		if event.Value != 0 {
			continue
		}

		log.Infoln("FLIRC event", event.Code)
		for i, code := range flircMap {
			if int(event.Code) == code {
				setState(i)
				break
			}
		}
	}
}
开发者ID:mastercactapus,项目名称:piusb-switcher,代码行数:42,代码来源:flirc.go


示例6: setEffects

// setEffects creates, uploads and plays a new Force feedback effect.
// This function uploads only 1 effect, but it can deal with
// up to N effects at the same time. Where N is whatever value
// returned from `Device.ForceFeedbackCaps()`.
func setEffects(dev *evdev.Device) {
	_, caps := dev.ForceFeedbackCaps()

	var effect evdev.Effect
	effect.Id = -1
	effect.Trigger.Button = 0
	effect.Trigger.Interval = 0
	effect.Replay.Length = 20000 // 20 seconds
	effect.Replay.Delay = 0

	// Some samples of various effect types.
	// (un)comment any one to try them out. Note that
	// the device must support a given effect type.

	switch {
	case dev.Test(caps, evdev.FFRumble):
		rumble(&effect)
	case dev.Test(caps, evdev.FFPeriodic):
		periodic(&effect)
	case dev.Test(caps, evdev.FFConstant):
		constant(&effect)
	case dev.Test(caps, evdev.FFSpring):
		spring(&effect)
	case dev.Test(caps, evdev.FFDamper):
		damper(&effect)
	}

	// Upload the effect.
	dev.SetEffects(&effect)

	fmt.Printf("Effect id: %d\n", effect.Id)

	// Play the effect.
	dev.PlayEffect(effect.Id)

	// Delete the effect.
	dev.UnsetEffects(&effect)
}
开发者ID:mastercactapus,项目名称:evdev,代码行数:42,代码来源:main.go


示例7: correctDevice

// check if device is a keyboard, mouse or touchpad.
func correctDevice(dev *evdev.Device) bool {
	// check if device is a keyboard
	if dev.Test(dev.EventTypes(), evdev.EvSync, evdev.EvKeys, evdev.EvMisc, evdev.EvLed, evdev.EvRepeat) {
		return true
	}

	// check if device is a mouse
	if dev.Test(dev.EventTypes(), evdev.EvSync, evdev.EvKeys, evdev.EvRelative, evdev.EvMisc) {
		return true
	}

	// check if device is a touchpad
	if dev.Test(dev.EventTypes(), evdev.EvSync, evdev.EvKeys, evdev.EvAbsolute) {
		return true
	}

	return false
}
开发者ID:mikkeloscar,项目名称:lis,代码行数:19,代码来源:input.go



注:本文中的github.com/jteeuwen/evdev.Device类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang glfw.CloseWindow函数代码示例发布时间:2022-05-23
下一篇:
Golang parser.AST类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap