├── .gitattributes ├── .gitignore ├── DllExport.bat ├── MU3Input.sln ├── MU3Input ├── AimiIO.cs ├── HidIO.cs ├── IOTest.Designer.cs ├── IOTest.cs ├── IOTest.resx ├── MU3IO.cs ├── MU3Input.csproj ├── Properties │ └── AssemblyInfo.cs └── SimpleRawHid.cs ├── README.md ├── SegaToolsPatch └── 0001-Add-led-code.patch ├── Test ├── Test.vcxproj ├── Test.vcxproj.filters └── main.cpp └── mu3controller ├── .gitignore ├── .idea ├── .gitignore ├── misc.xml ├── modules.xml ├── untitled1.iml └── vcs.xml ├── include └── README ├── lib └── README ├── platformio.ini ├── src ├── components │ ├── manager.cpp │ ├── manager.hpp │ ├── ongeki_hardware.cpp │ ├── ongeki_hardware.hpp │ ├── raw_hid.cpp │ └── raw_hid.hpp ├── main.cpp └── stdinclude.hpp └── test └── README /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /DllExport.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | :: Copyright (c) 2016-2021 Denis Kuzmin [x-3F@outlook.com] github/3F 3 | :: https://github.com/3F/DllExport 4 | if "%~1"=="/?" goto bq 5 | set "aa=%~dpnx0" 6 | set ab=%* 7 | set ac=%* 8 | if defined ab ( 9 | if defined __p_call ( 10 | set ac=%ac:^^=^% 11 | ) else ( 12 | set ab=%ab:^=^^% 13 | ) 14 | ) 15 | set wMgrArgs=%ac% 16 | set ad=%ab:!=^!% 17 | setlocal enableDelayedExpansion 18 | set "ae=^" 19 | set "ad=!ad:%%=%%%%!" 20 | set "ad=!ad:&=%%ae%%&!" 21 | set "af=1.7.4" 22 | set "wAction=Configure" 23 | set "ag=DllExport" 24 | set "ah=tools/net.r_eg.DllExport.Wizard.targets" 25 | set "ai=packages" 26 | set "aj=https://www.nuget.org/api/v2/package/" 27 | set "ak=build_info.txt" 28 | set "al=!aa!" 29 | set "wRootPath=!cd!" 30 | set /a wDxpOpt=0 31 | set "am=" 32 | set "an=" 33 | set "ao=" 34 | set "ap=" 35 | set "aq=" 36 | set "ar=" 37 | set "as=" 38 | set "at=" 39 | set "au=" 40 | set "av=" 41 | set /a aw=0 42 | if not defined ab ( 43 | if defined wAction goto br 44 | goto bq 45 | ) 46 | call :bs bk !ad! bl 47 | goto bt 48 | :bq 49 | echo. 50 | @echo .NET DllExport v1.7.4.29858+c1cc52f 51 | @echo Copyright (c) 2009-2015 Robert Giesecke 52 | @echo Copyright (c) 2016-2021 Denis Kuzmin ^ github/3F 53 | echo. 54 | echo MIT License 55 | @echo https://github.com/3F/DllExport 56 | echo Based on hMSBuild, MvsSln, +GetNuTool: https://github.com/3F 57 | echo. 58 | @echo. 59 | @echo Usage: DllExport [args to DllExport] [args to GetNuTool] [args to hMSBuild] 60 | echo ------ 61 | echo. 62 | echo Arguments 63 | echo --------- 64 | echo -action {type} - Specified action for Wizard. Where {type}: 65 | echo * Configure - To configure DllExport for specific projects. 66 | echo * Update - To update pkg reference for already configured projects. 67 | echo * Restore - To restore configured DllExport. 68 | echo * Export - To export configured projects data. 69 | echo * Recover - To re-configure projects via predefined/exported data. 70 | echo * Unset - To unset all data from specified projects. 71 | echo * Upgrade - Aggregates an Update action with additions for upgrading. 72 | echo. 73 | echo -sln-dir {path} - Path to directory with .sln files to be processed. 74 | echo -sln-file {path} - Optional predefined .sln file to be processed. 75 | echo -metalib {path} - Relative path to meta library. 76 | echo -metacor {path} - Relative path to meta core library. 77 | echo -dxp-target {path} - Relative path to entrypoint wrapper of the main core. 78 | echo -dxp-version {num} - Specific version of DllExport. Where {num}: 79 | echo * Versions: 1.7.3 ... 80 | echo * Keywords: 81 | echo `actual` - Unspecified local/latest remote version; 82 | echo ( Only if you know what you are doing ) 83 | echo. 84 | echo -msb {path} - Full path to specific msbuild. 85 | echo -hMSBuild {args} - Access to hMSBuild tool (packed) https://github.com/3F/hMSBuild 86 | echo -packages {path} - A common directory for packages. 87 | echo -server {url} - Url for searching remote packages. 88 | echo -proxy {cfg} - To use proxy. The format: [usr[:pwd]@]host[:port] 89 | echo -pkg-link {uri} - Direct link to package from the source via specified URI. 90 | echo -force - Aggressive behavior, e.g. like removing pkg when updating. 91 | echo -no-mgr - Do not use %~nx0 for automatic restore the remote package. 92 | echo -mgr-up - Updates %~nx0 to version from '-dxp-version'. 93 | echo -wz-target {path} - Relative path to entrypoint wrapper of the main wizard. 94 | echo -pe-exp-list {module} - To list all available exports from PE32/PE32+ module. 95 | echo -eng - Try to use english language for all build messages. 96 | echo -GetNuTool {args} - Access to GetNuTool (integrated) https://github.com/3F/GetNuTool 97 | echo -debug - To show additional information. 98 | echo -version - Displays version for which (together with) it was compiled. 99 | echo -build-info - Displays actual build information from selected DllExport. 100 | echo -help - Displays this help. Aliases: -help -h 101 | echo. 102 | echo Flags 103 | echo ----- 104 | echo __p_call - To use the call-type logic when invoking %~nx0 105 | echo. 106 | echo Samples 107 | echo ------- 108 | echo DllExport -action Configure -force -pkg-link http://host/v1.7.3.nupkg 109 | echo DllExport -action Restore -sln-file "Conari.sln" 110 | echo DllExport -proxy guest:1234@10.0.2.15:7428 -action Configure 111 | echo. 112 | echo DllExport -mgr-up -dxp-version 1.7.3 113 | echo DllExport -action Upgrade -dxp-version 1.7.3 114 | echo. 115 | echo DllExport -GetNuTool /p:ngpackages="Conari;regXwild" 116 | echo DllExport -pe-exp-list bin\Debug\regXwild.dll 117 | goto bu 118 | :bt 119 | set /a ax=0 120 | :bv 121 | set ay=!bk[%ax%]! 122 | if [!ay!]==[-help] ( goto bq ) else if [!ay!]==[-h] ( goto bq ) else if [!ay!]==[-?] ( goto bq ) 123 | if [!ay!]==[-debug] ( 124 | set am=1 125 | goto bw 126 | ) else if [!ay!]==[-action] ( set /a "ax+=1" & call :bx bk[!ax!] v 127 | set wAction=!v! 128 | for %%g in (Restore, Configure, Update, Export, Recover, Unset, Upgrade, Default) do ( 129 | if "!v!"=="%%g" goto bw 130 | ) 131 | echo Unknown -action !v! 132 | exit/B 1 133 | ) else if [!ay!]==[-sln-dir] ( set /a "ax+=1" & call :bx bk[!ax!] v 134 | set wSlnDir=!v! 135 | goto bw 136 | ) else if [!ay!]==[-sln-file] ( set /a "ax+=1" & call :bx bk[!ax!] v 137 | set wSlnFile=!v! 138 | goto bw 139 | ) else if [!ay!]==[-metalib] ( set /a "ax+=1" & call :bx bk[!ax!] v 140 | set wMetaLib=!v! 141 | goto bw 142 | ) else if [!ay!]==[-metacor] ( set /a "ax+=1" & call :bx bk[!ax!] v 143 | set wMetaCor=!v! 144 | goto bw 145 | ) else if [!ay!]==[-dxp-target] ( set /a "ax+=1" & call :bx bk[!ax!] v 146 | set wDxpTarget=!v! 147 | goto bw 148 | ) else if [!ay!]==[-dxp-version] ( set /a "ax+=1" & call :bx bk[!ax!] v 149 | set af=!v! 150 | goto bw 151 | ) else if [!ay!]==[-msb] ( set /a "ax+=1" & call :bx bk[!ax!] v 152 | set ao=!v! 153 | goto bw 154 | ) else if [!ay!]==[-packages] ( set /a "ax+=1" & call :bx bk[!ax!] v 155 | set ai=!v! 156 | goto bw 157 | ) else if [!ay!]==[-server] ( set /a "ax+=1" & call :bx bk[!ax!] v 158 | set aj=!v! 159 | goto bw 160 | ) else if [!ay!]==[-proxy] ( set /a "ax+=1" & call :bx bk[!ax!] v 161 | set at=!v! 162 | set wProxy=!v! 163 | goto bw 164 | ) else if [!ay!]==[-pkg-link] ( set /a "ax+=1" & call :bx bk[!ax!] v 165 | set ap=!v! 166 | set af=!ay! 167 | goto bw 168 | ) else if [!ay!]==[-force] ( 169 | set ar=1 170 | goto bw 171 | ) else if [!ay!]==[-no-mgr] ( 172 | set /a wDxpOpt^|=1 173 | goto bw 174 | ) else if [!ay!]==[-mgr-up] ( 175 | set as=1 176 | goto bw 177 | ) else if [!ay!]==[-wz-target] ( set /a "ax+=1" & call :bx bk[!ax!] v 178 | set ah=!v! 179 | goto bw 180 | ) else if [!ay!]==[-pe-exp-list] ( set /a "ax+=1" & call :bx bk[!ax!] v 181 | set aq=!v! 182 | goto bw 183 | ) else if [!ay!]==[-eng] ( 184 | chcp 437 >nul 185 | goto bw 186 | ) else if [!ay!]==[-GetNuTool] ( 187 | call :by -GetNuTool 10 188 | set /a aw=!ERRORLEVEL! & goto bu 189 | ) else if [!ay!]==[-hMSBuild] ( 190 | set av=1 & goto br 191 | ) else if [!ay!]==[-version] ( 192 | @echo v1.7.4.29858+c1cc52f %__dxp_pv% 193 | goto bu 194 | ) else if [!ay!]==[-build-info] ( 195 | set an=1 196 | goto bw 197 | ) else if [!ay!]==[-tests] ( set /a "ax+=1" & call :bx bk[!ax!] v 198 | set au=!v! 199 | goto bw 200 | ) else ( 201 | echo Incorrect key: !ay! 202 | set /a aw=1 203 | goto bu 204 | ) 205 | :bw 206 | set /a "ax+=1" & if %ax% LSS !bl! goto bv 207 | :br 208 | call :bz "dxpName = " ag 209 | call :bz "dxpVersion = " af 210 | call :bz "-sln-dir = " wSlnDir 211 | call :bz "-sln-file = " wSlnFile 212 | call :bz "-metalib = " wMetaLib 213 | call :bz "-metacor = " wMetaCor 214 | call :bz "-dxp-target = " wDxpTarget 215 | call :bz "-wz-target = " ah 216 | call :bz "#opt " wDxpOpt 217 | if defined af ( 218 | if "!af!"=="actual" ( 219 | set "af=" 220 | ) 221 | ) 222 | set wPkgVer=!af! 223 | if z%wAction%==zUpgrade ( 224 | call :bz "Upgrade is on" 225 | set as=1 226 | set ar=1 227 | ) 228 | call :b0 ai 229 | set "ai=!ai!\\" 230 | set "az=!ag!" 231 | set "wPkgPath=!ai!!ag!" 232 | if defined af ( 233 | set "az=!az!/!af!" 234 | set "wPkgPath=!wPkgPath!.!af!" 235 | ) 236 | if defined ar ( 237 | if exist "!wPkgPath!" ( 238 | call :bz "Removing old version before continue. '-force' key rule. " wPkgPath 239 | rmdir /S/Q "!wPkgPath!" 240 | ) 241 | ) 242 | set a0="!wPkgPath!\\!ah!" 243 | call :bz "wPkgPath = " wPkgPath 244 | if not exist !a0! ( 245 | if exist "!wPkgPath!" ( 246 | call :bz "Trying to replace obsolete version ... " wPkgPath 247 | rmdir /S/Q "!wPkgPath!" 248 | ) 249 | call :bz "-pkg-link = " ap 250 | call :bz "-server = " aj 251 | if defined ap ( 252 | set aj=!ap! 253 | if "!aj::=!"=="!aj!" ( 254 | set aj=!cd!/!aj! 255 | ) 256 | if "!wPkgPath::=!"=="!wPkgPath!" ( 257 | set "a1=../" 258 | ) 259 | set "az=:!a1!!wPkgPath!|" 260 | ) 261 | if defined ao ( 262 | set a2=-msbuild "!ao!" 263 | ) 264 | set a3=!a2! /p:ngserver="!aj!" /p:ngpackages="!az!" /p:ngpath="!ai!" /p:proxycfg="!at! " 265 | call :bz "GetNuTool call: " a3 266 | if defined am ( 267 | call :b1 !a3! 268 | ) else ( 269 | call :b1 !a3! >nul 270 | ) 271 | ) 272 | if defined av ( 273 | call :by -hMSBuild 9 274 | set /a aw=!ERRORLEVEL! & goto bu 275 | ) 276 | if defined aq ( 277 | "!wPkgPath!\\tools\\PeViewer.exe" -list -pemodule "!aq!" 278 | set /a aw=%ERRORLEVEL% 279 | goto bu 280 | ) 281 | if defined an ( 282 | call :bz "buildInfo = " wPkgPath ak 283 | if not exist "!wPkgPath!\\!ak!" ( 284 | echo information about build is not available. 285 | set /a aw=2 286 | goto bu 287 | ) 288 | type "!wPkgPath!\\!ak!" 289 | goto bu 290 | ) 291 | if not exist !a0! ( 292 | echo Something went wrong. Try to use another keys. 293 | set /a aw=2 294 | goto bu 295 | ) 296 | call :bz "wRootPath = " wRootPath 297 | call :bz "wAction = " wAction 298 | call :bz "wMgrArgs = " wMgrArgs 299 | if defined ao ( 300 | call :bz "Use specific MSBuild tools: " ao 301 | set a4="!ao!" 302 | goto b2 303 | ) 304 | call :b3 bm & set a4="!bm!" 305 | if "!ERRORLEVEL!"=="0" goto b2 306 | echo MSBuild tools was not found. Try with `-msb` key. 307 | set /a aw=2 308 | goto bu 309 | :b2 310 | if not defined a4 ( 311 | echo Something went wrong. Use `-debug` key for details. 312 | set /a aw=2 313 | goto bu 314 | ) 315 | if not defined au ( 316 | if not defined ao if defined wPkgPath ( 317 | set a4="!wPkgPath!\\hMSBuild" 318 | for /f "tokens=*" %%i in ('!a4! -version') do set a5=%%i 319 | call :b4 !a5! bn 320 | call :bz "hMSBuild -v" a5 bn 321 | if !bn! GEQ 230 ( 322 | call :bz "2.3+" 323 | set a4=!a4! -vsw-as "-requiresAny -requires Microsoft.NetCore.Component.SDK Microsoft.Net.Core.Component.SDK -products * -latest -prerelease" 324 | ) 325 | ) 326 | call :bz "Target: " a4 a0 327 | call !a4! /nologo /v:m /m:4 !a0! 328 | ) 329 | :bu 330 | if defined au ( 331 | echo Running Tests ... "!au!" 332 | call :b3 bo 333 | "!bo!" /nologo /v:m /m:4 "!au!" 334 | exit/B 0 335 | ) 336 | if defined as ( 337 | (copy /B/Y "!wPkgPath!\\DllExport.bat" "!al!" > nul) && ( echo Manager has been updated. & exit/B 0 ) || ( (echo -mgr-up failed:!aw! 1>&2) & exit/B 1 ) 338 | ) 339 | exit/B !aw! 340 | :b4 341 | set a6=%~1 342 | for /f "tokens=1,2 delims=." %%a in ("!a6!") do ( 343 | set _=%%b & set /a _*=10 & set /a %2=%%a!_! 344 | ) 345 | exit/B 0 346 | :by 347 | set ay=%~1 348 | set /a a7=%~2 349 | call :bz "accessing to !ay! ..." 350 | for /L %%p IN (0,1,8181) DO ( 351 | if "!ad:~%%p,%a7%!"=="!ay!" ( 352 | set a8=!ad:~%%p! 353 | set a9=!a8:~%a7%! 354 | if defined av ( 355 | call "!wPkgPath!\\hMSBuild" !a9! 356 | ) else ( 357 | call :b1 !a9! 358 | ) 359 | exit/B !ERRORLEVEL! 360 | ) 361 | ) 362 | call :bz "!ay! is corrupted: " ad 363 | exit/B 1 364 | :b3 365 | call :bz "Searching from .NET Framework - .NET 4.0, ..." 366 | for %%v in (4.0, 3.5, 2.0) do ( 367 | call :b5 %%v Y & if defined Y ( 368 | set %1=!Y! 369 | exit/B 0 370 | ) 371 | ) 372 | call :bz "msb -netfx: not found" 373 | set "%1=" 374 | exit/B 2 375 | :b5 376 | call :bz "check %1" 377 | for /F "usebackq tokens=2* skip=2" %%a in ( 378 | `reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\%1" /v MSBuildToolsPath 2^> nul` 379 | ) do if exist %%b ( 380 | set a_=%%~b 381 | call :bz ":msbfound " a_ 382 | call :b6 a_ bp 383 | set %2=!bp! 384 | exit/B 0 385 | ) 386 | set "%2=" 387 | exit/B 0 388 | :b6 389 | set %2=!%~1!\MSBuild.exe 390 | exit/B 0 391 | :bz 392 | if defined am ( 393 | set ba=%1 394 | set ba=!ba:~0,-1! 395 | set ba=!ba:~1! 396 | echo.[%TIME% ] !ba! !%2! !%3! 397 | ) 398 | exit/B 0 399 | :b0 400 | call :b7 %1 401 | call :b8 %1 402 | exit/B 0 403 | :b7 404 | call :b9 %1 "-=1" 405 | exit/B 0 406 | :b8 407 | call :b9 %1 "+=1" 408 | exit/B 0 409 | :b9 410 | set bb=z!%1!z 411 | if "%~2"=="-=1" (set "bc=1") else (set "bc=") 412 | if defined bc ( 413 | set /a "i=-2" 414 | ) else ( 415 | set /a "i=1" 416 | ) 417 | :b_ 418 | if "!bb:~%i%,1!"==" " ( 419 | set /a "i%~2" 420 | goto b_ 421 | ) 422 | if defined bc set /a "i+=1" 423 | if defined bc ( 424 | set "%1=!bb:~1,%i%!" 425 | ) else ( 426 | set "%1=!bb:~%i%,-1!" 427 | ) 428 | exit/B 0 429 | :bs 430 | set "bd=%~1" 431 | set /a ax=-1 432 | :ca 433 | set /a ax+=1 434 | set %bd%[!ax!]=%~2 435 | shift & if not "%~3"=="" goto ca 436 | set /a ax-=1 437 | set %1=!ax! 438 | exit/B 0 439 | :bx 440 | set %2=!%1! 441 | exit/B 0 442 | :b1 443 | setlocal disableDelayedExpansion 444 | @echo off 445 | :: GetNuTool - Executable version 446 | :: Copyright (c) 2015-2018,2020 Denis Kuzmin [ x-3F@outlook.com ] 447 | :: https://github.com/3F/GetNuTool 448 | set be=gnt.core 449 | set bf="%temp%\%random%%random%%be%" 450 | if "%~1"=="-unpack" goto cb 451 | set bg=%* 452 | if defined __p_call if defined bg set bg=%bg:^^=^% 453 | set bh=%__p_msb% 454 | if defined bh goto cc 455 | if "%~1"=="-msbuild" goto cd 456 | for %%v in (4.0, 14.0, 12.0, 3.5, 2.0) do ( 457 | for /F "usebackq tokens=2* skip=2" %%a in ( 458 | `reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\%%v" /v MSBuildToolsPath 2^> nul` 459 | ) do if exist %%b ( 460 | set bh="%%~b\MSBuild.exe" 461 | goto cc 462 | ) 463 | ) 464 | echo MSBuild was not found. Try -msbuild "fullpath" args 1>&2 465 | exit/B 2 466 | :cd 467 | shift 468 | set bh=%1 469 | shift 470 | set bi=%bg:!= #__b_ECL## % 471 | setlocal enableDelayedExpansion 472 | set bi=!bi:%%=%%%%! 473 | :ce 474 | for /F "tokens=1* delims==" %%a in ("!bi!") do ( 475 | if "%%~b"=="" ( 476 | call :cf !bi! 477 | exit/B %ERRORLEVEL% 478 | ) 479 | set bi=%%a #__b_EQ## %%b 480 | ) 481 | goto ce 482 | :cf 483 | shift & shift 484 | set "bg=" 485 | :cg 486 | set bg=!bg! %1 487 | shift & if not "%~2"=="" goto cg 488 | set bg=!bg: #__b_EQ## ==! 489 | setlocal disableDelayedExpansion 490 | set bg=%bg: #__b_ECL## =!% 491 | :cc 492 | call :ch 493 | call %bh% %bf% /nologo /p:wpath="%cd%/" /v:m /m:4 %bg% 494 | set "bh=" 495 | set bj=%ERRORLEVEL% 496 | del /Q/F %bf% 497 | exit/B %bj% 498 | :cb 499 | set bf="%cd%\%be%" 500 | echo Generating minified version in %bf% ... 501 | :ch 502 | %bf% 503 | set a=PropertyGroup&set b=Condition&set c=ngpackages&set d=Target&set e=DependsOnTargets&set f=TaskCoreDllPath&set g=MSBuildToolsPath&set h=UsingTask&set i=CodeTaskFactory&set j=ParameterGroup&set k=Reference&set l=Include&set m=System&set n=Using&set o=Namespace&set p=IsNullOrEmpty&set q=return&set r=string&set s=delegate&set t=foreach&set u=WriteLine&set v=Combine&set w=Console.WriteLine&set x=Directory&set y=GetNuTool&set z=StringComparison&set _=EXT_NUSPEC 504 | ^ 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | -------------------------------------------------------------------------------- /MU3Input/MU3IO.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using System.Runtime.InteropServices; 3 | using System.Diagnostics; 4 | 5 | namespace MU3Input 6 | { 7 | public static class Mu3Io 8 | { 9 | internal static HidIO Io; 10 | private static IOTest _test; 11 | 12 | [DllExport(ExportName = "mu3_io_get_api_version")] 13 | public static ushort GetVersion() 14 | { 15 | return 0x0102; 16 | } 17 | 18 | [DllExport(CallingConvention.Cdecl, ExportName = "mu3_io_init")] 19 | public static uint Init() 20 | { 21 | if (Process.GetCurrentProcess().ProcessName != "amdaemon" && 22 | Process.GetCurrentProcess().ProcessName != "Debug" && 23 | Process.GetCurrentProcess().ProcessName != "Test") 24 | return 0; 25 | 26 | Io = new HidIO(); 27 | _test = new IOTest(Io); 28 | 29 | Task.Run(() => _test.ShowDialog()); 30 | return 0; 31 | } 32 | 33 | [DllExport(CallingConvention.Cdecl, ExportName = "mu3_io_poll")] 34 | public static uint Poll() 35 | { 36 | if (Io == null) 37 | return 0; 38 | 39 | if (!Io.IsConnected) 40 | { 41 | Io.Reconnect(); 42 | } 43 | 44 | _test.UpdateData(); 45 | return 0; 46 | } 47 | 48 | [DllExport(CallingConvention.Cdecl, ExportName = "mu3_io_get_opbtns")] 49 | public static void GetOpButtons(out byte opbtn) 50 | { 51 | opbtn = 0; 52 | } 53 | 54 | [DllExport(CallingConvention.Cdecl, ExportName = "mu3_io_get_gamebtns")] 55 | public static void GetGameButtons(out byte left, out byte right) 56 | { 57 | if (Io == null || !Io.IsConnected) 58 | { 59 | left = 0; 60 | right = 0; 61 | return; 62 | } 63 | 64 | left = Io.LeftButton; 65 | right = Io.RightButton; 66 | } 67 | 68 | [DllExport(CallingConvention.Cdecl, ExportName = "mu3_io_get_lever")] 69 | public static void GetLever(out short pos) 70 | { 71 | if (Io == null || !Io.IsConnected) 72 | { 73 | pos = 0; 74 | return; 75 | } 76 | 77 | pos = Io.Lever; 78 | } 79 | 80 | [DllExport(CallingConvention.Cdecl, ExportName = "mu3_io_set_led")] 81 | public static void SetLed(uint data) 82 | { 83 | _test.SetColor(data); 84 | Io.SetLed(data); 85 | } 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /MU3Input/MU3Input.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {A90797A6-C546-4233-A183-453AF52319D0} 8 | Library 9 | Properties 10 | MU3Input 11 | MU3Input 12 | v4.7.2 13 | 512 14 | true 15 | true 16 | 17 | 18 | true 19 | bin\x64\Debug\ 20 | DEBUG;TRACE 21 | full 22 | 7.3 23 | prompt 24 | 25 | 26 | bin\x64\Release\ 27 | TRACE 28 | true 29 | pdbonly 30 | x64 31 | 7.3 32 | prompt 33 | 34 | 35 | 0B196F93-0E1B-4957-98A4-814FDC3A67C9 36 | DllExport.dll 37 | MU3Input 38 | true 39 | x64 40 | 1 41 | true 42 | false 43 | false 44 | true 45 | 30000 46 | 2 47 | 0 48 | 0 49 | 0 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | Form 74 | 75 | 76 | IOTest.cs 77 | 78 | 79 | 80 | 81 | 82 | 1.7.4 83 | false 84 | 1 85 | 86 | 87 | 13.0.1 88 | 89 | 90 | 91 | 92 | IOTest.cs 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | $(SolutionDir)packages\DllExport.1.7.4\gcache\$(DllExportMetaXBase)\$(DllExportNamespace)\$(DllExportMetaLibName) 111 | False 112 | False 113 | 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /MU3Input/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // 有关程序集的一般信息由以下 6 | // 控制。更改这些特性值可修改 7 | // 与程序集关联的信息。 8 | [assembly: AssemblyTitle("MU3Input")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("MU3Input")] 13 | [assembly: AssemblyCopyright("Copyright © 2021")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // 将 ComVisible 设置为 false 会使此程序集中的类型 18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 19 | //请将此类型的 ComVisible 特性设置为 true。 20 | [assembly: ComVisible(false)] 21 | 22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID 23 | [assembly: Guid("a90797a6-c546-4233-a183-453af52319d0")] 24 | 25 | // 程序集的版本信息由下列四个值组成: 26 | // 27 | // 主版本 28 | // 次版本 29 | // 生成号 30 | // 修订号 31 | // 32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 33 | //通过使用 "*",如下所示: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /MU3Input/SimpleRawHid.cs: -------------------------------------------------------------------------------- 1 | /* Simple Raw HID functions for C# based on http://www.pjrc.com/teensy/rawhid.html C functions (Copyright (c) 2009 PJRC.COM, LLC) 2 | * Copyright (c) 2017 Jan Henrik Sawatzki 3 | * 4 | * Open - open 1 or more HID devices 5 | * Close - close a HID device 6 | * Receive - receive a packet from HID device 7 | * Send - send a packet to HID device 8 | * 9 | * Permission is hereby granted, free of charge, to any person obtaining a copy 10 | * of this software and associated documentation files (the "Software"), to deal 11 | * in the Software without restriction, including without limitation the rights 12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | * copies of the Software, and to permit persons to whom the Software is 14 | * furnished to do so, subject to the following conditions: 15 | * 16 | * The above description, website URL and copyright notice and this permission 17 | * notice shall be included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | * THE SOFTWARE. 26 | */ 27 | 28 | using Microsoft.Win32.SafeHandles; 29 | using System; 30 | using System.Runtime.InteropServices; 31 | using System.Threading; 32 | 33 | // ReSharper disable All because it's third party source code 34 | namespace SimpleHID.Raw 35 | { 36 | class HIDDevice 37 | { 38 | public SafeFileHandle Handle; 39 | public bool IsOpen; 40 | public HIDDevice PreviousHIDDevice; 41 | public HIDDevice NextHIDDevice; 42 | } 43 | 44 | public class SimpleRawHID 45 | { 46 | private const int ERROR_IO_PENDING = 997; 47 | 48 | private const uint WAIT_OBJECT_0 = 0x00000000; 49 | private const uint WAIT_TIMEOUT = 0x00000102; 50 | 51 | private const uint GENERIC_READ = 0x80000000; 52 | private const uint GENERIC_WRITE = 0x40000000; 53 | private const uint OPEN_EXISTING = 3; 54 | 55 | private const uint FILE_SHARE_READ = 0x1; 56 | private const uint FILE_SHARE_WRITE = 0x2; 57 | private const uint FILE_FLAG_OVERLAPPED = 0x40000000; 58 | 59 | private static readonly IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1); 60 | 61 | [StructLayout(LayoutKind.Sequential)] 62 | private struct HIDD_ATTRIBUTES 63 | { 64 | public int Size; 65 | public ushort VendorID; 66 | public ushort ProductID; 67 | public ushort VersionNumber; 68 | } 69 | 70 | [StructLayout(LayoutKind.Sequential)] 71 | private struct SP_DEVICE_INTERFACE_DATA 72 | { 73 | public int cbSize; 74 | public Guid interfaceClassGuid; 75 | public int flags; 76 | private UIntPtr reserved; 77 | } 78 | 79 | [StructLayout(LayoutKind.Sequential)] 80 | private struct HIDP_CAPS 81 | { 82 | public ushort Usage; 83 | public ushort UsagePage; 84 | public ushort InputReportByteLength; 85 | public ushort OutputReportByteLength; 86 | public ushort FeatureReportByteLength; 87 | [MarshalAs(UnmanagedType.ByValArray, SizeConst = 17)] 88 | public ushort[] Reserved; 89 | public ushort NumberLinkCollectionNodes; 90 | public ushort NumberInputButtonCaps; 91 | public ushort NumberInputValueCaps; 92 | public ushort NumberInputDataIndices; 93 | public ushort NumberOutputButtonCaps; 94 | public ushort NumberOutputValueCaps; 95 | public ushort NumberOutputDataIndices; 96 | public ushort NumberFeatureButtonCaps; 97 | public ushort NumberFeatureValueCaps; 98 | public ushort NumberFeatureDataIndices; 99 | } 100 | 101 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] 102 | struct SP_DEVICE_INTERFACE_DETAIL_DATA 103 | { 104 | public int cbSize; 105 | [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)] 106 | public string DevicePath; 107 | } 108 | 109 | [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] 110 | private struct CRITICAL_SECTION 111 | { 112 | public IntPtr DebugInfo; 113 | public long LockCount; 114 | public long RecursionCount; 115 | public IntPtr OwningThread; 116 | public IntPtr LockSemaphore; 117 | public ulong SpinCount; 118 | } 119 | 120 | [Flags] 121 | private enum DiGetClassFlags : uint 122 | { 123 | DIGCF_DEFAULT = 0x00000001, // only valid with DIGCF_DEVICEINTERFACE 124 | DIGCF_PRESENT = 0x00000002, 125 | DIGCF_ALLCLASSES = 0x00000004, 126 | DIGCF_PROFILE = 0x00000008, 127 | DIGCF_DEVICEINTERFACE = 0x00000010, 128 | } 129 | 130 | [DllImport("hid.dll", EntryPoint = "HidD_GetHidGuid", SetLastError = true)] 131 | private static extern void HidD_GetHidGuid(out Guid Guid); 132 | 133 | [DllImport("hid.dll", SetLastError = true)] 134 | [return: MarshalAs(UnmanagedType.Bool)] 135 | private static extern bool HidD_GetAttributes(SafeHandle DeviceObject, ref HIDD_ATTRIBUTES Attributes); 136 | 137 | [DllImport("hid.dll", SetLastError = true)] 138 | [return: MarshalAs(UnmanagedType.Bool)] 139 | private static extern bool HidD_FreePreparsedData(IntPtr PreparsedData); 140 | 141 | [DllImport("hid.dll", SetLastError = true)] 142 | [return: MarshalAs(UnmanagedType.Bool)] 143 | private static extern bool HidD_GetPreparsedData(SafeFileHandle hidHandle, ref IntPtr preparsedDataPointer); 144 | 145 | [DllImport("hid.dll", SetLastError = true)] 146 | [return: MarshalAs(UnmanagedType.Bool)] 147 | private static extern bool HidP_GetCaps(IntPtr preparsedDataPointer, ref HIDP_CAPS capabilities); 148 | 149 | [DllImport("setupapi.dll", CharSet = CharSet.Auto)] 150 | private static extern IntPtr SetupDiGetClassDevs(ref Guid ClassGuid, IntPtr Enumerator, IntPtr hwndParent, DiGetClassFlags Flags); 151 | 152 | [DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)] 153 | [return: MarshalAs(UnmanagedType.Bool)] 154 | private static extern bool SetupDiGetDeviceInterfaceDetail(IntPtr hDevInfo, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData, ref SP_DEVICE_INTERFACE_DETAIL_DATA deviceInterfaceDetailData, uint deviceInterfaceDetailDataSize, IntPtr requiredSize, IntPtr deviceInfoData); 155 | 156 | [DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)] 157 | [return: MarshalAs(UnmanagedType.Bool)] 158 | private static extern bool SetupDiEnumDeviceInterfaces(IntPtr hDevInfo, IntPtr devInfo, ref Guid interfaceClassGuid, UInt32 memberIndex, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData); 159 | 160 | [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)] 161 | static extern SafeFileHandle CreateFile(string lpFileName, uint dwDesiredAccess, uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile); 162 | 163 | [DllImport("kernel32.dll", SetLastError = true)] 164 | [return: MarshalAs(UnmanagedType.Bool)] 165 | private static extern bool ReadFile(SafeFileHandle hFile, [Out] byte[] lpBuffer, uint nNumberOfBytesToRead, IntPtr lpNumberOfBytesRead, [In] ref System.Threading.NativeOverlapped lpOverlapped); 166 | 167 | [DllImport("kernel32.dll")] 168 | [return: MarshalAs(UnmanagedType.Bool)] 169 | private static extern bool WriteFile(SafeFileHandle hFile, byte[] lpBuffer, uint nNumberOfBytesToWrite, IntPtr lpNumberOfBytesWritten, [In] ref System.Threading.NativeOverlapped lpOverlapped); 170 | 171 | [DllImport("kernel32.dll")] 172 | [return: MarshalAs(UnmanagedType.Bool)] 173 | private static extern bool CancelIo(IntPtr hFile); 174 | 175 | [DllImport("kernel32.dll")] 176 | private static extern void InitializeCriticalSection(out CRITICAL_SECTION lpCriticalSection); 177 | 178 | [DllImport("kernel32.dll")] 179 | private static extern void EnterCriticalSection(ref CRITICAL_SECTION lpCriticalSection); 180 | 181 | [DllImport("kernel32.dll")] 182 | private static extern void LeaveCriticalSection(ref CRITICAL_SECTION lpCriticalSection); 183 | 184 | [DllImport("kernel32.dll", SetLastError = true)] 185 | private static extern uint WaitForSingleObject(IntPtr hHandle, UInt32 dwMilliseconds); 186 | 187 | [DllImport("kernel32.dll", SetLastError = true)] 188 | [return: MarshalAs(UnmanagedType.Bool)] 189 | private static extern bool GetOverlappedResult(IntPtr hFile, [In] ref System.Threading.NativeOverlapped lpOverlapped, out uint lpNumberOfBytesTransferred, bool bWait); 190 | 191 | [DllImport("kernel32.dll")] 192 | private static extern IntPtr CreateEvent(IntPtr lpEventAttributes, bool bManualReset, bool bInitialState, string lpName); 193 | 194 | [DllImport("kernel32.dll")] 195 | [return: MarshalAs(UnmanagedType.Bool)] 196 | private static extern bool ResetEvent(IntPtr hEvent); 197 | 198 | private static HIDDevice FirstHIDDevice = null; 199 | private static HIDDevice LastHIDDevice = null; 200 | 201 | private static IntPtr ReceiveEvent = IntPtr.Zero; 202 | private static IntPtr SendEvent = IntPtr.Zero; 203 | private static CRITICAL_SECTION ReceiveMutex = new CRITICAL_SECTION(); 204 | private static CRITICAL_SECTION SendMutex = new CRITICAL_SECTION(); 205 | 206 | public SimpleRawHID() 207 | { 208 | } 209 | 210 | // Open - opens 1 or more HID devices 211 | // 212 | // Inputs: 213 | // max = maximum number of devices to open 214 | // vid = Vendor ID, or -1 if any 215 | // pid = Product ID, or -1 if any 216 | // usagePage = top level usage page, or -1 if any 217 | // usage = top level usage number, or -1 if any 218 | // Output: 219 | // actual number of devices opened 220 | // 221 | public int Open(int max, uint vid, uint pid, int usagePage = -1, int usage = -1) 222 | { 223 | if (FirstHIDDevice != null) 224 | { 225 | FreeAllHIDDevices(); 226 | } 227 | 228 | if (max < 1) 229 | { 230 | return 0; 231 | } 232 | if (ReceiveEvent == IntPtr.Zero) 233 | { 234 | ReceiveEvent = CreateEvent(IntPtr.Zero, true, true, null); 235 | SendEvent = CreateEvent(IntPtr.Zero, true, true, null); 236 | InitializeCriticalSection(out ReceiveMutex); 237 | InitializeCriticalSection(out SendMutex); 238 | } 239 | 240 | Guid guid; 241 | HidD_GetHidGuid(out guid); 242 | IntPtr info = SetupDiGetClassDevs(ref guid, IntPtr.Zero, IntPtr.Zero, DiGetClassFlags.DIGCF_PRESENT | DiGetClassFlags.DIGCF_DEVICEINTERFACE); 243 | if (info == INVALID_HANDLE_VALUE) 244 | { 245 | return 0; 246 | } 247 | 248 | uint index = 0; 249 | int deviceCount = 0; 250 | bool retValue; 251 | 252 | while (true) 253 | { 254 | SP_DEVICE_INTERFACE_DATA iface = new SP_DEVICE_INTERFACE_DATA(); 255 | iface.cbSize = Marshal.SizeOf(iface); 256 | 257 | retValue = SetupDiEnumDeviceInterfaces(info, IntPtr.Zero, ref guid, index, ref iface); 258 | if (!retValue) 259 | { 260 | return deviceCount; 261 | } 262 | SP_DEVICE_INTERFACE_DETAIL_DATA details = new SP_DEVICE_INTERFACE_DETAIL_DATA(); 263 | if (IntPtr.Size == 8) 264 | { 265 | details.cbSize = 8; // for 64 bit os 266 | } 267 | 268 | else 269 | { 270 | details.cbSize = 4 + Marshal.SystemDefaultCharSize; // for 32 bit os 271 | } 272 | 273 | retValue = SetupDiGetDeviceInterfaceDetail(info, ref iface, ref details, 1024, IntPtr.Zero, IntPtr.Zero); 274 | if (!retValue) 275 | { 276 | index++; 277 | continue; 278 | } 279 | 280 | SafeFileHandle h = CreateFile(details.DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, IntPtr.Zero, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, IntPtr.Zero); 281 | 282 | if (h.IsInvalid) 283 | { 284 | index++; 285 | continue; 286 | } 287 | HIDD_ATTRIBUTES attrib = new HIDD_ATTRIBUTES(); 288 | attrib.Size = Marshal.SizeOf(attrib); 289 | retValue = HidD_GetAttributes(h, ref attrib); 290 | 291 | IntPtr hidData = new IntPtr(0); 292 | Console.WriteLine($"{index} - {attrib.VendorID:x}:{attrib.ProductID:x}"); 293 | 294 | if (!retValue || (vid > 0 && attrib.VendorID != vid) || 295 | (pid > 0 && attrib.ProductID != pid) || 296 | !HidD_GetPreparsedData(h, ref hidData)) 297 | { 298 | h.SetHandleAsInvalid(); 299 | h.Dispose(); 300 | h = null; 301 | index++; 302 | continue; 303 | } 304 | 305 | HIDP_CAPS capabilities = new HIDP_CAPS(); 306 | 307 | retValue = HidP_GetCaps(hidData, ref capabilities); 308 | 309 | if (!retValue || (usagePage > 0 && capabilities.UsagePage != usagePage) || 310 | (usage > 0 && capabilities.Usage != usage)) 311 | { 312 | HidD_FreePreparsedData(hidData); 313 | h.SetHandleAsInvalid(); 314 | h.Dispose(); 315 | h = null; 316 | index++; 317 | continue; 318 | } 319 | HidD_FreePreparsedData(hidData); 320 | HIDDevice device = new HIDDevice(); 321 | device.Handle = h; 322 | device.IsOpen = true; 323 | 324 | AddHIDDevice(device); 325 | deviceCount++; 326 | if (deviceCount >= max) 327 | { 328 | return deviceCount; 329 | } 330 | index++; 331 | } 332 | } 333 | 334 | // Close - closes a HID device 335 | // 336 | // Inputs: 337 | // (nothing) 338 | // Output 339 | // (nothing) 340 | // 341 | public void Close() 342 | { 343 | if (FirstHIDDevice != null) 344 | { 345 | FreeAllHIDDevices(); 346 | } 347 | } 348 | 349 | // Receive - receives a packet 350 | // 351 | // Inputs: 352 | // num = device to receive from (zero based) 353 | // buf = buffer to receive packet 354 | // len = buffer's size 355 | // timeout = time to wait, in milliseconds 356 | // Output: 357 | // number of bytes received, or -1 on error 358 | // 359 | public int Receive(int num, ref byte[] buf, int len, int timeout) 360 | { 361 | byte[] tempBuffer = new byte[516]; 362 | 363 | if (tempBuffer.Length < len + 1) 364 | { 365 | return -1; 366 | } 367 | 368 | HIDDevice device = GetHIDDevice(num); 369 | if (device == null || !device.IsOpen) 370 | { 371 | return -1; 372 | } 373 | 374 | EnterCriticalSection(ref ReceiveMutex); 375 | ResetEvent(ReceiveEvent); 376 | NativeOverlapped overlapped = new NativeOverlapped(); 377 | overlapped.EventHandle = ReceiveEvent; 378 | if (!ReadFile(device.Handle, tempBuffer, (uint)len + 1, IntPtr.Zero, ref overlapped)) 379 | { 380 | if (Marshal.GetLastWin32Error() != ERROR_IO_PENDING) 381 | { 382 | LeaveCriticalSection(ref ReceiveMutex); 383 | return -1; 384 | } 385 | 386 | uint waitStatus = WaitForSingleObject(ReceiveEvent, (uint)timeout); 387 | if (waitStatus == WAIT_TIMEOUT) 388 | { 389 | CancelIo(device.Handle.DangerousGetHandle()); 390 | LeaveCriticalSection(ref ReceiveMutex); 391 | return 0; 392 | } 393 | if (waitStatus != WAIT_OBJECT_0) 394 | { 395 | LeaveCriticalSection(ref ReceiveMutex); 396 | return -1; 397 | } 398 | } 399 | 400 | uint numberOfBytesReceived; 401 | if (!GetOverlappedResult(device.Handle.DangerousGetHandle(), ref overlapped, out numberOfBytesReceived, false)) 402 | { 403 | LeaveCriticalSection(ref ReceiveMutex); 404 | return -1; 405 | } 406 | 407 | LeaveCriticalSection(ref ReceiveMutex); 408 | 409 | if (numberOfBytesReceived <= 0) 410 | { 411 | return -1; 412 | } 413 | 414 | numberOfBytesReceived--; 415 | 416 | if (numberOfBytesReceived > len) 417 | { 418 | numberOfBytesReceived = (uint)len; 419 | } 420 | 421 | Array.Copy(tempBuffer, 1, buf, 0, numberOfBytesReceived); 422 | return (int)numberOfBytesReceived; 423 | } 424 | 425 | // Send - sends a packet 426 | // 427 | // Inputs: 428 | // num = device to transmit to (zero based) 429 | // buf = buffer containing packet to send 430 | // len = number of bytes to transmit 431 | // timeout = time to wait, in milliseconds 432 | // Output: 433 | // number of bytes sent, or -1 on error 434 | // 435 | public int Send(int num, byte[] buf, int len, int timeout) 436 | { 437 | byte[] tempBuffer = new byte[516]; 438 | 439 | if (tempBuffer.Length < len + 1) 440 | { 441 | return -1; 442 | } 443 | 444 | HIDDevice device = GetHIDDevice(num); 445 | if (device == null || !device.IsOpen) 446 | { 447 | return -1; 448 | } 449 | EnterCriticalSection(ref SendMutex); 450 | ResetEvent(SendEvent); 451 | 452 | NativeOverlapped overlapped = new NativeOverlapped(); 453 | overlapped.EventHandle = SendEvent; 454 | 455 | tempBuffer[0] = 0; 456 | Array.Copy(buf, 0, tempBuffer, 1, len); 457 | 458 | if (!WriteFile(device.Handle, tempBuffer, (uint)len + 1, IntPtr.Zero, ref overlapped)) 459 | { 460 | if (Marshal.GetLastWin32Error() != ERROR_IO_PENDING) 461 | { 462 | LeaveCriticalSection(ref SendMutex); 463 | return -1; 464 | } 465 | 466 | uint waitStatus = WaitForSingleObject(ReceiveEvent, (uint)timeout); 467 | if (waitStatus == WAIT_TIMEOUT) 468 | { 469 | CancelIo(device.Handle.DangerousGetHandle()); 470 | LeaveCriticalSection(ref SendMutex); 471 | return 0; 472 | } 473 | if (waitStatus != WAIT_OBJECT_0) 474 | { 475 | LeaveCriticalSection(ref SendMutex); 476 | return -1; 477 | } 478 | } 479 | 480 | uint numberOfBytesSend; 481 | if (!GetOverlappedResult(device.Handle.DangerousGetHandle(), ref overlapped, out numberOfBytesSend, false)) 482 | { 483 | LeaveCriticalSection(ref SendMutex); 484 | return -1; 485 | } 486 | 487 | LeaveCriticalSection(ref SendMutex); 488 | 489 | if (numberOfBytesSend <= 0) 490 | { 491 | return -1; 492 | } 493 | 494 | return (int)numberOfBytesSend - 1; 495 | } 496 | 497 | private void AddHIDDevice(HIDDevice device) 498 | { 499 | if (FirstHIDDevice == null || LastHIDDevice == null) 500 | { 501 | FirstHIDDevice = device; 502 | LastHIDDevice = device; 503 | 504 | device.NextHIDDevice = null; 505 | device.PreviousHIDDevice = null; 506 | 507 | return; 508 | } 509 | 510 | LastHIDDevice.NextHIDDevice = device; 511 | device.PreviousHIDDevice = LastHIDDevice; 512 | device.NextHIDDevice = null; 513 | LastHIDDevice = device; 514 | } 515 | 516 | private HIDDevice GetHIDDevice(int num) 517 | { 518 | HIDDevice p = FirstHIDDevice; 519 | while (p != null && num > 0) 520 | { 521 | p = p.NextHIDDevice; 522 | num--; 523 | } 524 | return p; 525 | } 526 | 527 | private void FreeAllHIDDevices() 528 | { 529 | HIDDevice p = FirstHIDDevice; 530 | HIDDevice q = null; 531 | 532 | while (p != null) 533 | { 534 | q = p; 535 | CloseHIDDevice(p); 536 | p = p.NextHIDDevice; 537 | q = null; 538 | } 539 | 540 | FirstHIDDevice = null; 541 | LastHIDDevice = null; 542 | } 543 | 544 | private void CloseHIDDevice(HIDDevice device) 545 | { 546 | if (device.IsOpen) 547 | { 548 | device.Handle.SetHandleAsInvalid(); 549 | device.Handle.Dispose(); 550 | device.Handle = null; 551 | } 552 | } 553 | } 554 | } 555 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### MU3Input `MU3Input.sln` 2 | #### IO library to use with segatools 3 | Usage: 4 | - Copy `MU3Input.dll` into game folder 5 | - Open segatools.ini and add following lines: 6 | ```ini 7 | [mu3io] 8 | path=MU3Input.dll 9 | 10 | [aimeio] 11 | path=MU3Input.dll 12 | ``` 13 | 14 | You can use Jetbrains Rider or Visual Studio to compile. 15 | 16 | Note: 17 | - My lever is a non-linear potentiometer, so it has correction code in `Lever` property of `HidIO.cs`, You may want to change it or remove it. 18 | 19 | ### mu3controller `mu3controller\ ` 20 | #### Arduino Leonardo firmware to use with above IO library. 21 | I'm using CLion to develop this, for CLion you will need to install platform io support plugin and run 22 | ``` 23 | pio -f -c clion init --ide clion 24 | ``` 25 | Note: 26 | - You can change pin settings in `src\components\ongeki_hardware.cpp` -------------------------------------------------------------------------------- /SegaToolsPatch/0001-Add-led-code.patch: -------------------------------------------------------------------------------- 1 | From 786c9ca98942dd9f88ba10036d1579d81fabcd7a Mon Sep 17 00:00:00 2001 2 | From: GEEKiDoS 3 | Date: Fri, 1 Oct 2021 14:57:41 +0800 4 | Subject: [PATCH] Add led code 5 | 6 | --- 7 | board/io4.c | 2 +- 8 | board/io4.h | 1 + 9 | mu3hook/io4.c | 13 +++++++++++++ 10 | mu3hook/mu3-dll.c | 3 +++ 11 | mu3hook/mu3-dll.h | 1 + 12 | mu3hook/mu3hook.def | 1 + 13 | mu3io/mu3io.c | 4 ++++ 14 | mu3io/mu3io.h | 2 ++ 15 | 8 files changed, 26 insertions(+), 1 deletion(-) 16 | 17 | diff --git a/board/io4.c b/board/io4.c 18 | index efad62f..9cdb054 100644 19 | --- a/board/io4.c 20 | +++ b/board/io4.c 21 | @@ -223,7 +223,7 @@ static HRESULT io4_handle_write(struct irp *irp) 22 | 23 | case IO4_CMD_SET_GENERAL_OUTPUT: 24 | dprintf("USB I/O: GPIO Out\n"); 25 | - 26 | + io4_ops->gpio_out(out.payload); 27 | return S_OK; 28 | 29 | case IO4_CMD_SET_PWM_OUTPUT: 30 | diff --git a/board/io4.h b/board/io4.h 31 | index 1a6cc05..87cd154 100644 32 | --- a/board/io4.h 33 | +++ b/board/io4.h 34 | @@ -24,6 +24,7 @@ struct io4_state { 35 | 36 | struct io4_ops { 37 | HRESULT (*poll)(void *ctx, struct io4_state *state); 38 | + HRESULT (*gpio_out)(uint8_t *payload); 39 | }; 40 | 41 | HRESULT io4_hook_init( 42 | diff --git a/mu3hook/io4.c b/mu3hook/io4.c 43 | index 7edcb0c..d7df696 100644 44 | --- a/mu3hook/io4.c 45 | +++ b/mu3hook/io4.c 46 | @@ -11,9 +11,11 @@ 47 | #include "util/dprintf.h" 48 | 49 | static HRESULT mu3_io4_poll(void *ctx, struct io4_state *state); 50 | +static HRESULT mu3_io4_gpio_out(uint8_t *payload); 51 | 52 | static const struct io4_ops mu3_io4_ops = { 53 | .poll = mu3_io4_poll, 54 | + .gpio_out = mu3_io4_gpio_out, 55 | }; 56 | 57 | HRESULT mu3_io4_hook_init(const struct io4_config *cfg) 58 | @@ -118,3 +120,14 @@ static HRESULT mu3_io4_poll(void *ctx, struct io4_state *state) 59 | 60 | return S_OK; 61 | } 62 | + 63 | +static HRESULT mu3_io4_gpio_out(uint8_t *payload) 64 | +{ 65 | + if (mu3_dll.set_led) 66 | + { 67 | + uint32_t data = payload[0] << 16 | payload[1] << 8 | payload[2]; 68 | + mu3_dll.set_led(data); 69 | + } 70 | + 71 | + return S_OK; 72 | +} 73 | diff --git a/mu3hook/mu3-dll.c b/mu3hook/mu3-dll.c 74 | index 9e8e93e..6abf26c 100644 75 | --- a/mu3hook/mu3-dll.c 76 | +++ b/mu3hook/mu3-dll.c 77 | @@ -24,6 +24,9 @@ const struct dll_bind_sym mu3_dll_syms[] = { 78 | }, { 79 | .sym = "mu3_io_get_lever", 80 | .off = offsetof(struct mu3_dll, get_lever), 81 | + }, { 82 | + .sym = "mu3_io_set_led", 83 | + .off = offsetof(struct mu3_dll, set_led), 84 | } 85 | }; 86 | 87 | diff --git a/mu3hook/mu3-dll.h b/mu3hook/mu3-dll.h 88 | index 41f280f..550772c 100644 89 | --- a/mu3hook/mu3-dll.h 90 | +++ b/mu3hook/mu3-dll.h 91 | @@ -11,6 +11,7 @@ struct mu3_dll { 92 | void (*get_opbtns)(uint8_t *opbtn); 93 | void (*get_gamebtns)(uint8_t *left, uint8_t *right); 94 | void (*get_lever)(int16_t *pos); 95 | + void (*set_led)(uint32_t info); 96 | }; 97 | 98 | struct mu3_dll_config { 99 | diff --git a/mu3hook/mu3hook.def b/mu3hook/mu3hook.def 100 | index e7367fb..8b03862 100644 101 | --- a/mu3hook/mu3hook.def 102 | +++ b/mu3hook/mu3hook.def 103 | @@ -18,3 +18,4 @@ EXPORTS 104 | mu3_io_get_opbtns 105 | mu3_io_init 106 | mu3_io_poll 107 | + mu3_io_set_led 108 | diff --git a/mu3io/mu3io.c b/mu3io/mu3io.c 109 | index 0bbd37f..bcbc668 100644 110 | --- a/mu3io/mu3io.c 111 | +++ b/mu3io/mu3io.c 112 | @@ -146,3 +146,7 @@ void mu3_io_get_lever(int16_t *pos) 113 | *pos = mu3_lever_xpos; 114 | } 115 | } 116 | + 117 | +void mu3_io_set_led(uint32_t led) 118 | +{ 119 | +} 120 | diff --git a/mu3io/mu3io.h b/mu3io/mu3io.h 121 | index d46a475..e540a3d 100644 122 | --- a/mu3io/mu3io.h 123 | +++ b/mu3io/mu3io.h 124 | @@ -82,3 +82,5 @@ void mu3_io_get_gamebtns(uint8_t *left, uint8_t *right); 125 | Minimum API version: 0x0100 */ 126 | 127 | void mu3_io_get_lever(int16_t *pos); 128 | + 129 | +void mu3_io_set_led(uint32_t led); 130 | -- 131 | 2.30.1.windows.1 132 | 133 | -------------------------------------------------------------------------------- /Test/Test.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | x64 7 | 8 | 9 | Release 10 | x64 11 | 12 | 13 | 14 | 16.0 15 | Win32Proj 16 | {d1b6bb17-f0b0-43fe-aabe-1a31d7a9d8a3} 17 | Test 18 | 10.0 19 | 20 | 21 | 22 | Application 23 | true 24 | v142 25 | Unicode 26 | 27 | 28 | Application 29 | false 30 | v142 31 | true 32 | Unicode 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | true 47 | C:\Users\GEEKiDoS\source\repos\MU3Input\MU3Input\bin\x64\Debug\ 48 | 49 | 50 | false 51 | 52 | 53 | 54 | Level3 55 | true 56 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 57 | true 58 | 59 | 60 | Console 61 | true 62 | 63 | 64 | 65 | 66 | Level3 67 | true 68 | true 69 | true 70 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 71 | true 72 | 73 | 74 | Console 75 | true 76 | true 77 | true 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /Test/Test.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 源文件 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Test/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | extern "C" 5 | { 6 | uint16_t mu3_io_get_api_version(void); 7 | HRESULT mu3_io_init(void); 8 | HRESULT mu3_io_poll(void); 9 | void mu3_io_get_opbtns(uint8_t* opbtn); 10 | void mu3_io_get_gamebtns(uint8_t* left, uint8_t* right); 11 | void mu3_io_get_lever(int16_t* pos); 12 | } 13 | 14 | int main() 15 | { 16 | mu3_io_init(); 17 | 18 | uint8_t opbtn, leftbtn, rightbtn; 19 | //int16_t lever; 20 | 21 | while(true) 22 | { 23 | mu3_io_poll(); 24 | 25 | mu3_io_get_opbtns(&opbtn); 26 | mu3_io_get_gamebtns(&leftbtn, &rightbtn); 27 | 28 | printf("%d %d %d %d\n", opbtn, leftbtn, rightbtn); 29 | Sleep(16); 30 | } 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /mu3controller/.gitignore: -------------------------------------------------------------------------------- 1 | .pio 2 | CMakeLists.txt 3 | CMakeListsPrivate.txt 4 | cmake-build-*/ 5 | -------------------------------------------------------------------------------- /mu3controller/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /mu3controller/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /mu3controller/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /mu3controller/.idea/untitled1.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /mu3controller/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /mu3controller/include/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project header files. 3 | 4 | A header file is a file containing C declarations and macro definitions 5 | to be shared between several project source files. You request the use of a 6 | header file in your project source file (C, C++, etc) located in `src` folder 7 | by including it, with the C preprocessing directive `#include'. 8 | 9 | ```src/main.c 10 | 11 | #include "header.h" 12 | 13 | int main (void) 14 | { 15 | ... 16 | } 17 | ``` 18 | 19 | Including a header file produces the same results as copying the header file 20 | into each source file that needs it. Such copying would be time-consuming 21 | and error-prone. With a header file, the related declarations appear 22 | in only one place. If they need to be changed, they can be changed in one 23 | place, and programs that include the header file will automatically use the 24 | new version when next recompiled. The header file eliminates the labor of 25 | finding and changing all the copies as well as the risk that a failure to 26 | find one copy will result in inconsistencies within a program. 27 | 28 | In C, the usual convention is to give header files names that end with `.h'. 29 | It is most portable to use only letters, digits, dashes, and underscores in 30 | header file names, and at most one dot. 31 | 32 | Read more about using header files in official GCC documentation: 33 | 34 | * Include Syntax 35 | * Include Operation 36 | * Once-Only Headers 37 | * Computed Includes 38 | 39 | https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html 40 | -------------------------------------------------------------------------------- /mu3controller/lib/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for project specific (private) libraries. 3 | PlatformIO will compile them to static libraries and link into executable file. 4 | 5 | The source code of each library should be placed in a an own separate directory 6 | ("lib/your_library_name/[here are source files]"). 7 | 8 | For example, see a structure of the following two libraries `Foo` and `Bar`: 9 | 10 | |--lib 11 | | | 12 | | |--Bar 13 | | | |--docs 14 | | | |--examples 15 | | | |--src 16 | | | |- Bar.c 17 | | | |- Bar.h 18 | | | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html 19 | | | 20 | | |--Foo 21 | | | |- Foo.c 22 | | | |- Foo.h 23 | | | 24 | | |- README --> THIS FILE 25 | | 26 | |- platformio.ini 27 | |--src 28 | |- main.c 29 | 30 | and a contents of `src/main.c`: 31 | ``` 32 | #include 33 | #include 34 | 35 | int main (void) 36 | { 37 | ... 38 | } 39 | 40 | ``` 41 | 42 | PlatformIO Library Dependency Finder will find automatically dependent 43 | libraries scanning project source files. 44 | 45 | More information about PlatformIO Library Dependency Finder 46 | - https://docs.platformio.org/page/librarymanager/ldf.html 47 | -------------------------------------------------------------------------------- /mu3controller/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [env:leonardo] 12 | platform = atmelavr 13 | board = leonardo 14 | framework = arduino 15 | upload_port = COM12 16 | lib_deps = 17 | fastled/FastLED@^3.4.0 18 | arduino-libraries/Keyboard@^1.0.2 19 | nicohood/HID-Project@^2.8.2 20 | -------------------------------------------------------------------------------- /mu3controller/src/components/manager.cpp: -------------------------------------------------------------------------------- 1 | #include "stdinclude.hpp" 2 | 3 | namespace component { 4 | namespace manager { 5 | void start() { 6 | raw_hid::start(); 7 | ongeki_hardware::start(); 8 | } 9 | 10 | void update() { 11 | raw_hid::update(); 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /mu3controller/src/components/manager.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace component { 4 | namespace manager { 5 | void start(); 6 | void update(); 7 | } 8 | } 9 | 10 | #include "raw_hid.hpp" 11 | #include "ongeki_hardware.hpp" -------------------------------------------------------------------------------- /mu3controller/src/components/ongeki_hardware.cpp: -------------------------------------------------------------------------------- 1 | #include "stdinclude.hpp" 2 | #include 3 | #include 4 | 5 | namespace component { 6 | namespace ongeki_hardware { 7 | const int LEVER = PIN_A0; 8 | const int LED_PIN = 12; 9 | const uint8_t PIN_MAP[10] = { 10 | // L: A B C SIDE MENU 11 | 9, 8, 7, 10, 11, 12 | // R: A B C SIDE MENU 13 | 4, 3, 2, 5, 6, 14 | }; 15 | 16 | CRGB lightColors[6]; 17 | 18 | void start() { 19 | // setup pin modes for button 20 | for (unsigned char i : PIN_MAP) { 21 | pinMode(i, INPUT_PULLUP); 22 | } 23 | 24 | // setup led_t 25 | FastLED.addLeds(lightColors, 6); 26 | } 27 | 28 | void read_io(raw_hid::output_data_t *data) { 29 | for(auto i = 0; i < 10; i++) { 30 | data->buttons[i] = digitalRead(PIN_MAP[i]) == LOW; 31 | } 32 | 33 | data->lever = analogRead(LEVER); 34 | 35 | if(data->buttons[4] && data->buttons[9]) { 36 | EEPROM.get(0, data->aimi_id); 37 | data->scan = true; 38 | } else { 39 | memset(&data->aimi_id, 0, 10); 40 | data->scan = false; 41 | } 42 | } 43 | 44 | void set_led(raw_hid::led_t &data) { 45 | FastLED.setBrightness(data.ledBrightness); 46 | 47 | for(int i = 0; i < 3; i++) { 48 | memcpy(&lightColors[i], &data.ledColors[i], 3); 49 | memcpy(&lightColors[i + 3], &data.ledColors[i + 5], 3); 50 | } 51 | 52 | FastLED.show(); 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /mu3controller/src/components/ongeki_hardware.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace component { 4 | namespace ongeki_hardware { 5 | void start(); 6 | void read_io(raw_hid::output_data_t *data); 7 | void set_led(raw_hid::led_t &data); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /mu3controller/src/components/raw_hid.cpp: -------------------------------------------------------------------------------- 1 | #include "stdinclude.hpp" 2 | #include 3 | 4 | namespace component { 5 | namespace raw_hid { 6 | uint8_t rawBuffer[255]; 7 | uint8_t outBuffer[64]; 8 | uint8_t inBuffer[64]; 9 | 10 | output_data_t *pOutputData = reinterpret_cast(outBuffer); 11 | input_data_t *pInputData = reinterpret_cast(inBuffer); 12 | 13 | void start() { 14 | RawHID.begin(rawBuffer, sizeof(rawBuffer)); 15 | } 16 | 17 | void update() { 18 | ongeki_hardware::read_io(pOutputData); 19 | RawHID.write(outBuffer, 64); 20 | 21 | if (RawHID.available()) { 22 | RawHID.readBytes(inBuffer, 64); 23 | 24 | switch (pInputData->type) { 25 | case 0: { 26 | ongeki_hardware::set_led(pInputData->led); 27 | break; 28 | } 29 | case 1: { 30 | EEPROM.put(0, pInputData->option.aimiId); 31 | break; 32 | } 33 | } 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /mu3controller/src/components/raw_hid.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace component { 4 | namespace raw_hid { 5 | 6 | #pragma pack(push, 1) 7 | struct aimi_id_t { 8 | uint8_t buffer[10]; 9 | }; 10 | 11 | struct output_data_t { 12 | union { 13 | char buffer[64]; 14 | struct { 15 | uint8_t buttons[10]; 16 | uint16_t lever; 17 | uint8_t scan; 18 | aimi_id_t aimi_id; 19 | }; 20 | }; 21 | }; 22 | 23 | typedef uint8_t color_t[3]; 24 | 25 | struct led_t { 26 | uint8_t ledBrightness; 27 | color_t ledColors[10]; 28 | }; 29 | 30 | struct option_t { 31 | aimi_id_t aimiId; 32 | }; 33 | 34 | struct input_data_t { 35 | uint8_t type; 36 | union { 37 | char buffer[63]; 38 | led_t led; 39 | option_t option; 40 | }; 41 | }; 42 | #pragma pack(pop) 43 | 44 | void start(); 45 | void update(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /mu3controller/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "stdinclude.hpp" 2 | 3 | void setup() { 4 | component::manager::start(); 5 | } 6 | 7 | void loop() { 8 | component::manager::update(); 9 | } 10 | -------------------------------------------------------------------------------- /mu3controller/src/stdinclude.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include "components/manager.hpp" 8 | -------------------------------------------------------------------------------- /mu3controller/test/README: -------------------------------------------------------------------------------- 1 | 2 | This directory is intended for PlatformIO Unit Testing and project tests. 3 | 4 | Unit Testing is a software testing method by which individual units of 5 | source code, sets of one or more MCU program modules together with associated 6 | control data, usage procedures, and operating procedures, are tested to 7 | determine whether they are fit for use. Unit testing finds problems early 8 | in the development cycle. 9 | 10 | More information about PlatformIO Unit Testing: 11 | - https://docs.platformio.org/page/plus/unit-testing.html 12 | --------------------------------------------------------------------------------