����͂ł�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