Glad to hear of your interest in enabling OpenMx to be able to read directly from PLINK and BGEN formats.
Mega2 has a long and convoluted history, starting as a C program, but more recently we've reorganized it as a C++ program and improved our use of object-oriented programming, and have now decoupled it into two parts: (1) the reading/decoding of the input data and storage of that data in a Mega2 SQLite database, and (2) the reformatting of data stored in a Mega2 database into a desired target format. So maybe you could merge the Part 1 reading/decoding code into OpenMx and instead of having it output into the SQLite database could have it reformat into what OpenMx needs?
This decoupling of decoding into a standard Mega2 SQLite database has proved useful in that our Mega2R R package now simply reads its input from a Mega2 database, and so for that package we didn't need to write any input code in R supporting lots of different input formats. However, of course, we do have to initially run Mega2 to create the input Mega2 database.
Thanks,
Dan