mobile phone keyboard

  • Thread starter Tomasz \Boruh\ Borowiak
  • Start date
T

Tomasz \Boruh\ Borowiak

Does anybody have any idea how to write a c++ console application which
simulates the mobile phone keyboard ?
for Example: when i write SMS
I hit 2 - I get "a"
I hit 22 - I get "b"
I hit 222 - I get "C";
Please help.

thanks for all replays
boruh
skype: Flyboruh
 
L

lallous

Tomasz "Boruh" Borowiak @interia.pl> said:
Does anybody have any idea how to write a c++ console application which
simulates the mobile phone keyboard ?
for Example: when i write SMS
I hit 2 - I get "a"
I hit 22 - I get "b"
I hit 222 - I get "C";
Please help.

thanks for all replays
boruh
skype: Flyboruh

Hello

Well, you can define the phone-keyboard-to-ascii-mapping as:

std::map<int> m;
int lasthitcounter = 0;
m[2]="abc";
m[3]="def";
m[4] = .... etc...

Now whenever you encounter a key press you increase the counter if the
keypress is the same as the old one (make sure you rotate the count if it
exceeds the strlen(m[keypress]), else you display
m[keypressNo][lasthitcounter] etc....

That's just a hint on how you can do it...

Hope that helps,
Elias
 
H

Howard

lallous said:
Tomasz "Boruh" Borowiak @interia.pl> said:
Does anybody have any idea how to write a c++ console application which
simulates the mobile phone keyboard ?
for Example: when i write SMS
I hit 2 - I get "a"
I hit 22 - I get "b"
I hit 222 - I get "C";
Please help.

thanks for all replays
boruh
skype: Flyboruh
Eh?

Hello

Well, you can define the phone-keyboard-to-ascii-mapping as:

std::map<int> m;
int lasthitcounter = 0;
m[2]="abc";
m[3]="def";
m[4] = .... etc...

Now whenever you encounter a key press you increase the counter if the
keypress is the same as the old one (make sure you rotate the count if it
exceeds the strlen(m[keypress]), else you display
m[keypressNo][lasthitcounter] etc....

That's just a hint on how you can do it...

Hope that helps,
Elias

That won't help much if you want to be able to enter letters from the same
numeric key, such as 'a' and then 'b'. You need a way to tell when you're
done with a specific entry.

I don't know about your cell phone, but mine has a timer of some sort that
waits to see if I'm going to hit the same key a second (or third or fourth)
time.

One way would be to query the system time when a keypress is detected.
Then, loop, until either a key is pressed or a certain amount of time has
passed. If a *different* key is pressed, or if the allotted time has passed,
save the current value you want and prepare to receive the next one (or do
whatever other actions you need, such as dialing if the user hits Enter).
If the *same* key is pressed and the time has not expired, then increment
your current value (i.e., from 'a' to 'b'), and if it's not at the limit of
presses for that key, then re-enter the loop to check for more hits.
(Otherwise, since more hits are not legal, treat it as if the counter has
expired and move on.)

Interrupt-driven events are another possibility.

BUT!....

The problem here is that there is no way in standard C++ to check for
keypresses! The streaming mechanisms wait for the user to press the
Enter/Return key before the data becomes visible via the stream. (Likewise,
interrupts are not part of standard C++.)

To accomplish the task, you'll need to use some operating-specific
extensions of your compiler. For details on how to do that, check on a
newsgroup devoted to your platform (e.g., windows, unix, mac), or for your
compiler (e.g., vc++).

-Howard
 
T

Tomasz \Boruh\ Borowiak

That's just a hint on how you can do it...
Hope that helps,
Elias

thanks for help

new idea new project :)

when i finish i send you my source code
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top