├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── docs ├── phone.jpg └── vjoy.png ├── sdvx_client ├── AndroidManifest.xml ├── Button.pde ├── Slider.pde ├── code │ └── sketch.properties ├── data │ └── Teko-SemiBold.ttf └── sdvx_client.pde └── sdvx_server ├── sdvx_server.sln └── sdvx_server ├── App.config ├── Program.cs ├── Properties └── AssemblyInfo.cs ├── SharpOSC.dll ├── VJoyInterface └── vJoyInterfaceWrap.dll ├── sdvx_server.csproj └── vJoyInterface.dll /.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 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | [Ll]og/ 24 | 25 | # Visual Studio 2015 cache/options directory 26 | .vs/ 27 | # Uncomment if you have tasks that create the project's static files in wwwroot 28 | #wwwroot/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | # DNX 44 | project.lock.json 45 | project.fragment.lock.json 46 | artifacts/ 47 | 48 | *_i.c 49 | *_p.c 50 | *_i.h 51 | *.ilk 52 | *.meta 53 | *.obj 54 | *.pch 55 | *.pdb 56 | *.pgc 57 | *.pgd 58 | *.rsp 59 | *.sbr 60 | *.tlb 61 | *.tli 62 | *.tlh 63 | *.tmp 64 | *.tmp_proj 65 | *.log 66 | *.vspscc 67 | *.vssscc 68 | .builds 69 | *.pidb 70 | *.svclog 71 | *.scc 72 | 73 | # Chutzpah Test files 74 | _Chutzpah* 75 | 76 | # Visual C++ cache files 77 | ipch/ 78 | *.aps 79 | *.ncb 80 | *.opendb 81 | *.opensdf 82 | *.sdf 83 | *.cachefile 84 | *.VC.db 85 | *.VC.VC.opendb 86 | 87 | # Visual Studio profiler 88 | *.psess 89 | *.vsp 90 | *.vspx 91 | *.sap 92 | 93 | # TFS 2012 Local Workspace 94 | $tf/ 95 | 96 | # Guidance Automation Toolkit 97 | *.gpState 98 | 99 | # ReSharper is a .NET coding add-in 100 | _ReSharper*/ 101 | *.[Rr]e[Ss]harper 102 | *.DotSettings.user 103 | 104 | # JustCode is a .NET coding add-in 105 | .JustCode 106 | 107 | # TeamCity is a build add-in 108 | _TeamCity* 109 | 110 | # DotCover is a Code Coverage Tool 111 | *.dotCover 112 | 113 | # NCrunch 114 | _NCrunch_* 115 | .*crunch*.local.xml 116 | nCrunchTemp_* 117 | 118 | # MightyMoose 119 | *.mm.* 120 | AutoTest.Net/ 121 | 122 | # Web workbench (sass) 123 | .sass-cache/ 124 | 125 | # Installshield output folder 126 | [Ee]xpress/ 127 | 128 | # DocProject is a documentation generator add-in 129 | DocProject/buildhelp/ 130 | DocProject/Help/*.HxT 131 | DocProject/Help/*.HxC 132 | DocProject/Help/*.hhc 133 | DocProject/Help/*.hhk 134 | DocProject/Help/*.hhp 135 | DocProject/Help/Html2 136 | DocProject/Help/html 137 | 138 | # Click-Once directory 139 | publish/ 140 | 141 | # Publish Web Output 142 | *.[Pp]ublish.xml 143 | *.azurePubxml 144 | # TODO: Comment the next line if you want to checkin your web deploy settings 145 | # but database connection strings (with potential passwords) will be unencrypted 146 | #*.pubxml 147 | *.publishproj 148 | 149 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 150 | # checkin your Azure Web App publish settings, but sensitive information contained 151 | # in these scripts will be unencrypted 152 | PublishScripts/ 153 | 154 | # NuGet Packages 155 | *.nupkg 156 | # The packages folder can be ignored because of Package Restore 157 | **/packages/* 158 | # except build/, which is used as an MSBuild target. 159 | !**/packages/build/ 160 | # Uncomment if necessary however generally it will be regenerated when needed 161 | #!**/packages/repositories.config 162 | # NuGet v3's project.json files produces more ignoreable files 163 | *.nuget.props 164 | *.nuget.targets 165 | 166 | # Microsoft Azure Build Output 167 | csx/ 168 | *.build.csdef 169 | 170 | # Microsoft Azure Emulator 171 | ecf/ 172 | rcf/ 173 | 174 | # Windows Store app package directories and files 175 | AppPackages/ 176 | BundleArtifacts/ 177 | Package.StoreAssociation.xml 178 | _pkginfo.txt 179 | 180 | # Visual Studio cache files 181 | # files ending in .cache can be ignored 182 | *.[Cc]ache 183 | # but keep track of directories ending in .cache 184 | !*.[Cc]ache/ 185 | 186 | # Others 187 | ClientBin/ 188 | ~$* 189 | *~ 190 | *.dbmdl 191 | *.dbproj.schemaview 192 | *.jfm 193 | *.pfx 194 | *.publishsettings 195 | node_modules/ 196 | orleans.codegen.cs 197 | 198 | # Since there are multiple workflows, uncomment next line to ignore bower_components 199 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 200 | #bower_components/ 201 | 202 | # RIA/Silverlight projects 203 | Generated_Code/ 204 | 205 | # Backup & report files from converting an old project file 206 | # to a newer Visual Studio version. Backup files are not needed, 207 | # because we have git ;-) 208 | _UpgradeReport_Files/ 209 | Backup*/ 210 | UpgradeLog*.XML 211 | UpgradeLog*.htm 212 | 213 | # SQL Server files 214 | *.mdf 215 | *.ldf 216 | 217 | # Business Intelligence projects 218 | *.rdl.data 219 | *.bim.layout 220 | *.bim_*.settings 221 | 222 | # Microsoft Fakes 223 | FakesAssemblies/ 224 | 225 | # GhostDoc plugin setting file 226 | *.GhostDoc.xml 227 | 228 | # Node.js Tools for Visual Studio 229 | .ntvs_analysis.dat 230 | 231 | # Visual Studio 6 build log 232 | *.plg 233 | 234 | # Visual Studio 6 workspace options file 235 | *.opt 236 | 237 | # Visual Studio LightSwitch build output 238 | **/*.HTMLClient/GeneratedArtifacts 239 | **/*.DesktopClient/GeneratedArtifacts 240 | **/*.DesktopClient/ModelManifest.xml 241 | **/*.Server/GeneratedArtifacts 242 | **/*.Server/ModelManifest.xml 243 | _Pvt_Extensions 244 | 245 | # Paket dependency manager 246 | .paket/paket.exe 247 | paket-files/ 248 | 249 | # FAKE - F# Make 250 | .fake/ 251 | 252 | # JetBrains Rider 253 | .idea/ 254 | *.sln.iml 255 | 256 | # CodeRush 257 | .cr/ 258 | 259 | # Python Tools for Visual Studio (PTVS) 260 | __pycache__/ 261 | *.pyc -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Daniel Sader 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sdvx-mobile-controller 2 | This repository contains an Android application that serves as a mobile controller for Sound Voltex-like games (like K-Shoot Mania). 3 | 4 | Games like these need special controllers to be played correctly, with things like analog knobs that can't be easily emulated with a mouse and keyboard. This project uses the flexibility of touch screens to simulate those controls on a mobile phone/tablet. 5 | 6 | ![Application running on a mobile phone](/docs/phone.jpg?raw=true "Optional Title") 7 | 8 | ## Building 9 | ### Client 10 | To build the Client, you'll need the [Processing Development Environment](https://processing.org/), as well as the Android SDK (Processing can automagically install it for you). Download the repository and open up the `sdvx_client.pde` file to load the project. 11 | 12 | Currently, the IP address of the server is hardcoded on the `sdvx_client/sdvx_client.pde` file. Change it to the IP address of your computer that will be running the game. Build the application and you're ready to go! 13 | 14 | ### Server 15 | 16 | To build the Server, you'll need [Visual Studio Community](https://visualstudio.microsoft.com/pt-br/vs/community/), with the Visual C# environment installed. Open up the `sdvx_server/sdvx_server.sln` file, and the project should load on Visual Studio. 17 | 18 | You may need to re-add the references to `SharpOSC.dll` and `vJoyInterfaceWrap.dll` to your project. To do that, right click the "References" item on the Solution Explorer, and click "Add Reference". 19 | 20 | After that, hit "Build" and the program should compile. Make sure your build configuration is set to `x64`, or else the program will fail to run. 21 | 22 | ## How to Use 23 | ### Client 24 | 25 | Open up the application on your mobile phone and you are ready to go. Make sure your phone is connected to the same network as your server, and that ports 12000 and 32000 (UDP) are open. 26 | 27 | ### Server 28 | 29 | To run the server, you'll need the [vJoy Virtual Joystick Drivers](http://vjoystick.sourceforge.net/). Those drivers are used to create a virtual device that will be controlled by your mobile phone. 30 | 31 | After installing vJoy, open up the "Configure vJoy" application and configure your first virtual joystick as follows: 32 | 33 | ![vJoy settings screen](/docs/vjoy.png?raw=true "Optional Title") 34 | 35 | Open the server application and, if everything is working, it will show the message `[OSC] Now listening to messages.`. Try pressing some buttons on the mobile phone to test if the connection is working properly. 36 | 37 | After that, configure your game to use the "vJoy - Virtual Joystick" controller as the main input device. The buttons are mapped as follows: 38 | 39 | | Button | vJoy input | 40 | |:------:|:----------:| 41 | | BTN-A | Button 1 | 42 | | BTN-B | Button 2 | 43 | | BTN-C | Button 3 | 44 | | BTN-D | Button 4 | 45 | | FX-L | Button 5 | 46 | | FX-R | Button 6 | 47 | | VOL-L | Slider 1 | 48 | | VOL-R | Slider 2 | 49 | | Start | Button 7 | 50 | 51 | ## Librares Used 52 | 53 | - [OscP5](http://www.sojamo.de/libraries/oscP5/) for sending the OSC messages on the Android app 54 | - [SharpOSC](https://github.com/ValdemarOrn/SharpOSC) for receiving the OSC messages on the Desktop app 55 | - [vJoy C# SDK](https://github.com/shauleiz/vJoy/tree/master/SDK/c%23) for simulating joystick inputs -------------------------------------------------------------------------------- /docs/phone.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saderuuu/sdvx-mobile-controller/91446e0f42ff5bd634afb9fd8dd6d4bd195e5341/docs/phone.jpg -------------------------------------------------------------------------------- /docs/vjoy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saderuuu/sdvx-mobile-controller/91446e0f42ff5bd634afb9fd8dd6d4bd195e5341/docs/vjoy.png -------------------------------------------------------------------------------- /sdvx_client/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /sdvx_client/Button.pde: -------------------------------------------------------------------------------- 1 | class Button 2 | { 3 | int x; 4 | int y; 5 | int w; 6 | int h; 7 | color mainColor; 8 | color textColor; 9 | color currentColor; 10 | String desc; 11 | 12 | boolean justPressed; 13 | boolean justReleased; 14 | 15 | boolean lastPressed; 16 | boolean currPressed; 17 | 18 | int padding = 20; 19 | 20 | public Button(int x, int y, int w, int h, color mainColor, String desc) 21 | { 22 | this.x = x; 23 | this.y = y; 24 | this.w = w; 25 | this.h = h; 26 | this.mainColor = mainColor; 27 | this.currentColor = mainColor; 28 | this.desc = desc; 29 | 30 | justPressed = false; 31 | justReleased = false; 32 | lastPressed = false; 33 | currPressed = false; 34 | } 35 | 36 | public boolean isInside(int x, int y) 37 | { 38 | if(x > this.x && x <= this.x + w && 39 | y > this.y && y <= this.y + h) 40 | return true; 41 | 42 | return false; 43 | } 44 | 45 | public void update() 46 | { 47 | lastPressed = currPressed; 48 | currPressed = false; 49 | 50 | justPressed = false; 51 | justReleased = false; 52 | 53 | currentColor = mainColor; 54 | textColor = color(255); 55 | 56 | for (int i = 0; i < touches.length; i++) { 57 | if(isInside((int)touches[i].x, (int)touches[i].y)) 58 | { 59 | currPressed = true; 60 | currentColor = color(255, 255, 255); 61 | textColor = color(0); 62 | break; 63 | } 64 | } 65 | 66 | if(lastPressed && !currPressed) 67 | justReleased = true; 68 | 69 | if(!lastPressed && currPressed) 70 | justPressed = true; 71 | } 72 | 73 | public boolean justPressed() 74 | { 75 | return justPressed; 76 | } 77 | 78 | public boolean justReleased() 79 | { 80 | return justReleased; 81 | } 82 | 83 | public void draw() 84 | { 85 | noStroke(); 86 | fill(currentColor); 87 | rect(x + padding, y + padding, w-(padding*2), h-(padding*2), 10); 88 | 89 | fill(textColor); 90 | text(desc, (x+padding+40), (y+padding+60)); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /sdvx_client/Slider.pde: -------------------------------------------------------------------------------- 1 | class Slider 2 | { 3 | int x; 4 | int y; 5 | int w; 6 | int h; 7 | color mainColor; 8 | color textColor; 9 | color currentColor; 10 | String desc; 11 | 12 | boolean justPressed; 13 | boolean justReleased; 14 | boolean isPressed; 15 | 16 | boolean lastPressed; 17 | boolean currPressed; 18 | 19 | int lastPressedPos; 20 | int currPressedPos; 21 | 22 | float currValue; 23 | float lastValue; 24 | float delta; 25 | 26 | int pressIndex; 27 | 28 | int padding = 20; 29 | 30 | public Slider(int x, int y, int w, int h, color mainColor, String desc) 31 | { 32 | this.x = x; 33 | this.y = y; 34 | this.w = w; 35 | this.h = h; 36 | this.mainColor = mainColor; 37 | this.currentColor = mainColor; 38 | this.desc = desc; 39 | 40 | justPressed = false; 41 | justReleased = false; 42 | lastPressed = false; 43 | currPressed = false; 44 | isPressed = false; 45 | 46 | lastPressedPos = -1; 47 | currPressedPos = -1; 48 | 49 | currValue = 0; 50 | lastValue = 0; 51 | 52 | pressIndex = -1; 53 | } 54 | 55 | public boolean isInside(int x, int y) 56 | { 57 | if(x > this.x && x <= this.x + w && 58 | y > this.y && y <= this.y + h) 59 | return true; 60 | 61 | return false; 62 | } 63 | 64 | public void update() 65 | { 66 | lastPressed = currPressed; 67 | currPressed = false; 68 | 69 | justPressed = false; 70 | justReleased = false; 71 | 72 | currentColor = mainColor; 73 | textColor = color(255); 74 | 75 | for (int i = 0; i < touches.length; i++) { 76 | if(isInside((int)touches[i].x, (int)touches[i].y)) 77 | { 78 | currPressed = true; 79 | currentColor = color(255, 255, 255); 80 | textColor = color(0); 81 | pressIndex = i; 82 | break; 83 | } 84 | } 85 | 86 | if(lastPressed && !currPressed) 87 | { 88 | justReleased = true; 89 | isPressed = false; 90 | pressIndex = -1; 91 | 92 | lastValue = 0; 93 | currValue = 0; 94 | } 95 | 96 | if(!lastPressed && currPressed) 97 | { 98 | justPressed = true; 99 | isPressed = true; 100 | 101 | currValue = (float)(currPressedPos - x) / (float)w; 102 | lastValue = currValue; 103 | } 104 | 105 | if(isPressed) 106 | { 107 | lastPressedPos = currPressedPos; 108 | currPressedPos = (int)touches[pressIndex].x; 109 | 110 | lastValue = currValue; 111 | currValue = (float)(currPressedPos - x) / (float)w; 112 | delta = lastValue - currValue; 113 | } 114 | 115 | } 116 | 117 | public float getValue() 118 | { 119 | return currValue *100; 120 | } 121 | 122 | public boolean justPressed() 123 | { 124 | return justPressed; 125 | } 126 | 127 | public boolean justReleased() 128 | { 129 | return justReleased; 130 | } 131 | 132 | public boolean isPressed() 133 | { 134 | return justReleased; 135 | } 136 | 137 | public void draw() 138 | { 139 | fill(currentColor); 140 | rect(x + padding, y + padding, w-(padding*2), h-(padding*2), 10); 141 | 142 | fill(textColor); 143 | text(desc, (x+padding+40), (y+padding+60)); 144 | 145 | if(isPressed) 146 | { 147 | fill(127); 148 | rect(currPressedPos-5, y+padding, 10, h-(padding*2)); 149 | } 150 | fill(0); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /sdvx_client/code/sketch.properties: -------------------------------------------------------------------------------- 1 | mode=Android 2 | component=app 3 | mode.id=processing.mode.android.AndroidMode 4 | -------------------------------------------------------------------------------- /sdvx_client/data/Teko-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saderuuu/sdvx-mobile-controller/91446e0f42ff5bd634afb9fd8dd6d4bd195e5341/sdvx_client/data/Teko-SemiBold.ttf -------------------------------------------------------------------------------- /sdvx_client/sdvx_client.pde: -------------------------------------------------------------------------------- 1 | import netP5.*; 2 | import oscP5.*; 3 | 4 | // Open Sound Control libraries 5 | OscP5 oscP5; 6 | NetAddress serverAddress; 7 | 8 | // Button objects 9 | Button btn_a, btn_b, btn_c, btn_d; 10 | Button fx_l, fx_r; 11 | Button start; 12 | 13 | Slider vol_l, vol_r; 14 | 15 | // Button colors 16 | color mainBtnColor = color(45, 219, 184); 17 | color fxBtnColor = color(201, 20, 51); 18 | color volLColor = color(107, 241, 253); 19 | color volRColor = color(255, 118, 255); 20 | 21 | // Application fonts 22 | PFont mainFont; 23 | 24 | float lastRPos; 25 | float currRPos; 26 | 27 | float lastLPos; 28 | float currLPos; 29 | 30 | void setup() 31 | { 32 | // oscP5 setup 33 | // Change the IP address below to the IP of your computer 34 | oscP5 = new OscP5(this, 12000); 35 | serverAddress = new NetAddress("192.168.15.10", 32000); 36 | 37 | // Screen setup 38 | fullScreen(); 39 | orientation(LANDSCAPE); 40 | 41 | 42 | // Layout sizes 43 | int mainBtnSize = width/4; 44 | int margins = (height - mainBtnSize)/2; 45 | 46 | // Font 47 | mainFont = createFont("Teko-SemiBold.ttf", 36, true); 48 | 49 | // Main buttons 50 | btn_a = new Button(0, margins, mainBtnSize, mainBtnSize, mainBtnColor, "BTN-A"); 51 | btn_b = new Button(mainBtnSize*1, margins, mainBtnSize, mainBtnSize, mainBtnColor, "BTN-B"); 52 | btn_c = new Button(mainBtnSize*2, margins, mainBtnSize, mainBtnSize, mainBtnColor, "BTN-C"); 53 | btn_d = new Button(mainBtnSize*3, margins, mainBtnSize, mainBtnSize, mainBtnColor, "BTN-D"); 54 | 55 | // FX buttons 56 | fx_l = new Button(0, margins + mainBtnSize, mainBtnSize*2, margins, fxBtnColor, "FX-L"); 57 | fx_r = new Button(mainBtnSize*2, margins + mainBtnSize, mainBtnSize*2, margins, fxBtnColor, "FX-R"); 58 | 59 | // Start button 60 | start = new Button((width/2)-(margins/4), 0, margins/2, margins, color(0, 0, 255), "ST"); 61 | 62 | // Sliders 63 | vol_l = new Slider(0, 0, (mainBtnSize*2)-(margins/4), margins, volLColor, "VOL-L"); 64 | vol_r = new Slider((width/2)+(margins/4), 0, mainBtnSize*2-(margins/4), margins, volRColor, "VOL-R"); 65 | 66 | lastRPos = 0; 67 | currRPos = 0; 68 | 69 | lastLPos = 0; 70 | currLPos = 0; 71 | } 72 | 73 | void draw() 74 | { 75 | background(15, 28, 36); 76 | textFont(mainFont); 77 | 78 | // Update button states 79 | // Main buttons 80 | btn_a.update(); 81 | btn_b.update(); 82 | btn_c.update(); 83 | btn_d.update(); 84 | 85 | // FX Buttons 86 | fx_l.update(); 87 | fx_r.update(); 88 | 89 | // Volume Buttons 90 | vol_l.update(); 91 | vol_r.update(); 92 | 93 | start.update(); 94 | 95 | // Send OSC messages 96 | sendOscMessages(); 97 | 98 | // Main buttons 99 | btn_a.draw(); 100 | btn_b.draw(); 101 | btn_c.draw(); 102 | btn_d.draw(); 103 | 104 | // FX Buttons 105 | fx_l.draw(); 106 | fx_r.draw(); 107 | 108 | // Volume Buttons 109 | vol_l.draw(); 110 | vol_r.draw(); 111 | 112 | // Draw everything 113 | start.draw(); 114 | } 115 | 116 | void sendOscMessages() 117 | { 118 | // Dispatch OSC messages for each of the buttons pressed. 119 | if(btn_a.justPressed()) 120 | { 121 | OscMessage msg = new OscMessage("/btn-a"); 122 | msg.add("P"); 123 | oscP5.send(msg, serverAddress); 124 | } 125 | 126 | if(btn_a.justReleased()) 127 | { 128 | OscMessage msg = new OscMessage("/btn-a"); 129 | msg.add("R"); 130 | oscP5.send(msg, serverAddress); 131 | } 132 | 133 | if(btn_b.justPressed()) 134 | { 135 | OscMessage msg = new OscMessage("/btn-b"); 136 | msg.add("P"); 137 | oscP5.send(msg, serverAddress); 138 | } 139 | 140 | if(btn_b.justReleased()) 141 | { 142 | OscMessage msg = new OscMessage("/btn-b"); 143 | msg.add("R"); 144 | oscP5.send(msg, serverAddress); 145 | } 146 | 147 | if(btn_c.justPressed()) 148 | { 149 | OscMessage msg = new OscMessage("/btn-c"); 150 | msg.add("P"); 151 | oscP5.send(msg, serverAddress); 152 | } 153 | 154 | if(btn_c.justReleased()) 155 | { 156 | OscMessage msg = new OscMessage("/btn-c"); 157 | msg.add("R"); 158 | oscP5.send(msg, serverAddress); 159 | } 160 | 161 | if(btn_d.justPressed()) 162 | { 163 | OscMessage msg = new OscMessage("/btn-d"); 164 | msg.add("P"); 165 | oscP5.send(msg, serverAddress); 166 | } 167 | 168 | if(btn_d.justReleased()) 169 | { 170 | OscMessage msg = new OscMessage("/btn-d"); 171 | msg.add("R"); 172 | oscP5.send(msg, serverAddress); 173 | } 174 | 175 | if(fx_l.justPressed()) 176 | { 177 | OscMessage msg = new OscMessage("/fx-l"); 178 | msg.add("P"); 179 | oscP5.send(msg, serverAddress); 180 | } 181 | 182 | if(fx_l.justReleased()) 183 | { 184 | OscMessage msg = new OscMessage("/fx-l"); 185 | msg.add("R"); 186 | oscP5.send(msg, serverAddress); 187 | } 188 | 189 | if(fx_r.justPressed()) 190 | { 191 | OscMessage msg = new OscMessage("/fx-r"); 192 | msg.add("P"); 193 | oscP5.send(msg, serverAddress); 194 | } 195 | 196 | if(fx_r.justReleased()) 197 | { 198 | OscMessage msg = new OscMessage("/fx-r"); 199 | msg.add("R"); 200 | oscP5.send(msg, serverAddress); 201 | } 202 | 203 | if(start.justPressed()) 204 | { 205 | OscMessage msg = new OscMessage("/start"); 206 | msg.add("P"); 207 | oscP5.send(msg, serverAddress); 208 | } 209 | 210 | if(start.justReleased()) 211 | { 212 | OscMessage msg = new OscMessage("/start"); 213 | msg.add("R"); 214 | oscP5.send(msg, serverAddress); 215 | } 216 | 217 | 218 | // In sliders, we send the current slider position as a float 219 | if(vol_l.getValue() != 0) 220 | { 221 | lastLPos = currLPos; 222 | currLPos = vol_l.getValue(); 223 | 224 | if(currLPos != lastLPos) 225 | { 226 | OscMessage msg = new OscMessage("/vol-l"); 227 | msg.add((int)currLPos); 228 | oscP5.send(msg, serverAddress); 229 | } 230 | } else { 231 | lastLPos = 0; 232 | currLPos = 0; 233 | } 234 | 235 | if(vol_r.getValue() != 0) 236 | { 237 | lastRPos = currRPos; 238 | currRPos = vol_r.getValue(); 239 | 240 | if(currRPos != lastRPos) 241 | { 242 | OscMessage msg = new OscMessage("/vol-r"); 243 | msg.add((int)currRPos); 244 | oscP5.send(msg, serverAddress); 245 | } 246 | } else { 247 | lastRPos = 0; 248 | currRPos = 0; 249 | } 250 | } 251 | -------------------------------------------------------------------------------- /sdvx_server/sdvx_server.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28010.2050 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sdvx_server", "sdvx_server\sdvx_server.csproj", "{D8778918-C143-4282-94A7-864C8FF4B283}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Debug|x64 = Debug|x64 12 | Release|Any CPU = Release|Any CPU 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {D8778918-C143-4282-94A7-864C8FF4B283}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {D8778918-C143-4282-94A7-864C8FF4B283}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {D8778918-C143-4282-94A7-864C8FF4B283}.Debug|x64.ActiveCfg = Debug|x64 19 | {D8778918-C143-4282-94A7-864C8FF4B283}.Debug|x64.Build.0 = Debug|x64 20 | {D8778918-C143-4282-94A7-864C8FF4B283}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {D8778918-C143-4282-94A7-864C8FF4B283}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {D8778918-C143-4282-94A7-864C8FF4B283}.Release|x64.ActiveCfg = Release|x64 23 | {D8778918-C143-4282-94A7-864C8FF4B283}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {7F8D0597-8FE3-4BEB-A50D-916E8C695F35} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /sdvx_server/sdvx_server/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /sdvx_server/sdvx_server/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using SharpOSC; 7 | using vJoyInterfaceWrap; 8 | 9 | namespace sdvx_server 10 | { 11 | class Program 12 | { 13 | static public vJoy joystick; 14 | static public vJoy.JoystickState iReport; 15 | static public uint id = 1; 16 | 17 | static float lastL = 0.0f; 18 | static float currL = 0.0f; 19 | 20 | static float lastR = 0.0f; 21 | static float currR = 0.0f; 22 | 23 | static float L; 24 | static float R; 25 | 26 | static void Main(string[] args) 27 | { 28 | // VIRTUAL GAMEPAD INITIALIZATION 29 | Console.WriteLine("[PAD] Initializing gamepad"); 30 | joystick = new vJoy(); 31 | iReport = new vJoy.JoystickState(); 32 | 33 | if (!joystick.vJoyEnabled()) 34 | { 35 | Console.WriteLine("[PAD] vJoy driver not enabled!"); 36 | return; 37 | } 38 | else 39 | { 40 | Console.WriteLine("[PAD] Vendor: {0}\n[PAD] Product :{1}\n[PAD] Version Number:{2}", joystick.GetvJoyManufacturerString(), joystick.GetvJoyProductString(), joystick.GetvJoySerialNumberString()); 41 | } 42 | 43 | VjdStat status = joystick.GetVJDStatus(id); 44 | 45 | int nButtons = joystick.GetVJDButtonNumber(id); 46 | 47 | if (nButtons < 7) 48 | { 49 | Console.WriteLine("[PAD] This app needs at least 7 buttons configured in vJoy to work."); 50 | return; 51 | } 52 | else 53 | { 54 | Console.WriteLine("[PAD] Available buttons: " + nButtons); 55 | } 56 | 57 | bool sliderR = joystick.GetVJDAxisExist(id, HID_USAGES.HID_USAGE_SL0); 58 | bool sliderL = joystick.GetVJDAxisExist(id, HID_USAGES.HID_USAGE_SL1); 59 | 60 | if(sliderR && sliderL) 61 | { 62 | Console.WriteLine("[PAD] Sliders enabled"); 63 | } 64 | else 65 | { 66 | Console.WriteLine("[PAD] This app needs at least 2 sliders configured in vJoy to work."); 67 | return; 68 | } 69 | 70 | if ((status == VjdStat.VJD_STAT_OWN) || ((status == VjdStat.VJD_STAT_FREE) && (!joystick.AcquireVJD(id)))) 71 | { 72 | Console.WriteLine("[PAD] Failed to acquire vJoy device number {0}.", id); 73 | return; 74 | } 75 | else 76 | { 77 | Console.WriteLine("[PAD] Acquired: vJoy device number {0}.", id); 78 | } 79 | 80 | HandleOscPacket callback = delegate (OscPacket packet) 81 | { 82 | var messageReceived = (OscMessage)packet; 83 | string addr = messageReceived.Address; 84 | string content = messageReceived.Arguments[0].ToString(); 85 | 86 | switch (messageReceived.Address) 87 | { 88 | case "/btn-a": 89 | if (content == "P") 90 | joystick.SetBtn(true, id, 1); 91 | if (content == "R") 92 | joystick.SetBtn(false, id, 1); 93 | break; 94 | 95 | case "/btn-b": 96 | if (content == "P") 97 | joystick.SetBtn(true, id, 2); 98 | if (content == "R") 99 | joystick.SetBtn(false, id, 2); 100 | break; 101 | 102 | case "/btn-c": 103 | if (content == "P") 104 | joystick.SetBtn(true, id, 3); 105 | if (content == "R") 106 | joystick.SetBtn(false, id, 3); 107 | break; 108 | 109 | case "/btn-d": 110 | if (content == "P") 111 | joystick.SetBtn(true, id, 4); 112 | if (content == "R") 113 | joystick.SetBtn(false, id, 4); 114 | break; 115 | 116 | case "/fx-l": 117 | if (content == "P") 118 | joystick.SetBtn(true, id, 5); 119 | if (content == "R") 120 | joystick.SetBtn(false, id, 5); 121 | break; 122 | 123 | case "/fx-r": 124 | if (content == "P") 125 | joystick.SetBtn(true, id, 6); 126 | if (content == "R") 127 | joystick.SetBtn(false, id, 6); 128 | break; 129 | 130 | case "/start": 131 | if (content == "P") 132 | joystick.SetBtn(true, id, 7); 133 | if (content == "R") 134 | joystick.SetBtn(false, id, 7); 135 | break; 136 | 137 | case "/vol-l": 138 | //lastL = currL; 139 | //currL = float.Parse(content); 140 | //float deltaL = lastL - currL; 141 | //L -= deltaL; 142 | 143 | int lPos = int.Parse(content); 144 | 145 | joystick.SetAxis(lPos*400, id, HID_USAGES.HID_USAGE_SL0); 146 | break; 147 | 148 | case "/vol-r": 149 | // lastR = currR; 150 | // currR = float.Parse(content); 151 | // float deltaR = lastR - currR; 152 | // R -= deltaR; 153 | 154 | int rPos = int.Parse(content); 155 | 156 | joystick.SetAxis(rPos * 400, id, HID_USAGES.HID_USAGE_SL1); 157 | break; 158 | } 159 | // Console.WriteLine("[OSC] Message Received: Address:" + messageReceived.Address + ", args: " + messageReceived.Arguments[0]); 160 | }; 161 | 162 | var listener = new UDPListener(32000, callback); 163 | 164 | Console.WriteLine("[OSC] Now listening to messages."); 165 | Console.WriteLine("[OSC] Press enter to stop"); 166 | Console.ReadLine(); 167 | listener.Close(); 168 | } 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /sdvx_server/sdvx_server/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // As informações gerais sobre um assembly são controladas por 6 | // conjunto de atributos. Altere estes valores de atributo para modificar as informações 7 | // associada a um assembly. 8 | [assembly: AssemblyTitle("sdvx_server")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("sdvx_server")] 13 | [assembly: AssemblyCopyright("Copyright © 2018")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Definir ComVisible como false torna os tipos neste assembly invisíveis 18 | // para componentes COM. Caso precise acessar um tipo neste assembly de 19 | // COM, defina o atributo ComVisible como true nesse tipo. 20 | [assembly: ComVisible(false)] 21 | 22 | // O GUID a seguir será destinado à ID de typelib se este projeto for exposto para COM 23 | [assembly: Guid("d8778918-c143-4282-94a7-864c8ff4b283")] 24 | 25 | // As informações da versão de um assembly consistem nos quatro valores a seguir: 26 | // 27 | // Versão Principal 28 | // Versão Secundária 29 | // Número da Versão 30 | // Revisão 31 | // 32 | // É possível especificar todos os valores ou usar como padrão os Números de Build e da Revisão 33 | // utilizando o "*" como mostrado abaixo: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /sdvx_server/sdvx_server/SharpOSC.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saderuuu/sdvx-mobile-controller/91446e0f42ff5bd634afb9fd8dd6d4bd195e5341/sdvx_server/sdvx_server/SharpOSC.dll -------------------------------------------------------------------------------- /sdvx_server/sdvx_server/VJoyInterface/vJoyInterfaceWrap.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saderuuu/sdvx-mobile-controller/91446e0f42ff5bd634afb9fd8dd6d4bd195e5341/sdvx_server/sdvx_server/VJoyInterface/vJoyInterfaceWrap.dll -------------------------------------------------------------------------------- /sdvx_server/sdvx_server/sdvx_server.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D8778918-C143-4282-94A7-864C8FF4B283} 8 | Exe 9 | sdvx_server 10 | sdvx_server 11 | v4.6.1 12 | 512 13 | true 14 | true 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | true 37 | bin\x64\Debug\ 38 | DEBUG;TRACE 39 | full 40 | x64 41 | prompt 42 | MinimumRecommendedRules.ruleset 43 | true 44 | 45 | 46 | bin\x64\Release\ 47 | TRACE 48 | true 49 | pdbonly 50 | x64 51 | prompt 52 | MinimumRecommendedRules.ruleset 53 | true 54 | 55 | 56 | 57 | False 58 | .\SharpOSC.dll 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | False 70 | VJoyInterface\vJoyInterfaceWrap.dll 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | PreserveNewest 84 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /sdvx_server/sdvx_server/vJoyInterface.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/saderuuu/sdvx-mobile-controller/91446e0f42ff5bd634afb9fd8dd6d4bd195e5341/sdvx_server/sdvx_server/vJoyInterface.dll --------------------------------------------------------------------------------