New Sys.openURL command added
This commit is contained in:
parent
9ad6b5eb1f
commit
754f917730
|
@ -213,4 +213,17 @@ public final class Sys {
|
|||
*
|
||||
public static native int getDirectBufferAddress(Buffer buf);
|
||||
*/
|
||||
|
||||
/**
|
||||
* Open the system web browser and point it at the specified URL. It is recommended
|
||||
* that this not be called whilst your game is running, but on application exit in
|
||||
* a shutdown hook, as the screen resolution will not be reset when the browser is
|
||||
* brought into view.
|
||||
*
|
||||
* There is no guarantee that this will work, nor that we can detect if it has
|
||||
* failed - hence we don't return success code or throw an Exception. This is just a
|
||||
* best attempt at opening the URL given - don't rely on it to work!
|
||||
* @param url The URL
|
||||
*/
|
||||
public static native void openURL(String url);
|
||||
}
|
||||
|
|
|
@ -62,11 +62,11 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_alert
|
|||
|
||||
/*
|
||||
* Class: org_lwjgl_Sys
|
||||
* Method: getDirectBufferAddress
|
||||
* Signature: (Ljava/nio/Buffer;)I
|
||||
JNIEXPORT jint JNICALL Java_org_lwjgl_Sys_getDirectBufferAddress
|
||||
(JNIEnv *, jclass, jobject);
|
||||
* Method: openURL
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_openURL
|
||||
(JNIEnv *, jclass, jstring);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -174,3 +174,16 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_alert(JNIEnv * env, jclass clazz, jstr
|
|||
env->ReleaseStringUTFChars(message, eMessageText);
|
||||
env->ReleaseStringUTFChars(title, cTitleBarText);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Sys
|
||||
* Method: openURL
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_openURL
|
||||
(JNIEnv * env, jclass clazz, jstring url)
|
||||
{
|
||||
const char * urlString = env->GetStringUTFChars(url, NULL);
|
||||
printf("*** Please visit %s\n", urlString);
|
||||
env->ReleaseStringUTFChars(url, urlString);
|
||||
}
|
|
@ -42,6 +42,7 @@
|
|||
#include <sched.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
#include "org_lwjgl_Sys.h"
|
||||
|
||||
long int hires_timer_freq; // Hires timer frequency
|
||||
|
@ -106,7 +107,9 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setTime
|
|||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_setProcessPriority
|
||||
(JNIEnv * env, jclass clazz, jint priority)
|
||||
{
|
||||
printf("Unsupported");
|
||||
#ifdef _DEBUG
|
||||
printf("Unsupported\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -124,3 +127,31 @@ JNIEXPORT void JNICALL Java_org_lwjgl_Sys_alert(JNIEnv * env, jclass clazz, jstr
|
|||
env->ReleaseStringUTFChars(message, eMessageText);
|
||||
env->ReleaseStringUTFChars(title, cTitleBarText);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Sys
|
||||
* Method: openURL
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_openURL
|
||||
(JNIEnv * env, jclass clazz, jstring url)
|
||||
{
|
||||
const char * urlString = env->GetStringUTFChars(url, NULL);
|
||||
|
||||
OSStatus err;
|
||||
ICInstance inst;
|
||||
long startSel;
|
||||
long endSel;
|
||||
Str255 urlStr;
|
||||
|
||||
CopyCStringToPascal(urlString, urlStr);
|
||||
env->ReleaseStringUTFChars(url, urlString);
|
||||
|
||||
err = ICStart(&inst, '????'); // Use your creator code if you have one!
|
||||
if (err == noErr) {
|
||||
startSel = 0;
|
||||
endSel = urlStr[0];
|
||||
err = ICLaunchURL(inst, "\p", (char *) &urlStr[1], urlStr[0], &startSel, &endSel);
|
||||
(void) ICStop(inst);
|
||||
}
|
||||
}
|
|
@ -153,3 +153,50 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_Sys_getDirectBufferAddress
|
|||
return (jint) env->GetDirectBufferAddress(buf);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Class: org_lwjgl_Sys
|
||||
* Method: openURL
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_org_lwjgl_Sys_openURL
|
||||
(JNIEnv * env, jclass clazz, jstring url)
|
||||
{
|
||||
const char * urlString = env->GetStringUTFChars(url, NULL);
|
||||
|
||||
char command[256];
|
||||
strcpy(command, "");
|
||||
strcat(command, "rundll32 url.dll,FileProtocolHandler ");
|
||||
strncat(command, urlString, 200); // Prevent buffer overflow
|
||||
env->ReleaseStringUTFChars(url, urlString);
|
||||
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
|
||||
ZeroMemory( &si, sizeof(si) );
|
||||
si.cb = sizeof(si);
|
||||
ZeroMemory( &pi, sizeof(pi) );
|
||||
|
||||
// Start the child process.
|
||||
if( !CreateProcess( NULL, // No module name (use command line).
|
||||
command, // Command line.
|
||||
NULL, // Process handle not inheritable.
|
||||
NULL, // Thread handle not inheritable.
|
||||
FALSE, // Set handle inheritance to FALSE.
|
||||
0, // No creation flags.
|
||||
NULL, // Use parent's environment block.
|
||||
NULL, // Use parent's starting directory.
|
||||
&si, // Pointer to STARTUPINFO structure.
|
||||
&pi ) // Pointer to PROCESS_INFORMATION structure.
|
||||
)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
printf("Failed to open URL %s\n", urlString);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Close process and thread handles.
|
||||
CloseHandle( pi.hProcess );
|
||||
CloseHandle( pi.hThread );
|
||||
|
||||
}
|
||||
|
|
|
@ -515,7 +515,7 @@ static void UpdateMouseFields(JNIEnv *env, jclass clsMouse) {
|
|||
}
|
||||
}
|
||||
jbyteArray mButtonsArray = (jbyteArray) env->GetStaticObjectField(clsMouse, fidMButtons);
|
||||
env->SetByteArrayRegion(mButtonsArray, 0, mButtoncount, diMouseState.rgbButtons);
|
||||
env->SetByteArrayRegion(mButtonsArray, 0, mButtoncount, (const signed char *) diMouseState.rgbButtons);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue