HID Wiimote 0.3.0.3 & Control Center Issues

Control Center Issues

This smaller update is intended to combat the Control Center issue some users have. For some users it silently crashes when it tries to open the Main Window. Which after doing the driver package install is the default Window to be launched.  Unfortunately, on all my machines and systems the Control Center is working as expected. Right now, I have only some little guessing, where the issue may come from, but do not have any clue about the why and how to fix it.

As I am unable to reproduce the issue, I call for your assistance to help me find the cause of that issue. For that reason, I added an error handler, that’ll catch all errors and display an error message with some (hopefully) useful information. It still does crash, but at least it is not silent anymore. I’d like you to try out the new version.  Report back with the resulting error message and some additional information. See below on what additional information I need. Hopefully that feedback will lead me to the fix. You can report back either under this post or directly post it on the Github issue.

The newest update is available on the HID Wiimote page.

Error Reporting additional information

  • Windows Edition, Version and Build, e.g. Windows 10 [S/N/Pro], 1706, 16299.309
  • System language
  • Time zone of your system
  • Single or multiple user accounts
  • Current account is administrator
  • Antivirus program used (Name and Version)

Changes

  • Upgrade to Visual Studio 2017 and current Fall Creators Update SDK and WDK (10.0.16299)
  • Add an unhandled exception handler to the Control Center
  • Fix #38: Change unit from Radians to Degree
  • Fix #40: Change guitar whammy bar and touchbar mapping from RX and RY to Z and RZ
  • Fix #41: Home button mapped to wrong output when using Nunchuck

Current State of Windows HIDAPI and Wiimotes

Introduction

This is a small follow up on my testings. Long time it was believed that the PlusInside Wiimotes (“-TR”) are not working with the default Bluetooth Windows Stack. Every program and library recommends the common Toshiba Bluetooth “hack” to get “-TR” Wiimotes and Wii U Pro controllers working on Windows. I did some research with the HIDAPI on Windows and came to the result, that on Windows 8 and above using the proper API Calls, “-TR” Wiimotes, as well as the Wii U Pro Controller is working perfectly fine.

I implemented and fixed the Wiimote Code in the Dolphin Project, which also lead to improved Wiimote Audio for “-TR” Wiimotes.

TLDR;

Using the proper API Calls the Toshiba Bluetooth Stack is not needed anymore on Windows 8 and above. Both Wiimotes types (TR & non-TR) and the Wii U Pro are working fine. Here is the code repository of my test program.

The following post is basically just a copy & paste of the Readme, as it got quite extensive.

Windows 7

The API Calls would also work fine on Windows 7, but there is a bug in the Microsoft HID Class Driver. This renders the “WriteFile”-Method unusable on Windows 7, therefore it is not possible to use the HIDAPI to send data to “-TR” Wiimotes.

HIDAPI

Sending & Receiving

Sending HID Reports:

Recieving HID Reports:

The MSDN Design Guides Sending HID Reports and Obtaining HID Reports are stating, that WriteFile and ReadFile are the preferred methods to send and recieve data from the device. Additionally sending data to a “-TR” Wiimote via WriteFile is working fine, whereas using HidD_SetOutputReport will result in the Wiimote turning off.

Issues with WriteFile

As the MSDN Desgin Guide Sending HID Reports by Kernel-Mode Drivers (WriteFile will send out an IRP_MJ_WRITE request to the driver interface) suggests, the output report buffers shall have the size of the largest output report supported by the device. In case of the Wiimote this is 22 Byte.

This seems to be currently enforced by the Microsoft HID Class Driver on Windows 7 and the Toshiba Bluetooth Stack, as they will fail WriteFile attempts with the error ERROR_INVALID_USER_BUFFER, when the buffer size is less.

On Windows 7 however more bytes than the acutal report are sent to the device, which produces an error on the Wiimote. It is unknown whether this is a bug or intented behaviour. The Toshiba Bluetooth Stack in contrast only sends the appropiate amount of bytes according to the used report to the device.

On Windows 8 and higher, the output report buffer can be arbitrary in size, as the given amount of byte are submitted to the device.

This results in the following table of compability.

Table of compability

x Toshiba Stack Win 7 Win 8.1 Win 10
WriteFile Largest Report Size +
WriteFile Acutal Report Size + +
SetOutputReport +* +* +*

* does not support “-TR” when connected via Bluetooth

Method Priority Order

This leads us to the following order of prioritized methods:

  1. Detect whether the Microsoft Stack or the Toshiba Stack is used for the Wii Remote.
  2. In case of Toshiba Stack, use WriteFile with the largest report size for the buffer
  3. In case of Microsoft Stack, try WriteFile with the actual report size
  4. If WriteFile fails, fall back to HidD_SetOutputReport

Detecting Stack

To detect the used stack for the Wiimote, the provider property of the used HID Class Driver is evaluated. As the enumerated Wiimote Devices are just raw PDO’s, that are acting as interfaces for the HID Class Driver and don’t have a driver directly associated with, it is neccessary to move one node up in the device tree to get to the device node that is associated with the HID Class Driver. To do so the PnP Configuration Manager API is used.

Why WriteFile supports “-TR”

It is believed, that the usage of HidD_SetOutputReport will result in sending the output report via the Control Channel. This is not supported by “-TR” Wiimotes, as they will immediately shut down. In contrast WriteFile seems to send the data to device via the Interrput/Data Channel.

DolphinBar

The Mayflash DolphinBar enumerates Wiimotes as USB Devices, resulting in using the Microsoft HID Class Driver. Therefore WriteFile won’t work on Windows 7 for Wiimotes connected through the DolphinBar either. However as the DolphinBar takes care of the Bluetooth communication and the outgoing data is send via USB to the DolphinBar, HidD_SetOutputReport does support “-TR” Wiimotes as long as they are connected through a DolphinBar.

HID Wiimote Update – 13.07.15

Just two small fixes.

Changes

  • Fixed LED Battery Level display for Wii U Pro Controller
  • Each Classic Controller (Pro) & Wii U Pro Controller Trigger has its own input axis

HID Wiimote Update 20.04.2015

Wii U Pro Controller

Yay, Update for HID Wiimote! The Nunchuck and Classic Controller (Pro) Extensions are now supported. In Addition to that the Wii U Pro Controller is supported as well.

I’ve added a lot of Buttons and some more Axis as well as a Hat Switch to the Properties Dialog. The Button Mapping switches dynamically when an Extension is plugged in.

With my Wii Remote the Extension is sometimes not correctly detected. In that case you have to remove the Extension and plug it in again until it works (Sometimes take up to 10 tries; but maybe my Wiimote has just a loose contact and there is normally no such problem).

My next task is creating an IR-Mouse driver as many have requested. I’ve already made quite good progress on that.

I would be very happy when you spread the news and this Blog entry or the HID Wiimote Project Page is shared on Facebook, Twitter, Reddit and all other sites.

Last but not least, i am streaming my coding sessions on Livecoding.tv and Twitch.tv. So feel free to join my streams and ask questions. My regular streaming schedule is every Monday starting at 08:00 PM (Berlin/UTC+1).

So get the newest version here.

Changes

  • Nunchuck, Classic Controller (Pro) and Wii U Pro Controller are now supported
  • Added more Axis, Buttons and a Hat Switch
  • Unfortunately no more Vista Builds
  • Windows 8.1 Build