sdl2-2.4.1.0: Both high- and low-level bindings to the SDL library (version 2.0.4+).

Safe Haskell | Safe
Language | Haskell2010

SDL.Power

Contents

- Power Status

Synopsis

- getPowerInfo :: (Functor m, MonadIO m) => m PowerState
- data PowerState
  - = Battery BatteryState Charge
  - | Mains
  - | UnknownPowerState
- data BatteryState
  - = Draining
  - | Charged
  - | Charging
- data Charge = Charge {
  - chargeSecondsLeft :: Maybe CInt
  - chargePercent :: Maybe CInt
  }

# Power Status

getPowerInfo :: (Functor m, MonadIO m) => m PowerState Source #

Current power supply details.

Throws `SDLException` if the current power state can not be determined.

See `SDL_GetPowerInfo` for C documentation.

data PowerState Source #

Information about the power supply for the user's environment

Constructors

Battery BatteryState Charge | The user is on a battery powered device. See `BatteryState` for charge information, and `Charge` for charge information
Mains | The user is on a device connected to the mains.
UnknownPowerState | SDL could not determine the power for the device.

Instances

Eq PowerState Source # |
Instance details Defined in SDL.Power Methods (==) :: PowerState -> PowerState -> Bool Source # (/=) :: PowerState -> PowerState -> Bool Source #
Ord PowerState Source # |

Instance details

Defined in SDL.Power

Methods

compare :: PowerState -> PowerState -> Ordering Source #

(<) :: PowerState -> PowerState -> Bool Source #

(<=) :: PowerState -> PowerState -> Bool Source #

(>) :: PowerState -> PowerState -> Bool Source #

(>=) :: PowerState -> PowerState -> Bool Source #

max :: PowerState -> PowerState -> PowerState Source #

min :: PowerState -> PowerState -> PowerState Source #

Read PowerState Source # |
Instance details Defined in SDL.Power Methods readsPrec :: Int -> ReadS PowerState Source # readList :: ReadS [PowerState] Source # readPrec :: ReadPrec PowerState Source # readListPrec :: ReadPrec [PowerState] Source #
Show PowerState Source # |
Instance details Defined in SDL.Power Methods showsPrec :: Int -> PowerState -> ShowS Source # show :: PowerState -> String Source # showList :: [PowerState] -> ShowS Source #
Generic PowerState Source # |
Instance details Defined in SDL.Power Associated Types type Rep PowerState :: Type -> Type Source # Methods from :: PowerState -> Rep PowerState x Source # to :: Rep PowerState x -> PowerState Source #
type Rep PowerState Source # |

Instance details

Defined in SDL.Power

type Rep PowerState = D1 (MetaData "PowerState" "SDL.Power" "sdl2-2.4.1.0-6o74Vl5oJciK9nOaeyWqit" False) (C1 (MetaCons "Battery" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 BatteryState) :*: S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Charge)) :+: (C1 (MetaCons "Mains" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "UnknownPowerState" PrefixI False) (U1 :: Type -> Type)))

data BatteryState Source #

Information on battery consumption for battery powered devices

Constructors

Draining | The battery is currently being drained.
Charged | The battery is fully charged.
Charging | The device is plugged in and the battery is charging.

Instances

Bounded BatteryState Source # |
Instance details Defined in SDL.Power Methods minBound :: BatteryState Source # maxBound :: BatteryState Source #
Enum BatteryState Source # |

Instance details

Defined in SDL.Power

Methods

succ :: BatteryState -> BatteryState Source #

pred :: BatteryState -> BatteryState Source #

toEnum :: Int -> BatteryState Source #

fromEnum :: BatteryState -> Int Source #

enumFrom :: BatteryState -> [BatteryState] Source #

enumFromThen :: BatteryState -> BatteryState -> [BatteryState] Source #

enumFromTo :: BatteryState -> BatteryState -> [BatteryState] Source #

enumFromThenTo :: BatteryState -> BatteryState -> BatteryState -> [BatteryState] Source #

Eq BatteryState Source # |
Instance details Defined in SDL.Power Methods (==) :: BatteryState -> BatteryState -> Bool Source # (/=) :: BatteryState -> BatteryState -> Bool Source #
Data BatteryState Source # |

Instance details

Defined in SDL.Power

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> BatteryState -> c BatteryState Source #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c BatteryState Source #

