hcwiid 0.0.1 → 0.0.2
raw patch · 6 files changed
+66/−4 lines, 6 filesnew-uploaderPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ System.CWiid: cwiidSetRumble :: CWiidWiimote -> CUChar -> IO CInt
Files
- CHANGELOG +4/−0
- README +16/−0
- System/CWiid.hsc +10/−1
- hcwiid.cabal +5/−3
- test/Makefile +14/−0
- test/Test.hs +17/−0
+ CHANGELOG view
@@ -0,0 +1,4 @@+2014-05-01 Ivan Perez <ivan.perez@keera.co.uk>++ * hcwiid.cabal: Version bump. Adds new maitainer, repo, extra files.+ * API: adds set_rumble.
+ README view
@@ -0,0 +1,16 @@+This is a refurbished version of hcwiid. It will include most of cwiid.+If you find something in cwiid which is not included here and you need it,+please let me know/send a pull request.++First things first: How the frag do I compile the tests in test/?++You need to do two things:+1) Compile the program with -rtsopts (enable RTS command line flags)+2) Run the program with +RTS -V0+ This will disable the internal ticks used for profiling, which+ in turn will make the runtime system not use the SIGALRM signal,+ which libluetooth uses for its own internal purposes and is necessary+ to connect to the wiimote.++ (This bit is the work of Paolo Capriotti, whose mastery of GHC+ baffles me every time.)
System/CWiid.hsc view
@@ -1,7 +1,8 @@ {-# LANGUAGE ForeignFunctionInterface #-} module System.CWiid- (cwiidOpen, cwiidSetLed, cwiidSetRptMode, cwiidGetBtnState,+ (cwiidOpen, cwiidSetLed, cwiidSetRptMode, cwiidSetRumble,+ cwiidGetBtnState, cwiidLed1, cwiidLed2, cwiidLed3, cwiidLed4, combineCwiidLedFlag, cwiidBtn2, cwiidBtn1, cwiidBtnB, cwiidBtnA, cwiidBtnMinus, cwiidBtnHome, cwiidBtnLeft, cwiidBtnRight, cwiidBtnDown, cwiidBtnUp,@@ -136,6 +137,10 @@ cwiidSetRptMode wm = c_cwiid_set_rpt_mode handle 2 -- set BTN where handle = unCWiidWiimote wm +cwiidSetRumble :: CWiidWiimote -> CUChar -> IO CInt+cwiidSetRumble wm rm = c_cwiid_set_rumble handle rm+ where handle = unCWiidWiimote wm+ cwiidGetBtnState :: CWiidWiimote -> IO CWiidBtnFlag cwiidGetBtnState wm = alloca $ \wiState -> do@@ -161,6 +166,10 @@ -- int cwiid_set_rpt_mode(cwiid_wiimote_t *wiimote, uint8_t rpt_mode); foreign import ccall safe "cwiid_set_rpt_mode" c_cwiid_set_rpt_mode+ :: Ptr () -> CUChar -> IO CInt++-- int cwiid_set_rumble(cwiid_wiimote_t *wiimote, uint8_t rumble);+foreign import ccall safe "cwiid_set_rumble" c_cwiid_set_rumble :: Ptr () -> CUChar -> IO CInt -- int cwiid_get_state(cwiid_wiimote_t *wiimote, struct cwiid_state *state);
hcwiid.cabal view
@@ -1,7 +1,7 @@ Name: hcwiid-Version: 0.0.1+Version: 0.0.2 Author: Kiwamu Okabe <kiwamu@debian.or.jp>-Maintainer: Kiwamu Okabe <kiwamu@debian.or.jp>+Maintainer: Ivan Perez <ivan.perez@keera.co.uk> License: GPL-2 License-File: COPYING Synopsis: Library to interface with the wiimote@@ -16,6 +16,8 @@ Homepage: https://gitorious.org/hcwiid Tested-with: GHC == 7.0.4 +Extra-source-files: README CHANGELOG test/Test.hs test/Makefile+ Library GHC-Options: -Wall Exposed-Modules: System.CWiid@@ -30,4 +32,4 @@ Source-Repository head Type: git- Location: git://gitorious.org/hcwiid/hcwiid.git+ Location: git@github.com:ivanperez-keera/hcwiid.git
+ test/Makefile view
@@ -0,0 +1,14 @@+all: Test++Test: Test.hs+ ghc --make -rtsopts -Wall Test.hs -o Test++lint: Test.hs+ hlint -c Test.hs++clean:+ rm -rf Test+ rm -rf *.hi *.o+ rm -rf *~++.PHONY: lint clean
+ test/Test.hs view
@@ -0,0 +1,17 @@+module Main where++import Prelude+import Control.Monad+import System.CWiid+import System.Posix.Unistd++main :: IO ()+main = do+ putStrLn "Put Wiimote in discoverable mode now (press 1+2)..."+ (Just wm) <- cwiidOpen+ putStrLn "found!"+ _ <- cwiidSetLed wm+ _ <- cwiidSetRptMode wm+ _ <- forever $ do _ <- usleep 300000+ cwiidGetBtnState wm >>= print+ return () -- not reach