jessedewaard
Posts: 8
Joined: Sat Sep 01, 2012 10:07 pm

How to get key input in OpenVG

Fri Oct 26, 2012 8:14 pm

I want jus to make a simple test program to write text in a circle.
But i can't find any simple way to read the keys pressed while not being in the terminal.
Scanf and getchar won't do the trick cause they bring me back to the terminal(i want to stay in my vg program).

So how can i draw the text am inputing on my keyboard?

bryancole
Posts: 9
Joined: Sun Jun 10, 2012 7:47 am

Re: How to get key input in OpenVG

Mon Oct 29, 2012 1:19 pm

You can simply read bytes from the keyboard device file (/dev/input/keyboard or something like that - I don't have my rpi to hand to check). You need a key-map to convert the keyboard key code to a letter/symbol. As to drawing text, you need to calculate some paths for each glyph you want to render. The freetype library is useful for this. It can load a ttf font file and get outlines for each glyph (you want "decompose_glyph"). You create a VG Path for each outline and (optionally) store it in a VG Font object. Then render the paths as necessary. All in all, rendering text is a complicated task to do well.

This might be useful: http://mindchunk.blogspot.co.uk/2012/09 ... ry-pi.html
And also: https://github.com/ajstarks/openvg
And if you're using python: https://bitbucket.org/bryancole/rpi_vid ... at=default

Return to “OpenVG”