-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UDP pipe for OpenTrack #191
Comments
I just did this myself and it worked well, changes only necessary to ltr_pipe.c. The problem I'm running into is that yaw / pitch / roll are affecting x / y / z while using a trackIR5 with the protrack clip on the side of the head. If anyone minds improving this so that there's an option to mitigate translation with this setup, that'd be rad. I launch the ltr_pipe with a quick script I made called trackIR_start.sh :
which helps to keep all the output quiet and unlinks it from the shell it started it, and then is stopped with a Anyway, here's the changes I made to ltr_pipe.c: index b8c94f3..4f999c9 100644
--- a/src/ltr_pipe.c
+++ b/src/ltr_pipe.c
@@ -109,6 +109,7 @@ enum formats {
FORMAT_UINPUT_ABS = 7, // uinput absolute position (like a joystick)
#endif
FORMAT_IL2_6DOF = 8, // For IL-2 Shturmovik v4.11+ (6DOF) with DeviceLink protocol
+ FORMAT_OPENTRACK = 9, // For opentrack UDP over network
};
@@ -122,7 +123,7 @@ struct args
char *ltr_profile;
char *ltr_timeout;
enum formats format;
- int range;
+ int range;
};
static struct args Args = {
@@ -133,7 +134,7 @@ static struct args Args = {
.ltr_profile = NULL, // DEFAULT_LTR_PROFILE
.ltr_timeout = DEFAULT_LTR_TIMEOUT,
.format = FORMAT_DEFAULT,
- .range = 4096
+ .range = 4096
};
:...skipping...
diff --git a/src/ltr_pipe.c b/src/ltr_pipe.c
index b8c94f3..4f999c9 100644
--- a/src/ltr_pipe.c
+++ b/src/ltr_pipe.c
@@ -109,6 +109,7 @@ enum formats {
FORMAT_UINPUT_ABS = 7, // uinput absolute position (like a joystick)
#endif
FORMAT_IL2_6DOF = 8, // For IL-2 Shturmovik v4.11+ (6DOF) with DeviceLink protocol
+ FORMAT_OPENTRACK = 9, // For opentrack UDP over network
};
@@ -122,7 +123,7 @@ struct args
char *ltr_profile;
char *ltr_timeout;
enum formats format;
- int range;
+ int range;
};
static struct args Args = {
@@ -133,7 +134,7 @@ static struct args Args = {
.ltr_profile = NULL, // DEFAULT_LTR_PROFILE
.ltr_timeout = DEFAULT_LTR_TIMEOUT,
.format = FORMAT_DEFAULT,
- .range = 4096
+ .range = 4096
};
@@ -161,8 +162,9 @@ enum option_codes {
#endif
OPT_FORMAT_IL2_6DOF = 0x11,
#ifdef LINUX
- OPT_UINPUT_ABS_RANGE = 0x12
+ OPT_UINPUT_ABS_RANGE = 0x12,
#endif
+ OPT_FORMAT_OPENTRACK = 0x13
};
@@ -283,12 +285,18 @@ static struct option Opts[] = {
0,
OPT_FORMAT_UINPUT_ABS
},
- {
- "uinput-abs-range",
- required_argument,
- 0,
- OPT_UINPUT_ABS_RANGE
- },
+ {
+ "uinput-abs-range",
+ required_argument,
+ 0,
+ OPT_UINPUT_ABS_RANGE
+ },
+ {
+ "format-opentrack",
+ no_argument,
+ 0,
+ OPT_FORMAT_OPENTRACK
+ },
#endif
{ 0, 0, 0, 0 }
};
@@ -343,6 +351,7 @@ static void help(void)
" --format-uinput-rel uinput relative position (like a mouse)\n"
" --format-uinput-abs uinput absolute position (like a joystick)\n"
" --uinput-abs-range=RANGE specify precision of abs device (-RANGE to +RANGE)\n"
+" --format-headtrack Opentrack UDP over network compatible format\n"
#endif
"\n",
@@ -418,6 +427,9 @@ static void parse_opts(int argc, char **argv)
case OPT_FORMAT_SILENTWINGS:
Args.format = FORMAT_SILENTWINGS;
break;
+ case OPT_FORMAT_OPENTRACK:
+ Args.format = FORMAT_OPENTRACK;
+ break;
case OPT_FORMAT_MOUSE:
Args.format = FORMAT_MOUSE;
break;
@@ -656,9 +668,9 @@ static void ofd_setup_file(void)
xioctl(UI_SET_ABSBIT, ABS_RX);
xioctl(UI_SET_ABSBIT, ABS_RY);
xioctl(UI_SET_ABSBIT, ABS_RZ);
- xioctl(UI_SET_EVBIT, EV_KEY);
- xioctl(UI_SET_KEYBIT, BTN_JOYSTICK);
- xioctl(UI_SET_KEYBIT, BTN_TRIGGER);
+ xioctl(UI_SET_EVBIT, EV_KEY);
+ xioctl(UI_SET_KEYBIT, BTN_JOYSTICK);
+ xioctl(UI_SET_KEYBIT, BTN_TRIGGER);
ud.absmin[ABS_X] = ud.absmin[ABS_RX] = -Args.range;
ud.absmin[ABS_Y] = ud.absmin[ABS_RY] = -Args.range;
@@ -889,7 +901,6 @@ static void write_data_default(const struct ltr_data *d)
xwrite(buf, r);
}
-
/**
* write_data_flightgear() - Write data in FlightGear format
* @d: Data to write.
@@ -905,6 +916,36 @@ static void write_data_flightgear(const struct ltr_data *d)
xwrite(buf, r);
}
+/**
+ * write_data_opentrack() - Write data in Opentrack format
+ * @d: Data to write.
+ **/
+static void write_data_opentrack(const struct ltr_data *d)
+{
+ const size_t bsz = 48;
+ double buf[6];
+ double tmp;
+
+ tmp = (double) d->x;
+ memcpy(&buf[0], &tmp, sizeof(double));
+
+ tmp = (double) d->y;
+ memcpy(&buf[1], &tmp, sizeof(double));
+
+ tmp = (double) d->z;
+ memcpy(&buf[2], &tmp, sizeof(double));
+
+ tmp = (double) d->h;
+ memcpy(&buf[3], &tmp, sizeof(double));
+
+ tmp = (double) d->p;
+ memcpy(&buf[4], &tmp, sizeof(double));
+
+ tmp = (double) d->r;
+ memcpy(&buf[5], &tmp, sizeof(double));
+
+ xwrite(buf, bsz);
+}
/**
* write_data_il2() - Write data in IL-2 Shturmovik DeviceLink format
@@ -1131,7 +1172,9 @@ static void write_data(const struct ltr_data *d)
case FORMAT_MOUSE:
write_data_mouse(d);
break;
-
+ case FORMAT_OPENTRACK:
+ write_data_opentrack(d);
+ break;
#ifdef LINUX
case FORMAT_UINPUT_REL:
case FORMAT_UINPUT_ABS: |
Thank you! |
In linuxtrack there's a few options for "Thee point Clip finetuning" on the model setup page, which I have completely disabled as they really messed things up on the UDP output to opentrack. I also disabled xyz, and I used the cinnamon keyboard desktop keybinds to run recentering (linuxtrack recenter with rctrl+home, opentrack recenter with home). I'm a little annoyed because in the linuxtrack preview window it doesn't appear to have any difficulty whatever with translation vs rotation, but opentrack is definitely not compensating for the fact the clip is on the side of my head. I feel necessary to say that I do not have an abnormally fat head. In linuxtrack I have sensitivity halfway up for pitch+yaw, roll is half that, and then translations are half of roll. Common smoothing is halfway. Oh, and I set a curve on the output in linuxtrack for pitch yaw and roll as well, so that my head doesn't constantly drift when I'm sat there trying to keep my head still. At this point its working so well for me that I'm not trying to make it any better, but if I find some missing feature that could benefit by offsets then I may come back to do more coding in the future. Keep me posted! |
Hmm, I have though a feeling LinuxTrack is not affecting the output of ltr_pipe at all, it is more reading the output of ltr_pipe, modifies it, and sends it some other way. I need to look in the code when I get some time, seeing if I can implement some more options in ltr_pipe.c for i.e. if you are using a trackclip pro and having it on left or right side. ltr_gui feels like it is abundant, as it is enough to run ltr_pipe, and then using opentrack for managing the data. Edit: |
I can see somebody have already wished for support for proton. As an alternative an UDP over network pipe to opentrack would also could solve the problem since they already have proton support.
The text was updated successfully, but these errors were encountered: