RSS Reader – Text Input

The program now reflects text input that includes special characters such as !@#$%^&*()`<>?[]:” that was not being handled by the Allegro 5 Game Programming Library (AGLP5). The AGLP5 system detects keyboard actions but only provides a function that tells you the name of the key but not the actual value of the character in most cases. The text character event doesn’t work at all (or may depend on the operating system used or a API setting documented elsewhere). Instead, I detect key presses and translate them into text character values. That was okay but the lack of character translation was not ideal. Despite reservations, I added a function name al_get_char_from_keycode that takes the AGLP5’s keycode from the Key Up/Down events and an indicator if shift or caps lock is active and returns a character.

The current version of the C++ code that has this sequence is available as the 1/21/2018 commit to GitHub. I looked at using Gainput as a drop in substitute for AGLP5’s tracking of keyboard entry but did not like the build approach for Gainput. I prefer libraries that use a single configure script from GNU Autotools when building on Linux. Next, I tried SDL and succeeded in getting SDL (you know, the code library used to make Angry Birds) mixed into the program but quickly realized you couldn’t just use the keyboard part without also initializing the video subsystem. Anyway, I am satisfied with the level of text support in the program now but learned that is a deficiency in AGLP5 that I’ve worked around but merely for the US English alphabet.

The next step with text input is to handle clipping the text within the text field’s display boundaries. I will have to simulate the continued input of text by implementing the appearance text characters on the opposite end of the text field moving away from the text cursor once text exceeds the width of the text field. Also, I need to put in backspace, delete functionality, cursor vertical line placement and a several other little details. Defining a text field from scratch rather than using it as a prepackaged widget reveals much about the qualities of input concepts often taken for granted.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.