From 2253dc9db935886b48b74edeb759a53c0a0b12bf Mon Sep 17 00:00:00 2001 From: QwertyChouskie Date: Wed, 28 Nov 2018 11:18:32 -0800 Subject: [PATCH] Update to 0.15.4, with fix for Windows compilation --- lib/wiiuse/.clang-format | 94 +++++++++++++++++++++++ lib/wiiuse/.gitignore | 2 + lib/wiiuse/.travis.yml | 15 ++++ lib/wiiuse/CHANGELOG.mkd | 31 ++++++-- lib/wiiuse/README.mkd | 56 +++++++------- lib/wiiuse/RELEASE.md | 8 ++ lib/wiiuse/cmake/FindWindowsSDK.cmake | 3 +- lib/wiiuse/src/definitions.h | 2 - lib/wiiuse/src/events.h | 10 +-- lib/wiiuse/src/wiiuse.c | 7 +- lib/wiiuse/src/wiiuse.h | 106 +++++++++++++------------- lib/wiiuse/src/wiiuse_internal.h | 2 +- 12 files changed, 234 insertions(+), 102 deletions(-) create mode 100644 lib/wiiuse/.clang-format create mode 100644 lib/wiiuse/.gitignore create mode 100644 lib/wiiuse/.travis.yml create mode 100644 lib/wiiuse/RELEASE.md diff --git a/lib/wiiuse/.clang-format b/lib/wiiuse/.clang-format new file mode 100644 index 000000000..1e8502543 --- /dev/null +++ b/lib/wiiuse/.clang-format @@ -0,0 +1,94 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: false +AlignEscapedNewlinesLeft: true +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: false +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: true + AfterControlStatement: true + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + BeforeCatch: false + BeforeElse: false + IndentBraces: false +BreakBeforeBinaryOperators: true +BreakBeforeBraces: Custom +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: true +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 110 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|isl|json)/)' + Priority: 3 + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '$' +IndentCaseLabels: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 4 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Right +ReflowComments: true +SortIncludes: false +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 8 +UseTab: Never +... diff --git a/lib/wiiuse/.gitignore b/lib/wiiuse/.gitignore new file mode 100644 index 000000000..837131d79 --- /dev/null +++ b/lib/wiiuse/.gitignore @@ -0,0 +1,2 @@ +build +.cquery_cached_index diff --git a/lib/wiiuse/.travis.yml b/lib/wiiuse/.travis.yml new file mode 100644 index 000000000..be275cc79 --- /dev/null +++ b/lib/wiiuse/.travis.yml @@ -0,0 +1,15 @@ +os: + - linux + - osx + +language: c + +compiler: + - clang + - gcc + +sudo: required +dist: trusty + +install: . scripts/ci/$TRAVIS_OS_NAME/install.sh +script: . scripts/ci/common/script.sh diff --git a/lib/wiiuse/CHANGELOG.mkd b/lib/wiiuse/CHANGELOG.mkd index 63eff5991..923aa9cb4 100644 --- a/lib/wiiuse/CHANGELOG.mkd +++ b/lib/wiiuse/CHANGELOG.mkd @@ -1,13 +1,35 @@ WiiUse Changelog ================ -Fork, located at +De-facto official fork, located at -Original project: +Original project (0.12 and earlier): -- -- - +- Now-defunct web sites: + - wiiuse.net: + most recent archive from 2011 + + - wiiuse.sourceforge.net: + most recent archive from 2010 (looks identical on homepage to 2011 snapshot above) + + +v0.15.4 -- 28-Nov-2018 +-------------------- + +Fixed: + +- Windows build - verified to work on VS Community 2017 from fresh install. + +Changed: + +- Removed `WCONST` macro of questionable value - + it made some struct members "const" for consuming software, + but non-const within the library. + Made it too complex to maintain. + Shouldn't really affect usage (doesn't change layout, etc.), + but noted separately because it is technically a (very minor) API change. +- Removed broken links to old project web sites. v0.15.3 -- 25-Nov-2018 -------------------- @@ -17,7 +39,6 @@ Fixed: - Fixed forgotten version number - Fixed library installation prefix on 64bit systems - v0.15.2 -- 25-Nov-2018 -------------------- diff --git a/lib/wiiuse/README.mkd b/lib/wiiuse/README.mkd index 1885eb9ab..b7c818069 100644 --- a/lib/wiiuse/README.mkd +++ b/lib/wiiuse/README.mkd @@ -50,7 +50,7 @@ Original Author: Michael Laforest < para > < thepara (--AT--) g m a i l [--DOT-- Additional Contributors: -- Jan Ciger - Reviatech SAS +- Jan Ciger - Reviatech SAS (effective co-maintainer) - dhewg - Christopher Sawczuk @ TU-Delft (initial Balance Board support) - Paul Burton @@ -120,16 +120,14 @@ Wiiuse currently operates on Linux, Windows and Mac. You will need: ### For Linux -- The kernel must support bluetooth -- The BlueZ bluetooth drivers must be installed +- The kernel must support Bluetooth +- The BlueZ Bluetooth drivers must be installed - If compiling, you'll need the BlueZ dev files (Debian/Ubuntu package `libbluetooth-dev`) ### For Windows -- Bluetooth driver (tested with Microsoft's stack with Windows XP SP2) - -- If compiling, Microsoft Windows Driver Development Kit (DDK) +- Bluetooth driver (tested with Microsoft's stack with Windows XP SP2 thru Windows 10) ### For Mac @@ -179,6 +177,10 @@ You may need to install the Windows SDK (in recent versions) or DDK (driver development kit - for old Windows SDK only) to compile wiiuse. +With Visual Studio Community 2017, this is very easy to build now: +if you have chosen to install the "desktop C++" tools, +you'll automatically have what you need. + ## Using the Library To use the library in your own program you must first compile wiiuse as @@ -227,7 +229,7 @@ Nintendo BlueZ -> Easy and intuitive bluetooth stack for Linux. +> Easy and intuitive Bluetooth stack for Linux. Thanks to Brent for letting me borrow his Guitar Hero 3 controller. @@ -260,30 +262,26 @@ greatly appreciated. - Created an 0.13 version with some very preliminary MotionPlus support. - Integrated into branch `fwiine-motionplus`, not yet merged pending alternate MotionPlus merge from WiiC by Jan Ciger. -- [DolphinEmu](http://code.google.com/p/dolphin-emu/source/checkout) - - Embedded, converted to C++, drastically changed over time and - mostly unrecognizable now. +- [DolphinEmu](https://github.com/dolphin-emu/dolphin) + - used to have a WiiUse fork labeled version 0.13.0 (no relation to 0.13 in this current project) + - Embedded, converted to C++, drastically changed over time, + mostly unrecognizable, and then removed before 3.0. + - Added Mac support. + - Added code to handle finding and pairing wiimotes on windows. - A mostly intact version is here: - - - Added Mac support - - Added code to handle finding and pairing wiimotes on windows, see: - - - Fully modified version of the IO code is here: - + + - Last code state before removal is here: + + - Their new replacement is - [paulburton on github](https://github.com/paulburton/wiiuse) - Added balance board support - skipped in favor of the TU Delft version. - Added static library support - not yet added to the mainline. - [KzMz on github)](https://github.com/KzMz/wiiuse_fork) - Started work on speaker support. -- [WiiC](http://wiic.sourceforge.net/) +- [WiiC](https://github.com/grandelli/WiiC) - Dramatically changed, C++ API added. - MotionPlus support added. - Added Mac support. -- DolphinEmu PPA: used to have a WiiUse 0.13 - - Added Mac support. - - Unknown other changes - not yet investigated. - - Source package zipped up and available here: - ## Other Links @@ -291,9 +289,13 @@ greatly appreciated. - Possible alternative using the Linux kernel support for the Wiimote and the standard Linux input system: -Original project: +Original project (0.12 and earlier): -- SourceForge page: -- Archived pages of the original project: - - - - +- +- Now-defunct web sites: + - wiiuse.net: + most recent archive from 2011 + + - wiiuse.sourceforge.net: + most recent archive from 2010 (looks identical on homepage to 2011 snapshot above) + diff --git a/lib/wiiuse/RELEASE.md b/lib/wiiuse/RELEASE.md new file mode 100644 index 000000000..4332d809d --- /dev/null +++ b/lib/wiiuse/RELEASE.md @@ -0,0 +1,8 @@ +# Release Checklist + +This project unfortunately has a several-step release process, +and it's easy to miss one of the steps. + +- Update `CHANGELOG.mkd` +- Ensure contributor list in `README.mkd` is accurate/up to date. +- Bump version in wiiuse.h diff --git a/lib/wiiuse/cmake/FindWindowsSDK.cmake b/lib/wiiuse/cmake/FindWindowsSDK.cmake index 6740dbb70..c8691efa7 100644 --- a/lib/wiiuse/cmake/FindWindowsSDK.cmake +++ b/lib/wiiuse/cmake/FindWindowsSDK.cmake @@ -73,7 +73,8 @@ macro(_winsdk_announce) endmacro() set(_winsdk_win10vers - 10.0.17133.0 # Redstone 4 aka Win10 1803 "April 1018 Update" + 10.0.17763.0 # Redstone 5 aka Win10 1810 "October 2018 Update" + 10.0.17133.0 # Redstone 4 aka Win10 1803 "April 2018 Update" 10.0.16299.0 # Redstone 3 aka Win10 1709 "Fall Creators Update" 10.0.15063.0 # Redstone 2 aka Win10 1703 "Creators Update" 10.0.14393.0 # Redstone aka Win10 1607 "Anniversary Update" diff --git a/lib/wiiuse/src/definitions.h b/lib/wiiuse/src/definitions.h index e3b545c7b..4e8e84e65 100644 --- a/lib/wiiuse/src/definitions.h +++ b/lib/wiiuse/src/definitions.h @@ -108,8 +108,6 @@ extern FILE *logtarget[]; #define absf(x) ((x >= 0) ? (x) : (x * -1.0f)) #define diff_f(x, y) ((x >= y) ? (absf(x - y)) : (absf(y - x))) -#define WCONST - /** @} */ #endif /* DEFINITIONS_H_INCLUDED */ diff --git a/lib/wiiuse/src/events.h b/lib/wiiuse/src/events.h index 4149ce5d1..504803f52 100644 --- a/lib/wiiuse/src/events.h +++ b/lib/wiiuse/src/events.h @@ -37,15 +37,7 @@ #ifndef EVENTS_H_INCLUDED #define EVENTS_H_INCLUDED -#if defined(_MSC_VER) -/* MS compilers of pre-VC2010 versions don't have stdint.h - * and I can't get VC2010's stdint.h to compile nicely in - * WiiUse - */ -#include "wiiuse_msvcstdint.h" -#else -#include -#endif +#include "wiiuse.h" /** @defgroup internal_events Internal: Event Utilities */ /** @{ */ diff --git a/lib/wiiuse/src/wiiuse.c b/lib/wiiuse/src/wiiuse.c index b534e4304..1e06280f1 100644 --- a/lib/wiiuse/src/wiiuse.c +++ b/lib/wiiuse/src/wiiuse.c @@ -117,12 +117,15 @@ struct wiimote_t **wiiuse_init(int wiimotes) * * This banner is only displayed once so that if you need * to call this function again it won't be intrusive. + * + * 2018: Replaced wiiuse.net with sourceforge project, since + * wiiuse.net is now abandoned and "parked". */ if (!g_banner) { printf("wiiuse v" WIIUSE_VERSION " loaded.\n" - " Fork at http://github.com/rpavlik/wiiuse\n" - " Original By: Michael Laforest http://wiiuse.net\n"); + " De-facto official fork at http://github.com/wiiuse/wiiuse\n" + " Original By: Michael Laforest \n"); g_banner = 1; } diff --git a/lib/wiiuse/src/wiiuse.h b/lib/wiiuse/src/wiiuse.h index 064ca5c29..af64b6236 100644 --- a/lib/wiiuse/src/wiiuse.h +++ b/lib/wiiuse/src/wiiuse.h @@ -58,7 +58,7 @@ * intended to be the new "upstream" of the project. The new homepage is * on GitHub, where the source is maintained: * - * - http://github.com/rpavlik/wiiuse + * - http://github.com/wiiuse/wiiuse * * Contributions (under the GPL 3+) are welcome and encouraged! * @@ -73,7 +73,7 @@ #define WIIUSE_MAJOR 0 #define WIIUSE_MINOR 15 -#define WIIUSE_MICRO 3 +#define WIIUSE_MICRO 4 #define WIIUSE_VERSION_TRANSFORM(MAJ, MIN, MICRO) (MAJ * 1000000 + MIN * 1000 + MICRO) #define WIIUSE_HAS_VERSION(MAJ, MIN, MICRO) \ @@ -107,11 +107,7 @@ #include #endif -#ifndef WCONST -#define WCONST const -#endif - -#if defined(_MSC_VER) +#if defined(_MSC_VER) && _MSC_VER < 1700 /* MS compilers of pre-VC2010 versions don't have stdint.h * and I can't get VC2010's stdint.h to compile nicely in * WiiUse @@ -733,89 +729,89 @@ typedef enum WIIUSE_WIIMOTE_TYPE { */ typedef struct wiimote_t { - WCONST int unid; /**< user specified id */ + int unid; /**< user specified id */ #ifdef WIIUSE_BLUEZ /** @name Linux-specific (BlueZ) members */ /** @{ */ - WCONST char bdaddr_str[18]; /**< readable bt address */ - WCONST bdaddr_t bdaddr; /**< bt address */ - WCONST int out_sock; /**< output socket */ - WCONST int in_sock; /**< input socket */ + char bdaddr_str[18]; /**< readable bt address */ + bdaddr_t bdaddr; /**< bt address */ + int out_sock; /**< output socket */ + int in_sock; /**< input socket */ /** @} */ #endif #ifdef WIIUSE_WIN32 /** @name Windows-specific members */ /** @{ */ - WCONST HANDLE dev_handle; /**< HID handle */ - WCONST OVERLAPPED hid_overlap; /**< overlap handle */ - WCONST enum win_bt_stack_t stack; /**< type of bluetooth stack to use */ - WCONST int timeout; /**< read timeout */ - WCONST byte normal_timeout; /**< normal timeout */ - WCONST byte exp_timeout; /**< timeout for expansion handshake */ + HANDLE dev_handle; /**< HID handle */ + OVERLAPPED hid_overlap; /**< overlap handle */ + enum win_bt_stack_t stack; /**< type of bluetooth stack to use */ + int timeout; /**< read timeout */ + byte normal_timeout; /**< normal timeout */ + byte exp_timeout; /**< timeout for expansion handshake */ /** @} */ #endif #ifdef WIIUSE_MAC /** @name Mac OS X-specific members */ /** @{ */ - WCONST void *objc_wm; /** WiiuseWiimote* as opaque pointer */ + void *objc_wm; /** WiiuseWiimote* as opaque pointer */ /** @} */ #endif - WCONST int state; /**< various state flags */ - WCONST byte leds; /**< currently lit leds */ - WCONST float battery_level; /**< battery level */ + int state; /**< various state flags */ + byte leds; /**< currently lit leds */ + float battery_level; /**< battery level */ - WCONST int flags; /**< options flag */ + int flags; /**< options flag */ #ifndef WIIUSE_SYNC_HANDSHAKE - WCONST byte handshake_state; /**< the state of the connection handshake */ + byte handshake_state; /**< the state of the connection handshake */ #endif - WCONST byte expansion_state; /**< the state of the expansion handshake */ - WCONST struct data_req_t *data_req; /**< list of data read requests */ + byte expansion_state; /**< the state of the expansion handshake */ + struct data_req_t *data_req; /**< list of data read requests */ - WCONST struct read_req_t *read_req; /**< list of data read requests */ - WCONST struct accel_t accel_calib; /**< wiimote accelerometer calibration */ - WCONST struct expansion_t exp; /**< wiimote expansion device */ + struct read_req_t *read_req; /**< list of data read requests */ + struct accel_t accel_calib; /**< wiimote accelerometer calibration */ + struct expansion_t exp; /**< wiimote expansion device */ - WCONST struct vec3b_t accel; /**< current raw acceleration data */ - WCONST struct orient_t orient; /**< current orientation on each axis */ - WCONST struct gforce_t gforce; /**< current gravity forces on each axis */ + struct vec3b_t accel; /**< current raw acceleration data */ + struct orient_t orient; /**< current orientation on each axis */ + struct gforce_t gforce; /**< current gravity forces on each axis */ - WCONST struct ir_t ir; /**< IR data */ + struct ir_t ir; /**< IR data */ - WCONST uint16_t btns; /**< what buttons have just been pressed */ - WCONST uint16_t btns_held; /**< what buttons are being held down */ - WCONST uint16_t btns_released; /**< what buttons were just released this */ + uint16_t btns; /**< what buttons have just been pressed */ + uint16_t btns_held; /**< what buttons are being held down */ + uint16_t btns_released; /**< what buttons were just released this */ - WCONST float orient_threshold; /**< threshold for orient to generate an event */ - WCONST int32_t accel_threshold; /**< threshold for accel to generate an event */ + float orient_threshold; /**< threshold for orient to generate an event */ + int32_t accel_threshold; /**< threshold for accel to generate an event */ - WCONST struct wiimote_state_t lstate; /**< last saved state */ + struct wiimote_state_t lstate; /**< last saved state */ - WCONST WIIUSE_EVENT_TYPE event; /**< type of event that occurred */ - WCONST byte motion_plus_id[6]; - WCONST WIIUSE_WIIMOTE_TYPE type; + WIIUSE_EVENT_TYPE event; /**< type of event that occurred */ + byte motion_plus_id[6]; + WIIUSE_WIIMOTE_TYPE type; } wiimote; /** @brief Data passed to a callback during wiiuse_update() */ typedef struct wiimote_callback_data_t { - WCONST int uid; - WCONST byte leds; - WCONST float battery_level; - WCONST struct vec3b_t accel; - WCONST struct orient_t orient; - WCONST struct gforce_t gforce; - WCONST struct ir_t ir; - WCONST uint16_t buttons; - WCONST uint16_t buttons_held; - WCONST uint16_t buttons_released; - WCONST WIIUSE_EVENT_TYPE event; - WCONST int state; - WCONST struct expansion_t expansion; + int uid; + byte leds; + float battery_level; + struct vec3b_t accel; + struct orient_t orient; + struct gforce_t gforce; + struct ir_t ir; + uint16_t buttons; + uint16_t buttons_held; + uint16_t buttons_released; + WIIUSE_EVENT_TYPE event; + int state; + struct expansion_t expansion; } wiimote_callback_data_t; /** @brief Callback type */ diff --git a/lib/wiiuse/src/wiiuse_internal.h b/lib/wiiuse/src/wiiuse_internal.h index 1f010926e..983692808 100644 --- a/lib/wiiuse/src/wiiuse_internal.h +++ b/lib/wiiuse/src/wiiuse_internal.h @@ -80,7 +80,7 @@ #include "definitions.h" -#if defined(_MSC_VER) +#if defined(_MSC_VER) && _MSC_VER < 1700 /* MS compilers of pre-VC2010 versions don't have stdint.h * and I can't get VC2010's stdint.h to compile nicely in * WiiUse