An I/O controller for virtual pinball machines: accelerometer nudge sensing, analog plunger input, button input encoding, LedWiz compatible output controls, and more.

Dependencies:   mbed FastIO FastPWM USBDevice

Fork of Pinscape_Controller by Mike R


This is Version 2 of the Pinscape Controller, an I/O controller for virtual pinball machines. (You can find the old version 1 software here.) Pinscape is software for the KL25Z that turns the board into a full-featured I/O controller for virtual pinball, with support for accelerometer-based nudging, a real plunger, button inputs, and feedback device control.

In case you haven't heard of the concept before, a "virtual pinball machine" is basically a video pinball simulator that's built into a real pinball machine body. A TV monitor goes in place of the pinball playfield, and a second TV goes in the backbox to serve as the "backglass" display. A third smaller monitor can serve as the "DMD" (the Dot Matrix Display used for scoring on newer machines), or you can even install a real pinball plasma DMD. A computer is hidden inside the cabinet, running pinball emulation software that displays a life-sized playfield on the main TV. The cabinet has all of the usual buttons, too, so it not only looks like the real thing, but plays like it too. That's a picture of my own machine to the right. On the outside, it's built exactly like a real arcade pinball machine, with the same overall dimensions and all of the standard pinball cabinet hardware.

A few small companies build and sell complete, finished virtual pinball machines, but I think it's more fun as a DIY project. If you have some basic wood-working skills and know your way around PCs, you can build one from scratch. The computer part is just an ordinary Windows PC, and all of the pinball emulation can be built out of free, open-source software. In that spirit, the Pinscape Controller is an open-source software/hardware project that offers a no-compromises, all-in-one control center for all of the unique input/output needs of a virtual pinball cabinet. If you've been thinking about building one of these, but you're not sure how to connect a plunger, flipper buttons, lights, nudge sensor, and whatever else you can think of, this project might be just what you're looking for.

You can find much more information about DIY Pin Cab building in general in the Virtual Cabinet Forum on Also visit my Pinscape Resources page for more about this project and other virtual pinball projects I'm working on.


  • Pinscape Release Builds: This page has download links for all of the Pinscape software. To get started, install and run the Pinscape Config Tool on your Windows computer. It will lead you through the steps for installing the Pinscape firmware on the KL25Z.
  • Config Tool Source Code. The complete C# source code for the config tool. You don't need this to run the tool, but it's available if you want to customize anything or see how it works inside.


The new Version 2 Build Guide is now complete! This new version aims to be a complete guide to building a virtual pinball machine, including not only the Pinscape elements but all of the basics, from sourcing parts to building all of the hardware.

You can also refer to the original Hardware Build Guide (PDF), but that's out of date now, since it refers to the old version 1 software, which was rather different (especially when it comes to configuration).

System Requirements

The new config tool requires a fairly up-to-date Microsoft .NET installation. If you use Windows Update to keep your system current, you should be fine. A modern version of Internet Explorer (IE) is required, even if you don't use it as your main browser, because the config tool uses some system components that Microsoft packages into the IE install set. I test with IE11, so that's known to work. IE8 doesn't work. IE9 and 10 are unknown at this point.

The Windows requirements are only for the config tool. The firmware doesn't care about anything on the Windows side, so if you can make do without the config tool, you can use almost any Windows setup.

Main Features

Plunger: The Pinscape Controller started out as a "mechanical plunger" controller: a device for attaching a real pinball plunger to the video game software so that you could launch the ball the natural way. This is still, of course, a central feature of the project. The software supports several types of sensors: a high-resolution optical sensor (which works by essentially taking pictures of the plunger as it moves); a slide potentionmeter (which determines the position via the changing electrical resistance in the pot); a quadrature sensor (which counts bars printed on a special guide rail that it moves along); and an IR distance sensor (which determines the position by sending pulses of light at the plunger and measuring the round-trip travel time). The Build Guide explains how to set up each type of sensor.

Nudging: The KL25Z (the little microcontroller that the software runs on) has a built-in accelerometer. The Pinscape software uses it to sense when you nudge the cabinet, and feeds the acceleration data to the pinball software on the PC. This turns physical nudges into virtual English on the ball. The accelerometer is quite sensitive and accurate, so we can measure the difference between little bumps and hard shoves, and everything in between. The result is natural and immersive.

Buttons: You can wire real pinball buttons to the KL25Z, and the software will translate the buttons into PC input. You have the option to map each button to a keyboard key or joystick button. You can wire up your flipper buttons, Magna Save buttons, Start button, coin slots, operator buttons, and whatever else you need.

Feedback devices: You can also attach "feedback devices" to the KL25Z. Feedback devices are things that create tactile, sound, and lighting effects in sync with the game action. The most popular PC pinball emulators know how to address a wide variety of these devices, and know how to match them to on-screen action in each virtual table. You just need an I/O controller that translates commands from the PC into electrical signals that turn the devices on and off. The Pinscape Controller can do that for you.

Expansion Boards

There are two main ways to run the Pinscape Controller: standalone, or using the "expansion boards".

In the basic standalone setup, you just need the KL25Z, plus whatever buttons, sensors, and feedback devices you want to attach to it. This mode lets you take advantage of everything the software can do, but for some features, you'll have to build some ad hoc external circuitry to interface external devices with the KL25Z. The Build Guide has detailed plans for exactly what you need to build.

The other option is the Pinscape Expansion Boards. The expansion boards are a companion project, which is also totally free and open-source, that provides Printed Circuit Board (PCB) layouts that are designed specifically to work with the Pinscape software. The PCB designs are in the widely used EAGLE format, which many PCB manufacturers can turn directly into physical boards for you. The expansion boards organize all of the external connections more neatly than on the standalone KL25Z, and they add all of the interface circuitry needed for all of the advanced software functions. The big thing they bring to the table is lots of high-power outputs. The boards provide a modular system that lets you add boards to add more outputs. If you opt for the basic core setup, you'll have enough outputs for all of the toys in a really well-equipped cabinet. If your ambitions go beyond merely well-equipped and run to the ridiculously extravagant, just add an extra board or two. The modular design also means that you can add to the system over time.

Expansion Board project page

Update notes

If you have a Pinscape V1 setup already installed, you should be able to switch to the new version pretty seamlessly. There are just a couple of things to be aware of.

First, the "configuration" procedure is completely different in the new version. Way better and way easier, but it's not what you're used to from V1. In V1, you had to edit the project source code and compile your own custom version of the program. No more! With V2, you simply install the standard, pre-compiled .bin file, and select options using the Pinscape Config Tool on Windows.

Second, if you're using the TSL1410R optical sensor for your plunger, there's a chance you'll need to boost your light source's brightness a little bit. The "shutter speed" is faster in this version, which means that it doesn't spend as much time collecting light per frame as before. The software actually does "auto exposure" adaptation on every frame, so the increased shutter speed really shouldn't bother it, but it does require a certain minimum level of contrast, which requires a certain minimal level of lighting. Check the plunger viewer in the setup tool if you have any problems; if the image looks totally dark, try increasing the light level to see if that helps.

New Features

V2 has numerous new features. Here are some of the highlights...

Dynamic configuration: as explained above, configuration is now handled through the Config Tool on Windows. It's no longer necessary to edit the source code or compile your own modified binary.

Improved plunger sensing: the software now reads the TSL1410R optical sensor about 15x faster than it did before. This allows reading the sensor at full resolution (400dpi), about 400 times per second. The faster frame rate makes a big difference in how accurately we can read the plunger position during the fast motion of a release, which allows for more precise position sensing and faster response. The differences aren't dramatic, since the sensing was already pretty good even with the slower V1 scan rate, but you might notice a little better precision in tricky skill shots.

Keyboard keys: button inputs can now be mapped to keyboard keys. The joystick button option is still available as well, of course. Keyboard keys have the advantage of being closer to universal for PC pinball software: some pinball software can be set up to take joystick input, but nearly all PC pinball emulators can take keyboard input, and nearly all of them use the same key mappings.

Local shift button: one physical button can be designed as the local shift button. This works like a Shift button on a keyboard, but with cabinet buttons. It allows each physical button on the cabinet to have two PC keys assigned, one normal and one shifted. Hold down the local shift button, then press another key, and the other key's shifted key mapping is sent to the PC. The shift button can have a regular key mapping of its own as well, so it can do double duty. The shift feature lets you access more functions without cluttering your cabinet with extra buttons. It's especially nice for less frequently used functions like adjusting the volume or activating night mode.

Night mode: the output controller has a new "night mode" option, which lets you turn off all of your noisy devices with a single button, switch, or PC command. You can designate individual ports as noisy or not. Night mode only disables the noisemakers, so you still get the benefit of your flashers, button lights, and other quiet devices. This lets you play late into the night without disturbing your housemates or neighbors.

Gamma correction: you can designate individual output ports for gamma correction. This adjusts the intensity level of an output to make it match the way the human eye perceives brightness, so that fades and color mixes look more natural in lighting devices. You can apply this to individual ports, so that it only affects ports that actually have lights of some kind attached.

IR Remote Control: the controller software can transmit and/or receive IR remote control commands if you attach appropriate parts (an IR LED to send, an IR sensor chip to receive). This can be used to turn on your TV(s) when the system powers on, if they don't turn on automatically, and for any other functions you can think of requiring IR send/receive capabilities. You can assign IR commands to cabinet buttons, so that pressing a button on your cabinet sends a remote control command from the attached IR LED, and you can have the controller generate virtual key presses on your PC in response to received IR commands. If you have the IR sensor attached, the system can use it to learn commands from your existing remotes.

Yet more USB fixes: I've been gradually finding and fixing USB bugs in the mbed library for months now. This version has all of the fixes of the last couple of releases, of course, plus some new ones. It also has a new "last resort" feature, since there always seems to be "just one more" USB bug. The last resort is that you can tell the device to automatically reboot itself if it loses the USB connection and can't restore it within a given time limit.

