Skip to content

MortalFlesh/XboxController

Repository files navigation

XBox Controller (Wrapper)

NuGet Version and Downloads count Build Status Build Status

It is F# wrapper for BrandonPotter/XBoxController

For now, I'm only able to use it on Windows machine, since it uses kernel32.dll inside, which is only on Windows.

Simple example

async {
    let! controller = Controller.waitFor Controller.Any
    printfn "Controller is connected (%A)" controller

    let! _ =
        [
            controller |> Controller.onButtonPressedAsync Medium (function
                | button -> printfn "Button pressed %A" button
            )

            controller |> Controller.onPositionChangedAsync Medium (function
                | PositionChanged.Lt (TriggerPressedPower power) -> printfn "Lt -> %A" power
                | PositionChanged.Rt (TriggerPressedPower power) -> printfn "Rt -> %A" power

                | PositionChanged.ThumbPadLeft { X = x; Y = y } -> printfn "ThumbPadLeft X: %A, Y: %A" x y
                | PositionChanged.ThumbPadRight { X = x; Y = y } -> printfn "ThumbPadRight X: %A, Y: %A" x y
            )
        ]
        |> Async.Parallel

    return ()
}

About

F# Wrapper for XBoxController .NET library

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published