Included in the package is the binary (place it in the lib folder in the Small Basic installation folder,) an example (below,) and the source (in C#.)
Currently, button values can only be read in real time, so you have to put the program in a constant loop. This is pretty common, but those who are just starting Small Basic may find it weird.
Sample code:
c = 0
While(c = 0)
c = WiiRemote.Connect()
TextWindow.WriteLine("Connecting!")
EndWhile
TextWindow.WriteLine("Connected!")
WiiRemote.SetLights("true", "false", "false", "true")
buttonA = 0
lastButtonA = 0
buttonB = 0
lastButtonB = 0
While(1 = 1)
buttonA = WiiRemote.A
buttonB = WiiRemote.B
If ((buttonA = 1) And (lastButtonA = 0)) Then
TextWindow.WriteLine("Button A pressed!")
endif
If ((buttonB = 1) And (lastButtonB = 0)) Then
TextWindow.WriteLine("Button B pressed!")
endif
If WiiRemote.Home = 1 then
Program.End()
EndIf
lastButtonA = buttonA
lastButtonB = buttonB
EndWhile
No comments:
Post a Comment