モーションプロセッサ用PCコントローラ
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
* モーションプロセッサ用PCコントローラ(V0.11) [#z30bf064]
#contents
----
**概要 [#k336f1b9]
ロボファイトなど、同時に多数の無線を使用する場合、無線の...
場合によっては整備中でも使用できないことが多々あることや...
本ソフトウェアは、モーションプロセッサの高速シリアルを利...
特にKRT-2を使用している方にお勧めです。
**操作方法 [#yba99ef4]
#ref(MPJOYPAD01.png)
マウス操作はできません。キーボードかジョイスティック操作...
ジョイスティックの判定は起動時に行いますので、接続後に起...
終了は、右上のクローズボックスを使用してください。~
-[1-8] COMポートを切り替えます。OFFLINE中のみ反応します。...
-[SPACE] ONLINE/OFFLINEを切り替えます。ONLINE中は表示が反...
-[ESC] LEVEL3スクリプトを停止して、OFFLINEになります。
-[他のキー] 表示されているボタンを押したことにしてデータ...
**ダウンロード [#m24524fd]
-Norton AntiVirus2005(ウィルス定義2006/04/26)でチェック済...
-動作するには.NET Framework 2.0が必要です。
#ref(MPJOYPAD01.ZIP)
-こちらはSW1-4の論理が逆転しています。(A=ON, B=OFFです)~
表示以外は変化ありません。~
Proboの配線を見た感じではSW3-4についてはA=ON, B=OFFになっ...
#ref(MPJOYPAD02.ZIP)
**制限事項など [#afacf28f]
-高速シリアルのパケット受信を使用するので、V14-V22が他の...
-キーの割り当ては固定です。
-他の環境で確認していませんので、動くかどうかは不明です。
-実行したままサスペンドすると、サスペンドできなかったりア...
**モーションプロセッサのLEVEL3プログラムでの使用方法 [#o1...
モーションプロセッサの無線コントロールは、通常低速シリア...
低速シリアル値は、V12およびV13に自動的に取り込まれるので...
一方、高速シリアルはスクリプト実行中のパケット取り込みが...
パケットデータの内、V14は高速シリアル判定用に0x11を送って...
V15,V16はKRT-2互換のデータで、V17-V22は今後の拡張用です。~
以下は、LEVEL3プログラムのサンプルです。
;コントロール信号 ----------------
JumpIf(V14,=,17,InputCheckNx)
;高速シリアル未使用ならProboデータで上書き
V15 = V12
V16 = V13
;操作判定 ------------------------
:InputCheckNx
;入力チェック(プロボ SW1=B)
V01 = V15 AND 1
JumpIf(V01,#,0,L_SW1_B) ★[SW1]をBに切り替えた場合の処...
;入力チェック(プロボ ↑a)
V01 = V16 AND 1
JumpIf(V01,#,0,L_FORWORD) ★[↑]ボタン押下の処理へ
;入力チェック(プロボ 1)
V01 = V16 AND 16
JumpIf(V01,#,0,L_1) ★[1]ボタン押下の処理へ
**ソースの一部 [#v6a02c31]
制御部分のソースです。
こんな感じで動かしています。(2006-08-05公開)
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Threading;
using Microsoft.DirectX.DirectInput;
using DInput = Microsoft.DirectX.DirectInput;
namespace MPJOYPAD
{
static class Program
{
/// <summary>
/// アプリケーションのメイン エントリ ポイントで...
/// </summary>
[STAThread]
static void Main()
{
///DirectInputキーボードデバイス
Device DInDevKBD;
//DirectInputキーボードデバイスの生成
DInDevKBD = new Microsoft.DirectX.DirectInpu...
///DirectInputジョイスティックデバイス
Device DInDevJOY = null;
//DirectInputジョイスティックデバイスの生成
foreach (
DeviceInstance di in
Manager.GetDevices(
DeviceClass.GameControl,
EnumDevicesFlags.AttachedOnly))
{
DInDevJOY = new Device(di.InstanceGuid);
break;
}
///画面
Form1 Mainform = new Form1();
//画面表示
Mainform.Show();
///キーボードデバイス状態
KeyboardState DKeyState;
///ジョイスティックデバイス状態
JoystickState DJoyState;
//キーボード入力制御開始
DInDevKBD.Acquire();
//ジョイスティック入力制御を開始
if (DInDevJOY == null)
{
Mainform.lblSEND.Text = "◆ジョイスティッ...
}
else
{
DInDevJOY.Acquire();
}
///インターバル値
double nexttime = (double)System.Environment...
float wait = 1000f / 30f;
///ONLINEフラグ
bool online = false;
///ON/OFFフラグ
bool onoff = false;
///COMポート名
Mainform.lblCOM.Text = "COM4";
///送信データ
int olddat = 0xffff;
String SENDDATA = "";
while (Mainform.Created)
{
//メインループ
if ((double)System.Environment.TickCount...
{
//入力チェックループ
///入力データ合成値
int indat = 0;
//キーボードの状態を取得
DKeyState = DInDevKBD.GetCurrentKeyb...
///ジョイスティックの状態
int joyY = 0;
int joyX = 0;
byte[] joybtn;
//ジョイスティックの状態を取得
if (DInDevJOY != null)
{
DJoyState = DInDevJOY.CurrentJoy...
if (DJoyState.Y < 0x1000) joyY =...
if (DJoyState.Y > 0xF000) joyY =...
if (DJoyState.X < 0x1000) joyX =...
if (DJoyState.X > 0xF000) joyX =...
joybtn = DJoyState.GetButtons();
}
else
{
joybtn = new byte[8];
}
//キーボード「A」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「S」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「]」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「:」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「D」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「Z」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「X」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「C」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「;」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「.」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「/」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「\」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「1-8」の判定
if (online==false)
{
if (DKeyState[DInput.Key.D1]) Ma...
if (DKeyState[DInput.Key.D2]) Ma...
if (DKeyState[DInput.Key.D3]) Ma...
if (DKeyState[DInput.Key.D4]) Ma...
if (DKeyState[DInput.Key.D5]) Ma...
if (DKeyState[DInput.Key.D6]) Ma...
if (DKeyState[DInput.Key.D7]) Ma...
if (DKeyState[DInput.Key.D8]) Ma...
}
//キーボード「SPACE」の判定
if (DKeyState[DInput.Key.Space])
{
onoff = true;
} else {
if (onoff == true)
{
onoff = false;
if (online)
{
//高速シリアル判定無効化...
SENDDATA = "#00110000000...
Mainform.lblSEND.Text = ...
Application.DoEvents();
//高速シリアル判定無効化...
byte[] buf = new byte[21];
buf[0] = (byte)'#';
for (int i = 1; i <= 18;...
buf[3] = (byte)'1';
buf[4] = (byte)'1';
buf[19] = 0x0d;
buf[20] = 0x0a; ...
try
{
Mainform.serialPort1...
}
catch
{
}
//回線切断
Mainform.serialPort1.Clo...
Mainform.lblONLINE.BackC...
Mainform.lblONLINE.ForeC...
online = false;
}
else
{
//回線接続
Mainform.lblONLINE.BackC...
Mainform.lblONLINE.ForeC...
Application.DoEvents();
online = true;
try
{
Mainform.serialPort1...
}
catch {
}
try {
Mainform.serialPort1...
Mainform.serialPort1...
}
catch
{
System.Threading.Thr...
Mainform.lblONLINE.B...
Mainform.lblONLINE.F...
Application.DoEvents...
online = false;
}
}
}
}
//キーボード「ESC」の判定
if(KeyCheck(Mainform.lblESC, 1, DKey...
//スクリプト停止コマンド表示
SENDDATA = "#000000000000000000<...
Mainform.lblSEND.Text = SENDDATA;
if (Mainform.serialPort1.IsOpen ...
{
//スクリプト停止コマンド送信
byte[] buf = new byte[21];
buf[0] = (byte)'#';
for (int i = 1; i <= 18; i++...
buf[19] = 0x0d;
buf[20] = 0x0a; ...
try
{
Mainform.serialPort1.Wri...
}
catch
{
}
//OFFLINEに移行
onoff = true;
}
}
else
{
//パケットコマンド表示
if (indat != olddat)
{
SENDDATA = "#11" + indat.ToS...
Mainform.lblSEND.Text = SEND...
}
if ((Mainform.serialPort1.IsOpen...
{
//パケットコマンド送信
byte[] buf = new byte[21];
buf[0] = (byte)'#';
for (int i = 1; i <= 18; i++...
buf[1] = (byte)'1';
buf[2] = (byte)'1';
buf[3] += (byte)((indat & 0x...
buf[4] += (byte)((indat & 0x...
buf[5] += (byte)((indat & 0x...
buf[6] += (byte)(indat & 0x0...
buf[19] = 0x0d;
buf[20] = 0x0a;
try
{
Mainform.serialPort1.Wri...
}
catch
{
}
olddat = indat;
}
}
nexttime += wait;
}
Application.DoEvents();
}
}
/// <summary>
/// キーボード入力をチェックし、ONの場合はON値を...
/// </summary>
static int KeyCheck(Control lbl, int ondata, boo...
{
return KeyCheck(lbl, ondata, key, false);
}
static int KeyCheck(Control lbl, int ondata, boo...
{
if (key)
{
lbl.BackColor = System.Drawing.Color.Bla...
lbl.ForeColor = System.Drawing.Color.Whi...
if (rev)
{
return 0;
}
else
{
return ondata;
}
}
else
{
lbl.BackColor = System.Drawing.Color.Whi...
lbl.ForeColor = System.Drawing.Color.Bla...
if (rev)
{
return ondata;
}
else
{
return 0;
}
}
}
}
}
----
#comment
終了行:
* モーションプロセッサ用PCコントローラ(V0.11) [#z30bf064]
#contents
----
**概要 [#k336f1b9]
ロボファイトなど、同時に多数の無線を使用する場合、無線の...
場合によっては整備中でも使用できないことが多々あることや...
本ソフトウェアは、モーションプロセッサの高速シリアルを利...
特にKRT-2を使用している方にお勧めです。
**操作方法 [#yba99ef4]
#ref(MPJOYPAD01.png)
マウス操作はできません。キーボードかジョイスティック操作...
ジョイスティックの判定は起動時に行いますので、接続後に起...
終了は、右上のクローズボックスを使用してください。~
-[1-8] COMポートを切り替えます。OFFLINE中のみ反応します。...
-[SPACE] ONLINE/OFFLINEを切り替えます。ONLINE中は表示が反...
-[ESC] LEVEL3スクリプトを停止して、OFFLINEになります。
-[他のキー] 表示されているボタンを押したことにしてデータ...
**ダウンロード [#m24524fd]
-Norton AntiVirus2005(ウィルス定義2006/04/26)でチェック済...
-動作するには.NET Framework 2.0が必要です。
#ref(MPJOYPAD01.ZIP)
-こちらはSW1-4の論理が逆転しています。(A=ON, B=OFFです)~
表示以外は変化ありません。~
Proboの配線を見た感じではSW3-4についてはA=ON, B=OFFになっ...
#ref(MPJOYPAD02.ZIP)
**制限事項など [#afacf28f]
-高速シリアルのパケット受信を使用するので、V14-V22が他の...
-キーの割り当ては固定です。
-他の環境で確認していませんので、動くかどうかは不明です。
-実行したままサスペンドすると、サスペンドできなかったりア...
**モーションプロセッサのLEVEL3プログラムでの使用方法 [#o1...
モーションプロセッサの無線コントロールは、通常低速シリア...
低速シリアル値は、V12およびV13に自動的に取り込まれるので...
一方、高速シリアルはスクリプト実行中のパケット取り込みが...
パケットデータの内、V14は高速シリアル判定用に0x11を送って...
V15,V16はKRT-2互換のデータで、V17-V22は今後の拡張用です。~
以下は、LEVEL3プログラムのサンプルです。
;コントロール信号 ----------------
JumpIf(V14,=,17,InputCheckNx)
;高速シリアル未使用ならProboデータで上書き
V15 = V12
V16 = V13
;操作判定 ------------------------
:InputCheckNx
;入力チェック(プロボ SW1=B)
V01 = V15 AND 1
JumpIf(V01,#,0,L_SW1_B) ★[SW1]をBに切り替えた場合の処...
;入力チェック(プロボ ↑a)
V01 = V16 AND 1
JumpIf(V01,#,0,L_FORWORD) ★[↑]ボタン押下の処理へ
;入力チェック(プロボ 1)
V01 = V16 AND 16
JumpIf(V01,#,0,L_1) ★[1]ボタン押下の処理へ
**ソースの一部 [#v6a02c31]
制御部分のソースです。
こんな感じで動かしています。(2006-08-05公開)
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Threading;
using Microsoft.DirectX.DirectInput;
using DInput = Microsoft.DirectX.DirectInput;
namespace MPJOYPAD
{
static class Program
{
/// <summary>
/// アプリケーションのメイン エントリ ポイントで...
/// </summary>
[STAThread]
static void Main()
{
///DirectInputキーボードデバイス
Device DInDevKBD;
//DirectInputキーボードデバイスの生成
DInDevKBD = new Microsoft.DirectX.DirectInpu...
///DirectInputジョイスティックデバイス
Device DInDevJOY = null;
//DirectInputジョイスティックデバイスの生成
foreach (
DeviceInstance di in
Manager.GetDevices(
DeviceClass.GameControl,
EnumDevicesFlags.AttachedOnly))
{
DInDevJOY = new Device(di.InstanceGuid);
break;
}
///画面
Form1 Mainform = new Form1();
//画面表示
Mainform.Show();
///キーボードデバイス状態
KeyboardState DKeyState;
///ジョイスティックデバイス状態
JoystickState DJoyState;
//キーボード入力制御開始
DInDevKBD.Acquire();
//ジョイスティック入力制御を開始
if (DInDevJOY == null)
{
Mainform.lblSEND.Text = "◆ジョイスティッ...
}
else
{
DInDevJOY.Acquire();
}
///インターバル値
double nexttime = (double)System.Environment...
float wait = 1000f / 30f;
///ONLINEフラグ
bool online = false;
///ON/OFFフラグ
bool onoff = false;
///COMポート名
Mainform.lblCOM.Text = "COM4";
///送信データ
int olddat = 0xffff;
String SENDDATA = "";
while (Mainform.Created)
{
//メインループ
if ((double)System.Environment.TickCount...
{
//入力チェックループ
///入力データ合成値
int indat = 0;
//キーボードの状態を取得
DKeyState = DInDevKBD.GetCurrentKeyb...
///ジョイスティックの状態
int joyY = 0;
int joyX = 0;
byte[] joybtn;
//ジョイスティックの状態を取得
if (DInDevJOY != null)
{
DJoyState = DInDevJOY.CurrentJoy...
if (DJoyState.Y < 0x1000) joyY =...
if (DJoyState.Y > 0xF000) joyY =...
if (DJoyState.X < 0x1000) joyX =...
if (DJoyState.X > 0xF000) joyX =...
joybtn = DJoyState.GetButtons();
}
else
{
joybtn = new byte[8];
}
//キーボード「A」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「S」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「]」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「:」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「D」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「Z」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「X」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「C」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「;」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「.」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「/」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「\」の判定
indat = (indat | KeyCheck(Mainform.l...
//キーボード「1-8」の判定
if (online==false)
{
if (DKeyState[DInput.Key.D1]) Ma...
if (DKeyState[DInput.Key.D2]) Ma...
if (DKeyState[DInput.Key.D3]) Ma...
if (DKeyState[DInput.Key.D4]) Ma...
if (DKeyState[DInput.Key.D5]) Ma...
if (DKeyState[DInput.Key.D6]) Ma...
if (DKeyState[DInput.Key.D7]) Ma...
if (DKeyState[DInput.Key.D8]) Ma...
}
//キーボード「SPACE」の判定
if (DKeyState[DInput.Key.Space])
{
onoff = true;
} else {
if (onoff == true)
{
onoff = false;
if (online)
{
//高速シリアル判定無効化...
SENDDATA = "#00110000000...
Mainform.lblSEND.Text = ...
Application.DoEvents();
//高速シリアル判定無効化...
byte[] buf = new byte[21];
buf[0] = (byte)'#';
for (int i = 1; i <= 18;...
buf[3] = (byte)'1';
buf[4] = (byte)'1';
buf[19] = 0x0d;
buf[20] = 0x0a; ...
try
{
Mainform.serialPort1...
}
catch
{
}
//回線切断
Mainform.serialPort1.Clo...
Mainform.lblONLINE.BackC...
Mainform.lblONLINE.ForeC...
online = false;
}
else
{
//回線接続
Mainform.lblONLINE.BackC...
Mainform.lblONLINE.ForeC...
Application.DoEvents();
online = true;
try
{
Mainform.serialPort1...
}
catch {
}
try {
Mainform.serialPort1...
Mainform.serialPort1...
}
catch
{
System.Threading.Thr...
Mainform.lblONLINE.B...
Mainform.lblONLINE.F...
Application.DoEvents...
online = false;
}
}
}
}
//キーボード「ESC」の判定
if(KeyCheck(Mainform.lblESC, 1, DKey...
//スクリプト停止コマンド表示
SENDDATA = "#000000000000000000<...
Mainform.lblSEND.Text = SENDDATA;
if (Mainform.serialPort1.IsOpen ...
{
//スクリプト停止コマンド送信
byte[] buf = new byte[21];
buf[0] = (byte)'#';
for (int i = 1; i <= 18; i++...
buf[19] = 0x0d;
buf[20] = 0x0a; ...
try
{
Mainform.serialPort1.Wri...
}
catch
{
}
//OFFLINEに移行
onoff = true;
}
}
else
{
//パケットコマンド表示
if (indat != olddat)
{
SENDDATA = "#11" + indat.ToS...
Mainform.lblSEND.Text = SEND...
}
if ((Mainform.serialPort1.IsOpen...
{
//パケットコマンド送信
byte[] buf = new byte[21];
buf[0] = (byte)'#';
for (int i = 1; i <= 18; i++...
buf[1] = (byte)'1';
buf[2] = (byte)'1';
buf[3] += (byte)((indat & 0x...
buf[4] += (byte)((indat & 0x...
buf[5] += (byte)((indat & 0x...
buf[6] += (byte)(indat & 0x0...
buf[19] = 0x0d;
buf[20] = 0x0a;
try
{
Mainform.serialPort1.Wri...
}
catch
{
}
olddat = indat;
}
}
nexttime += wait;
}
Application.DoEvents();
}
}
/// <summary>
/// キーボード入力をチェックし、ONの場合はON値を...
/// </summary>
static int KeyCheck(Control lbl, int ondata, boo...
{
return KeyCheck(lbl, ondata, key, false);
}
static int KeyCheck(Control lbl, int ondata, boo...
{
if (key)
{
lbl.BackColor = System.Drawing.Color.Bla...
lbl.ForeColor = System.Drawing.Color.Whi...
if (rev)
{
return 0;
}
else
{
return ondata;
}
}
else
{
lbl.BackColor = System.Drawing.Color.Whi...
lbl.ForeColor = System.Drawing.Color.Bla...
if (rev)
{
return ondata;
}
else
{
return 0;
}
}
}
}
}
----
#comment
ページ名: