Skip to content

Instantly share code, notes, and snippets.

Avatar
🍎
Coding

Sven Andersson andsve

🍎
Coding
View GitHub Profile
@andsve
andsve / thrustmasters_t150_pro_USB_report_data.txt
Last active Mar 27, 2021
Thrustmasters T150 Pro USB, Mac data report
View thrustmasters_t150_pro_USB_report_data.txt
Investigating values in the report data for Thrustmasters T150 Pro (including and connected pedals) when connected to a MacBook Pro.
The wheel is set in the PS4 mode, NOT the "recommended" PC mode "PS3".
The values were snooped up using Wireshark, listening to the USB.
Vendor: 0x44F (1103)
Product: 0xB66D (46701)
(Note: The values were recorded while the "switch clutch and acc" mode was enabled, sadly... But hopefully it should only be those two "axis" being swapped.)
Example of report data (in idle):
@andsve
andsve / neeze.h
Created Jan 16, 2021
snippets for reading nes controller 1 input (using minifb)
View neeze.h
// ...
enum GAMEPAD_ID
{
GAMEPAD_1 = 0,
GAMEPAD_2 = 1,
GAMEPAD_MAX = GAMEPAD_2,
};
enum GAMEPAD_BUTTON
View build.sh
g++ -MMD -MP -MP -DDEBUG -DSOKOL_GLCORE33 -I"/usr/include/gtk-3.0" -I"/usr/include/cairo" -I"/usr/include/pango-1.0" -I"/usr/include/harfbuzz" -I"/usr/include/atk-1.0" -I"/usr/include/gdk-pixbuf-2.0" -I"/usr/include/glib-2.0" -I"/usr/lib/x86_64-linux-gnu/glib-2.0/include" -g -m64 -fno-exceptions -fno-rtti -Wall -Werror -Wno-deprecated-declarations -m64 -lstdc++ -Wl,--no-as-needed -ldl -lXi -lXrandr -lXxf86vm -lXinerama -lXcursor -lrt -rdynamic -lpthread -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lGL -lX11 -lm sokol_gtk.cpp -o "sokol_gtk.out"
g++ -MMD -MP -MP -DDEBUG -DSOKOL_GLCORE33 -I"/usr/include/gtk-3.0" -I"/usr/include/cairo" -I"/usr/include/pango-1.0" -I"/usr/include/harfbuzz" -I"/usr/include/atk-1.0" -I"/usr/include/gdk-pixbuf-2.0" -I"/usr/include/glib-2.0" -I"/usr/lib/x86_64-linux-gnu/glib-2.0/include" -g -m64 -fno-exceptions -fno-rtti -Wall -Werror -Wno-deprecated-declarations -m64 -lstdc++ -Wl,--no-as
@andsve
andsve / app_delegate.c
Created Jan 17, 2019
A simple implementation of a NSApplicationDelegate and two methods (openFile:, openFiles:) in pure C.
View app_delegate.c
/*
app_delegate.c
1. Compile and link with:
$ clang -g -o AppInC app_delegate.c -lobjc -framework Foundation -framework AppKit -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
2. Create a Info.plist with:
[[
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
@andsve
andsve / gist:03ef7c2f911d3b061c55
Last active Aug 29, 2015
Faking a JavaScript "local" context + exporting predefined specific functions.
View gist:03ef7c2f911d3b061c55
function FakeContext( src ) {
return (Function( '"use strict";' +
"if (this != window) {" +
" for (var __i in this) {" +
" eval( 'var ' + __i + ' = this[ __i ];' );" +
" }" +
"}" +
src +
"\n" +
"if (typeof(initialize) != 'undefined') { this.initialize = initialize; };" +
@andsve
andsve / Makefile
Created Oct 8, 2014
Ogre 1.10.x Test for Emscripten
View Makefile
emsc:
em++ ogre_test.cpp -I/usr/ogre/OgreMain/include/ -I/usr/ogre/build/include/ -I/usr/ogre/RenderSystems/GLES2/include/ -I/usr/ogre/PlugIns/OctreeSceneManager/include/ -I/usr/ogre/Components/RTShaderSystem/include/ -o ogre_test.bc -Werror
em++ ogre_test.bc /usr/ogre/build_static/lib/libRenderSystem_GLES2Static.a /usr/ogre/build_static/lib/libPlugin_OctreeSceneManagerStatic.a /usr/ogre/build_static/lib/libOgreRTShaderSystemStatic.a /usr/ogre/build_static/lib/libOgreMainStatic.a -o ogre.html --preload-file assets/plugins.cfg --preload-file assets/media/models/ogrehead.mesh --preload-file assets/media/materials/scripts/Ogre.material --preload-file assets/media/materials/scripts/cool.frag --preload-file assets/media/materials/scripts/cool.vs
native:
g++ -L/usr/lib/x86_64-linux-gnu/ -lfreeimage -lpthread -lX11 -lXt -lXmu -lXaw -lm -lGL -lGLU -lXrandr ogre_test.cpp -I/usr/ogre/OgreMain/include/ -I/usr/ogre/build/include/ -I/usr/ogre/RenderSystems/GL/include/ -I/usr/ogre/PlugIns/OctreeSceneManager/include/ -I
View mapgen.lua
--[[
http://people.ee.ethz.ch/~pascmu/documents/procedural_modeling_of_cities__siggraph2001.pdf
]]
--[[
from: http://www.newton64.ca/blog/?p=747#7472
@andsve
andsve / JSON.lua
Created Mar 10, 2012
BigBrother Sweden Tweet-Getter
View JSON.lua
-- -*- coding: utf-8 -*-
--
-- Copyright 2010-2011 Jeffrey Friedl
-- http://regex.info/blog/
--
local VERSION = 20111207.5 -- version history at end of file
local OBJDEF = { VERSION = VERSION }
--
-- Simple JSON encoding and decoding in pure Lua.
@andsve
andsve / Unblock SOPA
Created Jan 18, 2012
Copy and paste into URL bar while visiting Wikipedia, press enter and you should be able to see the article again. PROTIP: Make it a bookmark for easy access!
View Unblock SOPA
javascript:e=["mw-page-base","mw-head-base","content","mw-head","mw-panel","footer"];for(var l in e){document.getElementById(e[l]).style.display="block";};document.getElementById("mw-sopaOverlay").style.display="none";void(0);
View imgcache2.lua
module("modules/imgcache2/imgcache2")
function parse_message(bot, msg)
local i,j,chan,s = string.find(msg, ":.-!.- PRIVMSG (.-) :(.+)")
if not (i == nil) then
function db_connect()
local luasql = require("luasql.sqlite3")
local env = luasql.sqlite3()
local conn = env:connect("imgcache2.sqlite")