WiiLi Wiki frontpage Include your post in the News Get links Hoteles Quito
WiiLi.org Forum Index WiiLi.org
a new revolution
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Script: Switching between scripts + typing by moving wiimote

 
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Scripts
View previous topic :: View next topic  
Author Message
runarius



Joined: 17 Jan 2007
Posts: 12

Digg It
PostPosted: Thu Jan 18, 2007 1:34 pm    Post subject: Script: Switching between scripts + typing by moving wiimote

This is a nice little script I wrote which lets you switch between multiple scripts by pressing B+plus+minus on the wiimote for switching to the next script and b+plus+A for switching to the previous one. Each script have their own number and the wiimote's leds shows which script is active. This is great if you want to use your wiimote for moving the mouse around, but then disabling the mouse when you are watching a movie. you just switch to another mode, and you have have full control over the movie. you can now press pause, rewind and everything.

Also I have included a script for typing in letters and stuff by moving the wiimote around. This works great for writing small ammounts of text. It works sort of like typing on a cellular phone. you tilt the wiimote forward and to the left for the 1 key, forward and to the middle for 2, forward and to the right for 3, and for 4 you don't tilt it(hold it straight) and then roll it to the left and so on. just like in a cellular phone, when you press 3 once, you get 'd'. on the wiimote you hold it in 2-position and press A once you get 'd', press it twice; 'e' and so on. Hope you all understand all this. Dot can be found at position 1, space and enter is at position 10, or(* as on cellular phones). for this positon you must tilt the wiimote backwards alot, almost vertically and to the left. Caps lock is at postition 12, or (#)This feels a little wierd for the first five minutes, but now, I can write kinda fast by this method. Hope you all will enjoy my script.

Mode zero in this script is a script for controlling movies and winamp. Not finished and not working to well since I discontinued it.

Mode one is a script for controlling the mouse which I stole from GlovePIE and edited a little bit. For leftmousepress, press A, for right mousepress, press A+B.

Mode two is the mentioned script for typing.

here is the code for the changemode-script with three scripts inside: mousecontroller by motion, partially mediacontroller, script for writing letters by motion.

Code:
var.modes = 2

if wiimote.B and wiimote.Minus and wiimote.Plus
var.currentMode = var.currentMode +1
                if var.currentMode > var.modes
                var.currentMode = 0
                endif

wait 300 ms
endif

if wiimote.B and wiimote.A and wiimote.Plus
var.currentMode = var.currentMode -1
                if var.currentMode < 0
                var.currentMOde = var.modes
                endif

wait 300 ms
endif

if var.currentMode = 2
var.p1H = -20
var.p1L = -60
var.p2L = -19
var.p2H = 20
var.p3L = 21
var.p3H = 50
var.p4L = 51
var.p4H = 90

var.r1H = -21
var.r1L = -60
var.r2L = -20
var.r2H = 20
var.r3L = 21
var.r3H = 60



if wiimote.pitch > var.p1L and wiimote.pitch < var.p1H
var.pitch = 1
elseif wiimote.pitch > var.p2L and wiimote.pitch < var.p2H
var.pitch = 4
elseif wiimote.pitch > var.p3L and wiimote.pitch < var.p3H
var.pitch = 7
elseif wiimote.pitch > var.p4L and wiimote.pitch < var.p4H
var.pitch = 10
endif

if wiimote.roll > var.r1L and wiimote.roll < var.r1H
var.roll = 0
elseif wiimote.roll > var.r2L and wiimote.roll < var.r2H
var.roll = 1
elseif wiimote.roll > var.r3L and wiimote.roll < var.r3H
var.roll = 2
endif

var.num = var.roll+var.pitch

