├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── Hardware ├── OSLTT.ino.bin ├── OSLTT │ ├── File2.ino │ ├── File3.ino │ └── OSLTT.ino └── Schematic_OSLTT_2023-07-19.png ├── LICENSE ├── OSLTT ├── Announcements.Designer.cs ├── Announcements.cs ├── Announcements.resx ├── App.config ├── CFuncs.cs ├── DirectX │ ├── DPerformanceTester.cs │ ├── Font │ │ ├── Font.ps │ │ ├── Font.vs │ │ ├── font.bmp │ │ ├── font01.bmp │ │ ├── font01.txt │ │ └── fontdata.txt │ ├── Graphics │ │ ├── DCameraClass.cs │ │ ├── DDX11Class.cs │ │ ├── DGraphicsClass.cs │ │ ├── DTextureClass.cs │ │ └── TextFont │ │ │ ├── DFontClass.cs │ │ │ ├── DFontShaderClass.cs │ │ │ └── DTextClass.cs │ ├── Input │ │ └── DInputClass.cs │ └── System │ │ ├── DCPUClass.cs │ │ ├── DFPSClass.cs │ │ ├── DSystemClass.cs │ │ ├── DSystemConfigurationClass.cs │ │ └── DTimerClass.cs ├── Main.Designer.cs ├── Main.cs ├── Main.resx ├── MouseHook │ ├── KeyboardHook.cs │ └── MouseHook.cs ├── OSLTT.csproj ├── OSLTT.sln ├── OSLTTTone.wav ├── ProcessData.cs ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ ├── Settings.settings │ └── icon.ico ├── Resources │ ├── arrow-rotate-right.png │ ├── bug-solid.png │ ├── chart-bar-solid.png │ ├── check.png │ ├── circle-question-solid.png │ ├── computer-mouse-solid.png │ ├── desktop-solid.png │ ├── folder-solid.png │ ├── gamepad-solid.png │ ├── gear-solid.png │ ├── headset-solid.png │ ├── keyboard-solid.png │ ├── play-solid.png │ └── wrench-solid.png ├── ResultsSettings.Designer.cs ├── ResultsSettings.cs ├── ResultsSettings.resx ├── ResultsView.Designer.cs ├── ResultsView.cs ├── ResultsView.resx ├── RoundedPanel.cs ├── Settings.cs ├── SettingsClasses.cs ├── SettingsPane.Designer.cs ├── SettingsPane.cs ├── SettingsPane.resx ├── TestSettings.cs ├── UpdateFirmware.cs ├── UpdateHandler.cs ├── UserSettings.cs ├── announcements.json ├── debugForm.Designer.cs ├── debugForm.cs ├── debugForm.resx ├── icon.ico ├── icon.png └── packages.config ├── OSLTTFlashTool.exe ├── README.md ├── buy-a-kit.png ├── software-qr.png ├── software-qr.svg └── view-the-docs.png /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.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 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Visual Studio code coverage results 141 | *.coverage 142 | *.coveragexml 143 | 144 | # NCrunch 145 | _NCrunch_* 146 | .*crunch*.local.xml 147 | nCrunchTemp_* 148 | 149 | # MightyMoose 150 | *.mm.* 151 | AutoTest.Net/ 152 | 153 | # Web workbench (sass) 154 | .sass-cache/ 155 | 156 | # Installshield output folder 157 | [Ee]xpress/ 158 | 159 | # DocProject is a documentation generator add-in 160 | DocProject/buildhelp/ 161 | DocProject/Help/*.HxT 162 | DocProject/Help/*.HxC 163 | DocProject/Help/*.hhc 164 | DocProject/Help/*.hhk 165 | DocProject/Help/*.hhp 166 | DocProject/Help/Html2 167 | DocProject/Help/html 168 | 169 | # Click-Once directory 170 | publish/ 171 | 172 | # Publish Web Output 173 | *.[Pp]ublish.xml 174 | *.azurePubxml 175 | # Note: Comment the next line if you want to checkin your web deploy settings, 176 | # but database connection strings (with potential passwords) will be unencrypted 177 | *.pubxml 178 | *.publishproj 179 | 180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 181 | # checkin your Azure Web App publish settings, but sensitive information contained 182 | # in these scripts will be unencrypted 183 | PublishScripts/ 184 | 185 | # NuGet Packages 186 | *.nupkg 187 | # NuGet Symbol Packages 188 | *.snupkg 189 | # The packages folder can be ignored because of Package Restore 190 | **/[Pp]ackages/* 191 | # except build/, which is used as an MSBuild target. 192 | !**/[Pp]ackages/build/ 193 | # Uncomment if necessary however generally it will be regenerated when needed 194 | #!**/[Pp]ackages/repositories.config 195 | # NuGet v3's project.json files produces more ignorable files 196 | *.nuget.props 197 | *.nuget.targets 198 | 199 | # Microsoft Azure Build Output 200 | csx/ 201 | *.build.csdef 202 | 203 | # Microsoft Azure Emulator 204 | ecf/ 205 | rcf/ 206 | 207 | # Windows Store app package directories and files 208 | AppPackages/ 209 | BundleArtifacts/ 210 | Package.StoreAssociation.xml 211 | _pkginfo.txt 212 | *.appx 213 | *.appxbundle 214 | *.appxupload 215 | 216 | # Visual Studio cache files 217 | # files ending in .cache can be ignored 218 | *.[Cc]ache 219 | # but keep track of directories ending in .cache 220 | !?*.[Cc]ache/ 221 | 222 | # Others 223 | ClientBin/ 224 | ~$* 225 | *~ 226 | *.dbmdl 227 | *.dbproj.schemaview 228 | *.jfm 229 | *.pfx 230 | *.publishsettings 231 | orleans.codegen.cs 232 | 233 | # Including strong name files can present a security risk 234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 235 | #*.snk 236 | 237 | # Since there are multiple workflows, uncomment next line to ignore bower_components 238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 239 | #bower_components/ 240 | 241 | # RIA/Silverlight projects 242 | Generated_Code/ 243 | 244 | # Backup & report files from converting an old project file 245 | # to a newer Visual Studio version. Backup files are not needed, 246 | # because we have git ;-) 247 | _UpgradeReport_Files/ 248 | Backup*/ 249 | UpgradeLog*.XML 250 | UpgradeLog*.htm 251 | ServiceFabricBackup/ 252 | *.rptproj.bak 253 | 254 | # SQL Server files 255 | *.mdf 256 | *.ldf 257 | *.ndf 258 | 259 | # Business Intelligence projects 260 | *.rdl.data 261 | *.bim.layout 262 | *.bim_*.settings 263 | *.rptproj.rsuser 264 | *- [Bb]ackup.rdl 265 | *- [Bb]ackup ([0-9]).rdl 266 | *- [Bb]ackup ([0-9][0-9]).rdl 267 | 268 | # Microsoft Fakes 269 | FakesAssemblies/ 270 | 271 | # GhostDoc plugin setting file 272 | *.GhostDoc.xml 273 | 274 | # Node.js Tools for Visual Studio 275 | .ntvs_analysis.dat 276 | node_modules/ 277 | 278 | # Visual Studio 6 build log 279 | *.plg 280 | 281 | # Visual Studio 6 workspace options file 282 | *.opt 283 | 284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 285 | *.vbw 286 | 287 | # Visual Studio LightSwitch build output 288 | **/*.HTMLClient/GeneratedArtifacts 289 | **/*.DesktopClient/GeneratedArtifacts 290 | **/*.DesktopClient/ModelManifest.xml 291 | **/*.Server/GeneratedArtifacts 292 | **/*.Server/ModelManifest.xml 293 | _Pvt_Extensions 294 | 295 | # Paket dependency manager 296 | .paket/paket.exe 297 | paket-files/ 298 | 299 | # FAKE - F# Make 300 | .fake/ 301 | 302 | # CodeRush personal settings 303 | .cr/personal 304 | 305 | # Python Tools for Visual Studio (PTVS) 306 | __pycache__/ 307 | *.pyc 308 | 309 | # Cake - Uncomment if you are using it 310 | # tools/** 311 | # !tools/packages.config 312 | 313 | # Tabs Studio 314 | *.tss 315 | 316 | # Telerik's JustMock configuration file 317 | *.jmconfig 318 | 319 | # BizTalk build output 320 | *.btp.cs 321 | *.btm.cs 322 | *.odx.cs 323 | *.xsd.cs 324 | 325 | # OpenCover UI analysis results 326 | OpenCover/ 327 | 328 | # Azure Stream Analytics local run output 329 | ASALocalRun/ 330 | 331 | # MSBuild Binary and Structured Log 332 | *.binlog 333 | 334 | # NVidia Nsight GPU debugger configuration file 335 | *.nvuser 336 | 337 | # MFractors (Xamarin productivity tool) working folder 338 | .mfractor/ 339 | 340 | # Local History for Visual Studio 341 | .localhistory/ 342 | 343 | # BeatPulse healthcheck temp database 344 | healthchecksdb 345 | 346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 347 | MigrationBackup/ 348 | 349 | # Ionide (cross platform F# VS Code tools) working folder 350 | .ionide/ 351 | -------------------------------------------------------------------------------- /Hardware/OSLTT.ino.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/Hardware/OSLTT.ino.bin -------------------------------------------------------------------------------- /Hardware/OSLTT/File3.ino: -------------------------------------------------------------------------------- 1 | // Main loop body 2 | #if defined(ARDUINO_SEEED_XIAO_M0) 3 | const char* boardname = "Seeed"; 4 | #elif defined(ARDUINO_SAMD_ZERO) 5 | const char* boardname = "Feather"; 6 | #else 7 | const char* boardname = "UNKNOWN BOARD"; 8 | #endif 9 | 10 | void setup() { 11 | setBootProt(2); 12 | uint32_t bootprot = getBootProt(); 13 | 14 | // start serial port at 9600 bps: 15 | Serial.begin(115200); 16 | while (!Serial) { 17 | ; // wait for serial port to connect. Needed for native USB port only 18 | } 19 | Serial.println(boardname); 20 | pinMode(PullDownPin, INPUT_PULLDOWN); 21 | pinMode(ButtonPin, INPUT_PULLUP); 22 | pinMode(LEDPin, OUTPUT); 23 | ChangeInterrupt(false); 24 | if (boardname == "Feather") 25 | { 26 | pinMode(PullUpPin, INPUT_PULLUP); 27 | //attachInterrupt(PullUpPin, PullUpInterrupt, LOW); 28 | Serial.println("Attached Interrupt"); 29 | } 30 | 31 | //ADC_Init(); 32 | analogReadResolution(14); 33 | 34 | establishContact(); // send a byte to establish contact until receiver responds 35 | 36 | } 37 | 38 | void loop() { 39 | int buttonState = 0; 40 | 41 | getSerialChars(); 42 | 43 | if (input[0] == 'T') // Button trigger test mode 44 | { 45 | while (input[0] != 'X') { 46 | Serial.setTimeout(100); 47 | getSerialChars(); 48 | if (inputType == 0) { 49 | if (digitalRead(ButtonPin)) { 50 | if (sensorType == 1) { 51 | if (autoClick) { 52 | for (int i = 0; i < shotCount; i++) { 53 | runAudioTest(); 54 | //delay(timeBetween * 1000); 55 | delay(100); 56 | } 57 | Serial.println("AUDIO TEST FINISHED"); 58 | break; 59 | } else { 60 | runAudioTest(); 61 | } 62 | } else { 63 | autoRunTest(autoClick, 12000, shotCount); 64 | if (autoClick) { 65 | break; 66 | } 67 | } 68 | } 69 | } else if (sourceType == 1 || sourceType == 5 || sourceType == 6 || sourceType == 7) { 70 | if (inputType == 1) 71 | { 72 | runClickTest(); 73 | } 74 | else if (inputType == 2) 75 | { 76 | runClickTest2Pin(); 77 | } 78 | else if (inputType == 3) 79 | { 80 | runClickTest3Pin(); 81 | } 82 | break; 83 | } else if (inputType == 1 && sensorType == 0) // mic trigger, light sensor data source. Console testing mode 84 | { 85 | micBaseline = setMicBaseline(); 86 | while (input[0] != 'X') { 87 | if (digitalRead(ButtonPin)) { 88 | input[0] = 'X'; 89 | toggleLED(false); 90 | Serial.println("FINISHED"); 91 | } 92 | if (analogRead(1) > micBaseline) 93 | { 94 | autoRunTest(false, 12000); 95 | toggleLED(true); 96 | getSerialChars(); 97 | delay(300); 98 | toggleLED(false); 99 | } 100 | } 101 | } else if (inputType == 2) { 102 | while (input[0] != 'X') { 103 | getSerialChars(); 104 | if (digitalRead(PullDownPin) != HIGH) { 105 | // Run test 106 | autoRunTest(false, 12000); 107 | } 108 | } 109 | break; 110 | } 111 | } 112 | } else if (input[0] == 'P') // Pre-test 113 | { 114 | Serial.println("pretest starting"); 115 | int localInputType = inputType; 116 | int localSourceType = sourceType; 117 | inputType = 0; 118 | sourceType = 0; 119 | while (input[0] != 'X') { 120 | getSerialChars(); 121 | if (digitalRead(ButtonPin)) { 122 | autoRunTest(true, 9000, 50, true); // set this back to 50 or 100 123 | inputType = localInputType; 124 | sourceType = localSourceType; 125 | input[0] = 'X'; 126 | 127 | } 128 | } 129 | } else if (input[0] == 'I') // Initialise everything 130 | { 131 | toggleLED(true); 132 | 133 | Serial.print("FW:"); 134 | Serial.println(firmwareVersion); 135 | 136 | // Sensor type - bit 1 137 | sensorType = convertHexToDec(input[1]) - 1; 138 | 139 | // Trigger type - bit 2 140 | inputType = convertHexToDec(input[2]) - 1; 141 | if (inputType == 3) 142 | { 143 | ChangeInterrupt(true); 144 | inputType--; 145 | } 146 | else if (inputType == 2) 147 | { 148 | ChangeInterrupt(false); 149 | } 150 | if (inputType == 4) { inputType--;} 151 | 152 | // Auto Click - bit 3 153 | if (input[3] == '1') { 154 | autoClick = true; 155 | } else { 156 | autoClick = false; 157 | } 158 | 159 | // DirectX - bit 4 160 | sourceType = convertHexToDec(input[4]) - 1; 161 | if (sourceType == 3) { setAGain(true); } 162 | else { setAGain(false); } 163 | 164 | // Shot count - bit 5 + 6 165 | int msb = convertHexToDec(input[5]); 166 | int lsb = convertHexToDec(input[6]); 167 | shotCount = (msb * 100) + (lsb * 10); 168 | 169 | // Time between - bit 7 170 | int tbw = convertHexToDec(input[7]); 171 | if (tbw == 1) { 172 | timeBetween = 0.5; 173 | } else { 174 | timeBetween = tbw - 1; 175 | } 176 | 177 | // Mouse Action - bit 8 178 | MouseAction = convertHexToDec(input[8]); 179 | 180 | // Confirm settings synced 181 | for (int i = 0; i < INPUT_SIZE; i++) { 182 | Serial.print(input[i]); 183 | } 184 | Serial.println(); 185 | Serial.println("Settings Synced"); 186 | 187 | } else if (input[0] == 'S') // Shot count 188 | { 189 | Serial.println("Ready"); 190 | getSerialChars(); 191 | int MSB = convertHexToDec(input[1]); 192 | int LSB = convertHexToDec(input[0]); 193 | shotCount = (MSB * 100) + (LSB * 10); 194 | } else if (input[0] == 'Q') { 195 | while (input[0] != 'X') { 196 | getSerialChars(); 197 | int pulldown = digitalRead(PullDownPin); 198 | Serial.println(pulldown); 199 | if (pulldown == LOW) { 200 | pulseLED(true); 201 | } else { 202 | pulseLED(false); 203 | } 204 | delay(100); 205 | } 206 | } else if (input[0] == 'W') { 207 | if (input[1] == '1') 208 | { 209 | while (!digitalRead(ButtonPin)) { 210 | delay(1); 211 | } 212 | long fourteen = fillADCBufferSlower(ArraySize, 1); 213 | 214 | for (int i = 0; i < ArraySize; i++) { 215 | Serial.print(adcBuff[i]); 216 | Serial.print(","); 217 | } 218 | Serial.println(); 219 | } 220 | else if (input[1]=='2') 221 | { 222 | while (!digitalRead(ButtonPin)) { 223 | delay(1); 224 | } 225 | long fourteen = fillADCBuffer(ArraySize, 0); 226 | 227 | for (int i = 0; i < ArraySize; i++) { 228 | Serial.print(adcBuff[i]); 229 | Serial.print(","); 230 | } 231 | Serial.println(); 232 | } 233 | else if (input[1]=='3') 234 | { 235 | long fourteen = fillADCBufferSlower(ArraySize, 1); 236 | Serial.print("MICTEST:"); 237 | for (int i = 0; i < ArraySize; i++) { 238 | Serial.print(adcBuff[i]); 239 | Serial.print(","); 240 | } 241 | Serial.println(); 242 | } 243 | } else if (input[0] == 'Y') { 244 | Serial.setTimeout(100); 245 | int counter = 100; 246 | getSerialChars(); 247 | while (input[0] != 'X'){ 248 | getSerialChars(); 249 | if (digitalRead(ButtonPin)) { 250 | for (int i = 0; i < counter; i++){ 251 | long click = micros(); 252 | Mouse.click(MOUSE_LEFT); 253 | //Keyboard.write('A'); 254 | //Serial.println("CLICKTEST"); 255 | long start = micros(); 256 | while (input[0] != 'H' && input[0] != 'X') { 257 | getClickChar(); 258 | //getSerialChars(); 259 | } 260 | long end = micros(); 261 | long time = end - start; 262 | adcBuff[i] = time; 263 | 264 | Serial.println(i); 265 | getSerialChars(); 266 | delay(500 + random(300)); 267 | } 268 | input[0]='X'; 269 | } 270 | } 271 | long avg = 0; 272 | for (int i = 0; i < counter; i++) { 273 | avg += adcBuff[i]; 274 | Serial.print(adcBuff[i]); 275 | Serial.print(","); 276 | } 277 | Serial.println(); 278 | avg /= counter; 279 | Serial.print("average time: "); 280 | Serial.println(avg); 281 | Serial.print("number of tests ran: "); 282 | Serial.println(counter); 283 | } else if (input[0] == 'Z') { 284 | if (input[1] == '1') // Pro CS board pre-shipping validation 285 | { 286 | toggleLED(false); 287 | uint32_t temp = 0; 288 | for (int i = 0; i < 1000; i++) 289 | { 290 | temp += analogRead(A0); 291 | } 292 | temp /= 1000; 293 | if (temp < 10 || temp > 1000) 294 | { 295 | Serial.println("Light sensor failed"); 296 | } 297 | else { Serial.println("Light sensor passed");} 298 | long fourteen = fillADCBufferSlower(ArraySize, 1); 299 | int max = 0; 300 | int min = 16000; 301 | for (int i = 0; i < ArraySize; i++) { 302 | if (adcBuff[i] > max) 303 | { 304 | max = adcBuff[i]; 305 | } 306 | if (adcBuff[i] < min) 307 | { 308 | min = adcBuff[i]; 309 | } 310 | } 311 | if (max > 12000 || min < 5000){ Serial.println("Audio test failed"); } 312 | else { Serial.println("Audio test passed");} 313 | bool button = false; 314 | bool twopin = true; 315 | bool threepin = true; 316 | long timer = millis(); 317 | long start = millis(); 318 | while (!button) 319 | { 320 | button = digitalRead(ButtonPin); 321 | timer= millis(); 322 | if (timer > 180000 + start) 323 | { 324 | Serial.println("button wasn't detected"); 325 | break; 326 | } 327 | } 328 | if (button) {Serial.println("Button passed");} 329 | while (twopin) 330 | { 331 | twopin = digitalRead(PullDownPin); 332 | timer= millis(); 333 | if (timer > 180000 + start) 334 | { 335 | Serial.println("two pin wasn't detected"); 336 | break; 337 | } 338 | } 339 | if (twopin) {Serial.println("Two Pin passed");} 340 | while (threepin) 341 | { 342 | threepin = digitalRead(PullUpPin); 343 | timer= millis(); 344 | if (timer > 180000 + start) 345 | { 346 | Serial.println("Three pin wasn't detected"); 347 | break; 348 | } 349 | } 350 | if (threepin) {Serial.println("Three pin passed");} 351 | toggleLED(true); 352 | delay(1000); 353 | toggleLED(false); 354 | delay(1000); 355 | toggleLED(true); 356 | delay(1000); 357 | toggleLED(false); 358 | Serial.println("Test complete, check for errors"); 359 | } 360 | else 361 | { 362 | long start = micros(); 363 | digitalRead(PullUpPin); 364 | long end = micros(); 365 | Serial.println(end - start); 366 | 367 | } 368 | } 369 | } 370 | -------------------------------------------------------------------------------- /Hardware/OSLTT/OSLTT.ino: -------------------------------------------------------------------------------- 1 | // Definitions, libraries 2 | #include 3 | #include 4 | 5 | #define INPUT_SIZE 9 6 | 7 | #define ArraySize 12000 8 | 9 | int LEDPin = 3; //19 // first analog sensor 10 | int PullDownPin = 4; //16 // second analog sensor 11 | int ButtonPin = 6; //2 // digital sensor 12 | int inByte = 0; // incoming serial byte 13 | int PullUpPin = 9; // CS Only 14 | int AGain = 7; // CS Only 15 | 16 | uint16_t adcBuff[ArraySize]; 17 | 18 | float firmwareVersion = 1.8; 19 | 20 | int inputType = 0; // 0 = button, 1 = audio, 2 = pin trigger 21 | 22 | int sensorType = 0; // 0 = light, 1 = audio 23 | 24 | int sourceType = 0; // 0 = directX, 1 = mouse/keyboard, 2 = game/external, 3 = audio clip 25 | 26 | int shotCount = 100; 27 | 28 | double timeBetween = 0.5; 29 | 30 | bool autoClick = true; 31 | 32 | int MouseAction = 0; // 0 = left click, 1 = move left, 2 = move right 33 | 34 | bool directXMode = true; 35 | 36 | char input[INPUT_SIZE + 1]; 37 | 38 | bool LEDState = false; 39 | 40 | bool InterruptFlag = false; 41 | int InterruptCount = 0; 42 | bool PullDownInterruptFlag = false; 43 | 44 | int micBaseline = 16000; 45 | -------------------------------------------------------------------------------- /Hardware/Schematic_OSLTT_2023-07-19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/Hardware/Schematic_OSLTT_2023-07-19.png -------------------------------------------------------------------------------- /OSLTT/Announcements.Designer.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace OSLTT 3 | { 4 | partial class Announcements 5 | { 6 | /// 7 | /// Required designer variable. 8 | /// 9 | private System.ComponentModel.IContainer components = null; 10 | 11 | /// 12 | /// Clean up any resources being used. 13 | /// 14 | /// true if managed resources should be disposed; otherwise, false. 15 | protected override void Dispose(bool disposing) 16 | { 17 | if (disposing && (components != null)) 18 | { 19 | components.Dispose(); 20 | } 21 | base.Dispose(disposing); 22 | } 23 | 24 | #region Windows Form Designer generated code 25 | 26 | /// 27 | /// Required method for Designer support - do not modify 28 | /// the contents of this method with the code editor. 29 | /// 30 | private void InitializeComponent() 31 | { 32 | this.closeBtn = new MaterialSkin.Controls.MaterialButton(); 33 | this.materialButton1 = new MaterialSkin.Controls.MaterialButton(); 34 | this.materialCard1 = new MaterialSkin.Controls.MaterialCard(); 35 | this.Description = new MaterialSkin.Controls.MaterialLabel(); 36 | this.Title = new MaterialSkin.Controls.MaterialLabel(); 37 | this.materialCard1.SuspendLayout(); 38 | this.SuspendLayout(); 39 | // 40 | // closeBtn 41 | // 42 | this.closeBtn.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 43 | this.closeBtn.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; 44 | this.closeBtn.Depth = 0; 45 | this.closeBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; 46 | this.closeBtn.HighEmphasis = true; 47 | this.closeBtn.Icon = null; 48 | this.closeBtn.Location = new System.Drawing.Point(668, 664); 49 | this.closeBtn.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); 50 | this.closeBtn.MouseState = MaterialSkin.MouseState.HOVER; 51 | this.closeBtn.Name = "closeBtn"; 52 | this.closeBtn.NoAccentTextColor = System.Drawing.Color.Empty; 53 | this.closeBtn.Size = new System.Drawing.Size(199, 36); 54 | this.closeBtn.TabIndex = 1; 55 | this.closeBtn.Text = "Close Announcements"; 56 | this.closeBtn.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; 57 | this.closeBtn.UseAccentColor = false; 58 | this.closeBtn.UseVisualStyleBackColor = true; 59 | this.closeBtn.Click += new System.EventHandler(this.closeBtn_Click); 60 | // 61 | // materialButton1 62 | // 63 | this.materialButton1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 64 | this.materialButton1.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; 65 | this.materialButton1.Depth = 0; 66 | this.materialButton1.DialogResult = System.Windows.Forms.DialogResult.Cancel; 67 | this.materialButton1.HighEmphasis = true; 68 | this.materialButton1.Icon = null; 69 | this.materialButton1.Location = new System.Drawing.Point(17, 664); 70 | this.materialButton1.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); 71 | this.materialButton1.MouseState = MaterialSkin.MouseState.HOVER; 72 | this.materialButton1.Name = "materialButton1"; 73 | this.materialButton1.NoAccentTextColor = System.Drawing.Color.Empty; 74 | this.materialButton1.Size = new System.Drawing.Size(228, 36); 75 | this.materialButton1.TabIndex = 3; 76 | this.materialButton1.Text = "Visit GitHub Releases Page"; 77 | this.materialButton1.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; 78 | this.materialButton1.UseAccentColor = false; 79 | this.materialButton1.UseVisualStyleBackColor = true; 80 | this.materialButton1.Click += new System.EventHandler(this.materialButton1_Click); 81 | // 82 | // materialCard1 83 | // 84 | this.materialCard1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); 85 | this.materialCard1.Controls.Add(this.Description); 86 | this.materialCard1.Controls.Add(this.Title); 87 | this.materialCard1.Depth = 0; 88 | this.materialCard1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(222)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); 89 | this.materialCard1.Location = new System.Drawing.Point(17, 78); 90 | this.materialCard1.Margin = new System.Windows.Forms.Padding(14); 91 | this.materialCard1.MouseState = MaterialSkin.MouseState.HOVER; 92 | this.materialCard1.Name = "materialCard1"; 93 | this.materialCard1.Padding = new System.Windows.Forms.Padding(14); 94 | this.materialCard1.Size = new System.Drawing.Size(850, 566); 95 | this.materialCard1.TabIndex = 4; 96 | // 97 | // Description 98 | // 99 | this.Description.Depth = 0; 100 | this.Description.Font = new System.Drawing.Font("Roboto Medium", 20F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); 101 | this.Description.FontType = MaterialSkin.MaterialSkinManager.fontType.H6; 102 | this.Description.Location = new System.Drawing.Point(36, 101); 103 | this.Description.MouseState = MaterialSkin.MouseState.HOVER; 104 | this.Description.Name = "Description"; 105 | this.Description.Size = new System.Drawing.Size(784, 442); 106 | this.Description.TabIndex = 1; 107 | this.Description.Text = "materialLabel1"; 108 | // 109 | // Title 110 | // 111 | this.Title.AutoSize = true; 112 | this.Title.Depth = 0; 113 | this.Title.Font = new System.Drawing.Font("Roboto", 48F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Pixel); 114 | this.Title.FontType = MaterialSkin.MaterialSkinManager.fontType.H3; 115 | this.Title.Location = new System.Drawing.Point(34, 29); 116 | this.Title.MouseState = MaterialSkin.MouseState.HOVER; 117 | this.Title.Name = "Title"; 118 | this.Title.Size = new System.Drawing.Size(319, 58); 119 | this.Title.TabIndex = 0; 120 | this.Title.Text = "materialLabel1"; 121 | // 122 | // Announcements 123 | // 124 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 125 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 126 | this.AutoScroll = true; 127 | this.CancelButton = this.closeBtn; 128 | this.ClientSize = new System.Drawing.Size(884, 727); 129 | this.Controls.Add(this.materialCard1); 130 | this.Controls.Add(this.materialButton1); 131 | this.Controls.Add(this.closeBtn); 132 | this.Name = "Announcements"; 133 | this.Text = "Announcements - Most Recent"; 134 | this.materialCard1.ResumeLayout(false); 135 | this.materialCard1.PerformLayout(); 136 | this.ResumeLayout(false); 137 | this.PerformLayout(); 138 | 139 | } 140 | 141 | #endregion 142 | private MaterialSkin.Controls.MaterialButton closeBtn; 143 | private MaterialSkin.Controls.MaterialButton materialButton1; 144 | private MaterialSkin.Controls.MaterialCard materialCard1; 145 | private MaterialSkin.Controls.MaterialLabel Description; 146 | private MaterialSkin.Controls.MaterialLabel Title; 147 | } 148 | } -------------------------------------------------------------------------------- /OSLTT/Announcements.cs: -------------------------------------------------------------------------------- 1 | using MaterialSkin; 2 | using MaterialSkin.Controls; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel; 6 | using System.Data; 7 | using System.Drawing; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using System.Windows.Forms; 12 | using System.Threading; 13 | using System.Diagnostics; 14 | 15 | namespace OSLTT 16 | { 17 | public partial class Announcements : MaterialForm 18 | { 19 | public UpdateHandler.AnnouncementText announcementText = new UpdateHandler.AnnouncementText { titleText = "Nothing to see here...", descriptionText = "No updates here!" }; 20 | public Announcements() 21 | { 22 | InitializeComponent(); 23 | var materialSkinManager = MaterialSkinManager.Instance; 24 | materialSkinManager.EnforceBackcolorOnAllComponents = true; 25 | materialSkinManager.AddFormToManage(this); 26 | materialSkinManager.Theme = MaterialSkinManager.Themes.DARK; 27 | materialSkinManager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE); 28 | 29 | this.TopMost = true; 30 | 31 | } 32 | 33 | public void SetAnnouncement(UpdateHandler.AnnouncementText a) 34 | { 35 | announcementText = a; 36 | Title.Text = announcementText.titleText; 37 | Description.Text = announcementText.descriptionText; 38 | } 39 | 40 | private void closeBtn_Click(object sender, EventArgs e) 41 | { 42 | this.Hide(); 43 | } 44 | 45 | private void materialButton1_Click(object sender, EventArgs e) 46 | { 47 | Process.Start("https://github.com/OSRTT/OSLTT/releases"); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /OSLTT/Announcements.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | -------------------------------------------------------------------------------- /OSLTT/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | False 23 | 24 | 25 | True 26 | 27 | 28 | False 29 | 30 | 31 | False 32 | 33 | 34 | False 35 | 36 | 37 | False 38 | 39 | 40 | False 41 | 42 | 43 | 100 44 | 45 | 46 | 0.5 47 | 48 | 49 | False 50 | 51 | 52 | True 53 | 54 | 55 | False 56 | 57 | 58 | False 59 | 60 | 61 | F10 62 | 63 | 64 | 30 65 | 66 | 67 | Black 68 | 69 | 70 | 1 71 | 72 | 73 | 0 74 | 75 | 76 | 0 77 | 78 | 79 | 500 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /OSLTT/CFuncs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Diagnostics; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Text.RegularExpressions; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace OSLTT 12 | { 13 | class CFuncs 14 | { 15 | public static DialogResult showMessageBox(string title, string message, MessageBoxButtons buttons, MessageBoxIcon icon) 16 | { 17 | if (true) 18 | { 19 | DialogResult d = MessageBox.Show(title, message, buttons, icon); 20 | return d; 21 | } 22 | else 23 | { 24 | return DialogResult.None; 25 | } 26 | } 27 | 28 | public static void HyperlinkOut(string url) 29 | { 30 | Process.Start(url); 31 | } 32 | 33 | 34 | public static void appRunning() 35 | { 36 | Process[] p = Process.GetProcessesByName("OSRTT Launcher"); 37 | if (p.Length > 1) 38 | { 39 | showMessageBox("ERROR: Program already open! Please close it before running again, or check the task bar and system tray for the running app.", "Program Open Already", MessageBoxButtons.OK, MessageBoxIcon.Error); 40 | Console.WriteLine(p.Length); 41 | //this.Close(); 42 | } 43 | } 44 | 45 | public static void IFailedYou(object sender, UnhandledExceptionEventArgs args) 46 | { 47 | Exception e = (Exception)args.ExceptionObject; 48 | string type = e.Message.ToString(); 49 | 50 | if (type != "Safe handle has been closed") 51 | { 52 | MessageBox.Show(e.Message, "Unexpected Error - Program Closing", MessageBoxButtons.OK, MessageBoxIcon.Error); 53 | } 54 | else if (type.Contains("TimeoutException") || type.Contains("operation has timed out")) 55 | { 56 | Console.WriteLine(e.Message + e.StackTrace); 57 | } 58 | else 59 | { 60 | Console.WriteLine(e.Message + " " + e.StackTrace); 61 | } 62 | } 63 | 64 | public static void checkFolderPermissions(string path) 65 | { 66 | string filePath = path + "\\permissionsTest"; 67 | bool test = false; 68 | try 69 | { 70 | Directory.CreateDirectory(filePath); 71 | test = true; 72 | } 73 | catch (Exception ex) 74 | { 75 | if (ex.Message.Contains("Access to the path")) 76 | { 77 | MessageBox.Show("Permissions Error - program unable to create new results folders. \n The program may be installed in the wrong location." + 78 | "Please check, or relaunch the program as admin.", "Permissions Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 79 | Application.Exit(); 80 | } 81 | } 82 | finally 83 | { 84 | if (test) 85 | { 86 | Directory.Delete(filePath); 87 | } 88 | } 89 | } 90 | 91 | public static string makeResultsFolder(string path, ProcessData.resultType type, string deviceName="OSLTT") 92 | { 93 | if (deviceName=="") 94 | { 95 | deviceName = "OSLTT"; 96 | } 97 | decimal fileNumber = 001; 98 | // search /Results folder for existing file names, pick new name 99 | string[] existingFiles = Directory.GetDirectories(path, deviceName + "-*"); 100 | //search files for number 101 | if (existingFiles.Length != 0) 102 | { 103 | foreach (var s in existingFiles) 104 | { 105 | var name = new DirectoryInfo(s).Name; 106 | string[] splitMe = name.Split('-'); 107 | decimal num = decimal.Parse(splitMe.Last()); 108 | if (num >= fileNumber) 109 | { 110 | fileNumber = num + 1; 111 | } 112 | } 113 | } 114 | string typeName = "LIGHT"; 115 | if (type == ProcessData.resultType.Audio) 116 | { typeName = "AUDIO"; } 117 | else if (type == ProcessData.resultType.Click) 118 | { typeName = "CLICK"; } 119 | string filePath = path + "\\" + deviceName + "-" + typeName + "-" + fileNumber.ToString("000"); 120 | Directory.CreateDirectory(filePath); 121 | return filePath; 122 | //initRunSettingsFile(filePath, monitor); 123 | } 124 | 125 | public static void removeResultsFolder(string path) 126 | { 127 | try 128 | { 129 | // search /Results folder for existing file names, pick new name 130 | string[] existingFiles = Directory.GetFiles(path); 131 | //search files for number 132 | if (existingFiles.Length == 0) 133 | { 134 | Directory.Delete(path); 135 | } 136 | } 137 | catch (Exception ex) 138 | { 139 | Console.WriteLine(ex.Message + ex.StackTrace); 140 | } 141 | } 142 | 143 | public static string makeResultsFile(string path, string type = "RAW") 144 | { 145 | if (type == "") 146 | { 147 | type = "RAW"; 148 | } 149 | string[] folders = path.Split('\\'); 150 | string[] parts = folders.Last().Split('-'); 151 | string filePath = ""; 152 | Regex regexMatchString = new Regex(@"\d\d\d"); 153 | foreach (var s in parts) 154 | { 155 | if (regexMatchString.IsMatch(s)) 156 | { 157 | filePath += type + "-" + s; 158 | } 159 | else 160 | { 161 | filePath += s + "-"; 162 | } 163 | } 164 | filePath += ".csv"; 165 | return filePath; 166 | //initRunSettingsFile(filePath, monitor); 167 | } 168 | 169 | public static void saveRawResultToFile(string path, string fileName, ProcessData.rawInputLagResult res) 170 | { 171 | string strSeparator = ","; 172 | StringBuilder csvString = new StringBuilder(); 173 | csvString.AppendLine(res.ClickTime.ToString() + "," + res.FrameTime.ToString() + "," + res.TimeTaken.ToString() + "," + res.SampleCount.ToString() + "," + string.Join(strSeparator, res.Samples)); 174 | 175 | File.AppendAllText(path + "\\" + fileName, csvString.ToString()); 176 | } 177 | 178 | public static string createIMGFileName(string path, string type) 179 | { 180 | string[] folders = path.Split('\\'); 181 | decimal fileNumber = 001; 182 | // search /Results folder for existing file names, pick new name 183 | string[] existingFiles = Directory.GetFiles(path, "*.png"); 184 | //search files for number 185 | if (existingFiles.Length != 0) 186 | { 187 | foreach (var s in existingFiles) 188 | { 189 | var name = new DirectoryInfo(s).Name; 190 | string[] splitMe = name.Split('-'); 191 | decimal num = decimal.Parse(splitMe[0]); 192 | if (num >= fileNumber) 193 | { 194 | fileNumber = num + 1; 195 | } 196 | } 197 | } 198 | string filePath = fileNumber.ToString("000") + "-"; 199 | 200 | string[] parts = folders.Last().Split('-'); 201 | Regex regexMatchString = new Regex(@"\d\d\d"); 202 | foreach (var s in parts) 203 | { 204 | if (regexMatchString.IsMatch(s)) 205 | { 206 | filePath += type; 207 | } 208 | else 209 | { 210 | filePath += s + "-"; 211 | } 212 | } 213 | filePath += ".png"; 214 | return filePath; 215 | } 216 | 217 | 218 | 219 | } 220 | } 221 | -------------------------------------------------------------------------------- /OSLTT/DirectX/DPerformanceTester.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | 7 | namespace TestConsole 8 | { 9 | public static class DPerfLogger // 168 lines 10 | { 11 | // CONVERT THIS TO JUST LIST FRAME TIMES THEN CALL MAIN() FUNCITON WITH AVERAGE FRAME TIME 12 | 13 | 14 | // Static variables 15 | public static StringBuilder sb; 16 | public static int TestTimeInSeconds = 8, estimatedFPS = 5000; 17 | 18 | // static properties 19 | public static bool IsTimedTest { get; set; } 20 | public static int TotalSamples { get; set; } 21 | public static List SampleFloatSet { get; set; } 22 | public static string ComputerName { get { return Environment.MachineName; } } 23 | 24 | // Static Methods 25 | public static void Initialize(string TestTitleType, int seconds, int width, int height) 26 | { 27 | IsTimedTest = (seconds > 0); 28 | TestTimeInSeconds = seconds; 29 | CalculateEstimatedFrames(width, height); 30 | Initialize(TestTitleType); 31 | } 32 | private static void Initialize(string TestTitleType) 33 | { 34 | sb = new StringBuilder(); 35 | sb.AppendLine(ComputerName + " " + DateTime.Now.ToShortDateString() + "-" + DateTime.Now.ToShortTimeString() + " " + TestTitleType + "--"); 36 | SampleFloatSet = new List(); 37 | } 38 | private static void CalculateEstimatedFrames(int width, int height) 39 | { 40 | // Create a List with the approximate number of needed slots in the list so that we are not creating nad inserting each entry. As well as an estimated number of pixels that can be processed as 2 billion per second. 41 | estimatedFPS = 2000000000 / (width * height); 42 | } 43 | public static void Frame(float frameTime) 44 | { 45 | SampleFloatSet.Add(1000.0f / frameTime); 46 | } 47 | public static void WriteFPSTest() 48 | { 49 | File.AppendAllText("Test.txt", sb.ToString()); 50 | 51 | // Reset Static class variables for next execution now that this test has been completed/ 52 | TestTimeInSeconds = 8; 53 | estimatedFPS = 5000; 54 | } 55 | public static double CalcualteFPSMetrics(List sampleFloatSet, bool writeToFile, bool cleanDirtyData, double percentageAllowance) 56 | { 57 | double fPSAverage = 0.0, FPSMinimum = 0.0, FPSMaximum = 0.0, standardDeviation2 = 0.0, newfPSAverage2 = 0.0; 58 | 59 | // Time Test 60 | double timeInBeforeDirtyDataRemoved = sampleFloatSet.Select(e => 1000.0 / e).Sum() / 1000.0; 61 | 62 | if (sampleFloatSet.Any()) 63 | { 64 | fPSAverage = sampleFloatSet.Average(); 65 | FPSMinimum = sampleFloatSet.Min(); 66 | FPSMaximum = sampleFloatSet.Max(); 67 | 68 | // List sameplSet = sampleFloatSet.ToList(); 69 | if (cleanDirtyData && sampleFloatSet.Count > 0) 70 | { 71 | // Record the count of SDamples before reducing Samples that represent Dirty Data. 72 | TotalSamples = sampleFloatSet.Count; 73 | // Perform Dirty Data cleaning algorythum 74 | newfPSAverage2 = RemoveUpperLowerLimits(FPSMinimum, FPSMaximum, sampleFloatSet, percentageAllowance); 75 | 76 | // If in the case that all samples get trimmed, revert back to the previous calculated average minimum NS Mxumum. 77 | if (sampleFloatSet.Count > 0) 78 | { 79 | // Update the fpsMin & Max values since Dirty data has now been removed. 80 | FPSMinimum = sampleFloatSet.Min(); 81 | FPSMaximum = sampleFloatSet.Max(); 82 | } 83 | else 84 | { } 85 | } 86 | else 87 | newfPSAverage2 = fPSAverage; 88 | 89 | double sumOfSquaresOfDifferences2 = sampleFloatSet.Select(val => (val - newfPSAverage2) * (val - newfPSAverage2)).Sum(); 90 | standardDeviation2 = Math.Sqrt(sumOfSquaresOfDifferences2 / sampleFloatSet.Count); 91 | } 92 | 93 | if (writeToFile) 94 | sb.AppendLine(string.Format("FPS Stats: # Samples: {0}\tTime: {8}\tAve: {1}\tMin: {2}\tMax: {3}\tStdDev: {4}/{5:p2}\tDirtyData: {6}/{7:p2}", sampleFloatSet.Count, newfPSAverage2.ToString("f4"), (FPSMinimum < 100) ? FPSMinimum.ToString("f0") + " " : FPSMinimum.ToString("f0"), FPSMaximum.ToString("f0"), ((standardDeviation2 / newfPSAverage2) * newfPSAverage2).ToString("f2"), standardDeviation2 / newfPSAverage2, (TotalSamples == 0) ? " - " : (TotalSamples - sampleFloatSet.Count).ToString(), (TotalSamples == 0) ? " - " : ((double)(TotalSamples - sampleFloatSet.Count) / (double)TotalSamples).ToString("p2"), (timeInBeforeDirtyDataRemoved < 10.0) ? timeInBeforeDirtyDataRemoved.ToString("f3") : timeInBeforeDirtyDataRemoved.ToString("f2"))); 95 | 96 | return standardDeviation2; 97 | } 98 | private static double RemoveUpperLowerLimits(double fPSMinimum, double fPSMaximum, List sameplSet, double percentageAllowance) 99 | { 100 | double doubleAverage = 0.0; 101 | int previousCount = sameplSet.Count; 102 | var tempfPSAverage = sameplSet.Average(); 103 | 104 | // Ensure we only Trim Dirty Data that needs to be Max or min values. 105 | if (fPSMinimum < (tempfPSAverage * (1.0 - percentageAllowance))) // .7 106 | sameplSet.RemoveAll((e => e <= (fPSMinimum * 1.1))); 107 | if (fPSMaximum > (tempfPSAverage * (1.0 + percentageAllowance))) // 1.3 108 | sameplSet.RemoveAll((e => e >= (fPSMaximum * 0.9))); 109 | 110 | // After removing superfluious samples, ensure that we have any samples left to re-Calculate, otherwise return the first passed in average back since trimming removed all samples. 111 | if (sameplSet.Count == 0 || previousCount == sameplSet.Count) 112 | return tempfPSAverage; 113 | 114 | // Re-Evaluate the Minimum and Max values. 115 | var newfPSAverage = sameplSet.Average(); 116 | var newFPSMinimum = sameplSet.Min(); 117 | var newFPSMaximum = sameplSet.Max(); 118 | 119 | // .70 to 1.3 default values. 120 | if (newFPSMinimum < (newfPSAverage * (1.0 - percentageAllowance)) || newFPSMaximum > newfPSAverage * (1.0 + percentageAllowance)) 121 | doubleAverage = RemoveUpperLowerLimits(newFPSMinimum, newFPSMaximum, sameplSet, percentageAllowance); 122 | else 123 | return newfPSAverage; 124 | 125 | return doubleAverage; 126 | } 127 | public static void ShutDown() 128 | { 129 | int rampupIndexEnd = 1; 130 | float percentAllowance = 0.25f; 131 | double standardDeveiation, startDeviation; 132 | 133 | standardDeveiation = CalcualteFPSMetrics(SampleFloatSet.Skip(SampleFloatSet.Count / 2).Take((SampleFloatSet.Count / 2) - (int)(SampleFloatSet.Count * 0.1)).ToList(), false, true, 0.3); 134 | 135 | // Now loop through the SamepleSet and when the standard deviation is grater then the above, its still rampming up. 136 | for (int i = 1; i < SampleFloatSet.Count; i++) 137 | { 138 | // Isolate a sliding second for ramp analysis 139 | startDeviation = CalcualteFPSMetrics(SampleFloatSet.Skip(i - 1).Take(100).ToList(), false, true, percentAllowance); 140 | 141 | if (startDeviation <= (standardDeveiation * (1.0f + 0.05f))) // was 1.1 then 1.3 then percentAllowance. 142 | { 143 | rampupIndexEnd = i + 99;// - 1; 144 | break; 145 | } 146 | } 147 | 148 | // Reset the Total Count before writting any results. 149 | TotalSamples = 0; 150 | startDeviation = CalcualteFPSMetrics(SampleFloatSet.Take(rampupIndexEnd + 1).ToList(), true, false, 0.3); 151 | standardDeveiation = CalcualteFPSMetrics(SampleFloatSet.Skip(rampupIndexEnd).ToList(), true, true, 0.45); // was .5 152 | 153 | if (IsTimedTest) 154 | WriteFPSTest(); 155 | 156 | SampleFloatSet.Clear(); 157 | SampleFloatSet = null; 158 | sb.Clear(); 159 | sb = null; 160 | } 161 | } 162 | } -------------------------------------------------------------------------------- /OSLTT/DirectX/Font/Font.ps: -------------------------------------------------------------------------------- 1 | ////////////////////// 2 | //// GLOBALS 3 | ////////////////////// 4 | Texture2D shaderTexture; 5 | SamplerState SampleType; 6 | 7 | cbuffer PixelBuffer 8 | { 9 | float4 pixelColor; 10 | }; 11 | 12 | ////////////////////// 13 | //// TYPEDEFS 14 | ////////////////////// 15 | struct PixelInputType 16 | { 17 | float4 position : SV_POSITION; 18 | float2 tex : TEXCOORD0; 19 | }; 20 | 21 | ////////////////////// 22 | //// Pixel Shader 23 | ///////////////////// 24 | float4 FontPixelShader(PixelInputType input) : SV_TARGET 25 | { 26 | float4 color; 27 | 28 | // Sample the texture pixel at this location. 29 | color = shaderTexture.Sample(SampleType, input.tex); 30 | 31 | // If the color is black on the texture then this pixel as transparent. 32 | if(color.r == 0.0f) 33 | { 34 | color.a = 0.0f; 35 | } 36 | // If the color is other than black on the texture then this is a pixel in the font so draw it using the font pixel color. 37 | else 38 | { 39 | color.a = 1.0f; 40 | color = color * pixelColor; 41 | } 42 | 43 | return color; 44 | } 45 | -------------------------------------------------------------------------------- /OSLTT/DirectX/Font/Font.vs: -------------------------------------------------------------------------------- 1 | /////////////////////// 2 | //// GLOBALS 3 | /////////////////////// 4 | cbuffer PerFrameBuffer 5 | { 6 | matrix worldMatrix; 7 | matrix viewMatrix; 8 | matrix projectionMatrix; 9 | }; 10 | 11 | ////////////////////// 12 | //// TYPES 13 | ////////////////////// 14 | struct VertexInputType 15 | { 16 | float4 position : POSITION; 17 | float2 tex : TEXCOORD0; 18 | }; 19 | 20 | struct PixelInputType 21 | { 22 | float4 position : SV_POSITION; 23 | float2 tex : TEXCOORD0; 24 | }; 25 | 26 | ///////////////////////////////////// 27 | ///// Vertex Shader 28 | ///////////////////////////////////// 29 | PixelInputType FontVertexShader(VertexInputType input) 30 | { 31 | PixelInputType output; 32 | 33 | // Change the position vector to be 4 units for proper matrix calculations. 34 | input.position.w = 1.0f; 35 | 36 | // Calculate the position of the vertex against the world, view, and projection matrices. 37 | output.position = mul(input.position, worldMatrix); 38 | output.position = mul(output.position, viewMatrix); 39 | output.position = mul(output.position, projectionMatrix); 40 | 41 | // Store the texture coordinates for the pixel shader to use. 42 | output.tex = input.tex; 43 | 44 | return output; 45 | } -------------------------------------------------------------------------------- /OSLTT/DirectX/Font/font.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/DirectX/Font/font.bmp -------------------------------------------------------------------------------- /OSLTT/DirectX/Font/font01.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/DirectX/Font/font01.bmp -------------------------------------------------------------------------------- /OSLTT/DirectX/Font/font01.txt: -------------------------------------------------------------------------------- 1 | 32 0.0 0.0 0 2 | 33 ! 0.0 0.00390625 4 3 | 34 " 0.0048828125 0.0107421875 6 4 | 35 # 0.01171875 0.025390625 14 5 | 36 $ 0.0263671875 0.0390625 13 6 | 37 % 0.0400390625 0.0546875 15 7 | 38 & 0.0556640625 0.0693359375 14 8 | 39 ' 0.0703125 0.0732421875 3 9 | 40 ( 0.07421875 0.0791015625 5 10 | 41 ) 0.080078125 0.0849609375 5 11 | 42 * 0.0859375 0.091796875 6 12 | 43 + 0.0927734375 0.103515625 11 13 | 44 , 0.1044921875 0.107421875 3 14 | 45 - 0.1083984375 0.1142578125 6 15 | 46 . 0.115234375 0.1181640625 3 16 | 47 / 0.119140625 0.126953125 8 17 | 48 0 0.1279296875 0.1416015625 14 18 | 49 1 0.142578125 0.146484375 4 19 | 50 2 0.1474609375 0.1591796875 12 20 | 51 3 0.16015625 0.1708984375 11 21 | 52 4 0.171875 0.1845703125 13 22 | 53 5 0.185546875 0.1962890625 11 23 | 54 6 0.197265625 0.2099609375 13 24 | 55 7 0.2109375 0.22265625 12 25 | 56 8 0.2236328125 0.236328125 13 26 | 57 9 0.2373046875 0.2490234375 12 27 | 58 : 0.25 0.2529296875 3 28 | 59 ; 0.25390625 0.2568359375 3 29 | 60 < 0.2578125 0.267578125 10 30 | 61 = 0.2685546875 0.279296875 11 31 | 62 > 0.2802734375 0.2900390625 10 32 | 63 ? 0.291015625 0.302734375 12 33 | 64 @ 0.3037109375 0.3173828125 14 34 | 65 A 0.318359375 0.33203125 14 35 | 66 B 0.3330078125 0.3447265625 12 36 | 67 C 0.345703125 0.3564453125 11 37 | 68 D 0.357421875 0.3701171875 13 38 | 69 E 0.37109375 0.3818359375 11 39 | 70 F 0.3828125 0.3935546875 11 40 | 71 G 0.39453125 0.40625 12 41 | 72 H 0.4072265625 0.41796875 11 42 | 73 I 0.4189453125 0.421875 3 43 | 74 J 0.4228515625 0.4326171875 10 44 | 75 K 0.43359375 0.4443359375 11 45 | 76 L 0.4453125 0.4541015625 9 46 | 77 M 0.455078125 0.4697265625 15 47 | 78 N 0.470703125 0.482421875 12 48 | 79 O 0.4833984375 0.49609375 13 49 | 80 P 0.4970703125 0.5078125 12 50 | 81 Q 0.509765625 0.5224609375 13 51 | 82 R 0.5234375 0.53515625 12 52 | 83 S 0.5361328125 0.548828125 13 53 | 84 T 0.5498046875 0.5615234375 12 54 | 85 U 0.5625 0.57421875 12 55 | 86 V 0.5751953125 0.5888671875 14 56 | 87 W 0.58984375 0.609375 20 57 | 88 X 0.6103515625 0.6220703125 12 58 | 89 Y 0.623046875 0.6357421875 13 59 | 90 Z 0.63671875 0.6474609375 11 60 | 91 [ 0.6484375 0.654296875 6 61 | 92 \ 0.6552734375 0.6630859375 8 62 | 93 ] 0.6640625 0.6689453125 5 63 | 94 ^ 0.669921875 0.6806640625 11 64 | 95 _ 0.681640625 0.6904296875 9 65 | 96 ` 0.69140625 0.6962890625 5 66 | 97 a 0.697265625 0.70703125 10 67 | 98 b 0.7080078125 0.7177734375 10 68 | 99 c 0.71875 0.7275390625 9 69 | 100 d 0.728515625 0.73828125 10 70 | 101 e 0.7392578125 0.748046875 9 71 | 102 f 0.7490234375 0.755859375 7 72 | 103 g 0.7568359375 0.7666015625 10 73 | 104 h 0.767578125 0.7763671875 9 74 | 105 i 0.77734375 0.7802734375 3 75 | 106 j 0.78125 0.7861328125 5 76 | 107 k 0.787109375 0.796875 10 77 | 108 l 0.7978515625 0.80078125 3 78 | 109 m 0.8017578125 0.8154296875 14 79 | 110 n 0.81640625 0.826171875 10 80 | 111 o 0.8271484375 0.8369140625 10 81 | 112 p 0.837890625 0.84765625 10 82 | 113 q 0.8486328125 0.8583984375 10 83 | 114 r 0.859375 0.8671875 8 84 | 115 s 0.8681640625 0.8779296875 10 85 | 116 t 0.87890625 0.8857421875 7 86 | 117 u 0.88671875 0.8955078125 9 87 | 118 v 0.896484375 0.908203125 12 88 | 119 w 0.9091796875 0.9248046875 16 89 | 120 x 0.92578125 0.935546875 10 90 | 121 y 0.9365234375 0.9453125 9 91 | 122 z 0.9462890625 0.9560546875 10 92 | 123 { 0.95703125 0.9638671875 7 93 | 124 | 0.96484375 0.966796875 2 94 | 125 } 0.9677734375 0.974609375 7 95 | 126 ~ 0.9755859375 0.986328125 11 -------------------------------------------------------------------------------- /OSLTT/DirectX/Font/fontdata.txt: -------------------------------------------------------------------------------- 1 | 32 0.0 0.0 0 2 | 33 ! 0.0 0.000976563 1 3 | 34 " 0.00195313 0.00488281 3 4 | 35 # 0.00585938 0.0136719 8 5 | 36 $ 0.0146484 0.0195313 5 6 | 37 % 0.0205078 0.0302734 10 7 | 38 & 0.03125 0.0390625 8 8 | 39 ' 0.0400391 0.0410156 1 9 | 40 ( 0.0419922 0.0449219 3 10 | 41 ) 0.0458984 0.0488281 3 11 | 42 * 0.0498047 0.0546875 5 12 | 43 + 0.0556641 0.0625 7 13 | 44 , 0.0634766 0.0644531 1 14 | 45 - 0.0654297 0.0683594 3 15 | 46 . 0.0693359 0.0703125 1 16 | 47 / 0.0712891 0.0751953 4 17 | 48 0 0.0761719 0.0820313 6 18 | 49 1 0.0830078 0.0859375 3 19 | 50 2 0.0869141 0.0927734 6 20 | 51 3 0.09375 0.0996094 6 21 | 52 4 0.100586 0.106445 6 22 | 53 5 0.107422 0.113281 6 23 | 54 6 0.114258 0.120117 6 24 | 55 7 0.121094 0.126953 6 25 | 56 8 0.12793 0.133789 6 26 | 57 9 0.134766 0.140625 6 27 | 58 : 0.141602 0.142578 1 28 | 59 ; 0.143555 0.144531 1 29 | 60 < 0.145508 0.151367 6 30 | 61 = 0.152344 0.15918 7 31 | 62 > 0.160156 0.166016 6 32 | 63 ? 0.166992 0.171875 5 33 | 64 @ 0.172852 0.18457 12 34 | 65 A 0.185547 0.194336 9 35 | 66 B 0.195313 0.202148 7 36 | 67 C 0.203125 0.209961 7 37 | 68 D 0.210938 0.217773 7 38 | 69 E 0.21875 0.225586 7 39 | 70 F 0.226563 0.232422 6 40 | 71 G 0.233398 0.241211 8 41 | 72 H 0.242188 0.249023 7 42 | 73 I 0.25 0.250977 1 43 | 74 J 0.251953 0.256836 5 44 | 75 K 0.257813 0.265625 8 45 | 76 L 0.266602 0.272461 6 46 | 77 M 0.273438 0.282227 9 47 | 78 N 0.283203 0.290039 7 48 | 79 O 0.291016 0.298828 8 49 | 80 P 0.299805 0.306641 7 50 | 81 Q 0.307617 0.31543 8 51 | 82 R 0.316406 0.323242 7 52 | 83 S 0.324219 0.331055 7 53 | 84 T 0.332031 0.338867 7 54 | 85 U 0.339844 0.34668 7 55 | 86 V 0.347656 0.356445 9 56 | 87 W 0.357422 0.370117 13 57 | 88 X 0.371094 0.37793 7 58 | 89 Y 0.378906 0.385742 7 59 | 90 Z 0.386719 0.393555 7 60 | 91 [ 0.394531 0.396484 2 61 | 92 \ 0.397461 0.401367 4 62 | 93 ] 0.402344 0.404297 2 63 | 94 ^ 0.405273 0.410156 5 64 | 95 _ 0.411133 0.417969 7 65 | 96 ` 0.418945 0.420898 2 66 | 97 a 0.421875 0.426758 5 67 | 98 b 0.427734 0.432617 5 68 | 99 c 0.433594 0.438477 5 69 | 100 d 0.439453 0.444336 5 70 | 101 e 0.445313 0.450195 5 71 | 102 f 0.451172 0.455078 4 72 | 103 g 0.456055 0.460938 5 73 | 104 h 0.461914 0.466797 5 74 | 105 i 0.467773 0.46875 1 75 | 106 j 0.469727 0.472656 3 76 | 107 k 0.473633 0.478516 5 77 | 108 l 0.479492 0.480469 1 78 | 109 m 0.481445 0.490234 9 79 | 110 n 0.491211 0.496094 5 80 | 111 o 0.49707 0.501953 5 81 | 112 p 0.50293 0.507813 5 82 | 113 q 0.508789 0.513672 5 83 | 114 r 0.514648 0.517578 3 84 | 115 s 0.518555 0.523438 5 85 | 116 t 0.524414 0.527344 3 86 | 117 u 0.52832 0.533203 5 87 | 118 v 0.53418 0.539063 5 88 | 119 w 0.540039 0.548828 9 89 | 120 x 0.549805 0.554688 5 90 | 121 y 0.555664 0.560547 5 91 | 122 z 0.561523 0.566406 5 92 | 123 { 0.567383 0.570313 3 93 | 124 | 0.571289 0.572266 1 94 | 125 } 0.573242 0.576172 3 95 | 126 ~ 0.577148 0.583984 7 96 | -------------------------------------------------------------------------------- /OSLTT/DirectX/Graphics/DCameraClass.cs: -------------------------------------------------------------------------------- 1 | using SharpDX; 2 | 3 | namespace OSLTT.DirectX.Graphics 4 | { 5 | public class DCamera // 53 lines 6 | { 7 | // Properties. 8 | private float PositionX { get; set; } 9 | private float PositionY { get; set; } 10 | private float PositionZ { get; set; } 11 | private float RotationX { get; set; } 12 | private float RotationY { get; set; } 13 | private float RotationZ { get; set; } 14 | public Matrix ViewMatrix { get; private set; } 15 | 16 | // Constructor 17 | public DCamera() { } 18 | 19 | // Methods. 20 | public void SetPosition(float x, float y, float z) 21 | { 22 | PositionX = x; 23 | PositionY = y; 24 | PositionZ = z; 25 | } 26 | public void Render() 27 | { 28 | // Setup the position of the camera in the world. 29 | Vector3 position = new Vector3(PositionX, PositionY, PositionZ); 30 | 31 | // Setup where the camera is looking by default. 32 | Vector3 lookAt = new Vector3(0, 0, 1); 33 | 34 | // Set the yaw (Y axis), pitch (X axis), and roll (Z axis) rotations in radians. 35 | float pitch = RotationX * 0.0174532925f; 36 | float yaw = RotationY * 0.0174532925f; ; 37 | float roll = RotationZ * 0.0174532925f; ; 38 | 39 | // Create the rotation matrix from the yaw, pitch, and roll values. 40 | Matrix rotationMatrix = Matrix.RotationYawPitchRoll(yaw, pitch, roll); 41 | 42 | // Transform the lookAt and up vector by the rotation matrix so the view is correctly rotated at the origin. 43 | lookAt = Vector3.TransformCoordinate(lookAt, rotationMatrix); 44 | Vector3 up = Vector3.TransformCoordinate(Vector3.UnitY, rotationMatrix); 45 | 46 | // Translate the rotated camera position to the location of the viewer. 47 | lookAt = position + lookAt; 48 | 49 | // Finally create the view matrix from the three updated vectors. 50 | ViewMatrix = Matrix.LookAtLH(position, lookAt, up); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /OSLTT/DirectX/Graphics/DGraphicsClass.cs: -------------------------------------------------------------------------------- 1 | using OSLTT.DirectX.Graphics.TextFont; 2 | using OSLTT.DirectX.System; 3 | using System; 4 | using System.Windows.Forms; 5 | 6 | namespace OSLTT.DirectX.Graphics 7 | { 8 | public class DGraphics // 120 lines 9 | { 10 | // Properties 11 | private DDX11 D3D { get; set; } 12 | private DCamera Camera { get; set; } 13 | public DTextClass Text { get; set; } 14 | public DTimer Timer { get; set; } 15 | 16 | // Construtor 17 | public DGraphics() { } 18 | 19 | // Methods. 20 | public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle) 21 | { 22 | try 23 | { 24 | // Create the Direct3D object. 25 | D3D = new DDX11(); 26 | 27 | // Initialize the Direct3D object. 28 | if (!D3D.Initialize(configuration, windowHandle)) 29 | return false; 30 | 31 | // Create the Timer 32 | Timer = new DTimer(); 33 | 34 | // Initialize the Timer 35 | if (!Timer.Initialize()) 36 | return false; 37 | 38 | // Create the camera object 39 | Camera = new DCamera(); 40 | 41 | // Initialize a base view matrix the camera for 2D user interface rendering. 42 | Camera.SetPosition(0, 0, -1); 43 | Camera.Render(); 44 | var baseViewMatrix = Camera.ViewMatrix; 45 | 46 | // Create the text object. 47 | Text = new DTextClass(); 48 | if (!Text.Initialize(D3D.Device, D3D.DeviceContext, windowHandle, configuration.Width, configuration.Height, baseViewMatrix)) 49 | return false; 50 | 51 | return true; 52 | } 53 | catch (Exception ex) 54 | { 55 | MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); 56 | return false; 57 | } 58 | } 59 | public void Shutdown() 60 | { 61 | Timer = null; 62 | Camera = null; 63 | 64 | // Release the text object. 65 | Text?.Shutdown(); 66 | Text = null; 67 | // Release the Direct3D object. 68 | D3D?.ShutDown(); 69 | D3D = null; 70 | } 71 | public bool Frame(int fps = 0, int cpu = 0) 72 | { 73 | 74 | // Set the frames per second. 75 | if (!Text.SetFps(D3D.DeviceContext, fps)) 76 | return false; 77 | 78 | // Set the cpu usage. 79 | if (!Text.SetCpu(D3D.DeviceContext, cpu)) 80 | return false; 81 | 82 | // Set the position of the camera. 83 | Camera.SetPosition(0, 0, -10f); 84 | 85 | return true; 86 | } 87 | public bool Render(float RGB = 0.0f) 88 | { 89 | // Clear the buffer to begin the scene. 90 | D3D.BeginScene(RGB, RGB, RGB, 1f); 91 | 92 | // Generate the view matrix based on the camera position. 93 | Camera.Render(); 94 | 95 | // Get the world, view, and projection matrices from camera and d3d objects. 96 | var viewMatrix = Camera.ViewMatrix; 97 | var worldMatrix = D3D.WorldMatrix; 98 | var projectionMatrix = D3D.ProjectionMatrix; 99 | var orthoMatrix = D3D.OrthoMatrix; 100 | 101 | // Turn off the Z buffer to begin all 2D rendering. 102 | D3D.TurnZBufferOff(); 103 | 104 | // Turn on the alpha blending before rendering the text. 105 | D3D.TurnOnAlphaBlending(); 106 | 107 | // Render the text string. 108 | if (!Text.Render(D3D.DeviceContext, worldMatrix, orthoMatrix)) 109 | return false; 110 | 111 | // Turn off the alpha blending before rendering the text. 112 | D3D.TurnOffAlphaBlending(); 113 | 114 | // Turn on the Z buffer to begin all 2D rendering. 115 | D3D.TurnZBufferOn(); 116 | 117 | // Present the rendered scene to the screen. 118 | D3D.EndScene(); 119 | 120 | return true; 121 | } 122 | } 123 | } -------------------------------------------------------------------------------- /OSLTT/DirectX/Graphics/DTextureClass.cs: -------------------------------------------------------------------------------- 1 | using SharpDX.Direct3D11; 2 | using SharpDX.WIC; 3 | 4 | namespace OSLTT.DirectX.Graphics 5 | { 6 | public class DTexture // 31 lines 7 | { 8 | // Propertues 9 | public ShaderResourceView TextureResource { get; private set; } 10 | 11 | // Methods. 12 | public bool Initialize(Device device, string fileName) 13 | { 14 | try 15 | { 16 | using (var texture = LoadFromFile(device, new SharpDX.WIC.ImagingFactory(), fileName)) 17 | { 18 | ShaderResourceViewDescription srvDesc = new ShaderResourceViewDescription() 19 | { 20 | Format = texture.Description.Format, 21 | Dimension = SharpDX.Direct3D.ShaderResourceViewDimension.Texture2D, 22 | }; 23 | srvDesc.Texture2D.MostDetailedMip = 0; 24 | srvDesc.Texture2D.MipLevels = -1; 25 | 26 | TextureResource = new ShaderResourceView(device, texture, srvDesc); 27 | device.ImmediateContext.GenerateMips(TextureResource); 28 | } 29 | // TextureResource = ShaderResourceView.FromFile(device, fileName); 30 | return true; 31 | } 32 | catch 33 | { 34 | return false; 35 | } 36 | } 37 | public void ShutDown() 38 | { 39 | TextureResource?.Dispose(); 40 | TextureResource = null; 41 | } 42 | 43 | public Texture2D LoadFromFile(Device device, ImagingFactory factory, string fileName) 44 | { 45 | using (var bs = LoadBitmap(factory, fileName)) 46 | return CreateTexture2DFromBitmap(device, bs); 47 | } 48 | public BitmapSource LoadBitmap(ImagingFactory factory, string filename) 49 | { 50 | var bitmapDecoder = new SharpDX.WIC.BitmapDecoder( 51 | factory, 52 | filename, 53 | SharpDX.WIC.DecodeOptions.CacheOnDemand 54 | ); 55 | 56 | var result = new SharpDX.WIC.FormatConverter(factory); 57 | 58 | result.Initialize( 59 | bitmapDecoder.GetFrame(0), 60 | SharpDX.WIC.PixelFormat.Format32bppPRGBA, 61 | SharpDX.WIC.BitmapDitherType.None, 62 | null, 63 | 0.0, 64 | SharpDX.WIC.BitmapPaletteType.Custom); 65 | 66 | return result; 67 | } 68 | public Texture2D CreateTexture2DFromBitmap(Device device, BitmapSource bitmapSource) 69 | { 70 | // Allocate DataStream to receive the WIC image pixels 71 | int stride = bitmapSource.Size.Width * 4; 72 | using (var buffer = new SharpDX.DataStream(bitmapSource.Size.Height * stride, true, true)) 73 | { 74 | // Copy the content of the WIC to the buffer 75 | bitmapSource.CopyPixels(stride, buffer); 76 | return new SharpDX.Direct3D11.Texture2D(device, new SharpDX.Direct3D11.Texture2DDescription() 77 | { 78 | Width = bitmapSource.Size.Width, 79 | Height = bitmapSource.Size.Height, 80 | ArraySize = 1, 81 | BindFlags = SharpDX.Direct3D11.BindFlags.ShaderResource | BindFlags.RenderTarget, 82 | Usage = SharpDX.Direct3D11.ResourceUsage.Default, 83 | CpuAccessFlags = SharpDX.Direct3D11.CpuAccessFlags.None, 84 | Format = SharpDX.DXGI.Format.R8G8B8A8_UNorm, 85 | MipLevels = 1, 86 | OptionFlags = ResourceOptionFlags.GenerateMipMaps, // ResourceOptionFlags.GenerateMipMap 87 | SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0), 88 | }, new SharpDX.DataRectangle(buffer.DataPointer, stride)); 89 | } 90 | } 91 | } 92 | } -------------------------------------------------------------------------------- /OSLTT/DirectX/Graphics/TextFont/DFontClass.cs: -------------------------------------------------------------------------------- 1 | using OSLTT.DirectX.System; 2 | using SharpDX; 3 | using SharpDX.Direct3D11; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Runtime.InteropServices; 8 | 9 | namespace OSLTT.DirectX.Graphics.TextFont 10 | { 11 | public class DFont // 179 lines 12 | { 13 | // Structs 14 | [StructLayout(LayoutKind.Sequential)] 15 | public struct DCharacter 16 | { 17 | // Variables. 18 | public float left, right; 19 | public int size; 20 | 21 | // Constructor 22 | public DCharacter(string fontData) 23 | { 24 | var data = fontData.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); 25 | left = float.Parse(data[data.Length - 3]); 26 | right = float.Parse(data[data.Length - 2]); 27 | size = int.Parse(data[data.Length - 1]); 28 | } 29 | } 30 | 31 | // Properties. 32 | public List FontCharacters { get; private set; } 33 | public DTexture Texture { get; private set; } 34 | 35 | // Methods 36 | public bool Initialize(Device device, string fontFileName, string textureFileName) 37 | { 38 | // Load in the text file containing the font data. 39 | if (!LoadFontData(fontFileName)) 40 | return false; 41 | 42 | // Load the texture that has font characters on it. 43 | if (!LoadTexture(device, textureFileName)) 44 | return false; 45 | 46 | return true; 47 | } 48 | public void Shutdown() 49 | { 50 | // Release the font texture. 51 | ReleaseTexture(); 52 | 53 | // Release the font data. 54 | ReleaseFontData(); 55 | } 56 | private bool LoadFontData(string fontFileName) 57 | { 58 | try 59 | { 60 | fontFileName = DSystemConfiguration.FontFilePath + fontFileName; 61 | 62 | // Get all the lines containing the font data. 63 | var fontDataLines = File.ReadAllLines(fontFileName); 64 | 65 | // Create Font and fill with characters. 66 | FontCharacters = new List(); 67 | foreach (var line in fontDataLines) 68 | FontCharacters.Add(new DCharacter(line)); 69 | 70 | return true; 71 | } 72 | catch (Exception ex) 73 | { 74 | Console.WriteLine(ex.Message + ex.StackTrace); 75 | return false; 76 | } 77 | } 78 | private void ReleaseFontData() 79 | { 80 | // Release the font data array. 81 | FontCharacters?.Clear(); 82 | FontCharacters = null; 83 | } 84 | private bool LoadTexture(Device device, string textureFileName) 85 | { 86 | textureFileName = DSystemConfiguration.FontFilePath + textureFileName; 87 | 88 | // Create new texture object. 89 | Texture = new DTexture(); 90 | 91 | // Initialize the texture object. 92 | if (!Texture.Initialize(device, textureFileName)) 93 | return false; 94 | 95 | return true; 96 | } 97 | private void ReleaseTexture() 98 | { 99 | // Release the texture object. 100 | Texture?.ShutDown(); 101 | Texture = null; 102 | } 103 | public void BuildVertexArray(out List vertices, string sentence, float drawX, float drawY) 104 | { 105 | // Create list of the vertices 106 | vertices = new List(); 107 | 108 | // Draw each letter onto a quad. 109 | foreach (char ch in sentence) 110 | { 111 | var letter = ch - 32; 112 | 113 | // If the letter is a space then just move over three pixel. 114 | if (letter == 0) 115 | drawX += 3; 116 | else 117 | { 118 | // Add quad vertices for the character. 119 | BuildVertexArray(vertices, letter, ref drawX, ref drawY); 120 | 121 | // Update the x location for drawing be the size of the letter and one pixel. 122 | drawX += FontCharacters[letter].size + 1; 123 | } 124 | } 125 | } 126 | private void BuildVertexArray(List vertices, int letter, ref float drawX, ref float drawY) 127 | { 128 | // First triangle in the quad 129 | vertices.Add // Top left. 130 | ( 131 | new DTextClass.DVertex() 132 | { 133 | position = new Vector3(drawX, drawY, 0), 134 | texture = new Vector2(FontCharacters[letter].left, 0) 135 | } 136 | ); 137 | vertices.Add // Bottom right. 138 | ( 139 | new DTextClass.DVertex() 140 | { 141 | position = new Vector3(drawX + FontCharacters[letter].size, drawY - 16, 0), 142 | texture = new Vector2(FontCharacters[letter].right, 1) 143 | } 144 | ); 145 | vertices.Add // Bottom left. 146 | ( 147 | new DTextClass.DVertex() 148 | { 149 | position = new Vector3(drawX, drawY - 16, 0), 150 | texture = new Vector2(FontCharacters[letter].left, 1) 151 | } 152 | ); 153 | // Second triangle in quad. 154 | vertices.Add // Top left. 155 | ( 156 | new DTextClass.DVertex() 157 | { 158 | position = new Vector3(drawX, drawY, 0), 159 | texture = new Vector2(FontCharacters[letter].left, 0) 160 | } 161 | ); 162 | vertices.Add // Top right. 163 | ( 164 | new DTextClass.DVertex() 165 | { 166 | position = new Vector3(drawX + FontCharacters[letter].size, drawY, 0), 167 | texture = new Vector2(FontCharacters[letter].right, 0) 168 | } 169 | ); 170 | vertices.Add // Bottom right. 171 | ( 172 | new DTextClass.DVertex() 173 | { 174 | position = new Vector3(drawX + FontCharacters[letter].size, drawY - 16, 0), 175 | texture = new Vector2(FontCharacters[letter].right, 1) 176 | } 177 | ); 178 | } 179 | } 180 | } -------------------------------------------------------------------------------- /OSLTT/DirectX/Input/DInputClass.cs: -------------------------------------------------------------------------------- 1 | using OSLTT.DirectX.System; 2 | using SharpDX; 3 | using SharpDX.DirectInput; 4 | using System; 5 | 6 | namespace OSLTT.DirectX.Input 7 | { 8 | public class DInput // 212 lines 9 | { 10 | // Variables & Properties. 11 | public KeyboardState _KeyboardState; 12 | public MouseState _MouseState; 13 | 14 | // Properties 15 | public DirectInput _DirectInput { get; set; } 16 | public Keyboard _Keyboard { get; set; } 17 | public Mouse _Mouse { get; set; } 18 | public int _ScreenWidth { get; set; } 19 | public int _ScreenHeight { get; set; } 20 | public int _MouseX { get; set; } 21 | public int _MouseY { get; set; } 22 | public string PressedKeys { get; set; } 23 | 24 | // Methods. 25 | internal bool Initialize(DSystemConfiguration configuration, IntPtr windowsHandle) 26 | { 27 | // Screen the screen size which will be used for positioning the mouse cursor. 28 | _ScreenWidth = configuration.Width; 29 | _ScreenHeight = configuration.Height; 30 | 31 | // Initialize the location of the mouse on the screen. 32 | _MouseX = 0; 33 | _MouseY = 0; 34 | 35 | // Initialize the main direct input interface. 36 | _DirectInput = new DirectInput(); 37 | 38 | #region Keyboard related Initiailization 39 | // Initialize the direct interface for the keyboard. 40 | _Keyboard = new Keyboard(_DirectInput); 41 | _Keyboard.Properties.BufferSize = 256; 42 | 43 | // Set the cooperative level of the keyboard to not share with other programs. 44 | // use 'CooperativeLevel.Background' for debugging purpose on Both the Mouse and Keyboard as well as NonExclusive on the keybaord. 45 | _Keyboard.SetCooperativeLevel(windowsHandle, CooperativeLevel.Background | CooperativeLevel.NonExclusive); 46 | 47 | try 48 | { 49 | _Keyboard.Acquire(); 50 | } 51 | catch (SharpDXException sEx) 52 | { 53 | if (sEx.ResultCode.Failure) 54 | return false; 55 | } 56 | #endregion 57 | 58 | #region Mouse related Initiailization 59 | // Initialize the direct interface for the mouse. 60 | _Mouse = new Mouse(_DirectInput); 61 | _Mouse.Properties.AxisMode = DeviceAxisMode.Relative; 62 | 63 | // Set the cooperative level of the mouse to share with other programs. 64 | _Mouse.SetCooperativeLevel(windowsHandle, CooperativeLevel.Foreground | CooperativeLevel.NonExclusive); 65 | 66 | try 67 | { 68 | _Mouse.Acquire(); 69 | } 70 | catch (SharpDXException sEx) 71 | { 72 | if (sEx.ResultCode.Failure) 73 | return false; 74 | } 75 | #endregion 76 | 77 | return true; 78 | } 79 | // Added this function in Turoail 13. 80 | public void Shutdown() 81 | { 82 | // Release the mouse. 83 | _Mouse?.Unacquire(); 84 | _Mouse?.Dispose(); 85 | _Mouse = null; 86 | // Release the keyboard. 87 | _Keyboard?.Unacquire(); 88 | _Keyboard?.Dispose(); 89 | _Keyboard = null; 90 | // Release the main interface to direct input. 91 | _DirectInput?.Dispose(); 92 | _DirectInput = null; 93 | } 94 | public bool Frame() 95 | { 96 | PressedKeys = ""; 97 | // Read the current state of the keyboard. 98 | if (!ReadKeyboard()) 99 | return false; 100 | //ReadKeyboard(); 101 | //ReadMouse(); 102 | // Read the current state of the mouse. 103 | if (!ReadMouse()) 104 | return false; 105 | 106 | // Process the changes in the mouse and keyboard. 107 | //ProcessInput(); 108 | 109 | return true; 110 | } 111 | private bool ReadKeyboard() 112 | { 113 | var resultCode = ResultCode.Ok; 114 | _KeyboardState = new KeyboardState(); 115 | 116 | try 117 | { 118 | // Read the keyboard device. 119 | _Keyboard.Poll(); 120 | _Keyboard.GetCurrentState(ref _KeyboardState); 121 | /*foreach (Key k in _KeyboardState.PressedKeys) 122 | { 123 | // Pressed Keys should be reset per frame in theory. In practice this is better. 124 | // This will only output a single key (i.e no rollover support.) 125 | PressedKeys = k.ToString(); 126 | Console.WriteLine(k); 127 | }*/ 128 | } 129 | catch (SharpDX.SharpDXException ex) 130 | { 131 | resultCode = ex.Descriptor; // ex.ResultCode; 132 | return false; 133 | } 134 | //catch (Exception) 135 | //{ 136 | // return false; 137 | //} 138 | 139 | // Error usually occurs when mouse pointer is off the window and pressed. Short dircuit re aquisition of the mouse when the Mouse cursor if off the Windows. 140 | //if (DSystem.IsMouseOffScreen) 141 | // return true; 142 | 143 | // If the keyboard lost focus or was not acquired then try to get control back. 144 | if (resultCode == ResultCode.InputLost || resultCode == ResultCode.NotAcquired) 145 | _Keyboard.Acquire(); 146 | else if (resultCode != ResultCode.Ok) 147 | return false; 148 | 149 | return true; 150 | } 151 | private bool ReadMouse() 152 | { 153 | var resultCode = ResultCode.Ok; 154 | 155 | _MouseState = new MouseState(); 156 | try 157 | { 158 | // Read the mouse device. 159 | _Mouse.GetCurrentState(ref _MouseState); 160 | if (_MouseState.Buttons[1]) 161 | { 162 | PressedKeys = "RightMouseButton"; 163 | } 164 | if (_MouseState.Buttons[0]) 165 | { 166 | PressedKeys = "LeftMouseButton"; 167 | } 168 | } 169 | catch (SharpDX.SharpDXException ex) 170 | { 171 | // Error usually occurs when mouse pointer is off the window and pressed. Short dircuit re aquisition of the mouse when the Mouse cursor if off the Windows. 172 | if (DSystem.IsMouseOffScreen) 173 | return true; 174 | 175 | resultCode = ex.Descriptor; // ex.ResultCode; 176 | 177 | if (ex.ResultCode.Failure) 178 | { 179 | if (ex.ResultCode == ResultCode.InputLost || ex.ResultCode == ResultCode.NotAcquired) 180 | { 181 | // If the mouse lost focus or was not acquired then try to get control back. 182 | try 183 | { 184 | _Mouse.Acquire(); 185 | } 186 | catch (SharpDX.SharpDXException exc) 187 | { 188 | 189 | } 190 | } 191 | else 192 | return false; 193 | } 194 | } 195 | catch (Exception) 196 | { 197 | return false; 198 | } 199 | 200 | // If the keyboard lost focus or was not acquired then try to get control back. 201 | /*if (resultCode == ResultCode.InputLost || resultCode == ResultCode.NotAcquired) 202 | _Mouse.Acquire(); 203 | else if (resultCode != ResultCode.Ok) 204 | return false;*/ 205 | 206 | return true; 207 | } 208 | private void ProcessInput() 209 | { 210 | if (_MouseState != null) 211 | { 212 | _MouseX += _MouseState.X; 213 | _MouseY += _MouseState.Y; 214 | } 215 | 216 | // Ensure the mouse location doesn't exceed the screen width or height. 217 | if (_MouseX < 0) 218 | _MouseX = 0; 219 | if (_MouseY < 0) 220 | _MouseY = 0; 221 | 222 | if (_MouseX > _ScreenWidth) 223 | _MouseX = _ScreenWidth; 224 | if (_MouseY > _ScreenHeight) 225 | _MouseY = _ScreenHeight; 226 | } 227 | public bool IsEscapePressed() 228 | { 229 | // Do a bitwise and on the keyboard state to check if the escape key is currently being pressed. 230 | return _KeyboardState != null && _KeyboardState.PressedKeys.Contains(Key.Escape); 231 | } 232 | public void GetMouseLocation(out int mouseX, out int mouseY) 233 | { 234 | mouseX = _MouseX; 235 | mouseY = _MouseY; 236 | } 237 | 238 | } 239 | } -------------------------------------------------------------------------------- /OSLTT/DirectX/System/DCPUClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | 4 | namespace OSLTT.DirectX.System 5 | { 6 | public class DCPU // 60 lines 7 | { 8 | // Variables 9 | private bool _CanReadCPU; 10 | private PerformanceCounter counter; 11 | private TimeSpan _LastSampleTime; 12 | private long _CpuUsage; 13 | 14 | // Properties 15 | public int Value { get { return _CanReadCPU ? (int)_CpuUsage : 0; } } 16 | 17 | // Public Methods. 18 | public void Initialize() 19 | { 20 | // Initialize the flag indicating whether this object can read the system cpu usage or not. 21 | _CanReadCPU = true; 22 | 23 | try 24 | { 25 | // Create performance counter. 26 | counter = new PerformanceCounter(); 27 | counter.CategoryName = "Processor"; 28 | counter.CounterName = "% Processor Time"; 29 | counter.InstanceName = "_Total"; 30 | 31 | _LastSampleTime = DateTime.Now.TimeOfDay; 32 | 33 | _CpuUsage = 0; 34 | } 35 | catch 36 | { 37 | _CanReadCPU = false; 38 | } 39 | } 40 | 41 | public void Shutdown() 42 | { 43 | if (_CanReadCPU) 44 | counter.Close(); 45 | } 46 | public void Frame() 47 | { 48 | if (_CanReadCPU) 49 | { 50 | int secondsElapsed = (DateTime.Now.TimeOfDay - _LastSampleTime).Seconds; 51 | 52 | if (secondsElapsed >= 1) 53 | { 54 | _LastSampleTime = DateTime.Now.TimeOfDay; 55 | _CpuUsage = (int)counter.NextValue(); 56 | } 57 | } 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /OSLTT/DirectX/System/DFPSClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace OSLTT.DirectX.System 4 | { 5 | public class DFPS // 43 lines 6 | { 7 | // Variables 8 | private int _Count; 9 | private TimeSpan _StartTime; 10 | 11 | // Propertues 12 | public int Value { get; private set; } 13 | 14 | // Public methods 15 | public void Initialize() 16 | { 17 | Value = 0; 18 | _Count = 0; 19 | _StartTime = DateTime.Now.TimeOfDay; 20 | } 21 | public void Frame() 22 | { 23 | // Increment the number of frames passed this second. 24 | _Count++; 25 | 26 | // Determine if a second has passed since the last update of FPS. 27 | int secondsPassed = (DateTime.Now.TimeOfDay - _StartTime).Seconds; 28 | 29 | // When a second has elasped perform the following. 30 | if (secondsPassed >= 1) 31 | { 32 | // Assign the counted frames that poassed during this second to the 'Value' property 33 | Value = _Count; 34 | 35 | // Reset the '_Count' variable to 0 to begin counting frames for the NEXT second 36 | _Count = 0; 37 | 38 | // Rreset '_StartTime' to current time for this next Frame. 39 | _StartTime = DateTime.Now.TimeOfDay; 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /OSLTT/DirectX/System/DSystemConfigurationClass.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Forms; 2 | 3 | namespace OSLTT.DirectX.System 4 | { 5 | public class DSystemConfiguration // 52 lines 6 | { 7 | // Properties 8 | public string Title { get; set; } 9 | public int Width { get; set; } 10 | public int Height { get; set; } 11 | 12 | // Static Variables. 13 | public static bool FullScreen { get; private set; } 14 | public static bool VerticalSyncEnabled { get; private set; } 15 | public static float ScreenDepth { get; private set; } 16 | public static float ScreenNear { get; private set; } 17 | public static FormBorderStyle BorderStyle { get; private set; } 18 | public static string FontFilePath { get; private set; } 19 | 20 | // Constructors 21 | public DSystemConfiguration(bool fullScreen, bool vSync) : this("SharpDX Demo", fullScreen, vSync) { } 22 | public DSystemConfiguration(string title, bool fullScreen, bool vSync) : this(title, 800, 600, fullScreen, vSync) { } 23 | public DSystemConfiguration(string title, int width, int height, bool fullScreen, bool vSync, int display = 0) 24 | { 25 | FullScreen = fullScreen; 26 | Title = title; 27 | VerticalSyncEnabled = vSync; 28 | 29 | if (!FullScreen) 30 | { 31 | Width = width; 32 | Height = height; 33 | } 34 | else 35 | { 36 | Screen[] screens = Screen.AllScreens; 37 | Width = screens[display].Bounds.Width; 38 | Height = screens[display].Bounds.Height; 39 | } 40 | } 41 | 42 | // Static Constructor 43 | static DSystemConfiguration() 44 | { 45 | FullScreen = false; 46 | VerticalSyncEnabled = false; 47 | ScreenDepth = 1000.0f; 48 | ScreenNear = 0.1f; 49 | BorderStyle = FormBorderStyle.None; 50 | 51 | FontFilePath = @"DirectX\Font\"; 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /OSLTT/DirectX/System/DTimerClass.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics; 2 | 3 | namespace OSLTT.DirectX.System 4 | { 5 | public class DTimer // 47 lines 6 | { 7 | // Variables 8 | private Stopwatch _StopWatch; 9 | private float m_ticksPerMs; 10 | private long m_LastFrameTime = 0; 11 | 12 | // Properties 13 | public float FrameTime { get; private set; } 14 | public float CumulativeFrameTime { get; private set; } 15 | 16 | // Public Methods 17 | public bool Initialize() 18 | { 19 | // Check to see if this system supports high performance timers. 20 | if (!Stopwatch.IsHighResolution) 21 | return false; 22 | if (Stopwatch.Frequency == 0) 23 | return false; 24 | 25 | // Find out how many times the frequency counter ticks every millisecond. 26 | m_ticksPerMs = (float)(Stopwatch.Frequency / 1000.0f); 27 | 28 | _StopWatch = Stopwatch.StartNew(); 29 | return true; 30 | } 31 | public void Frame2() 32 | { 33 | // Query the current time. 34 | long currentTime = _StopWatch.ElapsedTicks; 35 | 36 | // Calculate the difference in time since the last time we queried for the current time. 37 | float timeDifference = currentTime - m_LastFrameTime; 38 | 39 | // Calculate the frame time by the time difference over the timer speed resolution. 40 | FrameTime = timeDifference / m_ticksPerMs; 41 | CumulativeFrameTime += FrameTime; 42 | 43 | // record this Frames durations to the LastFrame for next frame processing. 44 | m_LastFrameTime = currentTime; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /OSLTT/MouseHook/MouseHook.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Diagnostics; 4 | 5 | namespace OSLTT 6 | { 7 | // Source - https://github.com/rvknth043/Global-Low-Level-Key-Board-And-Mouse-Hook 8 | /// 9 | /// Class for intercepting low level Windows mouse hooks. 10 | /// 11 | class MouseHook 12 | { 13 | /// 14 | /// Internal callback processing function 15 | /// 16 | private delegate IntPtr MouseHookHandler(int nCode, IntPtr wParam, IntPtr lParam); 17 | private MouseHookHandler hookHandler; 18 | 19 | /// 20 | /// Function to be called when defined even occurs 21 | /// 22 | /// MSLLHOOKSTRUCT mouse structure 23 | public delegate void MouseHookCallback(MSLLHOOKSTRUCT mouseStruct); 24 | 25 | #region Events 26 | public event MouseHookCallback LeftButtonDown; 27 | public event MouseHookCallback LeftButtonUp; 28 | public event MouseHookCallback RightButtonDown; 29 | public event MouseHookCallback RightButtonUp; 30 | public event MouseHookCallback MouseMove; 31 | public event MouseHookCallback MouseWheel; 32 | public event MouseHookCallback DoubleClick; 33 | public event MouseHookCallback MiddleButtonDown; 34 | public event MouseHookCallback MiddleButtonUp; 35 | #endregion 36 | 37 | /// 38 | /// Low level mouse hook's ID 39 | /// 40 | private IntPtr hookID = IntPtr.Zero; 41 | 42 | /// 43 | /// Install low level mouse hook 44 | /// 45 | /// Callback function 46 | public void Install() 47 | { 48 | try 49 | { 50 | hookHandler = HookFunc; 51 | hookID = SetHook(hookHandler); 52 | } 53 | catch { } 54 | } 55 | 56 | /// 57 | /// Remove low level mouse hook 58 | /// 59 | public void Uninstall() 60 | { 61 | if (hookID == IntPtr.Zero) 62 | return; 63 | 64 | UnhookWindowsHookEx(hookID); 65 | hookID = IntPtr.Zero; 66 | } 67 | 68 | /// 69 | /// Destructor. Unhook current hook 70 | /// 71 | ~MouseHook() 72 | { 73 | Uninstall(); 74 | } 75 | 76 | /// 77 | /// Sets hook and assigns its ID for tracking 78 | /// 79 | /// Internal callback function 80 | /// Hook ID 81 | private IntPtr SetHook(MouseHookHandler proc) 82 | { 83 | using (ProcessModule module = Process.GetCurrentProcess().MainModule) 84 | return SetWindowsHookEx(WH_MOUSE_LL, proc, GetModuleHandle(module.ModuleName), 0); 85 | } 86 | 87 | /// 88 | /// Callback function 89 | /// 90 | private IntPtr HookFunc(int nCode, IntPtr wParam, IntPtr lParam) 91 | { 92 | // parse system messages 93 | if (nCode >= 0) 94 | { 95 | if (MouseMessages.WM_LBUTTONDOWN == (MouseMessages)wParam) 96 | if (LeftButtonDown != null) 97 | LeftButtonDown((MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); 98 | if (MouseMessages.WM_LBUTTONUP == (MouseMessages)wParam) 99 | if (LeftButtonUp != null) 100 | LeftButtonUp((MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); 101 | if (MouseMessages.WM_RBUTTONDOWN == (MouseMessages)wParam) 102 | if (RightButtonDown != null) 103 | RightButtonDown((MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); 104 | if (MouseMessages.WM_RBUTTONUP == (MouseMessages)wParam) 105 | if (RightButtonUp != null) 106 | RightButtonUp((MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); 107 | if (MouseMessages.WM_MOUSEMOVE == (MouseMessages)wParam) 108 | if (MouseMove != null) 109 | MouseMove((MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); 110 | if (MouseMessages.WM_MOUSEWHEEL == (MouseMessages)wParam) 111 | if (MouseWheel != null) 112 | MouseWheel((MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); 113 | if (MouseMessages.WM_LBUTTONDBLCLK == (MouseMessages)wParam) 114 | if (DoubleClick != null) 115 | DoubleClick((MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); 116 | if (MouseMessages.WM_MBUTTONDOWN == (MouseMessages)wParam) 117 | if (MiddleButtonDown != null) 118 | MiddleButtonDown((MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); 119 | if (MouseMessages.WM_MBUTTONUP == (MouseMessages)wParam) 120 | if (MiddleButtonUp != null) 121 | MiddleButtonUp((MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT))); 122 | } 123 | return CallNextHookEx(hookID, nCode, wParam, lParam); 124 | } 125 | 126 | #region WinAPI 127 | private const int WH_MOUSE_LL = 14; 128 | 129 | private enum MouseMessages 130 | { 131 | WM_LBUTTONDOWN = 0x0201, 132 | WM_LBUTTONUP = 0x0202, 133 | WM_MOUSEMOVE = 0x0200, 134 | WM_MOUSEWHEEL = 0x020A, 135 | WM_RBUTTONDOWN = 0x0204, 136 | WM_RBUTTONUP = 0x0205, 137 | WM_LBUTTONDBLCLK = 0x0203, 138 | WM_MBUTTONDOWN = 0x0207, 139 | WM_MBUTTONUP = 0x0208 140 | } 141 | 142 | [StructLayout(LayoutKind.Sequential)] 143 | public struct POINT 144 | { 145 | public int x; 146 | public int y; 147 | } 148 | 149 | [StructLayout(LayoutKind.Sequential)] 150 | public struct MSLLHOOKSTRUCT 151 | { 152 | public POINT pt; 153 | public uint mouseData; 154 | public uint flags; 155 | public uint time; 156 | public IntPtr dwExtraInfo; 157 | } 158 | 159 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] 160 | private static extern IntPtr SetWindowsHookEx(int idHook, 161 | MouseHookHandler lpfn, IntPtr hMod, uint dwThreadId); 162 | 163 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] 164 | [return: MarshalAs(UnmanagedType.Bool)] 165 | public static extern bool UnhookWindowsHookEx(IntPtr hhk); 166 | 167 | [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)] 168 | private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam); 169 | 170 | [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)] 171 | private static extern IntPtr GetModuleHandle(string lpModuleName); 172 | #endregion 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /OSLTT/OSLTT.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.32126.315 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OSLTT", "OSLTT.csproj", "{6B68DB4A-CC69-4B5B-89FF-6D9F7A872517}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {6B68DB4A-CC69-4B5B-89FF-6D9F7A872517}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {6B68DB4A-CC69-4B5B-89FF-6D9F7A872517}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {6B68DB4A-CC69-4B5B-89FF-6D9F7A872517}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {6B68DB4A-CC69-4B5B-89FF-6D9F7A872517}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {09D9388B-1B18-4618-8337-555CB567004B} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /OSLTT/OSLTTTone.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/OSLTTTone.wav -------------------------------------------------------------------------------- /OSLTT/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace OSLTT 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new Main()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /OSLTT/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("OSLTT")] 9 | [assembly: AssemblyDescription("Desktop App for the Open Source Latency Testing Tool")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("TechteamGB")] 12 | [assembly: AssemblyProduct("OSLTT")] 13 | [assembly: AssemblyCopyright("Andrew McDonald © 2024")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("6b68db4a-cc69-4b5b-89ff-6d9f7a872517")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.7.0.0")] 36 | [assembly: AssemblyFileVersion("1.7.0.0")] 37 | -------------------------------------------------------------------------------- /OSLTT/Properties/Resources.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace OSLTT.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("OSLTT.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | 63 | /// 64 | /// Looks up a localized resource of type System.Drawing.Bitmap. 65 | /// 66 | internal static System.Drawing.Bitmap arrow_rotate_right { 67 | get { 68 | object obj = ResourceManager.GetObject("arrow_rotate_right", resourceCulture); 69 | return ((System.Drawing.Bitmap)(obj)); 70 | } 71 | } 72 | 73 | /// 74 | /// Looks up a localized resource of type System.Drawing.Bitmap. 75 | /// 76 | internal static System.Drawing.Bitmap bug_solid { 77 | get { 78 | object obj = ResourceManager.GetObject("bug-solid", resourceCulture); 79 | return ((System.Drawing.Bitmap)(obj)); 80 | } 81 | } 82 | 83 | /// 84 | /// Looks up a localized resource of type System.Drawing.Bitmap. 85 | /// 86 | internal static System.Drawing.Bitmap chart_bar_solid { 87 | get { 88 | object obj = ResourceManager.GetObject("chart-bar-solid", resourceCulture); 89 | return ((System.Drawing.Bitmap)(obj)); 90 | } 91 | } 92 | 93 | /// 94 | /// Looks up a localized resource of type System.Drawing.Bitmap. 95 | /// 96 | internal static System.Drawing.Bitmap check { 97 | get { 98 | object obj = ResourceManager.GetObject("check", resourceCulture); 99 | return ((System.Drawing.Bitmap)(obj)); 100 | } 101 | } 102 | 103 | /// 104 | /// Looks up a localized resource of type System.Drawing.Bitmap. 105 | /// 106 | internal static System.Drawing.Bitmap circle_question_solid { 107 | get { 108 | object obj = ResourceManager.GetObject("circle-question-solid", resourceCulture); 109 | return ((System.Drawing.Bitmap)(obj)); 110 | } 111 | } 112 | 113 | /// 114 | /// Looks up a localized resource of type System.Drawing.Bitmap. 115 | /// 116 | internal static System.Drawing.Bitmap computer_mouse_solid { 117 | get { 118 | object obj = ResourceManager.GetObject("computer-mouse-solid", resourceCulture); 119 | return ((System.Drawing.Bitmap)(obj)); 120 | } 121 | } 122 | 123 | /// 124 | /// Looks up a localized resource of type System.Drawing.Bitmap. 125 | /// 126 | internal static System.Drawing.Bitmap desktop_solid { 127 | get { 128 | object obj = ResourceManager.GetObject("desktop-solid", resourceCulture); 129 | return ((System.Drawing.Bitmap)(obj)); 130 | } 131 | } 132 | 133 | /// 134 | /// Looks up a localized resource of type System.Drawing.Bitmap. 135 | /// 136 | internal static System.Drawing.Bitmap folder_solid { 137 | get { 138 | object obj = ResourceManager.GetObject("folder_solid", resourceCulture); 139 | return ((System.Drawing.Bitmap)(obj)); 140 | } 141 | } 142 | 143 | /// 144 | /// Looks up a localized resource of type System.Drawing.Bitmap. 145 | /// 146 | internal static System.Drawing.Bitmap gamepad_solid { 147 | get { 148 | object obj = ResourceManager.GetObject("gamepad-solid", resourceCulture); 149 | return ((System.Drawing.Bitmap)(obj)); 150 | } 151 | } 152 | 153 | /// 154 | /// Looks up a localized resource of type System.Drawing.Bitmap. 155 | /// 156 | internal static System.Drawing.Bitmap gear_solid { 157 | get { 158 | object obj = ResourceManager.GetObject("gear_solid", resourceCulture); 159 | return ((System.Drawing.Bitmap)(obj)); 160 | } 161 | } 162 | 163 | /// 164 | /// Looks up a localized resource of type System.Drawing.Bitmap. 165 | /// 166 | internal static System.Drawing.Bitmap headset_solid { 167 | get { 168 | object obj = ResourceManager.GetObject("headset-solid", resourceCulture); 169 | return ((System.Drawing.Bitmap)(obj)); 170 | } 171 | } 172 | 173 | /// 174 | /// Looks up a localized resource of type System.Drawing.Bitmap. 175 | /// 176 | internal static System.Drawing.Bitmap keyboard_solid { 177 | get { 178 | object obj = ResourceManager.GetObject("keyboard_solid", resourceCulture); 179 | return ((System.Drawing.Bitmap)(obj)); 180 | } 181 | } 182 | 183 | /// 184 | /// Looks up a localized resource of type System.IO.UnmanagedMemoryStream similar to System.IO.MemoryStream. 185 | /// 186 | internal static System.IO.UnmanagedMemoryStream OSLTTTone { 187 | get { 188 | return ResourceManager.GetStream("OSLTTTone", resourceCulture); 189 | } 190 | } 191 | 192 | /// 193 | /// Looks up a localized resource of type System.Drawing.Bitmap. 194 | /// 195 | internal static System.Drawing.Bitmap play_solid { 196 | get { 197 | object obj = ResourceManager.GetObject("play-solid", resourceCulture); 198 | return ((System.Drawing.Bitmap)(obj)); 199 | } 200 | } 201 | 202 | /// 203 | /// Looks up a localized resource of type System.Drawing.Bitmap. 204 | /// 205 | internal static System.Drawing.Bitmap wrench_solid { 206 | get { 207 | object obj = ResourceManager.GetObject("wrench_solid", resourceCulture); 208 | return ((System.Drawing.Bitmap)(obj)); 209 | } 210 | } 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /OSLTT/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | 121 | 122 | ..\Resources\desktop-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 123 | 124 | 125 | ..\Resources\computer-mouse-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 126 | 127 | 128 | ..\Resources\arrow-rotate-right.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 129 | 130 | 131 | ..\Resources\play-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 132 | 133 | 134 | ..\Resources\headset-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 135 | 136 | 137 | ..\Resources\chart-bar-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 138 | 139 | 140 | ..\Resources\gamepad-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 141 | 142 | 143 | ..\Resources\check.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 144 | 145 | 146 | ..\Resources\bug-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 147 | 148 | 149 | ..\Resources\circle-question-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 150 | 151 | 152 | ..\OSLTTTone.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 153 | 154 | 155 | ..\Resources\wrench-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 156 | 157 | 158 | ..\Resources\gear-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 159 | 160 | 161 | ..\Resources\folder-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 162 | 163 | 164 | ..\Resources\keyboard-solid.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 165 | 166 | -------------------------------------------------------------------------------- /OSLTT/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | False 7 | 8 | 9 | True 10 | 11 | 12 | False 13 | 14 | 15 | False 16 | 17 | 18 | False 19 | 20 | 21 | False 22 | 23 | 24 | False 25 | 26 | 27 | 100 28 | 29 | 30 | 0.5 31 | 32 | 33 | False 34 | 35 | 36 | True 37 | 38 | 39 | False 40 | 41 | 42 | False 43 | 44 | 45 | 46 | 47 | 48 | F10 49 | 50 | 51 | 30 52 | 53 | 54 | Black 55 | 56 | 57 | 1 58 | 59 | 60 | 0 61 | 62 | 63 | 0 64 | 65 | 66 | 500 67 | 68 | 69 | -------------------------------------------------------------------------------- /OSLTT/Properties/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/Properties/icon.ico -------------------------------------------------------------------------------- /OSLTT/Resources/arrow-rotate-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/Resources/arrow-rotate-right.png -------------------------------------------------------------------------------- /OSLTT/Resources/bug-solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/Resources/bug-solid.png -------------------------------------------------------------------------------- /OSLTT/Resources/chart-bar-solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/Resources/chart-bar-solid.png -------------------------------------------------------------------------------- /OSLTT/Resources/check.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/Resources/check.png -------------------------------------------------------------------------------- /OSLTT/Resources/circle-question-solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/Resources/circle-question-solid.png -------------------------------------------------------------------------------- /OSLTT/Resources/computer-mouse-solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/Resources/computer-mouse-solid.png -------------------------------------------------------------------------------- /OSLTT/Resources/desktop-solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/Resources/desktop-solid.png -------------------------------------------------------------------------------- /OSLTT/Resources/folder-solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/Resources/folder-solid.png -------------------------------------------------------------------------------- /OSLTT/Resources/gamepad-solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/Resources/gamepad-solid.png -------------------------------------------------------------------------------- /OSLTT/Resources/gear-solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/Resources/gear-solid.png -------------------------------------------------------------------------------- /OSLTT/Resources/headset-solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/Resources/headset-solid.png -------------------------------------------------------------------------------- /OSLTT/Resources/keyboard-solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/Resources/keyboard-solid.png -------------------------------------------------------------------------------- /OSLTT/Resources/play-solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/Resources/play-solid.png -------------------------------------------------------------------------------- /OSLTT/Resources/wrench-solid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/Resources/wrench-solid.png -------------------------------------------------------------------------------- /OSLTT/ResultsSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using MaterialSkin; 9 | using MaterialSkin.Controls; 10 | using System.Threading.Tasks; 11 | using System.Windows.Forms; 12 | 13 | namespace OSLTT 14 | { 15 | public partial class ResultsSettings : MaterialForm 16 | { 17 | public ResultsSettings() 18 | { 19 | InitializeComponent(); 20 | var materialSkinManager = MaterialSkinManager.Instance; 21 | materialSkinManager.EnforceBackcolorOnAllComponents = true; 22 | materialSkinManager.AddFormToManage(this); 23 | materialSkinManager.Theme = MaterialSkinManager.Themes.DARK; 24 | materialSkinManager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE); 25 | 26 | axisColourSelect.Items.Clear(); 27 | foreach (var i in AxisColours) 28 | { 29 | axisColourSelect.Items.Add(i.Text); 30 | } 31 | autoScreenshotSelect.Items.Clear(); 32 | autoScreenshotSelect.Items.Add("Disabled"); 33 | autoScreenshotSelect.Items.Add("Transparent"); 34 | autoScreenshotSelect.Items.Add("White Background"); 35 | graphViewSelect.Items.Clear(); 36 | graphViewSelect.Items.Add("Bar Chart"); 37 | graphViewSelect.Items.Add("Scatter Plot"); 38 | for (int i = 0; i < AxisColours.Count; i++) 39 | { 40 | if (AxisColours[i].Colour == Properties.Settings.Default.chartTextColour) 41 | { 42 | axisColourSelect.SelectedIndex = i; 43 | break; 44 | } 45 | } 46 | autoScreenshotSelect.SelectedIndex = Properties.Settings.Default.autoSaveScreenshots; 47 | graphViewSelect.SelectedIndex = Properties.Settings.Default.defaultGraphView; 48 | yAxisSlider.Value = Properties.Settings.Default.yMax; 49 | comparePointsLimit.Value = Properties.Settings.Default.comparePoints; 50 | 51 | } 52 | 53 | public class AxisColour 54 | { 55 | public string Text { get; set; } 56 | public Color Colour { get; set; } 57 | } 58 | public static List AxisColours = new List 59 | { 60 | new AxisColour { Text = "Black", Colour = Color.Black }, 61 | new AxisColour { Text = "Grey", Colour = Color.Gray }, 62 | new AxisColour { Text = "White", Colour = Color.White }, 63 | }; 64 | 65 | private void yAxisSlider_MouseUp(object sender, MouseEventArgs e) 66 | { 67 | var ctrl = sender as MaterialSlider; 68 | if (ctrl.Focused) 69 | { 70 | // Save new setting 71 | if (ctrl.Value < 5) 72 | { 73 | ctrl.Value = 5; 74 | } 75 | Properties.Settings.Default.yMax = ctrl.Value; 76 | Properties.Settings.Default.Save(); 77 | } 78 | } 79 | 80 | private void axisColourSelect_SelectedIndexChanged(object sender, EventArgs e) 81 | { 82 | var ctrl = sender as MaterialComboBox; 83 | if (ctrl.Focused) 84 | { 85 | Properties.Settings.Default.chartTextColour = AxisColours[ctrl.SelectedIndex].Colour; 86 | Properties.Settings.Default.Save(); 87 | } 88 | } 89 | 90 | private void graphViewSelect_SelectedIndexChanged(object sender, EventArgs e) 91 | { 92 | var ctrl = sender as MaterialComboBox; 93 | if (ctrl.Focused) 94 | { 95 | Properties.Settings.Default.defaultGraphView = ctrl.SelectedIndex; 96 | Properties.Settings.Default.Save(); 97 | } 98 | } 99 | 100 | private void autoScreenshotSelect_SelectedIndexChanged(object sender, EventArgs e) 101 | { 102 | var ctrl = sender as MaterialComboBox; 103 | if (ctrl.Focused) 104 | { 105 | Properties.Settings.Default.autoSaveScreenshots = ctrl.SelectedIndex; 106 | Properties.Settings.Default.Save(); 107 | } 108 | } 109 | private void comparePointsLimit_MouseUp(object sender, MouseEventArgs e) 110 | { 111 | var ctrl = sender as MaterialSlider; 112 | if (ctrl.Focused) 113 | { 114 | // Save new setting 115 | Properties.Settings.Default.comparePoints = ctrl.Value; 116 | Properties.Settings.Default.Save(); 117 | } 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /OSLTT/ResultsSettings.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | -------------------------------------------------------------------------------- /OSLTT/ResultsView.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | -------------------------------------------------------------------------------- /OSLTT/RoundedPanel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Drawing; 4 | using System.Drawing.Drawing2D; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows.Forms; 9 | 10 | namespace OSLTT 11 | { 12 | 13 | public class RoundedPanel : Panel 14 | { 15 | private float _thickness = 5; 16 | public float Thickness 17 | { 18 | get 19 | { 20 | return _thickness; 21 | } 22 | set 23 | { 24 | _thickness = value; 25 | _pen = new Pen(_borderColor, Thickness); 26 | Invalidate(); 27 | } 28 | } 29 | 30 | private Color _borderColor = Color.White; 31 | public Color BorderColor 32 | { 33 | get 34 | { 35 | return _borderColor; 36 | } 37 | set 38 | { 39 | _borderColor = value; 40 | _pen = new Pen(_borderColor, Thickness); 41 | Invalidate(); 42 | } 43 | } 44 | 45 | private int _radius = 20; 46 | public int Radius 47 | { 48 | get 49 | { 50 | return _radius; 51 | } 52 | set 53 | { 54 | _radius = value; 55 | Invalidate(); 56 | } 57 | } 58 | 59 | private Pen _pen; 60 | 61 | public RoundedPanel() : base() 62 | { 63 | _pen = new Pen(BorderColor, Thickness); 64 | DoubleBuffered = true; 65 | } 66 | private Rectangle GetLeftUpper(int e) 67 | { 68 | return new Rectangle(0, 0, e, e); 69 | } 70 | private Rectangle GetRightUpper(int e) 71 | { 72 | return new Rectangle(Width - e, 0, e, e); 73 | } 74 | private Rectangle GetRightLower(int e) 75 | { 76 | return new Rectangle(Width - e, Height - e, e, e); 77 | } 78 | private Rectangle GetLeftLower(int e) 79 | { 80 | return new Rectangle(0, Height - e, e, e); 81 | } 82 | 83 | private void ExtendedDraw(PaintEventArgs e) 84 | { 85 | e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; 86 | GraphicsPath path = new GraphicsPath(); 87 | path.StartFigure(); 88 | path.AddArc(GetLeftUpper(Radius), 180, 90); 89 | path.AddLine(Radius, 0, Width - Radius, 0); 90 | path.AddArc(GetRightUpper(Radius), 270, 90); 91 | path.AddLine(Width, Radius, Width, Height - Radius); 92 | path.AddArc(GetRightLower(Radius), 0, 90); 93 | path.AddLine(Width - Radius, Height, Radius, Height); 94 | path.AddArc(GetLeftLower(Radius), 90, 90); 95 | path.AddLine(0, Height - Radius, 0, Radius); 96 | path.CloseFigure(); 97 | Region = new Region(path); 98 | } 99 | private void DrawSingleBorder(Graphics graphics) 100 | { 101 | graphics.DrawArc(_pen, new Rectangle(0, 0, Radius, Radius), 180, 90); 102 | graphics.DrawArc(_pen, new Rectangle(Width - Radius - 1, -1, Radius, Radius), 270, 90); 103 | graphics.DrawArc(_pen, new Rectangle(Width - Radius - 1, Height - Radius - 1, Radius, Radius), 0, 90); 104 | graphics.DrawArc(_pen, new Rectangle(0, Height - Radius - 1, Radius, Radius), 90, 90); 105 | graphics.DrawRectangle(_pen, 0.0f, 0.0f, (float)Width - 1.0f, (float)Height - 1.0f); 106 | } 107 | private void Draw3DBorder(Graphics graphics) 108 | { 109 | DrawSingleBorder(graphics); 110 | } 111 | private void DrawBorder(Graphics graphics) 112 | { 113 | DrawSingleBorder(graphics); 114 | } 115 | protected override void OnPaint(PaintEventArgs e) 116 | { 117 | base.OnPaint(e); 118 | ExtendedDraw(e); 119 | DrawBorder(e.Graphics); 120 | } 121 | 122 | } 123 | } -------------------------------------------------------------------------------- /OSLTT/Settings.cs: -------------------------------------------------------------------------------- 1 | namespace OSLTT.Properties { 2 | 3 | 4 | // This class allows you to handle specific events on the settings class: 5 | // The SettingChanging event is raised before a setting's value is changed. 6 | // The PropertyChanged event is raised after a setting's value is changed. 7 | // The SettingsLoaded event is raised after the setting values are loaded. 8 | // The SettingsSaving event is raised before the setting values are saved. 9 | internal sealed partial class Settings { 10 | 11 | public Settings() { 12 | // // To add event handlers for saving and changing settings, uncomment the lines below: 13 | // 14 | // this.SettingChanging += this.SettingChangingEventHandler; 15 | // 16 | // this.SettingsSaving += this.SettingsSavingEventHandler; 17 | // 18 | } 19 | 20 | private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) { 21 | // Add code to handle the SettingChangingEvent event here. 22 | } 23 | 24 | private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) { 25 | // Add code to handle the SettingsSaving event here. 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /OSLTT/SettingsClasses.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace OSLTT 8 | { 9 | public class SettingsClasses 10 | { 11 | public class RunSettings 12 | { 13 | public int TriggerType { get; set; } 14 | public int SensorType { get; set; } 15 | public int SourceType { get; set; } 16 | public bool PreTest { get; set; } 17 | 18 | } 19 | 20 | public class TestSettings 21 | { 22 | 23 | } 24 | 25 | 26 | public static RunSettings initRunSettings() 27 | { 28 | SettingsClasses.RunSettings runSettings = new SettingsClasses.RunSettings(); 29 | if (Properties.Settings.Default.buttonTriggerToggle) 30 | { 31 | runSettings.TriggerType = 1; 32 | } 33 | else if (Properties.Settings.Default.audioTriggerToggle) 34 | { 35 | runSettings.TriggerType = 2; 36 | } 37 | else if (Properties.Settings.Default.pinTriggerToggle) 38 | { 39 | runSettings.TriggerType = 3; 40 | } 41 | if (Properties.Settings.Default.lightSensorToggle) 42 | { 43 | runSettings.SensorType = 1; 44 | } 45 | else if (Properties.Settings.Default.audioSensorToggle) 46 | { 47 | runSettings.SensorType = 2; 48 | } 49 | if (Properties.Settings.Default.directXToggle) 50 | { 51 | runSettings.SourceType = 1; 52 | } 53 | else if (Properties.Settings.Default.gameExternalToggle) 54 | { 55 | runSettings.SourceType = 2; 56 | } 57 | else if (Properties.Settings.Default.audioSourceToggle) 58 | { 59 | runSettings.SourceType = 3; 60 | } 61 | runSettings.PreTest = Properties.Settings.Default.preTestToggle; 62 | return runSettings; 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /OSLTT/SettingsPane.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | -------------------------------------------------------------------------------- /OSLTT/TestSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using MaterialSkin.Controls; 7 | 8 | namespace OSLTT 9 | { 10 | public class TestSettings 11 | { 12 | public string Name { get; set; } 13 | public int TriggerType { get; set; } 14 | public int SensorType { get; set; } 15 | public int TestSource { get; set; } 16 | public bool AutoClick { get; set; } 17 | public int ClickCount { get; set; } 18 | public double TimeBetween { get; set; } 19 | public bool PreTest { get; set; } 20 | public int MouseAction { get; set; } 21 | public int TwoPinTrigger { get; set; } 22 | 23 | public ProcessData.resultType ResultType { get; set; } 24 | 25 | public int TriggerTypes(MaterialRadioButton button, MaterialRadioButton audio, MaterialRadioButton twoPin) 26 | { 27 | if (button.Checked) 28 | { 29 | return 1; 30 | } 31 | else if (audio.Checked) 32 | { 33 | return 2; 34 | } 35 | else if (twoPin.Checked) 36 | { 37 | return 3; 38 | } 39 | else 40 | { 41 | return 4; 42 | } 43 | } 44 | 45 | public int SensorTypes(MaterialRadioButton light, MaterialRadioButton audio) 46 | { 47 | if (light.Checked) 48 | { 49 | return 1; 50 | } 51 | else if (audio.Checked) 52 | { 53 | return 2; 54 | } 55 | else 56 | { 57 | return 3; // clicks 58 | } 59 | } 60 | 61 | public int SourceTypes(MaterialRadioButton directx, MaterialRadioButton mouse, MaterialRadioButton keyboard, MaterialRadioButton game, MaterialRadioButton audio, MaterialRadioButton external) 62 | { 63 | if (directx.Checked) 64 | { 65 | return 1; 66 | } 67 | else if (mouse.Checked) 68 | { 69 | return 2; 70 | } 71 | else if (game.Checked) 72 | { 73 | return 3; 74 | } 75 | else if (audio.Checked) 76 | { 77 | return 4; 78 | } 79 | else if (external.Checked) 80 | { 81 | return 5; 82 | } 83 | else if (keyboard.Checked) 84 | { 85 | return 6; 86 | } 87 | else 88 | { 89 | return 7; // Controller 90 | } 91 | } 92 | 93 | public ProcessData.resultType GetResultType(int SensorType) 94 | { 95 | if (SensorType == 1) 96 | { 97 | return ProcessData.resultType.Light; 98 | } 99 | else if (SensorType == 2) 100 | { 101 | return ProcessData.resultType.Audio; 102 | } 103 | else 104 | { 105 | return ProcessData.resultType.Click; 106 | } 107 | } 108 | 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /OSLTT/UpdateFirmware.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Net; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows.Forms; 9 | using Newtonsoft.Json; 10 | 11 | namespace OSLTT 12 | { 13 | class UpdateFirmware 14 | { 15 | private static string releasesUrl = "https://api.github.com/repos/OSRTT/OSLTT/releases/latest"; 16 | private static string newFirmwareUrl = ""; 17 | 18 | public static void initialSetup() 19 | { 20 | string appData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); 21 | var samdCore = appData + "\\Arduino15\\packages\\Seeeduino\\hardware\\samd"; 22 | var adafruitCore = appData + "\\Arduino15\\packages\\adafruit\\hardware\\samd"; 23 | Console.WriteLine(samdCore); 24 | if (!Directory.Exists(samdCore)) 25 | { 26 | DialogResult d = MessageBox.Show("Further setup is required to connect and update device, do that now?", "Setup Required", MessageBoxButtons.YesNo, MessageBoxIcon.Question); 27 | if (d == DialogResult.Yes) 28 | { 29 | System.Diagnostics.Process process = new System.Diagnostics.Process(); 30 | //process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 31 | process.StartInfo.FileName = "cmd.exe"; 32 | process.StartInfo.Arguments = "/C .\\arduinoCLI\\arduino-cli.exe config init"; 33 | //process.StartInfo.UseShellExecute = false; 34 | //process.StartInfo.RedirectStandardOutput = true; 35 | //process.StartInfo.CreateNoWindow = true; 36 | process.Start(); 37 | //string output = process.StandardOutput.ReadToEnd(); 38 | process.WaitForExit(); 39 | //Console.WriteLine(output); 40 | process.StartInfo.Arguments = "/C .\\arduinoCLI\\arduino-cli.exe config set directories.user \"C:\\OSRTT Launcher\\arduinoCLI\""; 41 | process.Start(); 42 | process.WaitForExit(); 43 | process.StartInfo.Arguments = "/C .\\arduinoCLI\\arduino-cli.exe config add board_manager.additional_urls https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json"; 44 | process.Start(); 45 | process.WaitForExit(); 46 | process.StartInfo.Arguments = "/C .\\arduinoCLI\\arduino-cli.exe core update-index && .\\arduinoCLI\\arduino-cli.exe core install arduino:samd && .\\arduinoCLI\\arduino-cli.exe core install Seeeduino:samd"; 47 | process.Start(); 48 | process.WaitForExit(); 49 | } 50 | } 51 | if (!Directory.Exists(adafruitCore)) 52 | { 53 | DialogResult d = MessageBox.Show("Further setup is required to connect and update device, do that now?", "Setup Required", MessageBoxButtons.YesNo, MessageBoxIcon.Question); 54 | if (d == DialogResult.Yes) 55 | { 56 | System.Diagnostics.Process process = new System.Diagnostics.Process(); 57 | //process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 58 | process.StartInfo.FileName = "cmd.exe"; 59 | process.StartInfo.Arguments = "/C .\\arduinoCLI\\arduino-cli.exe config init"; 60 | //process.StartInfo.UseShellExecute = false; 61 | //process.StartInfo.RedirectStandardOutput = true; 62 | //process.StartInfo.CreateNoWindow = true; 63 | process.Start(); 64 | //string output = process.StandardOutput.ReadToEnd(); 65 | process.WaitForExit(); 66 | //Console.WriteLine(output); 67 | process.StartInfo.Arguments = "/C .\\arduinoCLI\\arduino-cli.exe config set directories.user \"C:\\OSRTT Launcher\\arduinoCLI\""; 68 | process.Start(); 69 | process.WaitForExit(); 70 | process.StartInfo.Arguments = "/C .\\arduinoCLI\\arduino-cli.exe config add board_manager.additional_urls https://adafruit.github.io/arduino-board-index/package_adafruit_index.json"; 71 | process.Start(); 72 | process.WaitForExit(); 73 | process.StartInfo.Arguments = "/C .\\arduinoCLI\\arduino-cli.exe core update-index && .\\arduinoCLI\\arduino-cli.exe core install arduino:samd && .\\arduinoCLI\\arduino-cli.exe core install adafruit:samd"; 74 | process.Start(); 75 | process.WaitForExit(); 76 | } 77 | } 78 | } 79 | 80 | public static double getNewFirmwareFile(string localPath) 81 | { 82 | using (WebClient wc = new WebClient()) 83 | { 84 | wc.Headers.Add("user-agent", "OSLTT"); 85 | 86 | try 87 | { 88 | string latest = wc.DownloadString(releasesUrl); 89 | string[] splitMessage = latest.Split('}'); 90 | foreach (var s in splitMessage) 91 | { 92 | if (s.Contains("browser_download_url")) 93 | { 94 | string[] splitForUrl = s.Split('"'); 95 | foreach (var st in splitForUrl) 96 | { 97 | if (st.StartsWith("https://github.com/") && st.Contains(".ino.bin")) // change to .ino.bin for prod 98 | { 99 | newFirmwareUrl = st; 100 | string[] filename = newFirmwareUrl.Split('/'); 101 | wc.DownloadFile(newFirmwareUrl, localPath + @"\\arduinoCLI\\" + filename.Last()); 102 | } 103 | } 104 | if (newFirmwareUrl != "") 105 | { 106 | //break; 107 | } 108 | } 109 | } 110 | 111 | } 112 | catch (Exception ex) 113 | { 114 | Console.WriteLine(ex.Message + ex.StackTrace); 115 | } 116 | 117 | } 118 | if (newFirmwareUrl != "") 119 | { 120 | try 121 | { 122 | string[] fileSplit = newFirmwareUrl.Split('/'); 123 | string[] fileVersion = fileSplit.Last().Split('_'); 124 | string fileNumber = fileVersion.Last(); 125 | fileNumber = fileNumber.Remove(fileNumber.Length - 8); 126 | return double.Parse(fileNumber); 127 | } 128 | catch { return 0; } 129 | } 130 | return 0; 131 | } 132 | 133 | public class FirmwareReport 134 | { 135 | public string ErrorMessage { get; set; } 136 | public int State { get; set; } 137 | public string ConsoleOutput { get; set; } 138 | } 139 | 140 | public static FirmwareReport UpdateDeviceFirmware(string localPath, string p, int boardType = 0) 141 | { 142 | FirmwareReport fwr = new FirmwareReport { ErrorMessage = "", State = 0, ConsoleOutput="" }; 143 | System.Diagnostics.Process process = new System.Diagnostics.Process(); 144 | process.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 145 | process.StartInfo.FileName = "cmd.exe"; 146 | string updateCommand = ""; 147 | 148 | string binFileAvailable = ""; 149 | string csBinFile = ""; 150 | foreach (var f in Directory.GetFiles(localPath + @"\\arduinoCLI")) 151 | { 152 | if (f.Contains("ino.bin") && !f.Contains("CS") && boardType == 0) { binFileAvailable = f; } 153 | if (f.Contains("ino.bin") && f.Contains("CS") && boardType == 1) { csBinFile = f; } 154 | } 155 | if (binFileAvailable != "" && boardType == 0) 156 | { 157 | Console.WriteLine(binFileAvailable); 158 | updateCommand = "/C .\\arduinoCLI\\arduino-cli.exe upload --port " + p + " --fqbn Seeeduino:samd:seeed_XIAO_m0 -i \"" + binFileAvailable + "\""; 159 | Console.WriteLine(updateCommand); 160 | } 161 | else if (csBinFile != "" && boardType == 1) 162 | { 163 | Console.WriteLine(binFileAvailable); 164 | updateCommand = "/C .\\arduinoCLI\\arduino-cli.exe upload --port " + p + " --fqbn adafruit:samd:adafruit_feather_m0 -i \"" + csBinFile + "\""; 165 | Console.WriteLine(updateCommand); 166 | } 167 | else 168 | { 169 | return new FirmwareReport { State = 4, ConsoleOutput = "", ErrorMessage = "No Binary File Available" }; 170 | } 171 | 172 | Console.WriteLine("ready to start"); 173 | process.StartInfo.UseShellExecute = false; 174 | process.StartInfo.RedirectStandardOutput = true; 175 | process.StartInfo.CreateNoWindow = true; 176 | process.StartInfo.Arguments = updateCommand; 177 | try 178 | { 179 | Console.WriteLine("starting update"); 180 | process.Start(); 181 | string output = process.StandardOutput.ReadToEnd(); 182 | Console.WriteLine(output); 183 | fwr.ConsoleOutput = output; 184 | process.WaitForExit(); 185 | //MessageBox.Show(output); 186 | if (output.Contains("error")) 187 | { 188 | //MessageBox.Show("Firmware update failed. Error message: " + output, "Update Device Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); 189 | fwr.ErrorMessage = "Failed to update device firmware, check debug log for more information"; 190 | fwr.State = 4; 191 | } 192 | else 193 | { 194 | //MessageBox.Show("Device has been updated successfully!", "Updated Device", MessageBoxButtons.OK, MessageBoxIcon.Information); 195 | fwr.ErrorMessage = "Device updated successfully"; 196 | fwr.State = 3; 197 | } 198 | } 199 | catch (Exception ex) 200 | { 201 | MessageBox.Show("Unable to write to device, check it's connected via USB.", "Update Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); 202 | Console.WriteLine(ex); 203 | fwr.ErrorMessage = ex.Message + ex.StackTrace; 204 | } 205 | return fwr; 206 | } 207 | } 208 | } 209 | -------------------------------------------------------------------------------- /OSLTT/UpdateHandler.cs: -------------------------------------------------------------------------------- 1 | using AutoUpdaterDotNET; 2 | using Newtonsoft.Json; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Net; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using System.Windows.Forms; 11 | 12 | namespace OSLTT 13 | { 14 | public class UpdateHandler 15 | { 16 | public static void UpdateMe(string softwareVersion) 17 | { 18 | AutoUpdater.InstalledVersion = new Version(softwareVersion); 19 | AutoUpdater.ShowSkipButton = false; 20 | AutoUpdater.RemindLaterTimeSpan = RemindLaterFormat.Days; 21 | AutoUpdater.RemindLaterAt = 2; 22 | AutoUpdater.RunUpdateAsAdmin = false; 23 | AutoUpdater.HttpUserAgent = "Autoupdater"; 24 | AutoUpdater.UpdateFormSize = new System.Drawing.Size(1200, 800); 25 | AutoUpdater.ParseUpdateInfoEvent += AutoUpdaterOnParseUpdateInfoEvent; 26 | AutoUpdater.ApplicationExitEvent += AutoUpdater_ApplicationExitEvent; 27 | AutoUpdater.Start("https://api.github.com/repos/OSRTT/OSLTT/releases/latest"); 28 | } 29 | 30 | private static void AutoUpdaterOnParseUpdateInfoEvent(ParseUpdateInfoEventArgs args) 31 | { 32 | dynamic json = JsonConvert.DeserializeObject(args.RemoteData); 33 | string dlUrl = ""; 34 | foreach (var a in json.assets) 35 | { 36 | string tmp = a.browser_download_url; 37 | if (tmp.Contains(".zip")) 38 | { 39 | dlUrl = tmp; 40 | } 41 | } 42 | args.UpdateInfo = new UpdateInfoEventArgs 43 | { 44 | CurrentVersion = json.tag_name, 45 | ChangelogURL = json.html_url, 46 | DownloadURL = dlUrl, 47 | }; 48 | } 49 | private static void AutoUpdater_ApplicationExitEvent() 50 | { 51 | Properties.Settings.Default.updateInProgress = true; 52 | Properties.Settings.Default.Save(); 53 | 54 | Application.Exit(); 55 | } 56 | 57 | public class AnnouncementText 58 | { 59 | public string titleText { get; set; } = "No updates found"; 60 | public string descriptionText { get; set; } = ""; 61 | public bool Read { get; set; } 62 | } 63 | 64 | public static AnnouncementText GetAnnouncements(string localPath) 65 | { 66 | using (WebClient wc = new WebClient()) 67 | { 68 | wc.Headers.Add("user-agent", "OSLTT"); 69 | 70 | try 71 | { 72 | List existingList; 73 | if (File.Exists(localPath + @"\\announcements.json")) 74 | { 75 | existingList = JsonConvert.DeserializeObject>(File.ReadAllText(localPath + @"\\announcements.json")); 76 | } 77 | else 78 | { 79 | existingList = new List(); 80 | } 81 | 82 | string url = "https://raw.githubusercontent.com/OSRTT/OSLTT/main/OSLTT/announcements.json"; 83 | //wc.DownloadFile(url, localPath + @"announcements.json"); 84 | string content = wc.DownloadString(url); 85 | List jsonified = JsonConvert.DeserializeObject>(content); 86 | 87 | if (jsonified.Count() > existingList.Count()) 88 | { 89 | // there's new shit probably. 90 | // save new list to file 91 | jsonified.Last().Read = true; 92 | File.Delete(localPath + @"\\announcements.json"); 93 | File.WriteAllText(localPath + @"\\announcements.json", JsonConvert.SerializeObject(jsonified)); 94 | // return newest results 95 | return jsonified.Last(); 96 | } 97 | else if (!existingList.Last().Read) 98 | { 99 | // last result hasn't been shown yet. (somehow) 100 | existingList.Last().Read = true; 101 | File.Delete(localPath + @"\\announcements.json"); 102 | File.WriteAllText(localPath + @"\\announcements.json", JsonConvert.SerializeObject(existingList)); 103 | return existingList.Last(); 104 | } 105 | else 106 | { 107 | return null; 108 | } 109 | } 110 | catch (Exception ex) 111 | { 112 | Console.WriteLine(ex.Message + ex.StackTrace); 113 | } 114 | 115 | } 116 | 117 | return null; 118 | } 119 | 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /OSLTT/UserSettings.cs: -------------------------------------------------------------------------------- 1 | using Newtonsoft.Json; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace OSLTT 10 | { 11 | class UserSettings 12 | { 13 | class userSettings 14 | { 15 | public class usersetting 16 | { 17 | public string name { get; set; } 18 | public string value { get; set; } 19 | } 20 | public List usersettings { get; set; } = new List(); 21 | } 22 | public static void readAndSaveUserSettings(bool closing) 23 | { 24 | string UserSettingsFile = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase; 25 | UserSettingsFile = new Uri(System.IO.Path.GetDirectoryName(UserSettingsFile)).LocalPath; 26 | UserSettingsFile += @"\\userSettings.json"; 27 | try 28 | { 29 | if (closing) 30 | { 31 | // write settings to file 32 | userSettings us = new userSettings(); 33 | foreach (System.Configuration.SettingsProperty s in Properties.Settings.Default.Properties) 34 | { 35 | if (s.Name == "customTestSettings") 36 | { 37 | string ts = JsonConvert.SerializeObject(Properties.Settings.Default.customTestSettings); 38 | us.usersettings.Add(new userSettings.usersetting { name = "customTestSettings", value = ts }); 39 | } 40 | else 41 | { 42 | us.usersettings.Add(new userSettings.usersetting { name = s.Name, value = Properties.Settings.Default[s.Name].ToString() }); 43 | } 44 | } 45 | string jsonData = JsonConvert.SerializeObject(us); 46 | File.WriteAllText(UserSettingsFile, jsonData); 47 | } 48 | else if (File.Exists(UserSettingsFile)) 49 | { 50 | // opening program, read settings from file 51 | string contents = File.ReadAllText(UserSettingsFile); 52 | userSettings settings = JsonConvert.DeserializeObject(contents); 53 | foreach (userSettings.usersetting s in settings.usersettings) 54 | { 55 | if (s.name == "customTestSettings") 56 | { 57 | try 58 | { 59 | Properties.Settings.Default.customTestSettings = JsonConvert.DeserializeObject(s.value); 60 | } 61 | catch (Exception e) { Console.WriteLine(e.Message + e.StackTrace); } 62 | } 63 | else 64 | { 65 | try 66 | { 67 | Type t = Properties.Settings.Default[s.name].GetType(); 68 | if (s.name.Contains("Colour")) 69 | { 70 | Console.WriteLine(System.Drawing.Color.FromName(s.value)); 71 | //Console.WriteLine(); 72 | } 73 | Properties.Settings.Default[s.name] = Convert.ChangeType(s.value, t); 74 | } 75 | catch (Exception e) { Console.WriteLine(e.Message + e.StackTrace); } 76 | } 77 | } 78 | Properties.Settings.Default.Save(); 79 | } 80 | } 81 | catch (Exception ex) 82 | { 83 | Console.WriteLine(ex.Message + ex.StackTrace); 84 | } 85 | } 86 | 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /OSLTT/announcements.json: -------------------------------------------------------------------------------- 1 | [{"titleText":"Testing out the announcements","descriptionText":"I'm adding these announcements as a way to keep you informed on any updates. \n Let's face it, no one reads the Github release notes, so hopefully these are more useful!","Read":false}] -------------------------------------------------------------------------------- /OSLTT/debugForm.Designer.cs: -------------------------------------------------------------------------------- 1 |  2 | namespace OSLTT 3 | { 4 | partial class debugForm 5 | { 6 | /// 7 | /// Required designer variable. 8 | /// 9 | private System.ComponentModel.IContainer components = null; 10 | 11 | /// 12 | /// Clean up any resources being used. 13 | /// 14 | /// true if managed resources should be disposed; otherwise, false. 15 | protected override void Dispose(bool disposing) 16 | { 17 | if (disposing && (components != null)) 18 | { 19 | components.Dispose(); 20 | } 21 | base.Dispose(disposing); 22 | } 23 | 24 | #region Windows Form Designer generated code 25 | 26 | /// 27 | /// Required method for Designer support - do not modify 28 | /// the contents of this method with the code editor. 29 | /// 30 | private void InitializeComponent() 31 | { 32 | this.closeBtn = new MaterialSkin.Controls.MaterialButton(); 33 | this.debugBox = new MaterialSkin.Controls.MaterialMultiLineTextBox2(); 34 | this.testMicBtn = new MaterialSkin.Controls.MaterialButton(); 35 | this.SuspendLayout(); 36 | // 37 | // closeBtn 38 | // 39 | this.closeBtn.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 40 | this.closeBtn.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; 41 | this.closeBtn.Depth = 0; 42 | this.closeBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; 43 | this.closeBtn.HighEmphasis = true; 44 | this.closeBtn.Icon = null; 45 | this.closeBtn.Location = new System.Drawing.Point(717, 666); 46 | this.closeBtn.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); 47 | this.closeBtn.MouseState = MaterialSkin.MouseState.HOVER; 48 | this.closeBtn.Name = "closeBtn"; 49 | this.closeBtn.NoAccentTextColor = System.Drawing.Color.Empty; 50 | this.closeBtn.Size = new System.Drawing.Size(149, 36); 51 | this.closeBtn.TabIndex = 1; 52 | this.closeBtn.Text = "Close Debug Log"; 53 | this.closeBtn.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; 54 | this.closeBtn.UseAccentColor = false; 55 | this.closeBtn.UseVisualStyleBackColor = true; 56 | this.closeBtn.Click += new System.EventHandler(this.closeBtn_Click); 57 | // 58 | // debugBox 59 | // 60 | this.debugBox.AnimateReadOnly = true; 61 | this.debugBox.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; 62 | this.debugBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Normal; 63 | this.debugBox.Cursor = System.Windows.Forms.Cursors.IBeam; 64 | this.debugBox.Depth = 0; 65 | this.debugBox.HideSelection = true; 66 | this.debugBox.Location = new System.Drawing.Point(9, 70); 67 | this.debugBox.MaxLength = 32767; 68 | this.debugBox.MouseState = MaterialSkin.MouseState.OUT; 69 | this.debugBox.Name = "debugBox"; 70 | this.debugBox.PasswordChar = '\0'; 71 | this.debugBox.ReadOnly = true; 72 | this.debugBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; 73 | this.debugBox.SelectedText = ""; 74 | this.debugBox.SelectionLength = 0; 75 | this.debugBox.SelectionStart = 0; 76 | this.debugBox.ShortcutsEnabled = true; 77 | this.debugBox.Size = new System.Drawing.Size(899, 651); 78 | this.debugBox.TabIndex = 2; 79 | this.debugBox.TabStop = false; 80 | this.debugBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Left; 81 | this.debugBox.UseSystemPasswordChar = false; 82 | // 83 | // testMicBtn 84 | // 85 | this.testMicBtn.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; 86 | this.testMicBtn.Density = MaterialSkin.Controls.MaterialButton.MaterialButtonDensity.Default; 87 | this.testMicBtn.Depth = 0; 88 | this.testMicBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; 89 | this.testMicBtn.HighEmphasis = true; 90 | this.testMicBtn.Icon = null; 91 | this.testMicBtn.Location = new System.Drawing.Point(773, 618); 92 | this.testMicBtn.Margin = new System.Windows.Forms.Padding(4, 6, 4, 6); 93 | this.testMicBtn.MouseState = MaterialSkin.MouseState.HOVER; 94 | this.testMicBtn.Name = "testMicBtn"; 95 | this.testMicBtn.NoAccentTextColor = System.Drawing.Color.Empty; 96 | this.testMicBtn.Size = new System.Drawing.Size(93, 36); 97 | this.testMicBtn.TabIndex = 3; 98 | this.testMicBtn.Text = "Mic dump"; 99 | this.testMicBtn.Type = MaterialSkin.Controls.MaterialButton.MaterialButtonType.Contained; 100 | this.testMicBtn.UseAccentColor = false; 101 | this.testMicBtn.UseVisualStyleBackColor = true; 102 | this.testMicBtn.Click += new System.EventHandler(this.testMicBtn_Click); 103 | // 104 | // debugForm 105 | // 106 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 107 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 108 | this.AutoScroll = true; 109 | this.CancelButton = this.closeBtn; 110 | this.ClientSize = new System.Drawing.Size(914, 727); 111 | this.Controls.Add(this.testMicBtn); 112 | this.Controls.Add(this.closeBtn); 113 | this.Controls.Add(this.debugBox); 114 | this.Name = "debugForm"; 115 | this.Text = "Debug Log"; 116 | this.ResumeLayout(false); 117 | this.PerformLayout(); 118 | 119 | } 120 | 121 | #endregion 122 | private MaterialSkin.Controls.MaterialButton closeBtn; 123 | private MaterialSkin.Controls.MaterialMultiLineTextBox2 debugBox; 124 | private MaterialSkin.Controls.MaterialButton testMicBtn; 125 | } 126 | } -------------------------------------------------------------------------------- /OSLTT/debugForm.cs: -------------------------------------------------------------------------------- 1 | using MaterialSkin; 2 | using MaterialSkin.Controls; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.ComponentModel; 6 | using System.Data; 7 | using System.Drawing; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using System.Windows.Forms; 12 | using System.Threading; 13 | 14 | namespace OSLTT 15 | { 16 | public partial class debugForm : MaterialForm 17 | { 18 | public Main mainWindow; 19 | public debugForm() 20 | { 21 | InitializeComponent(); 22 | var materialSkinManager = MaterialSkinManager.Instance; 23 | materialSkinManager.EnforceBackcolorOnAllComponents = true; 24 | materialSkinManager.AddFormToManage(this); 25 | materialSkinManager.Theme = MaterialSkinManager.Themes.DARK; 26 | materialSkinManager.ColorScheme = new ColorScheme(Primary.BlueGrey800, Primary.BlueGrey900, Primary.BlueGrey500, Accent.LightBlue200, TextShade.WHITE); 27 | this.HandleCreated += handleCreated; 28 | Thread updateThread = new Thread(new ThreadStart(UpdateLog)); 29 | updateThread.Start(); 30 | } 31 | 32 | public List debugList = new List(); 33 | 34 | private void handleCreated(Object sender, EventArgs e) 35 | { 36 | 37 | } 38 | 39 | public void AddToLog(string s) 40 | { 41 | debugList.Add(s); 42 | /*if (debugBox.InvokeRequired) 43 | { 44 | this.debugBox.Invoke((MethodInvoker)(() => this.debugBox.Text = s + Environment.NewLine + this.debugBox.Text)); 45 | } 46 | else 47 | { 48 | this.debugBox.Text = s + Environment.NewLine + this.debugBox.Text; 49 | }*/ 50 | } 51 | 52 | private void UpdateLog() 53 | { 54 | int listSize = 0; 55 | while (true) 56 | { 57 | while (this.IsHandleCreated) 58 | { 59 | if (listSize != debugList.Count) 60 | { 61 | for (int i = listSize; i < debugList.Count; i++) 62 | { 63 | this.debugBox.Invoke((MethodInvoker)(() => this.debugBox.Text = debugList[i] + Environment.NewLine + this.debugBox.Text)); 64 | } 65 | listSize = debugList.Count(); 66 | } 67 | Thread.Sleep(1000); 68 | } 69 | Thread.Sleep(1000); 70 | } 71 | } 72 | 73 | private void closeBtn_Click(object sender, EventArgs e) 74 | { 75 | this.Hide(); 76 | } 77 | 78 | private void testMicBtn_Click(object sender, EventArgs e) 79 | { 80 | if (mainWindow != null) 81 | { 82 | mainWindow.portWrite("W3"); 83 | } 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /OSLTT/debugForm.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 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 | -------------------------------------------------------------------------------- /OSLTT/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/icon.ico -------------------------------------------------------------------------------- /OSLTT/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTT/icon.png -------------------------------------------------------------------------------- /OSLTT/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /OSLTTFlashTool.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/OSLTTFlashTool.exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OSLTT - Open Source Latency Test Tool 2 | An open source latency testing tool project - here you'll find the desktop software needed to use the tool, the firmware for the device, the circuit diagram and support. 3 | 4 | 5 | ![Buy a kit](buy-a-kit.png) 6 | 7 | ## Get Started 8 | - Download the most recent release from the releases page. 9 | - Run the installer, which will install to C:\OSLTT 10 | - Launch the software 11 | - Allow it to install the drivers for the board 12 | - Allow it to update the device firmware (if prompted) 13 | - Select the test type you want to try - Monitor is the one I'd recommend trying first. 14 | - Hit "Start Test" - if you picked monitor your screen will go black, and FPS counter on the top left should read around 1000FPS. 15 | - Press the button on the tool to start capturing data. Let it complete then it'll close the test window. 16 | - Take a look at the results in the results view window. 17 | - Enjoy! 18 | 19 | ## Features not currently implemented 20 | - Pre-testing system latency - this is a top priority for me. It will be done ASAP! 21 | - ~~Add hotkeys to start and stop testing - this isn't all that difficult so I should have this added fairly quickly.~~ __This has been implemented - press F10 to start/stop the test__. 22 | - A more live view style mode would be great. The baud rate is the biggest limiting factor there (115200 baud is ~1ms per byte, so you'd only get ~1000Hz which isn't all that useful) 23 | - More control over the triggers and sensors. Right now everything is quite fixed how I originally invisaged it, but I can already see methods that might be useful that the device doesn't currently support. 24 | - More on device processing for better compatability. In theory this can work with at least MacOS and Linux systems at a basic level so would be good to support them at least a little with more on device processing. 25 | 26 | ## Reporting problems 27 | If you encounter an errant bug in the software or firmware, please do let me know. The best way to do that is here on GitHub, through the issues tab. If you don't have a GitHub account, you can also email me here. Please include as much information as possible, and any screenshots relevant. 28 | 29 | ## Feature suggestions 30 | Much like the reporting problems section above, if you'd like to request a feature be added, please either submit an issue, or email me here. 31 | 32 | ## Building from Source 33 | - Clone the repo 34 | - Launch the SLN in Visual Studio 35 | - Build the solution before opening Main.cs (as SettingsPane.cs is a user control that needs to be built before displaying Main.cs) 36 | - Copy the DirectX folder to bin/Debug 37 | - Get a copy of the arduino CLI here and place it in a new folder called "arduinoCLI" in bin/Debug 38 | - Run the program and enjoy! 39 | 40 | ## Contributing 41 | ### Supporting Directly 42 | If you'd like to support the project but don't need a device, you can support by sharing the project with your favourite tech reviewers, or support directly through PayPal. 43 | 44 | ### Code Contribution 45 | If you'd like to contribute some code to the project - either bug fixes or new features - please submit a pull request with as much info as possible. I'll do my best to review and merge any changes in good time. If you have any questions about my (imperfect) code, please do submit an issue and tag it as a question. 46 | -------------------------------------------------------------------------------- /buy-a-kit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/buy-a-kit.png -------------------------------------------------------------------------------- /software-qr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/software-qr.png -------------------------------------------------------------------------------- /software-qr.svg: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | Zint Generated Symbol 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 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 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /view-the-docs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OSRTT/OSLTT/09839bba9e3b58a0bc2027e8ac2e39e7446ffe0c/view-the-docs.png --------------------------------------------------------------------------------