Skip to content

Commit

Permalink
Merge pull request #47 from murtas/master-upgrade-SDK-v4
Browse files Browse the repository at this point in the history
Fix xcontrol on xplane 12
  • Loading branch information
user2684 authored Jan 21, 2024
2 parents 22eb679 + 64bc3a7 commit 62eb430
Show file tree
Hide file tree
Showing 36 changed files with 6,392 additions and 4,217 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.0] - 2024-01-14

- Migrate plugin to X-Plane SDK v4.
- Add support for X-Plane 12.
8 changes: 7 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ In order to compile the code, accomplish the following steps:
- Build the project
- When building for different architectures using the same build chain, remember to clean all before rebuilding.

in alternative:

```sh
qmake && make
```

Supported joysticks
=====================================
The plugin supports the following Saitek X52 and Saitek X52 Pro joystick models:
Expand Down Expand Up @@ -48,4 +54,4 @@ Directory Structure
- libusb0: contains libusb source code
- build/lib: contains libraries used when dinamically linking the plugin at compilation time
- build/release: contains the files and directories to be distributed
- build/working: builds the plugin within this directory
- build/working: builds the plugin within this directory
Binary file modified build/release/32/mac.xpl
Binary file not shown.
Binary file modified build/release/64/lin.xpl
100644 → 100755
Binary file not shown.
Binary file modified build/release/64/mac.xpl
Binary file not shown.
4 changes: 2 additions & 2 deletions gui_fms_option.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void gui_fms_option_t::create(int x, int y, int w, int h){
// build the option window
widget = XPCreateWidget(x, y, x2, y2,1,"FMS Options",1,NULL,xpWidgetClass_MainWindow);
XPSetWidgetProperty(widget, xpProperty_MainWindowHasCloseBoxes, 1);
window = XPCreateWidget(x+30, y-30, x2-30, y2+30,1, "",0,widget,xpWidgetClass_SubWindow);
window = XPCreateWidget(x+30, y-30, x2-30, y2+30,1, "",0,widget,xpWidgetClass_SubWindow);
XPSetWidgetProperty(window, xpProperty_SubWindowType, xpSubWindowStyle_SubWindow);
// build the labels and the text box widgets
XPCreateWidget(x+60, y-(70 + (Item*30)), x+115, y-(92 + (Item*30)),1,"Requested Flight Level (FL)",0,widget,xpWidgetClass_Caption);
Expand All @@ -86,7 +86,7 @@ void gui_fms_option_t::create(int x, int y, int w, int h){


// handle events from the FMS options panel
int gui_fms_option_t::click(XPWidgetMessage inMessage,XPWidgetID inWidget,long inParam1,long inParam2) {
int gui_fms_option_t::click(XPWidgetMessage inMessage,XPWidgetID inWidget,intptr_t inParam1,intptr_t inParam2) {
if (inMessage == xpMessage_CloseButtonPushed){
if(XPIsWidgetVisible(widget)) XPHideWidget(widget);
return 1;
Expand Down
2 changes: 1 addition & 1 deletion gui_fms_status.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ void gui_fms_status_t::create(void){
}

// handle events from the FMS status panel
int gui_fms_status_t::click(XPWidgetMessage inMessage,XPWidgetID inWidget,long inParam1,long inParam2) {
int gui_fms_status_t::click(XPWidgetMessage inMessage,XPWidgetID inWidget,intptr_t inParam1,intptr_t inParam2) {
if (inMessage == xpMessage_CloseButtonPushed){
if(XPIsWidgetVisible(widget)) XPHideWidget(widget);
return 1;
Expand Down
4 changes: 2 additions & 2 deletions gui_mfd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void gui_mfd_t::create(int x, int y, int w, int h){
XPDestroyWidget(mfd_widget, 1);
mfd_widget = XPCreateWidget(x, y, x2, y2,1,"Virtual MFD",1,NULL,xpWidgetClass_MainWindow);
XPSetWidgetProperty(mfd_widget, xpProperty_MainWindowHasCloseBoxes, 1);
mfd_window = XPCreateWidget(x+30, y-30, x2-30, y2+30,1, "",0,mfd_widget,xpWidgetClass_SubWindow);
mfd_window = XPCreateWidget(x+30, y-30, x2-30, y2+30,1, "",0,mfd_widget,xpWidgetClass_SubWindow);
XPSetWidgetProperty(mfd_window, xpProperty_SubWindowType, xpSubWindowStyle_SubWindow);
// set the text
XPCreateWidget(x+60, y-(70 + (Item*30)), x+115, y-(92 + (Item*30)),1,a_out_ref->a_joystick->get_text(0).c_str(),0,mfd_widget,xpWidgetClass_Caption);
Expand All @@ -69,7 +69,7 @@ void gui_mfd_t::create(int x, int y, int w, int h){
}

// handle events from the MFD panel
int gui_mfd_t::click(XPWidgetMessage inMessage,XPWidgetID inWidget,long inParam1,long inParam2) {
int gui_mfd_t::click(XPWidgetMessage inMessage,XPWidgetID inWidget,intptr_t inParam1,intptr_t inParam2) {
if (inMessage == xpMessage_CloseButtonPushed){
if(XPIsWidgetVisible(mfd_widget)) XPHideWidget(mfd_widget);
return 1;
Expand Down
163 changes: 81 additions & 82 deletions include/SDK/XPLMCamera.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,46 @@
#define _XPLMCamera_h_

/*
* Copyright 2005 Sandy Barbour and Ben Supnik
*
* All rights reserved. See license.txt for usage.
*
* X-Plane SDK Version: 1.0.2
* Copyright 2005-2022 Laminar Research, Sandy Barbour and Ben Supnik All
* rights reserved. See license.txt for usage. X-Plane SDK Version: 4.0.0
*
*/

/***************************************************************************
* XPLMCamera
***************************************************************************/
/*
* XPLMCamera - THEORY OF OPERATION The XPLMCamera APIs allow plug-ins to
* control the camera angle in X-Plane. This has a number of applications,
* including but not limited to:
*
* - Creating new views (including dynamic/user-controllable views) for the
* user.
*
* - Creating applications that use X-Plane as a renderer of scenery,
* aircrafts, or both.
*
* The camera is controlled via six parameters: a location in OpenGL
* coordinates and pitch, roll and yaw, similar to an airplane's position.
* OpenGL coordinate info is described in detail in the XPLMGraphics
* documentation; generally you should use the XPLMGraphics routines to
* convert from world to local coordinates. The camera's orientation starts
* facing level with the ground directly up the negative-Z axis
* (approximately north) with the horizon horizontal. It is then rotated
* clockwise for yaw, pitched up for positive pitch, and rolled clockwise
* around the vector it is looking along for roll.
*
* You control the camera either either until the user selects a new view or
* permanently (the later being similar to how UDP camera control works). You
* control the camera by registering a callback per frame from which you
* calculate the new camera positions. This guarantees smooth camera motion.
*
* Use the XPLMDataAccess APIs to get information like the position of the
* aircraft, etc. for complex camera positioning.
* The XPLMCamera APIs allow plug-ins to control the camera angle in X-Plane.
* This has a number of applications, including but not limited to:
*
* - Creating new views (including dynamic/user-controllable views) for the
* user.
* - Creating applications that use X-Plane as a renderer of scenery,
* aircrafts, or both.
*
* The camera is controlled via six parameters: a location in OpenGL
* coordinates and pitch, roll and yaw, similar to an airplane's position.
* OpenGL coordinate info is described in detail in the XPLMGraphics
* documentation; generally you should use the XPLMGraphics routines to
* convert from world to local coordinates. The camera's orientation starts
* facing level with the ground directly up the negative-Z axis (approximately
* north) with the horizon horizontal. It is then rotated clockwise for yaw,
* pitched up for positive pitch, and rolled clockwise around the vector it is
* looking along for roll.
*
* You control the camera either either until the user selects a new view or
* permanently (the latter being similar to how UDP camera control works). You
* control the camera by registering a callback per frame from which you
* calculate the new camera positions. This guarantees smooth camera motion.
*
* Use the XPLMDataAccess APIs to get information like the position of the
* aircraft, etc. for complex camera positioning.
*
* Note: if your goal is to move the virtual pilot in the cockpit, this API is
* not needed; simply update the datarefs for the pilot's head position.
*
* For custom exterior cameras, set the camera's mode to an external view
* first to get correct sound and 2-d panel behavior.
*
*/

Expand All @@ -50,26 +54,21 @@ extern "C" {
/***************************************************************************
* CAMERA CONTROL
***************************************************************************/
/*
*
*
*/


/*
* XPLMCameraControlDuration
*
* This enumeration states how long you want to retain control of the camera.
* You can retain it indefinitely or until the user selects a new view.
* This enumeration states how long you want to retain control of the camera.
* You can retain it indefinitely or until the user selects a new view.
*
*/
enum {
/* Control the camera until the user picks a new view. */
xplm_ControlCameraUntilViewChanges = 1
/* Control the camera until the user picks a new view. */
xplm_ControlCameraUntilViewChanges = 1,

/* Control the camera until your plugin is disabled or another plugin forcably *
* takes control. */
,xplm_ControlCameraForever = 2
/* Control the camera until your plugin is disabled or another plugin forcibly*
* takes control. */
xplm_ControlCameraForever = 2,


};
Expand All @@ -78,12 +77,12 @@ typedef int XPLMCameraControlDuration;
/*
* XPLMCameraPosition_t
*
* This structure contains a full specification of the camera. X, Y, and Z
* are the camera's position in OpenGL coordiantes; pitch, roll, and yaw are
* rotations from a camera facing flat north in degrees. Positive pitch means
* nose up, positive roll means roll right, and positive yaw means yaw right,
* all in degrees. Zoom is a zoom factor, with 1.0 meaning normal zoom and 2.0
* magnifying by 2x (objects appear larger).
* This structure contains a full specification of the camera. X, Y, and Z are
* the camera's position in OpenGL coordinates; pitch, roll, and yaw are
* rotations from a camera facing flat north in degrees. Positive pitch means
* nose up, positive roll means roll right, and positive yaw means yaw right,
* all in degrees. Zoom is a zoom factor, with 1.0 meaning normal zoom and 2.0
* magnifying by 2x (objects appear larger).
*
*/
typedef struct {
Expand All @@ -99,67 +98,67 @@ typedef struct {
/*
* XPLMCameraControl_f
*
* You use an XPLMCameraControl function to provide continuous control over
* the camera. You are passed in a structure in which to put the new camera
* position; modify it and return 1 to reposition the camera. Return 0 to
* surrender control of the camera; camera control will be handled by X-Plane
* on this draw loop. The contents of the structure as you are called are
* undefined.
* You use an XPLMCameraControl function to provide continuous control over
* the camera. You are passed a structure in which to put the new camera
* position; modify it and return 1 to reposition the camera. Return 0 to
* surrender control of the camera; camera control will be handled by X-Plane
* on this draw loop. The contents of the structure as you are called are
* undefined.
*
* If X-Plane is taking camera control away from you, this function will be
* called with inIsLosingControl set to 1 and ioCameraPosition NULL.
* If X-Plane is taking camera control away from you, this function will be
* called with inIsLosingControl set to 1 and ioCameraPosition NULL.
*
*/
typedef int (* XPLMCameraControl_f)(
XPLMCameraPosition_t * outCameraPosition, /* Can be NULL */
int inIsLosingControl,
void * inRefcon);
XPLMCameraPosition_t * outCameraPosition, /* Can be NULL */
int inIsLosingControl,
void * inRefcon);

/*
* XPLMControlCamera
*
* This function repositions the camera on the next drawing cycle. You must
* pass a non-null control function. Specify in inHowLong how long you'd like
* control (indefinitely or until a key is pressed).
* This function repositions the camera on the next drawing cycle. You must
* pass a non-null control function. Specify in inHowLong how long you'd like
* control (indefinitely or until a new view mode is set by the user).
*
*/
XPLM_API void XPLMControlCamera(
XPLMCameraControlDuration inHowLong,
XPLMCameraControl_f inControlFunc,
void * inRefcon);
XPLM_API void XPLMControlCamera(
XPLMCameraControlDuration inHowLong,
XPLMCameraControl_f inControlFunc,
void * inRefcon);

/*
* XPLMDontControlCamera
*
* This function stops you from controlling the camera. If you have a camera
* control function, it will not be called with an inIsLosingControl flag.
* X-Plane will control the camera on the next cycle.
* This function stops you from controlling the camera. If you have a camera
* control function, it will not be called with an inIsLosingControl flag.
* X-Plane will control the camera on the next cycle.
*
* For maximum compatibility you should not use this routine unless you are in
* posession of the camera.
* For maximum compatibility you should not use this routine unless you are in
* posession of the camera.
*
*/
XPLM_API void XPLMDontControlCamera(void);
XPLM_API void XPLMDontControlCamera(void);

/*
* XPLMIsCameraBeingControlled
*
* This routine returns 1 if the camera is being controlled, zero if it is
* not. If it is and you pass in a pointer to a camera control duration, the
* current control duration will be returned.
* This routine returns 1 if the camera is being controlled, zero if it is
* not. If it is and you pass in a pointer to a camera control duration, the
* current control duration will be returned.
*
*/
XPLM_API int XPLMIsCameraBeingControlled(
XPLMCameraControlDuration * outCameraControlDuration); /* Can be NULL */
XPLM_API int XPLMIsCameraBeingControlled(
XPLMCameraControlDuration * outCameraControlDuration); /* Can be NULL */

/*
* XPLMReadCameraPosition
*
* This function reads the current camera position.
* This function reads the current camera position.
*
*/
XPLM_API void XPLMReadCameraPosition(
XPLMCameraPosition_t * outCameraPosition);
XPLM_API void XPLMReadCameraPosition(
XPLMCameraPosition_t * outCameraPosition);

#ifdef __cplusplus
}
Expand Down
Loading

0 comments on commit 62eb430

Please sign in to comment.