Table of Contents

Work In Progress

Ergodex DX1 protocol

Written By Dominic Clifton (C) 2007

Overview

Data is transferred to and from the Ergodex DX1's second interface in multiple of 16 bytes. We refer this second interface as the “Control” interface. The first interface is a HID USB Keyboard.

After snooping the USB communications between the host machine and the Ergodex DX1 the following information has been compiled.

We split up the information into requests and responses

Control Requests

16 bytes per request.

* Byte 1: Request Code

* Bytes 2-16: Request Data

Request data is different for each request.

Set Device

Usage

Send when device is idle.

Request Code

0x02

Request Data

The 15 byes of request data is made up as follows:

0x01 - enable "Test" mode.

When the device is in this mode will cause a “Control” device “Key Test” event to be raised when pressing or releasing any key. There is something rather odd about test mode though. If the RED LED is OFF you will receive up to 6 keypresses in the “Key Test” reponse. However, if the RED LED is ON and you press and hold one key and then press and hold another key you'll get a “Key Test” event with no key press information. Thus, you'll never be able to check for more than one key pressed at a time when in “Test” mode and the RED LED is ON. Weird.

0x00 - normal mode
0x00 - 00000000 - all led's off
0x01 - 00000001 - green led on, red led off
0x02 - 00000010 - green led off, red led on
0x03 - 00000011 - green led on, red led on
0x00 - enable keymap, all programmed keys will now send back data when pressed
0x01 - clear keymap, all previously programmed keys are cleared from the device's memory.

If the pad has been previously sent a set device command with this set to 0x01 sending subsequently setting this to 0x00 has no apparent effect. If it's never set to 0x01 the pad does not seem to send any data back. TODO: investigate more.

If the pad has been previously sent a set device command with this set to 0x01 sending subsequently setting this to 0x00 has no apparent effect. If it's never set to 0x01 the pad does not seem to send any data back. TODO: investigate more.

Examples:

00 00 01 00 01 01 01 00 00 00 00 00 00 00 00
00 00 01 00 00 01 01 00 00 00 00 00 00 00 00
00 01 01 00 01 01 01 00 00 00 00 00 00 00 00

Contents unknown at present.

Program Keys

Usage

Program up to 5 keys per requests

Request Code

0x03

Request Data

3 bytes per key (below) If a key is not to be programmed then pad the request with 0x00's

Then for each key that has a single key macro assigned to it sends 3 bytes

Key types:

0x01 - "Single Key"
0x02 - "Modifier Key"
0x03 - "Macro"

When key is:

Byte 3: Set to a valid Keyboard Scan Code

See Keyboard Scan Code Specification [References 1,2] Appendix C: USB Keyboard/Keypad Page (0x07)

Byte 3: Set as follows

0x01 LEFT CTRL
0x02 LEFT SHIFT
0x04 LEFT ALT
0x08 LEFT WIN KEY (Left GUI Key)
0x10 RIGHT CTRL
0x20 RIGHT SHIFT
0x40 RIGHT ALT
0x80 RIGHT WIN KEY (Right GUI Key)

Byte 3: Empty Value (0x00)

When keys are assigned “Single” or “Modifer” keys data is received by the HID interface for key up and key down events (8 bytes per event, see below)

When keys are assigned “Macro” keys data is received by the “control” interface for key up and key down events (16 bytes per event)

Example of data sent when switching to an application that has a profile enabled for it.

000003: Bulk or Interrupt Transfer (UP), 06.02.2007 14:50:42.4375000 +5.0312500
Pipe Handle: 0x88094694 (Endpoint Address: 0x2)
Send 0x10 bytes to the device:
 02 00 00 01 00 01 01 01 00 00 00 00 00 00 00 00   ................
000004: Bulk or Interrupt Transfer (UP), 06.02.2007 14:50:42.4843750 +0.0468750
Pipe Handle: 0x88094694 (Endpoint Address: 0x2)
Send 0x30 bytes to the device:
 03 01 02 02 02 03 00 03 03 00 04 03 00 0E 03 00   ................
 03 12 03 00 18 03 00 1B 03 00 29 03 00 2C 03 00   ..........)..,..
 02 00 00 01 00 00 01 01 00 00 00 00 00 00 00 00   ................

Status Inquiry

Usage

Sent when device is idle.

Request Code

0x01

Request Data

Fill with 0x00's

Get Device Information

Use to request a “Device Information” response.

Usage

