Code Monkey home page Code Monkey logo

xpanel's Introduction

XPanel

Detailed description and configuration options can be found here

XPanel is a plugin for X-Plane >=11 flight simulator. If you have or plan to build a home cockpit then it is good to check this. It can connect your USB HID hardware devices to the X-Plane system.

It has a configuration file where you can define the logical connections between hardware elements (buttons, switches, displays, etc) and the internal datarefs and commands of X-Plane.

Currently, it supports these types of USB-HID devices:

Device URL Description
MultiPanel Saitek Multi Panel This is a device that mainly contains the buttons associated with the autopilot functions
RadioPanel Saitek Radio Panel Device to control radio functions of your airplane
SwitchPanel Saitek Switch Panel Device with switches to control the electrical systems of your plane
FIP Logitech/Saitek Flight Instrument Panel Device with a graphical screen to display aircraft instruments (supported only on Windows)
TRC100 TRC-1000 PFD/MFD & Audio Panel These devices are replica of Garmin G1000 cockpit panels
Custom USB HID devices Custom USB HID Devices You can use a custom USB HID device like Arduino Leonardo board

Install

Windows

Get the latest release from github

Copy the xpanel folder into your X-Plane plugin directory (in my case it is c:\XPlane12\resources\plugins).

Please don't forget to remove any other plugins that want to connect to your USB Hid devices in the home cockpit.

The aircraft-specific configuration file (xpanel.ini) shall be put into the aircraft folder.

If you have any errors during the plugin load or run please check the main X-Plane log file. If you want more detailed logs from the plugin, please set the log level to DEBUG or even TRACE. See the details at troubleshooting

Linux

Get the latest release from github Copy the xpanel folder into your X-Plane plugin directory.

udev rules

You need to add the appropriate udev rules to grant access permissions for the devices

For the Saitek devices you need to set udev rules like this:

/etc/udev/rules.d/99-saitek.rules

KERNEL=="hidraw*", ATTRS{idProduct}=="0d67", ATTRS{idVendor}=="06a3", MODE="0666", SYMLINK+="saitekswitchpanel"
KERNEL=="hidraw*", ATTRS{idProduct}=="0d05", ATTRS{idVendor}=="06a3", MODE="0666", SYMLINK+="saitekradiopanel"
KERNEL=="hidraw*", ATTRS{idProduct}=="0d06", ATTRS{idVendor}=="06a3", MODE="0666", SYMLINK+="saitekmultipanel"
BUS=="usb", ATTRS{idProduct}=="0d05", ATTRS{idVendor}=="06a3", MODE="0666"
BUS=="usb", ATTRS{idProduct}=="0d06", ATTRS{idVendor}=="06a3", MODE="0666"
BUS=="usb", ATTRS{idProduct}=="0d67", ATTRS{idVendor}=="06a3", MODE="0666"

If you have an Arduino based board, please add this rule:

/etc/udev/rules.d/99-leonardo.rules:

KERNEL=="hidraw*", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="8036", MODE:="0666", SYMLINK+="arduinoleonardo"
BUS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="8036", MODE="0666"

After setting the above rules, please don't forget to reload them

udevadm control --reload

Build

Windows

Check out the latest source file from github

Open the solution file (XPanel.sln) with Visual Studio. Select either Release or Debug build configuration. The solution file contains two projects. One for the xpanel plugin and one for the unit tests.

The build artifact of the plugin is generated in the Release|Debug/plugin/xpanel folder (win.xpl file)

You can also use cmake to build the plugin on Windows

Run unit tests

To run the unit tests, open the Visual Studio test menu and select Test Explorer. Push the run-all button and check the test results.

Linux

Check out the latest source file from github

Dependencies:

  • C++ toolchain
  • CMake
  • pkg-config
  • libudev
  • Lua
$ cmake --install-prefix /tmp/xpanel-install -S . -B build
$ cmake --build build
$ cmake --install build

macOS

Dependencies:

brew install lua
brew install pkg-config

Copy or link the /tmp/xpanel-install/XPanel directory into the X-Plane plugin folder.

Report bugs

If you find any bug in the plugin or need help please open a new bug report at github Please always attach the X-Plane log file and make sure you set the highest log level (TRACE) in the plugin config file. Also attach your plugin configuration file as well.

xpanel's People

Contributors

alltilla avatar mranno avatar norberttak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

xpanel's Issues

[BUG] Negative number display doesn't work

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior like this:
Configure the plugin to display a dataref that has negative value.

Expected behavior
Negative number is displayed properly

[BUG] hid_send_feature_report error on Gentoo Linux

Describe the bug
With attached xpanel.ini and Saitek Radio Panel connected to USB, plugin crash and x-plane with it

To Reproduce
Steps to reproduce the behavior like this:

  1. Attach saitek device
  2. Run X-Plane12 and select aircraft (ZIBO 4.01.9)
  3. Start flight
  4. X-Plane crash

Expected behavior
Flight start

** X-Plane log file **
Log.txt

xpanel.ini content:

; Aircraft specific handler for Zibo 737 XPlane aircraft
log_level="DEBUG"
aircraft_acf="b738_4k.acf"

;---------------------- Saitek Radio Panel -------------------------
[device:id="saitek_radio"]
vid="6a3"
pid="d05"

[multi_display:id="RADIO_DISPLAY_ACTIVE_UP"]
line="on_select:SW_UP_COM1,dataref:sim/cockpit/radios/com1_freq_hz"
line="on_select:SW_UP_COM2,dataref:sim/cockpit/radios/com2_freq_hz"
line="on_select:SW_UP_NAV1,dataref:sim/cockpit/radios/nav1_freq_hz"
line="on_select:SW_UP_NAV2,dataref:sim/cockpit/radios/nav2_freq_hz"
line="on_select:SW_UP_ADF,dataref:sim/cockpit/radios/adf1_freq_hz"
line="on_select:SW_UP_IDT,dataref:sim/cockpit/radios/transponder_code"

[multi_display:id="RADIO_DISPLAY_STBY_UP"]
line="on_select:SW_UP_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz"
line="on_select:SW_UP_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz"
line="on_select:SW_UP_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz"
line="on_select:SW_UP_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz"
line="on_select:SW_UP_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz"

[button:id="KNOB_UP_BIG_PLUS"]
on_push="on_select:SW_UP_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz:100:0:15000"
on_push="on_select:SW_UP_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz:100:0:15000"
on_push="on_select:SW_UP_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz:100:0:15000"
on_push="on_select:SW_UP_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz:100:0:15000"
on_push="on_select:SW_UP_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz:100:0:359"
on_push="on_select:SW_UP_IDT,dataref:sim/cockpit/radios/transponder_code:100:0:8888"

[button:id="KNOB_UP_BIG_MINUS"]
on_push="on_select:SW_UP_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz:-100:0:16000"
on_push="on_select:SW_UP_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz:-100:0:16000"
on_push="on_select:SW_UP_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz:-100:0:16000"
on_push="on_select:SW_UP_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz:-100:0:16000"
on_push="on_select:SW_UP_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz:-100:0:359"
on_push="on_select:SW_UP_IDT,dataref:sim/cockpit2/radios/actuators/transponder_code:-100:0:8888"

[button:id="KNOB_UP_SMALL_PLUS"]
on_push="on_select:SW_UP_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz:5:0:15000"
on_push="on_select:SW_UP_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz:5:0:15000"
on_push="on_select:SW_UP_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz:1:0:15000"
on_push="on_select:SW_UP_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz:1:0:15000"
on_push="on_select:SW_UP_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz:1:0:359"
on_push="on_select:SW_UP_IDT,dataref:sim/cockpit/radios/transponder_code:1:0:8888"

[button:id="KNOB_UP_SMALL_MINUS"]
on_push="on_select:SW_UP_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz:-5:0:16000"
on_push="on_select:SW_UP_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz:-5:0:16000"
on_push="on_select:SW_UP_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz:-1:0:16000"
on_push="on_select:SW_UP_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz:-1:0:16000"
on_push="on_select:SW_UP_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz:-1:0:359"
on_push="on_select:SW_UP_IDT,dataref:sim/cockpit2/radios/actuators/transponder_code:-1:0:8888"

[button:id="ACT_STBY_UP"]
on_push="on_select:SW_UP_COM1,commandref:sim/radios/com1_standy_flip:once"
on_push="on_select:SW_UP_COM2,commandref:sim/radios/com2_standy_flip:once"
on_push="on_select:SW_UP_NAV1,commandref:sim/radios/nav1_standy_flip:once"
on_push="on_select:SW_UP_NAV2,commandref:sim/radios/nav2_standy_flip:once"
on_push="on_select:SW_UP_ADF,commandref:sim/radios/adf1_standy_flip:once"



[multi_display:id="RADIO_DISPLAY_ACTIVE_DOWN"]
line="on_select:SW_DOWN_COM1,dataref:sim/cockpit/radios/com1_freq_hz"
line="on_select:SW_DOWN_COM2,dataref:sim/cockpit/radios/com2_freq_hz"
line="on_select:SW_DOWN_NAV1,dataref:sim/cockpit/radios/nav1_freq_hz"
line="on_select:SW_DOWN_NAV2,dataref:sim/cockpit/radios/nav2_freq_hz"
line="on_select:SW_DOWN_ADF,dataref:sim/cockpit/radios/adf1_freq_hz"
line="on_select:SW_DOWN_IDT,dataref:sim/cockpit/radios/transponder_code"

