Wiiリモコン
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
[[11_YoshidaY]]~
工事中~
*ご意見等々枠 [#p6bbcf01]
- フォームアプリケーションでは、コピペしてもうまく行きま...
#comment
*Wiiリモコンのぺーじ [#mce2f993]
#contents
ここではWiiリモコンのページを作って行きたいと思います。~
Wiiリモコンを扱うのはちょっと難儀します。どう使うか理解す...
ちょっと今前作ったプログラムがツンしてくるんですが、最近...
**環境・使用物 [#g7b823c0]
-PC:Lenovo PC Windows 7 32bit
-デバイス:Wii Remote (Motion Plus)
-開発環境:Visual C++ 2008, Processing
-やること
--C++(WiiYourself!)でWiiリモコンへアクセス→Processingに加...
--できればWii remote plusのジャイロセンサも使用したい所。...
**最低限必要なコード [#faf4cf35]
***WiiYourself!で加速度、ボタンの値を取得する(フォームア...
#pragma once
#include "stdafx.h"
extern SOCKET sock;
char sendchar2[1024];
char sendchar[1024];
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;
/// <summary>
/// Form1 の概要
///
/// 警告: このクラスの名前を変更する場合、このクラスが...
/// マネージ リソース コンパイラ ツールに対し...
/// 変更する必要があります。この変更を行わない...
/// デザイナと、このフォームに関連付けられたロ...
/// 正しく相互に利用できなくなります。
/// </summary>
public ref class Form1 : public System::Windows::Forms:...
{
public: Wiimote^ wm; //Wiimoteオブジェクトwmの宣言
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::Label^ label7;
private: System::Windows::Forms::Label^ label8;
private: System::Windows::Forms::Label^ label9;
private: System::Windows::Forms::Label^ label10;
private: System::Windows::Forms::Label^ label11;
public:
public:
public: int count; //LED用の変数countの宣言
public:
Form1(void)
{
Control::CheckForIllegalCrossThreadCalls = false;
wm = gcnew Wiimote();
InitializeComponent();
//
//TODO: ここにコンストラクタ コードを追加します
//
wm->WiimoteChanged +=
gcnew System::EventHandler<WiimoteChangedEventArgs^>(
this, &Form1::wm_WiimoteChanged);
wm->SetReportType(InputReport::Buttons, true);
wm->SetReportType(InputReport::ButtonsAccel, true);
wm->Connect();
}
public:
void wm_WiimoteChanged(Object^
sender,WiimoteLib::WiimoteChangedEventArgs^ args){
WiimoteState^ ws;
//ここからポチコード
float AX, AY, AZ;
int Abtn, Bbtn, Plus, Minus, One, Two, Home;
//ボタンが何も押されていない状態ではは0(off)とする
AX = AY = AZ = 0.0;
Abtn = Bbtn = Plus = Minus = One = Two = Home = 0;
ws = args->WiimoteState;
AX = (ws->AccelState.Values.X);
AY = (ws->AccelState.Values.Y);
AZ = (ws->AccelState.Values.Z);
//Aボタンが押されたら0→1
if(ws->ButtonState.A) Abtn = 1;
//Bボタンが押されたら0→1
if(ws->ButtonState.B) Bbtn = 1;
//Homeボタンが押されたら0→1
if(ws->ButtonState.Home) Home = 1;
//+ボタンが押されたら1を足す
if(ws->ButtonState.Plus) Plus++;
//-ボタンが押されたら1を引く
if(ws->ButtonState.Minus) Minus--;
//1ボタンが押されたら0→1
if(ws->ButtonState.One) One = 1;
//2ボタンが押されたら0→1
if(ws->ButtonState.Two) Two = 1;
sendchar2[0] = '\0';
//文字列をsendchar(送る変数)に代入
sprintf_s(sendchar, "%f %f %f %d %d %d %d %d %d %d \n"...
strcat_s(sendchar2,sendchar);
send(sock, sendchar2, strlen(sendchar2), 0);
//ここまでポチコード
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.O...
this->label4->Text = "Button 2:" + (ws->ButtonState.T...
this->label5->Text = "Button ↓:" + (ws->ButtonState.D...
this->label6->Text = "Button ↑:" + (ws->ButtonState.U...
this->label7->Text = "Button ←:" + (ws->ButtonState.L...
this->label8->Text = "Button →:" + (ws->ButtonState.R...
this->label9->Text = "X軸:" + (ws->AccelState.Values....
this->label10->Text = "Y軸:" + (ws->AccelState.Values...
this->label11->Text = "Z軸:" + (ws->AccelState.Values...
}
protected:
/// <summary>
/// 使用中のリソースをすべてクリーンアップします。
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
protected:
private:
/// <summary>
/// 必要なデザイナ変数です。
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// デザイナ サポートに必要なメソッドです。このメソッ...
/// コード エディタで変更しないでください。
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button...
this->button2 = (gcnew System::Windows::Forms::Button...
this->button3 = (gcnew System::Windows::Forms::Button...
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->label6 = (gcnew System::Windows::Forms::Label());
this->label7 = (gcnew System::Windows::Forms::Label());
this->label8 = (gcnew System::Windows::Forms::Label());
this->label9 = (gcnew System::Windows::Forms::Label());
this->label10 = (gcnew System::Windows::Forms::Label(...
this->label11 = (gcnew System::Windows::Forms::Label(...
this->SuspendLayout();
//
// button1
//
this->button1->Font = (gcnew System::Drawing::Font(L"...
System::Drawing::GraphicsUnit::Point, static_cast<Sys...
this->button1->Location = System::Drawing::Point(12, ...
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 27);
this->button1->TabIndex = 0;
this->button1->Text = L"VibON";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(th...
//
// button2
//
this->button2->Font = (gcnew System::Drawing::Font(L"...
System::Drawing::GraphicsUnit::Point, static_cast<Sys...
this->button2->Location = System::Drawing::Point(84, ...
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 27);
this->button2->TabIndex = 1;
this->button2->Text = L"VibOFF";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(th...
//
// button3
//
this->button3->Font = (gcnew System::Drawing::Font(L"...
System::Drawing::GraphicsUnit::Point, static_cast<Sys...
this->button3->Location = System::Drawing::Point(164,...
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(184, 27);
this->button3->TabIndex = 2;
this->button3->Text = L"LED";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(th...
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label1->ForeColor = System::Drawing::Color::Whi...
this->label1->Location = System::Drawing::Point(9, 8);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(78, 27);
this->label1->TabIndex = 3;
this->label1->Text = L"label1";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label2->ForeColor = System::Drawing::Color::Whi...
this->label2->Location = System::Drawing::Point(9, 36);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(78, 27);
this->label2->TabIndex = 4;
this->label2->Text = L"label2";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label3->ForeColor = System::Drawing::Color::Whi...
this->label3->Location = System::Drawing::Point(9, 64);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(78, 27);
this->label3->TabIndex = 5;
this->label3->Text = L"label3";
this->label3->Click += gcnew System::EventHandler(thi...
//
// label4
//
this->label4->AutoSize = true;
this->label4->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label4->ForeColor = System::Drawing::Color::Whi...
this->label4->Location = System::Drawing::Point(9, 91);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(78, 27);
this->label4->TabIndex = 6;
this->label4->Text = L"label4";
this->label4->Click += gcnew System::EventHandler(thi...
//
// label5
//
this->label5->AutoSize = true;
this->label5->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label5->ForeColor = System::Drawing::Color::Whi...
this->label5->Location = System::Drawing::Point(9, 11...
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(78, 27);
this->label5->TabIndex = 8;
this->label5->Text = L"label5";
this->label5->Click += gcnew System::EventHandler(thi...
//
// label6
//
this->label6->AutoSize = true;
this->label6->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label6->ForeColor = System::Drawing::Color::Whi...
this->label6->Location = System::Drawing::Point(9, 14...
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(78, 27);
this->label6->TabIndex = 7;
this->label6->Text = L"label6";
this->label6->Click += gcnew System::EventHandler(thi...
//
// label7
//
this->label7->AutoSize = true;
this->label7->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label7->ForeColor = System::Drawing::Color::Whi...
this->label7->Location = System::Drawing::Point(9, 16...
this->label7->Name = L"label7";
this->label7->Size = System::Drawing::Size(78, 27);
this->label7->TabIndex = 9;
this->label7->Text = L"label7";
this->label7->Click += gcnew System::EventHandler(thi...
//
// label8
//
this->label8->AutoSize = true;
this->label8->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label8->ForeColor = System::Drawing::Color::Whi...
this->label8->Location = System::Drawing::Point(9, 19...
this->label8->Name = L"label8";
this->label8->Size = System::Drawing::Size(78, 27);
this->label8->TabIndex = 10;
this->label8->Text = L"label8";
this->label8->Click += gcnew System::EventHandler(thi...
//
// label9
//
this->label9->AutoSize = true;
this->label9->BackColor = System::Drawing::Color::Mar...
this->label9->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label9->ForeColor = System::Drawing::Color::Whi...
this->label9->Location = System::Drawing::Point(9, 22...
this->label9->Name = L"label9";
this->label9->Size = System::Drawing::Size(78, 27);
this->label9->TabIndex = 13;
this->label9->Text = L"label9";
this->label9->Click += gcnew System::EventHandler(this...
//
// label10
//
this->label10->AutoSize = true;
this->label10->Font = (gcnew System::Drawing::Font(L"...
static_cast<System::Byte>(128)));
this->label10->ForeColor = System::Drawing::Color::Wh...
this->label10->Location = System::Drawing::Point(9, 2...
this->label10->Name = L"label10";
this->label10->Size = System::Drawing::Size(92, 27);
this->label10->TabIndex = 12;
this->label10->Text = L"label10";
this->label10->Click += gcnew System::EventHandler(th...
//
// label11
//
this->label11->AutoSize = true;
this->label11->Font = (gcnew System::Drawing::Font(L"...
static_cast<System::Byte>(128)));
this->label11->ForeColor = System::Drawing::Color::Wh...
this->label11->Location = System::Drawing::Point(9, 2...
this->label11->Name = L"label11";
this->label11->Size = System::Drawing::Size(92, 27);
this->label11->TabIndex = 11;
this->label11->Text = L"label11";
this->label11->Click += gcnew System::EventHandler(th...
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6,...
this->AutoScaleMode = System::Windows::Forms::AutoSca...
this->BackColor = System::Drawing::Color::Maroon;
this->ClientSize = System::Drawing::Size(353, 343);
this->Controls->Add(this->label9);
this->Controls->Add(this->label10);
this->Controls->Add(this->label11);
this->Controls->Add(this->label8);
this->Controls->Add(this->label7);
this->Controls->Add(this->label5);
this->Controls->Add(this->label6);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Name = L"Form1";
this->Text = L"WiiServer";
this->Load += gcnew System::EventHandler(this, &Form1...
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ se...
wm->SetRumble(true);
}
private: System::Void button2_Click(System::Object^ se...
wm->SetRumble(false);
}
private: System::Void button3_Click(System::Object^ se...
button3->Text = "wm->SetLEDs(" + count + ")を表示中";
wm->SetLEDs(count);
count++;
}
private: System::Void Form1_Load(System::Object^ sende...
}
private: System::Void label5_Click(System::Object^ send...
}
private: System::Void label8_Click(System::Object^ send...
}
private: System::Void label7_Click(System::Object^ send...
}
private: System::Void label6_Click(System::Object^ send...
}
private: System::Void label12_Click(System::Object^ sen...
}
private: System::Void label3_Click(System::Object^ send...
}
private: System::Void label10_Click(System::Object^ sen...
}
private: System::Void label11_Click(System::Object^ sen...
}
private: System::Void label4_Click(System::Object^ send...
}
private: System::Void label9_Click(System::Object^ send...
}
};
}
***Socket通信で情報を送るコード [#td5f03b7]
// WiimoteLib01cpp.cpp : メイン プロジェクト ファイルで...
#include "stdafx.h"
#include "Form1.h"
#pragma comment(lib,"ws2_32.lib")
using namespace WiimoteLib01cpp;
using namespace std;
using namespace System;
SOCKET sock;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
WSADATA wsaData;
SOCKET sock0;
struct sockaddr_in addr;
struct sockaddr_in client;
int len;
System::Windows::Forms::MessageBox::Show("OKを押した...
// winsock2の初期化
if (WSAStartup(MAKEWORD(2,0), &wsaData))
{
System::Windows::Forms::MessageBox::Show("winsock ...
getchar();
return 1;
}
// ソケットの作成
sock0= socket(AF_INET,SOCK_STREAM,0);
if(sock0 == INVALID_SOCKET)
{
System::Windows::Forms::MessageBox::Show("socket faile...
getchar();
return 1;
}
// ソケットの設定
addr.sin_family = AF_INET;
addr.sin_port = htons(54321);
addr.sin_addr.S_un.S_addr = INADDR_ANY;
bind(sock0, (struct sockaddr *)&addr, sizeof(addr));
System::Windows::Forms::MessageBox::Show("TCP クライア...
// TCPクライアントからの接続要求を待てる状態にする
listen(sock0, 6);
// TCPクライアントからの接続要求を受け付ける
len = sizeof(client);
sock = accept(sock0, (struct sockaddr *)&client, &len);
if(sock > 0) {
// コントロールが作成される前に、Windows XP ビジュアル...
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// メイン ウィンドウを作成して、実行します
Application::Run(gcnew Form1());
}
// TCPセッションの終了
closesocket(sock);
// winsock2の終了処理
closesocket(sock0);
WSACleanup();
return 0;
}
**参考リンク [#l9d6d45e]
-[[Johnny Chung Lee > Projects > Wii:http://johnnylee.net...
-[[WiiRemoteプログラミング:http://ssl.ohmsha.co.jp/cgi-bi...
-[[WiiYourself!でモーションプラスを使い角度を算出してみる...
終了行:
[[11_YoshidaY]]~
工事中~
*ご意見等々枠 [#p6bbcf01]
- フォームアプリケーションでは、コピペしてもうまく行きま...
#comment
*Wiiリモコンのぺーじ [#mce2f993]
#contents
ここではWiiリモコンのページを作って行きたいと思います。~
Wiiリモコンを扱うのはちょっと難儀します。どう使うか理解す...
ちょっと今前作ったプログラムがツンしてくるんですが、最近...
**環境・使用物 [#g7b823c0]
-PC:Lenovo PC Windows 7 32bit
-デバイス:Wii Remote (Motion Plus)
-開発環境:Visual C++ 2008, Processing
-やること
--C++(WiiYourself!)でWiiリモコンへアクセス→Processingに加...
--できればWii remote plusのジャイロセンサも使用したい所。...
**最低限必要なコード [#faf4cf35]
***WiiYourself!で加速度、ボタンの値を取得する(フォームア...
#pragma once
#include "stdafx.h"
extern SOCKET sock;
char sendchar2[1024];
char sendchar[1024];
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;
/// <summary>
/// Form1 の概要
///
/// 警告: このクラスの名前を変更する場合、このクラスが...
/// マネージ リソース コンパイラ ツールに対し...
/// 変更する必要があります。この変更を行わない...
/// デザイナと、このフォームに関連付けられたロ...
/// 正しく相互に利用できなくなります。
/// </summary>
public ref class Form1 : public System::Windows::Forms:...
{
public: Wiimote^ wm; //Wiimoteオブジェクトwmの宣言
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Label^ label1;
private: System::Windows::Forms::Label^ label2;
private: System::Windows::Forms::Label^ label3;
private: System::Windows::Forms::Label^ label4;
private: System::Windows::Forms::Label^ label5;
private: System::Windows::Forms::Label^ label6;
private: System::Windows::Forms::Label^ label7;
private: System::Windows::Forms::Label^ label8;
private: System::Windows::Forms::Label^ label9;
private: System::Windows::Forms::Label^ label10;
private: System::Windows::Forms::Label^ label11;
public:
public:
public: int count; //LED用の変数countの宣言
public:
Form1(void)
{
Control::CheckForIllegalCrossThreadCalls = false;
wm = gcnew Wiimote();
InitializeComponent();
//
//TODO: ここにコンストラクタ コードを追加します
//
wm->WiimoteChanged +=
gcnew System::EventHandler<WiimoteChangedEventArgs^>(
this, &Form1::wm_WiimoteChanged);
wm->SetReportType(InputReport::Buttons, true);
wm->SetReportType(InputReport::ButtonsAccel, true);
wm->Connect();
}
public:
void wm_WiimoteChanged(Object^
sender,WiimoteLib::WiimoteChangedEventArgs^ args){
WiimoteState^ ws;
//ここからポチコード
float AX, AY, AZ;
int Abtn, Bbtn, Plus, Minus, One, Two, Home;
//ボタンが何も押されていない状態ではは0(off)とする
AX = AY = AZ = 0.0;
Abtn = Bbtn = Plus = Minus = One = Two = Home = 0;
ws = args->WiimoteState;
AX = (ws->AccelState.Values.X);
AY = (ws->AccelState.Values.Y);
AZ = (ws->AccelState.Values.Z);
//Aボタンが押されたら0→1
if(ws->ButtonState.A) Abtn = 1;
//Bボタンが押されたら0→1
if(ws->ButtonState.B) Bbtn = 1;
//Homeボタンが押されたら0→1
if(ws->ButtonState.Home) Home = 1;
//+ボタンが押されたら1を足す
if(ws->ButtonState.Plus) Plus++;
//-ボタンが押されたら1を引く
if(ws->ButtonState.Minus) Minus--;
//1ボタンが押されたら0→1
if(ws->ButtonState.One) One = 1;
//2ボタンが押されたら0→1
if(ws->ButtonState.Two) Two = 1;
sendchar2[0] = '\0';
//文字列をsendchar(送る変数)に代入
sprintf_s(sendchar, "%f %f %f %d %d %d %d %d %d %d \n"...
strcat_s(sendchar2,sendchar);
send(sock, sendchar2, strlen(sendchar2), 0);
//ここまでポチコード
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.O...
this->label4->Text = "Button 2:" + (ws->ButtonState.T...
this->label5->Text = "Button ↓:" + (ws->ButtonState.D...
this->label6->Text = "Button ↑:" + (ws->ButtonState.U...
this->label7->Text = "Button ←:" + (ws->ButtonState.L...
this->label8->Text = "Button →:" + (ws->ButtonState.R...
this->label9->Text = "X軸:" + (ws->AccelState.Values....
this->label10->Text = "Y軸:" + (ws->AccelState.Values...
this->label11->Text = "Z軸:" + (ws->AccelState.Values...
}
protected:
/// <summary>
/// 使用中のリソースをすべてクリーンアップします。
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Button^ button2;
protected:
private:
/// <summary>
/// 必要なデザイナ変数です。
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// デザイナ サポートに必要なメソッドです。このメソッ...
/// コード エディタで変更しないでください。
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button...
this->button2 = (gcnew System::Windows::Forms::Button...
this->button3 = (gcnew System::Windows::Forms::Button...
this->label1 = (gcnew System::Windows::Forms::Label());
this->label2 = (gcnew System::Windows::Forms::Label());
this->label3 = (gcnew System::Windows::Forms::Label());
this->label4 = (gcnew System::Windows::Forms::Label());
this->label5 = (gcnew System::Windows::Forms::Label());
this->label6 = (gcnew System::Windows::Forms::Label());
this->label7 = (gcnew System::Windows::Forms::Label());
this->label8 = (gcnew System::Windows::Forms::Label());
this->label9 = (gcnew System::Windows::Forms::Label());
this->label10 = (gcnew System::Windows::Forms::Label(...
this->label11 = (gcnew System::Windows::Forms::Label(...
this->SuspendLayout();
//
// button1
//
this->button1->Font = (gcnew System::Drawing::Font(L"...
System::Drawing::GraphicsUnit::Point, static_cast<Sys...
this->button1->Location = System::Drawing::Point(12, ...
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 27);
this->button1->TabIndex = 0;
this->button1->Text = L"VibON";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(th...
//
// button2
//
this->button2->Font = (gcnew System::Drawing::Font(L"...
System::Drawing::GraphicsUnit::Point, static_cast<Sys...
this->button2->Location = System::Drawing::Point(84, ...
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(75, 27);
this->button2->TabIndex = 1;
this->button2->Text = L"VibOFF";
this->button2->UseVisualStyleBackColor = true;
this->button2->Click += gcnew System::EventHandler(th...
//
// button3
//
this->button3->Font = (gcnew System::Drawing::Font(L"...
System::Drawing::GraphicsUnit::Point, static_cast<Sys...
this->button3->Location = System::Drawing::Point(164,...
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(184, 27);
this->button3->TabIndex = 2;
this->button3->Text = L"LED";
this->button3->UseVisualStyleBackColor = true;
this->button3->Click += gcnew System::EventHandler(th...
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label1->ForeColor = System::Drawing::Color::Whi...
this->label1->Location = System::Drawing::Point(9, 8);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(78, 27);
this->label1->TabIndex = 3;
this->label1->Text = L"label1";
//
// label2
//
this->label2->AutoSize = true;
this->label2->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label2->ForeColor = System::Drawing::Color::Whi...
this->label2->Location = System::Drawing::Point(9, 36);
this->label2->Name = L"label2";
this->label2->Size = System::Drawing::Size(78, 27);
this->label2->TabIndex = 4;
this->label2->Text = L"label2";
//
// label3
//
this->label3->AutoSize = true;
this->label3->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label3->ForeColor = System::Drawing::Color::Whi...
this->label3->Location = System::Drawing::Point(9, 64);
this->label3->Name = L"label3";
this->label3->Size = System::Drawing::Size(78, 27);
this->label3->TabIndex = 5;
this->label3->Text = L"label3";
this->label3->Click += gcnew System::EventHandler(thi...
//
// label4
//
this->label4->AutoSize = true;
this->label4->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label4->ForeColor = System::Drawing::Color::Whi...
this->label4->Location = System::Drawing::Point(9, 91);
this->label4->Name = L"label4";
this->label4->Size = System::Drawing::Size(78, 27);
this->label4->TabIndex = 6;
this->label4->Text = L"label4";
this->label4->Click += gcnew System::EventHandler(thi...
//
// label5
//
this->label5->AutoSize = true;
this->label5->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label5->ForeColor = System::Drawing::Color::Whi...
this->label5->Location = System::Drawing::Point(9, 11...
this->label5->Name = L"label5";
this->label5->Size = System::Drawing::Size(78, 27);
this->label5->TabIndex = 8;
this->label5->Text = L"label5";
this->label5->Click += gcnew System::EventHandler(thi...
//
// label6
//
this->label6->AutoSize = true;
this->label6->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label6->ForeColor = System::Drawing::Color::Whi...
this->label6->Location = System::Drawing::Point(9, 14...
this->label6->Name = L"label6";
this->label6->Size = System::Drawing::Size(78, 27);
this->label6->TabIndex = 7;
this->label6->Text = L"label6";
this->label6->Click += gcnew System::EventHandler(thi...
//
// label7
//
this->label7->AutoSize = true;
this->label7->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label7->ForeColor = System::Drawing::Color::Whi...
this->label7->Location = System::Drawing::Point(9, 16...
this->label7->Name = L"label7";
this->label7->Size = System::Drawing::Size(78, 27);
this->label7->TabIndex = 9;
this->label7->Text = L"label7";
this->label7->Click += gcnew System::EventHandler(thi...
//
// label8
//
this->label8->AutoSize = true;
this->label8->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label8->ForeColor = System::Drawing::Color::Whi...
this->label8->Location = System::Drawing::Point(9, 19...
this->label8->Name = L"label8";
this->label8->Size = System::Drawing::Size(78, 27);
this->label8->TabIndex = 10;
this->label8->Text = L"label8";
this->label8->Click += gcnew System::EventHandler(thi...
//
// label9
//
this->label9->AutoSize = true;
this->label9->BackColor = System::Drawing::Color::Mar...
this->label9->Font = (gcnew System::Drawing::Font(L"M...
static_cast<System::Byte>(128)));
this->label9->ForeColor = System::Drawing::Color::Whi...
this->label9->Location = System::Drawing::Point(9, 22...
this->label9->Name = L"label9";
this->label9->Size = System::Drawing::Size(78, 27);
this->label9->TabIndex = 13;
this->label9->Text = L"label9";
this->label9->Click += gcnew System::EventHandler(this...
//
// label10
//
this->label10->AutoSize = true;
this->label10->Font = (gcnew System::Drawing::Font(L"...
static_cast<System::Byte>(128)));
this->label10->ForeColor = System::Drawing::Color::Wh...
this->label10->Location = System::Drawing::Point(9, 2...
this->label10->Name = L"label10";
this->label10->Size = System::Drawing::Size(92, 27);
this->label10->TabIndex = 12;
this->label10->Text = L"label10";
this->label10->Click += gcnew System::EventHandler(th...
//
// label11
//
this->label11->AutoSize = true;
this->label11->Font = (gcnew System::Drawing::Font(L"...
static_cast<System::Byte>(128)));
this->label11->ForeColor = System::Drawing::Color::Wh...
this->label11->Location = System::Drawing::Point(9, 2...
this->label11->Name = L"label11";
this->label11->Size = System::Drawing::Size(92, 27);
this->label11->TabIndex = 11;
this->label11->Text = L"label11";
this->label11->Click += gcnew System::EventHandler(th...
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(6,...
this->AutoScaleMode = System::Windows::Forms::AutoSca...
this->BackColor = System::Drawing::Color::Maroon;
this->ClientSize = System::Drawing::Size(353, 343);
this->Controls->Add(this->label9);
this->Controls->Add(this->label10);
this->Controls->Add(this->label11);
this->Controls->Add(this->label8);
this->Controls->Add(this->label7);
this->Controls->Add(this->label5);
this->Controls->Add(this->label6);
this->Controls->Add(this->label4);
this->Controls->Add(this->label3);
this->Controls->Add(this->label2);
this->Controls->Add(this->label1);
this->Controls->Add(this->button3);
this->Controls->Add(this->button2);
this->Controls->Add(this->button1);
this->Name = L"Form1";
this->Text = L"WiiServer";
this->Load += gcnew System::EventHandler(this, &Form1...
this->ResumeLayout(false);
this->PerformLayout();
}
#pragma endregion
private: System::Void button1_Click(System::Object^ se...
wm->SetRumble(true);
}
private: System::Void button2_Click(System::Object^ se...
wm->SetRumble(false);
}
private: System::Void button3_Click(System::Object^ se...
button3->Text = "wm->SetLEDs(" + count + ")を表示中";
wm->SetLEDs(count);
count++;
}
private: System::Void Form1_Load(System::Object^ sende...
}
private: System::Void label5_Click(System::Object^ send...
}
private: System::Void label8_Click(System::Object^ send...
}
private: System::Void label7_Click(System::Object^ send...
}
private: System::Void label6_Click(System::Object^ send...
}
private: System::Void label12_Click(System::Object^ sen...
}
private: System::Void label3_Click(System::Object^ send...
}
private: System::Void label10_Click(System::Object^ sen...
}
private: System::Void label11_Click(System::Object^ sen...
}
private: System::Void label4_Click(System::Object^ send...
}
private: System::Void label9_Click(System::Object^ send...
}
};
}
***Socket通信で情報を送るコード [#td5f03b7]
// WiimoteLib01cpp.cpp : メイン プロジェクト ファイルで...
#include "stdafx.h"
#include "Form1.h"
#pragma comment(lib,"ws2_32.lib")
using namespace WiimoteLib01cpp;
using namespace std;
using namespace System;
SOCKET sock;
[STAThreadAttribute]
int main(array<System::String ^> ^args)
{
WSADATA wsaData;
SOCKET sock0;
struct sockaddr_in addr;
struct sockaddr_in client;
int len;
System::Windows::Forms::MessageBox::Show("OKを押した...
// winsock2の初期化
if (WSAStartup(MAKEWORD(2,0), &wsaData))
{
System::Windows::Forms::MessageBox::Show("winsock ...
getchar();
return 1;
}
// ソケットの作成
sock0= socket(AF_INET,SOCK_STREAM,0);
if(sock0 == INVALID_SOCKET)
{
System::Windows::Forms::MessageBox::Show("socket faile...
getchar();
return 1;
}
// ソケットの設定
addr.sin_family = AF_INET;
addr.sin_port = htons(54321);
addr.sin_addr.S_un.S_addr = INADDR_ANY;
bind(sock0, (struct sockaddr *)&addr, sizeof(addr));
System::Windows::Forms::MessageBox::Show("TCP クライア...
// TCPクライアントからの接続要求を待てる状態にする
listen(sock0, 6);
// TCPクライアントからの接続要求を受け付ける
len = sizeof(client);
sock = accept(sock0, (struct sockaddr *)&client, &len);
if(sock > 0) {
// コントロールが作成される前に、Windows XP ビジュアル...
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// メイン ウィンドウを作成して、実行します
Application::Run(gcnew Form1());
}
// TCPセッションの終了
closesocket(sock);
// winsock2の終了処理
closesocket(sock0);
WSACleanup();
return 0;
}
**参考リンク [#l9d6d45e]
-[[Johnny Chung Lee > Projects > Wii:http://johnnylee.net...
-[[WiiRemoteプログラミング:http://ssl.ohmsha.co.jp/cgi-bi...
-[[WiiYourself!でモーションプラスを使い角度を算出してみる...
ページ名: