その他、名前から機能が想像できそうなコマンドを名称だけでも紹介しておきます。試してみるとよいでしょう。「ExitScript, ExitPIE, Execute(filename), Chain(filename), Display(text), DebugPrint(text), OutputToFile(text), AddCode(text), ControlPanel, ControlPanelKeyboard, ControlPanelJoystick, ControlPanelMouse, ControlPanelP5, ControlPanelPPJoy, ControlPanelSpeech, ControlPanelMidi, ControlPanelDisplay, PlaySound(filename),Beep([freq, duration]), BeepAsterisk, BeepExclamation, BeepHand, BeepQuestion, BeepDefault, FlashPieWindow, HidePie, ShowPie, MinimizePie, MaximizePie, RestorePie, UnMinimizePie, UnMaximizePie, Press(x), Release(x), Toggle(x), Type(text), TypeUnicode(text), SendOsc(ip, port, address, [p1, p2, p3…]), BroadcastOsc(port, address, [p1, p2, p3…]), WiimotePoke([wiimote number], address, value), WiimoteSend(wiimote number, report number, [p1, p2, p3…])」
これらの関数(例えばtrunc)に興味があったら「DebugPrint(trunc(-3.7));」として実行してみてください。デバッグウインドウに結果を表示することができます。また単に「debug = random」とすることで「Run」ボタンの右側に表示することもできます。
The Wiimote also has three accelerometers which measure forces/accelerations, in each of the three dimensions. Force and Acceleration are basically the same thing, since the mass is constant (F=ma). In GlovePIE they are labelled like this: X is to the right (of the wiimote), Y is up (from the wiimote buttons), and Z is forwards (or wherever the wiimote is pointing). This is the left-handed Direct3D system.
If you drop a Wiimote and it is in freefall, all the forces will be zero. BUT if you are holding a wiimote up so that it doesn’t fall, then you are pushing it upwards with a force equal to the force of gravity, but in the upwards direction. If you hold the Wiimote flat then the force holding it up will be in the +Y direction, but if you point the Wiimote at the ceiling then the force holding it up will be in the +Z direction. This helps us measure the Wiimotes tilt as well as its acceleration.
There are three values that you should never use anymore, because they are obsolete and only for backwards compatability: RawForceX, RawForceY, and RawForceZ. If your script is currently using them, then replace them with the calibrated force values below. Remember the calibrated force values don’t need an offset, and they are about 1/30 the size of the RawForce values.
There are three calibrated force values:
gx, gy, and gz
They can be zero for no force/acceleration, 1 for the same amount of force/acceleration as gravity, or any value in between or outside that range. There is also the vector version:
The accelerations above are effectively measured in Gs. You can use them for measuring actual acceleration, or for measuring tilt.
If you prefer acceleration values in other units, you can use these values:
RawAccX, RawAccY, and RawAccZ.
They are measured in Metres Per Second Per Second. But GlovePIE supports units so you can do things like this:
RawAccX in miles per hour per second
to get the value in different units.
The RawAcc values still include gravity.
If you want to get the real acceleration without gravity then you should use the following values instead:
RelAccX, RelAccY, and RelAccZ
They are not very accurate because it is hard for GlovePIE to separate out the force of gravity, but it makes a good attempt.
All these acceleration values are relative to the Wiimote’s orientation. So Z is wherever the Wiimote is pointing, not necessarily a fixed direction.
The Wiimote doesn’t contain gyros (BOO!!!), so it has no way of determining the yaw rotation without using an imitation sensor bar. But it can sort-of tell which way is down, based on the force of gravity. This allows it to measure pitch and roll rotations. You can use the following values:
Pitch, Roll SmoothPitch, SmoothRoll
The angles are all in degrees.
Pitch is the vertical angle. It is 90 when the wiimote is pointing at the ceiling, -90 when it is pointing at the ground, 0 when it is flat, and a value in between for angles in between.
Roll is how much the top is tilted towards the right. It is -180 or +180 when the Wiimote is upside-down, -90 when it is on its left side, +90 when it is on its right side. and 0 when it is flat.
Pitch and Roll attempt to filter out accelerations. This may make them slightly jagged. You can use SmoothPitch and SmoothRoll if you don’t mind getting the wrong result if the wiimote moves, but you do want it to be smooth.
There is also a rotation matrix, for those who prefer it. It is a 3x3 Direct3D style rotation matrix: RotMat
The sensor bar is just a bunch of Infra Red lights which are always on. You can make your own fake sensor bar with candles, Christmas tree lights, or Infra-Red remote controls with a button held down. Or you can order a wireless sensor bar off the internet, or you can build your own.
You can read the position of the infra-red dots that the Wiimote can see with: wiimote.dot1x, wiimote.dot1y…wiimote.dot4x, wiimote.dot4y
You can tell whether an infra-red dot can be seen with Wiimote.dot1vis to Wiimote.dot4vis
You can tell the size of a dot (between 0 and 15) with Wiimote.dot1size to Wiimote.dot4size
The size will always be reported as 16 if your script uses the Nunchuk or Classic Controller, because the report needs to contain more information. LEDs
You can set the 4 LEDs on the Wiimote by setting:
to a value between 0 and 15. It is binary.
Or you can set:
Wiimote.Led1, Wiimote.Led2, Wiimote.Led3, and Wiimote.Led4
to either true or false individually.
You can activate force feedback by setting:
to either true or false
You can play sounds on the Wiimote simply by setting these values:
If you set Frequency to 0 it will switch the speaker off. If you set it to non-zero it will switch the speaker on again. The frequency is measured in Hz. Don’t confuse frequency with pitch, they are different in this context.
You can set the volume to a value between 0 and 2, (between 0% and 200% in other words). I don’t recommend setting it above 100% though, unless you want to go deaf.
You can also turn the speaker on and off by setting either of these values:
Setting speaker to true switches on the speaker (slowly) and setting it to false switches off the speaker. Setting Mute to true mutes the speaker, and setting it to false un-mutes it. Using”Mute”works faster than using“Speaker”. Note that you don’t need to turn the speaker on if you set the frequency, because setting the frequency to non-zero does it automatically. Turning sound on and off with mute is also faster than doing it by changing the frequency to 0.
You can also set the sample rate with this variable:
Currently GlovePIE only supports sample rates around 3640 Hz. Sample rates must be multiples of 280 added or subtracted from that value. The default is 3640 Hz. The sample rate is also measured in Hz. The sample rate will automatically increase if you set the frequency higher than 1820 Hz. There isn’t much point in changing the sample rate.
Nunchuck and Classic Controllers
To tell whether a Nunchuk or classic controller is plugged in, use these values:
Wiimote.HasNunChuck Wiimote.HasClassic Wiimote.Expansion
The first two are true or false. The third one is a number: 0 means none, 1 don’t know what kind yet, 2 means Nunchuk, 3 means Classic Controller.
The Nunchuk has accelerometers too! Most of the same acceleration values and rotation values are the same as the Wiimote, so see the description in the sections above. The difference is the Nunchuk accelerometers have higher precision and lower range.
The Nunchuk also has two buttons. NOTE: Unlike a playstation controller, pushing in the joystick is not a button, don’t try it. The two buttons are:
Unlike the other controllers, you need the word“Button”on the end, because Z is the name of an axis and I’m reserving it for future axis use.
The Nunchuk also has a joystick. It uses the following values:
JoyX is -1 to the left, 0 in the middle, and +1 to the right. JoyY is -1 up, 0 in the middle, and +1 down.
These are the same values used by PPJoy.
The Nunchuk does NOT have vibration, or a speaker.
The classic controller does NOT have accelerometers or rumble, or a speaker!
The classic controller does have an unexplained lock button in the top centre, which physically opens and closes two slots in the back. The two slots can’t connect to anything and seem totally pointless. The lock button can’t be read.
You can read the following buttons:
a, b, x, y Minus, Home, Plus Up, Down, Left, Right ZL, ZR LFull, and RFull
They are either True or False.
The L button and the R button (LFull, and RFull above) also have analog versions:
L, and R
They will be between 0 and 1. Although mine won’t go below 0.03 when fully released, and yours may not reach 1 when fully pressed.
There are also two joysticks. I’m calling the one on the left Joy1, and the one on the right Joy2.
Joy1X, Joy1Y, Joy2X, Joy2Y
They are between -1 and 1, the same as the Nunchuk joystick described above. Low level stuff
You can read the data reports from the Wiimote with:
debug = Wiimote.InByteString
Or you can read them individually with:
var.a = Wiimote.InReport var.b = Wiimote.InByte1
You can send data reports to the Wiimote with this function (it has no dot):
WiimoteSend(1, 0x12, 1, 0x33)
The first parameter of WiimoteSend is the Wiimote number you want to send it to, normally 1. The second parameter is the report number. The remaining parameters are the report payload. In this case, the report tells the Wiimote to start vibrating, and to send data via report 0x33.
The one-byte reports can also be sent another way by setting one of these values (it will only send the report when the value changes):
Wiimote.Report11, Wiimote.Report13, Wiimote.Report14, Wiimote.Report15, Wiimote.Report19, Wiimote.Report1A
You can set bytes in the Wiimote’s onboard memory (where Miis are stored) with the WiimotePoke command, and read bytes from its memory with the WiimotePeek command.
WiimotePoke(1, 0x04B00033, 0x33) var.value = WiimotePeek(1, 0x04B00033)
The first parameter is optional, and it is the Wiimote number. The second parameter is the address. The third parameter is the value you want to set it to (between 0 and 255).
Note that the Nunchuk and Classic Controller have their own memory space which is mapped to the Wiimote’s when they are plugged in.
Don’t use these low level functions unless you know what you are doing and have read the www.wiili.org/Wiimote page. One person has bricked their nunchuk by experimenting with writing to all its addresses (although that is how we discovered how the nunchuk works).
You can tell how many Wiimotes there are with Wiimote.Count
You can access a particular wiimote by putting a number after the word“wiimote”and before the dot. For example:
Enter = wiimote2.A
You can tell whether a particular Wiimote exists with Wiimote.Exists
You can’t read the Serial number (as text) anymore with Wiimote.Serial, because I disabled it. It rebooted computers with BlueSoleil when you tried to read the serial.
Don’t forget to sync both Wiimotes with the PC before you try to use them.
http://www.sonasphere.com/blog/徳井直生(株)Qosmo代表取締役／東京藝術大学非常勤講師／DJ)工学博士"ユメみるiPhone―クリエイターのためのiPhone SDKプログラミング" (徳井直生) "iPhone×Music - iPhoneが予言する「いつか音楽と呼ばれるもの」" (徳井直生,永野哲久,金子智太郎)