Thursday, 08 January 2009
 
  Home arrow Forum  
Main Menu
Home
News
Forum
Documentation
Download
Links
Administrator
Login Form
Welcome, Guest. Please login or register.
January 08, 2009, 07:26:55 AM
Username: Password:
Login with username, password and session length

Forgot your password?
A Keyboard! Finally!
DSLua Community
Welcome, Guest. Please login or register.
January 08, 2009, 07:26:55 AM
1724 Posts in 316 Topics by 10247 Members
Latest Member: Samnmoora
DSLua Community  |  DSLua - Best scripting language for Nintendo DS  |  Examples/Tutorials  |  A Keyboard! Finally! « previous next »
Pages: [1]
Author Topic: A Keyboard! Finally!  (Read 2908 times)
Jeremysr
Waxing Gibbous
****
Posts: 254



WWW
« on: August 31, 2006, 10:11:52 AM »

After a few hours of constant changing around of my messy hard-to-read code I have FINALLY got a touchscreen keyboard working! You will need to require() keyboard.inc.lua in your program to use it in your programs, and put all the files in the zip file into the same directory as keyboard.inc.lua...except for keyboardtest.inc.lua, which is for testing it out. To use the keyboard, just use something like this code:

userinput = keyboard()

after you've require()ed it.If you want it to be a number, use:

userinput = tonumber(keyboard())

although I'm not sure what will happen if they decide to enter letters! Anyway, the keyboard I've included only lets you type the number keys, backspace, and enter key. I will add them, but it might take a while. So...many...coordinates...to enter in Shocked



http://www.bio-gaming.com/jeremy/dslua/index.php?act=keyboard

Edit: Note: the little number "1" that keeps flashing when you enter a button was just for me when I was trying to figure something out, and forgot about it...also, I just found out a little bug, it seems like the first button you type won't work, but everything after that works perfectly..oh, note number 3: when it returns the variable, it will return it with a space before all the other numbers/letters...so if you need to use it to do things like adding and multiplying with it, then you'll have to find some way of removing the space for now.
« Last Edit: September 02, 2006, 01:46:38 AM by Jeremysr » Logged
jeffx
Waxing Crescent
**
Posts: 14

Lua Programmer


« Reply #1 on: August 31, 2006, 05:31:59 PM »

why don't you just use tostring() all the time? not sure I get this. Haven't looked at your code, either.
Logged
Jeremysr
Waxing Gibbous
****
Posts: 254



WWW
« Reply #2 on: August 31, 2006, 05:34:21 PM »

I'm using an array that stores each letter/digit seperately. Then it puts them all together when you hit ENTER, and returns it as a string.
Logged
Jeremysr
Waxing Gibbous
****
Posts: 254



WWW
« Reply #3 on: September 02, 2006, 01:46:13 AM »

Ok, after an ENORMOUS amount of time/boredom, I've entered in the coordinate pairs of every top-left/lower-right corner of every one of the 38 keys! Which means all keys work! I included an example called helloname.lua which shows you how to use the function. The only thing wrong with it is that the first key you try to press won't do anything. But then after that, it'll work fine. I hope to add a cursor, a click sound when you tap a key, and to fix the bug with the first key not doing anything soon.

Edit: Ok, I fixed the bug where the first key struck wouldn't work. I also added the cursor. Grin Now all I want is the sound when you click the buttons. But when I tried playing .raw sound files a few weeks ago, they went REALLY slow...does anyone know if this happens on hardware? I know it doesn't with .mod files....but .raw files went WAY slower.

Page ---> http://www.bio-gaming.com/jeremy/dslua/index.php?act=keyboard
Download ---> http://www.bio-gaming.com/jeremy/dslua/downloads/keyboard0.9.zip
« Last Edit: September 02, 2006, 02:18:48 AM by Jeremysr » Logged
daltonlaffs
Waxing Gibbous
****
Posts: 340


Freaking Insane


WWW
« Reply #4 on: September 02, 2006, 08:38:23 AM »

Aaaactually, yeah. Raw files ARE regular speed on hardware. Let's face it -- emulator + sound = suck.

And NICE PROG!
Logged

Code:
-- Bored? Read code line below.
-- Bored? Read code line above.



^^ That works, I SWEAR! ^^
Jeremysr
Waxing Gibbous
****
Posts: 254



WWW
« Reply #5 on: September 06, 2006, 06:13:08 PM »

I finished keyboard 1.0. It doesn't use the top screen anymore because I found out how to print text on top of background maps. So it echos the text to the touch screen now.

So now it should be very easy to make your programs work with the keyboard, especially if your program only uses the top screen. Smiley

New Screenshot


Download
Keyboard 1.0

Site
Here

Edit: I also added sound effects (click) they don't sound good on Dualis, can someone tell me if they work on hardware? Or which raw file I should have converted them to? Because my sound converter had a-law raw, and u-law raw. Don't know what that means...
Logged
daltonlaffs
Waxing Gibbous
****
Posts: 340


Freaking Insane


WWW
« Reply #6 on: September 06, 2006, 06:28:56 PM »

 Huh It sounds WORSE on hardware   Undecided

Try this:

1. Open one of the raw music files included with DSLua

2. Play the sound on Dualis/hardware.

3. Open the raw with your converter thingy, and try to play it

4. If it doesn't sound right (garbled, too fast, too slow), change the RAW settings (mono, stereo, KHZ)

5. When it sounds right, take note of the working settings, and output your own sounds with the same ones.

Try it!  Grin
Logged

Code:
-- Bored? Read code line below.
-- Bored? Read code line above.



^^ That works, I SWEAR! ^^
daltonlaffs
Waxing Gibbous
****
Posts: 340


Freaking Insane


WWW
« Reply #7 on: September 06, 2006, 06:31:31 PM »

Or just use the blaster.raw file for your key-clicking. I LIKE THAT NOISE!  Cheesy
Logged

Code:
-- Bored? Read code line below.
-- Bored? Read code line above.



^^ That works, I SWEAR! ^^
Jeremysr
Waxing Gibbous
****
Posts: 254



WWW
« Reply #8 on: September 06, 2006, 06:42:16 PM »

Lol, well DSLua should play my audio files right since they play the example ones. But I can't find anything on the internet that plays raw files!
Logged
daltonlaffs
Waxing Gibbous
****
Posts: 340


Freaking Insane


WWW
« Reply #9 on: September 06, 2006, 07:24:13 PM »

Search for Switch. While it SAYS it is a time-limited trial, it seems to last forever.  Huh

And also, I played your number-guess game, and when I got it right (it said higher with 50, lower with 52, I typed 51), it crashed. So I fixed it. Here is MY version of the game. Still works in 1.0, but works right.

* numberguess2.lua (2.08 KB - downloaded 119 times.)
Logged

Code:
-- Bored? Read code line below.
-- Bored? Read code line above.



^^ That works, I SWEAR! ^^
Jeremysr
Waxing Gibbous
****
Posts: 254



WWW
« Reply #10 on: September 06, 2006, 10:51:47 PM »

Thanks, I updated the dowload file with no sound and with your fixed version of number guess. Cheesy
Logged
daltonlaffs
Waxing Gibbous
****
Posts: 340


Freaking Insane


WWW
« Reply #11 on: September 07, 2006, 08:58:49 AM »

One thing you might wanna look into, though... the so-called 'random' number is 70 90% of the time...
Logged

Code:
-- Bored? Read code line below.
-- Bored? Read code line above.



^^ That works, I SWEAR! ^^
Pages: [1]
« previous next »
    Jump to:  



    (C) 2009 DSLua

    DSLua - Best scripting language for Nintendo DS home-brew!