Linux and Hardware/OS Abstractions

This post will pretty much only be of interest to Linux users - everyone else, talk amongst yourselves.  Topic of discussion: X-Plane.com is neither a plane nor a communist.  (Sorry, work on the road processing code has drained me of any remaining sanity.)

Linux History

The brief history of X-Plane for Linux is that Joshua Wise ported X-Plane to Linux a while ago because he felt like it (and being too young to drive at the time, apparently had some free time).  The Linux port was never a commercial effort. - Laminar Research didn't say "we'll make a ton of money by porting to Linux, so let's hire someone".  It just sort of happened.  (Well, I wasn't in the room so I don't know exactly what was said.)

Linux has steadily represented about 5% of our user base from that point on, and this gets to the "commercial problem" of Linux: even with the work we do to try to keep platform specific code in X-Plane to a minimum, Linux sales don't justify the development cost to maintain the platform.

Yet there still is a Linux version of X-Plane.  We keep renewing the Linux port for "one more version" because while the Linux community doesn't buy a ton of copies of X-Plane, Linux users do contribute in an outsized way by providing code back to the scenery tools and other development efforts.  In other words, the Linux community doesn't contribute dollars, but they contribute a lot of code.

Code Contributions

This came up during the X-Plane 9 and 10 Linux discussions.  Our primary request to Linux users has been "please support each other".  There are too many Linux distributions for us to provide support; our dedicated support staff does not even have Linux expertise, so Linux support immediately hits engineering.

While a number of Linux users have really done a great job of helping other users out, another issue came up.  One of the ways we try to minimize Linux-specific costs is to keep the OS-specific code very basic and rudimentary.  In the past we've taken patches from users to fix OS specific bugs, but this is an awkward process at best.

Some Linux users asked if we could find a way to release source to the OS-specific parts of X-Plane so that they could improve the Linux-specific code (and thus the platform-specific experience) themselves.  Right now this is a very awkward process: I have to tell the user "give me a snippet that does X" and then hope that I can get the snippet integrated and tested on my own.

One of the suggestions that came up at the time was to separate out some of the code that abstracts the OS/hardware so that Linux users could patch it more easily.

A Hard Abstraction

Separating out the platform specific code is a good idea, but it wasn't one we were going to drop everything to pursue - if we did, the end result would be no improvement to X-Plane after some number of weeks of heavy development.  Instead, we are slowly moving the code in this direction as we work on it.

The first code to get a work-over is the joystick code; Chris has been refactoring the joystick code for a few weeks now.  10.10 won't show you any new behavior; it runs the existing UI on top of new low level code.  Once we are sure this works, Chris can implement a bunch of new joystick UI features on top of the new low level code quite easily.

The new joystick code separates out the OS-specific joystick interface code from the rest of X-Plane.  In the long term, this will make it practical for us to share the hardware abstraction code with users as source, take patches, and even allow developers to swap it out on their local development machines via a shared object.  We're not there yet with this level of flexibility, but the new code makes these things possible.

You Can Keep Your Hat On

There is one immediate win to the new code that will be apparent to Linux users in X-Plane 10.10: the new code (which is based on input.h instead of joystick.h) recognizes hat switches as a set of buttons, rather than a pair of axes; this is almost certainly better from a UI configuration standpoint.


  • Facebook
  • Reddit
  • Twitter
  • LinkedIn

About Ben Supnik

Ben is a software engineer who works on X-Plane; he spends most of his days drinking coffee and swearing at the computer -- sometimes at the same time.
This entry was posted in Development, Hardware. Bookmark the permalink.

