![]() ![]() Identifier is stored in it or to allocate it to an empty member if bothĪn empty member exists and the system identifier is not present in the Thisįunction (called GetContactIndex) is able to return theĪppropriate index to the identifier storage array if the system The original MSDN code has a function for returning a usable indexįor system identifiers for each of the touch points on the screen. This function makes a random colour value for the circle ![]() It was easy to do and the code is nice and concise: One advantage of this is that it is that unlike the MSDN code there won't be a problem if the value of MAXPOINTS is increased. I plonked this function in near the top of the Multitouch.cpp file. Instead of prescribing the colours to be used in a array with ten fixed values I wrote a function to supply random colour values for the touch points.I give more details about how the statefulness is preserved later. For the raw MSDN code (or as near as you can get to it) the statefulness stops once ten touch points have been placed on the screen. It seemed tidier to me to do it this way. Instead of using separate arrays for storing the system touch point ID idLookup and the two dimensional points arrays I have put all of this information plus the colour (that's British spelling in case your wondering) information into an array ( circlesArray) of type circle.Other differences between my code and the MSDN code are:. I've added in some global variables for status reporting purposes - touchCount and cycleCount. can be stored and retreived for the touch points. State information (ie colour of the circle) #include // included for point conversion These check that things are all tickety boo regarding the software environment. The first step described in the article is to put some lines into the project's targetver.h file. cpp file and add some code to the InitInstance and WndProc functions which will have been generated already by the wizard. ![]() The next task is to add some global variables and a global function to main. The MSDN article explains how to do this using the Visual Studio project wizard tool. For the second edition of the article I have changed the code so that touch points being held on the screen will keep their state no matter what is happening at other touch points. In the first edition of this article, the sample application would change the colour of a circle held on the screen depending on what was happening at other touch points. Of particular interest to me, since I am hoping to implement multi touch functionality in my own custom control at some point in the future, was to find a clear and reliable way to achieve statefulness of the touch points. Once I got the MSDN article code to run I made changes to it to improve its stability by removing memory leaks and making changes to the way touch point information is stored. My aim, therefore, in writing up this commentary (that is quite closely based on the MSDN article) is to hopefully provide a smoother start for other people wanting to get going with multi touch. It was quite hard for me going through the article and applying the fixes Tom1omT and duggulous had given and then finding one or two other things that still needed fixing. So we play with it and worry at it until we find out what can be changed to make it more satisfying and/or usable. The code works and demonstrates what it is supposed to but there are a few more things to do to it before it is ready to used in another project. We open up a project and copy and paste the code in. Guys like me come and want to find out how they work. I guess there is educational value in these articles being a bit rough around the edges. So - I have started looking at implementing multi touch for my custom control and searching for ways I could do this and the first real progress I have made is based on the MSDN article at. Experimenting with multi touch, however, seemed like a dream for the distant future until about a week ago when I was able to get my first touch screen laptop computer (a Toshiba C55T-10K - on a substantial discount!). I have been working on a custom control for ages now - one which, for a long time now, I have known could benefit from having a multi touch interface. Watch this YouTube video to see what this program does. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |