Emulating Danzeff's Keyboard for LuaPlayerHM
Danzeff Lua Keyboard is a virtual keyboard to let you write easily some text on screen in your Lua Homebrews. It might be useful for simple text writing, but not as a full text editor.
Tapping R or L triggers cycling through the 4 (four) sets of characters supported.
- Set 1: Lowercase Alphabetic letters
- Set 2: Uppercase Alphabetic letters
- Set 3: Numbers
- Set 4: Special characters
Move Analog to select a block of character. Any block is composed of 4 characters matching with 4 buttons on your Sony's PSP.
Tap Triangle or Square or Cross or Circle button to input the desired character.
Select enables or disables the keyboard
First, include the library itself by copying the OSK folder in your Homebrew.
Then load the library in your program using loadfile or require or dofile command.
require './OSK/osk'
loadfile './OSK/osk.lua'
dofile './OSK/osk.lua'In your main application, out of the main loop, create a new keyboard and init it with the X & Y coordinates corresponding to where you want to place your input.
myKeyboard= OSK:New()
myKeyboard:Init(myX,myY)Now declare a string where you want to hold the inputted text.
myText = ''In the main Loop, read a characted from the keyboard input using osk:Input().You must have declared a pad and an oldpad variables before.
local char = osk:Input(pad,oldpad)
if char then
if char=='del' then
text = string.sub(text,1,-2)
else text = text..char
end
endNote: When you hit del on the keyboard, it returns string 'del'. You'll have to deal with that issue as shown in the previous code to withdraw the last written character.
Now print your text using osk:Print()
osk:Print(text)This last command draws the Virtual keyboard.
osk:Draw(pad,oldpad) The usage is pretty simple as you see. Just refers to the given example for more details.
- Danzel & Jeff for pics, and the original keyboard
- Homemister for LuaPlayerHM
- Devsgen & XtreamLua Communities members
This software is MIT-Licensed.
Copyright (c) 2012 Roland Yonaba.