Creating a touch screen driver for OS X: where to start? - c

OK, so I recently purchased an Acer T232HL touch screen display to hook up to my Macbook Pro as a secondary monitor. To give you an idea, here's my setup.
OS X doesn't support this monitor in any way, so as you can see in the screenshot I'm actually running Windows 8 through VMware, which proxies the USB connection to Windows perfectly where the touch events are supported. But obviously this isn't ideal.
There's at least one 3rd party driver for OS X that looked sort of promising, but it doesn't seem to support multitouch from this device, it's expensive, and generally was a pain to get working to the small degree it was. There's also mt4j but best I could tell after running their examples, it doesn't support this device at all.
So here's my question: what exactly am I in for if I wanted to write a driver for this thing? I'm mostly a web developer with years of experience with Ruby, Objective-C (and a little C), Javascript, etc. I have never ventured into any kind of hardware programming, so from the surface this feels like an interesting while intimidating challenge.
I know at some level I need to read data from USB. I know this will probably mean trying to reverse engineer whatever protocol they're using for the touch events (is it possible this will be entirely custom?). However I haven't got a clue where to start - would this be a kernel extension? In C, I presume? Would love a high level overview of the moving parts involved here.
Ultimately I want to use the touch screen to drive a specialized web interface (running in Chrome), so ideally I could proxy the touch events straight to Chrome without the OS actually moving the mouse cursor to the touch location (so have the UI behave just as it would on an iPad), but regardless of whether this is technically possible, I'd love to start with just getting something working.

You're going to want to start with Apple's I/O Kit documentation. You can hope that the touchscreen isn't completely custom, though there must be some part that's not standard USB HID, or it would work already. If there are any linux (or other open source) drivers available, you'll have the advantage that somebody already did some of the reverse engineering for you. As an alternative to the I/O Kit, you might also want to look into libusb, which might make your brain hurt less when getting started. If you end up needing to write a kext, that might not help you anymore, though.
As to some of your specific questions:
would this be a kernel extension?
Maybe, maybe not. I'm not really up on the Mac OS X driver situation, but I did write some totally user-space USB code for OS X many years ago. Maybe you'll be as lucky.
In C, I presume?
Probably. I/O Kit itself is written in a subset of C++, so you can probably use that too, if you prefer.
is it possible this will be entirely custom?
Unfortunately, yes, it's possible.
Good luck!

Related

How to directly access the display for drawing

Context
I've been programming mainly as a hobby for some time now, mostly in C# and Java. I made many application (Windows Forms or Java Forms) that required animated content. In Java I would use Graphics.drawX() and redraw in function of time. When the animations were happening frequently the resolution would diminish or the application would slow down. I never gave it thought until I played a video game on the same computer that had so much trouble rendering a simple Java app. How can my computer instantly render a complex moving environment but rush a displaying a home-made 2048 game? I figured it must be because either I am misusing the draw functions, either because those functions are not optized for real-time render.
Question :
How can I directly access the display without having to go through preprogrammed functions?
I realize this maybe hard in higher level languages so let's say in C on a Windows OS. (But I would appreciate any answer relating to any language and/or OS)
I know it's a really vague question but I can't seem to find the right words to Google it appropriatly. Thank you very much for your help!
You can't (or maybe I should say should never) try to access the graphics driver directly on Windows. You used to have write directly to video memory to do graphics prior to Windows as DOS did not support graphics or display management and the stability of those programs were always a bit dicey. On Windows, it owns the screen and you have to work through it to access it.
The very concept of a Windows-based OS is that the OS owns the display and gives application access to a virtual display so that the OS can hide it or move it around. In most cases this does not cause a speed problem; but, in certain cases like gaming you need more speed; so, DirectX allows you tor transfer some of those task to the graphics card to get you the speed you need.
For more info on DirectX, check out Microsoft's Graphics and Gaming Resources

Searching for a method to get Wireless Access Point information programmatically

