XPLMDefs

To use:

import xp

XPLMPluginID

Each plug-in is identified by a unique integer ID. This ID can be used to disable or enable a plug-in, or discover what plug-in is ‘running’ at the time. A plug-in ID is unique within the currently running instance of X-Plane unless plug-ins are reloaded. Plug-ins may receive a different unique ID each time they are loaded.

For persistent identification of plug-ins, use findPluginBySignature().

NO_PLUGIN_ID = -1

No plugin. Official SDK: XPLM_NO_PLUGIN_ID

PLUGIN_XPLANE = 0

X-Plane itself. Official SDK: XPLM_PLUGIN_XPLANE

kVersion = 400

The current XPLM SDK revision for X-Plane 11.55 is 303. X-Plane 12 is 400. Official SDK: kXPLM_Version

XPLMKeyFlags

These bitfields define modifier keys in a platform independent way. When a key is pressed, a series of messages are sent to your plugin. The down flag is set in the first of these messages, and the up flag in the last. While the key is held down, messages are sent with neither to indicate that the key is being held down as a repeated character.

The control flag is mapped to the control flag on Macintosh and PC. Generally X-Plane uses the control key and not the command key on Macintosh, providing a consistent interface across platforms that does not necessarily match the Macintosh user interface guidelines. There is not yet a way for plugins to access the Macintosh control keys without using #ifdefed code.

For xp.py, these are defined without the leading xplm_ e.g., xp.ShiftFlag

ShiftFlag = 1

The shift key is down. Official SDK: xplm_ShiftFlag

OptionAltFlag = 2

The option or alt key is down. Official SDK: xplm_OptionAltFlag

ControlFlag = 4

The control key is down. Official SDK: xplm_ControlFlag

DownFlag = 8

The key is being pressed down. Official SDK: xplm_DownFlag

UpFlag = 16

The key is being released. Official SDK: xplm_UpFlag

ASCII Control Key Codes

These definitions define how various control keys are mapped to ASCII key codes. Not all key presses generate an ASCII value, so plugin code should be prepared to see null characters come from the keyboard…this usually represents a key stroke that has no equivalent ASCII, like a page-down press. Use virtual key codes to find these key strokes. ASCII key codes ake into account modifier keys; shift keys will affect capitals and punctuation; control key combinations may have no vaild ASCII and produce NULL. To detect control-key combinations, use virtual key codes, not ASCII keys.

For xp.py, these are defined without the leading XPLM_ e.g., xp.KEY_RETURN

Value

SDK Value

KEY_RETURN

XPLM_KEY_RETURN

KEY_ESCAPE

XPLM_KEY_ESCAPE

KEY_TAB

XPLM_KEY_TAB

KEY_DELETE

XPLM_KEY_DELETE

KEY_LEFT

XPLM_KEY_LEFT

KEY_RIGHT

XPLM_KEY_RIGHT

KEY_UP

XPLM_KEY_UP

KEY_DOWN

XPLM_KEY_DOWN

KEY_0

XPLM_KEY_0

KEY_1

XPLM_KEY_1

KEY_2

XPLM_KEY_2

KEY_3

XPLM_KEY_3

KEY_4

XPLM_KEY_4

KEY_5

XPLM_KEY_5

KEY_6

XPLM_KEY_6

KEY_7

XPLM_KEY_7

KEY_8

XPLM_KEY_8

KEY_9

XPLM_KEY_9

KEY_DECIMAL

XPLM_KEY_DECIMAL

Virtual Key Codes

These are cross-platform defines for every distinct keyboard press on the computer. Every physical key on the keyboard has a virtual key code. So the “two” key on the top row of the main keyboard has a different code from the “two” key on the numeric key pad. But the ‘w’ and ‘W’ character are indistinguishable by virtual key code because they are the same physical key (one with and one without the shift key).

Use virtual key codes to detect keystrokes that do not have ASCII equivalents, allow the user to map the numeric keypad separately from the main keyboard, and detect control key and other modifier-key combinations that generate ASCII control key sequences (many of which are not available directly via character keys in the SDK).

To assign virtual key codes we started with the Microsoft set but made some additions and changes. A few differences:

  1. Modifier keys are not available as virtual key codes. You cannot get distinct modifier press and release messages. Please do not try to use modifier keys as regular keys; doing so will almost certainly interfere with users’ abilities to use the native x-plane key bindings.

  2. Some keys that do not exist on both Mac and PC keyboards are removed.

  3. Do not assume that the values of these keystrokes are interchangeable with MS v-keys.

For xp.py, these are defined without the leading XPLM_ e.g., xp.VK_TAB

Value

SDK Value

VK_BACK

XPLM_VK_BACK

VK_TAB

XPLM_VK_TAB

VK_CLEAR

XPLM_VK_CLEAR

VK_RETURN

XPLM_VK_RETURN

VK_ESCAPE

XPLM_VK_ESCAPE

VK_SPACE

XPLM_VK_SPACE

VK_PRIOR

XPLM_VK_PRIOR

VK_NEXT

XPLM_VK_NEXT

VK_END

XPLM_VK_END

VK_HOME

XPLM_VK_HOME

VK_LEFT

XPLM_VK_LEFT

VK_UP

XPLM_VK_UP

VK_RIGHT

XPLM_VK_RIGHT

VK_DOWN

XPLM_VK_DOWN

VK_SELECT

XPLM_VK_SELECT

VK_PRINT

XPLM_VK_PRINT

VK_EXECUTE

XPLM_VK_EXECUTE

VK_SNAPSHOT

XPLM_VK_SNAPSHOT

VK_INSERT

XPLM_VK_INSERT

VK_DELETE

XPLM_VK_DELETE

VK_HELP

XPLM_VK_HELP

XPLM_VK_0 thru XPLM_VK_9 are the same as ASCII ‘0’ thru ‘9’ (= 0x30 - 0x39)

Value

SDK Value

VK_0

XPLM_VK_0

VK_1

XPLM_VK_1

VK_2

XPLM_VK_2

VK_3

XPLM_VK_3

VK_4

XPLM_VK_4

VK_5

XPLM_VK_5

VK_6

XPLM_VK_6

VK_7

XPLM_VK_7

VK_8

XPLM_VK_8

VK_9

XPLM_VK_9

XPLM_VK_A thru XPLM_VK_Z are the same as ASCII ‘A’ thru ‘Z’ (= 0x41 - 0x5A)

Value

SDK Value

VK_A

XPLM_VK_A

VK_B

XPLM_VK_B

VK_C

XPLM_VK_C

VK_D

XPLM_VK_D

VK_E

XPLM_VK_E

VK_F

XPLM_VK_F

VK_G

XPLM_VK_G

VK_H

XPLM_VK_H

VK_I

XPLM_VK_I

VK_J

XPLM_VK_J

VK_K

XPLM_VK_K

VK_L

XPLM_VK_L

VK_M

XPLM_VK_M

VK_N

XPLM_VK_N

VK_O

XPLM_VK_O

VK_P

XPLM_VK_P

VK_Q

XPLM_VK_Q

VK_R

XPLM_VK_R

VK_S

XPLM_VK_S

VK_T

XPLM_VK_T

VK_U

XPLM_VK_U

VK_V

XPLM_VK_V

VK_W

XPLM_VK_W

VK_X

XPLM_VK_X

VK_Y

XPLM_VK_Y

VK_Z

XPLM_VK_Z

VK_NUMPAD0

XPLM_VK_NUMPAD0

VK_NUMPAD1

XPLM_VK_NUMPAD1

VK_NUMPAD2

XPLM_VK_NUMPAD2

VK_NUMPAD3

XPLM_VK_NUMPAD3

VK_NUMPAD4

XPLM_VK_NUMPAD4

VK_NUMPAD5

XPLM_VK_NUMPAD5

VK_NUMPAD6

XPLM_VK_NUMPAD6

VK_NUMPAD7

XPLM_VK_NUMPAD7

VK_NUMPAD8

XPLM_VK_NUMPAD8

VK_NUMPAD9

XPLM_VK_NUMPAD9

VK_MULTIPLY

XPLM_VK_MULTIPLY

VK_ADD

XPLM_VK_ADD

VK_SEPARATOR

XPLM_VK_SEPARATOR

VK_SUBTRACT

XPLM_VK_SUBTRACT

VK_DECIMAL

XPLM_VK_DECIMAL

VK_DIVIDE

XPLM_VK_DIVIDE

VK_F1

XPLM_VK_F1

VK_F2

XPLM_VK_F2

VK_F3

XPLM_VK_F3

VK_F4

XPLM_VK_F4

VK_F5

XPLM_VK_F5

VK_F6

XPLM_VK_F6

VK_F7

XPLM_VK_F7

VK_F8

XPLM_VK_F8

VK_F9

XPLM_VK_F9

VK_F10

XPLM_VK_F10

VK_F11

XPLM_VK_F11

VK_F12

XPLM_VK_F12

VK_F13

XPLM_VK_F13

VK_F14

XPLM_VK_F14

VK_F15

XPLM_VK_F15

VK_F16

XPLM_VK_F16

VK_F17

XPLM_VK_F17

VK_F18

XPLM_VK_F18

VK_F19

XPLM_VK_F19

VK_F20

XPLM_VK_F20

VK_F21

XPLM_VK_F21

VK_F22

XPLM_VK_F22

VK_F23

XPLM_VK_F23

VK_F24

XPLM_VK_F24

The following definitions are extended and are not based on the Microsoft key set.

Value

SDK Value

VK_EQUAL

XPLM_VK_EQUAL

VK_MINUS

XPLM_VK_MINUS

VK_RBRACE

XPLM_VK_RBRACE

VK_LBRACE

XPLM_VK_LBRACE

VK_QUOTE

XPLM_VK_QUOTE

VK_SEMICOLON

XPLM_VK_SEMICOLON

VK_BACKSLASH

XPLM_VK_BACKSLASH

VK_COMMA

XPLM_VK_COMMA

VK_SLASH

XPLM_VK_SLASH

VK_PERIOD

XPLM_VK_PERIOD

VK_BACKQUOTE

XPLM_VK_BACKQUOTE

VK_ENTER

XPLM_VK_ENTER

VK_NUMPAD_ENT

XPLM_VK_NUMPAD_ENT

VK_NUMPAD_EQ

XPLM_VK_NUMPAD_EQ