Skip to content

Instantly share code, notes, and snippets.

View Plnda's full-sized avatar

Jason Meulenhoff Plnda

View GitHub Profile
@Plnda
Plnda / test.cs
Last active October 29, 2022 21:25
unity.cs
```
using System;
using Framework.DI;
using UnityEngine;
using UnityEngine.Networking;
namespace Game.Gameplay
{
public class ShootBehaviour : MonoBehaviour
{
var projectileCount = 3;
var initialOffset = -30;
for(int i = 0; i < projectileCount; i++) {
var projectile = Instantiate(projectile, cam.transform.position, cam.transform.rotation * Quaternion.Euler(0,initialOffset,0));
initalOffset += 30;
projectile.GetComponent<Rigidbody>().AddForce(projectile.transform.forward * 15, ForceMode.Impulse);
}
@Plnda
Plnda / controller.js
Last active August 31, 2024 08:37
Get native gamepad working with SteamDeck
var HID = require('node-hid');
const express = require('express');
// Steam Neptune Controller
var device = new HID.HID("/dev/hidraw3");
var port = 8000
var controller = {
id: "Steam Controller (Neptune)",
index: 0,
class ViewController: UIViewController {
private var webview: WKWebView!
private var controller: WebController = WebController()
override func viewDidLoad() {
super.viewDidLoad()
let configuration = WKWebViewConfiguration()
configuration.allowsInlineMediaPlayback = false
import UIKit
import WebKit
class ViewController: UIViewController {
private var webview: WKWebView!
private var controller: WebController = WebController()
override func viewDidLoad() {
super.viewDidLoad()
public class WebController: NSObject
{
@File(name: "gamepad", type: "js", decoder: { String(data: $0, encoding: .utf8) })
var gamepadScript: String?
public func setup(webview: WKWebView)
{
guard let script = gamepadScript else {
return
}
@Plnda
Plnda / gamepad.js
Last active September 15, 2020 12:26
var emulatedGamepad = {
id: "Emulated iOS Controller",
index: 0,
connected: true,
timestamp: 0,
mapping: "standard",
axes: [0, 0, 0, 0],
buttons: new Array(17).fill().map(m => ({pressed: false, touched: false, value: 0}))
}
@Plnda
Plnda / WebController.js
Created September 15, 2020 11:33
controllerData
private var controllerData: String {
guard let controller = GCController.controllers().first,
let gamepad = controller.extendedGamepad,
let buttonOptions = gamepad.buttonOptions,
let buttonHome = gamepad.buttonHome,
let leftThumbstickButton = gamepad.leftThumbstickButton,
let rightThumbstickButton = gamepad.rightThumbstickButton else {
return ""
@Plnda
Plnda / Controller.swift
Last active September 15, 2020 12:07
Controller.swift
public struct Controller: Codable
{
let axes: [Double]
let buttons: [GamePadButton?]
let connected: Bool
let id: String
let index: Int
let mapping: String
let timestamp: Double
struct ContentView: View {
@State private var initialOffset: CGFloat = 350.0
@State private var initialOpacity: Double = 0.0
private let duration = 5.0
@ObservedObject var manager = MotionManager()
var body: some View {