I've been investigating a way of tracking a device's location in a building, at first I was intending to use iBeacons. However I have been since told that it must be done by monitoring access points and looking for the MAC address of that device.
I can't seem to find any generic sort of library or API that can hook into an access point and give me details. Infact I don't even know where to start looking which is making it even harder.
Has anybody had dealings with this and could point me in the right direction? Any programming language acceptable.
I have written software from scratch to do exactly this, but to my knowledge, no frameworks are available.
The basic steps are:
Get a number of small, low-cost computers (Raspberry Pis work nicely) to act as sensors that do WiFi scanning in promiscuous mode, collecting unique macs and detection times. On Linux, you can use C or Java software to collect these records.
Write the info from the sensors to a server, including the sensor identifier so you know where each device was detected.
Write lots of code to crunch the numbers.
You should be aware of three big issues:
Mobile devices aren't always detectable on WiFi. If they are asleep, or simply not communicating, you will not detect them. On iOS the best you can hope for is detections every minute or so if the device is not locked and not actively using WiFi.
On iOS 8+, mac addresses are scrambled under certain conditions,boften making it impossible to track unique devices.
Building the above from scratch is a lot of work. Think several man months for even a basic system.
I know you were asked to build it this way and not with beacons, but beacons do provide a much simpler path forward if you can ensure an app on each device and can revisit this design constraint.
I suggest you to do this with iBeacons.
But :
On IOS 8 , when u try in anyway to get mac adress from a device , you obtain this value : 02:00:00:00:00:00.
The best way to get an unique identifier for a device is to use the identifierForVendor method form UIDevice.
Like this :
UIDevice *device = [[UIDevice alloc]init];
NSString *uniqueIdForDevice= [NSString stringWithFormat:#"%#", [device identifierForVendor]];
NSLog(#"%#",uniqueIdForDevice);
That gives you an ID that's unique for that device for your company.
I hope this can help you.
I'm not sure what the constraints are on your particular design but there are existing systems that allow you to get the kind of monitoring I think you're looking for. As davidgyoung writes, there are a few technical challenges that exist at OS level that will be present in whatever wi-fi solution to choose (e.g. iOS MAC address rotation). That aside, you might get some value from looking at solutions from Wi-fi hardware manufacturers like Cisco: https://meraki.cisco.com/solutions/cmx . They have a pre-built platform for visitor data (i.e. showing you where phones are in buildings/spaces). I think all the major wi-fi hardware manufacturers have something similar now and Cisco are likely to be top-end. From memory, Aruba were much cheaper (I'm going back ~10 months).
There are also software providers like Euclid Analytics ( http://euclidanalytics.com ) who build on top of the hardware and API's of providers like Cisco to provide visitor info like I think you want.
This isn't an exhaustive list as I'm writing this from memory but hopefully a bit of Googling based on the above should give you a better chance of success than rolling your own.
Good luck,
James
If you want to do indoor location services, then I would recommend checking out Cisco Connected Mobile Experience software.
You can try it free.
Based on my analysis, it is the best solution out there. I am biased because I work there. But, I do competitive analysis and have yet to find anything I think works better.

Writing a driver to fool Linux systems about having a GPU

I'm into something about writing a "Mock GPU driver" for Linux based systems. What I mean is that, simply I want to write a driver (Behind X-server obviously) to answer X's API calls with some debugging messages.
In other words I want to fool Linux about having an actual GPU. So I can make a test-bed for GUI-accelerated packages in console based systems.
Right now, if I execute a GUI-accelerated package in Linux console based systems; it'll simply dies due to lack of a real GPU (or a GPU driver better I'd say).
So I want to know:
Is it even possible? (Writing a GPU driver to fool Linux about having an actual GPU)
What resources do you recommend before getting my hands dirty in code?
Is there any similar projects around the net?
PS: I'm an experienced ANSI-C programmer but I don't have any clue in real Kernel/Driver development under *nix (read some tutorials about USB driver development though), so any resources about these areas will be really appreciated as well. Thanks in advance.
What you are looking for is actually part of Xorg server suite, and it is called Xvfb (virtual framebuffer).
If you're not afraid of a bit complex bash, you can take a look at Gentoo's virtualx.eclass for an use example (we use it to run tests which require X11).
A good place to start is the Mesa project - it implements OpenGL in software. It has a way to trick the OS into thinking that it is the OpenGL driver.

Developing IN an iPod touch

I am thinking about buying an iPod touch and I Wonder if there is Java and c++ editor to install in the iPod, something like having netbeans in the IPod. I want this because I would like to advance in my home-works on my way college-home while I'm on the bus or waiting for someone, etc. Is there anything?
Don't even consider trying to write code on an iPod, or even an iPad.
iPod is the wrong type of device for any sort of development. There are some ergonomic factors which are really important when it comes to writing code:
You should have a decent keyboard - i-devices only have touch-screens. A laptop keyboard is OK but not great.
You need the screen at a reasonable height and angle if you're going to be looking at it for a long time. You need to be able to type with both hands at the same time.
You need as much screen space as you can get.
I could come up with a lot more reasons for not using an i-device for development, but I think they are too obvious to bother listing.
If you really want to do your homework on the bus, you are better off getting yourself a decent laptop.
The iTunes App Store restrictions explicitly prohibit any compilers or interpreters from running on approved iOS apps.
That said, you could make a simple Javascript interpreter in a webpage, and then save it for offline use, without much trouble.
For that matter, any language that's implemented in Javascript and can work in an offline webpage could be used. For example, if you had a compiler written in Javascript, which compiled C++ to Javascript, then you could use that to write C++ on your iPod. I do not know of any such compilers offhand, but there's no theoretical reason they couldn't exist, as the App Store restrictions don't apply to HTML pages you browse to yourself.
A far more practical solution would be to just get a text editor (of which the App Store has many). Write your code on the bus, and then compile it when you get home. It will still be faster than the compilers we had when I was a kid!
(Or just get an SRS and spend the time studying rather than programming, since you're not going to be very effective at programming on a small touchscreen device, anyway.)
There's always an option to jailbreak your device and install GCC toolchain: iphone-gcc in Cydia and instruction here. Netbook would be a much better option though.
You can do some basic HTML and Latex but no Java or C++.
But I found something that could be interesting:
Processing is quite like Java and can be programmed on this site, with every iDevice.
http://jepstone.net/HiperPad/editor.php/HiPad4d113f1595b4c#home

What's the smallest device I can program on?

I'm thinking of something smaller than a laptop that i can spend my hours on the way to work doing project euler problems or such.
Any ideas?
If you mean a programming platform, you could get a netbook like the ASUS EEE.
Or if you meant smallest programmable device, check out a PIC microcontroller:
http://en.wikipedia.org/wiki/PIC_microcontroller
This may sound crazy but try pen/pencil and paper. No you can't run the code but it'll help you to not use online references so much (yes they are good but memory skills help us all) and it'll probably also help you plan your code better.
I've programmed directly on my HP 48G series calculator.
There's a good programming tutorial for it here. I'll have to dust it off and see if it will pass Project Euler's one-minute rule.
If you are looking for a microcontroller or similar my advice to you would be to check out either an AVR, PIC, Arduino, or BeagleBoard.
All are relatively cheap and easy to program (the first three more so). AVR's and PIC's are types of microcontrollers that you can program with C or ASM, however you will need some type of prototyping board or similar to achieve anything. An Arduino is an AVR chip sitting on a board, so it is much easier to achieve something in a small amount of time. In addition to this they are quite popular and you can find many projects that have been done at Hackaday. Lastly BeagleBoard is a much gruntier board that will run embedded linux.
My recommendation is for the Arduino.
There are many more suggestions here.
However, If you are looking for a small laptop device to program you have plenty of options. An Asus EEE pc, HP 2133 (I believe thats the correct model), MSI Wind, MacBook Air etc etc. As other people have suggested check out some netbooks. There are also various PDA's or mobile phones that you could program, such as an Android phone or an OpenMoko phone. There are plenty of options, I suggest you find out what size you are looking for specifically and that will narrow down your choices.
Good Luck.
I'll take the reputation hit to say this: why not read a book or watch the scenery go by? Trying to cram more programming into your day isn't actually good for you, and may even make you less productive.
I have used SmallBASIC on my Palm OS 5 device for a while now, and it seems to work well with most of the problems I throw at it.
How about using a Palm with the OnboardC compiler?
A netbook would be ideal.
A graphing calculator might be too limited for programming.
If you're talking about doing a microcontroller, there are several models of arduino boards that are very easy for someone not familiar with embedded programming.
I have a Nokia E51 with python interpreter. It's not pleasant to type with a numeric keypad at all. I think it is as small as you can get.
I have a Samsung i760 running Windows Mobile 6. The slide-out keyboard is fantastic (best mini-keyboard on any device) - I can type on it almost as fast as a normal keyboard. I mainly use it to write Oracle Lite queries in mSQL, which is borderline unusable with any other PDA keyboard.
This question led me to wonder about real programming environments for this device, so I asked another question, and one of the answers was a link to this, which is a Windows Mobile IDE for creating .NET Windows Mobile applications. You write them in C#, even.
Netbooks are smaller than your typical laptop and have plenty of power.
It's pretty subjective. I code on my commute using a 15.4" laptop and I find it quite limiting.
I could still work at 13", but the limitations would be getting so large I'd already be questioning if it's worth it. Anything smaller would be right out.
But then I tend to work with lots of windows open. Multiple editors, docs, browsers etc. Cutting back on that eats into my productivity. At home I have a 30" display. At work I have 2x 24" displays.
If you tend to work mostly in one window, rarely consult docs and other apps etc, you could probably go smaller.
It depends so much on the type of person you are, what you are comfortable with, the way you work, what you are working in and with... the list goes on.
My guess is that for most developers 13" is going to be the smallest before it gets so frustrating that you're better off just listening to podcasts or something - but YMMV - and will!

Resources