CARVIEW |
Select Language
HTTP/2 302
date: Thu, 31 Jul 2025 03:02:27 GMT
content-type: text/html; charset=utf-8
content-length: 0
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
location: https://gist.github.com/mattdesl/4255483
cache-control: no-cache
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
set-cookie: _gh_sess=mwJ%2FED3X5FVLn9QyBRyuP5%2BTgFak6G2wN0c43wWJpf4Hc6LI1XNCY75VC3W%2FQ%2F9hDJ8qYs%2BMcGAM1gDaig5qHiTHasYVtmcpEW5ciyVy1Ttk6X3rDJT%2BzJwQT3VhwMfu9T8F1Hl%2FVEeAOzQ4WqI91v9fGU0KiPDO%2FI%2FojtqshoHNwJpXYIz3nZU8sILx67xpAGe9A7bxz%2FJs0CDt%2Be%2BBOHmqpGD2y1GUsBtY7hh2%2Bx1B2XhJ%2B2ie3rGkayDSVqbwtlAz5jP8pQhFCPDghmlbwg%3D%3D--dNkSZi9JAWblnHky--6XjixJvLpSERCkA%2FKj1DLA%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.162850687.1753930947; Path=/; Domain=github.com; Expires=Fri, 31 Jul 2026 03:02:27 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Fri, 31 Jul 2026 03:02:27 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 904A:33DAA7:19CBA1:268242:688ADCC3
HTTP/2 200
date: Thu, 31 Jul 2025 03:02:28 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"ddb1d501ac2934cb2f3dff01444ea93e"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: origin-when-cross-origin, strict-origin-when-cross-origin
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com wss://alive-staging.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
x-github-request-id: 904A:33DAA7:19CBB5:268258:688ADCC3
LibGDX: Hide Mouse Cursor (Desktop) · GitHub
Show Gist options
Save mattdesl/4255483 to your computer and use it in GitHub Desktop.
{{ message }}
Instantly share code, notes, and snippets.
Created
December 11, 2012 02:44
-
Star
4
(4)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save mattdesl/4255483 to your computer and use it in GitHub Desktop.
LibGDX: Hide Mouse Cursor (Desktop)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.nio.IntBuffer; | |
import org.lwjgl.BufferUtils; | |
import org.lwjgl.LWJGLException; | |
import org.lwjgl.input.Mouse; | |
import com.badlogic.gdx.Application.ApplicationType; | |
import com.badlogic.gdx.ApplicationListener; | |
import com.badlogic.gdx.Gdx; | |
import com.badlogic.gdx.Input.Keys; | |
import com.badlogic.gdx.InputAdapter; | |
import com.badlogic.gdx.backends.lwjgl.LwjglApplication; | |
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; | |
import com.badlogic.gdx.graphics.GL10; | |
import com.badlogic.gdx.graphics.OrthographicCamera; | |
import com.badlogic.gdx.graphics.Texture; | |
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | |
import com.badlogic.gdx.utils.GdxRuntimeException; | |
/** NOTE: Presumably LibGDX will implement this functionality in time, making | |
* this snippet obsolete. */ | |
public class HideCursor implements ApplicationListener { | |
public static void setHWCursorVisible(boolean visible) throws LWJGLException { | |
if (Gdx.app.getType() != ApplicationType.Desktop && Gdx.app instanceof LwjglApplication) | |
return; | |
if (emptyCursor == null) { | |
if (Mouse.isCreated()) { | |
int min = org.lwjgl.input.Cursor.getMinCursorSize(); | |
IntBuffer tmp = BufferUtils.createIntBuffer(min * min); | |
emptyCursor = new org.lwjgl.input.Cursor(min, min, min / 2, min / 2, 1, tmp, null); | |
} else { | |
throw new LWJGLException( | |
"Could not create empty cursor before Mouse object is created"); | |
} | |
} | |
if (Mouse.isInsideWindow()) | |
Mouse.setNativeCursor(visible ? null : emptyCursor); | |
} | |
public static void main(String[] args) { | |
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration(); | |
cfg.title = "atmos"; | |
cfg.useGL20 = true; | |
cfg.width = 480; | |
cfg.height = 320; | |
LwjglApplication app = new LwjglApplication(new HideCursor(), cfg); | |
} | |
SpriteBatch batch; | |
OrthographicCamera camera; | |
static org.lwjgl.input.Cursor emptyCursor; | |
boolean hwVisible = false; | |
Texture cursor; | |
int xHotspot, yHotspot; | |
@Override | |
public void create() { | |
batch = new SpriteBatch(); | |
camera = new OrthographicCamera(); | |
cursor = new Texture(Gdx.files.internal("data/cursor.png")); | |
xHotspot = 0; | |
yHotspot = cursor.getHeight(); // lower left origin! | |
// press SPACE to toggle software cursor | |
Gdx.input.setInputProcessor(new InputAdapter() { | |
public boolean keyDown(int key) { | |
if (key == Keys.SPACE) { | |
hwVisible = !hwVisible; | |
return true; | |
} | |
return false; | |
} | |
}); | |
} | |
@Override | |
public void resize(int width, int height) { | |
camera.setToOrtho(false, width, height); | |
batch.setProjectionMatrix(camera.combined); | |
} | |
@Override | |
public void render() { | |
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT); | |
Gdx.gl.glClearColor(0.5f, 0.5f, 0.5f, 1f); | |
try { | |
setHWCursorVisible(hwVisible); | |
} catch (LWJGLException e) { | |
throw new GdxRuntimeException(e); | |
} | |
batch.begin(); | |
// ... draw sprites ... | |
// draw SW cursor | |
if (!hwVisible) { | |
int x = Gdx.input.getX(); | |
int y = Gdx.input.getY(); | |
batch.draw(cursor, x - xHotspot, Gdx.graphics.getHeight() - y - 1 - yHotspot); | |
} | |
batch.end(); | |
} | |
@Override | |
public void pause() { | |
} | |
@Override | |
public void resume() { | |
} | |
@Override | |
public void dispose() { | |
cursor.dispose(); | |
batch.dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can’t perform that action at this time.