在触控板上检测手指的绝对位置 [英] Detecting absolute finger positions on trackpad

查看:100
本文介绍了在触控板上检测手指的绝对位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 13 MacBook Pro(型号7,1。2010年中) a>,我最近安装了Ubuntu 12.04 LTS,基本上我想做的是制作一个程序,当用户单击Mac触控板的右下角时,该程序会调用右键菜单。

I'm on a 13" MacBook Pro (model 7,1. Mid-2010) and I recently installed Ubuntu 12.04 LTS. Essentially what I'm trying to do is make a program that invokes the right-click menu when a user clicks the bottom right corner of the Mac trackpad.

这里的主要问题是检测用户在触控板上的确切位置。当然,在OSX中使用 NSTouch

The main issue here is detecting where exactly the user's position on the trackpad is. Of course, this is rather easy to do in OSX using NSTouch:

- (void)touchesBeganWithEvent:(NSEvent *)event {
    NSSet *touches = [event touchesMatchingPhase:NSTouchPhaseBegan inView:self];
    for(NSTouch *touch in touches) {
        NSPoint normalizedPosition = touch.normalizedPosition;

        //points inside `normalizedPosition`
        //top center: (.5, 1), bottom left: (1, 0)
    }
}

但是,问题出在在Ubuntu中也是一样(老实说,任何编程语言都可以)。现在,我看过类似,但是,因为我已经想出了如何在OSX中执行此操作,所以我认为这个问题并不重要。我也看过帖子,但是,我并不是在寻找通用的,是检测手指绝对位置的标准化方法。老实说,我很高兴让Ubuntu在Mac制造的触控板上仅检测手指位置。也看到了 AskUbuntu的帖子,但回答者(虽然他做了一个很好的总结)似乎是更通用的说法。

However, the issue is doing the same thing within Ubuntu (any programming language is fine to be honest). Now, I've seen posts like this, however, because I've already figured out how to do it within OSX, I don't see this question as relevant. I've also seen this post, however, I'm not looking for a universal, standardized way to detect absolute finger position. Honestly, I'd be happy to get Ubuntu detecting finger positions only for Mac-made trackpads. Saw this AskUbuntu post also, but the answerer (while he does a great summary) seems to be speaking more universal-wise.

有人会知道如何获得 normalizedPosition 属性吗? Ubuntu中的 NSTouch (或在Ubuntu上编译的编程语言)?

Would anyone know how to get something like the normalizedPosition attribute on the NSTouch within Ubuntu (or a programming language which compiles on Ubuntu)?

推荐答案

您可以使用 mtdev 库。从 evtest 开始,找出来自的输入设备和信息。所需的输入设备,然后使用mtdev库从C进行访问。

You can do this with the mtdev library. Start off with evtest to figure out what input device and information from the input device you need, then use the mtdev library to access it from C.

另一个很棒的库可以完成我最初想要做的事情(即在(可以调用右键菜单的触控板)是 mtrack 库(保存一些工作)。如果想要遍历代码,它也提供了一些示例,可以从mtdev访问信息。

Another great library to do what I was originally trying to do (i.e., create a zone on the trackpad which would invoke a right-click menu up) is the mtrack library (to save some work). It also has examples for accessing information from mtdev if you want to go hunting through the code.

这篇关于在触控板上检测手指的绝对位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