if wiimote.A
if var.pressed = false
var.lastNum = var.num
var.pressed = true
var.presses = var.presses +1
var.pressTimeOut = 40
if var.lastNum = 1
if var.presses = 1
var.letter = '.'
elseif var.presses = 2
var.letter = ','
elseif var.presses = 3
var.letter = '?'
elseif var.presses = 4
var.letter = '('
elseif var.presses = 5
var.letter = ')'
elseif var.presses > 5
var.presses = 1
var.letter = '.'
endif
endif
if var.lastNum = 2
if var.presses = 1
var.letter = 'a'
elseif var.presses = 2
var.letter = 'b'
elseif var.presses = 3
var.letter = 'c'
elseif var.presses = 4
var.letter = 'å'
elseif var.presses > 4
var.presses = 1
var.letter = 'a'
endif
endif
if var.lastNum = 3
if var.presses = 1
var.letter = 'd'
elseif var.presses = 2
var.letter = 'e'
elseif var.presses = 3
var.letter = 'f'
elseif var.presses > 3
var.presses = 1
var.letter = 'd'
endif
endif
if var.lastNum = 4
if var.presses = 1
var.letter = 'g'
elseif var.presses = 2
var.letter = 'h'
elseif var.presses = 3
var.letter = 'i'
elseif var.presses > 3
var.presses = 1
var.letter = 'g'
endif
endif
if var.lastNum = 5
if var.presses = 1
var.letter = 'j'
elseif var.presses = 2
var.letter = 'k'
elseif var.presses = 3
var.letter = 'l'
elseif var.presses > 3
var.presses = 1
var.letter = 'j'
endif
endif
if var.lastNum = 6
if var.presses = 1
var.letter = 'm'
elseif var.presses = 2
var.letter = 'n'
elseif var.presses = 3
var.letter = 'o'
elseif var.presses > 3
var.presses = 1
var.letter = 'm'
endif
endif
if var.lastNum = 7
if var.presses = 1
var.letter = 'p'
elseif var.presses = 2
var.letter = 'q'
elseif var.presses = 3
var.letter = 'r'
elseif var.presses = 4
var.letter = 's'
elseif var.presses > 4
var.presses = 1
var.letter = 'p'
endif
endif
if var.lastNum = 8
if var.presses = 1
var.letter = 't'
elseif var.presses = 2
var.letter = 'u'
elseif var.presses = 3
var.letter = 'v'
elseif var.presses > 3
var.presses = 1
var.letter = 't'
endif
endif
if var.lastNum = 9
if var.presses = 1
var.letter = 'w'
elseif var.presses = 2
var.letter = 'x'
elseif var.presses = 3
var.letter = 'y'
elseif var.presses = 4
var.letter = 'z'
elseif var.presses > 4
var.presses = 1
var.letter = 'w'
endif
endif
if var.lastNum = 10
if var.presses = 1
var.letter = 'Space'
elseif var.presses = 2
var.letter = 'Enter'
elseif var.presses > 2
var.presses = 1
var.letter = 'Space'
endif
endif
if var.lastNum = 11
if var.presses = 1
var.letter = ''
elseif var.presses = 2
var.letter = ''
elseif var.presses > 2
var.presses = 1
var.letter = ''
endif
endif
if var.lastNum = 12
if var.presses = 1
var.letter = 'Caps Lock'
elseif var.presses > 1
var.presses = 1
var.letter = 'Caps Lock'
endif
endif
endif
else
var.pressed = false
endif

if var.pressTimeOut > 0
var.pressTimeOut = var.pressTimeOut-1
endif

if var.lastNum != var.num or var.pressTimeOut <= 0
if var.presses > 0

if var.letter = 'Space'
key.Space = true
key.Space = false
elseif var.letter = 'Enter'
key.Enter = true
key.enter = false
elseif var.letter = 'Caps Lock'
key.CapsLock = true
key.capslock = false
else
Type(var.letter)
endif
var.presses = 0
var.lastNum = false
endif
endif

if wiimote.Minus
if var.minusPressed != true
var.minusPressed = true
key.backspace = true
key.backspace = false
endif
else
var.minusPressed = false
endif






debug = var.letter +'    ;  ' +var.num +';     '+ var.lastNum +';   '+wiimote.pitch+';'+wiimote.roll
endif