[multi_display:id="RADIO_DISPLAY_STBY_DOWN"]
line="on_select:SW_DOWN_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz"
line="on_select:SW_DOWN_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz"
line="on_select:SW_DOWN_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz"
line="on_select:SW_DOWN_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz"
line="on_select:SW_DOWN_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz"

[button:id="KNOB_DOWN_BIG_PLUS"]
on_push="on_select:SW_DOWN_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz:100:0:15000"
on_push="on_select:SW_DOWN_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz:100:0:15000"
on_push="on_select:SW_DOWN_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz:100:0:15000"
on_push="on_select:SW_DOWN_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz:100:0:15000"
on_push="on_select:SW_DOWN_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz:100:0:359"
on_push="on_select:SW_DOWN_IDT,dataref:sim/cockpit/radios/transponder_code:100:0:8888"

[button:id="KNOB_DOWN_BIG_MINUS"]
on_push="on_select:SW_DOWN_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz:-100:0:16000"
on_push="on_select:SW_DOWN_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz:-100:0:16000"
on_push="on_select:SW_DOWN_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz:-100:0:16000"
on_push="on_select:SW_DOWN_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz:-100:0:16000"
on_push="on_select:SW_DOWN_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz:-100:0:359"
on_push="on_select:SW_DOWN_IDT,dataref:sim/cockpit2/radios/actuators/transponder_code:-100:0:8888"

[button:id="KNOB_DOWN_SMALL_PLUS"]
on_push="on_select:SW_DOWN_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz:5:0:15000"
on_push="on_select:SW_DOWN_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz:5:0:15000"
on_push="on_select:SW_DOWN_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz:1:0:15000"
on_push="on_select:SW_DOWN_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz:1:0:15000"
on_push="on_select:SW_DOWN_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz:1:0:359"
on_push="on_select:SW_DOWN_IDT,dataref:sim/cockpit/radios/transponder_code:1:0:8888"

[button:id="KNOB_DOWN_SMALL_MINUS"]
on_push="on_select:SW_DOWN_COM1,dataref:sim/cockpit/radios/com1_stdby_freq_hz:-5:0:16000"
on_push="on_select:SW_DOWN_COM2,dataref:sim/cockpit/radios/com2_stdby_freq_hz:-5:0:16000"
on_push="on_select:SW_DOWN_NAV1,dataref:sim/cockpit/radios/nav1_stdby_freq_hz:-1:0:16000"
on_push="on_select:SW_DOWN_NAV2,dataref:sim/cockpit/radios/nav2_stdby_freq_hz:-1:0:16000"
on_push="on_select:SW_DOWN_ADF,dataref:sim/cockpit/radios/adf1_stdby_freq_hz:-1:0:359"
on_push="on_select:SW_DOWN_IDT,dataref:sim/cockpit2/radios/actuators/transponder_code:-1:0:8888"

[button:id="ACT_STBY_DOWN"]
on_push="on_select:SW_DOWN_COM1,commandref:sim/radios/com1_standy_flip:once"
on_push="on_select:SW_DOWN_COM2,commandref:sim/radios/com2_standy_flip:once"
on_push="on_select:SW_DOWN_NAV1,commandref:sim/radios/nav1_standy_flip:once"
on_push="on_select:SW_DOWN_NAV2,commandref:sim/radios/nav2_standy_flip:once"
on_push="on_select:SW_DOWN_ADF,commandref:sim/radios/adf1_standy_flip:once"

List of usb devices connected before run X-Plane12

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 1462:7d25 Micro Star International MYSTIC LIGHT 
Bus 001 Device 003: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 006: ID 05e3:0608 Genesys Logic, Inc. Hub
Bus 001 Device 009: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 010: ID 058f:6364 Alcor Micro Corp. AU6477 Card Reader Controller
Bus 001 Device 033: ID 043e:9a10 LG Electronics USA, Inc. ASM107x
Bus 001 Device 034: ID 131d:0159 Natural Point 
Bus 001 Device 041: ID 05e3:0610 Genesys Logic, Inc. Hub
Bus 001 Device 042: ID 06a3:0d05 Saitek PLC Pro Flight Radio Panel
Bus 001 Device 043: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 044: ID 03f0:e807 HP, Inc HP Webcam HD 4310
Bus 001 Device 045: ID 046d:c52b Logitech, Inc. Unifying Receiver
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 005: ID 05e3:0616 Genesys Logic, Inc. hub

Desktop (please complete the following information):

  • OS: Linux Gentoo
  • X-Plane version 12.09.rc5 (last available)

Consolidate file naming

The project has many different file name patterns. We need to rename files to use a single naming convention.

Question if XPanel could be used for communicating with my generic hidapi boards?

