motion data should be structured
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
pyfreespace |
Invalid
|
Undecided
|
JT Burgess |
Bug Description
The motion data is returned as a string. For example:
s = device.
The content of s is:
"UserFrame(
This string can be parsed easily. However it would be more convenient to receive:
s = {
"type": "userframe",
"buttons": [False, False, False, False, False],
"delta": [0, 0, 0],
"sequenceNu
"linearPosi
"angularPos
}
An alternative is to return the structure above in JSON format.
Actually, readMessage does not return a string, it returns an object. The type of the object returned depends on the message received, but in this case it's actually of type freespace.UserFrame
If you run
> s = device. readMessage( 500)
> dir(s)
you can see that s actually has a number of read-only attributes to it, which are the fields listed in the string representation above.
You can access each field by doing
s.button1 (which is a boolean)
s.linearPosX (which is an integer)
etc.