if var.currentMode = 1
var.mouseWaitTime = 200
if wiimote.Up
Up = true
Wait 200 ms
Up = false
endif
if wiimote.Down
Down = true
Wait 200 ms
Down = false
endif
if wiimote.Left
Left = true
Wait 200 ms
Left = false
endif
if wiimote.Right
Right = true
Wait 200 ms
Right = false
endif

if wiimote.A and wiimote.B then
   Mouse.RightButton = true
   wait var.mouseWaitTime ms
   Mouse.RightButton = false
endif

if wiimote.A then
   Mouse.LeftButton = true
   wait var.mouseWaitTime ms
   Mouse.LeftButton = false
endif


//If the mouse reaches the end, rumble for 200 milliseconds
if mouse.x = 0 or mouse.x = 1 or mouse.y = 0 or mouse.y = 1 then
if var.rmbl = false
wiimote.Rumble = 1
wait 200 ms
wiimote.Rumble = 0
endif
var.rmbl = true
else
var.rmbl = false
endif

//****Everything past here deals with mouse movement*****

// set these to the offsets when the wiimote is at rest
// will be different for each wiimote most likely
var.x = Wiimote.RawForceX + var.trimx //trim to 0
var.y = Wiimote.RawForceY + var.trimy // trim to 0
var.z = Wiimote.RawForceZ + var.trimz //trim to 0

//precision
var.sense0 = 500
var.thresh0x = 5
var.thresh0y = 2

var.sense = 300
var.threshx = 10
var.threshy = 5

var.sense2 = 100
var.thresh2x = 15
var.thresh2y = 8

var.sense3 = 50
var.thresh3x = 20
var.thresh3y = 12

//first sensitivity setting
//xaxis
if var.x > var.thresh0x
mouse.x = mouse.x - 1/var.sense0
endif
if var.x < -var.thresh0x
mouse.x = mouse.x + 1/var.sense0
endif

//yaxis
if var.z > var.thresh0y
mouse.y = mouse.y - 1/var.sense0
endif
if var.z < -var.thresh0y
mouse.y = mouse.y + 1/var.sense0
endif


//second sensitivity setting
//xaxis
if var.x > var.threshx
mouse.x = mouse.x - 1/var.sense
endif
if var.x < -var.threshx
mouse.x = mouse.x + 1/var.sense
endif

//yaxis
if var.z > var.threshy
mouse.y = mouse.y - 1/var.sense
endif
if var.z < -var.threshy
mouse.y = mouse.y + 1/var.sense
endif

//third sensitivity setting
//xaxis
if var.x > var.thresh2x
mouse.x = mouse.x - 1/var.sense2
endif
if var.x < -var.thresh2x
mouse.x = mouse.x + 1/var.sense2
endif

//yaxis
if var.z > var.thresh2y
mouse.y = mouse.y - 1/var.sense2
endif
if var.z < -var.thresh2y
mouse.y = mouse.y + 1/var.sense2
endif

//fourth sensitivity setting
//xaxis
if var.x > var.thresh3x
mouse.x = mouse.x - 1/var.sense3
endif
if var.x < -var.thresh3x
mouse.x = mouse.x + 1/var.sense3
endif

//yaxis
if var.z > var.thresh3y
mouse.y = mouse.y - 1/var.sense3
endif
if var.z < -var.thresh3y
mouse.y = mouse.y + 1/var.sense3
endif

endif

if var.currentMode = 0
var.waitTime = 2
Ctrl+Shift+Alt+M = wiimote.Down and wiimote.B
Ctrl+Shift+Alt+B = wiimote.Left and !wiimote.B
Ctrl+Shift+Alt+V = wiimote.A and wiimote.B
Ctrl+Shift+Alt+C = wiimote.Up and !wiimote.B
Ctrl+Shift+Alt+X = wiimote.Down and !wiimote.B
Ctrl+Shift+Alt+Z = wiimote.Up and wiimote.B

if wiimote.Two then
   Key.Alt+Key.Enter = true
   wait var.waitTime ms
   Key.Alt+Key.Enter = false
endif

if wiimote.A then
   Play/Pause = true
   wait var.waitTime ms
   Play/Pause = false
endif

endif

debug = var.currentMode
Wiimote.Leds = var.currentMode