Hi
I came across your XPanel project and it seems like its what I was looking for.
I want to communicate between X_Plane to 3 G1000 PFD and MFD panels and 1 G1000 audio panel from brand TRC.
I received the hidapi protocol information from the manufacturer and made some scripts in lua ( Flywithlua ) to track button or rotary knob actions through hid_write and hid_read's and switch on LEDS. This works fine but at a huge FPS costs. I am now looking for a more efficient solution for this communication. I hesitate to start coding a plugin because I am not very current in c++.
Question: Could I used XPanel for this communication and does it need additional functionality or can that be done through the config options? The panels are not SAITEK or Arduino based but seem to me fairly straight forward hid-api devices.
Thanks and regards,.
Wilko

Dynamic speed for rotation knobs

Rotation knob needs to be speed up when moving more steps in a short time.
This will help to do big changes in heading, course, altitude, etc values.

Create config files for some aircrafts

Create configuration files for these aircraft:

  • default C172
  • airfoillabs C172
  • airfoillabs C172 NG
  • Felis TU-154
  • Felis B747-200
  • Thrandra DHC2
  • Thrandra Quest
  • Morava
  • L410
  • Zibo 737

[BUG] multiple datatype not managed

If I try to get or set dataref of type double, plugin return me this error:
Invalid datareftype: 7

and if I try to assign it to variable like below
variable_1 = get_dataref("dataref_name")

variable_1 is setted to nil instead of value of dateref (verified with datarefTool)

Allow spaces in the configuration file

The config parser shall be able to process the spaces in the configuration option lines.
At a minimum, starting a line with spaces or tabs will be valid. It can help improve the config file's readability by applying indentation.

The ideal solution would be to also allow the spaces inside the configuration lines.

Create release package

Create a release package for the 1.0 release. This version will be supported only on Windows so don't need a multi-platform release package.

The release package shall be a zip file that contains

  1. plugin binary in the right directory structure
  2. dependency binaries (usbHID, lua)
  3. sample configuration files

[BUG] Multiple instances of same type HID devices are messed up

Followup bug of #90

if I connect only 1 radio it works as expected, but if I connect all my 3 radio devices, all 3 devices's display show same things (Top-Left display of first, second and third devices shows same thing, top-right same thing on all 3 devices and so on) and 3 devices are setted as below:

device 1 upper: COM1
device 1 lower: COM 2
device 2 upper: NAV 1
device 2 lower: NAV 2
device 3 upper: ADF
device 3 lower: XPDR

If I turn device 1 knobs, sometimes display of device 1 change, sometimes display of device 2, sometimes display of device 3. Same thing if I use knobs of device 2 or device 3.

I think that now the plugin have to distinguish the device when there are multiple devices of the same type.

Add GPLv3 license text to each source file

{{ project }}
Copyright (C) {{ year }} {{ organization }}

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.

[BUG] Build error for fip

There is a missing code line in /src/devices/fip/FIPLayer.h:
after line 9:
#include <fstream>

you have to add this line:
#include <cstdint>

With that build saccessful :-)

[BUG] Missing device crash the plugin and X-Plane

Describe the bug
If device specified in config (xpanel.ini) is missing (es. not connected to usb port), plugin crash and x-plane with it

To Reproduce
Steps to reproduce the behavior like this:

  1. disconnect device
  2. start x-plane
  3. start fly with aircraft having xpanel.ini (in my case Zibo 4.01.9)
  4. x-plane crash

attached log file
Log.txt

I think that in this case plugin hasn't to crash, but when all is loaded and ready into the aircraft, something have to be write into error dialog window or better: the plugin still working ignoring missing devices informing user about it in dialog window

[enhancement] Add "." (dot) symbol to radio display

When Selector is setted to COM1, COM2, NAV1, NAV2 it would be useful to see on display value like "134.90" instead of "13490"

I think that it could be possible introducing a parameter in line statement
from
line="on_select:SW_UP_COM1,dataref:sim/cockpit/radios/com1_freq_hz"
to
line="on_select:SW_UP_COM1,dataref:sim/cockpit/radios/com1_freq_hz,dot_position:3"
where "dot_position" is the key and "3" is the digit after which is positioned the "." symbol.

Add LUA support

This LUA functions needs to be provided:

get_dataref(dataref_str)
set_dataref(dataref_str, value)
command_begin(commandref_str)
command_end(commandref_str)
command_once(commandref_str)
log(log_msg)

The set and get dataref functions shall store the bound datarefs to avoid the very expensive XPLMFind function calls.

These LUA global variables need to be set in the plugin:

AIRCRAFT_FILENAME
AIRCRAFT_PATH

If the Lua script defines (not mandatory) a callback function it shall be called by the plugin at every flight loop:

function flight_loop(time_since_last_call)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.