Skip to content

Commit 6896e8e

Browse files
committed
v1.2.10 build 0
Lwjgl 3.2.2-3 with OpenVR 1.2.10 Kotlin 1.3.21 Kotlintest 3.2.1 Shadow 4.0.4 Gradle 5.2.1 with Shadow workaround
1 parent b4f1b54 commit 6896e8e

26 files changed

+439
-420
lines changed

build.gradle

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ plugins {
44
id 'maven'
55
id 'java'
66
id 'java-library'
7-
id "org.jetbrains.kotlin.jvm" version "1.3.11"
8-
id "com.github.johnrengelman.shadow" version '4.0.3'
7+
id "org.jetbrains.kotlin.jvm" version "1.3.21"
8+
id "com.github.johnrengelman.shadow" version '4.0.4'
99
}
1010

1111
// jitpack
@@ -14,10 +14,10 @@ group = 'com.github.kotlin-graphics'
1414
ext{
1515
moduleName = 'com.github.kotlin_graphics.openvr'
1616
kotlin = 'org.jetbrains.kotlin:kotlin'
17-
kotlin_version = '1.3.11'
18-
kotlintest_version = '3.1.11'
17+
kotlin_version = '1.3.21'
18+
kotlintest_version = '3.2.1'
1919
uno_version = 'd04fa5dcb3735347e11cd3480615e574b1ffaa0b'
20-
lwjgl_version = "3.2.1"
20+
lwjgl_version = "3.2.2-SNAPSHOT"
2121
lwjgl_natives = current() == WINDOWS ? "windows" : current() == LINUX ? "linux" : "macos"
2222
}
2323

@@ -28,19 +28,13 @@ dependencies {
2828
testImplementation "io.kotlintest:kotlintest-runner-junit5:$kotlintest_version"
2929

3030
ext.kx = "com.github.kotlin-graphics"
31-
implementation "$kx:uno-sdk:24550988e24b8fc99428e599b62f2e81a6f0b334"
31+
implementation "$kx:uno-sdk:60edf33067835253aa30ac79bd5129363fee953f"
3232

3333
["", "-glfw", "-jemalloc", "-openal", "-opengl", "-stb", "-openvr", "-vulkan"].each {
3434
implementation "org.lwjgl:lwjgl$it:$lwjgl_version"
3535
if (it != "-vulkan")
3636
runtime "org.lwjgl:lwjgl$it:$lwjgl_version:natives-$lwjgl_natives"
3737
}
38-
39-
constraints {
40-
testImplementation("$kotlin-stdlib:$kotlin_version")
41-
testImplementation("$kotlin-stdlib-jdk7:$kotlin_version")
42-
testImplementation("$kotlin-reflect:$kotlin_version")
43-
}
4438
}
4539

