private static boolean initOpenVROverlay() { vrOverlay = new VR_IVROverlay_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVROverlay_Version, hmdErrorStore)); if (hmdErrorStore.get(0) == 0) { vrOverlay.setAutoSynch(false); vrOverlay.read(); logger.info("OpenVR Overlay initialized OK."); } else { String errorString = jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.get(0)).getString(0); logger.info("vrOverlay initialization failed:" + errorString); return false; } return true; }
private static boolean initOpenVROSettings() { vrSettings = new VR_IVRSettings_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRSettings_Version, hmdErrorStore)); if (hmdErrorStore.get(0) == 0) { vrSettings.setAutoSynch(false); vrSettings.read(); logger.info("OpenVR Settings initialized OK."); } else { String errorString = jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.get(0)).getString(0); logger.info("OpenVROSettings initialization failed:" + errorString); return false; } return true; }
JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ManufacturerName_String, str1, 128, hmdErrorStore); if( hmdErrorStore.getValue() == 0 ) completeName += str1.getString(0); vrsystemFunctions.GetStringTrackedDeviceProperty.apply(JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd, JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ModelNumber_String, str2, 128, hmdErrorStore); if( hmdErrorStore.getValue() == 0 ) completeName += " " + str2.getString(0); if( completeName.length() > 0 ) { completeName = completeName.toLowerCase(Locale.ENGLISH).trim();
/** * Turn on the keyboard overlay. This is a keyboard that hovers in front of the user, that can be typed upon by * pointing the ray extending from the top of the controller at the key the user wants to press. * @param showingState - true or false * @return - true if successful. If this call fails, an error is logged. */ public static boolean setKeyboardOverlayShowing(boolean showingState) { int ret; if (showingState) { Pointer pointer = new Memory(3); pointer.setString(0, "mc"); Pointer empty = new Memory(1); empty.setString(0, ""); ret = vrOverlay.ShowKeyboard.apply(0, 0, pointer, 256, empty, (byte) 1, 0); keyboardShowing = 0 == ret; //0 = no error, > 0 see EVROverlayError if (ret != 0) { logger.error("VR Overlay Error: " + vrOverlay.GetOverlayErrorNameFromEnum.apply(ret).getString(0)); } } else { try { vrOverlay.HideKeyboard.apply(); } catch (Error e) { logger.error("Error bringing up keyboard overlay: " + e.toString()); } keyboardShowing = false; } return keyboardShowing; }
vrCompositor.SetTrackingSpace.apply(JOpenVRLibrary.ETrackingUniverseOrigin.ETrackingUniverseOrigin_TrackingUniverseStanding); } else { String errorString = jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.get(0)).getString(0); logger.info("vrCompositor initialization failed:" + errorString); return false;
private static boolean initializeJOpenVR() { hmdErrorStore = IntBuffer.allocate(1); vrSystem = null; JOpenVRLibrary.VR_InitInternal(hmdErrorStore, JOpenVRLibrary.EVRApplicationType.EVRApplicationType_VRApplication_Scene); if (hmdErrorStore.get(0) == 0) { // ok, try and get the vrSystem pointer.. vrSystem = new VR_IVRSystem_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRSystem_Version, hmdErrorStore)); } if (vrSystem == null || hmdErrorStore.get(0) != 0) { String errorString = jopenvr.JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.get(0)).getString(0); logger.info("vrSystem initialization failed:" + errorString); return false; } else { vrSystem.setAutoSynch(false); vrSystem.read(); logger.info("OpenVR initialized & VR connected."); hmdTrackedDevicePoseReference = new TrackedDevicePose_t.ByReference(); hmdTrackedDevicePoses = (TrackedDevicePose_t[]) hmdTrackedDevicePoseReference.toArray(JOpenVRLibrary.k_unMaxTrackedDeviceCount); // disable all this stuff which kills performance hmdTrackedDevicePoseReference.setAutoRead(false); hmdTrackedDevicePoseReference.setAutoWrite(false); hmdTrackedDevicePoseReference.setAutoSynch(false); for (int i = 0; i < JOpenVRLibrary.k_unMaxTrackedDeviceCount; i++) { hmdTrackedDevicePoses[i].setAutoRead(false); hmdTrackedDevicePoses[i].setAutoWrite(false); hmdTrackedDevicePoses[i].setAutoSynch(false); } } return true; }
logger.severe("OpenVR Initialize Result: " + JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.getValue()).getString(0)); logger.severe("Initializing OpenVR system [FAILED]"); return false;
str = pchValue.getString(0); } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_BufferTooSmall){ throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")");
/** * Copy native memory to a Java String. The encoding used is obtained * form {@link Native#getDefaultStringEncoding()}. * * @param offset byte offset from pointer to start reading bytes * @return the <code>String</code> value being pointed to */ public String getString(long offset) { return getString(offset, Native.getDefaultStringEncoding()); }
@Override public String getString(long offset, String encoding) { // NOTE: we only make sure the start of the string is within bounds boundsCheck(offset, 0); return super.getString(offset, encoding); }
/** * @param error error * @return an error message. */ public static String strError(int error) { return NativeMappings.pcap_strerror(error).getString(0); }
@Override public String toString() { boolean wide = WIDE_STRING.equals(encoding); return (wide ? pointer.getWideString(0) : pointer.getString(0, encoding)); }
/** Read back from native memory. */ @Override public void read() { boolean returnWide = original instanceof WString[]; boolean wide = NativeString.WIDE_STRING.equals(encoding); for (int si=0;si < original.length;si++) { Pointer p = getPointer(si * Native.POINTER_SIZE); Object s = null; if (p != null) { s = wide ? p.getWideString(0) : p.getString(0, encoding); if (returnWide) s = new WString((String)s); } original[si] = s; } }
/** * Call the native function being represented by this object * * @param callFlags calling convention to be used * @param args * Arguments to pass to the native function * @param wide whether the native string uses <code>wchar_t</code>; * if false, <code>char</code> is assumed * @return The value returned by the target native function, as a String */ private String invokeString(int callFlags, Object[] args, boolean wide) { Pointer ptr = invokePointer(callFlags, args); String s = null; if (ptr != null) { if (wide) { s = ptr.getWideString(0); } else { s = ptr.getString(0, encoding); } } return s; }
RuntimeException e = new UnsupportedOperationException("sandbox_init(): " + errorBuf.getString(0)); libc_mac.sandbox_free_error(errorBuf); throw e;
/** * @return an error message. * @throws NotOpenException if this PcapHandle is not open. */ public String getError() throws NotOpenException { if (!open) { throw new NotOpenException(); } if (!handleLock.readLock().tryLock()) { throw new NotOpenException(); } try { if (!open) { throw new NotOpenException(); } return NativeMappings.pcap_geterr(handle).getString(0); } finally { handleLock.readLock().unlock(); } }
/** * Gets recognized text. * * @param filename input file name. Needed only for reading a UNLV zone * file. * @param pageNum page number; needed for hocr paging. * @return the recognized text */ protected String getOCRText(String filename, int pageNum) { if (filename != null && !filename.isEmpty()) { TessBaseAPISetInputName(handle, filename); } Pointer utf8Text = renderedFormat == RenderedFormat.HOCR ? TessBaseAPIGetHOCRText(handle, pageNum - 1) : TessBaseAPIGetUTF8Text(handle); String str = utf8Text.getString(0); TessDeleteText(utf8Text); return str; }
/** * Gets recognized text. * * @param filename input file name. Needed only for reading a UNLV zone * file. * @param pageNum page number; needed for hocr paging. * @return the recognized text */ protected String getOCRText(String filename, int pageNum) { if (filename != null && !filename.isEmpty()) { api.TessBaseAPISetInputName(handle, filename); } Pointer utf8Text = renderedFormat == RenderedFormat.HOCR ? api.TessBaseAPIGetHOCRText(handle, pageNum - 1) : api.TessBaseAPIGetUTF8Text(handle); String str = utf8Text.getString(0); api.TessDeleteText(utf8Text); return str; }
String text = ptr.getString(0); api.TessDeleteText(ptr); float confidence = api.TessResultIteratorConfidence(ri, pageIteratorLevel);