35 Responses to Linux and Hardware/OS Abstractions

  1. Daniel says:

    "the new code (which is based on input.h instead of joystick.h) recognizes hat switches as a set of buttons, rather than a pair of axes"
    Thanks !!!!!

  2. simon says:

    Totally agree with your first sentence Ben!

  3. Jake says:

    One day soon I will really appreciate this and would just like to says thanks in advance. I tried the XP9 demo on my Thinkpad T60 and it was a tricolour slideshow due to the ancient graphics card I have. This means I really need to get a whole new set up but I keep postponing thinking the hardware will get cheaper or the game will be shinier for the same outlay (also this is the only game I'm interested in and hence the only thing that can't be accomplished currently although patience is sometimes required).
    Anyway I'm very glad the linux port exists and spread the word about Xplane to anyone who maybe interested. I hope this counts for something until I hand you my cash.
    Best of luck in all your future efforts, Jake

    • Jake says:

      I just re-read my comment and I didn't mean to cause anyone offence by calling this a game but I am anticipating it being fun which qualifies it in my opinion.

  4. I'm glad to read we won't need jhat to get the hat working, this was a bit tricky, so thank you for that effort !

    There is one point I want to clarify : <>. What do you intend by this ? Is it the last version of XPlane for Linux, or you will try to continue to developp Linux support but with no commitment ?

    Thanks.

    • Ben Supnik says:

      We will continue the Linux port for the rest of the v10 run; for the next major version we will re-evaluate, as we always do. We don't have any plans to drop Linux at v11, but for v10 we're not going to stop providing updates for Linux because we label the product as running on Linux.

  5. Ooops, the filter swallowed the sentence ! Here it is : We keep renewing the Linux port for “one more version” .

    By the way, one more question : what is your OSX market share ?

    Thanks.

  6. piotr says:

    Thank you for your efforts to keep linux version! There's a chance that linux will be more popular among X-Plane users over the time. Canonical expects that Ubuntu will be pre installed on 20mlns PC's this year. From my experience, X-Plane works great on Ubuntu, much better than on Windows 7 on the same hardware, so I think that this might be additional factor.

    • Ben Supnik says:

      We have nothing against Linux, but we're not expecting the market share to grow - only because it has been so completely stable at 5% for years now. Still, it's good that people have options.

  7. Toxe says:

    I migrated to Mac OS X four years ago, but until then I was primarily using Linux for many years and I think this is a very nice solution, allowing the community to contribute code!

    On a side note: I am fairly new to X-Plane (I was attracted by the XP10 shininess) and one of the things I absolutely love about it is that it feels a lot more open than comparable products / companies.

    Ben, all the infos and updates you post on this dev blog are greatly appreciated! Being a software developer myself it is really nice to read about what you guys are working on or what problems you face. I especially liked all you your OpenGL postings.

  8. Mike says:

    Ben,

    Are you meaning that the work Chris is doing on joystick code will be of UI asthetics and or performance enhancement in terms of more usable commands, esp useful for helos / multiple joystick peripherals plugged in?

    10.10+ should give a better feel for this if understood correctly. Anticipating to try this out in relatively near future in hopes 10.10 can make primetime shortly finally.
    Any blog updates for developers /users for code reinforcement or eta is appreciated.

    Regards

    • Chris Serio says:

      At this moment in time, the low-level USB/HID layer has been completely rewritten to support all of the features that we have planned. It's too early to mention what those are at this time but in general our goal is to make joystick device management easier/faster to setup, more intuitive to use and overall just more friendly to our users. There will be UI changes, there will be new device features but since it's code I haven't written yet, I don't want to get into too many details right now.

      • chris says:

        Sounds like quite some work and interesting & beneficial changes for Linux.

        Look forward to 10.10 news.

        • Chris Serio says:

          It's not just for linux...it's for Mac/Windows as well.

          • Mike says:

            I stand corrected, Those users shall benefit too soon.

          • Ben Supnik says:

            To be clear:
            - Chris's reworking of the joystick code will allow him to build a new better user experience for _all_ platforms.
            - We are particularly looking to make it easier for users to modify the hardware code for Linux, because that's the only platform with that kind of user demand (user demand to mod the code).

      • Bill says:

        Chris,

        Does this have anything to do with hidapi? As a user myself have been very pleased with the results. Thanks for the Linux support as this is why I am using and developing for X-Plane.

        Bill (sparker)

        • Ben Supnik says:

          We are using HIDAPI on Mac/Lin to talk to HID devices, but not Linux - for Linux we have to use input.h. The problems on Linux are three-fold:
          1. HIDAPI doesn't feature a HID report descriptor parser (and descriptor parsing is not trivial). So it doesn't provide the pre-parsed data that we need.
          2. In some cases, the device permissions to view an input device as HID (and not as the more specific input/joy) require root permission. We do not want to have to walk our users through modifying udev to use their joystick - it really has to just work.
          3. It appears that most modern distros come with hidraw, but the regular hid driver (the one where the OS parses the descriptor) is often compiled out.

          If anyone ever resolves these issues we could use HIDAPI on three platforms instead of two, which might be nice for sharing presets across platforms. But we're prepared to ship with input.h for now.

  9. Tom Knudsen says:

    I do understand that there might not be that much marked for Linux usage, but to drop the platform entierly (hopefully i'd understood that wrong?) is just plain sad. X-plane should be able to be played at Linux, as it is a growing framework usage and more and more will convert as the distros gets better and better (ref. Ubuntu, Mint, Fedora etc.)

    I've tried XP10 on Linux and I can say for sure that it has far better performance than Windows 64bit has (though no support for 64bit yet), so it would be a shame to not have further updates to Linux if so inteded.

    What about MAC, is there a hole lot of selling marked shares there? I guess there is, but I would bet there is not more than Windows, am i right?

    I do hope I got this all wrong and we will still see X-plane for Linux in the future as well..

    PS..
    Thanks a bunch for the Hat On

    • Ben Supnik says:

      Huh? I think you totally misunderstood the post. I will make this as simple as we possibly can.

      We are not dropping Linux support.

      • Tom Knudsen says:

        Let me tell you Ben, that would be the mistake I am most happy to have made 🙂 Thank you!
        Language barriers are not all that in my favour LOL..

  10. cestomano says:

    These are good news for Linux community (about abstracting code)! 🙂

    But, in the other hand, future about linux support in XP11, Xp12... 🙁

    Yes, Linux users are 5% of XP users but... are they (us) 5% of market? I think is more. An example: http://www.omgubuntu.co.uk/2012/06/latest-humble-bundle-now-officially-the-biggest-grossing-ever (sorry about link to another website): "Linux Users Still Pay Most".

    I think (I "think") almost all linux users bought XP10 but... I can't say the same about another plataforms.

    Cheers

  11. carrotroot says:

    "We are not dropping Linux support ... But if it where up to me I woulda snuffed out Josh Wise long ago. However, thanks for all the fish!"

    There fixed it for you Ben.

  12. erikb says:

    Has the X-Plane team considered SDL? (start at http://www.libsdl.org/ and the Wikipedia page https://en.wikipedia.org/wiki/Simple_DirectMedia_Layer) It seems to me that it is made to handle exactly this type of situation, and could keep you from rolling your own solution. (But what do I -- some outsider -- know about how it would mesh with the X-Plane codebase... 🙂 I assume the team has investigated cross-platform abstraction options, but just wanted to throw out the suggestion on the chance that's not the case.

    Even though my flightsim PC runs windows since most other games & sims are windows(-only), I still really appreciate the fact that X-Plane is multi-platform. I like knowing I won't have to abandon X-Plane in case I ditch windows in the future, or someday when I can build a multi-projector setup, I can save a little by installing a free OS on the other display machines. So thanks for keeping it multi-platform.

    • Ben Supnik says:

      Chris and I should have started a betting pool as to how long before someone said "why not SDL."

      We looked at SDL but its functionality (in multiple areas) is often not rich enough to build the user experience we want. Sometimes the SDL API does less than our OS specific code now, and in sometimes it's about the same but doesn't contain the new features that we want. In some cases, modifying SDL to do what we want would be _highly_ non-trivial.

      For example, for input devices we want to be able to track the addition/removal of hardware on the fly for hot-swapping devices, and pull as much meta-data off of the device as possible so that we can pre-initialize a device sanely, or load a preset for a known device.

  13. thorax says:

    Linux customers may be 5% but as you suspected they are the ones that contribute the most. Every serious developer uses Linux. It would be a big step back if you decide in the future drop the linux version.

  14. Ondrej says:

    Thank you for this post and you're absolutely right about Linux users contributing code or other things to XP. I think a lot of developers do work with Linux and they contribute in many ways, with third party software/libraries, plugins or tools. I for myself am counting me to the ones contributing tools for XP. Keep up the good work and this interesting blog.

  15. Fran says:

    Thanks for the insights, Ben. Hate to request features using your nice blog, but here we go 🙂 A few of us DONT use joystick mapping to drive X-Plane, but existing datarefs. (the ones indicating yoke deflection and so on).

    We already suffer some issues (like X-Plane thinking there's no Joystick and drawing a "nice" cross for flying with the mouse, or, as far as I can tell, different settings (like linearity) not being applied to our inputs, so wanted to ask if at least we will be keeping same functionality.

    Essentially our cockpits talk with X-Plane using a TCP connection and a plugin, which exposes our HW to all data refs. For us, elevator is no different than throttle, so would rather keep using a dataref rather than emulating a Joystick.

    • Ben Supnik says:

      There is no change to the dataref interface or UI behavior in 10.10.

      When we redo the UI, we will continue to support the existing datarefs.

      In the long term there's probably a better way to allow for third party hardware but that's not a short term priority.

  16. Max says:

    How is your progress on 10.10?

    • NLS says:

      I second the question... it's been long without betas or releases eh?
      Also is x64 windows code coming as you guys said would come?

      • Chris Serio says:

        Please keep the comments on-topic guys. We don't like having to moderate and remove off-topic responses.

        The developer's blog is not an open topic forum and it's especially not intended as a way to solicit information from the developers on status.

Comments are closed.