Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment issues? #5

Open
aorr76 opened this issue Jun 8, 2015 · 3 comments
Open

Environment issues? #5

aorr76 opened this issue Jun 8, 2015 · 3 comments

Comments

@aorr76
Copy link

aorr76 commented Jun 8, 2015

Attempting to build on Ubuntu 14.04.2 LTS. See errors below. Any ideas?

$ cabal build
Building EnableRazer-0.0.4...
Preprocessing executable 'EnableRazer' for EnableRazer-0.0.4...
[1 of 1] Compiling Main             ( src/Main.hs, dist/build/EnableRazer/EnableRazer-tmp/Main.o )

src/Main.hs:56:3:
    Couldn't match expected type `Integer
                                  -> Integer -> BS.ByteString -> Timeout -> IO ()'
                with actual type `IO ()'
    The function `writeControlExact' is applied to 8 arguments,
    but its type `DeviceHandle -> ControlSetup -> WriteExactAction'
    has only four
    In a stmt of a 'do' block:
      writeControlExact
        devHndl Class ToInterface _SET_REPORT 768 2 cdata noTimeout
    In the expression:
      do { putStrLn "WRITING SET_REPORT";
           writeControlExact
             devHndl Class ToInterface _SET_REPORT 768 2 cdata noTimeout }

src/Main.hs:57:5:
    Couldn't match expected type `ControlSetup'
                with actual type `RequestType'
    In the second argument of `writeControlExact', namely `Class'
    In a stmt of a 'do' block:
      writeControlExact
        devHndl Class ToInterface _SET_REPORT 768 2 cdata noTimeout
    In the expression:
      do { putStrLn "WRITING SET_REPORT";
           writeControlExact
             devHndl Class ToInterface _SET_REPORT 768 2 cdata noTimeout }

src/Main.hs:58:5:
    Couldn't match expected type `BS.ByteString'
                with actual type `Recipient'
    In the third argument of `writeControlExact', namely `ToInterface'
    In a stmt of a 'do' block:
      writeControlExact
        devHndl Class ToInterface _SET_REPORT 768 2 cdata noTimeout
    In the expression:
      do { putStrLn "WRITING SET_REPORT";
           writeControlExact
             devHndl Class ToInterface _SET_REPORT 768 2 cdata noTimeout }

src/Main.hs:59:5:
    Couldn't match type `GHC.Word.Word8' with `Int'
    Expected type: Timeout
      Actual type: Request
    In the fourth argument of `writeControlExact', namely `_SET_REPORT'
    In a stmt of a 'do' block:
      writeControlExact
        devHndl Class ToInterface _SET_REPORT 768 2 cdata noTimeout
    In the expression:
      do { putStrLn "WRITING SET_REPORT";
           writeControlExact
             devHndl Class ToInterface _SET_REPORT 768 2 cdata noTimeout }
@OvermindDL1
Copy link

Same issue with latest Haskell.

@OvermindDL1
Copy link

For anyone curious, this seems to fix it:

diff --git a/EnableRazer.cabal b/EnableRazer.cabal
index 5db0cf0..6b87d0f 100644
--- a/EnableRazer.cabal
+++ b/EnableRazer.cabal
@@ -3,7 +3,7 @@ version:        0.0.4
 cabal-version:  -any
 build-type:     Simple
 license:        AllRightsReserved
-build-depends:  base -any, bytestring -any, vector -any, usb -any
+build-depends:  base -any, bytestring -any, vector -any, usb >= 1.3.0.2
 description:    .
 author:         Audrius Šaikūnas
 executable:     EnableRazer
diff --git a/src/Main.hs b/src/Main.hs
index 03b8e01..889601d 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -49,22 +49,24 @@ withDevice venId prodIds hnd = do
   if V.null devs1 
     then return $ error "Device not found"
     else V.mapM_ hnd devs1
+
+controlSetup :: ControlSetup
+controlSetup = ControlSetup
+  { controlSetupRequestType = Class
+  , controlSetupRecipient = ToInterface
+  , controlSetupRequest = _SET_REPORT
+  , controlSetupValue = 0x0300
+  , controlSetupIndex = 2
+  }

 enableRazer :: DeviceHandle -> IO ()
 enableRazer devHndl = do
   putStrLn "WRITING SET_REPORT"
-  writeControlExact devHndl
-    Class 
-    ToInterface 
-    _SET_REPORT 
-    0x0300 
-    2
-    cdata
-    noTimeout
+  writeControlExact devHndl controlSetup cdata noTimeout

 main :: IO ()
 main = do
-  withDevice 0x1532 [0x010d, 0x010e, 0x010f] $ \dev -> do
+  withDevice 0x1532 [0x0040, 0x010d, 0x010e, 0x010f] $ \dev -> do
   withDeviceHandle dev $ \devHndl ->
     withDetachedKernelDriver devHndl 2 $
     withClaimedInterface devHndl 2 $ do

@evandrix
Copy link

evandrix commented Jul 1, 2016

Yes, this works for me perfectly; on XUbuntu 16.04 LTS. Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants