https://github.com/functionally/vrpn
https://github.com/functionally/vrpn
Last synced: 7 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/functionally/vrpn
- Owner: functionally
- License: mit
- Created: 2022-11-10T06:24:32.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-10T06:53:46.000Z (about 3 years ago)
- Last Synced: 2025-02-24T08:18:13.197Z (11 months ago)
- Language: Haskell
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: ReadMe.md
- License: LICENSE
Awesome Lists containing this project
README
Bindings for VRPN
=================
This package contains bindings to VRPN, <> and is loosely modeled on the code in <>. This has been tested using VRPN 07.30 on Linux. It requires the VRPN C++ header files.
Please report issues at <>.
Skeletal example illustrating the use of VRPN bindings
------------------------------------------------------
```haskell
data ButtonType = LeftButton | RightButton
deriving (Enum, Eq, Show)
main :: IO ()
main =
do
putStrLn "Press the left button to exit."
done <- newEmptyMVar
let
-- A remote button that signals completion when the left button is released.
button :: Device Int ButtonType Double
button =
Button "spacenav0@localhost"
$ Just
$ \time button state ->
do
print (time, button, state)
if button == LeftButton && not state
then void $ tryPutMVar done ()
else return ()
-- An analog device.
analog :: Device Int Int Int Double
analog = Analog "spacenav0@localhost"
$ Just
$ curry print
-- Open the remote devices.
devices <- sequence [openDevice button, openDevice analog]
-- Loop until a signal to complete is received.
mainLoops (not <$> isEmptyMVar done) 10 devices
-- Close the remote devices.
mapM_ closeDevice devices
```