4640
repositories {
@@ -50,12 +44,12 @@ repositories {
5044
}
5145

5246
task sourcesJar(type: Jar, dependsOn: classes) {
53-
classifier = 'sources'
47+
archiveClassifier = 'sources'
5448
from sourceSets.main.allSource
5549
}
5650

5751
task javadocJar(type: Jar, dependsOn: javadoc) {
58-
classifier = 'javadoc'
52+
archiveClassifier = 'javadoc'
5953
from javadoc.destinationDir
6054
}
6155

@@ -74,4 +68,6 @@ test.useJUnitPlatform()
7468
// outputs.upToDateWhen { false }
7569
// showStandardStreams = true
7670
// }
77-
//}
71+
//}
72+
73+
shadowJar.archiveClassifier = 'all'

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-all.zip

src/main/kotlin/openvr/lib/ivrApplications.kt

Lines changed: 52 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package openvr.lib
22

33
import kool.*
4+
import kool.lib.toByteArray
45
import org.lwjgl.openvr.AppOverrideKeys
56
import org.lwjgl.openvr.OpenVR.IVRApplications
67
import org.lwjgl.openvr.VRApplications.*
7-
import org.lwjgl.system.MemoryStack.stackGet
88
import org.lwjgl.system.MemoryUtil.*
99
import java.nio.ByteBuffer
1010

@@ -130,23 +130,23 @@ object vrApplications : vrInterface {
130130
* @param temporary
131131
*/
132132
fun addApplicationManifest(applicationManifestFullPath: String, temporary: Boolean = false): Error =
133-
Error of nVRApplications_AddApplicationManifest(addressOfAscii(applicationManifestFullPath), temporary)
133+
stak { Error of nVRApplications_AddApplicationManifest(it.addressOfAscii(applicationManifestFullPath), temporary) }
134134

135135
/**
136136
* Removes an application manifest from the list to load when building the list of installed applications.
137137
*
138138
* @param applicationManifestFullPath
139139
*/
140140
infix fun removeApplicationManifest(applicationManifestFullPath: String): Error =
141-
Error of nVRApplications_RemoveApplicationManifest(addressOfAscii(applicationManifestFullPath))
141+
stak { Error of nVRApplications_RemoveApplicationManifest(it.addressOfAscii(applicationManifestFullPath)) }
142142

143143
/**
144144
* Returns true if an application is installed.
145145
*
146146
* @param appKey
147147
*/
148148
infix fun isApplicationInstalled(appKey: String): Boolean =
149-
nVRApplications_IsApplicationInstalled(addressOfAscii(appKey))
149+
stak { nVRApplications_IsApplicationInstalled(it.addressOfAscii(appKey)) }
150150

151151
/** Returns the number of applications available in the list. */
152152
val applicationCount: Int
@@ -163,9 +163,11 @@ object vrApplications : vrInterface {
163163
* @param appKeyBuffer
164164
*/
165165
@JvmOverloads
166-
fun getApplicationKeyByIndex(applicationIndex: Int, pErr: VRApplicationErrorBuffer = pError): ByteBuffer =
167-
stackGet().malloc(maxKeyLength).apply {
168-
pErr[0] = nVRApplications_GetApplicationKeyByIndex(applicationIndex, adr, maxKeyLength)
166+
fun getApplicationKeyByIndex(applicationIndex: Int, pErr: VRApplicationErrorBuffer = pError): ByteArray =
167+
stak {
168+
val buf = it.malloc(maxKeyLength)
169+
pErr[0] = nVRApplications_GetApplicationKeyByIndex(applicationIndex, buf.adr, maxKeyLength)
170+
buf.toByteArray()
169171
}
170172

171173
/**
@@ -179,9 +181,11 @@ object vrApplications : vrInterface {
179181
* @param appKeyBuffer
180182
*/
181183
@JvmOverloads
182-
fun getApplicationKeyByProcessId(processId: Int, pErr: VRApplicationErrorBuffer = pError): ByteBuffer =
183-
stackGet().malloc(maxKeyLength).apply {
184-
pErr[0] = nVRApplications_GetApplicationKeyByProcessId(processId, adr, maxKeyLength)
184+
fun getApplicationKeyByProcessId(processId: Int, pErr: VRApplicationErrorBuffer = pError): ByteArray =
185+
stak {
186+
val buf = it.malloc(maxKeyLength)
187+
pErr[0] = nVRApplications_GetApplicationKeyByProcessId(processId, buf.adr, maxKeyLength)
188+
buf.toByteArray()
185189
}
186190

187191
/**
@@ -192,7 +196,7 @@ object vrApplications : vrInterface {
192196
* @param appKey
193197
*/
194198
infix fun launchApplication(appKey: String): Error =
195-
Error of nVRApplications_LaunchApplication(addressOfAscii(appKey))
199+
stak { Error of nVRApplications_LaunchApplication(it.addressOfAscii(appKey)) }
196200

197201
/**
198202
* Launches an instance of an application of type template, with its app key being {@code newAppKey} (which must be unique) and optionally override
@@ -203,7 +207,7 @@ object vrApplications : vrInterface {
203207
* @param keys
204208
*/
205209
fun launchTemplateApplication(templateAppKey: String, newAppKey: String, keys: AppOverrideKeys.Buffer): Error =
206-
Error of nVRApplications_LaunchTemplateApplication(addressOfAscii(templateAppKey), addressOfAscii(newAppKey), keys.adr, keys.rem)
210+
stak { Error of nVRApplications_LaunchTemplateApplication(it.addressOfAscii(templateAppKey), it.addressOfAscii(newAppKey), keys.adr, keys.rem) }
207211

208212
/**
209213
* Launches the application currently associated with this mime type and passes it the option args, typically the filename or object name of the item
@@ -213,23 +217,23 @@ object vrApplications : vrInterface {
213217
* @param args
214218
*/
215219
fun launchApplicationFromMimeType(mimeType: String, args: String): Error =
216-
Error of nVRApplications_LaunchApplicationFromMimeType(addressOfAscii(mimeType), addressOfAscii(args))
220+
stak { Error of nVRApplications_LaunchApplicationFromMimeType(it.addressOfAscii(mimeType), it.addressOfAscii(args)) }
217221

218222
/**
219223
* Launches the dashboard overlay application if it is not already running. This call is only valid for dashboard overlay applications.
220224
*
221225
* @param appKey
222226
*/
223227
infix fun launchDashboardOverlay(appKey: String): Error =
224-
Error of nVRApplications_LaunchDashboardOverlay(addressOfAscii(appKey))
228+
stak { Error of nVRApplications_LaunchDashboardOverlay(it.addressOfAscii(appKey)) }
225229

226230
/**
227231
* Cancel a pending launch for an application.
228232
*
229233
* @param appKey
230234
*/
231235
infix fun cancelApplicationLaunch(appKey: String): Boolean =
232-
nVRApplications_CancelApplicationLaunch(addressOfAscii(appKey))
236+
stak { nVRApplications_CancelApplicationLaunch(it.addressOfAscii(appKey)) }
233237

234238
/**
235239
* Identifies a running application. OpenVR can't always tell which process started in response to a URL. This function allows a URL handler (or the
@@ -240,15 +244,15 @@ object vrApplications : vrInterface {
240244
* @param appKey
241245
*/
242246
fun identifyApplication(processId: Int, appKey: String): Error =
243-
Error of nVRApplications_IdentifyApplication(processId, addressOfAscii(appKey))
247+
stak { Error of nVRApplications_IdentifyApplication(processId, it.addressOfAscii(appKey)) }
244248

245249
/**
246250
* Returns the process ID for an application. Return 0 if the application was not found or is not running.
247251
*
248252
* @param appKey
249253
*/
250254
infix fun getApplicationProcessId(appKey: String): Int =
251-
nVRApplications_GetApplicationProcessId(addressOfAscii(appKey))
255+
stak { nVRApplications_GetApplicationProcessId(it.addressOfAscii(appKey)) }
252256

253257
/**
254258
* Kind of useless on JVM, but it will be offered anyway on the enum itself
@@ -280,12 +284,13 @@ object vrApplications : vrInterface {
280284
* @param error
281285
*/
282286
@JvmOverloads
283-
fun getApplicationPropertyString(appKey: String, property: Property, propertyValueBufferLen: Int = vr.maxPropertyStringSize, error: VRApplicationErrorBuffer = pError): String = stackGet().run {
284-
val appKeyEncoded = addressOfAscii(appKey)
285-
val propertyValueBuffer = malloc(propertyValueBufferLen)
286-
val result = nVRApplications_GetApplicationPropertyString(appKeyEncoded, property.i, propertyValueBuffer.adr, propertyValueBufferLen, error.adr)
287-
memASCII(propertyValueBuffer, result - 1)
288-
}
287+
fun getApplicationPropertyString(appKey: String, property: Property, propertyValueBufferLen: Int = vr.maxPropertyStringSize, error: VRApplicationErrorBuffer = pError): String =
288+
stak {
289+
val appKeyEncoded = it.addressOfAscii(appKey)
290+
val propertyValueBuffer = it.malloc(propertyValueBufferLen)
291+
val result = nVRApplications_GetApplicationPropertyString(appKeyEncoded, property.i, propertyValueBuffer.adr, propertyValueBufferLen, error.adr)
292+
memASCII(propertyValueBuffer, result - 1)
293+
}
289294

290295
/**
291296
* Returns a bool value for an application property. Returns false in all error cases.
@@ -298,7 +303,7 @@ object vrApplications : vrInterface {
298303
*/
299304
@JvmOverloads
300305
fun getApplicationPropertyBool(appKey: String, property: Property, error: VRApplicationErrorBuffer = pError): Boolean =
301-
nVRApplications_GetApplicationPropertyBool(addressOfAscii(appKey), property.i, error.adr)
306+
stak { nVRApplications_GetApplicationPropertyBool(it.addressOfAscii(appKey), property.i, error.adr) }
302307

303308
/**
304309
* Returns a uint64 value for an application property. Returns 0 in all error cases.
@@ -311,7 +316,7 @@ object vrApplications : vrInterface {
311316
*/
312317
@JvmOverloads
313318
fun getApplicationPropertyLong(appKey: String, property: Property, error: VRApplicationErrorBuffer = pError): Long =
314-
nVRApplications_GetApplicationPropertyUint64(addressOfAscii(appKey), property.i, error.adr)
319+
stak { nVRApplications_GetApplicationPropertyUint64(it.addressOfAscii(appKey), property.i, error.adr) }
315320

316321
/**
317322
* Sets the application auto-launch flag. This is only valid for applications which return true for
@@ -321,7 +326,7 @@ object vrApplications : vrInterface {
321326
* @param autoLaunch
322327
*/
323328
fun setApplicationAutoLaunch(appKey: String, autoLaunch: Boolean): Error =
324-
Error of nVRApplications_SetApplicationAutoLaunch(addressOfAscii(appKey), autoLaunch)
329+
stak { Error of nVRApplications_SetApplicationAutoLaunch(it.addressOfAscii(appKey), autoLaunch) }
325330

326331
/**
327332
* Gets the application auto-launch flag. This is only valid for applications which return true for
@@ -330,7 +335,7 @@ object vrApplications : vrInterface {
330335
* @param appKey
331336
*/
332337
infix fun getApplicationAutoLaunch(appKey: String): Boolean =
333-
nVRApplications_GetApplicationAutoLaunch(addressOfAscii(appKey))
338+
stak { nVRApplications_GetApplicationAutoLaunch(it.addressOfAscii(appKey)) }
334339

335340
/**
336341
* Adds this mime-type to the list of supported mime types for this application.
@@ -339,7 +344,7 @@ object vrApplications : vrInterface {
339344
* @param mimeType
340345
*/
341346
fun setDefaultApplicationForMimeType(appKey: String, mimeType: String): Error =
342-
Error of nVRApplications_SetDefaultApplicationForMimeType(addressOfAscii(appKey), addressOfAscii(mimeType))
347+
stak { Error of nVRApplications_SetDefaultApplicationForMimeType(it.addressOfAscii(appKey), it.addressOfAscii(mimeType)) }
343348

344349
/**
345350
* Return the app key that will open this mime type. TODO offer a more convenient one?
@@ -348,8 +353,8 @@ object vrApplications : vrInterface {
348353
* @param appKeyBuffer
349354
*/
350355
fun getDefaultApplicationForMimeType(mimeType: String, appKeyBuffer: ByteBuffer?): Boolean =
351-
nVRApplications_GetDefaultApplicationForMimeType(addressOfAscii(mimeType), appKeyBuffer?.adr
352-
?: NULL, appKeyBuffer?.cap ?: 0)
356+
stak { nVRApplications_GetDefaultApplicationForMimeType(it.addressOfAscii(mimeType), appKeyBuffer?.adr
357+
?: NULL, appKeyBuffer?.cap ?: 0) }
353358

354359
/**
355360
* Get the list of supported mime types for this application, comma-delimited. TODO offer a more convenient one?
@@ -358,32 +363,35 @@ object vrApplications : vrInterface {
358363
* @param mimeTypesBuffer
359364
*/
360365
fun getApplicationSupportedMimeTypes(appKey: String, mimeTypesBuffer: ByteBuffer?): Boolean =
361-
nVRApplications_GetApplicationSupportedMimeTypes(addressOfAscii(appKey), mimeTypesBuffer?.adr
362-
?: NULL, mimeTypesBuffer?.rem ?: 0)
366+
stak { nVRApplications_GetApplicationSupportedMimeTypes(it.addressOfAscii(appKey), mimeTypesBuffer?.adr
367+
?: NULL, mimeTypesBuffer?.rem ?: 0) }
363368

364369
/**
365370
* Get the list of app-keys that support this mime type, comma-delimited, the return value is number of bytes you need to return the full string.
366371
*
367372
* @param mimeType
368373
* @param appKeysThatSupportBufferSize
369374
*/
370-
fun getApplicationsThatSupportMimeType(mimeType: String, appKeysThatSupportBufferSize: Int): String {
371-
val appKeysThatSupportBuffer = stackGet().malloc(appKeysThatSupportBufferSize)
372-
val result = nVRApplications_GetApplicationsThatSupportMimeType(addressOfAscii(mimeType), appKeysThatSupportBuffer.adr, appKeysThatSupportBufferSize)
373-
return memASCII(appKeysThatSupportBuffer, result - 1)
374-
}
375+
fun getApplicationsThatSupportMimeType(mimeType: String, appKeysThatSupportBufferSize: Int): String =
376+
stak {
377+
val appKeysThatSupportBuffer = it.malloc(appKeysThatSupportBufferSize)
378+
val pMimeType = it.addressOfAscii(mimeType)
379+
val result = nVRApplications_GetApplicationsThatSupportMimeType(pMimeType, appKeysThatSupportBuffer.adr, appKeysThatSupportBufferSize)
380+
memASCII(appKeysThatSupportBuffer, result - 1)
381+
}
375382

376383
/**
377384
* Get the args list from an app launch that had the process already running, you call this when you get a {@link VR#EVREventType_VREvent_ApplicationMimeTypeLoad}.
378385
*
379386
* @param handle
380387
* @param argsSize
381388
*/
382-
fun getApplicationLaunchArguments(handle: Int, argsSize: Int): String {
383-
val args = stackGet().malloc(argsSize)
384-
val result = nVRApplications_GetApplicationLaunchArguments(handle, args.adr, argsSize)
385-
return memASCII(args, result - 1)
386-
}
389+
fun getApplicationLaunchArguments(handle: Int, argsSize: Int): String =
390+
stak {
391+
val args = it.malloc(argsSize)
392+
val result = nVRApplications_GetApplicationLaunchArguments(handle, args.adr, argsSize)
393+
memASCII(args, result - 1)
394+
}
387395

388396
/**
389397
* Returns the app key for the application that is starting up.
@@ -414,7 +422,7 @@ object vrApplications : vrInterface {
414422
* @param appKey
415423
*/
416424
infix fun performApplicationPrelaunchCheck(appKey: String): Error =
417-
Error of nVRApplications_PerformApplicationPrelaunchCheck(addressOfAscii(appKey))
425+
stak { Error of nVRApplications_PerformApplicationPrelaunchCheck(it.addressOfAscii(appKey)) }
418426

419427
/**
420428
* Kind of useless on JVM, but it will be offered anyway on the enum itself
@@ -441,7 +449,7 @@ object vrApplications : vrInterface {
441449
* @param workingDirectory
442450
*/
443451
fun launchInternalProcess(binaryPath: String, arguments: String, workingDirectory: String): Error =
444-
Error of nVRApplications_LaunchInternalProcess(addressOfAscii(binaryPath), addressOfAscii(arguments), addressOfAscii(workingDirectory))
452+
stak { Error of nVRApplications_LaunchInternalProcess(it.addressOfAscii(binaryPath), it.addressOfAscii(arguments), it.addressOfAscii(workingDirectory)) }
445453

446454
/**
447455
* Returns the current scene process ID according to the application system. A scene process will get scene focus once it starts rendering, but it will

0 commit comments

Comments
 (0)