Skip to main content

Posts

Showing posts with the label touch

Detect whether browser has keyboard/arrow keys in web page

I have a full-screen game in HTML+JavaScript, which uses the arrow keys as primary controls. This cannot be used on keyboardless Android devices (I haven't tested on iOS), and even if the soft keyboard had arrow keys it would take up unnecessary space. Therefore, I have added onscreen control buttons. However, the buttons are unnecessary (and absurdly large) on desktop browsers, so I would like them to not pop up unless they are needed. What heuristics can I use to decide whether they are needed — that is, whether it is impossible or awkward for the user to input arrow-key events — other than recognizing specific User-Agents (which is straightforward, but not future-proof)? I will of course allow the user to hide/show the buttons; I am looking for useful heuristics for choosing the default setting. Source: Tips4all

How does the iPhone Google image search touch-event functionality work?

When I do a Google image search on my iPhone within the Safari mobile browser, it gives me this beautiful interface for flipping through the images. If I swipe left or right, it browses through the images. If I touch and move up or down, I get what appears to be the native Safari scroll function. Can anyone explain how Google does this? I'm only beginning to learn the Safari API for touch events. It seems like either you capture the touch event to attach handlers to swipe left or right or you let Safari handle the touch events natively, in which case you get the beautiful native Safari scrolling. Can anyone explain how Google captures left/right swipe but not scrolling?

iPhone opengl es: Touch detection

I have been messing around with opengl es on the iphone and right now I have some cubes on the screen. Currently I am trying to detect touches on these cubes. After a lot of searching on google this is what I have so far Use gluUnProject to find the x,y cordinates on the near plane in the world cordinate system Use gluUnProject to find the x,y cordinates on the far plane in the world cordinate system Subtract the vector obtained in 2 from the vector obtained in 1 to obtain the direction vector Normalize the direction vector to obtain the unit vector Iterate through all the trianlges and use the ray-triangle intersection to check if the ray intersects this triangle I think my mistake is in step 5. I have a feeling I am supposed to transform my triangles by the modelview matrix? Is my assumption correct? If yes any clues how to transform a triangle (an array of 3 floats) by the modelview matrix (an array of 16 floats)