More Downloads

  • Custom VP builds: I created modified versions of Visual Pinball 9.9 and Physmod5 that you might want to use in combination with this controller. The modified versions have special handling for plunger calibration specific to the Pinscape Controller, as well as some enhancements to the nudge physics. If you're not using the plunger, you might still want it for the nudge improvements. The modified version also works with any other input controller, so you can get the enhanced nudging effects even if you're using a different plunger/nudge kit. The big change in the modified versions is a "filter" for accelerometer input that's designed to make the response to cabinet nudges more realistic. It also makes the response more subdued than in the standard VP, so it's not to everyone's taste. The downloads include both the updated executables and the source code changes, in case you want to merge the changes into your own custom version(s).

    Note! These features are now standard in the official VP releases, so you don't need my custom builds if you're using 9.9.1 or later and/or VP 10. I don't think there's any reason to use my versions instead of the latest official ones, and in fact I'd encourage you to use the official releases since they're more up to date, but I'm leaving my builds available just in case. In the official versions, look for the checkbox "Enable Nudge Filter" in the Keys preferences dialog. My custom versions don't include that checkbox; they just enable the filter unconditionally.
  • Output circuit shopping list: This is a saved shopping cart at with the parts needed to build one copy of the high-power output circuit for the LedWiz emulator feature, for use with the standalone KL25Z (that is, without the expansion boards). The quantities in the cart are for one output channel, so if you want N outputs, simply multiply the quantities by the N, with one exception: you only need one ULN2803 transistor array chip for each eight output circuits. If you're using the expansion boards, you won't need any of this, since the boards provide their own high-power outputs.
  • Cary Owens' optical sensor housing: A 3D-printable design for a housing/mounting bracket for the optical plunger sensor, designed by Cary Owens. This makes it easy to mount the sensor.
  • Lemming77's potentiometer mounting bracket and shooter rod connecter: Sketchup designs for 3D-printable parts for mounting a slide potentiometer as the plunger sensor. These were designed for a particular slide potentiometer that used to be available from an seller but is no longer listed. You can probably use this design as a starting point for other similar devices; just check the dimensions before committing the design to plastic.

Copyright and License

The Pinscape firmware is copyright 2014, 2021 by Michael J Roberts. It's released under an MIT open-source license. See License.

Warning to VirtuaPin Kit Owners

This software isn't designed as a replacement for the VirtuaPin plunger kit's firmware. If you bought the VirtuaPin kit, I recommend that you don't install this software. The VirtuaPin kit uses the same KL25Z microcontroller that Pinscape uses, but the rest of its hardware is different and incompatible. In particular, the Pinscape firmware doesn't include support for the IR proximity sensor used in the VirtuaPin plunger kit, so you won't be able to use your plunger device with the Pinscape firmware. In addition, the VirtuaPin setup uses a different set of GPIO pins for the button inputs from the Pinscape defaults, so if you do install the Pinscape firmware, you'll have to go into the Config Tool and reassign all of the buttons to match the VirtuaPin wiring.