Sent when device is idle.

Request Code

0x0A

Request Data

Fill with 0x00's

Unknown Command 1

The Ergodex software sends this command when recording macros. It has the effect of momentarily turning of the red LED. The green LED remains on. The command it sent once a second and the red led blinks off once a second.

Usage

Only seen being sent when the device is in “Test” mode.

Request Code

0x08

Request Data

Unknown.

Here's what the ergodex software sends (complete request, including command code).

08 00 00 00 00 00 01 01 00 00 00 00 00 00 00 00

Event and Response Data

HID Events are triggered by the device when keys are pressed on it. Which events you receive depend upon the device's status.

HID Events

The HID interface receives the following events:

Each HID event causes the device to send 8 bytes of data.

If a key assigned to a “Modifier Key” is pressed at the same time as one or more keys assigned to “Modifier Key” or a single key assigned to “Single Key” then only one event is received and the data is combined. e.g. if you assign keys 1-Shift, 2-Control, 3-A, 4-B and press 1 2 and 3 at the same time you'll get one event, if you press keys 1-4 you'll get two events. (TODO: double check)

There's not much point going into further detail regarding the HID event data as it should be the same as any other standard USB keyboard.

One thing to note is if you program keys 1-3 with ctrl and alt and shift and press them all at the same time you receive the following data

07 00 00 00 00 00 00 00

This indicates the values are additive, it has been reported it's possible to assign a key to “Modifier Key” and use the value 0x07 which simulates pressing all the keys together.

Control Responses

The ergodex pad sends the sends data to the control interface when:

Data is set to the control interface in 16 byte blocks.

Status Changed

Sent in response to a status inquiry request or because the device's status changed due to the “Hand” or “Record” buttons being pressed.

Event Type Code

0x01

Data

The remaining 15 bytes of data is made up as follows

The first two bits indicate the current status of the buttons

0x00 - 00 - both buttons pressed
0x01 - 01 - record button pressed
0x02 - 10 - hand button pressed
0x03 - 11 - no buttons pressed

When these two bits are inverted they make up a bitmask of the button status. When inverted the first bit (lsb) is 1 when the hand button is pressed and the second bit is 1 when the record button is pressed.

example:

#define PRES_EROGODEXDX1_OFFSET_STATUS_BUTTONS 0x04

#define PRES_EROGDEXDX1_BITMASK_BUTTON_HAND    ( 1 << 0 )
#define PRES_EROGDEXDX1_BITMASK_BUTTON_RECORD  ( 1 << 1 )

BOOL bRecordButtonPressed = !(*(pResponseData + PRES_EROGODEXDX1_OFFSET_STATUS_BUTTONS) & PRES_EROGDEXDX1_BITMASK_BUTTON_RECORD);
BOOL bHandButtonPressed = !(*(pResponseData + PRES_EROGODEXDX1_OFFSET_STATUS_BUTTONS) & PRES_EROGDEXDX1_BITMASK_BUTTON_HAND);

It looks like byte 5 is set as follows:

0x01 - keys are enabled
0x00 - keys are disabled

Macro Key Pressed

Sent as soon as a key assigned to “Macro Key” is pressed or released.

Event Type Code

0x02

Data

The remaining 15 bytes of data is made up as follows

When a key is pressed the values corresponds to number printed on the physical keys

If one key is pressed then byte 3 will be the number of the key pressed, bytes 4-8 will contain 0x00

If two keys are pressed then byte 3 and 4 will contain the numbers of the key that are currently pressed in random order, bytes 5-8 will contain 0x00

… and so on, up to 6 keys.

When all keys are released bytes 3-8 will be filled with 0x00.

Test

Sent as soon as a key is pressed or released when the device is in “Test” mode.

Event Type Code

0x03

Data

The data for this response appears to be the same as the “Macro Key Pressed” response, except that you will only ever receive information about 1 key being pressed instead of up to 6 when the RED LED is ON. If two keys are pressed Bytes 3-8 will be filled with 0x00. If the RED LED is OFF you'll receive information about multiple keys in bytes 3-8. See “Set Device”, above.

Device Information

Sent in response to a “Get Device Information” request

Event Type Code

0x0A

Data

The remaining 15 bytes of data is made up as follows

References

- Key Support, Keyboard Scan Codes, and Windows

http://www.microsoft.com/whdc/device/input/Scancode.mspx

- Keyboard Scan Code Specification

http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/scancode.doc