noir.pl
Still Fresh
I've just had an idea about text entry on gp2x.
Forgive me that the description will be very brief but it's 02:30 and I'm tired.
Here it is:
* joystick selects character bank (central bank accessed via joystick push)
* "ABXY" keys insert letters
* "L" key exits text entry
* "R" key inserts most probable letter (based on dictionary)
Below you will find small app in python (requires TK) to test this idea on PC.
Feel free to change the config section and experiment with different layouts...
hell... feel free to do anything with this code
BTW. Functionality of "R" key is not yet implemented... I'll do this later tomo^H^Hday.
Forgive me that the description will be very brief but it's 02:30 and I'm tired.
Here it is:
* joystick selects character bank (central bank accessed via joystick push)
* "ABXY" keys insert letters
* "L" key exits text entry
* "R" key inserts most probable letter (based on dictionary)
Below you will find small app in python (requires TK) to test this idea on PC.
Feel free to change the config section and experiment with different layouts...
hell... feel free to do anything with this code
BTW. Functionality of "R" key is not yet implemented... I'll do this later tomo^H^Hday.
Code:
#!/usr/bin/python
# gp2x text entry prototype v1
# by noir.pl -> mobarski AT gmail DOT com
#=======================================================================
# config
bank_keys = "qweasdzxc"
char_keys = "1235"
bank_text = (
" ", "abc ", "def ",
"ghi ", "jkl ", "mno ",
"pqrs", "tuv ", "wxyz",
)
#=======================================================================
from Tkinter import *
import sys
root = Tk()
info = []
active_bank = 0
root.unbind_class("Text", "<Return>")
root.unbind_class("Text", "<Any-KeyPress>")
root.unbind_class("Text", "<Any-KeyRelease>")
text = Text(root, width=40, height=20)
text.grid(columnspan=9)
def select_bank(bank):
global active_bank, info
info[active_bank].tag_config("all", foreground="black")
info[bank].tag_config("all", foreground="red")
active_bank = bank
def on_bank_key(char):
bank = bank_keys.find(char)
select_bank(bank)
def on_char_key(char):
i = char_keys.find(char)
c = bank_text[active_bank][i]
text.insert(END, c)
sys.stdout.write(c)
def on_key(event):
k = event.char
if k in bank_keys:
on_bank_key(k)
elif k in char_keys:
on_char_key(k)
def create_info():
global info
i = 0
for b in bank_text:
t = Text(root, width=3, height=2)
info += [t]
t.grid(row=1+i/3, column=3+i%3)
tags = ("bank%d"%i,"all")
t.insert(END, " %s " % b[3], tags)
t.insert(END, "%s%s%s" % (b[0], b[1], b[2]), tags)
i += 1
create_info()
select_bank(4)
text.insert(END, "select bank with keys: " + bank_keys + "\n")
text.insert(END, "enter text with keys: " + char_keys + " from num pad\n\n\n")
text.bind("<Key>", on_key)
text.focus_set()
root.mainloop()