Powered by SmartDoc

�t�^

2009�N4��14���ŏI�X�V
����ŕF
http://akihiko.shirai.as/projects/BookWii/

�ڎ�

�t�^�FGlovePIE�֐����t�@�����X

�����GlovePIE�ɓ�������Ă���uDocumentation.rtf�v��Ǝ��ɐ������Ȃ���|�󂵂����̂ł��B�����[�����e������܂�����A���ЍŐV�̃I���W�i���̉p��ł��m�F����邱�Ƃ������߂��܂��B��҂̕��L���m���Ɋ������o���܂��B

�R�����g�s
�“ǐ������߂邽�߂̃R�����g�s�ł��B�u//�v�̑��Ɂu/*�`*/�v�A�u'�v�A�u%�v�A�uREM�v�Ŏn�܂�s���R�����g�Ƃ��Ė�������܂��B
�s��
�����t���������s���Ă���肠��܂��񂪁AC/C++�X�^�C���́u;�v��t�����čs���𖾎��I�ɋL�q�ł��܂��B
���
�uA=B�v�Ƃ����A�̒��g��B�ɂȂ�܂��B�uA:=B�v��uB=>A�v�Ƃ��L�q�ł��܂��B
If��(��������)
��{�́uif (����) then (����) [;] end if�v�ł����uthen�v�͏ȗ��”\�Aend if���uend�v�Ə����܂��B�uelse�v���g�p�ł��܂��B
while��(�J��Ԃ����s)
�uwhile (����) { (����) }�v�ł��B1�s�ŏ������Ƃ��ł��܂��B�udo�v���g�p�ł��܂��B
For��(�J��Ԃ����s)
for ( (�����l) ; (����) ; (����) ) { (����) }�v�ł��B�����I�ɕ‚��邽�߂Ɂuend for�v���g�����Ƃ��ł��܂��B
wait��
�������w�莞�Ԃ�����~�ł��܂��B�uwait 100 ms�v,�uwait 1 second�v,�uwait(500 milliseconds)�v�ȂǒP�ʕt���ŕW�L���܂��B
���Z/���Z
���Z�F�uvar.x++�v,�u++var.x�v,�uInc(var.x)�v�A���Z�F�uvar.x--�v,�u--var.x�v,�uDec(var.x)�v���C�����C���Ŏg�p�ł��܂��B
�r�b�g�V�t�g���Z
�ushr var.x, 1�v,�ushl var.x,1�v�Ƃ��邱�ƂŃr�b�g�V�t�g���Z�����s�ł��܂��B
����
�uSay�ghello world�h�v�������́uSay(�ghello world�h)�v�Ə������ƂŁA���������Ŏ��R�ɒ��点�邱�Ƃ��ł��܂��B

�����Ċ֐��ł��B

�O�p�֐�(trigonometric)�E�t�O�p�֐�(Inverse trigonometric)
sin, cos, tan, sec, cosec, cotan, aSin, aCos, aTan, aSec, aCosec, aCotan, atan2
�o�Ȑ��֐�(Hyperbolic)�E�t�o�Ȑ��֐�(Inverse Hyperbolic trig.)
SinH, CosH, TanH, SecH, CosecH, CotH, aSinH, aCosH, aTanH, aSecH, aCosecH, aCotanH
�ۂߊ֐�(Rounding Functions)
�uceil()�v�؂�グ������,�ufloor()�v�؂�̂Đ�����,�utrunc()/int()�v�؂藎�Ƃ�������,�uround()�v�l�̌ܓ�,�ufrac()�v������, RoundTo(),SipleRoundTo()
�����֐�(Sign Functions)
�uSign()�v���Ȃ�1�A0�Ȃ�0�A���Ȃ�-1��Ԃ��B�uAbs()�v��Βl�B��������菜���ĕԂ��B
�w���ƕ�����(Exponential and Square Root)
�usqr(x)�vx�̓��A�usqrt(x)�v��x�A�upower(x,y)/intPower(x,y)�vx��y��A�uexp(x)�ve��x��(e=2.71828... e^x�̔�����e^x)�A�uLdexp(s,p)�vs * (2^p)���v�Z�B
������(polynomial)
�uPoly(x, a0, [a1, [a2, [a3, [a4, [a5, [a6]]]]]])�v��a0 + a1*x + a2*(x^2) + a3*(x^3) + a4*(x^4) + ...���v�Z
�ΐ�(Logarithms)
�uLog10(x)�v,�uLog2(x)�v,�uLogN(N, x)�v,�uLn(x)�v,�uLnXP1(x)�vLn(x)�Ɠ����ł����iX+1�j�̎��R�ΐ���Ԃ��B
��r�֐�(Comparison)
�uIsZero(x)�v,�uIsInfinite(x)�v�����Ȃ�true,�uIsNaN(x)�vx�����l�łȂ����true,�uSameValue(a, b [, c])�va,b������(c�ȍ~��)�Ȃ�true,�uInSet(x,a,b,c,d,e,f,g,...)�vx���Ȍ��a�`g�Ɉ�v�����true�B
�ő�/�ŏ��֐�
�umax(a,b)/min(a,b)�v2�‚̒l�̍ő�/�ŏ���Ԃ��A�P�ʂ͕ۑ��B
�l��֐�
�uEnsureRange(x, a, b)�vx��l��[a,b]�Ɏ��߂�B�uInRange(x, a, b)�vx���l��[a,b]���ł����true�B
�}�b�v�֐�
�uMapRange(x, a, b, c, d)�v�l��[a,b]�ɂ�����x��l��[c,d]�Ɋ��蓖�Ă��l��Ԃ��B�}�b�v�オ�l��̊O�ł����Ă��K���Ȓl�ɂȂ�B�uEnsureMapRange(x, a, b, c, d)�vMapRange�Ɠ��������l��̊O�̒l��l��̒[�Ƃ���B
����(Random)
�uRandom�v0�`1�̃����_���ȏ����l�B�uRandom(n)�v0�`n-1�܂ł̃����_���Ȑ��B�uRandomRange(a,b)�va�`b�܂ł̃����_���Ȑ��B�uRandG(mean, StandDev)�v���ς̂܂��ɃK�E�X���z���痐����Ԃ��B
����(Ordinal)
�uodd(n)�v��Ȃ�true,�upred(n)/succ(n)�v���R��n-1/n+1��Ԃ��B
���t�����֐�
�uNow/Time/Date�v���݂̓���,�uTomorrow/Yesterday�v����/����̓��t,�uCurrentYear�v�O���S���I��̍��N,�uDateOf(x)/TimeOf(x)�vx�̓��t/����,�uDayofthemonth(x), dayoftheweek(x), dayoftheyear(x), dayofweek(x), Daysbetween(x, y), Daysinamonth(x, y), daysinayear(x), daysinmonth(x), daysinyear(x), DaySpan(x, y), HourOfTheDay(x), HourOfTheMonth(x), HourOfTheWeek(x), HourOfTheYear(x), HoursBetween(x, y), HourSpan(x, y), IncDay(x, [y])�v���̑����t�����֐�

���̑��̊֐�

Smooth(x, [ExtraFrames, [DeadbandDistance]])
Smooths�֐��͒lx���ߋ���[ExtraFrames]�̌����������‚����ĕ��ς��Z�o���܂��B����[DeadbandDistance]�ȏ�̕ύX���Ȃ���΁A�S�Ăɂ����ĕύX���Ȃ��������̂Ƃ��Ĕ��f���܂�(�ȗ����̃f�t�H���g[DeadbandDistance]��0)�B
Pressed(x), Clicked(x), SingleClicked(x), DoubleClicked(x)
���ꂼ��̃C�x���g�����������Ƃ���true��Ԃ��܂��B
HeldDown(x, MinTime)
x��������Ă���ԁAMinTime�̊Ԃ���true��Ԃ��܂��B
KeepDown(x, MinTime)
MinTime���o�߂���܂�true�ł����Ԃ��I����Ă���true�ł��葱���܂��B

���̑��A���O����@�\���z���ł������ȃR�}���h�𖼏̂����ł��Љ�Ă����܂��B�����Ă݂�Ƃ悢�ł��傤�B�uExitScript, 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�c]), BroadcastOsc(port, address, [p1, p2, p3�c]), WiimotePoke([wiimote number], address, value), WiimoteSend(wiimote number, report number, [p1, p2, p3�c])�v

