/** * Initialize the headset camera. * @param allowed <code>true</code> is the use of the headset camera is allowed and <code>false</code> otherwise. */ public void initCamera(boolean allowed) { hmdErrorStore.setValue(0); // clear the error store if( allowed && vrsystemFunctions != null ) { IntByReference intptr = JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRTrackedCamera_Version, hmdErrorStore); if (intptr != null){ cameraFunctions = new VR_IVRTrackedCamera_FnTable(intptr.getPointer()); if(cameraFunctions != null && hmdErrorStore.getValue() == 0 ){ cameraFunctions.setAutoSynch(false); cameraFunctions.read(); logger.config("OpenVR Camera initialized"); } } } }
/** * Initialize the VR bounds. * @return <code>true</code> if the initialization is a success and <code>false</code> otherwise. */ public boolean init(OpenVR api) { logger.config("Initialize VR bounds..."); if( vrChaperone == null ) { vrChaperone = new VR_IVRChaperone_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRChaperone_Version, api.hmdErrorStore).getPointer()); if( vrChaperone != null ) { vrChaperone.setAutoSynch(false); vrChaperone.read(); FloatByReference fbX = new FloatByReference(); FloatByReference fbZ = new FloatByReference(); vrChaperone.GetPlayAreaSize.apply(fbX, fbZ); playSize = new Vector2f(fbX.getValue(), fbZ.getValue()); logger.config("Initialize VR bounds [SUCCESS]"); return true; // init success } logger.warning("Initialize VR bounds [FAILED]."); return false; // failed to init } logger.config("Initialize VR bounds already done."); return true; // already initialized }
if (intptr != null){ if (intptr.getPointer() != null){ compositorFunctions = new VR_IVRCompositor_FnTable(intptr.getPointer()); if(compositorFunctions != null && hmdErrorStore.getValue() == 0 ){ compositorFunctions.setAutoSynch(false);
if(LIBC.sysctl(new int[]{CTL_KERN,KERN_ARGMAX},2, argmaxRef.getPointer(), size, NULL, intByRef)!=0) throw new IOException("Failed to get kern.argmax: "+LIBC.strerror(Native.getLastError()));
vrsystemFunctions = new VR_IVRSystem_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRSystem_Version, hmdErrorStore).getPointer());
public int getValue() { return getPointer().getInt(0); } }
public void setValue(int value) { getPointer().setInt(0, value); }
IntByReference intPtr = new IntByReference(); //that's the place where i'm stuck trying to initialize with Pointer constructor Pointer ptr = new Memory(Pointer.SIZE * 256); User32.INSTANCE.SystemParametersInfo(User32.SPI_GETSCREENSAVERRUNNING, 0,intPtr.getPointer(), 0); User32.INSTANCE.SystemParametersInfo(User32.SPI_GETDESKWALLPAPER,256, ptr, 0);
public void allowFragmentation(final int level, final int option_name, final boolean frag) throws IOException { final int socket = getSock(); if (socket < 0) { throw new IOException("Invalid socket!"); } final IntByReference dontfragment = new IntByReference(frag == true? 0 : 1); try { setsockopt(socket, level, option_name, dontfragment.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new IOException("setsockopt: " + strerror(e.getErrorCode())); } }
public static boolean setAddressPreference(DatagramSocket s, SOCKET_ADDR_PREFERENCE p) { if(!Platform.isLinux()) return false; int fd = getFd(s); if(fd <= 2) return false; int ret = -1; try { ret = socketOptionsHolder.setsockopt(fd, SOCKET_level.IPPROTO_IPV6.linux, p.option_name.linux, new IntByReference(p.linux).getPointer(), Pointer.SIZE); } catch(Exception e) { Logger.normal(UdpSocketHandler.class, e.getMessage(),e); } //if it fails that's fine return (ret == 0 ? true : false); } }
public void allowFragmentation(final int level, final int option_name, final boolean frag) throws IOException { final int socket = getSock(); if (socket < 0) { throw new IOException("Invalid socket!"); } final IntByReference dontfragment = new IntByReference(frag == true? 0 : 1); try { setsockopt(socket, level, option_name, dontfragment.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new IOException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public void setTrafficClass(final int tc) throws LastErrorException { final IntByReference tc_ptr = new IntByReference(tc); try { setsockopt(getSock(), IPPROTO_IPV6, IPV6_TCLASS, tc_ptr.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new RuntimeException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public void setTrafficClass(final int tc) throws IOException { final IntByReference tc_ptr = new IntByReference(tc); try { setsockopt(getSock(), IPPROTO_IP, IP_TOS, tc_ptr.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new IOException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public void setTrafficClass(final int tc) throws IOException { final IntByReference tc_ptr = new IntByReference(tc); try { setsockopt(getSock(), IPPROTO_IP, IP_TOS, tc_ptr.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new IOException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public void setTrafficClass(final int tc) throws LastErrorException { final IntByReference tc_ptr = new IntByReference(tc); try { setsockopt(getSock(), IPPROTO_IPV6, IPV6_TCLASS, tc_ptr.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new RuntimeException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public void setTrafficClass(final int tc) throws IOException { final IntByReference tc_ptr = new IntByReference(tc); try { setsockopt(getSock(), IPPROTO_IP, IP_TOS, tc_ptr.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new IOException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public void setTrafficClass(final int tc) throws LastErrorException { final IntByReference tc_ptr = new IntByReference(tc); try { setsockopt(getSock(), IPPROTO_IPV6, IPV6_TCLASS, tc_ptr.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new RuntimeException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public void setTrafficClass(final int tc) throws LastErrorException { final IntByReference tc_ptr = new IntByReference(tc); try { setsockopt(getSock(), IPPROTO_IPV6, IPV6_TCLASS, tc_ptr.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new RuntimeException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public void setTrafficClass(final int tc) throws IOException { final IntByReference tc_ptr = new IntByReference(tc); try { setsockopt(getSock(), IPPROTO_IP, IP_TOS, tc_ptr.getPointer(), Pointer.SIZE); } catch (final LastErrorException e) { throw new IOException("setsockopt: " + strerror(e.getErrorCode())); } }
@Override public Pointer getPointer(long offset) { if (Platform.getPlatform().longSize() == 32) { IntByReference ref = new IntByReference(getInt(offset)); return ref.getPointer().getPointer(0); } else { LongByReference ref = new LongByReference(getLong(offset)); return ref.getPointer().getPointer(0); } }