toConstr :: BatteryState -> Constr Source #

dataTypeOf :: BatteryState -> DataType Source #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c BatteryState) Source #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c BatteryState) Source #

gmapT :: (forall b. Data b => b -> b) -> BatteryState -> BatteryState Source #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> BatteryState -> r Source #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> BatteryState -> r Source #

gmapQ :: (forall d. Data d => d -> u) -> BatteryState -> [u] Source #

gmapQi :: Int -> (forall d. Data d => d -> u) -> BatteryState -> u Source #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> BatteryState -> m BatteryState Source #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> BatteryState -> m BatteryState Source #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> BatteryState -> m BatteryState Source #

Ord BatteryState Source # |

Instance details

Defined in SDL.Power

Methods

compare :: BatteryState -> BatteryState -> Ordering Source #

(<) :: BatteryState -> BatteryState -> Bool Source #

(<=) :: BatteryState -> BatteryState -> Bool Source #

(>) :: BatteryState -> BatteryState -> Bool Source #

(>=) :: BatteryState -> BatteryState -> Bool Source #

max :: BatteryState -> BatteryState -> BatteryState Source #

min :: BatteryState -> BatteryState -> BatteryState Source #

Read BatteryState Source # |
Instance details Defined in SDL.Power Methods readsPrec :: Int -> ReadS BatteryState Source # readList :: ReadS [BatteryState] Source # readPrec :: ReadPrec BatteryState Source # readListPrec :: ReadPrec [BatteryState] Source #
Show BatteryState Source # |
Instance details Defined in SDL.Power Methods showsPrec :: Int -> BatteryState -> ShowS Source # show :: BatteryState -> String Source # showList :: [BatteryState] -> ShowS Source #
Generic BatteryState Source # |
Instance details Defined in SDL.Power Associated Types type Rep BatteryState :: Type -> Type Source # Methods from :: BatteryState -> Rep BatteryState x Source # to :: Rep BatteryState x -> BatteryState Source #
type Rep BatteryState Source # |
Instance details Defined in SDL.Power type Rep BatteryState = D1 (MetaData "BatteryState" "SDL.Power" "sdl2-2.4.1.0-6o74Vl5oJciK9nOaeyWqit" False) (C1 (MetaCons "Draining" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "Charged" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "Charging" PrefixI False) (U1 :: Type -> Type)))

data Charge Source #

Information about how much charge a battery has.

Constructors

Charge |

Fields

- chargeSecondsLeft :: Maybe CInt

  How many seconds of battery life is left

- chargePercent :: Maybe CInt

  The percentage of battery charged

Instances

Eq Charge Source # |
Instance details Defined in SDL.Power Methods (==) :: Charge -> Charge -> Bool Source # (/=) :: Charge -> Charge -> Bool Source #
Ord Charge Source # |
Instance details Defined in SDL.Power Methods compare :: Charge -> Charge -> Ordering Source # (<) :: Charge -> Charge -> Bool Source # (<=) :: Charge -> Charge -> Bool Source # (>) :: Charge -> Charge -> Bool Source # (>=) :: Charge -> Charge -> Bool Source # max :: Charge -> Charge -> Charge Source # min :: Charge -> Charge -> Charge Source #
Read Charge Source # |
Instance details Defined in SDL.Power Methods readsPrec :: Int -> ReadS Charge Source # readList :: ReadS [Charge] Source # readPrec :: ReadPrec Charge Source # readListPrec :: ReadPrec [Charge] Source #
Show Charge Source # |
Instance details Defined in SDL.Power Methods showsPrec :: Int -> Charge -> ShowS Source # show :: Charge -> String Source # showList :: [Charge] -> ShowS Source #
Generic Charge Source # |
Instance details Defined in SDL.Power Associated Types type Rep Charge :: Type -> Type Source # Methods from :: Charge -> Rep Charge x Source # to :: Rep Charge x -> Charge Source #
type Rep Charge Source # |
Instance details Defined in SDL.Power type Rep Charge = D1 (MetaData "Charge" "SDL.Power" "sdl2-2.4.1.0-6o74Vl5oJciK9nOaeyWqit" False) (C1 (MetaCons "Charge" PrefixI True) (S1 (MetaSel (Just "chargeSecondsLeft") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe CInt)) :*: S1 (MetaSel (Just "chargePercent") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe CInt))))