Question

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.

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)
    }
}

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.

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

Was it helpful?

Solution

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top