<---- 1. script: changemode-script with mousecontroller by motion, partially mediacontroller and my typing-script by motion.



here is the script for the modechanging part only, without any other scripts+ instructions for how to add scripts.

Code:

// change this value to the number of scripts you have minus one.
// example: if you have three scripts, you write two here.
// to add scripts, look a little bit longer down.
var.modes = 1

// change the first line here two what button-combination you want to press
// to change to the NEXT script(mode)
if wiimote.B and wiimote.Minus and wiimote.Plus
var.currentMode = var.currentMode +1
                if var.currentMode > var.modes
                var.currentMode = 0
                endif

wait 300 ms
endif

// change the first line here two what button-combination you want to press
// to change to the PREVIOUES script(mode)
if wiimote.B and wiimote.A and wiimote.Plus
var.currentMode = var.currentMode -1
                if var.currentMode < 0
                var.currentMOde = var.modes
                endif

wait 300 ms
endif

if var.currentMode = 0
//copy and paste the first here.

elseif var.currentMode = 1
//copy and pastre the second script here.

//to add more scripts, just add 'elseif var.currentMode = 2' without the quotations
// and simply increase the number by one for each script.
endif

debug = var.currentMode
Wiimote.Leds = var.currentMode

<--- second script: changemode-script only

and this is the code for the typing script:



Code:
var.p1H = -20
var.p1L = -60
var.p2L = -19
var.p2H = 20
var.p3L = 21
var.p3H = 50
var.p4L = 51
var.p4H = 90

var.r1H = -21
var.r1L = -60
var.r2L = -20
var.r2H = 20
var.r3L = 21
var.r3H = 60



if wiimote.pitch > var.p1L and wiimote.pitch < var.p1H
var.pitch = 1
elseif wiimote.pitch > var.p2L and wiimote.pitch < var.p2H
var.pitch = 4
elseif wiimote.pitch > var.p3L and wiimote.pitch < var.p3H
var.pitch = 7
elseif wiimote.pitch > var.p4L and wiimote.pitch < var.p4H
var.pitch = 10
endif

if wiimote.roll > var.r1L and wiimote.roll < var.r1H
var.roll = 0
elseif wiimote.roll > var.r2L and wiimote.roll < var.r2H
var.roll = 1
elseif wiimote.roll > var.r3L and wiimote.roll < var.r3H
var.roll = 2
endif

var.num = var.roll+var.pitch