WiiRemote�ɒ��ڃR�}���h�𑗂�uWiimoteSend()�v��A�f�[�^���e�L�X�g�t�@�C���ɏ����o���uOutputToFile()�v�Ȃǂ��낢�날��܂��B

�����̊֐�(�Ⴆ��trunc)�ɋ�������������uDebugPrint(trunc(-3.7));�v�Ƃ��Ď��s���Ă݂Ă��������B�f�o�b�O�E�C���h�E�Ɍ��ʂ�\�����邱�Ƃ��ł��܂��B�܂��P�Ɂudebug = random�v�Ƃ��邱�ƂŁuRun�v�{�^���̉E���ɕ\�����邱�Ƃ��ł��܂��B

���ɂ��}�j���A���ɂ͎Z�p�L��(�I�y���[�^�[)�ɂ‚��Ẳ��������܂����A�����̃v���O���~���O����Ƒ傫���ς��Ȃ��̂ł����ł͊������܂��B

�ȉ�Wiimote�I�u�W�F�N�g�ɂ‚��āB

Buttons
Up, Down, Left, Right, A, B, Minus, Home, Plus, One, Two�̏�Ԃ��擾���܂��BPower��Sync�{�^���͑��݂��܂���B
Motion Sensing

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�ft 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�ft 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:

g

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�fs orientation. So Z is wherever the Wiimote is pointing, not necessarily a fixed direction.

Rotations

The Wiimote doesn�ft 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�ft 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

Sensor Bar

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�cwiimote.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:

Wiimote.Leds

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.

Force Feedback

You can activate force feedback by setting:

Wiimote.Rumble

to either true or false

Speaker

You can play sounds on the Wiimote simply by setting these values:

Frequency, Volume

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�ft 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�ft 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:

Speaker, Mute

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�hMute�hworks faster than using�gSpeaker�h. Note that you don�ft 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:

SampleRate

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�ft 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�ft know what kind yet, 2 means Nunchuk, 3 means Classic Controller.

Nunchuk

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�ft try it. The two buttons are:

CButton ZButton

Unlike the other controllers, you need the word�gButton�hon the end, because Z is the name of an axis and I�fm reserving it for future axis use.

The Nunchuk also has a joystick. It uses the following values:

JoyX, JoyY

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.

Classic Controller

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�ft connect to anything and seem totally pointless. The lock button can�ft 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�ft go below 0.03 when fully released, and yours may not reach 1 when fully pressed.

There are also two joysticks. I�fm 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�fs 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�fs when they are plugged in.

Don�ft 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).

Multiple Wiimotes

You can tell how many Wiimotes there are with Wiimote.Count

You can access a particular wiimote by putting a number after the word�gwiimote�hand before the dot. For example:

Enter = wiimote2.A

You can tell whether a particular Wiimote exists with Wiimote.Exists

You can�ft 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�ft forget to sync both Wiimotes with the PC before you try to use them.

WiiRemote���|�[�^��

http://www.wiimoteproject.com/

�֌W���邩������Ȃ�Web/Blog

���‚ĉ��y�ƌĂ΂ꂽ����

http://www.sonasphere.com/blog/���䒼��(��)Qosmo��\������^�����Y�p��w���΍u�t�^DJ)�H�w���m"�����݂�iPhone�\�N���G�C�^�[�̂��߂�iPhone SDK�v���O���~���O" (���䒼��) "iPhone×Music - iPhone���\������u���‚����y�ƌĂ΂����́v" (���䒼��,�i��N�v,���q�q���Y)