10. Iforce 協議¶
- 作者:
Johann Deneux <johann.deneux@gmail.com>
主頁地址:http://web.archive.org/web/*/http://www.esil.univ-mrs.fr
- 補充內容:
由 Vojtech Pavlik。
10.1. 簡介¶
本文件描述了我對用於指定力反饋效果到 I-Force 2.0 裝置的協議所發現的資訊。所有這些資訊均非來自 Immerse 公司。因此,您不應完全相信本文件中的內容。本文件旨在幫助理解該協議,並非參考資料。歡迎提供評論和更正。要聯絡我,請傳送電子郵件至:johann.deneux@gmail.com
警告
如果您嘗試根據本文件中的內容向您的 I-Force 裝置傳送資料,我將不對因此造成的任何損害或傷害負責。
10.2. 預備說明¶
所有值均為十六進位制,採用大端編碼(最高有效位元組在左側)。請注意,資料包內部的值採用小端編碼。作用未知位元組標記為“???”。需要進一步檢查的資訊標記為“(?)"。
10.2.1. 資料包的一般形式¶
當裝置使用 RS232 進行通訊時,資料包的格式如下。
2B |
OP |
LEN |
DATA |
CS |
CS 是校驗和。它等於所有位元組的異或運算結果。
使用 USB 時
OP |
DATA |
2B、LEN 和 CS 欄位已消失,這可能是因為 USB 處理幀,並且資料損壞已得到處理或不重要。
首先,我描述裝置傳送給計算機的效果。
10.3. 裝置輸入狀態¶
此資料包用於指示每個按鈕的狀態和每個軸的值。
OP= 01 for a joystick, 03 for a wheel
LEN= Varies from device to device
00 X-Axis lsb
01 X-Axis msb
02 Y-Axis lsb, or gas pedal for a wheel
03 Y-Axis msb, or brake pedal for a wheel
04 Throttle
05 Buttons
06 Lower 4 bits: Buttons
Upper 4 bits: Hat
07 Rudder
10.4. 裝置效果狀態¶
OP= 02
LEN= Varies
00 ? Bit 1 (Value 2) is the value of the deadman switch
01 Bit 8 is set if the effect is playing. Bits 0 to 7 are the effect id.
02 ??
03 Address of parameter block changed (lsb)
04 Address of parameter block changed (msb)
05 Address of second parameter block changed (lsb)
... depending on the number of parameter blocks updated
10.4.1. 力反饋效果¶
OP= 01
LEN= 0e
00 Channel (when playing several effects at the same time, each must
be assigned a channel)
01 Wave form
Val 00 Constant
Val 20 Square
Val 21 Triangle
Val 22 Sine
Val 23 Sawtooth up
Val 24 Sawtooth down
Val 40 Spring (Force = f(pos))
Val 41 Friction (Force = f(velocity)) and Inertia
(Force = f(acceleration))
02 Axes affected and trigger
Bits 4-7: Val 2 = effect along one axis. Byte 05 indicates direction
Val 4 = X axis only. Byte 05 must contain 5a
Val 8 = Y axis only. Byte 05 must contain b4
Val c = X and Y axes. Bytes 05 must contain 60
Bits 0-3: Val 0 = No trigger
Val x+1 = Button x triggers the effect
When the whole byte is 0, cancel the previously set trigger
03-04 Duration of effect (little endian encoding, in ms)
05 Direction of effect, if applicable. Else, see 02 for value to assign.
06-07 Minimum time between triggering.
08-09 Address of periodicity or magnitude parameters
0a-0b Address of attack and fade parameters, or ffff if none.
*or*
08-09 Address of interactive parameters for X-axis,
or ffff if not applicable
0a-0b Address of interactive parameters for Y-axis,
or ffff if not applicable
0c-0d Delay before execution of effect (little endian encoding, in ms)
10.4.2. 基於時間的引數¶
10.4.2.1. 起效和消退¶
OP= 02
LEN= 08
00-01 Address where to store the parameters
02-03 Duration of attack (little endian encoding, in ms)
04 Level at end of attack. Signed byte.
05-06 Duration of fade.
07 Level at end of fade.
10.4.2.2. 幅度¶
OP= 03
LEN= 03
00-01 Address
02 Level. Signed byte.
10.4.2.3. 週期性¶
OP= 04
LEN= 07
00-01 Address
02 Magnitude. Signed byte.
03 Offset. Signed byte.
04 Phase. Val 00 = 0 deg, Val 40 = 90 degs.
05-06 Period (little endian encoding, in ms)
10.4.3. 互動引數¶
OP= 05
LEN= 0a
00-01 Address
02 Positive Coeff
03 Negative Coeff
04+05 Offset (center)
06+07 Dead band (Val 01F4 = 5000 (decimal))
08 Positive saturation (Val 0a = 1000 (decimal) Val 64 = 10000 (decimal))
09 Negative saturation
這裡的編碼有點特別:對於係數,它們是帶符號的值。最大值為 64(十進位制 100),最小值為 9c。對於偏移量,最小值為 FE0C,最大值為 01F4。對於死區,最小值為 0,最大值為 03E8。
10.4.4. 控制¶
OP= 41
LEN= 03
00 Channel
01 Start/Stop
Val 00: Stop
Val 01: Start and play once.
Val 41: Start and play n times (See byte 02 below)
02 Number of iterations n.
10.4.5. 初始化¶
10.4.5.1. 查詢特性¶
OP= ff
Query command. Length varies according to the query type.
The general format of this packet is:
ff 01 QUERY [INDEX] CHECKSUM
responses are of the same form:
FF LEN QUERY VALUE_QUERIED CHECKSUM2
where LEN = 1 + length(VALUE_QUERIED)
10.4.5.1.1. 查詢記憶體大小¶
QUERY = 42 ('B'uffer size)
裝置應回覆相同的資料包,並附加兩個位元組表示記憶體大小:ff 03 42 03 e8 CS 表示裝置有 1000 位元組的可用記憶體。
10.4.5.1.2. 查詢效果數量¶
QUERY = 4e ('N'umber of effects)
裝置應回覆同時可以播放的效果數量(一個位元組):ff 02 4e 14 CS 代表 20 種效果。
10.4.5.1.3. 廠商 ID¶
QUERY = 4d ('M'anufacturer)
查詢廠商 ID(2 位元組)
10.4.5.1.4. 產品 ID¶
QUERY = 50 ('P'roduct)
查詢產品 ID(2 位元組)
10.4.5.1.5. 開啟裝置¶
QUERY = 4f ('O'pen)
無資料返回。
10.4.5.1.6. 關閉裝置¶
QUERY = 43 ('C')lose
無資料返回。
10.4.5.1.7. 查詢效果¶
QUERY = 45 ('E')
傳送效果型別。如果支援則返回非零值(2 位元組)。
10.4.5.1.8. 韌體版本¶
QUERY = 56 ('V'ersion)
返回 3 位元組 - 主版本、次版本、修訂版本
10.4.5.2. 裝置初始化¶
10.4.5.2.1. 設定控制¶
注意
取決於裝置,在不同型號上可能不同!
OP= 40 <idx> <val> [<val>]
LEN= 2 or 3
00 Idx
Idx 00 Set dead zone (0..2048)
Idx 01 Ignore Deadman sensor (0..1)
Idx 02 Enable comm watchdog (0..1)
Idx 03 Set the strength of the spring (0..100)
Idx 04 Enable or disable the spring (0/1)
Idx 05 Set axis saturation threshold (0..2048)
10.4.5.2.2. 設定效果狀態¶
OP= 42 <val>
LEN= 1
00 State
Bit 3 Pause force feedback
Bit 2 Enable force feedback
Bit 0 Stop all effects
10.4.5.2.3. 整體設定¶
OP= 43 <val>
LEN= 1
00 Gain
Val 00 = 0%
Val 40 = 50%
Val 80 = 100%
10.4.6. 引數記憶體¶
每個裝置都有一定量的記憶體來儲存效果引數。記憶體大小可能有所不同,我遇到過 200 到 1000 位元組的值。下面是每組引數顯然所需的記憶體量:
週期 : 0c
幅度 : 02
起效和消退 : 0e
互動 : 08
10.5. 附錄:如何研究協議?¶
1. 使用 DirectX SDK 提供的力反饋編輯器生成效果,或使用 Immersion Studio(可在其網站的開發者部分免費獲取:www.immersion.com)。2. 啟動一個 RS232 或 USB 埠監視軟體(取決於您連線操縱桿/方向盤的方式)。我使用了 fCoder 的 ComPortSpy(alpha 版本!)。3. 播放效果,並觀察監視螢幕上的變化。
關於 ComPortSpy 的幾句話:乍一看,這個軟體似乎,嗯,有點……buggy。實際上,資料會出現幾秒的延遲。就我個人而言,每次播放效果時我都會重啟它。請記住它是免費的(如同免費啤酒)且處於 alpha 階段!
10.6. URLS¶
請訪問 http://www.immerse.com 獲取 Immersion Studio,訪問 http://www.fcoder.com 獲取 ComPortSpy。
I-Force 是 Immersion Corp. 的商標。