if wiimote.A
if var.pressed = false
var.lastNum = var.num
var.pressed = true
var.presses = var.presses +1
var.pressTimeOut = 40
if var.lastNum = 1
if var.presses = 1
var.letter = '.'
elseif var.presses = 2
var.letter = ','
elseif var.presses = 3
var.letter = '?'
elseif var.presses = 4
var.letter = '('
elseif var.presses = 5
var.letter = ')'
elseif var.presses > 5
var.presses = 1
var.letter = '.'
endif
endif
if var.lastNum = 2
if var.presses = 1
var.letter = 'a'
elseif var.presses = 2
var.letter = 'b'
elseif var.presses = 3
var.letter = 'c'
elseif var.presses = 4
var.letter = 'å'
elseif var.presses > 4
var.presses = 1
var.letter = 'a'
endif
endif
if var.lastNum = 3
if var.presses = 1
var.letter = 'd'
elseif var.presses = 2
var.letter = 'e'
elseif var.presses = 3
var.letter = 'f'
elseif var.presses > 3
var.presses = 1
var.letter = 'd'
endif
endif
if var.lastNum = 4
if var.presses = 1
var.letter = 'g'
elseif var.presses = 2
var.letter = 'h'
elseif var.presses = 3
var.letter = 'i'
elseif var.presses > 3
var.presses = 1
var.letter = 'g'
endif
endif
if var.lastNum = 5
if var.presses = 1
var.letter = 'j'
elseif var.presses = 2
var.letter = 'k'
elseif var.presses = 3
var.letter = 'l'
elseif var.presses > 3
var.presses = 1
var.letter = 'j'
endif
endif
if var.lastNum = 6
if var.presses = 1
var.letter = 'm'
elseif var.presses = 2
var.letter = 'n'
elseif var.presses = 3
var.letter = 'o'
elseif var.presses > 3
var.presses = 1
var.letter = 'm'
endif
endif
if var.lastNum = 7
if var.presses = 1
var.letter = 'p'
elseif var.presses = 2
var.letter = 'q'
elseif var.presses = 3
var.letter = 'r'
elseif var.presses = 4
var.letter = 's'
elseif var.presses > 4
var.presses = 1
var.letter = 'p'
endif
endif
if var.lastNum = 8
if var.presses = 1
var.letter = 't'
elseif var.presses = 2
var.letter = 'u'
elseif var.presses = 3
var.letter = 'v'
elseif var.presses > 3
var.presses = 1
var.letter = 't'
endif
endif
if var.lastNum = 9
if var.presses = 1
var.letter = 'w'
elseif var.presses = 2
var.letter = 'x'
elseif var.presses = 3
var.letter = 'y'
elseif var.presses = 4
var.letter = 'z'
elseif var.presses > 4
var.presses = 1
var.letter = 'w'
endif
endif
if var.lastNum = 10
if var.presses = 1
var.letter = 'Space'
elseif var.presses = 2
var.letter = 'Enter'
elseif var.presses > 2
var.presses = 1
var.letter = 'Space'
endif
endif
if var.lastNum = 11
if var.presses = 1
var.letter = ''
elseif var.presses = 2
var.letter = ''
elseif var.presses > 2
var.presses = 1
var.letter = ''
endif
endif
if var.lastNum = 12
if var.presses = 1
var.letter = 'Caps Lock'
elseif var.presses > 1
var.presses = 1
var.letter = 'Caps Lock'
endif
endif
endif
else
var.pressed = false
endif

if var.pressTimeOut > 0
var.pressTimeOut = var.pressTimeOut-1
endif

if var.lastNum != var.num or var.pressTimeOut <= 0
if var.presses > 0

if var.letter = 'Space'
key.Space = true
key.Space = false
elseif var.letter = 'Enter'
key.Enter = true
key.enter = false
elseif var.letter = 'Caps Lock'
key.CapsLock = true
key.capslock = false
else
Type(var.letter)
endif
var.presses = 0
var.lastNum = false
endif
endif

if wiimote.Minus
if var.minusPressed != true
var.minusPressed = true
key.backspace = true
key.backspace = false
endif
else
var.minusPressed = false
endif






debug = var.letter +'    ;  ' +var.num +';     '+ var.lastNum +';   '+wiimote.pitch+';'+wiimote.roll

<--- 3.script: script for typing letters by motion.


Last edited by runarius on Thu Jan 18, 2007 11:23 pm; edited 1 time in total
Back to top
View user's profile Send private message
deceased
Site Admin


Joined: 11 Dec 2006
Posts: 287
Location: Aurora, ON

Digg It
PostPosted: Thu Jan 18, 2007 2:54 pm    Post subject:

Neat. Wish I could test it.
_________________
-deceased-

Wiili - a gnu revolution
Back to top
View user's profile Send private message
kunalkunal2



Joined: 13 Dec 2006
Posts: 279

Digg It
PostPosted: Fri Jan 19, 2007 12:32 am    Post subject:

WOW..... (That looked like alot of time to make though)
But, Nice Script
_________________
Check out my collection of my wii script's
freewebs.com/kunalkunal2
Back to top
View user's profile Send private message
runarius



Joined: 17 Jan 2007
Posts: 12

Digg It
PostPosted: Fri Jan 19, 2007 4:59 pm    Post subject:

no, it didn't take alot time actuall... (note that there is more than one script there, so it isn't really that big) and that I stole the biggest and most time-consuming script, the mousecontroller. I made the mode-switching in about 30 minutes or something. The typing script took me five-six hours or something. So, could I get some feedback please?
Back to top
View user's profile Send private message
diegostuff



Joined: 09 Jan 2007
Posts: 7

