hidapi 0.1 → 0.1.1
raw patch · 2 files changed
+11/−4 lines, 2 filesdep +deepseq-genericsnew-uploader
Dependencies added: deepseq-generics
Files
- System/HIDAPI.hsc +9/−3
- hidapi.cabal +2/−1
System/HIDAPI.hsc view
@@ -1,4 +1,4 @@-{-# LANGUAGE ForeignFunctionInterface, DeriveDataTypeable #-}+{-# LANGUAGE ForeignFunctionInterface, DeriveDataTypeable, DeriveGeneric #-} #include "hidapi/hidapi.h" @@ -22,6 +22,7 @@ ) where import Control.Applicative+import Control.DeepSeq.Generics import Control.Exception import Control.Monad import Data.ByteString@@ -31,6 +32,7 @@ import Foreign import Foreign.C.Types import Foreign.C.String+import GHC.Generics (Generic) type Hid_Device_Ptr = Ptr () -- used where hid_device* is used on C side newtype Device = Device Hid_Device_Ptr@@ -86,8 +88,10 @@ , usagePage :: Word16 , usage :: Word16 , interfaceNumber :: InterfaceNumber- } deriving (Show)+ } deriving (Show, Generic) +instance NFData DeviceInfo where rnf = genericRnf+ peekOptString :: Ptr CWchar -> IO (Maybe String) peekOptString p | p == nullPtr = return Nothing@@ -110,12 +114,14 @@ hid_error :: Hid_Device_Ptr -> IO CWString data HIDAPIException = HIDAPIException String String- deriving (Data, Typeable)+ deriving (Data, Typeable, Generic) instance Show HIDAPIException where showsPrec _ (HIDAPIException a c) = showString a . showString ": " . showString c instance Exception HIDAPIException++instance NFData HIDAPIException where rnf = genericRnf -- TODO As of https://github.com/signal11/hidapi/issues/123 it is unclear -- whether the passed in pointer may be NULL, and if hid_error ever
hidapi.cabal view
@@ -1,5 +1,5 @@ name: hidapi-version: 0.1+version: 0.1.1 build-type: Simple cabal-version: >= 1.6 category: Hardware@@ -21,4 +21,5 @@ build-depends: base < 5 , bytestring >= 0.10+ , deepseq-generics >= 0.1 extra-libraries: hidapi-hidraw