Wiimote를 OSG 프로그램에 연동하기위해 다음과 같이 한다.
0. 하드웨어 준비하기 (위모트, 블루투스 동글)
1. WiimoteLib를 이용하여 Wiimote로 부터 데이터를 읽어들이고(블루투스->COM포트), 그 읽어들인 데이터를 Shared Memory (to local disk)나 UDP(to remote location)로 보내는 프로그램을 작성한다.
2. 기존의 OSG 프로그램에 Shared Memory나 UDP로 받은 Wiimote 데이터를 읽어들여서 OSG를 콘트롤 처리하는 OSG Manipulator 를 추가한다.
	 
	
	
	
	
		
		1. Download WiimoteLib from http://www.codeplex.com/WiimoteLib
2. WiimoteLib을 이용한 간단한 프로그램
// WiimoteLib Example
#include <iostream>
#import “../WiimoteLib/bin//x86/Release/WiimoteLib.tlb”
using namespace std;
using namespace WiimoteLib;
int main(int argc, char * argv[])
{
    HRESULT hr = CoInitialize(NULL);
    try
    {
        IWiimoteCOMServerPtr spWiimoteCOMServer;
        hr = spWiimoteCOMServer.CreateInstance(
                                                   “WiimoteLib.WiimoteCOMServer”);
        int count = 1;
        while (!GetAsyncKeyState(VK_ESCAPE))
        {
            cout << “X : ” << spWiimoteCOMServer->GetX() << endl;
            cout << “Y : ” << spWiimoteCOMServer->GetY() << endl;
            cout << “Z : ” << spWiimoteCOMServer->GetZ() << endl;
            cout << “Battery Status : ” << 
               spWiimoteCOMServer->GetBatteryStatus() << endl;
            
            Sleep(1000);
            
            switch (count)
            {
            case 1:
                spWiimoteCOMServer->SetLEDs(true, false, false, false);
                break;
            case 2:
                spWiimoteCOMServer->SetLEDs(false, true, false, false);
                break;
            case 3:
                spWiimoteCOMServer->SetLEDs(false, false, true, false);
                break;
            case 4:
                spWiimoteCOMServer->SetLEDs(false, false, false, true);
                break;
            default:
                spWiimoteCOMServer->SetLEDs(true, true, true, true);
                count = 0;
                break;
            }
            ++count;
            // 럼블 (진동) 키기
            //spWiimoteCOMServer->ToggleRumble(true);
        }
    }
    catch (_com_error& e)
    {
        cout << e.ErrorMessage() << endl;
    }
 return 0;
}
 
	 
	
	
		 
	
		
Just another Kyoung Shin Park’s Lectures Sites site