���̏͂ł�WiimoteLib�Ƃ���API�𗘗p���āAWiiRemote�̃v���O���~���O�̊�b��������Ă����܂��B�v���O���~���O���Ƃ��āA�����ŗ��p�ł���uVisual C++ 2008 Express Edition�v�������́uVisual C# 2008 Express Edition�v���g���܂��B�܂�v���O���~���O����Ƃ��āAC++��C#���ɕ��Ĉ����܂��B
�܂��A�{�͂�C#.NET�ɂ��v���O���~���O�T���v���͋���H�Ɛ�卂���w�Z�̏��␒�V�搶(http://www.kosaka-lab.com/)�̋��͂ɂ����̂ł��B�v���O���~���O���S�҂ł��킩��₷�������ł���悤�ɁA�ł��邾�������̃T���v���J�ɏ���ǂ��ĉ�����邱�ƂŁAWiiRemote�v���O���~���O��̌����邱�Ƃ��ł���悤�ɂȂ��Ă��܂��B
���̃Z�N�V�����ł́A�����ŗ��p�ł���uVisual C++ 2008 Express Edition�v�ƁuVisual C# 2008 Express Edition�v���Z�b�g�A�b�v���܂��B���ɂ����̐��i�̏�ʃo�[�W����(Standard Edition�Ȃ�)���C���X�g�[������Ă������AC++�AC#�̂����ꂩ�����K�v�łȂ����́A�K�v�ȂƂ��낾���Q�Ƃ��Ă��������B
Visual C# 2008 Express Edition�̃Z�b�g�A�b�v�ɂ��ẮA�}�C�N���\�t�g�̌����T�C�g�ɒ��J�ɉ������Ă���܂��B
http://www.microsoft.com/japan/msdn/vstudio/express/beginners/2008/vcsharp.aspx
Express Edition��Web�C���X�g�[�����_�E�����[�h���A���v��\������A�v���P�[�V���������ۂɍ���Ă݂邱�Ƃ��ł��܂��BC#�͂��炭�g���\��͂Ȃ�����ǂ��A�C���X�g�[�����Ă݂悤�A�Ƃ������͐����Ă݂Ă��������B
�����ł�Microsoft Visual C++ 2008 Express Edition�̃Z�b�g�A�b�v�A�T���v���J���ɂ��ĉ�����܂��B����Visual C++��.NET�Ƃ������J���������g���̕��́A�ǂݔ���Ă��������Ă���肠��܂���B
�܂��}�C�N���\�t�g�̃z�[���y�[�W����Microsoft Visual C++ 2008 Express Edition���_�E�����[�h���܂��B
http://www.microsoft.com/japan/msdn/vstudio/express/
�uWeb�C���X�g�[��(�_�E�����[�h)�v���N���b�N����ƁAWeb�C���X�g�[���ŃZ�b�g�A�b�v�t�@�C���uvcsetup.exe�v���_�E�����[�h���邱�Ƃ��ł��܂��B���̃z�[���y�[�W�ɂ�Visual Studio���i���g����ł̖��ɗ����������܂��B�Ƃ肠����VC2008���g���Ă݂������́u�͂��߂Ă̕��̂��߂̃C���X�g�[�����@�v��ǂ�ł݂�Ƃ���Ɨǂ��ł��傤�B
�K�v�ȃn�[�h�f�B�X�N�e�ʂ̊m�F�A�N�����̃A�v���P�[�V�����̏I���Ȃǂ��s���Ă���C���X�g�[���E�B�U�[�h�uvcsetup.exe�v���N�����܂��B
�u�Z�b�g�A�b�v�̕i������v���O�����v�̓`�F�b�N���Ă����Ȃ��Ă��A�ǂ���ł����܂��܂���B�u���ցv���N���b�N���Đi�݂܂��B
���C�Z���X�������悭�ǂ�Łu���ӂ���v��I��ł��������B�܂��uVisual Studio�ŃI�����C����RSS�R���e���c����M���ĕ\���ł���悤�ɂ���v�����ɖ�肪�Ȃ���`�F�b�N���܂��傤�B�C�x���g��T�[�r�X�p�b�N�Ȃǂ̍X�V���VC2008�N������ɕ\�������X�^�[�g�y�[�W�Ɏ����I�ɕ\�������悤�ɂȂ�܂��i�����ł�RSS��M�̐ݒ�͌�ł��I�v�V�����������X�^�[�g�A�b�v�ŕύX�ł��܂��j�B�u���ցv���N���b�N���Đi�݂܂��B
�u�C���X�g�[���I�v�V�����v��I�����܂��B�����ŕ\������Ă���3�̃I�v�V�����́A�ǂ���C���X�g�[�����Ȃ��Ă���肠��܂���B�uMSDN Express���C�u�����v��F1�L�[�ŌĂяo����h�L�������g�ŁA�I�����C���ł̕����[�����Ă���̂ł����A�M�҂͓d�Ԃ̒��ŃR�[�f�B���O�����邱�Ƃ������̂ŃC���X�g�[�����Ă��܂��i�I�����C���łƓ������ė��p�ł��܂��j�B�uSQL Server 2005�v�A�uSilverlight�v�͎g���\�肪�Ȃ���C���X�g�[�����Ȃ��ėǂ��ł��傤�B�u���ցv���N���b�N���Đi�݂܂��B
�u�R�s�[��t�H���_�v�ƃ_�E�����[�h�p�b�P�[�W�̃��X�g�ł��B�u�C���X�g�[������t�H���_�v�͖{���ł̓f�t�H���g�̂܂܂Ƃ��ĉ�����܂��B�_�E�����[�h���X�g�̒��ɁuWindows SDK�v�������Ă���̂�������܂�(�ȑO��Express Edition�ł͕ʓr�C���X�g�[������K�v������܂���)�B�u�C���X�g�[���v���N���b�N����ƃ_�E�����[�h�ƃC���X�g�[�������s����܂��B
�ȏ��WindowsXP�V���[�Y�ɂ�����VC2008�Z�b�g�A�b�v�̗���ł��iWindows Vista�̏ꍇ�́u�Ǘ��Ҍ����Ŏ��s�v������K�v������_�Ȃǂ������ׂ����_���قȂ�܂����قړ�������ł��j�B�������������VC2008�̃E�B�U�[�h��I�����C���`���[�g���A���Ȃǂ��g���ĊȒP�ȃv���O���~���O�������Ă݂�Ɨǂ��ł��傤�B
�����A����Visual C++��Visual Studio�̉ߋ��̃o�[�W����(.NET2003/2005�Ȃ�)�����g���ŁA����2008�N���_�̍ŐV�łł���Visual C++ 2008 Express�i�ȉ�VC2008�j�������Ă݂����̓ǎ҂́A�����ł�����Ɖ�蓹�����Ď����Ă݂邱�Ƃ��������߂��܂��BVC2008��Version Selector�Ƃ����@�\������A�قȂ�o�[�W������Visual Studio���i�̍��݂��\�ɂ��܂��B�e�o�[�W�����ɂ����ă\�����[�V�����t�@�C���͊g���q�u.sln�v�ƕς��܂��A�����I�ɂ��̊g���q�u.sln�v�Ɋ֘A�Â���ꂽ�A�v���P�[�V�����ł���uVersion Selector�v���t�@�C�������̃o�[�W�����L�q�������I�ɓǂݎ��A�t�@�C�����_�u���N���b�N���ꂽ�Ƃ��͓K�ȃo�[�W������VC���N�����܂��B���̋@�\�̂������ŕ����̃o�[�W�����̊J���������S���ăC���X�g�[���ł���悤�ɂȂ�܂��B
WiimoteLib��Brian Peek(http://www.brianpeek.com/)�ɂ��.NET���ŗ��p�ł���API�I�[�v���\�[�X�v���W�F�N�g�ł��BMicrosoft���x������I�[�v���\�[�X�v���W�F�N�g�x���T�C�g�uCodePlex�v(http://www.codeplex.com/)�Ō��J����Ă��܂��BWiimoteLib��p���邱�ƂŁA.NET���ŊȒP��WiiRemote�𗘗p����A�v���P�[�V�������J�����邱�Ƃ��ł��܂��BVersion1.6.0.0�����WiiRemote�����łȂ�Wii Fit�o�����X�{�[�h�ɂ��Ή����Ă��܂��B
WiimoteLib��.NET�ŊJ�����ꂽAPI�ł���A����Ɉˑ����܂��AC#��Visual Basic�����C���̃^�[�Q�b�g�̂悤�ł��BC++�ł̃T���v���͔z�z����Ă��炸�A�܂��l�b�g��̏������܂葶�݂��Ȃ��̂ł����A�{�͂�ǂݐi�߂Ă������ƂŁA������ԂŖ��Ȃ����p�ł��邱�Ƃ��킩��ł��傤�B
C++����ɂ͂��܂��܂Ȍ���d�l�����݂��܂����A�{�͂ł͓���.NET�v���O���~���O�Ƃ��Ĉ����₷���uC++/CLI�v�������܂��BCLI�Ƃ́uCommon Language Infrastructure(���ʌ�����)�v�̗��ŁAC++�Ɋ���e���v���O���}�[�ɂ��A��a���̏��Ȃ��`�Ő�i�I��.NET�v���O���~���O������Ă��܂��B�{�͂ł͂��̓����𗘗p���A������{�I�ȃv���O���~���O��C++��C#�Ƃ���2�̌���ʼn������Ƃ����킯�ł��B
WiimoteLib�̃��C�Z���X�́uMicrosoft Permissive License (Ms-PL)�v�ł��BMs-PL�́A�ł������̊ɂ��}�C�N���\�t�g�̃\�[�X�R�[�h���C�Z���X�ŁA�\�[�X�R�[�h�����p�܂��͔p�̖ړI�ŕ\���A�ύX�A�ĔЕz�ł��܂��B�܂���]����ꍇ�́A�ύX�����\�[�X�R�[�h�ɑ��ă��C�Z���X�����ۋ����邱�Ƃ��ł��܂��B�ȉ��ɏ̓��{��Q�l������p���Ă����܂�(http://www.microsoft.com/japan/resources/sharedsource/licensingbasics/permissivelicense.mspx)�B
Microsoft Permissive License (Ms-PL)�@���J��: 2007�N7��9��
�{���C�Z���X�́A�t������\�t�g�E�F�A�̎g�p�ɓK�p����܂��B�{�\�t�g�E�F�A���g�p����ꍇ�́A�{���C�Z���X�ɓ��ӂ������̂Ƃ݂Ȃ��܂��B�{���C�Z���X�ɓ��ӂ��Ȃ��ꍇ�A�{�\�t�g�E�F�A���g�p���邱�Ƃ͂ł��܂���B
1.��`
�{���C�Z���X�ł́A"��������"�A"����"�A"�I���앨"�A�����"�Еz"�Ƃ����p��́A�č��̒��쌠�@�̉��Ŏg����ꍇ�Ɠ����Ӗ���L���܂��B"�R���g���r���[�V����"�Ƃ́A�I���W�i���̃\�t�g�E�F�A�A�܂��̓\�t�g�E�F�A�ɑ���lj��������͕ύX���Ӗ����܂��B"�R���g���r���[�^�["�Ƃ́A�{���C�Z���X�̉��Ŏ���̃R���g���r���[�V������Еz����҂��Ӗ����܂��B"�Ώۓ���"�Ƃ́A�R���g���r���[�V���������ڒ�G����A�R���g���r���[�^�[�̗L����������̐����͈͂��Ӗ����܂��B
2.�����̕t�^
(A)���쌠�Ɋւ��鋖��-��3���u��������ѐ����v���܂ޖ{���C�Z���X�̏����ɏ]���āA�e�R���g���r���[�^�[�͎g�p�҂ɑ��A�R���g���r���[�V���������A�R���g���r���[�V�����̓I���앨���쐬���A�R���g���r���[�V�����܂��͍쐬�����I���앨��Еz����A��Ɛ�I�A���E�S��A�����̒��쌠���C�Z���X��t�^���܂��B(B)�������Ɋւ��鋖��-��3���u��������ѐ����v���܂ޖ{���C�Z���X�̏����ɏ]���āA�e�R���g���r���[�^�[�͎g�p�҂ɑ��A�{�\�t�g�E�F�A�̃R���g���r���[�V�����܂��͖{�\�t�g�E�F�A�̃R���g���r���[�V�����̓I���앨���쐬���A�쐬�����A�g�p���A�̔����A�̔����Ă��A�A�����A�����/�܂��͂��̑��̕��@�ŏ�������A�Ώۓ����Ɋ�Â���Ɛ�I�A���E�S��A�����̓��������C�Z���X��t�^���܂��B
3.��������ѐ���
(A)���W�̏��O-�{���C�Z���X�ł́A�R���g���r���[�^�[�̖��O�A���S�A�܂��͏��W���g�p���錠���͗^�����܂���B
(B)�g�p�҂��A�{�\�t�g�E�F�A�ɂ��N�Q���咣��������Ɋւ��A�R���g���r���[�^�[�ɑ��ē����N�Q���咣����ꍇ�A���Y�R���g���r���[�^�[�ɂ��{�\�t�g�E�F�A�ɂ��Ă̎g�p�҂ɑ���������C�Z���X�͎����I�ɏI�����܂��B
(C)�{�\�t�g�E�F�A�̑S���܂��͈ꕔ��Еz����ꍇ�A�{�\�t�g�E�F�A�ɕt�����邷�ׂĂ̒��쌠�A�������A���W�A����яo���̕\����ێ�����K�v������܂��B
(D)�{�\�t�g�E�F�A�̑S���܂��͈ꕔ���\�[�X�R�[�h�̌`���ŔЕz����ꍇ�́A�Еz���ɖ{���C�Z���X�̊��S�Ȏʂ����܂߂���ŁA�{���C�Z���X�̏����̉��ł̂ݔЕz���邱�Ƃ��ł��܂��B�{�\�t�g�E�F�A�̑S���܂��͈ꕔ���R���p�C���ς݂܂��̓I�u�W�F�N�g�R�[�h�`���ŔЕz����ꍇ�́A�{���C�Z���X�ɒ�G���Ȃ������̃��C�Z���X�̉��ł̂ݔЕz���邱�Ƃ��ł��܂��B
(E)�{�\�t�g�E�F�A�͌���L�p�ɂă��C�Z���X����܂��B�{�\�t�g�E�F�A�̎g�p�ɔ����댯�́A���ׂĎg�p�҂��������̂Ƃ��܂��B�R���g���r���[�^�[����̖����I�ȕۏ܂��͏����͈����܂���B�g�p�n�̖@���Ɋ�Â��A�{���C�Z���X�ł͕ύX�ł��Ȃ����̑��̏���҂̌��������݂���ꍇ������܂��B�g�p�n�̖@���Ɋ�Â��ċ������͈͂ŁA�R���g���r���[�^�[�́A���i���A����ړI�ɑ���K�����A��N�Q�ɂ��āA�َ��I�ȕۏ�ے肵�܂��B
(�{�T�C�g��http://www.microsoft.com/resources/sharedsource/licensingbasics/permissivelicense.mspx�̎Q�l��ł�)
���C�Z���X���m�F������AWiimoteLib���_�E�����[�h���܂��B���e�o�Ŏ��_�ł̍ŐV�ł�2009�N1��19���Ɍ��J���ꂽWiimoteLib v1.7�ł��B
http://www.codeplex.com/WiimoteLib
�z�[���y�[�W�㕔�ɂ���uDownload�v�̃����N���N���b�N����ƁA�_�E�����[�h�y�[�W���{���ł��܂��B�z�z�p�̃p�b�P�[�W�ƃ\�[�X�R�[�h���z�z����Ă��܂����A�\�[�X�R�[�h�ł͂Ȃ��ق��uWiimoteLib V1.7 (787K)�v���_�E�����[�h���Ă��������B
�N���b�N����ƁA���C�Z���X���p��ŕ\������܂��̂�(�m�F������)�uI Agree�v�N���b�N���A�_�E�����[�h���J�n���܂��B
�_�E�����[�h����ZIP�t�@�C����W�J������A�܂��͓���m�F�����܂��B���g����Bluetooth�X�^�b�N�Ǘ��\�t�g�E�F�A���N�����āAWiiRemote��1��ڑ����܂��B�ڑ��ł�����A�W�J�����t�H���_�̒��ɂ���uWiimoteTest.exe�v���_�u���N���b�N���Ď��s���Ă݂Ă��������B
���������s�ł���ƁA���b�Ԃ̏������̌�A�}�̂悤�Ȏ��s��ʂ��\�������͂��ł��BWiiRemote��U������A�{�^�����������ƂŁA���A���^�C���Œl���擾�ł��Ă��邱�Ƃ��m�F�ł��܂��B
�t�H�[���̉E��u×�v���N���b�N����ƏI�����܂��B�����茳�ɕ�����WiiRemote��Z���T�[�o�[�A�k���`���N�A�M�^�[�R���g���[���[�AWiiFit�o�����X�{�[�h�Ȃǂ���܂�����A���Аڑ����ē���������Ă݂Ă��������B
�����WiimoteLib���g���邱�Ƃ��m�F�ł��܂����B�G���[�����������ꍇ�A���ɁuError reading data from Wiimote...is it connected?�v�ƕ\�����ꂽ�ꍇ�́ABluetooth�ł̐ڑ��ɖ�肪����܂��BBluetooth�X�^�b�N��������WiiRemote��ڑ����Ă��邩�ǂ����A�m�F���Ă݂Ă��������B
���āA�W�J�����t�@�C���̂����uWiimoteLib.dll�v����ԏd�v�ȃt�@�C���ł��B�uWiimoteTest.ext�v������DLL�������f�B���N�g���ɑ��݂��Ȃ���ΐ��������삵�܂���B�Ȃ�WiimoteLib���J���ŗ��p����ɂ�����A���ɃC���X�g�[���[�Ȃǂ͂���܂���̂ŁA�W�J�����t�H���_���Ɓu�}�C�h�L�������g\Visual Studio 2008\Projects\WiimotLib_1.7�v�Ɉړ����Ă����Ƃ��̂��Ƃ̍�Ƃ��y�ɂȂ�ł��傤�iWiimoteLib.dll�����ł������̂ł����A�w���v�╡���̃o�[�W������DLL�����݂���ƌ�X���ł��j�B�Ȃ��udocs�v�t�H���_�ɂ���uWiimoteLib.chm�v���w���v�t�@�C���ł��B�h�L�������g����������Ɛ�������Ă��܂��B
����ŃZ�b�g�A�b�v�͏I���ł��I���̐߂���͎��ۂɁA�܂���Visual C#��p����WiiRemote�𐧌䂵�Ă����܂��B
���̐߂ł́AVisual C# 2008 Express(�Ȍ�uC#�v�ƕW�L)���g���āAWiimoteLib�ł̃v���O���~���O��̌����Ă����܂��B
Visual C# 2008 Express Edition���N�����܂��B
[�t�@�C��(F)]��[�V�����v���W�F�N�g(P)]��[Windows�t�H�[���A�v���P�[�V����]��I�����܂��B
�u�v���W�F�N�g���v�ɁuWiimoteLib01�v�Ƃ������O��t����[OK]�{�^�����N���b�N���܂��B
���b�҂ƐV�����v���W�F�N�g���쐬����܂��B���������������[F5]�L�[�������āA���s���Ă݂�Ɨǂ��ł��傤�B
��قǍ쐬������̃v���W�F�N�g��WiimoteLib��g�ݍ���ł����܂��傤�B�E���ɕ\������Ă���A�\�����[�V�����G�N�X�v���[����[�Q�Ɛݒ�]���E�N���b�N�A[�Q�Ƃ̒lj�(R)...]��I�����܂��B
�Q�Ƃ̒lj�����[�Q��]��I�����AWiimoteLib.dll��I�����܂��B�}�C�h�L�������g�́uVisual Studio 2008\Projects�v�ɂ������uWiimoteLib_1.7\WiimoteLib.dll�v��I����[OK]�{�^�����N���b�N���܂��B
����Ń\�����[�V�����G�N�X�v���[���̎Q�Ɛݒ��WiimoteLib���lj����ꂽ�͂��ł��B
����ł͍ŏ����̃v���O�����̎��s���ʂ�\�����邽�߂̃t�H�[�����쐬���܂��傤�B�\�����[�V�����G�N�X�v���[���́uForm.cs�v���E�N���b�N���āu�R�[�h�̕\���v�ŕ\�������C#�̃R�[�h�ɁA�ł��d�v�ȍŏ���1�s�uusing WiimoteLib;�v��lj����܂��B
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; | using WiimoteLib; //������1�s�lj����܂� namespace WiimoteLib01 { //���w�肵���v���W�F�N�g�� public partial class Form1 : Form { public Form1() { InitializeComponent(); } } }
�ȏオC#����WiimoteLib��p���邽�߂̍ŏ��̈���̑���ł��B�܂�WiiRemote�炵�����Ƃ͉����ł��܂��A�����WiimoteLib�̃N���X�����p�ł���悤�ɂȂ�܂����B���̃X�e�b�v�ŁA���ۂɓ�����m�F���Ă݂܂��傤�B
[F5]�L�[�A�܂��́A[�f�o�b�N(D)]��[�f�o�b�N�J�n(F5)]�������ăv���O���������s�����Ă݂܂��傤�B
�v���O�����ɃG���[���Ȃ���Ή��}�̂悤�ɕ\�������͂��ł��B
���̃v���O�����͒P�Ƀt�H�[��������v���O�����ł��B�u×�v�{�^���������ăt�H�[������ăv���O�������I�������܂��傤�B�Ȍ�A���̃v���O�������x�[�X��WiiRemote�𐧌䂷��v���O������lj����Ă����܂��B
����Visual C++ 2008 Express(�Ȍ�uC++�v�ƕW�L)���g���āAWiimoteLib�ł̃v���O���~���O��̌����Ă����܂��B��x������o������A�Ȍ�͋��ʂł��B�����C++��C#�A�ǂ���ł����܂��܂���B�����g���g���₷�������I��ł݂Ă��������B
Visual C++ 2008 Express Edition���N�����܂��B
[�t�@�C��(F)]��[�V�����v���W�F�N�g(P)]����A[CLR]��[Windows�t�H�[���A�v���P�[�V����]��I�����܂��B
�u�v���W�F�N�g���v�ɁuWiimoteLib01cpp�v�Ƃ������O��t����[OK]�{�^�����N���b�N���܂��B
�V�����v���W�F�N�g���쐬����܂����B���������������[F5]�L�[�������āA���s���Ă݂�Ɨǂ��ł��傤�B�����Ȃ��t�H�[�����\������A�u×�v�{�^���������ƏI�����܂��B
��قǍ쐬�����v���W�F�N�g��WiimoteLib��g�ݍ���ł����܂��傤�B�\�����[�V�����G�N�X�v���[���Ńv���W�F�N�g(�����ł́uWiimoteLib01cpp�v)���E�N���b�N����[�Q��]��I�����܂��B
�v���W�F�N�g�̃v���p�e�B�y�[�W����[�V�����Q�Ƃ̒lj�(N)...]���N���b�N���A[�Q��]�^�u���N���b�N���A�t�@�C���I���_�C�A���O�ŁA�}�C�h�L�������g�́uVisual Studio 2008\Projects�v�ɂ������uWiimoteLib_1.7\WiimoteLib.dll�v��I����[OK]�{�^�����N���b�N���܂��B
���ɁAWiimoteLib�̏������R�[�h�������܂��B�\�����[�V�����G�N�X�v���[���́uForm1.h�v���E�N���b�N���āu�R�[�h�̕\���v��I�ԂƁAForm1.h�̃R�[�h���\������܂��B���̃R�[�h�̐擪12�s�ڂɈȉ��̂悤�ɁA�K�v��1�s�����������Ă��������B
#pragma once namespace WiimoteLib01cpp { //���w�肵���v���W�F�N�g�� using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; | using namespace WiimoteLib; //�����1�s�lj����܂� ���ȉ�����
�ȏオC++/CLI��WiimoteLib��p���邽�߂̕K�v�Œ���̃v���O�����ł��B[F5]�L�[�������ăv���O���������s�����Ă݂܂��傤�B
�v���O�����ɃG���[���Ȃ����C#�Ɠ��l�A�����Ȃ��t�H�[�����\�������͂��ł��B���܂̂Ƃ���A���̃v���O�����͒P�Ƀt�H�[�������邾���̃v���O�����ł����AWiimoteLib�̃N���X��using namespace�錾�ɂ���Ė��Ȃ��g�ݍ��܂�Ă��邱�Ƃ��킩��܂��B�Ȍ�A���̃v���O�������x�[�X��WiiRemote�𐧌䂷��v���O������lj����Ă����܂��B
��������́A�����WiimoteLib��API��p���ăv���O���~���O���s���Ă����܂��B�����C++��C#����ĉ�����Ă����܂����A.NET�t���[�����[�N�̂�������GUI�̐v�Ȃǂ͂܂�������������ŊJ����i�߂邱�Ƃ��ł��܂��B
�܂��APC��ʏ�ɕ\�������Form�{�^���ɂ���āAWiiRemote�̐U���@�\(�o�C�u���[�^�[)�̓��������邷��v���O���������܂��B
�O�߂̂Ƃ���AWiimoteLib��g�ݍ��v���W�F�N�g�̃��C���̃R�[�h�iForm1.cs��������Form1.h�j�Ɉȉ���3�s��lj����܂��B
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; | using WiimoteLib; //WiimoteLib��錾 namespace WiimoteLib01 { public partial class Form1 : Form { | Wiimote wm = new Wiimote(); //Wiimote�N���X�̍쐬 public Form1() { InitializeComponent(); | wm.Connect(); //Wiimote�ɐڑ� } } } ���ȉ�����
#pragma once namespace WiimoteLib01cpp { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; | using namespace WiimoteLib; //WiimoteLib��錾 �������� public ref class Form1 : public System::Windows::Forms::Form { | public: Wiimote^ wm; //Wiimote�N���X�̓��ꕨ public: Form1(void) { | wm = gcnew Wiimote(); //Wiimote�N���X�̍쐬; InitializeComponent(); // //TODO: �����ɃR���X�g���N�^ �R�[�h��lj����܂� // | wm->Connect(); //Wiimote�ɐڑ� } ���ȉ�����
C#��C++�������̋L����\���͈Ⴆ�ǁA�قƂ�Ǔ����ł��邱�Ƃ��������肢���������ł��傤���HC++�ł�wm�Ƃ������ꕨ��Form1�N���X��Public�����o�[�Ƃ��ėp�ӂ��Ă��܂��B
�܂��A�t�H�[���Ƀ{�^����\��t���Ă��������BC#�ł́A�c�[���{�b�N�X����h���b�O����Form1�̍D���Ȉʒu�ɔz�u���܂��B(C++�ł����l�ł�)�\������Ă��Ȃ��ꍇ�A[�\��]����[�f�U�C�i]�Ƃ���Form1�̃f�U�C����\�����A�ēx[�\��]����[�c�[���{�b�N�X]��I�Ԃ��ƂʼnE���Ƀc�[���{�b�N�X�E�B���h�E������܂�(C++�͍���)�B�u�R�����R���g���[���v�ɁuButton�v������܂��̂ŁA�t�H�[���̏�Ƀh���b�O���Ă��������B
���ɁA�\��t�����ubutton1�v�̃v���p�e�B�V�[�g�́uText�v���ubutton1�v����uON�v�ɕύX���܂��B����Ńt�H�[����̃{�^���ɏ�����Ă���e�L�X�g���uON�v�ɕς��͂��ł��B
Form1��ɔz�u�����{�^���uON�v���_�u���N���b�N����ƁA�{�^���N���b�N���̃C�x���g���w�肷��R�[�h�������I�ɕ\������܂��̂ʼn��L�̂悤�ɋL�q���܂��B
private void button1_Click(object sender, EventArgs e) { wm.SetRumble(true); //�o�C�u�[�V����ON }
#pragma endregion private: System::Void button1_Click(System::Object^ sender, \ System::EventArgs^ e) { wm->SetRumble(true); //�o�C�u�[�V����ON } }; }
�C���͂����͂�����[F5]�L�[�����������Ȃ邩������܂��A�����͎̂��̃X�e�b�v�܂Ői��ł���ɂ��܂��傤�I���̂܂܂ł́ABluetooth�ڑ�����Ă��܂��A�o�C�u���[�^�[���쓮���Ă��܂��~�߂���@���������Ă��܂���̂ŁA�u���u������ςȂ��̍�������ԂɂȂ��Ă��܂��܂��B
�o�C�u���[�^�[���~������uOFF�v�{�^�����쐬���܂��B��قǂƓ��l�ɁA�c�[���{�b�N�X����{�^����z�u���܂��B
��قǂƓ������A�\��t�����ubutton2�v�̃v���p�e�B��Text���ubutton2�v����uOFF�v�ɕύX���܂��B
�Ō�ɁA�\��t�����ubutton2�v���_�u���N���b�N���A���L�̂悤�ȃR�[�h���L�q���܂��B
private void button2_Click(object sender, EventArgs e) { wm.SetRumble(false); //�o�C�u�[�V����OFF }
private: System::Void button2_Click(System::Object^ sender, \ System::EventArgs^ e) { wm->SetRumble(false); //�o�C�u���[�V����OFF }
�ȏ�ŏI���ł��B���ꂾ���̃v���O������WiiRemote�̃o�C�u���[�V�����@�\��ON/OFF���䂪�\�ɂȂ�܂��B
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; | using WiimoteLib; //WiimoteLib�̓ǂݍ��� namespace WiimoteLib01 { public partial class Form1 : Form { | Wiimote wm = new Wiimote(); //Wiimote�̐錾 public Form1() { InitializeComponent(); | wm.Connect(); //Wiimote�̐ڑ� } private void button1_Click(object sender, EventArgs e) { | wm.SetRumble(true); //�o�C�u�[�V����ON } private void button2_Click(object sender, EventArgs e) { | wm.SetRumble(false); //�o�C�u�[�V����OFF } } }
#pragma once ������ | using namespace WiimoteLib; //WiimoteLib��錾 ������ public ref class Form1 : public System::Windows::Forms::Form { | public: Wiimote^ wm; //Wiimote�N���X�̓��ꕨ public: Form1(void) { | wm = gcnew Wiimote(); //Wiimote�N���X�̍쐬; InitializeComponent(); // //TODO: �����ɃR���X�g���N�^ �R�[�h��lj����܂� // | wm->Connect(); //Wiimote�ɐڑ� } ������ #pragma endregion private: System::Void button1_Click(System::Object^ sender, \ System::EventArgs^ e) { | wm->SetRumble(true); //�o�C�u�[�V����ON } private: System::Void button2_Click(System::Object^ sender, \ System::EventArgs^ e) { | wm->SetRumble(false); //�o�C�u���[�V����OFF } }; }
�܂��A���g����Bluetooth�X�^�b�N����WiiRemote��ڑ����܂��B
�����āAVisual C#/C++����uF5�v�L�[�������ăv���O�������N�����܂��B�G���[���Ȃ���Ή��̂悤�ȃt�H�[�����N������͂��ł��B
�������̂悤�ȃG���[����������ꍇ��WiiRemote���������ڑ�����Ă��邩�m�F���Ă��������B
�����ɋN���ł����ꍇ�A�uON�v�{�^�����N���b�N����ƁA�o�C�u���[�V������ON�ɂȂ�WiiRemote���U�����܂��B����Ă��������uOFF�v�{�^�����N���b�N���āAWiiRemote�̐U�����Ƃ߂܂��傤�B
�ǂ��ł��傤���H���ɊȒP��WiiRemote�̃o�C�u���[�V��������v���O���������܂����B���̂悤��WiimoteLib��C++/CLI��C#.NET�̑g�ݍ��킹�ŁA�ȒP�ɃA�v���P�[�V�������J�����Ă������Ƃ��ł��܂��B
WiimoteLib�ɂ̓o�C�u���[�^�[�̐���ȊO�ɂ�WiiRemote�����䂷�邽�߂̊������������Ă��܂��B
�ȒP�Ƀv���O�����̗����������܂��ƁA�܂��uConnect()���v��WiiRemote�Ƃ̐ڑ����s���܂��B���̂Ƃ�WiiRemote���������ڑ��A�F������Ă��Ȃ������ꍇ�A��O(Exception)���������܂��B����͗�O�������s���Ă��܂���̂ŁA���ۂ̃A�v���P�[�V�����ł͕K�v�ɉ����ė�O������lj����Ă��������B�{�^�����������Ƃ��ɁA�uSetRumble()���v��WiiRemote�̃o�C�u���[�V�����𐧌䂵�܂��B()�̈����Ɂutrue�v������ƃo�C�u���[�V�������U�����A�ufalse�v������ƃo�C�u���[�V��������~���܂��BPWM����(�p���X���ϒ�:Pulse With Modulation)��p���邱�Ƃɂ���ăo�C�u���[�V�����ɋ����t���邱�Ƃ��ł��܂��B�ȒP�ɐ�������ƍ�����ON��OFF���J��Ԃ����Ƃɂ���ăo�C�u���[�V�����ɋ�������鐧����@�ł��B�����ł͂����Đ������܂��A�]�͂̂���l�̓`�������W���Ă݂Ă��������B
�ȉ��A���̃v���O�����Ŏg����WiimoteLib��API���ł��B
C# | C++ | ��� |
---|---|---|
using WiimoteLib; | using namespace WiimoteLib; | �l�[���X�y�[�X�錾 |
public Wiimote wm; | public: Wiimote^ wm; | �N���X�̐錾 |
wm = new Wiimote(); | Wiimote^ wm = gcnew Wiimote(); | �N���X�V�K�쐬 |
wm.Connect(); | wm->Connect(); | WiiRemote�ɐڑ� |
wm.SetRumble(true); | wm->SetRumble(true); | �o�C�u���[�^�[�쓮 |
wm.SetRumble(false); | wm->SetRumble(false); | �o�C�u���[�^�[��~ |
�������ł��傤�A.NET���ɂ����āAC#��C++�ł͉������̂Ȃ����Ƃ��悭�킩��܂��BGUI�ɂ��t�H�[���쐬���A�}�E�X�h���b�O�ƃv���p�e�B�̐ݒ�A�_�u���N���b�N�ɂ��Y���R�[�h�̎�������������܂��̂Ŕ��ɉ��K�ɃR�[�f�B���O�ł��܂��B���̃X�e�b�v�ł͓����v�̂ŁALED�̓_���𐧌䂵�Ă����܂��B
����WiiRemote��LED����ɂ��ăv���O���~���O���s���Ă����܂��B�����ł́AForm�{�^�����N���b�N���閈��WiiRemote�́u�v���C���[�C���W�P�[�^�[�v�ƌĂ��FLED���J�E���g�A�b�v�����Ă����܂��B
�����ɂ������Ă̊�{�I�ȃv���O���~���O�̗���͑O�߂̃o�C�u���[�^�[�̐���̏ꍇ�Ɠ����ł��B�V�����v���W�F�N�g���쐬���A�v���W�F�N�g�̃N���X�̎Q�Ɛݒ��WiimoteLib��lj����A�ȉ��̏������R�[�h�����������Ă��������B
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; |using WiimoteLib; //WiimoteLib�̎g�p��錾 namespace WindowsFormsApplication1 { //���v���W�F�N�g���ɂ���ĈقȂ� public partial class Form1 : Form { |Wiimote wm = new Wiimote(); //Wiimote�̐錾 |int count=0; //�J�E���g�̐錾 public Form1() { InitializeComponent(); | wm.Connect(); //WiiRemote�ڑ� } } }
#pragma once namespace WLCLED { //���v���W�F�N�g���ɂ���ĈقȂ� using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; | using namespace WiimoteLib; //WiimoteLib�̎g�p��錾 ������ public ref class Form1 : public System::Windows::Forms::Form { | public: Wiimote^ wm; //Wiimote�I�u�W�F�N�gwm�̐錾 | public: int count; //LED�J�E���g�p�̕ϐ�count�̐錾 public: Form1(void) { | wm = gcnew Wiimote(); //Wiimote�C���X�^���X�̍쐬 InitializeComponent(); // //TODO: �����ɃR���X�g���N�^ �R�[�h��lj����܂� // | wm->Connect(); //WiiRemote�ڑ� } protected: ������
�m�F�̂��߂ɂ�����WiiRemote��Bluetooth�ڑ����s���A[F5]�L�[�Ŏ��s�������Ă݂邱�Ƃ������߂��܂��B�R���p�C���G���[��WiimoteLib.dll�̒lj��킷��ȂǁA�����̋̃t�H�[�����\������邾���̏�Ԃł����A�m�F�͑厖�ł��B������A���̏������R�[�h�쐬�܂ł̗��ꉽ�x���s���܂��̂ŁA�J���_�Ŋo���Ă��܂��܂��傤�B
�Ȃ�C++�ł́Aint�^�̕ϐ�count��AWiimote�I�u�W�F�N�g���i�[����wm�̐錾���AForm1�̃C���X�^���X�Ƃ͕ʂɍs���K�v������܂��B�������Ȃ���Α��̃��\�b�h���爵�����Ƃ��ł��܂���B����A�ׂ����Ƃ����C#�ƈႢ���o�Ă��܂��̂Œ��ӂ��Ă��������i�����̂���l�́A�킴�ƊԈႦ�Ă݂�̂����ɂȂ��Ă�����������܂��j�B
����C#/C++�ŋ��ʂ̍�Ƃł��B��قǂ̃o�C�u���[�^�[�̗�Ɠ��l�Ƀt�H�[���uForm1�v�Ƀ{�^����\��t���Ă��������B�{�^�����������ѕ\�����ς��d�g�݂�������܂��̂ŁA�{�^���͏����傫�ځA�����ɂ��Ă����Ɨǂ��ł��傤�B
���ɓ\��t�����ubutton1�v���_�u�����b�N���āA�ȉ��̃R�[�h��lj����܂��B
private void button1_Click(object sender, EventArgs e) { this.button1.Text ="wm.SetLEDs("+ count+") ��\����"; this.wm.SetLEDs(count); count++; }
private: System::Void button1_Click(System::Object^ sender, \ System::EventArgs^ e) { button1->Text = "wm->SetLEDs("+ count +")��\����"; wm->SetLEDs(count); count++; }
�ȏ�ŃR�[�f�B���O�͏I���ł��B���������ꂾ���̃v���O������WiiRemote��LED���䂪�\�ɂȂ�܂��B
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; |using WiimoteLib; namespace WL_LED { public partial class Form1 : Form { | Wiimote wm = new Wiimote(); | int count = 0; public Form1() { InitializeComponent(); | wm.Connect(); } private void button1_Click(object sender, EventArgs e) { | this.button1.Text = "wm.SetLEDs(" + count + ")��\����"; | wm.SetLEDs(count); | count++; } } }
#pragma once namespace WLCLED { //�쐬�����v���W�F�N�g���A���R�B using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; | using namespace WiimoteLib; /// <summary> ������ /// </summary> public ref class Form1 : public System::Windows::Forms::Form { | public: Wiimote^ wm; //Wiimote�I�u�W�F�N�gwm�̐錾 | public: int count; //LED�J�E���g�p�̕ϐ�count�̐錾 public: Form1(void) { | wm = gcnew Wiimote(); InitializeComponent(); // //TODO: �����ɃR���X�g���N�^ �R�[�h��lj����܂� // | wm->Connect(); //WiiRemote�ڑ� } protected: /// <summary> /// �g�p���̃��\�[�X�����ׂăN���[���A�b�v���܂��B /// </summary> ~Form1() { if (components) { delete components; } } private: System::Windows::Forms::Button^ button1; protected: ������ #pragma endregion private: System::Void button1_Click(System::Object^ sender, \ System::EventArgs^ e) { | button1->Text = "wm->SetLEDs("+ count +")��\����"; | wm->SetLEDs(count); | count++; } }; }
�C++�̂ق����R�[�h�������Ȃ�܂����A�����Œlj����ꂽ�ȊO�̉ӏ��̈Ӗ�������C#�ł�C++�ł��A�قړ����ł��邱�Ƃ��킩��܂��B
����ł͑������s���Ă݂܂��傤�B
���ɁAVisual C#/C++��[F5]�L�[�������Ď��s���Ă��������B���s����Ɖ��}�̂悤�ȃA�v���P�[�V�������N�����܂��B
�������}�̂悤�ȃG���[����������ꍇ��WiiRemote���������ڑ�����Ă��邩�m�F���Ă��������B
�t�H�[���ɕ\�������{�^�����N���b�N���Ă����ƁAWiiRemote������LED�����X�ƌ����Ă����܂��B
�u×�v���N���b�N���ďI�����܂��B
LED�̓_���Ə����͂���API�𗘗p���܂��B
SetLEDs(int32 leds);
���̊��̈����uleds�v��int32�`���̐��l�������邱�ƂŁA�Ή�����LED���ω����܂��B���̃v���O�����ł͕ϐ�count�̒l�����uSetLEDs(count);�v�Ƃ��Ă��܂��BForm�ɔz�u���ꂽ�{�^�����N���b�N����ƁAcount�l��+1����Ă����܂��B
�����͐���(int32�`��)�ŗ^���܂����A�����WiiRemote���t���܂ɂ�����Ԃ̊eLED��4�r�b�g��2�i���ŕ\�����āA�e�r�b�g��0����15�܂ő����Ă��������̂ł��B2�i���ɓ���݂��Ȃ����̂��߂ɁA�\�ŕ\�����Ă݂܂����i���������A�����_���ł��j�B
10�i��(int) | LED4 | LED3 | LED2 | LED1 |
---|---|---|---|---|
0 | �� | �� | �� | �� |
1 | �� | �� | �� | �� |
2 | �� | �� | �� | �� |
3 | �� | �� | �� | �� |
4 | �� | �� | �� | �� |
5 | �� | �� | �� | �� |
6 | �� | �� | �� | �� |
7 | �� | �� | �� | �� |
8 | �� | �� | �� | �� |
9 | �� | �� | �� | �� |
10 | �� | �� | �� | �� |
11 | �� | �� | �� | �� |
12 | �� | �� | �� | �� |
13 | �� | �� | �� | �� |
14 | �� | �� | �� | �� |
15 | �� | �� | �� | �� |
�t�H�[����̃{�^�������������āAcount��10�i����16�ɂȂ�ƁALED0�`LED4�̌��͂��ꂼ��0�ɂȂ�LED�͑S�ď����܂����A����ȏ�̒l(17,18,19,...)�������Ă��A�܂����ʃr�b�g�ɒl������܂��̂ŁALED�̓J�E���g�A�b�v���Â��܂��B
�v���O�����ɂ���Ă�2�i����10�i���ł͂Ȃ��A�X��LED���w�肵�Č��点�����Ƃ�������ł��傤�B�����������Ƃ��́A���t�H�[�}�b�g���قȂ�ȉ��̌`���𗘗p���܂��F
SetLEDs(bool led1 ,bool led2 ,bool led3,bool led4);
�������ł��A������4�w�肷�邱�ƂŁA�e�X��LED�𐧌䂷�邱�Ƃ��\�ɂȂ�܂��B(�v���O���~���O�p��ł́A���̂悤�Ȋ��̗��p�̎d�����I�[�o�[���[�h�Ƃ����܂��j
�ȏ��LED�̐���͏I���܂��B���ɃV���v���ł����A�A�C�f�B�A����ł��낢��Ȃ��Ƃ��ł��܂��̂ŁA���Д��z��L���ɂ��ĉ��Ɏg���邩�l���Ă݂Ă��������B�܂����̕\���ɍ��킹���֗��ȏo�͗p��������Ă݂�Ƃ悢�ł��傤�B�Ⴆ�A�M�҂́uSetLEDbyValue(int)�v�Ƃ�����������āA4�i�K�̒l��\���ł���悤�ɂ��܂����B�u���[�X�Q�[���ł̃V�[���h�c�ʁv��u���_���[�W�̕\���v�A���ꂩ�珈���̒i�K��\���v���O���X�o�[�ɂ�LED���g���܂��B
��L�́uSetLEDs�v�̂悤��WiimoteLib�Ɏ�������Ă���API�����ꂼ��̋@�\�́AWiimoteLib�́udocs�v�t�H���_�ɂ���w���v�t�@�C���uWiimoteLib.chm�v���Q�Ƃ��邱�ƂŒT�����Ƃ��ł��܂��B�Ⴆ�A����API���̏ꍇ�͈ȉ��̂悤�ɋL�ڂ���Ă��܂��B
��Wiimote.SetLEDs Method��Overload List
Name | Description | |||
---|---|---|---|---|
SetLEDs(Int32) | Set the LEDs on the Wiimote | |||
SetLEDs(Boolean | Boolean | Boolean | Boolean) | Set the LEDs on the Wiimote |
See Also Wiimote Class Wiimote Members WiimoteLib Namespace
�܂���uSetLEDs()�v�ɂ́A����̂悤��Int32�̒l1�Ŏw�肷������ƁABoolean�܂�_�����邩�ǂ����̐^�U(true/false)��4�Ŏw�肷����@��2��ނ��p�ӂ���Ă���Ƃ������Ƃł��B�ǂ�����������ʂł͂���̂ł����A���̂悤�ɂ��āAWiimoteLib�Ȃǂ�API��������l�͕֗��ɃA�N�Z�X�ł���悤�ɁA��������̋C�̗����������J�����Ă���Ƃ������Ƃł��ˁB���́uSee Also�v�ɂ͏������Ă���N���X����o�[���Ȃǂւ̃����N������܂��B
�킩��Ȃ����Ƃ���������u����ȋ@�\�Ȃ����ȁH�v�Ǝv�����Ƃ��́A���̃w���v�t�@�C�������p���܂��傤�B���̃w���v�t�@�C���̓v���O�����R�[�h���玩����������Ă���悤�ł����A�����@�\�������Ă���AC#��VB�̃R�[�h���܂܂�Ă��āA���ɂȂ�܂��B
���̃X�e�b�v�ł�WiiRemote�̃{�^�����͂ɂ��Ċw�т܂��B�{�^����ON/OFF���擾���āA�t�H�[���ɕ\������V���v���ȃv���O�������쐬���܂��B
�����قǂ܂ł̃v���O�����Ɠ��l�ɁA�V�����v���W�F�N�g���쐬���A�Q�Ɛݒ��WiimoteLib��lj����ď������ł�����A�uForm1�v�Ƀ��x��(Label�R���g���[��)��4�\��t���Ă��������B
����Label�̕����́A��قǃv���O���������珑�������܂��̂Őݒ�͕s�v�ł��B
WiiRemote�̃{�^�����������Ƃ��ɔ�������C�x���g�𗘗p���āA���̃��x����\������l��ύX���邱�ƂŁA���݂̃{�^�����͂̏�Ԃ�\������Ƃ����v�Ńv���O����������Ă����܂��B
Form1.cs(C#)��������Form1.h(C++)�Ɉȉ��̕�����lj����܂��B
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; |using WiimoteLib; //WimoteLib�̎g�p��錾 namespace WiimoteLib_Sample //���쐬�����v���W�F�N�g�� { public partial class Form1 : Form { | Wiimote wm = new Wiimote(); //Wiimote�N���X���쐬 public Form1() { | Control.CheckForIllegalCrossThreadCalls = false; //���܂��Ȃ� InitializeComponent(); | wm.WiimoteChanged += wm_WiimoteChanged; //�C�x���g���̓o�^ | wm.Connect(); //WiiRemote�Ɛڑ� } | //Wii�����R���̒l���ω������Ƃ��ɌĂ��� | void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args) | { | WiimoteState ws = args.WiimoteState; //WiimoteState�̒l���擾 | this.DrawForms(ws); //�t�H�[���`�ʊ��� | } | //�t�H�[���`�ʊ� | public void DrawForms(WiimoteState ws) | { | this.label1.Text = "Button A:" + (ws.ButtonState.A); //�{�^��A | this.label2.Text = "Button B:" + (ws.ButtonState.B); //�{�^��B | this.label3.Text = "Button 1:" + (ws.ButtonState.One);//�{�^��1 | this.label4.Text = "Button 2:" + (ws.ButtonState.Two);//�{�^��2 | } } }
#pragma once namespace WiimoteLib_Sample { //���쐬�����v���W�F�N�g�� using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; | using namespace WiimoteLib; //WimoteLib�̎g�p��錾 /// <summary> ������ /// </summary> public ref class Form1 : public System::Windows::Forms::Form { | public: Wiimote^ wm; //Wiimote�I�u�W�F�N�gwm���쐬 public: Form1(void) { | Control::CheckForIllegalCrossThreadCalls = false; //���܂��Ȃ� | wm = gcnew Wiimote(); //Wiimote�N���X���쐬 InitializeComponent(); | //�C�x���g���̓o�^ | wm->WiimoteChanged += | gcnew System::EventHandler<WiimoteChangedEventArgs^>( | this, &Form1::wm_WiimoteChanged); | wm->SetReportType(InputReport::Buttons, true); //���|�[�g�^�C�v�̐ݒ� | wm->Connect(); //WiiRemote�Ɛڑ� | } public: | void wm_WiimoteChanged(Object^ \ sender,WiimoteLib::WiimoteChangedEventArgs^ args){ | WiimoteState^ ws; | ws = args->WiimoteState; | this->DrawForms(ws); | } | public: void DrawForms(WiimoteState^ ws) { | this->label1->Text = "Button A:" + (ws->ButtonState.A); | this->label2->Text = "Button B:" + (ws->ButtonState.B); | this->label3->Text = "Button 1:" + (ws->ButtonState.One); | this->label4->Text = "Button 2:" + (ws->ButtonState.Two); | } protected: ������
���āA���s���Ă݂܂��傤�B�܂����g����Bluetooth�X�^�b�N����AWiiRemote��Bluetooth��PC�ɐڑ����܂��B�ڑ����m�F�ł�����AVisual C#/C++���[F5]�L�[�������Ď��s���܂��B�R���p�C�����Ƃ���A���������s�����Ɖ��}�̂悤�ȃA�v���P�[�V�������N�����܂��B���������ŃG���[����������ꍇ�A�قƂ�ǂ�Bluetooth�ڑ������܂��ڑ�����Ă��Ȃ��P�[�X�ł��BWiiRemote���������ڑ�����Ă��邩�m�F���Ă��������B
WiiRemote��A�{�^�������������܂��B
�t�H�[����́uLabel1�v�̉ӏ��ɁuButton A: True�v�ƕ\�������ΐ����ł��B�����WiiRemote�̂��ׂẴ{�^�������𗣂��āA���ׂẴ{�^���������Ȃ���Ԃɂ����Ƃ��A�t�H�[����̃{�^���̃X�e�[�^�X��\���\�����S�āuFalse�v�ɂȂ�ΐ����ł��B
WiiRemote��A�{�^����B�{�^�����ɉ�������ł݂܂��B
�Ō�ɁAWiiRemote��1�{�^����2�{�^�����ɉ�������ł݂܂��B
��ʂ�̎������I�������A�}�E�X�Łu×�v���N���b�N���邩�A�L�[�{�[�h����[Alt+F4]�������āA�v���O�������I�������܂��B
Wii�����R���̃{�^����ON/OFF�ɂ����Form�̃��x����ω������Ă��܂��BFalse��OFF(��𗣂������), True��ON(����)�ɑΉ����Ă��܂��B�ȉ��A���p����API����������܂��B
[C#] wm.WiimoteChanged += wm_WiimoteChanged; [C++] wm->WiimoteChanged += gcnew System::EventHandler<WiimoteChangedEventArgs^>( this, &Form1::wm_WiimoteChanged);
WiiRemote�̃{�^���������ꂽ�A�����x�Z���T�[�̒l���ς�����A�ȂǁA��Ԃɕω����������Ƃ��ɌĂ�����o�^���Ă��܂��B�v���O���~���O�p��Łu�R�[���o�b�N���v�Ƃ����A������o�^���邱�ƂŁA���̃C�x���g�����������Ƃ��Ɏ����I�ɂ��̊������s�����悤�Ɍ��߂�ꂽ���@�Ŏw�肵�܂��B�����ł́AWiiRemote�̃{�^����Ԃɕω����������ꍇ�uwm_WiimoteChanged�v�Ƃ��������Ă��悤�ɐݒ肵�Ă��܂��B�J�b�R������Ȃǂ͂��炩���ߋK�肳�ꂽ�`���ɉ����Ă��܂��̂ŁA������n�������ł����ł悢�̂ł�(C++�̃R�[�h�����������̂͂��̂��߂ł�)�B
[C#] WiimoteState ws = args.WiimoteState; [C++] WiimoteState^ ws; ws = args->WiimoteState;
������Wii�����R���̃X�e�[�^�X(���)��ws�Ƃ������O��"�C�����m"�ɂƂ肱��ł��܂��B�����ɂ͂����Ŏg���Ă���WiimoteState�̓N���X�ł����A���̖��O����z���ł���悤�ɁA�C�x���g�Ŕ��������{�^���Ȃǂ̒l����荞�܂�܂��B�ȉ��A�g���������Ă݂܂��傤�B
[C#] this.label1.Text = "Button A: " + (ws.ButtonState.A); [C++] this->label1->Text = "Button A:" + (ws->ButtonState.A);
WiiRemote��A�{�^���̒l��label1�ɕ\�����Ă��܂��B�{�^����������Ă�����ATrue��\�����܂��B�{�^����������Ă�����AFalse��\�����܂��B���ۂɂ́uws.ButtonState.A�v���Ӗ�����l��True��False�Ƃ����^�U�̒l�ł����A�������ulabel1.Text�v�Ȃ̂Ŏ����I�ɕ�����ɕϊ�����Ă��܂�(.ToString()����K�v�͂Ȃ�)�B
���l�Ɂuws.ButtonState.b�v�ȂǂƂ��邱�Ƃ�WiiRemote��B�{�^���A���̑��S�Ẵ{�^���̏�Ԃ��擾���邱�Ƃ��ł��܂��B
�ǂ��ł��傤�H�Ƃ��Ă��ȒP�ł��ˁI���̃C�x���g�̃R�[���o�b�N���ŃX�e�[�g���擾������@�͑��̂��낢��ȓ��͂ɉ��p�ł��܂��B�������A���̊��������R�[���o�b�N�̎d�g�݂��ȒP�ɗ��p�ł���w�i�ɂ́A�l�X�ȕ��G�ȃv���O���~���O�̓����̋Z�p������܂��B���̓t�H�[���̃R���X�g���N�^�ŁA1�����A���܂��Ȃ������Ă��܂����B
[C#] Control.CheckForIllegalCrossThreadCalls = false; [C++] Control::CheckForIllegalCrossThreadCalls = false;
�]�T�̂���l�́A���̍s���R�����g�A�E�g���āA���s���Ă݂Ă��������B�Ȃ������s���Ƀ{�^���������ƃG���[���o�Ă��܂��܂��B����́A�}���`�X���b�h(�X���b�h;Thread�������̗���)�Ɋւ����ł��B��̃{�^���̏�Ԃ�ǂݍ���WiimoteLib�̃X���b�h�ƁA�t�H�[���̏����������s���X���b�h�����ꂼ��قȂ�̂Łu�X���b�h�Z�[�t�łȂ��v�܂�A�����̃X���b�h�ɂ����鏈���̏����Ȃǂ��ۏł��Ȃ����ߎ��s���G���[�ɂȂ��Ă��܂��܂��BWiimoteLib�̌����ŏЉ��Ă�����@�ŁA
//Wii�����R���̒l���ω������Ƃ��ɌĂ���[C#] void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args){ WiimoteState ws = args.WiimoteState; //WiimoteState�̒l���擾 if (this.IsHandleCreated) { this.Invoke( (MethodInvoker)delegate() { this.DrawForms( ws ); //�t�H�[���`�ʊ��� }); } }
���̂悤�ɁAInvoke()�Ƃ������\�b�h���g�����@������܂����A������Ə��S�҂ɂ͕s���Ăȏ������ł��B�����N���Ă��āA�ǂ�ȃ��X�N�����邩(�t�H�[���̏����������X���b�h�Z�[�t�łȂ��㏑�������)�Ƃ������Ƃ��킩���Ă���Ȃ�
Control.CheckForIllegalCrossThreadCalls=false;
�Ƃ��āA�s���ȃX���b�h�ԃR�[���̃`�F�b�N�����Ȃ��A�Ɛ錾������@������̂ŁA�{�͂ł́u���܂��Ȃ��v�Ƃ��ĈȌケ�̕��@���̗p���邱�Ƃɂ��܂��B
������WiimoteState�ŎQ�Ƃł��郁���o�[��\�ŏЉ�Ă����܂��B
���� | ��� |
---|---|
AccelCalibrationInfo | ���݂̉����x�Z���T�[�̃L�����u���[�V������� |
AccelState | ���݂̉����x�Z���T�[�̏�� |
BalanceBoardState | ���݂�WiiFit�o�����X�{�[�h�̏�� |
Battery | �Z�o���ꂽ���݂̃o�b�e���[���x�� |
BatteryRaw | ���݂̃o�b�e���[���x���̌v�Z�O�̒l(���l) |
ButtonState | ���݂̃{�^���̏�� |
ClassicControllerState | ���݂̊g���N���V�b�N�R���g���[���[�̏�� |
DrumsState | ���݂̊g���h�����R���g���[���[�̏�� |
Extension | �g���R���g���[���[���}������Ă��邩 |
ExtensionType | �g���R���g���[���[���}������Ă���ꍇ���̎�� |
GuitarState | ���݂�GuitarHero�g���M�^�[�R���g���[���[�̏�� |
IRState | ���݂̐ԊO���Z���T�[�̏�� |
LEDState | ���݂�LED�̏�� |
NunchukState | ���݂̊g���k���`���N�R���g���[���[�̏�� |
Rumble | ���݂̃o�C�u���[�^�[�̏�� |
WiimoteLib�ɂ͎��ɗl�X�Ȋg���R���g���[���[����������Ă���A���̃����o�[�����Ԃ��擾�ł��邱�Ƃ��킩��܂��B�����̒l��\�b�h�Ȃǂ́AVisual Studio��Intellisense�@�\���g���Ăǂ�ǂ���������Ă����܂��傤�B��قǂ̃{�^���̗�Ȃǂ��A�uws.ButtonState.�v�Ɓu.�v���������u�Ԃɂ͐������W�L�̑I����������܂��B�{�^���̖��̂Ȃǂ͂��������o���Ă����܂���̂ŁA���ɕ֗��ł��B�Ȃ�Intellisense��Ctrl+Space�ł��ł��ǂ��ł��Ăяo���܂��B�S�ẴO���[�o���ȃI�u�W�F�N�g���\������܂��B��������Ɏg���Ƃ悢�ł��傤�B
���āA����܂�WiimoteLib���g���āA��{�I�ȓ��o�͂��w��ł��܂����B���̂�����ŁA���p�I�ȃv���O�����̗�Ƃ��āu�����`���[�v���쐬���Ă݂܂��傤�B�{�^�����������тɁAWindows�̃A�N�Z�T���u�������v��u�d��v�ȂNJO���v���O�������N������v���O�����ł��B
�O�߂́u�{�^���C�x���g�̎擾�v�Ɗ�{�͓����ł��BWiimoteLib�̐錾���s���A�R�[���o�b�N�����ŊO���v���O�������N��������A�A�v���P�[�V�������g���I���������肵�܂��B
�V�����v���W�F�N�g���쐬���AWiimoteLib���Q�Ƃɒlj����AForm1���E�N���b�N���āu�R�[�h��\���v���A���̃R�[�h���L�q���܂��B�O�߂̃v���O�����̉�������n�߂Ă��ǂ��ł��傤�B
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; |using WiimoteLib; //WimoteLib�̎g�p��錾 namespace WL_Launcher { public partial class Form1 : Form { | Wiimote wm = new Wiimote(); //Wiimote�N���X���쐬 public Form1() { | Control.CheckForIllegalCrossThreadCalls = false; //���܂��Ȃ� InitializeComponent(); | wm.WiimoteChanged += wm_WiimoteChanged; //�C�x���g���̓o�^ | wm.Connect(); //WiiRemote�Ɛڑ� } | //Wii�����R���̒l���ω������Ƃ��ɌĂ��� | void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args) | { | WiimoteState ws = args.WiimoteState; //WiimoteState�̒l���擾 | //A�{�^���������ꂽ�烁�������N�� | if (ws.ButtonState.A == true) | { | System.Diagnostics.Process.Start("notepad.exe"); | } | //B�{�^���������ꂽ��d����N�� | if (ws.ButtonState.B == true) | { | System.Diagnostics.Process.Start("calc.exe"); | } | //HOME�{�^���������ꂽ�炱�̃A�v�����I�� | if (ws.ButtonState.Home == true) | { | Environment.Exit(0); | } | } } }
#pragma once namespace WLCLauncher { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; | using namespace WiimoteLib; //WimoteLib�̎g�p��錾 public ref class Form1 : public System::Windows::Forms::Form { | public: Wiimote^ wm; //Wiimote�I�u�W�F�N�gwm���쐬 public: Form1(void) { | Control::CheckForIllegalCrossThreadCalls = false; //���܂��Ȃ� | wm = gcnew Wiimote(); //Wiimote�N���X���쐬 InitializeComponent(); | //�C�x���g���̓o�^ | wm->WiimoteChanged += | gcnew System::EventHandler<WiimoteChangedEventArgs^>( | this, &Form1::wm_WiimoteChanged); | wm->SetReportType(InputReport::Buttons, true); //���|�[�g�^�C�v�̐ݒ� | wm->Connect(); //WiiRemote�Ɛڑ� | } public: void wm_WiimoteChanged(Object^ sender,WiimoteLib::WiimoteChangedEventArgs^ \ args){ | WiimoteState^ ws; | ws = args->WiimoteState; | //A�{�^���������ꂽ�烁�������N�� | if (ws->ButtonState.A) { | System::Diagnostics::Process::Start("notepad.exe"); | } | //B�{�^���������ꂽ��d����N�� | if (ws->ButtonState.B) { | System::Diagnostics::Process::Start("calc.exe"); | } | //HOME�{�^���������ꂽ�炱�̃A�v�����I�� | if (ws->ButtonState.Home) { | Environment::Exit(0); | } | } ���ȉ�����
�܂��́A�����ʂ�WiiRemote��ڑ����Ă��������B������Visual Studio��[F5]�L�[�������āA�쐬�����v���O���������s���܂��B���������ŃG���[����������ꍇ��WiiRemote���������ڑ�����Ă��邩�m�F���Ă��������B
WiiRemote��A�{�^���������ƁA���������N�����AB�{�^���������ƁA�d�삪�N�����܂��B
WiiRemote��B�{�^���𐔉��ƁA�����������A�d�삪�N�����܂��B
WiiRemote��Home�{�^���������ƁA�����`���[�v���O�������I�����܂��B
���̃v���O�����́unotepad.exe�v��ucalc.exe�v���D���ȊO���v���O�����ɏ���������A���ł��N���ł���Ƃ����킯�ł��ˁB�Ȃ����낢��Ȃ��Ƃ��ł������ł��B�y�����Ȃ��Ă��܂��H
WiiRemote�̃{�^����������邱�Ƃɂ���Đݒ肵���A�v���P�[�V�������N�����邽�߂ɂ́A��قǂ̃v���O������DrawForm()�ŏ��������悤�ȁA���x���̃e�L�X�g���������������ɁA.NET�ŗp�ӂ���Ă���d�g�݂𗘗p���āA�O���v���O�������N�����܂��B
if (ws.ButtonState.A == true) { //A�{�^���������ꂽ�烁�������N�� System.Diagnostics.Process.Start("notepad.exe"); }
�uSystem.Diagnostics.Process.Start()�v�ɂ��Ă͂��낢��ȉ��p������܂��B�e�L�X�g�t�@�C���Ȃǂ��w�肷�邱�ƂŊ֘A�Â���ꂽ�v���O�������g���ĊJ�����ƂȂǂ��\�ł��B�ڂ����̓C���^�[�l�b�g�Ō��J����Ă���.NET Framework�N���X���C�u�����̃}�j���A����uProcess.Start�v���L�[���[�h�Ɍ������Ă݂�Ɨǂ��ł��傤�B
�ȏ�́AC#�ł̋L�q�ł����AC++/CLI�ł��S����a���Ȃ��݊������ۂ���Ă��܂��BC++��Home�{�^���������ďI������ӏ��̃R�[�h�����Ă݂܂��傤�B
//HOME�{�^���������ꂽ�炱�̃A�v�����I�� if (ws->ButtonState.Home) { Environment::Exit(0); }
�ȏ�̂悤�ɁuEnvironment::Exit(0);�v�ŁA�������g�̃A�v���P�[�V�������I���ł��܂��B
���āA����ȕ֗��ȃR�[�����o����ƁA�����`���[�ŋN�������v���O�����̏I���Ȃǂ�����Ă݂����Ȃ�Ǝv���܂��B
���̐�̐ԊO���|�C���^��p���ă}�E�X���쐬�������w�K���Ă���A����ɍ��@�\�ɉ������Ă݂�Ƃ悢�ł��傤�B
���́AWiiRemote�̉����x�Z���T�[���g�����v���O���~���O���������Ă����܂��B2�͂ʼn�������Ƃ���AWiiRemote�ɂ�X���AY���AZ���ɑΉ�����3���̉����x�Z���T�[����������Ă��܂��B
WiiRemote�ɓ������ꂽ3���}�C�N�������x�Z���T�[�́A���ꂼ��̎��ɑ���8bit�A�܂�0�`255�̒l�������܂��B���̃Z�N�V�����ł́A�܂��l���Ƃ��v���O�������쐬���A���̌�A���p�A�v���P�[�V�����̊J����ʂ��āA�����x�Z���T�[�̊�{�I�ȗ��p�ɒ��킵�܂��B
�����ł́A�܂���n�߂ɁAWiiRemote�̉����x���擾����v���O�������쐬���܂��B��قǂ܂łƓ��l�AVisual Studio(C#/C++�ǂ���ł����܂��܂���I)�ŁA�V�����v���W�F�N�g���쐬���A�Q�ƂɁuWiimoteLib�v��lj����܂��B�����I�ɐ�������Ă���t�H�[���uForm1�v�ɁA�c�[���{�b�N�X���烉�x��(Label)��3�\��t���Ă��������B�����ɉ����x�Z���T�[X,Y,Z�̃��A���^�C������l��\�����܂��B
�����ăR�[�f�B���O�ł��BForm1���E�N���b�N���āu�R�[�h��\���v���āA�ȉ��̃v���O�����̃R�����g�A�E�g���Ă���ӏ������������Ă����܂�(�����������ꂽ�R�����g�s�͊������Ă��܂�)�B�܂��`����using��ɂ��N���X�̐錾�ł����A�ŏ����K�v�ȕ��݂̂ɂ��Ă��܂��B
using System; using System.Windows.Forms; | using WiimoteLib; //WimoteLib�̎g�p��錾 namespace WL_Accel { public partial class Form1 : Form { | Wiimote wm = new Wiimote(); //Wiimote�N���X���쐬 public Form1() { | Control.CheckForIllegalCrossThreadCalls = false; //���܂��Ȃ� InitializeComponent(); | wm.WiimoteChanged += wm_WiimoteChanged; //�C�x���g���̓o�^ | wm.SetReportType(InputReport.ButtonsAccel, true); //���|�[�g�^�C�v�̐ݒ� | wm.Connect(); //WiiRemote�Ɛڑ� } | //Wii�����R���̒l���ω������Ƃ��ɌĂ��� | void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args) { | WiimoteState ws = args.WiimoteState; //WiimoteState�̒l���擾 | this.DrawForms(ws); //�t�H�[���`����� | } | //�t�H�[���`��� | public void DrawForms(WiimoteState ws) { | this.label1.Text = "X��:" + (ws.AccelState.Values.X); | this.label2.Text = "Y��:" + (ws.AccelState.Values.Y); | this.label3.Text = "Z��:" + (ws.AccelState.Values.Z); | } } }
#pragma once namespace WLCAccel { using namespace System; using namespace System::Windows::Forms; | using namespace WiimoteLib; //WimoteLib�̎g�p��錾 public ref class Form1 : public System::Windows::Forms::Form { | public: Wiimote^ wm; //Wiimote�I�u�W�F�N�gwm���쐬 public: Form1(void) { | Control::CheckForIllegalCrossThreadCalls = false; //���܂��Ȃ� | wm = gcnew Wiimote(); //Wiimote�N���X���쐬 InitializeComponent(); | //�C�x���g���̓o�^ | wm->WiimoteChanged += | gcnew System::EventHandler<WiimoteChangedEventArgs^>( | this, &Form1::wm_WiimoteChanged); | wm->SetReportType(InputReport::ButtonsAccel, true); //���|�[�g�^�C�v�̐ݒ� | wm->Connect(); //WiiRemote�Ɛڑ� } | public: | void wm_WiimoteChanged(Object^ \ sender,WiimoteLib::WiimoteChangedEventArgs^ args){ | WiimoteState^ ws; | ws = args->WiimoteState; | this->DrawForms(ws); | } | public: | void DrawForms(WiimoteState^ ws) { | this->label1->Text = "X��:" + (ws->AccelState.Values.X); | this->label2->Text = "Y��:" + (ws->AccelState.Values.Y); | this->label3->Text = "Z��:" + (ws->AccelState.Values.Z); | } ���ȉ�����
����ł͎������Ă݂܂��傤�B�܂�WiiRemote�����g����Bluetooth�X�^�b�N�Őڑ����Ă��������B
����Visual Studio���[F5]�L�[�������Ď��s���Ă��������B�������v���O������������Ă��炸�A�G���[�Ȃǂ��o��ꍇ�͂悭�m�F���āA�C�����Ă��������B
�t�H�[�����\�����ꂽ��AWiiRemote��U��܂킵�Ă݂Ă��������B���̂Ƃ��A���q�ɏ���ĐU������Ĕ��ł����Ɗ댯�Ȃ̂ŁA��U�肷��Ƃ��͕K���X�g���b�v�����Ă��������B
�t�H�[���ɒ���t�����A�����x��X,Y,Z�̒l���f���������Ă��邱�Ƃ��킩��܂��B
�y���Ӂz�N������3�̒l���[���̂܂܂������ꍇ�A��U�쐬�����A�v���P�[�V�������I�������āAWiimoteLib�̃T���v���uWiimoteTest.exe�v�����s���Ă݂Ă��������B��x���̃T���v�����N�����Ă���A����쐬�����A�v���P�[�V�������N������ƒl���Ƃ�邱�Ƃ�����܂�(�G���[�����⏉�����J�ɂ��Ă��Ȃ����炩������܂���)�A�s����������Ƃ��͎����Ă݂Ă��������B
�܂��A�I�����ɁuDispose�v�Ɋւ���G���[���o��Ƃ�������܂����A��������܂̂Ƃ��떳�����Ă��܂��܂���B
WiiRemote��3���̉����x�Z���T�[�̃��A���^�C���l��\�����܂����B
[C#] wm.SetReportType( InputReport.ButtonsAccel, true); [C++] wm->SetReportType(InputReport::ButtonsAccel, true);
���|�[�g�^�C�v�A���Ȃ킿�C�x���g���N�����Ƃ��ɕ���悤��WiiRemote�ɂ��肢����u��ށv�������Őݒ肵�Ă��܂��B�uButtonsAccel�v�͉����x�Z���T�[�ƃ{�^���C�x���g���擾���Ă��܂��B
[C#] ws.AccelState.Values.X [C++] ws->AccelState.Values.X
WiiRemote�ɓ������ꂽ�����x�Z���T�[�e���̐��l��float�Ŏ擾���܂��B
[C#] Control.CheckForIllegalCrossThreadCalls = false; [C++] Control::CheckForIllegalCrossThreadCalls = false;
�O��Ɠ������A�ʂ̃X���b�h����t�H�[�������������邱�Ƃ������܂��B
���|�[�g�^�C�v�ɁuButtonsAccel�v���w�肵�Ă���̂ŁA���̏�ԂŃ{�^���C�x���g�Ȃǂ��擾�ł��܂��B�]�͂̂���l�͎����Ă݂܂��傤�B�����āA���ۂɂǂꂾ���̒l���o�͂���邩�������Ă݂܂��傤�B�u���u���U���Ă݂�ƁA�����ł�������±5���x�̒l���v������܂��BWiiRemote��������ƁAX,Z�Ȃ�2�̒l�̓[���ɂȂ�܂����A�����ЂƂ̎��A���Ƃ���Y���ɂ͂��Ȃ炸±0.9���x�̒l���c��܂��B
����͉��ł��傤�c�c�H�����ł��A�d�͉����x�ł��I���i�͖ڂɌ����Ȃ��d�͉����x��ڂŌ��邱�Ƃ��ł��܂��B
�u���|�[�g�^�C�v�v�Ƃ�WiiRemote�ɖ₢���킹����Ƃ��̃��[�h�̂��ƂŁA���̃��|�[�g�^�C�v�ɂ���āAWiiRemote���Ԃ��Ԏ����قȂ�܂��B
WiimoteLib1.7�ł�InputReport���ňȉ��̃��|�[�g�^�C�v����`����Ă���悤�ł��B
���|�[�g�^�C�v�́A�f�[�^�̃t�H�[�}�b�g��ݒ肷��ړI�̑��ɂ��A���肠��ʐM�ш�⏈�����x���œK�ɐݒ肷��ړI������悤�ł��B��L��WiimoteLib�Ŏ�������Ă��郌�|�[�g�^�C�v�ȊO�ɂ��A�킩���Ă��邾���ł��A�{�^���݂̂̓��o�͂���A�����x�Z���T�[3��A�k���`���N�t��6��A�ԊO���t�����ǂ����A�Ƃ�������荂���ŃV���v���ȓ��o�̓��[�h����A��������̒l�����Ƃ肷�郂�[�h�܂ŁA�e�푵���Ă��܂��B�܂��ԊO���Z���T�[�ɂ��Ă��A�ő�4�_�܂ň����郂�[�h�ɑ���2�_�������[�h�ȂǁA�B�����[�h�I�ȃ��|�[�g�^�C�v�����݂���悤�ł�(WiimoteLib�ł�4�_�̂݃T�|�[�g���Ă��܂�)�B
��������WiiRemote�̓����̂ЂƂł�������x�Z���T�[�̒l���擾�ł���悤�ɂȂ����̂Łu���ۂ��ǂ��v������Ă݂܂��傤�B���ۂƌĂԂɂ͑傰����������܂��A�����x�Z���T�[�ɓ��͂��ꂽ����������苭���Ȃ��...���Ƃ��ΐ�قǂ̎�����±5���x�̒l������ł��܂����̂ŁA���̒l�����ꍇ�ɁAWAV�t�@�C�����Đ����邱�Ƃɂ��܂��B
��قǂ̉����x�Z���T�[���g���v���O�����̑�������n�߂�Ɨǂ��ł��傤�B�t�H�[���uForm1�v�̃R�[�h��\�����āA�ȉ��̂悤�ɒNjL���܂��B
using System; using System.Windows.Forms; | using WiimoteLib; //WimoteLib�̎g�p��錾 | using System.Media; //System.Media�̐錾 namespace WL_Taiko { public partial class Form1 : Form { | Wiimote wm = new Wiimote(); //Wiimote�N���X���쐬 | string path = null; //Wav�t�@�C���� | SoundPlayer wavePlayer; //SoundPlayer��錾 public Form1() { InitializeComponent(); | wm.WiimoteChanged += wm_WiimoteChanged; //�C�x���g���̓o�^ | wm.SetReportType(InputReport.ButtonsAccel, true); //���|�[�g�^�C�v�̐ݒ� | wm.Connect(); //WiiRemote�Ɛڑ� | path = @"C:\WINDOWS\Media\chord.wav"; //�Đ�����WAV�t�@�C�����w�� | wavePlayer = new SoundPlayer(path); //�v���C���[��WAV�t�@�C����n�� } | //Wii�����R���̒l���ω������Ƃ��ɌĂ��� | void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args) { | WiimoteState ws = args.WiimoteState; //WiimoteState�̒l���擾 | //WAV�t�@�C�����ǂݍ��܂�Ă��邩�m�F | if (this.path != null) { | float AX = Math.Abs(ws.AccelState.Values.X); //X���̐�Βl | float AY = Math.Abs(ws.AccelState.Values.Y); //Y���̐�Βl | float AZ = Math.Abs(ws.AccelState.Values.Z); //Z���̐�Βl | //X,Y,Z���̉����x�Z���T�̐�Βl�̍��v��5���鎞�ɁA�U�����Ɣ��� | if ((AX+AY+AZ) >= 5) { | wavePlayer.PlaySync(); //����炷 | } | } | } } }
#pragma once namespace WLCTaiko { using namespace System; using namespace System::Windows::Forms; | using namespace WiimoteLib; //WimoteLib�̎g�p��錾 | using namespace System::Media; //System.Media�̐錾 public ref class Form1 : public System::Windows::Forms::Form { | public: Wiimote^ wm; //Wiimote�I�u�W�F�N�gwm���쐬 | public: String^ path; //WAV�t�@�C���p�X�i�[�p | public: SoundPlayer^ wavePlayer; //SoundPlayer��錾 public: Form1(void) { | wm = gcnew Wiimote(); //Wiimote�N���X���쐬 InitializeComponent(); | //�C�x���g���̓o�^ | wm->WiimoteChanged += | gcnew System::EventHandler<WiimoteChangedEventArgs^>( | this, &Form1::wm_WiimoteChanged); | wm->SetReportType(InputReport::ButtonsAccel, true); //���|�[�g�^�C�v�̐ݒ� | wm->Connect(); //WiiRemote�Ɛڑ� | path ="C:\\WINDOWS\\Media\\achord.wav"; //�Đ�����WAV�t�@�C�����w�� | wavePlayer = gcnew SoundPlayer(path); //�v���C���[��WAV�t�@�C����n�� } public: void wm_WiimoteChanged(Object^ sender,WiimoteLib::WiimoteChangedEventArgs^ \ args){ | WiimoteState^ ws; | float AX, AY, AZ; | ws = args->WiimoteState; | if (this->path!=nullptr) { | AX = Math::Abs(ws->AccelState.Values.X); //X���̐�Βl | AY = Math::Abs(ws->AccelState.Values.Y); //Y���̐�Βl | AZ = Math::Abs(ws->AccelState.Values.Z); //Z���̐�Βl | //X,Y,Z���̉����x�Z���T�̐�Βl�̍��v��5���鎞�ɁA�U�����Ɣ��� | if ((AX+AY+AZ)>=5) { | wavePlayer->PlaySync(); //����炷 | } | } | } ���ȉ�����
Visual C#��[F6]�AVisual C++��[F7]�L�[�������ăR���p�C���G���[���Ȃ����ƂȂǂ��m�F������ABluetooth�X�^�b�N����WiiRemote��ڑ����Ă�������(�ؒf����Ă��Ȃ�����̂܂ܑ��s���Ă��܂��܂���)�B
Visual Studio��[F5]�L�[�������Ď��s���Ă��������B�����ɃG���[�Ȃ����s�����ƁA�t�H�[�����\������܂��B���̃t�H�[���͍���g�p���܂��AWiiRemote��U���Ă݂�ƁA�U��ɍ��킹�āA�Ȃ��������������Ƃ̂��鉹����܂��B
WiiRemote��3���̉����x�Z���T�̒l���擾���āA�w�肵�������x�����o����Ǝw�肵��WAV�t�@�C����炵�܂��B
[C#] path = @"C:\WINDOWS\Media\achord.wav"; [C++] path ="C:\\WINDOWS\\Media\\achord.wav";
���́u@�v�́u@-quoted string�v�Ƃ����āA���ꂪ�擪�ɒ����Ă��镶����́u\�v���o�b�N�X���b�V�������ȕ����Ƃ��Ăł͂Ȃ��A�t�@�C���p�X�Ƃ��ĊȒP�ɏ����ł��܂��BC++�ɂ͂���ɊY������W�L���Ȃ��悤�Ȃ̂Łu\\�v�Ƃ��āu\�v����ʂ�1�����Ƃ��Ĉ����Ă��܂��B
���Ă����ōĐ�����t�@�C�����w�肵�Ă��܂��B�炵����WAV�t�@�C�����w�肵�Ă��������B���̃v���O�����ł�Windows�ɗp�ӂ��ꂽWAV�t�@�C���Ƃ��āAWindows�̃V�X�e���ɍŏ���������Ă���WAV���w�肵�܂������A�����g�ŗp�ӂ��ꂽ���y����ʉ����w�肵�Ă��ǂ��ł��傤�B
[c#] float AX = Math.Abs(ws.AccelState.Values.X); //X���̐�Βl [c++] AY = Math::Abs(ws->AccelState.Values.Y); //Y���̐�Βl
WiiRemote��X,Y,Z���̒l���擾���A���̐�Βl���Ƃ�܂��B
//X,Y,Z���̉����x�Z���T�̐�Βl�̍��v��5���鎞�ɁA�U�����Ɣ��� if ((AX+AY+AZ)>= 5) { wavePlayer.PlaySync(); }
X,Y,Z���̉����x�̐�Βl�̘a��[5]����Ɖ���炷�Ƃ́A�����ɂ��ȒP�ł��B����[5]�Ƃ����l���A����������Ώ��Ȃ�����Ŕ������܂��B���ɑ��₹�A�傫������Ŕ������܂��B�����̍D�݂̐����ɒu�������Ă݂āA�������Ă݂Ă��������B�Ȃ�����́A�����Đ�����WiiRemote��U���Ă��������܂���(�Đ����ɂ�����A���Đ��������ꍇ�̓X���b�h�����Ȃǂ�p����K�v������܂�)�B
���āA�����x�Z���T�[���Ђƒʂ�g�����Ȃ������Ƃ́A�ԊO���Z���T�[�ɒ��킵�Ă݂܂��傤�B�ԊO���͐l�Ԃ̖ڂŌ��邱�Ƃ��ł��܂���B�������ŏ��ɍ쐬����v���O�����u�ԊO���T�m�@�v�́A�ԊO����WiiRemote�̎��E�ɂ͂���ƁA�o�C�u���[�^�[��炷���Ƃ��ł��܂��B���ɍő�4�_�̐ԊO���������J�E���g���A���̌��ʂ�LED�ɕ\������v���O���������܂��B����ɂ�������p���A�O���t�B�b�N�X�ɑg�ݍ��ފ�b���w�сA�Ō�ɐԊO���Z���T�[���g�����}�E�X����v���O�������X�e�b�v��ǂ��ĊJ�����Ă����܂��B�ڂɌ����Ȃ��ԊO�����A�ƂĂ��ʔ�������`���郁�f�B�A�ɂȂ邱�Ƃ�̊����Ă����܂��傤�I
�����v���O���~���O���n�߂܂��傤�B������O��ɍ쐬���������x�Z���T�[�̃v���O���������҂��Ă��悢�̂ł����A�V�K�ō��ق������ɂȂ��Ă悢�ł��傤�B�\�����[�V������V�����쐬����K�v�͂Ȃ��A�\�����[�V�������E�N���b�N���āu�lj��v���u�V�����v���W�F�N�g�v�ŐV�����v���W�F�N�g��(�����ł́uIR1�v)��^���āA�v���W�F�N�g���ł�����������A�v���W�F�N�g���E�N���b�N���āu�X�^�[�g�A�b�v�v���W�F�N�g�ɐݒ�v���A�Q�Ɛݒ��WiimoteLib��lj����܂��B���̃v���W�F�N�g�̃R�[�h��t�H�[�����ԈႦ�ĕҏW���Ȃ��悤�A��U�J���Ă���\�[�X�R�[�h�̃E�B���h�E�����ׂĕ��܂��B����ŏ����͂ł�������ł��B����m�F�̂��߂�[F5]�L�[�������Ď��s���Ă݂Ă��悢�ł��傤�B
���̃v���W�F�N�g�ł͂܂��AWiiRemote�ւ́u�ڑ��v�u�ؒf�v�{�^�����쐬���܂��B�t�H�[���Ƀ{�^��2����t���Ă��������B
�\��t������A�ubutton1�v�̃v���p�e�B��Text���u�ڑ��v�ɁA�ubutton2�v�̃v���p�e�B��Text���u�ؒf�v�ɐݒ肵�܂��B
�t�H�[���uForm1�v���E�N���b�N���āu�R�[�h�̕\���v�����Đ錾�ƁA�ڑ����̏����A�ԊO�����������Ƃ��̃o�C�u���[�^�[�̏��������������܂��傤�B
//�s�v��using�錾�͍폜���Ă��܂��܂��� using System; using System.Windows.Forms; | using WiimoteLib; //WimoteLib�̎g�p��錾 namespace IR1 { public partial class Form1 : Form { | Wiimote wm = new Wiimote(); //Wiimote�N���X���쐬 public Form1() { InitializeComponent(); | //���X���b�h����̃R���g���[���Ăяo������ | Control.CheckForIllegalCrossThreadCalls = false; } | //�ڑ��{�^���������ꂽ�� private void button1_Click(object sender, EventArgs e) { | wm.Connect(); //Wiimote�̐ڑ� | wm.WiimoteChanged += wm_WiimoteChanged; //�C�x���g���̓o�^ | wm.SetReportType(InputReport.IRExtensionAccel, true);//���|�[�g�^�C�v�̐ݒ� } | //�ؒf�{�^���������ꂽ�� private void button2_Click(object sender, EventArgs e) { | wm.WiimoteChanged -= wm_WiimoteChanged; //�C�x���g���̓o�^���� | wm.Disconnect(); //Wiimote�ؒf | wm.Dispose(); //�I�u�W�F�N�g�̔j�� } | //Wii�����R���̒l���ω�����x�ɌĂ�� | void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args) { | WiimoteState ws = args.WiimoteState; //WiimoteState�̒l���擾 | //�����ԊO�����P���������� | if (ws.IRState.IRSensors[0].Found) { | wm.SetRumble(true); //�o�C�u���[�^ON | } else { | wm.SetRumble(false); //�o�C�u���[�^OFF | } | } } }
#pragma once namespace IR1 { using namespace System; using namespace System::Windows::Forms; | using namespace WiimoteLib; //WimoteLib�̎g�p��錾 public ref class Form1 : public System::Windows::Forms::Form { | public: Wiimote^ wm; //Wiimote�I�u�W�F�N�gwm���쐬 public: Form1(void) { | wm = gcnew Wiimote(); //Wiimote�N���X���쐬 InitializeComponent(); | //���X���b�h����̃R���g���[���Ăяo������ | Control::CheckForIllegalCrossThreadCalls = false; } protected: ~Form1() ���ȗ��� #pragma endregion | //�ڑ��{�^���������ꂽ�� private: System::Void button1_Click(System::Object^ sender, \ System::EventArgs^ e) { | wm->Connect(); //WiiRemote�Ɛڑ� | wm->WiimoteChanged += | gcnew System::EventHandler<WiimoteChangedEventArgs^>( | this, &Form1::wm_WiimoteChanged); | wm->SetReportType(InputReport::IRExtensionAccel, true); //���|�[�g�^�C�v�̐ݒ� } | //�ؒf�{�^���������ꂽ�� private: System::Void button2_Click(System::Object^ sender, \ System::EventArgs^ e) { | wm->WiimoteChanged -= | gcnew System::EventHandler<WiimoteChangedEventArgs^>( | this, &Form1::wm_WiimoteChanged); //�C�x���g���̓o�^���� | wm->Disconnect(); //Wiimote�ؒf | wm->Dispose(); //�I�u�W�F�N�g�̔j�� } | //WiiRemote�̒l���ω�����x�ɌĂ�� | public: | void wm_WiimoteChanged(Object^ \ sender,WiimoteLib::WiimoteChangedEventArgs^ args){ | WiimoteState^ ws = args->WiimoteState; //WiimoteState�̒l���擾 | //�����ԊO�����P���������� | if (ws->IRState.IRSensors[0].Found) { | wm->SetRumble(true); //�o�C�u���[�^ON | } else { | wm->SetRumble(false); //�o�C�u���[�^OFF | } | } }; }
���āA���s���Ă݂܂��B�܂����͂ɐԊO��������p�ӂ��Ă��������BWii�{�̕t���̃Z���T�[�o�[������Ύ����葁���̂ł����A�Ȃ��ꍇ�͎���ɂ���Ɩ��A���z���Ȃǂɂ���������Ă݂܂��傤�BBluetooth�X�^�b�N����WiiRemote��ڑ����āAVisual Studio��[F5]�L�[�������Ď��s���Ă��������B�t�H�[�����\�����ꂽ��A[�ڑ�]�{�^���������Ă��������BWiiRemote���Z���T�[�o�[�ȂǐԊO�������Ɍ����Ă��������B�Z���T�[�o�[���Ȃ��ꍇ�́A���z�A�n���Q�������v�Ȃǂ̔M���Ɩ��A���C�^�[�̉A�e���r�̃����R���A�g�ѓd�b�̐ԊO���ʐM�ȂǂɌ����Ă݂Ă��������B��肭���o�ł���ƁA�o�C�u���[�^�[����܂��B�o�C�u���[�^�[�����Ă��Ȃ���Ԃ�[�ؒf]�{�^���������Ă���I�����܂��傤�B
���C�^�[��E�\�N�Ȃǂ�p���ĐԊO�������ɂ���ꍇ�́A�Ύ���Ώ��Ȃǂɏ\���C�����Ď������s���Ă��������B�܂��A�e���r�����R����p����ꍇ�́A�{�^���������ꂽ�Ƃ��ɂ����ԊO���𑗐M���܂���̂ŁA���x���A�ł��Ċm�F�������Ȃ��Ƃ悢�ł��傤�B
���낢��ȕ����Ɍ����Ă݂܂��悤�B���i�͌����Ȃ��ԊO���ł����A�g�̉��ɂ���l�X�ȕ��ɗ��p����Ă��邱�ƂɋC�������Ƃł��傤�B
��L�̃R�[�h�����̂܂܃R�s�[���Ă��܂��H�{�^�����������Ƃ��̏����́AForm1�̏�ɂ���{�^�����_�u���N���b�N���āAWindows�t�H�[���f�U�C�i�������Ő��������R�[�h���g���ď����Ă����̂��m���ł��B�����P�ɁA��L�̃R�[�h���R�s�[����ƁA�ڑ��{�^���������Ă��A�K�ȏ����Ƀv���O����������Ă����܂���B���̎d�g�݂Ɂw�ǂ�����!?�x�Ǝv�����l�́A�v���W�F�N�g�̒��ɂ���uForm1.Designer.cs�v��`���Ă݂܂��傤�B�����Ɂu#region Windows�t�H�[���f�U�C�i�Ő������ꂽ�R�[�h�v�Ƃ����f�t�H���g�Ŕ�\���ɂȂ��Ă���p�[�g������܂��B
#region Windows �t�H�[�� �f�U�C�i�Ő������ꂽ�R�[�h �c this.button1.Click += new System.EventHandler(this.button1_Click_1); �c this.button2.Click += new System.EventHandler(this.button2_Click);
�����ɂ́AGUI�ō쐬�����t�H�[���ɂ��Ă̈ʒu��傫���Ȃǂ̃v���p�e�B���L�ڂ���Ă��܂��B�厖�Ȃ̂́A�{�^�����������Ƃ��̃C�x���g�̔����ł��B
this.button1.Click+=new System.EventHandler(this.button1_Click_1);
�܂���WiiRemote�̃C�x���g�̒lj��Ɠ����悤�ɁA�N���b�N���̃C�x���g��lj����Ă��܂��B�������A��̗�ł́ubutton1_Click_1�v�Ƃ������ɂȂ��Ă��܂��B�u_1�v�̕����́A���̊����̊��Ɩ��O���Փ˂��Ȃ��悤�A�����Ő�������܂��B�܂菟��Ɂubutton1_Click�v�Ƃ������������Ă����Ƃ��Ă��A�{�^�����������Ƃ��̃C�x���g�Ƃ��ăR�[������邱�Ƃ͂���܂���B
�w�ȂA�킴�킴GUI�Ń_�u���N���b�N���Ȃ��Ƃ����Ȃ��̂��I�x�Ǝv���邩������܂��A�Ǘ����ʓ|�ȃC�x���g�n���Ȃǂ������Ő����E�Ǘ����Ă����A.NET�X�^�C���̊J�����u�����܂ŗ������āv�g�����Ȃ��A�Ƃ����̂��J�b�R�C�C�̂ł͂Ȃ��ł��傤���B
���̃v���O�����̎d�g�݂͒P���ł��B�R�[���o�b�N����ݒ肵�āAWiiRemote�̐ԊO���Z���T�[���ЂƂł�����������A�o�C�u���[�^�[��ON�ɂ��܂��B
[C#] wm.SetReportType ( InputReport.IRExtensionAccel, true); [C++] wm->SetReportType(InputReport::IRExtensionAccel, true);
���|�[�g�^�C�v���uIRExtensionAccel�v(�ԊO���{�g���{�����x)�擾���[�h�ɐݒ肵�܂��B���̃R�[���͂��Ȃ炸wm.Connect();�̌�ɋL�q���Ă��������Bwm.Connect();���O�ɋL�q����ƐԊO���Z���T�[�����������삵�܂���B
[C#] ws.IRState.IRSensors[0].Found [C++] ws->IRState.IRSensors[0].Found
���̃v���p�e�B��True/False��Ԃ��܂��̂ŁAif�����g���ĐԊO�������o���邱�Ƃ��ł��܂��B�܂�WiimoteLib�́A������4�_�܂ŐԊO�����������o���邱�Ƃ��ł��܂��B�X�̌�������肷�邱�Ƃ͂ł��܂��uIRSensors[3].Found�v���ꂪTrue�Ȃ�4�̐ԊO�������������Ă���A�Ƃ������Ƃł��B
�����āA�쐬������{�I�ȃv���O���������p���āA�ԊO���̌��𐔂���v���O�����Ɋg�����܂��BWiimoteLib�ɂ͓�����4�_�܂ł̐ԊO�����v�����邱�Ƃ��ł��܂��B�����܂ł̃v���O�����ł�1�_�ł��ԊO���������Z���T�[�̎��E�ɓ���ƁA�o�C�u���[�^�[���U������悤�ɂȂ��Ă��܂������A�FLED(�v���C���[�C���W�Q�[�^�[)�������āA���_���o���Ă��邩��\������v���O������lj����܂��B
void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args) { WiimoteState ws = args.WiimoteState; //WiimoteState�̒l���擾 //�����ԊO�����P���������� if (ws.IRState.IRSensors[0].Found) { wm.SetRumble(true); //�o�C�u���[�^ON } else { wm.SetRumble(false); //�o�C�u���[�^OFF } | //���o���ꂽ�ԊO������Wii�����R����LED�ɕ\������ | wm.SetLEDs(ws.IRState.IRSensors[0].Found, ws.IRState.IRSensors[1].Found, | ws.IRState.IRSensors[2].Found, ws.IRState.IRSensors[3].Found); }
public: void wm_WiimoteChanged(Object^ sender,WiimoteLib::WiimoteChangedEventArgs^ \ args){ WiimoteState^ ws = args->WiimoteState; //WiimoteState�̒l���擾 //�����ԊO�����P���������� if (ws->IRState.IRSensors[0].Found) { wm->SetRumble(true); //�o�C�u���[�^ON } else { wm->SetRumble(false); //�o�C�u���[�^OFF } | //���o���ꂽ�ԊO������Wii�����R����LED�ɕ\������ | wm->SetLEDs(ws->IRState.IRSensors[0].Found, \ ws->IRState.IRSensors[1].Found, | ws->IRState.IRSensors[2].Found, ws->IRState.IRSensors[3].Found ); }
�����ł͐�ق�LED�̓_������Ŏg�����uSetLED��()�v���̂����A4�����̂��̂��g���Ă��܂��BWiiRemote�̐ԊO���Z���T�[�ɕ����̐ԊO�������������ƁA�o�C�u���[�^�[�̐U���Ƌ���LED�C���W�Q�[�^�[���g���ĐԊO�����o����\�����܂��B
���āA�ԊO�������̗L����A���̃J�E���g���ł���悤�ɂȂ����̂ŁA���͐ԊO���Z���T�[�ɂ��������W�̎擾���s���A�t�H�[�����ɃO���t�B�b�N�X�@�\���g���ĕ`�悵�܂��B��قǂ̃v���W�F�N�g�����̂܂܉��ǂ��ĊJ�����邱�Ƃɂ��܂��傤�B
�܂��A�t�H�[���̃f�U�C����ύX���܂��B�͂��߂Ďg���V�����R���g���[����z�u���܂��B�u�c�[���{�b�N�X�v�́u�R�����R���g���[���v����uPictureBox�v��Form1�ɒ���t���܂��B�v���p�e�B�́uSize�v���u200, 200�v�ɂ��܂��B���̃{�^����t�H�[���̃o�����X���Ƃ��Ĕz�u���܂��B
�v���O�����̂ق��͂܂��A�`����using�錾�ŁuSystem.Drawing�v���錾����Ă��邱�Ƃ��m�F���Ă��������B��������{�^���C�x���g�͂��̂܂܂ŁAWiiRemote�̏�Ԃ��ω������Ƃ��ɌĂ����uwm_WiimoteChanged()�v�ƃt�H�[���`����uDrawForms(ws)�v�ɁA�`��̂��߂̃R�[�h�����M���܂��B
using System; using System.Windows.Forms; | using System.Drawing; //�`��̂��߂ɕK�v | using WiimoteLib; //WimoteLib�̎g�p��錾 namespace IR4 { //�쐬�����v���W�F�N�g���� public partial class Form1 Form { | Wiimote wm = new Wiimote(); //Wiimote�N���X���쐬 public Form1) { InitializeComponent(); | //���X���b�h����̃R���g���[���Ăяo������ | Control.CheckForIllegalCrossThreadCalls = false; } | //WiiRemote�̏�Ԃ��ω������Ƃ��ɌĂ��� | void wm_WiimoteChanged(object sender, WiimoteChangedEventArgs args) { | WiimoteState ws = args.WiimoteState; //WiimoteState�̒l���擾 | DrawForms(ws); //�t�H�[���`�ʊ��� | } �����F�{�^���C�x���g�W�� | //�t�H�[���`�ʊ� | public void DrawForms(WiimoteState ws) { | Graphics g =this.pictureBox1.CreateGraphics(); //�O���t�B�b�N�X�擾 | g.Clear(Color.Black); //��ʂ����F�ɃN���A | //�����ԊO�����P���������� | if (ws.IRState.IRSensors[0].Found) { | //�ԐF�Ń}�[�J��`�� | g.FillEllipse(Brushes.Red, | ws.IRState.IRSensors[0].Position.X * 200, | ws.IRState.IRSensors[0].Position.Y * 200, 10, 10); | } | //�����ԊO�����Q���������� | if (ws.IRState.IRSensors[1].Found) { | //�F�Ń}�[�J��`�� | g.FillEllipse(Brushes.Blue, | ws.IRState.IRSensors[1].Position.X * 200, | ws.IRState.IRSensors[1].Position.Y * 200, 10, 10); | } | //�����ԊO�����R���������� | if (ws.IRState.IRSensors[2].Found) { | //���F�Ń}�[�J��`�� | g.FillEllipse(Brushes.Yellow, | ws.IRState.IRSensors[2].Position.X * 200, | ws.IRState.IRSensors[2].Position.Y * 200, 10, 10); | } | //�����ԊO�����S���������� | if (ws.IRState.IRSensors[3].Found) { | //�ΐF�Ń}�[�J��`�� | g.FillEllipse(Brushes.Green, | ws.IRState.IRSensors[3].Position.X * 200, | ws.IRState.IRSensors[3].Position.Y * 200, 10, 10); | } | g.Dispose();//�O���t�B�b�N�X�̉�� | } } }
#pragma once namespace IR4 { //�쐬�����v���W�F�N�g���� using namespace System::Windows::Forms; | using namespace System::Drawing; | using namespace WiimoteLib; //WimoteLib�̎g�p��錾 public ref class Form1 : public System::Windows::Forms::Form { | public: Wiimote^ wm; //Wiimote�I�u�W�F�N�gwm���쐬 public: Form1(void) { | wm = gcnew Wiimote(); //Wiimote�N���X���쐬 InitializeComponent(); | //���X���b�h����̃R���g���[���Ăяo������ | Control::CheckForIllegalCrossThreadCalls = false; } protected: /// <summary> ������ #pragma endregion | //�ڑ��{�^���������ꂽ�� private: System::Void button1_Click(System::Object^ sender, \ System::EventArgs^ e) { | wm->Connect(); //WiiRemote�Ɛڑ� | wm->WiimoteChanged += | gcnew System::EventHandler<WiimoteChangedEventArgs^>( | this, &Form1::wm_WiimoteChanged); | //���|�[�g�^�C�v�̐ݒ� | wm->SetReportType(InputReport::IRExtensionAccel, true); } | //�ؒf�{�^���������ꂽ�� private: System::Void button2_Click(System::Object^ sender, \ System::EventArgs^ e) { | wm->WiimoteChanged -= | gcnew System::EventHandler<WiimoteChangedEventArgs^>( | this, &Form1::wm_WiimoteChanged); //�C�x���g���̓o�^���� | wm->Disconnect(); //Wiimote�ؒf } | //WiiRemote�̒l���ω�����x�ɌĂ�� | public: | void wm_WiimoteChanged(Object^ \ sender,WiimoteLib::WiimoteChangedEventArgs^ args){ | WiimoteState^ ws = args->WiimoteState; //WiimoteState���擾 | DrawForms(ws); | } | public: | void DrawForms(WiimoteState^ ws) { | //�O���t�B�b�N�X���擾 | Graphics^ g = this->pictureBox1->CreateGraphics(); | g->Clear(Color::Black);//��ʂ����F�ɃN���A | if (ws->IRState.IRSensors[0].Found) { //�ԊO����1���������� | //�ԐF�Ń}�[�J��`�� | g->FillEllipse( Brushes::Red , | (float)ws->IRState.IRSensors[0].Position.X * 200.0f , | (float)ws->IRState.IRSensors[0].Position.Y * 200.0f , 10.0f , 10.0f ); | } | if (ws->IRState.IRSensors[1].Found) { //�ԊO����2���������� | //�F�Ń}�[�J��`�� | g->FillEllipse( Brushes::Blue , | (float)ws->IRState.IRSensors[1].Position.X * 200.0f , | (float)ws->IRState.IRSensors[1].Position.Y * 200.0f , 10.0f , 10.0f ); | } | if (ws->IRState.IRSensors[2].Found) { //�ԊO����3���������� | //���F�Ń}�[�J��`�� | g->FillEllipse( Brushes::Yellow , | (float)ws->IRState.IRSensors[2].Position.X * 200.0f , | (float)ws->IRState.IRSensors[2].Position.Y * 200.0f , 10.0f , 10.0f ); | } | if (ws->IRState.IRSensors[3].Found) { //�ԊO����4���������� | //�ΐF�Ń}�[�J��`�� | g->FillEllipse( Brushes::Green , | (float)ws->IRState.IRSensors[3].Position.X * 200.0f , | (float)ws->IRState.IRSensors[3].Position.Y * 200.0f , 10.0f , 10.0f ); | } | } }; }
�܂��ԊO��������p�ӂ��āABluetooth�X�^�b�N����WiiRemote��ڑ����Ă��������BVisual Studio����[F5]�L�[�������ăv���O���������s���܂��B�\�����ꂽ�t�H�[����[�ڑ�]�{�^�����N���b�N���āAWiiRemote���Z���T�[�o�[��d���Ȃǂ̐ԊO�������Ɍ����Ă��������B
�ԊO�������o�����Ɛ}�̂悤�Ƀ}�[�J�_���\�����܂��B�}�[�J�̓���������������ꍇ�́AWiiRemote�ƃZ���T�[�o�[�Ƃ̋�����2m�`3m�܂ŗ����Ă��������B�����������قLj��肵���������s�����Ƃ��ł��܂��B
�Ȃ�Wii�{�̕t���̕W���̃Z���T�[�o�[�ɂ͐ԊO��LED�����E2�O���[�v��������܂���i��������4�_���o�ł���Ƃ����@�\�����݂���Ƃ��낪�����ł��I�j�B�����̐ԊO����������Ȃ��ꍇ�́A�����i���z�Ɍ�����Ȃǁj�ɑ��̊O�Ɍ�����ƕ����̐ԊO�������o�ł���Ǝv���܂��B���z�̌��𗐔��˂��Ă���l�q�Ȃǂł������_���擾�ł��邱�Ƃ�����܂����A�ԊO���������m���߂�����ƂЂƂ̃O���[�v�Ƃ��Č�F������m�C�Y�̌����ɂȂ�܂��̂ŁA������x���肵�Ď擾�ł�������⋗���ׂĂ݂�̂��悢�ł��傤�B��̐}�ł́A�Ƃ���X�܂̓V��ɒ݂��Ă���4�̃n���Q�������v�̗l�q�ł��B�I������ꍇ�́A�ؒf�{�^���������Ă���I�������Ă��������B
WiiRemote�̐ԊO���J�����̒l���擾���āA�ԊO�����������ʂɕ`�悵�Ă��܂��B
[C#] ws.IRState.IRSensors[0].Position.X [C++] ws->IRState.IRSensors[0].Position.X
�ԊO���̍��W(x,y)�̈ʒu(Position)�́A{0.0�`1.0}�̒l����Ƃ�܂��B�O���t�B�b�N�X�Ƃ̑g�ݍ��킹���ӊO�ƊȒP�������̂ł͂Ȃ��ł��傤���B�{�v���O�����ł́A���̒l��pictureBox�̉����Ƃ��Đݒ肵��200x200�ɍ����悤�ɁA200���|���ďo�͂��Ă��܂����A�t�H�[����Size��ύX�����肵�āA���D�݂̉�ʃf�U�C���ɂ��Ă݂�Ƃ悢�ł��傤�B
�Ȃ��AWiiRemote�̐ԊO���Z���T�[�͔��ɍ����\�ł��B�����ł�4�_�̌��o���s���Ă��܂����A���ۂɐԊO���������W�������Ă���X�s�[�h�͔��ɑ������Ƃɒ��ڂł��B�ʏ�̃r�f�I�J��������1�b��15-30����x�̎B�e���s���Ă���̂ɑ��AWiiRemote��200����x�̍��W�擾�������s���Ă���悤�ł��B�������Q�[���p���̓f�o�C�X�ł��A���x����ł��I
�{�͂ł͔�r�I���S�҂̓ǎ҂Ɍ����āAVisual Studio���g���AC#��C++�Ƃ��������̌�������g����.NET�ŊJ�����ꂽWiimoteLib��ʂ��āA��{�I��WiiRemote�v���O���~���O���w�т܂����BWiimoteLib�͌���ł������x�̍���API�̂ЂƂŁA���Ɉ��肵�ē��삵�܂��B.NET�Ƃ���������uC#��p�H�v�ƍl�����Ă��܂����A�{���Ɍ�����C++/CLI�ɂ����������[�������܂���(�����炭���E���I�ł�)�B
WiimoteLib���g�����T���v���A��̓I�ȊJ�����8�͂ł������Ă����܂��B