Digg It
PostPosted: Sat Jan 20, 2007 5:36 am    Post subject:

Back to top
View user's profile Send private message
runarius



Joined: 17 Jan 2007
Posts: 12

Digg It
PostPosted: Sat Jan 20, 2007 9:12 am    Post subject:

ah, yeah, that's great! didn't mean to ripp you off or anything, I didn't know that anybody had written a script like that before. anybody who has made a script-switcher before?
Back to top
View user's profile Send private message
TylerK



Joined: 18 Dec 2006
Posts: 384
Location: Springfield, IL

Digg It
PostPosted: Sat Jan 20, 2007 7:00 pm    Post subject:

I believe the Goldeneye (advanced) script included with GlovePIE did some script switching like that to separate the menu controls from the in-game controls because they were so different from each other. I also did something similar for a Genesis controller script.

Code:
/* Genesis Script
 This is a script used for the Genesis emulator Fusion.
 You must setup the controls like the following in Fusion
 or it won't work correctly:

 GENESIS CONTROLLER           ACTUAL KEYBOARD KEYS
 ----------------------------------------------------
 A                                 K
 B                                 M
 C                               Comma
 Up                                Up
 Down                             Down
 Left                             Left
 Right                            Right
 Start                            Enter
 ----------------------------------------------------

 This script is designed to allow you to play Genesis games using
 only the Wiimote held in the classic controller style. Since the
 Genesis had three buttons (let's ignore the 6-button controller)
 and the Wiimote's buttons are laid out so strangely, I'm hesitant
 to have just one solitary control scheme.

 By default, the controls are thus:

 A = Wiimote.B
 B = Wiimote.One
 C = Wiimote.Two

 ...but if you hold the Minus button and press 1 or 2 on the Wiimote
 you can cycle through the 4 different button layouts (indicated by
 the LEDs on the Wiimote). Some games will be easier to play with
 the default button layout, but if in some games it's bothersome,
 try switching to a different layout.

 Additionally, you can hold Minus and press Left or Right to cycle
 through save slots. Holding Minus and pressing Wiimote.A will save
 to the selected slot. Holding Minus and pressing Wiimote.B will
 load from the selected save slot.
*/

// Wiimote Setup
var.batteryLife1 = Wiimote1.Battery;

if (!var.initialized) then
   var.initialized = true;
   var.mode1 = 1
endif

// extra controls
If (Wiimote1.Minus) then
  // switch between save state slots
  F6 = Wiimote1.Down
  F7 = Wiimote1.Up

  // save state to selected slot
  F5 = Wiimote1.A

  // load state from selected slot
  F8 = Wiimote1.B

  // Switch between control schemes.
  if (Pressed(Wiimote1.One)) then
    if (var.mode1 == 1) then
       var.mode1 = 4
    else
       var.mode1--;
    endif
  endif
  if (Pressed(Wiimote1.Two)) then
    if (var.mode1 == 4) then
       var.mode1 = 1
    else
       var.mode1++;
    endif
  endif
else

// Controls that don't change.
Up = wiimote1.Right
Down = wiimote1.Left
Left = wiimote1.Up
Right = wiimote1.Down
Enter = wiimote1.Plus
Escape = wiimote1.Home

// Different button layouts based on mode.
if (var.mode1 == 1) then
   M = wiimote1.One
   Comma = wiimote1.Two
   K = wiimote1.B
elseif (var.mode1 == 2) then
   M = wiimote1.One
   Comma = wiimote1.Two
   K = wiimote1.A
elseif (var.mode1 == 3) then
   K = wiimote1.Two
   M = wiimote1.One
   Comma = wiimote1.A
else
   K = wiimote1.One
   M = wiimote1.Two
   Comma = wiimote1.B
endif
endif

// Indicate which button layout we're using via LEDs.
Wiimote1.Led1 = (var.mode1 == 1)
Wiimote1.Led2 = (var.mode1 == 2)
Wiimote1.Led3 = (var.mode1 == 3)
Wiimote1.Led4 = (var.mode1 == 4)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    WiiLi.org Forum Index -> Wii Scripts All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group