Sat Mar 05 00:16:52 2016 +0000
New calibration procedure - attempt #1, with separate calibration release sensingi

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mjr 35:e959ffba78fd 1 // USB Message Protocol
mjr 35:e959ffba78fd 2 //
mjr 35:e959ffba78fd 3 // This file is purely for documentation, to describe our USB protocol.
mjr 35:e959ffba78fd 4 // We use the standard HID setup with one endpoint in each direction.
mjr 35:e959ffba78fd 5 // See USBJoystick.cpp/.h for our USB descriptor arrangement.
mjr 35:e959ffba78fd 6 //
mjr 35:e959ffba78fd 7
mjr 35:e959ffba78fd 8 // ------ OUTGOING MESSAGES (DEVICE TO HOST) ------
mjr 35:e959ffba78fd 9 //
mjr 47:df7a88cd249c 10 // General note: 16-bit and 32-bit fields in our reports are little-endian
mjr 47:df7a88cd249c 11 // unless otherwise specified.
mjr 47:df7a88cd249c 12 //
mjr 39:b3815a1c3802 13 // 1. Joystick reports
mjr 35:e959ffba78fd 14 // In most cases, our outgoing messages are HID joystick reports, using the
mjr 35:e959ffba78fd 15 // format defined in USBJoystick.cpp. This allows us to be installed on
mjr 35:e959ffba78fd 16 // Windows as a standard USB joystick, which all versions of Windows support
mjr 35:e959ffba78fd 17 // using in-the-box drivers. This allows a completely transparent, driverless,
mjr 39:b3815a1c3802 18 // plug-and-play installation experience on Windows. Our joystick report
mjr 39:b3815a1c3802 19 // looks like this (see USBJoystick.cpp for the formal HID report descriptor):
mjr 35:e959ffba78fd 20 //
mjr 39:b3815a1c3802 21 // ss status bits: 0x01 -> plunger enabled
mjr 40:cc0d9814522b 22 // 00 2nd byte of status (reserved)
mjr 40:cc0d9814522b 23 // 00 3rd byte of status (reserved)
mjr 39:b3815a1c3802 24 // 00 always zero for joystick reports
mjr 40:cc0d9814522b 25 // bb joystick buttons, low byte (buttons 1-8, 1 bit per button)
mjr 40:cc0d9814522b 26 // bb joystick buttons, 2nd byte (buttons 9-16)
mjr 40:cc0d9814522b 27 // bb joystick buttons, 3rd byte (buttons 17-24)
mjr 40:cc0d9814522b 28 // bb joystick buttons, high byte (buttons 25-32)
mjr 39:b3815a1c3802 29 // xx low byte of X position = nudge/accelerometer X axis
mjr 39:b3815a1c3802 30 // xx high byte of X position
mjr 39:b3815a1c3802 31 // yy low byte of Y position = nudge/accelerometer Y axis
mjr 39:b3815a1c3802 32 // yy high byte of Y position
mjr 39:b3815a1c3802 33 // zz low byte of Z position = plunger position
mjr 39:b3815a1c3802 34 // zz high byte of Z position
mjr 39:b3815a1c3802 35 //
mjr 39:b3815a1c3802 36 // The X, Y, and Z values are 16-bit signed integers. The accelerometer
mjr 39:b3815a1c3802 37 // values are on an abstract scale, where 0 represents no acceleration,
mjr 39:b3815a1c3802 38 // negative maximum represents -1g on that axis, and positive maximum
mjr 39:b3815a1c3802 39 // represents +1g on that axis. For the plunger position, 0 is the park
mjr 39:b3815a1c3802 40 // position (the rest position of the plunger) and positive values represent
mjr 39:b3815a1c3802 41 // retracted (pulled back) positions. A negative value means that the plunger
mjr 39:b3815a1c3802 42 // is pushed forward of the park position.
mjr 39:b3815a1c3802 43 //
mjr 39:b3815a1c3802 44 // 2. Special reports
mjr 35:e959ffba78fd 45 // We subvert the joystick report format in certain cases to report other
mjr 35:e959ffba78fd 46 // types of information, when specifically requested by the host. This allows
mjr 35:e959ffba78fd 47 // our custom configuration UI on the Windows side to query additional
mjr 35:e959ffba78fd 48 // information that we don't normally send via the joystick reports. We
mjr 35:e959ffba78fd 49 // define a custom vendor-specific "status" field in the reports that we
mjr 35:e959ffba78fd 50 // use to identify these special reports, as described below.
mjr 35:e959ffba78fd 51 //
mjr 39:b3815a1c3802 52 // Normal joystick reports always have 0 in the high bit of the 2nd byte
mjr 35:e959ffba78fd 53 // of the report. Special non-joystick reports always have 1 in the high bit
mjr 35:e959ffba78fd 54 // of the first byte. (This byte is defined in the HID Report Descriptor
mjr 35:e959ffba78fd 55 // as an opaque vendor-defined value, so the joystick interface on the
mjr 35:e959ffba78fd 56 // Windows side simply ignores it.)
mjr 35:e959ffba78fd 57 //
mjr 52:8298b2a73eb2 58 // 2A. Plunger sensor status report
mjr 52:8298b2a73eb2 59 // Software on the PC can request a detailed status report from the plunger
mjr 52:8298b2a73eb2 60 // sensor. The status information is meant as an aid to installing and
mjr 52:8298b2a73eb2 61 // adjusting the sensor device for proper performance. For imaging sensor
mjr 52:8298b2a73eb2 62 // types, the status report includes a complete current image snapshot
mjr 52:8298b2a73eb2 63 // (an array of all of the pixels the sensor is currently imaging). For
mjr 52:8298b2a73eb2 64 // all sensor types, it includes the current plunger position registered
mjr 52:8298b2a73eb2 65 // on the sensor, and some timing information.
mjr 52:8298b2a73eb2 66 //
mjr 52:8298b2a73eb2 67 // To request the sensor status, the host sends custom protocol message 65 3
mjr 52:8298b2a73eb2 68 // (see below). The device replies with a message in this format:
mjr 52:8298b2a73eb2 69 //
mjr 52:8298b2a73eb2 70 // bytes 0:1 = 0x87FF
mjr 52:8298b2a73eb2 71 // byte 2 = 0 -> first (currently only) status report packet
mjr 52:8298b2a73eb2 72 // (additional packets could be added in the future if
mjr 52:8298b2a73eb2 73 // more fields need to be added)
mjr 52:8298b2a73eb2 74 // bytes 3:4 = number of pixels to be sent in following messages, as
mjr 52:8298b2a73eb2 75 // an unsigned 16-bit little-endian integer. This is 0 if
mjr 52:8298b2a73eb2 76 // the sensor isn't an imaging type.
mjr 52:8298b2a73eb2 77 // bytes 5:6 = current plunger position registered on the sensor.
mjr 52:8298b2a73eb2 78 // For imaging sensors, this is the pixel position, so it's
mjr 52:8298b2a73eb2 79 // scaled from 0 to number of pixels - 1. For non-imaging
mjr 52:8298b2a73eb2 80 // sensors, this uses the generic joystick scale 0..4095.
mjr 52:8298b2a73eb2 81 // The special value 0xFFFF means that the position couldn't
mjr 52:8298b2a73eb2 82 // be determined,
mjr 52:8298b2a73eb2 83 // byte 7 = bit flags:
mjr 52:8298b2a73eb2 84 // 0x01 = normal orientation detected
mjr 52:8298b2a73eb2 85 // 0x02 = reversed orientation detected
mjr 52:8298b2a73eb2 86 // 0x04 = calibration mode is active (no pixel packets
mjr 52:8298b2a73eb2 87 // are sent for this reading)
mjr 52:8298b2a73eb2 88 // bytes 8:9:10 = average time for each sensor read, in 10us units.
mjr 52:8298b2a73eb2 89 // This is the average time it takes to complete the I/O
mjr 52:8298b2a73eb2 90 // operation to read the sensor, to obtain the raw sensor
mjr 52:8298b2a73eb2 91 // data for instantaneous plunger position reading. For
mjr 52:8298b2a73eb2 92 // an imaging sensor, this is the time it takes for the
mjr 52:8298b2a73eb2 93 // sensor to capture the image and transfer it to the
mjr 52:8298b2a73eb2 94 // microcontroller. For an analog sensor (e.g., an LVDT
mjr 52:8298b2a73eb2 95 // or potentiometer), it's the time to complete an ADC
mjr 52:8298b2a73eb2 96 // sample.
mjr 52:8298b2a73eb2 97 // bytes 11:12:13 = time it took to process the current frame, in 10us
mjr 52:8298b2a73eb2 98 // units. This is the software processing time that was
mjr 52:8298b2a73eb2 99 // needed to analyze the raw data read from the sensor.
mjr 52:8298b2a73eb2 100 // This is typically only non-zero for imaging sensors,
mjr 52:8298b2a73eb2 101 // where it reflects the time required to scan the pixel
mjr 52:8298b2a73eb2 102 // array to find the indicated plunger position. The time
mjr 52:8298b2a73eb2 103 // is usually zero or negligible for analog sensor types,
mjr 52:8298b2a73eb2 104 // since the only "analysis" is a multiplication to rescale
mjr 52:8298b2a73eb2 105 // the ADC sample.
mjr 52:8298b2a73eb2 106 //
mjr 52:8298b2a73eb2 107 // If the sensor is an imaging sensor type, this will be followed by a
mjr 52:8298b2a73eb2 108 // series of pixel messages. The imaging sensor types have too many pixels
mjr 52:8298b2a73eb2 109 // to send in a single USB transaction, so the device breaks up the array
mjr 52:8298b2a73eb2 110 // into as many packets as needed and sends them in sequence. For non-
mjr 52:8298b2a73eb2 111 // imaging sensors, the "number of pixels" field in the lead packet is
mjr 52:8298b2a73eb2 112 // zero, so obviously no pixel packets will follow. If the "calibration
mjr 52:8298b2a73eb2 113 // active" bit in the flags byte is set, no pixel packets are sent even
mjr 52:8298b2a73eb2 114 // if the sensor is an imaging type, since the transmission time for the
mjr 52:8298b2a73eb2 115 // pixels would intefere with the calibration process. If pixels are sent,
mjr 52:8298b2a73eb2 116 // they're sent in order starting at the first pixel. The format of each
mjr 52:8298b2a73eb2 117 // pixel packet is:
mjr 35:e959ffba78fd 118 //
mjr 35:e959ffba78fd 119 // bytes 0:1 = 11-bit index, with high 5 bits set to 10000. For
mjr 48:058ace2aed1d 120 // example, 0x8004 (encoded little endian as 0x04 0x80)
mjr 48:058ace2aed1d 121 // indicates index 4. This is the starting pixel number
mjr 48:058ace2aed1d 122 // in the report. The first report will be 0x00 0x80 to
mjr 48:058ace2aed1d 123 // indicate pixel #0.
mjr 47:df7a88cd249c 124 // bytes 2 = 8-bit unsigned int brightness level of pixel at index
mjr 47:df7a88cd249c 125 // bytes 3 = brightness of pixel at index+1
mjr 35:e959ffba78fd 126 // etc for the rest of the packet
mjr 35:e959ffba78fd 127 //
mjr 52:8298b2a73eb2 128 // Note that we currently only support one-dimensional imaging sensors
mjr 52:8298b2a73eb2 129 // (i.e., pixel arrays that are 1 pixel wide). The report format doesn't
mjr 52:8298b2a73eb2 130 // have any provision for a two-dimensional layout. The KL25Z probably
mjr 52:8298b2a73eb2 131 // isn't powerful enough to do real-time image analysis on a 2D image
mjr 52:8298b2a73eb2 132 // anyway, so it's unlikely that we'd be able to make 2D sensors work at
mjr 52:8298b2a73eb2 133 // all, but if we ever add such a thing we'll have to upgrade the report
mjr 52:8298b2a73eb2 134 // format here accordingly.
mjr 51:57eb311faafa 135 //
mjr 51:57eb311faafa 136 //
mjr 39:b3815a1c3802 137 // 2B. Configuration query.
mjr 39:b3815a1c3802 138 // This is requested by sending custom protocol message 65 4 (see below).
mjr 39:b3815a1c3802 139 // In reponse, the device sends one report to the host using this format:
mjr 35:e959ffba78fd 140 //
mjr 35:e959ffba78fd 141 // bytes 0:1 = 0x8800. This has the bit pattern 10001 in the high
mjr 35:e959ffba78fd 142 // 5 bits, which distinguishes it from regular joystick
mjr 40:cc0d9814522b 143 // reports and from other special report types.
mjr 35:e959ffba78fd 144 // bytes 2:3 = total number of outputs, little endian
mjr 40:cc0d9814522b 145 // bytes 6:7 = plunger calibration zero point, little endian
mjr 40:cc0d9814522b 146 // bytes 8:9 = plunger calibration maximum point, little endian
mjr 52:8298b2a73eb2 147 // byte 10 = plunger calibration release time, in milliseconds
mjr 52:8298b2a73eb2 148 // byte 11 = bit flags:
mjr 40:cc0d9814522b 149 // 0x01 -> configuration loaded; 0 in this bit means that
mjr 40:cc0d9814522b 150 // the firmware has been loaded but no configuration
mjr 40:cc0d9814522b 151 // has been sent from the host
mjr 40:cc0d9814522b 152 // The remaining bytes are reserved for future use.
mjr 35:e959ffba78fd 153 //
mjr 40:cc0d9814522b 154 // 2C. Device ID query.
mjr 40:cc0d9814522b 155 // This is requested by sending custom protocol message 65 7 (see below).
mjr 40:cc0d9814522b 156 // In response, the device sends one report to the host using this format:
mjr 40:cc0d9814522b 157 //
mjr 52:8298b2a73eb2 158 // bytes 0:1 = 0x9000. This has bit pattern 10010 in the high 5 bits
mjr 52:8298b2a73eb2 159 // to distinguish this from other report types.
mjr 40:cc0d9814522b 160 // bytes 2-11 = Unique CPU ID. This is the ID stored in the CPU at the
mjr 40:cc0d9814522b 161 // factory, guaranteed to be unique across Kinetis devices.
mjr 40:cc0d9814522b 162 // This can be used by the host to distinguish devices when
mjr 40:cc0d9814522b 163 // two or more controllers are attached.
mjr 35:e959ffba78fd 164 //
mjr 52:8298b2a73eb2 165 // 2D. Configuration variable query.
mjr 52:8298b2a73eb2 166 // This is requested by sending custom protocol message 65 9 (see below).
mjr 52:8298b2a73eb2 167 // In response, the device sends one report to the host using this format:
mjr 52:8298b2a73eb2 168 //
mjr 52:8298b2a73eb2 169 // bytes 0:1 = 0x9800. This has bit pattern 10011 in the high 5 bits
mjr 52:8298b2a73eb2 170 // to distinguish this from other report types.
mjr 52:8298b2a73eb2 171 // byte 2 = Variable ID. This is the same variable ID sent in the
mjr 52:8298b2a73eb2 172 // query message, to relate the reply to the request.
mjr 52:8298b2a73eb2 173 // bytes 3-8 = Current value of the variable, in the format for the
mjr 52:8298b2a73eb2 174 // individual variable type. The variable formats are
mjr 52:8298b2a73eb2 175 // described in the CONFIGURATION VARIABLES section below.
mjr 52:8298b2a73eb2 176 //
mjr 52:8298b2a73eb2 177 //
mjr 35:e959ffba78fd 179 //
mjr 35:e959ffba78fd 180 // The HID report system was specifically designed to provide a clean,
mjr 35:e959ffba78fd 181 // structured way for devices to describe the data they send to the host.
mjr 35:e959ffba78fd 182 // Our approach isn't clean or structured; it ignores the promises we
mjr 35:e959ffba78fd 183 // make about the contents of our report via the HID Report Descriptor
mjr 35:e959ffba78fd 184 // and stuffs our own different data format into the same structure.
mjr 35:e959ffba78fd 185 //
mjr 35:e959ffba78fd 186 // We use this hacky approach only because we can't use the official
mjr 35:e959ffba78fd 187 // mechanism, due to the constraint that we want to emulate the LedWiz.
mjr 35:e959ffba78fd 188 // The right way to send different report types is to declare different
mjr 35:e959ffba78fd 189 // report types via extra HID Report Descriptors, then send each report
mjr 35:e959ffba78fd 190 // using one of the types we declared. If it weren't for the LedWiz
mjr 35:e959ffba78fd 191 // constraint, we'd simply define the pixel dump and config query reports
mjr 35:e959ffba78fd 192 // as their own separate HID Report types, each consisting of opaque
mjr 35:e959ffba78fd 193 // blocks of bytes. But we can't do this. The snag is that some versions
mjr 35:e959ffba78fd 194 // of the LedWiz Windows host software parse the USB HID descriptors as part
mjr 35:e959ffba78fd 195 // of identifying a device as a valid LedWiz unit, and will only recognize
mjr 35:e959ffba78fd 196 // the device if it matches certain particulars about the descriptor
mjr 35:e959ffba78fd 197 // structure of a real LedWiz. One of the features that's important to
mjr 35:e959ffba78fd 198 // some versions of the software is the descriptor link structure, which
mjr 35:e959ffba78fd 199 // is affected by the layout of HID Report Descriptor entries. In order
mjr 35:e959ffba78fd 200 // to match the expected layout, we can only define a single kind of output
mjr 35:e959ffba78fd 201 // report. Since we have to use Joystick reports for the sake of VP and
mjr 35:e959ffba78fd 202 // other pinball software, and we're only allowed the one report type, we
mjr 35:e959ffba78fd 203 // have to make that one report type the Joystick type. That's why we
mjr 35:e959ffba78fd 204 // overload the joystick reports with other meanings. It's a hack, but
mjr 35:e959ffba78fd 205 // at least it's a fairly reliable and isolated hack, iun that our special
mjr 35:e959ffba78fd 206 // reports are only generated when clients specifically ask for them.
mjr 35:e959ffba78fd 207 // Plus, even if a client who doesn't ask for a special report somehow
mjr 35:e959ffba78fd 208 // gets one, the worst that happens is that they get a momentary spurious
mjr 35:e959ffba78fd 209 // reading from the accelerometer and plunger.
mjr 35:e959ffba78fd 210
mjr 35:e959ffba78fd 211
mjr 35:e959ffba78fd 212
mjr 35:e959ffba78fd 213 // ------- INCOMING MESSAGES (HOST TO DEVICE) -------
mjr 35:e959ffba78fd 214 //
mjr 35:e959ffba78fd 215 // For LedWiz compatibility, our incoming message format conforms to the
mjr 35:e959ffba78fd 216 // basic USB format used by real LedWiz units. This is simply 8 data
mjr 35:e959ffba78fd 217 // bytes, all private vendor-specific values (meaning that the Windows HID
mjr 35:e959ffba78fd 218 // driver treats them as opaque and doesn't attempt to parse them).
mjr 35:e959ffba78fd 219 //
mjr 35:e959ffba78fd 220 // Within this basic 8-byte format, we recognize the full protocol used
mjr 35:e959ffba78fd 221 // by real LedWiz units, plus an extended protocol that we define privately.
mjr 35:e959ffba78fd 222 // The LedWiz protocol leaves a large part of the potential protocol space
mjr 35:e959ffba78fd 223 // undefined, so we take advantage of this undefined region for our
mjr 35:e959ffba78fd 224 // extensions. This ensures that we can properly recognize all messages
mjr 35:e959ffba78fd 225 // intended for a real LedWiz unit, as well as messages from custom host
mjr 35:e959ffba78fd 226 // software that knows it's talking to a Pinscape unit.
mjr 35:e959ffba78fd 227
mjr 35:e959ffba78fd 228 // --- REAL LED WIZ MESSAGES ---
mjr 35:e959ffba78fd 229 //
mjr 35:e959ffba78fd 230 // The real LedWiz protocol has two message types, identified by the first
mjr 35:e959ffba78fd 231 // byte of the 8-byte USB packet:
mjr 35:e959ffba78fd 232 //
mjr 35:e959ffba78fd 233 // 64 -> SBA (64 xx xx xx xx ss uu uu)
mjr 35:e959ffba78fd 234 // xx = on/off bit mask for 8 outputs
mjr 35:e959ffba78fd 235 // ss = global flash speed setting (1-7)
mjr 35:e959ffba78fd 236 // uu = unused
mjr 35:e959ffba78fd 237 //
mjr 35:e959ffba78fd 238 // If the first byte has value 64 (0x40), it's an SBA message. This type of
mjr 35:e959ffba78fd 239 // message sets all 32 outputs individually ON or OFF according to the next
mjr 35:e959ffba78fd 240 // 32 bits (4 bytes) of the message, and sets the flash speed to the value in
mjr 35:e959ffba78fd 241 // the sixth byte. (The flash speed sets the global cycle rate for flashing
mjr 35:e959ffba78fd 242 // outputs - outputs with their values set to the range 128-132 - to a
mjr 35:e959ffba78fd 243 // relative speed, scaled linearly in frequency. 1 is the slowest at about
mjr 35:e959ffba78fd 244 // 2 Hz, 7 is the fastest at about 14 Hz.)
mjr 35:e959ffba78fd 245 //
mjr 35:e959ffba78fd 246 // 0-49 or 128-132 -> PBA (bb bb bb bb bb bb bb bb)
mjr 35:e959ffba78fd 247 // bb = brightness level/flash pattern for one output
mjr 35:e959ffba78fd 248 //
mjr 35:e959ffba78fd 249 // If the first byte is any valid brightness setting, it's a PBA message.
mjr 35:e959ffba78fd 250 // Valid brightness settings are:
mjr 35:e959ffba78fd 251 //
mjr 35:e959ffba78fd 252 // 0-48 = fixed brightness level, linearly from 0% to 100% intensity
mjr 35:e959ffba78fd 253 // 49 = fixed brightness level at 100% intensity (same as 48)
mjr 35:e959ffba78fd 254 // 129 = flashing pattern, fade up / fade down (sawtooth wave)
mjr 35:e959ffba78fd 255 // 130 = flashing pattern, on / off (square wave)
mjr 35:e959ffba78fd 256 // 131 = flashing pattern, on for 50% duty cycle / fade down
mjr 35:e959ffba78fd 257 // 132 = flashing pattern, fade up / on for 50% duty cycle
mjr 35:e959ffba78fd 258 //
mjr 35:e959ffba78fd 259 // A PBA message sets 8 outputs out of 32. Which 8 are to be set is
mjr 35:e959ffba78fd 260 // implicit in the message sequence: the first PBA sets outputs 1-8, the
mjr 35:e959ffba78fd 261 // second sets 9-16, and so on, rolling around after each fourth PBA.
mjr 35:e959ffba78fd 262 // An SBA also resets the implicit "bank" for the next PBA to outputs 1-8.
mjr 35:e959ffba78fd 263 //
mjr 35:e959ffba78fd 264 // Note that there's no special first byte to indicate the PBA message
mjr 35:e959ffba78fd 265 // type, as there is in an SBA. The first byte of a PBA is simply the
mjr 35:e959ffba78fd 266 // first output setting. The way the LedWiz creators conceived this, the
mjr 35:e959ffba78fd 267 // SBA distinguishable from a PBA because 64 isn't a valid output setting,
mjr 35:e959ffba78fd 268 // hence a message that starts with a byte value of 64 isn't a valid PBA
mjr 35:e959ffba78fd 269 // message.
mjr 35:e959ffba78fd 270 //
mjr 35:e959ffba78fd 271 // Our extended protocol uses the same principle, taking advantage of the
mjr 35:e959ffba78fd 272 // other byte value ranges that are invalid in PBA messages. To be a valid
mjr 35:e959ffba78fd 273 // PBA message, the first byte must be in the range 0-49 or 129-132. As
mjr 35:e959ffba78fd 274 // already mentioned, byte value 64 indicates an SBA message. This leaves
mjr 35:e959ffba78fd 275 // these ranges available for other uses: 50-63, 65-128, and 133-255.
mjr 35:e959ffba78fd 276
mjr 35:e959ffba78fd 277
mjr 35:e959ffba78fd 278 // --- PRIVATE EXTENDED MESSAGES ---
mjr 35:e959ffba78fd 279 //
mjr 35:e959ffba78fd 280 // All of our extended protocol messages are identified by the first byte:
mjr 35:e959ffba78fd 281 //
mjr 35:e959ffba78fd 282 // 65 -> Miscellaneous control message. The second byte specifies the specific
mjr 35:e959ffba78fd 283 // operation:
mjr 35:e959ffba78fd 284 //
mjr 39:b3815a1c3802 285 // 0 -> No Op - does nothing. (This can be used to send a test message on the
mjr 39:b3815a1c3802 286 // USB endpoint.)
mjr 39:b3815a1c3802 287 //
mjr 35:e959ffba78fd 288 // 1 -> Set device unit number and plunger status, and save the changes immediately
mjr 35:e959ffba78fd 289 // to flash. The device will automatically reboot after the changes are saved.
mjr 35:e959ffba78fd 290 // The additional bytes of the message give the parameters:
mjr 35:e959ffba78fd 291 //
mjr 35:e959ffba78fd 292 // third byte = new unit number (0-15, corresponding to nominal unit numbers 1-16)
mjr 35:e959ffba78fd 293 // fourth byte = plunger on/off (0=disabled, 1=enabled)
mjr 35:e959ffba78fd 294 //
mjr 35:e959ffba78fd 295 // 2 -> Begin plunger calibration mode. The device stays in this mode for about
mjr 35:e959ffba78fd 296 // 15 seconds, and sets the zero point and maximum retraction points to the
mjr 35:e959ffba78fd 297 // observed endpoints of sensor readings while the mode is running. After
mjr 35:e959ffba78fd 298 // the time limit elapses, the device automatically stores the results in
mjr 35:e959ffba78fd 299 // non-volatile flash memory and exits the mode.
mjr 35:e959ffba78fd 300 //
mjr 51:57eb311faafa 301 // 3 -> Send pixel dump. The device sends one complete image snapshot from the
mjr 51:57eb311faafa 302 // plunger sensor, as as series of pixel dump messages. (The message format
mjr 51:57eb311faafa 303 // isn't big enough to allow the whole image to be sent in one message, so
mjr 51:57eb311faafa 304 // the image is broken up into as many messages as necessary.) After sending
mjr 51:57eb311faafa 305 // the pixels, the device sends the special suffix messages with additional
mjr 51:57eb311faafa 306 // data about the sensor. See the "pixel dump message" section above. The
mjr 51:57eb311faafa 307 // device then resumes sending normal joystick messages. If the plunger
mjr 51:57eb311faafa 308 // sensor isn't an imaging type, no pixel messages are sent, but the extra
mjr 51:57eb311faafa 309 // suffix reports are still sent. If no plunger sensor is installed, no
mjr 51:57eb311faafa 310 // reports are sent. Parameters:
mjr 48:058ace2aed1d 311 //
mjr 48:058ace2aed1d 312 // third byte = bit flags:
mjr 51:57eb311faafa 313 // 0x01 = low res mode. The device rescales the sensor pixel array
mjr 51:57eb311faafa 314 // sent in the dump messages to a low-resolution subset. The
mjr 51:57eb311faafa 315 // size of the subset is determined by the device. This has
mjr 51:57eb311faafa 316 // no effect on the sensor operation; it merely reduces the
mjr 51:57eb311faafa 317 // USB transmission time to allow for a faster frame rate for
mjr 51:57eb311faafa 318 // viewing in the config tool.
mjr 35:e959ffba78fd 319 //
mjr 35:e959ffba78fd 320 // 4 -> Query configuration. The device sends a special configuration report,
mjr 40:cc0d9814522b 321 // (see above; see also USBJoystick.cpp), then resumes sending normal
mjr 40:cc0d9814522b 322 // joystick reports.
mjr 35:e959ffba78fd 323 //
mjr 35:e959ffba78fd 324 // 5 -> Turn all outputs off and restore LedWiz defaults. Sets output ports
mjr 35:e959ffba78fd 325 // 1-32 to OFF and LedWiz brightness/mode setting 48, sets outputs 33 and
mjr 35:e959ffba78fd 326 // higher to brightness level 0, and sets the LedWiz global flash speed to 2.
mjr 35:e959ffba78fd 327 //
mjr 35:e959ffba78fd 328 // 6 -> Save configuration to flash. This saves all variable updates sent via
mjr 35:e959ffba78fd 329 // type 66 messages since the last reboot, then automatically reboots the
mjr 35:e959ffba78fd 330 // device to put the changes into effect.
mjr 35:e959ffba78fd 331 //
mjr 40:cc0d9814522b 332 // 7 -> Query device ID. The device replies with a special device ID report
mjr 40:cc0d9814522b 333 // (see above; see also USBJoystick.cpp), then resumes sending normal
mjr 40:cc0d9814522b 334 // joystick reports.
mjr 40:cc0d9814522b 335 //
mjr 40:cc0d9814522b 336 // 8 -> Engage/disengage night mode. The third byte of the message is 1 to
mjr 40:cc0d9814522b 337 // engage night mode, 0 to disengage night mode. (This mode isn't stored
mjr 40:cc0d9814522b 338 // persistently; night mode is disengaged after a reset or power cycle.)
mjr 40:cc0d9814522b 339 //
mjr 52:8298b2a73eb2 340 // 9 -> Query configuration variable. The second byte is the config variable
mjr 52:8298b2a73eb2 341 // number (see the CONFIGURATION VARIABLES section below). For the array
mjr 52:8298b2a73eb2 342 // variables (button assignments, output ports), the third byte is the
mjr 52:8298b2a73eb2 343 // array index. The device replies with a configuration variable report
mjr 52:8298b2a73eb2 344 // (see above) with the current setting for the requested variable.
mjr 52:8298b2a73eb2 345 //
mjr 35:e959ffba78fd 346 // 66 -> Set configuration variable. The second byte of the message is the config
mjr 35:e959ffba78fd 347 // variable number, and the remaining bytes give the new value for the variable.
mjr 35:e959ffba78fd 348 // The value format is specific to each variable; see the list below for details.
mjr 35:e959ffba78fd 349 // This message only sets the value in RAM - it doesn't write the value to flash
mjr 35:e959ffba78fd 350 // and doesn't put the change into effect immediately. To put updates into effect,
mjr 35:e959ffba78fd 351 // the host must send a type 65 subtype 6 message (see above), which saves updates
mjr 35:e959ffba78fd 352 // to flash and reboots the device.
mjr 35:e959ffba78fd 353 //
mjr 35:e959ffba78fd 354 // 200-228 -> Set extended output brightness. This sets outputs N to N+6 to the
mjr 35:e959ffba78fd 355 // respective brightness values in the 2nd through 8th bytes of the message
mjr 35:e959ffba78fd 356 // (output N is set to the 2nd byte value, N+1 is set to the 3rd byte value,
mjr 35:e959ffba78fd 357 // etc). Each brightness level is a linear brightness level from 0-255,
mjr 35:e959ffba78fd 358 // where 0 is 0% brightness and 255 is 100% brightness. N is calculated as
mjr 35:e959ffba78fd 359 // (first byte - 200)*7 + 1:
mjr 35:e959ffba78fd 360 //
mjr 35:e959ffba78fd 361 // 200 = outputs 1-7
mjr 35:e959ffba78fd 362 // 201 = outputs 8-14
mjr 35:e959ffba78fd 363 // 202 = outputs 15-21
mjr 35:e959ffba78fd 364 // ...
mjr 35:e959ffba78fd 365 // 228 = outputs 197-203
mjr 35:e959ffba78fd 366 //
mjr 35:e959ffba78fd 367 // This message is the only way to address ports 33 and higher, since standard
mjr 35:e959ffba78fd 368 // LedWiz messages are inherently limited to ports 1-32.
mjr 35:e959ffba78fd 369 //
mjr 35:e959ffba78fd 370 // Note that these extended output messages differ from regular LedWiz settings
mjr 35:e959ffba78fd 371 // in two ways. First, the brightness is the ONLY attribute when an output is
mjr 35:e959ffba78fd 372 // set using this mode - there's no separate ON/OFF setting per output as there
mjr 35:e959ffba78fd 373 // is with the SBA/PBA messages. To turn an output OFF with this message, set
mjr 35:e959ffba78fd 374 // the intensity to 0. Setting a non-zero intensity turns it on immediately
mjr 35:e959ffba78fd 375 // without regard to the SBA status for the port. Second, the brightness is
mjr 35:e959ffba78fd 376 // on a full 8-bit scale (0-255) rather than the LedWiz's approximately 5-bit
mjr 35:e959ffba78fd 377 // scale, because there are no parts of the range reserved for flashing modes.
mjr 35:e959ffba78fd 378 //
mjr 35:e959ffba78fd 379 // Outputs 1-32 can be controlled by EITHER the regular LedWiz SBA/PBA messages
mjr 35:e959ffba78fd 380 // or by the extended messages. The latest setting for a given port takes
mjr 35:e959ffba78fd 381 // precedence. If an SBA/PBA message was the last thing sent to a port, the
mjr 35:e959ffba78fd 382 // normal LedWiz combination of ON/OFF and brightness/flash mode status is used
mjr 35:e959ffba78fd 383 // to determine the port's physical output setting. If an extended brightness
mjr 35:e959ffba78fd 384 // message was the last thing sent to a port, the LedWiz ON/OFF status and
mjr 35:e959ffba78fd 385 // flash modes are ignored, and the fixed brightness is set. Outputs 33 and
mjr 35:e959ffba78fd 386 // higher inherently can't be addressed or affected by SBA/PBA messages.
mjr 35:e959ffba78fd 387
mjr 35:e959ffba78fd 388
mjr 35:e959ffba78fd 389 // ------- CONFIGURATION VARIABLES -------
mjr 35:e959ffba78fd 390 //
mjr 35:e959ffba78fd 391 // Message type 66 (see above) sets one configuration variable. The second byte
mjr 35:e959ffba78fd 392 // of the message is the variable ID, and the rest of the bytes give the new
mjr 35:e959ffba78fd 393 // value, in a variable-specific format. 16-bit values are little endian.
mjr 35:e959ffba78fd 394 //
mjr 35:e959ffba78fd 395 // 1 -> USB device ID. Bytes 3-4 give the 16-bit USB Vendor ID; bytes
mjr 35:e959ffba78fd 396 // 5-6 give the 16-bit USB Product ID. For LedWiz emulation, use
mjr 35:e959ffba78fd 397 // vendor 0xFAFA and product 0x00EF + unit# (where unit# is the
mjr 35:e959ffba78fd 398 // nominal LedWiz unit number, from 1 to 16). If LedWiz emulation
mjr 35:e959ffba78fd 399 // isn't desired or causes host conflicts, you can use our private
mjr 35:e959ffba78fd 400 // ID assigned by (a registry for open-source USB
mjr 35:e959ffba78fd 401 // devices) of vendor 0x1209 and product 0xEAEA. (You can also use
mjr 35:e959ffba78fd 402 // any other values that don't cause a conflict on your PC, but we
mjr 35:e959ffba78fd 403 // recommend using one of these pre-assigned values if possible.)
mjr 35:e959ffba78fd 404 //
mjr 35:e959ffba78fd 405 // 2 -> Pinscape Controller unit number for DOF. Byte 3 is the new
mjr 35:e959ffba78fd 406 // unit number, from 1 to 16.
mjr 35:e959ffba78fd 407 //
mjr 35:e959ffba78fd 408 // 3 -> Enable/disable joystick reports. Byte 2 is 1 to enable, 0 to
mjr 35:e959ffba78fd 409 // disable. When disabled, the device registers as a generic HID
mjr 35:e959ffba78fd 410 / device, and only sends the private report types used by the
mjr 35:e959ffba78fd 411 // Windows config tool.
mjr 35:e959ffba78fd 412 //
mjr 35:e959ffba78fd 413 // 4 -> Accelerometer orientation. Byte 3 is the new setting:
mjr 35:e959ffba78fd 414 //
mjr 35:e959ffba78fd 415 // 0 = ports at front (USB ports pointing towards front of cabinet)
mjr 35:e959ffba78fd 416 // 1 = ports at left
mjr 35:e959ffba78fd 417 // 2 = ports at right
mjr 35:e959ffba78fd 418 // 3 = ports at rear
mjr 35:e959ffba78fd 419 //
mjr 35:e959ffba78fd 420 // 5 -> Plunger sensor type. Byte 3 is the type ID:
mjr 35:e959ffba78fd 421 //
mjr 35:e959ffba78fd 422 // 0 = none (disabled)
mjr 35:e959ffba78fd 423 // 1 = TSL1410R linear image sensor, 1280x1 pixels, serial mode
mjr 47:df7a88cd249c 424 // *2 = TSL1410R, parallel mode
mjr 35:e959ffba78fd 425 // 3 = TSL1412R linear image sensor, 1536x1 pixels, serial mode
mjr 47:df7a88cd249c 426 // *4 = TSL1412R, parallel mode
mjr 35:e959ffba78fd 427 // 5 = Potentiometer with linear taper, or any other device that
mjr 35:e959ffba78fd 428 // represents the position reading with a single analog voltage
mjr 47:df7a88cd249c 429 // *6 = AEDR8300 optical quadrature sensor, 75lpi
mjr 47:df7a88cd249c 430 // *7 = AS5304 magnetic quadrature sensor, 160 steps per 2mm
mjr 47:df7a88cd249c 431 //
mjr 47:df7a88cd249c 432 // * The sensor types marked with asterisks (*) are planned but not
mjr 47:df7a88cd249c 433 // currently implemented. Selecting these types will effectively
mjr 47:df7a88cd249c 434 // disable the plunger.
mjr 35:e959ffba78fd 435 //
mjr 35:e959ffba78fd 436 // 6 -> Plunger pin assignments. Bytes 3-6 give the pin assignments for
mjr 35:e959ffba78fd 437 // pins 1, 2, 3, and 4. These use the Pin Number Mappings listed
mjr 35:e959ffba78fd 438 // below. The meaning of each pin depends on the plunger type:
mjr 35:e959ffba78fd 439 //
mjr 35:e959ffba78fd 440 // TSL1410R/1412R, serial: SI (DigitalOut), CLK (DigitalOut), AO (AnalogIn), NC
mjr 35:e959ffba78fd 441 // TSL1410R/1412R, parallel: SI (DigitalOut), CLK (DigitalOut), AO1 (AnalogIn), AO2 (AnalogIn)
mjr 35:e959ffba78fd 442 // Potentiometer: AO (AnalogIn), NC, NC, NC
mjr 35:e959ffba78fd 443 // AEDR8300: A (InterruptIn), B (InterruptIn), NC, NC
mjr 35:e959ffba78fd 444 // AS5304: A (InterruptIn), B (InterruptIn), NC, NC
mjr 35:e959ffba78fd 445 //
mjr 35:e959ffba78fd 446 // 7 -> Plunger calibration button pin assignments. Byte 3 is the DigitalIn
mjr 35:e959ffba78fd 447 // pin for the button switch; byte 4 is the DigitalOut pin for the indicator
mjr 35:e959ffba78fd 448 // lamp. Either can be set to NC to disable the function. (Use the Pin
mjr 35:e959ffba78fd 449 // Number Mappins listed below for both bytes.)
mjr 35:e959ffba78fd 450 //
mjr 35:e959ffba78fd 451 // 8 -> ZB Launch Ball setup. This configures the ZB Launch Ball feature. Byte
mjr 35:e959ffba78fd 452 // 3 is the LedWiz port number (1-255) mapped to the "ZB Launch Ball" output
mjr 35:e959ffba78fd 453 // in DOF. Set the port to 0 to disable the feature. Byte 4 is the button
mjr 35:e959ffba78fd 454 // number (1-32) that we'll "press" when the feature is activated. Bytes 5-6
mjr 35:e959ffba78fd 455 // give the "push distance" for activating the button by pushing forward on
mjr 40:cc0d9814522b 456 // the plunger knob, in 1/1000 inch increments (e.g., 80 represents 0.08",
mjr 40:cc0d9814522b 457 // which is the recommended setting).
mjr 35:e959ffba78fd 458 //
mjr 35:e959ffba78fd 459 // 9 -> TV ON relay setup. This requires external circuitry implemented on the
mjr 35:e959ffba78fd 460 // Expansion Board (or an equivalent circuit as described in the Build Guide).
mjr 35:e959ffba78fd 461 // Byte 3 is the GPIO DigitalIn pin for the "power status" input, using the
mjr 35:e959ffba78fd 462 // Pin Number Mappings below. Byte 4 is the DigitalOut pin for the "latch"
mjr 35:e959ffba78fd 463 // output. Byte 5 is the DigitalOut pin for the relay trigger. Bytes 6-7
mjr 35:e959ffba78fd 464 // give the delay time in 10ms increments as an unsigned 16-bit value (e.g.,
mjr 35:e959ffba78fd 465 // 550 represents 5.5 seconds).
mjr 35:e959ffba78fd 466 //
mjr 35:e959ffba78fd 467 // 10 -> TLC5940NT setup. This chip is an external PWM controller, with 32 outputs
mjr 35:e959ffba78fd 468 // per chip and a serial data interface that allows the chips to be daisy-
mjr 35:e959ffba78fd 469 // chained. We can use these chips to add an arbitrary number of PWM output
mjr 35:e959ffba78fd 470 // ports for the LedWiz emulation. Set the number of chips to 0 to disable
mjr 35:e959ffba78fd 471 // the feature. The bytes of the message are:
mjr 35:e959ffba78fd 472 // byte 3 = number of chips attached (connected in daisy chain)
mjr 35:e959ffba78fd 473 // byte 4 = SIN pin - Serial data (must connect to SPIO MOSI -> PTC6 or PTD2)
mjr 35:e959ffba78fd 474 // byte 5 = SCLK pin - Serial clock (must connect to SPIO SCLK -> PTC5 or PTD1)
mjr 35:e959ffba78fd 475 // byte 6 = XLAT pin - XLAT (latch) signal (any GPIO pin)
mjr 35:e959ffba78fd 476 // byte 7 = BLANK pin - BLANK signal (any GPIO pin)
mjr 35:e959ffba78fd 477 // byte 8 = GSCLK pin - Grayscale clock signal (must be a PWM-out capable pin)
mjr 35:e959ffba78fd 478 //
mjr 35:e959ffba78fd 479 // 11 -> 74HC595 setup. This chip is an external shift register, with 8 outputs per
mjr 35:e959ffba78fd 480 // chip and a serial data interface that allows daisy-chaining. We use this
mjr 35:e959ffba78fd 481 // chips to add extra digital outputs for the LedWiz emulation. In particular,
mjr 35:e959ffba78fd 482 // the Chime Board (part of the Expansion Board suite) uses these to add timer-
mjr 35:e959ffba78fd 483 // protected outputs for coil devices (knockers, chimes, bells, etc). Set the
mjr 35:e959ffba78fd 484 // number of chips to 0 to disable the feature. The message bytes are:
mjr 35:e959ffba78fd 485 // byte 3 = number of chips attached (connected in daisy chain)
mjr 35:e959ffba78fd 486 // byte 4 = SIN pin - Serial data (any GPIO pin)
mjr 35:e959ffba78fd 487 // byte 5 = SCLK pin - Serial clock (any GPIO pin)
mjr 35:e959ffba78fd 488 // byte 6 = LATCH pin - LATCH signal (any GPIO pin)
mjr 35:e959ffba78fd 489 // byte 7 = ENA pin - ENABLE signal (any GPIO pin)
mjr 35:e959ffba78fd 490 //
mjr 35:e959ffba78fd 491 // 12 -> Input button setup. This sets up one button; it can be repeated for each
mjr 35:e959ffba78fd 492 // button to be configured. There are 32 button slots, numbered 1-32. Each
mjr 35:e959ffba78fd 493 // key can be configured as a joystick button, a regular keyboard key, a
mjr 35:e959ffba78fd 494 // keyboard modifier key (such as Shift, Ctrl, or Alt), or a media control
mjr 35:e959ffba78fd 495 // key (such as volume up/down).
mjr 35:e959ffba78fd 496 //
mjr 35:e959ffba78fd 497 // The bytes of the message are:
mjr 35:e959ffba78fd 498 // byte 3 = Button number (1-32)
mjr 35:e959ffba78fd 499 // byte 4 = GPIO pin to read for button input
mjr 35:e959ffba78fd 500 // byte 5 = key type reported to PC when button is pushed:
mjr 35:e959ffba78fd 501 // 1 = joystick button -> byte 6 is the button number, 1-32
mjr 35:e959ffba78fd 502 // 2 = regular keyboard key -> byte 6 is the USB key code (see below)
mjr 35:e959ffba78fd 503 // 3 = keyboard modifier key -> byte 6 is the USB modifier code (see below)
mjr 35:e959ffba78fd 504 // 4 = media control key -> byte 6 is the USB key code (see below)
mjr 38:091e511ce8a0 505 // 5 = special button -> byte 6 is the special button code (see below)
mjr 35:e959ffba78fd 506 // byte 6 = key code, which depends on the key type in byte 5
mjr 38:091e511ce8a0 507 // byte 7 = flags - a combination of these bit values:
mjr 38:091e511ce8a0 508 // 0x01 = pulse mode. This reports a physical on/off switch's state
mjr 38:091e511ce8a0 509 // to the host as a brief key press whenever the switch changes
mjr 38:091e511ce8a0 510 // state. This is useful for the VPinMAME Coin Door button,
mjr 38:091e511ce8a0 511 // which requires the End key to be pressed each time the
mjr 38:091e511ce8a0 512 // door changes state.
mjr 35:e959ffba78fd 513 //
mjr 35:e959ffba78fd 514 // 13 -> LedWiz output port setup. This sets up one output port; it can be repeated
mjr 35:e959ffba78fd 515 // for each port to be configured. There are 203 possible slots for output ports,
mjr 35:e959ffba78fd 516 // numbered 1 to 203. The number of ports visible to the host is determined by
mjr 35:e959ffba78fd 517 // the first DISABLED port (type 0). For example, if ports 1-32 are set as GPIO
mjr 35:e959ffba78fd 518 // outputs and port 33 is disabled, the host will see 32 ports, regardless of
mjr 35:e959ffba78fd 519 // the settings for post 34 and higher.
mjr 35:e959ffba78fd 520 //
mjr 35:e959ffba78fd 521 // The bytes of the message are:
mjr 35:e959ffba78fd 522 // byte 3 = LedWiz port number (1 to maximum number or ports)
mjr 35:e959ffba78fd 523 // byte 4 = physical output type:
mjr 35:e959ffba78fd 524 // 0 = Disabled. This output isn't used, and isn't visible to the
mjr 35:e959ffba78fd 525 // LedWiz/DOF software on the host. The FIRST disabled port
mjr 35:e959ffba78fd 526 // determines the number of ports visible to the host - ALL ports
mjr 35:e959ffba78fd 527 // after the first disabled port are also implicitly disabled.
mjr 35:e959ffba78fd 528 // 1 = GPIO PWM output: connected to GPIO pin specified in byte 5,
mjr 35:e959ffba78fd 529 // operating in PWM mode. Note that only a subset of KL25Z GPIO
mjr 35:e959ffba78fd 530 // ports are PWM-capable.
mjr 35:e959ffba78fd 531 // 2 = GPIO Digital output: connected to GPIO pin specified in byte 5,
mjr 35:e959ffba78fd 532 // operating in digital mode. Digital ports can only be set ON
mjr 35:e959ffba78fd 533 // or OFF, with no brightness/intensity control. All pins can be
mjr 35:e959ffba78fd 534 // used in this mode.
mjr 35:e959ffba78fd 535 // 3 = TLC5940 port: connected to TLC5940 output port number specified
mjr 35:e959ffba78fd 536 // in byte 5. Ports are numbered sequentially starting from port 0
mjr 35:e959ffba78fd 537 // for the first output (OUT0) on the first chip in the daisy chain.
mjr 35:e959ffba78fd 538 // 4 = 74HC595 port: connected to 74HC595 output port specified in byte 5.
mjr 35:e959ffba78fd 539 // As with the TLC5940 outputs, ports are numbered sequentially from 0
mjr 35:e959ffba78fd 540 // for the first output on the first chip in the daisy chain.
mjr 35:e959ffba78fd 541 // 5 = Virtual output: this output port exists for the purposes of the
mjr 35:e959ffba78fd 542 // LedWiz/DOF software on the host, but isn't physically connected
mjr 35:e959ffba78fd 543 // to any output device. This can be used to create a virtual output
mjr 35:e959ffba78fd 544 // for the DOF ZB Launch Ball signal, for example, or simply as a
mjr 35:e959ffba78fd 545 // placeholder in the LedWiz port numbering. The physical output ID
mjr 35:e959ffba78fd 546 // (byte 5) is ignored for this port type.
mjr 35:e959ffba78fd 547 // byte 5 = physical output ID, interpreted according to the value in byte 4
mjr 35:e959ffba78fd 548 // byte 6 = flags: a combination of these bit values:
mjr 38:091e511ce8a0 549 // 0x01 = active-high output (0V on output turns attached device ON)
mjr 38:091e511ce8a0 550 // 0x02 = noisemaker device: disable this output when "night mode" is engaged
mjr 40:cc0d9814522b 551 // 0x04 = apply gamma correction to this output
mjr 38:091e511ce8a0 552 //
mjr 38:091e511ce8a0 553 // Note that the on-board LED segments can be used as LedWiz output ports. This
mjr 38:091e511ce8a0 554 // is useful for testing a new installation with DOF or other PC software without
mjr 38:091e511ce8a0 555 // having to connect any external devices. Assigning the on-board LED segments to
mjr 38:091e511ce8a0 556 // output ports overrides their normal status/diagnostic display use, so the normal
mjr 38:091e511ce8a0 557 // status flash pattern won't appear when they're used this way.
mjr 38:091e511ce8a0 558 //
mjr 38:091e511ce8a0 559 // Special port numbers: if the LedWiz port number is one of these special values,
mjr 38:091e511ce8a0 560 // the physical output is used for a special purpose. These ports aren't visible
mjr 38:091e511ce8a0 561 // to the PC as LedWiz ports; they're for internal use by the controller. The
mjr 38:091e511ce8a0 562 // special port numbers are:
mjr 38:091e511ce8a0 563 //
mjr 38:091e511ce8a0 564 // 254 = Night Mode indicator lamp. This port is turned on when night mode
mjr 38:091e511ce8a0 565 // is engaged, and turned off when night mode is disengaged. This can
mjr 38:091e511ce8a0 566 // be used, for example, to control an indicator LED inside a lighted
mjr 38:091e511ce8a0 567 // momentary pushbutton switch used to activate night mode. The light
mjr 38:091e511ce8a0 568 // provides visual feedback that the mode is turned on.
mjr 38:091e511ce8a0 569 //
mjr 51:57eb311faafa 570 // 14 -> Disconnect reboot timeout. The reboot timeout allows the controller software
mjr 51:57eb311faafa 571 // to automatically reboot the KL25Z after it detects that the USB connection is
mjr 51:57eb311faafa 572 // broken. On some hosts, the device isn't able to reconnect after the initial
mjr 51:57eb311faafa 573 // connection is lost. The reboot timeout is a workaround for these cases. When
mjr 51:57eb311faafa 574 // the software detects that the connection is no longer active, it will reboot
mjr 51:57eb311faafa 575 // the KL25Z automatically if a new connection isn't established within the
mjr 51:57eb311faafa 576 // timeout period. Bytes 3 give the new reboot timeout in seconds. Setting this
mjr 51:57eb311faafa 577 // to 0 disables the reboot timeout.
mjr 51:57eb311faafa 578 //
mjr 52:8298b2a73eb2 579 // 15 -> Plunger calibration. In most cases, the calibration is set internally by the
mjr 52:8298b2a73eb2 580 // device by running the calibration procedure. However, it's sometimes useful
mjr 52:8298b2a73eb2 581 // for the host to be able to get and set the calibration, such as to back up
mjr 52:8298b2a73eb2 582 // the device settings on the PC, or to save and restore the current settings
mjr 52:8298b2a73eb2 583 // when installing a software update.
mjr 52:8298b2a73eb2 584 //
mjr 52:8298b2a73eb2 585 // bytes 3:4 = rest position (unsigned 16-bit little-endian)
mjr 52:8298b2a73eb2 586 // bytes 5:6 = maximum retraction point (unsigned 16-bit little-endian)
mjr 52:8298b2a73eb2 587 // byte 7 = measured plunger release travel time in milliseconds
mjr 52:8298b2a73eb2 588 //
mjr 52:8298b2a73eb2 589 // 16 -> Expansion board configuration. This doesn't affect the controller behavior
mjr 52:8298b2a73eb2 590 // directly; the individual options related to the expansion boards (such as
mjr 52:8298b2a73eb2 591 // the TLC5940 and 74HC595 setup) still need to be set separately. This is
mjr 52:8298b2a73eb2 592 // stored so that the PC config UI can store and recover the information to
mjr 52:8298b2a73eb2 593 // present in the UI. For the "classic" KL25Z-only configuration, simply set
mjr 52:8298b2a73eb2 594 // all of the fields to zero.
mjr 52:8298b2a73eb2 595 //
mjr 52:8298b2a73eb2 596 // byte 3 = number of main interface boards
mjr 52:8298b2a73eb2 597 // byte 4 = number of MOSFET power boards
mjr 52:8298b2a73eb2 598 // byte 5 = number of chime boards
mjr 52:8298b2a73eb2 599 //
mjr 35:e959ffba78fd 600
mjr 35:e959ffba78fd 601
mjr 35:e959ffba78fd 602 // --- PIN NUMBER MAPPINGS ---
mjr 35:e959ffba78fd 603 //
mjr 35:e959ffba78fd 604 // In USB messages that specify GPIO pin assignments, pins are identified with
mjr 35:e959ffba78fd 605 // our own private numbering scheme. Our numbering scheme only includes the
mjr 35:e959ffba78fd 606 // ports connected to external header pins on the KL25Z board, so this is only
mjr 35:e959ffba78fd 607 // a sparse subset of the full GPIO port set. These are numbered in order of
mjr 35:e959ffba78fd 608 // pin name. The special value 0 = NC = Not Connected can be used where
mjr 35:e959ffba78fd 609 // appropriate to indicate a disabled or unused pin.
mjr 35:e959ffba78fd 610 //
mjr 35:e959ffba78fd 611 // 0 = NC (not connected)
mjr 35:e959ffba78fd 612 // 1 = PTA1
mjr 35:e959ffba78fd 613 // 2 = PTA2
mjr 35:e959ffba78fd 614 // 3 = PTA4
mjr 35:e959ffba78fd 615 // 4 = PTA5
mjr 35:e959ffba78fd 616 // 5 = PTA12
mjr 35:e959ffba78fd 617 // 6 = PTA13
mjr 35:e959ffba78fd 618 // 7 = PTA16
mjr 35:e959ffba78fd 619 // 8 = PTA17
mjr 35:e959ffba78fd 620 // 9 = PTB0
mjr 35:e959ffba78fd 621 // 10 = PTB1
mjr 35:e959ffba78fd 622 // 11 = PTB2
mjr 35:e959ffba78fd 623 // 12 = PTB3
mjr 35:e959ffba78fd 624 // 13 = PTB8
mjr 35:e959ffba78fd 625 // 14 = PTB9
mjr 35:e959ffba78fd 626 // 15 = PTB10
mjr 35:e959ffba78fd 627 // 16 = PTB11
mjr 38:091e511ce8a0 628 // 17 = PTB18 (on-board LED Red segment - not exposed as a header pin)
mjr 38:091e511ce8a0 629 // 18 = PTB19 (on-board LED Green segment - not exposed as a header pin)
mjr 38:091e511ce8a0 630 // 19 = PTC0
mjr 38:091e511ce8a0 631 // 20 = PTC1
mjr 38:091e511ce8a0 632 // 21 = PTC2
mjr 38:091e511ce8a0 633 // 22 = PTC3
mjr 38:091e511ce8a0 634 // 23 = PTC4
mjr 38:091e511ce8a0 635 // 24 = PTC5
mjr 38:091e511ce8a0 636 // 25 = PTC6
mjr 38:091e511ce8a0 637 // 26 = PTC7
mjr 38:091e511ce8a0 638 // 27 = PTC8
mjr 38:091e511ce8a0 639 // 28 = PTC9
mjr 38:091e511ce8a0 640 // 29 = PTC10
mjr 38:091e511ce8a0 641 // 30 = PTC11
mjr 38:091e511ce8a0 642 // 31 = PTC12
mjr 38:091e511ce8a0 643 // 32 = PTC13
mjr 38:091e511ce8a0 644 // 33 = PTC16
mjr 38:091e511ce8a0 645 // 34 = PTC17
mjr 38:091e511ce8a0 646 // 35 = PTD0
mjr 38:091e511ce8a0 647 // 36 = PTD1 (on-board LED Blue segment)
mjr 38:091e511ce8a0 648 // 37 = PTD2
mjr 38:091e511ce8a0 649 // 38 = PTD3
mjr 38:091e511ce8a0 650 // 39 = PTD4
mjr 38:091e511ce8a0 651 // 40 = PTD5
mjr 38:091e511ce8a0 652 // 41 = PTD6
mjr 38:091e511ce8a0 653 // 42 = PTD7
mjr 38:091e511ce8a0 654 // 43 = PTE0
mjr 38:091e511ce8a0 655 // 44 = PTE1
mjr 38:091e511ce8a0 656 // 45 = PTE2
mjr 38:091e511ce8a0 657 // 46 = PTE3
mjr 38:091e511ce8a0 658 // 47 = PTE4
mjr 38:091e511ce8a0 659 // 48 = PTE5
mjr 38:091e511ce8a0 660 // 49 = PTE20
mjr 38:091e511ce8a0 661 // 50 = PTE21
mjr 38:091e511ce8a0 662 // 51 = PTE22
mjr 38:091e511ce8a0 663 // 52 = PTE23
mjr 38:091e511ce8a0 664 // 53 = PTE29
mjr 38:091e511ce8a0 665 // 54 = PTE30
mjr 38:091e511ce8a0 666 // 55 = PTE31
mjr 35:e959ffba78fd 667
mjr 35:e959ffba78fd 668 // --- USB KEYBOARD SCAN CODES ---
mjr 35:e959ffba78fd 669 //
mjr 35:e959ffba78fd 670 // Use the standard USB HID keyboard codes for regular keys. See the
mjr 35:e959ffba78fd 671 // HID Usage Tables in the official USB specifications for a full list.
mjr 35:e959ffba78fd 672 // Here are the most common codes for quick references:
mjr 35:e959ffba78fd 673 //
mjr 35:e959ffba78fd 674 // A-Z -> 4-29
mjr 35:e959ffba78fd 675 // top row numbers -> 30-39
mjr 35:e959ffba78fd 676 // Return -> 40
mjr 35:e959ffba78fd 677 // Escape -> 41
mjr 35:e959ffba78fd 678 // Backspace -> 42
mjr 35:e959ffba78fd 679 // Tab -> 43
mjr 35:e959ffba78fd 680 // Spacebar -> 44
mjr 35:e959ffba78fd 681 // -_ -> 45
mjr 35:e959ffba78fd 682 // =+ -> 46
mjr 35:e959ffba78fd 683 // [{ -> 47
mjr 35:e959ffba78fd 684 // ]} -> 48
mjr 35:e959ffba78fd 685 // \| -> 49
mjr 35:e959ffba78fd 686 // ;: -> 51
mjr 35:e959ffba78fd 687 // '" -> 52
mjr 35:e959ffba78fd 688 // `~ -> 53
mjr 35:e959ffba78fd 689 // ,< -> 54
mjr 35:e959ffba78fd 690 // .> -> 55
mjr 35:e959ffba78fd 691 // /? -> 56
mjr 35:e959ffba78fd 692 // Caps Lock -> 57
mjr 35:e959ffba78fd 693 // F1-F12 -> 58-69
mjr 35:e959ffba78fd 694 // F13-F24 -> 104-115
mjr 35:e959ffba78fd 695 // Print Screen -> 70
mjr 35:e959ffba78fd 696 // Scroll Lock -> 71
mjr 35:e959ffba78fd 697 // Pause -> 72
mjr 35:e959ffba78fd 698 // Insert -> 73
mjr 35:e959ffba78fd 699 // Home -> 74
mjr 35:e959ffba78fd 700 // Page Up -> 75
mjr 35:e959ffba78fd 701 // Del -> 76
mjr 35:e959ffba78fd 702 // End -> 77
mjr 35:e959ffba78fd 703 // Page Down -> 78
mjr 35:e959ffba78fd 704 // Right Arrow -> 79
mjr 35:e959ffba78fd 705 // Left Arrow -> 80
mjr 35:e959ffba78fd 706 // Down Arrow -> 81
mjr 35:e959ffba78fd 707 // Up Arrow -> 82
mjr 35:e959ffba78fd 708 // Num Lock/Clear -> 83
mjr 35:e959ffba78fd 709 // Keypad / * - + -> 84 85 86 87
mjr 35:e959ffba78fd 710 // Keypad Enter -> 88
mjr 35:e959ffba78fd 711 // Keypad 1-9 -> 89-97
mjr 35:e959ffba78fd 712 // Keypad 0 -> 98
mjr 35:e959ffba78fd 713 // Keypad . -> 99
mjr 35:e959ffba78fd 714 //
mjr 35:e959ffba78fd 715
mjr 35:e959ffba78fd 716
mjr 35:e959ffba78fd 717 // --- USB KEYBOARD MODIFIER KEY CODES ---
mjr 35:e959ffba78fd 718 //
mjr 35:e959ffba78fd 719 // Use these codes for modifier keys in the button mappings
mjr 35:e959ffba78fd 720 //
mjr 35:e959ffba78fd 721 // 0x01 = Left Control
mjr 35:e959ffba78fd 722 // 0x02 = Left Shift
mjr 35:e959ffba78fd 723 // 0x04 = Left Alt
mjr 35:e959ffba78fd 724 // 0x08 = Left GUI ("Windows" key)
mjr 35:e959ffba78fd 725 // 0x10 = Right Control
mjr 35:e959ffba78fd 726 // 0x20 = Right Shift
mjr 35:e959ffba78fd 727 // 0x40 = Right Alt
mjr 35:e959ffba78fd 728 // 0x80 = Right GUI ("Windows" key)
mjr 35:e959ffba78fd 729
mjr 35:e959ffba78fd 730
mjr 35:e959ffba78fd 731 // --- USB KEYBOARD MEDIA KEY CODES ---
mjr 35:e959ffba78fd 732 //
mjr 35:e959ffba78fd 733 // Use these for media control keys in the button mappings
mjr 35:e959ffba78fd 734 //
mjr 35:e959ffba78fd 735 // 0x01 = Volume Up
mjr 35:e959ffba78fd 736 // 0x02 = Volume Down
mjr 35:e959ffba78fd 737 // 0x04 = Mute on/off
mjr 35:e959ffba78fd 738
mjr 38:091e511ce8a0 739
mjr 38:091e511ce8a0 740 // --- SPECIAL BUTTON KEY CODES ---
mjr 38:091e511ce8a0 741 //
mjr 38:091e511ce8a0 742 // Use these for special keys in the button mappings
mjr 38:091e511ce8a0 743 //
mjr 38:091e511ce8a0 744 // 0x01 = Night mode switch, momentary switch mode. Pushing this button
mjr 38:091e511ce8a0 745 // engages night mode, disabling all LedWiz outputs marked with the
mjr 38:091e511ce8a0 746 // "noisemaker" flag. Other outputs are unaffected. Pushing
mjr 38:091e511ce8a0 747 // the button again disengages night mode. Use this option if the
mjr 38:091e511ce8a0 748 // physical button attached to the input is a momentary switch type.
mjr 38:091e511ce8a0 749 //
mjr 38:091e511ce8a0 750 // 0x02 = Night mode switch, toggle switch mode. When this switch is on,
mjr 38:091e511ce8a0 751 // night mode is engaged; when the switch is off, night mode is
mjr 38:091e511ce8a0 752 // disengaged. Use this option if the physical switch attached to
mjr 38:091e511ce8a0 753 // to the input is a toggle switch (not a momentary switch).
mjr 38:091e511ce8a0 754