HGamer3D-WinEvent (empty) → 0.3.0
raw patch · 4 files changed
+229/−0 lines, 4 filesdep +HGamer3D-Datadep +HGamer3D-SDL2-Bindingdep +basesetup-changed
Dependencies added: HGamer3D-Data, HGamer3D-SDL2-Binding, base, text
Files
- HGamer3D-WinEvent.cabal +33/−0
- HGamer3D/WinEvent.hs +132/−0
- LICENSE +42/−0
- Setup.hs +22/−0
+ HGamer3D-WinEvent.cabal view
@@ -0,0 +1,33 @@+Name: HGamer3D-WinEvent +Version: 0.3.0 +Synopsis: Windowing and Event Functionality for HGamer3D +Description: + HGamer3D is a game engine for developing 3D games in the programming + language Haskell. This package provides the Windowing and Event + functionality, based on the package HGamer3D-SDL2-Binding. + HGamer3D-WinEvent is available on Windows and Linux. + +License: OtherLicense +License-file: LICENSE +Author: Peter Althainz +Maintainer: althainz@gmail.com +Build-Type: Simple +Cabal-Version: >=1.4 +Homepage: http://www.hgamer3d.org +Category: Game Engine +Extra-source-files: Setup.hs + +Library + Build-Depends: base >= 3 && < 5, text, HGamer3D-Data >= 0.3.0 && < 0.4.0, HGamer3D-SDL2-Binding >= 0.3.0 && < 0.4.0 + + Exposed-modules: HGamer3D.WinEvent + Other-modules: + + c-sources: + + ghc-options: + cc-options: -Wno-attributes + hs-source-dirs: . + Include-dirs: . + build-depends: + extra-libraries:
+ HGamer3D/WinEvent.hs view
@@ -0,0 +1,132 @@+-- This source file is part of HGamer3D+-- (A project to enable 3D game development in Haskell)+-- For the latest info, see http://www.hgamer3d.org+--+-- (c) 2011-2014 Peter Althainz+--+-- Licensed under the Apache License, Version 2.0 (the "License");+-- you may not use this file except in compliance with the License.+-- You may obtain a copy of the License at+--+-- http://www.apache.org/licenses/LICENSE-2.0+--+-- Unless required by applicable law or agreed to in writing, software+-- distributed under the License is distributed on an "AS IS" BASIS,+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+-- See the License for the specific language governing permissions and+-- limitations under the License.++-- Events.hs+++-- | Windowing and Event functionality for HGamer3D+module HGamer3D.WinEvent+(+ EnumWinEventInit (..),+ SDLWindow,+ initWinEvent,+ attachToWindow,+ openWindow,+ pollWinEvent,+ quitWinEvent,+ showCursor,+ module HGamer3D.Bindings.SDL2.StructSDLEvent,+ module HGamer3D.Bindings.SDL2.EnumSDLEventType,+ module HGamer3D.Bindings.SDL2.EnumSDLKeymod,+ module HGamer3D.Bindings.SDL2.EnumSDLScancode,+ module HGamer3D.Bindings.SDL2.EnumSDLWindowEventID,+ module HGamer3D.Bindings.SDL2.EnumSDLWindowFlags,++ initHGamer3D,+ exitHGamer3D,+ loopHGamer3D+)++where++import GHC.Ptr+import HGamer3D.Data++import HGamer3D.Bindings.SDL2.ClassPtr+import HGamer3D.Bindings.SDL2.Utils+++import HGamer3D.Bindings.SDL2.EnumSDLEventType+import HGamer3D.Bindings.SDL2.EnumSDLKeymod+import HGamer3D.Bindings.SDL2.EnumSDLScancode+import HGamer3D.Bindings.SDL2.EnumSDLWindowEventID+import HGamer3D.Bindings.SDL2.EnumSDLWindowFlags++import HGamer3D.Bindings.SDL2.StructSDLEvent++import HGamer3D.Bindings.SDL2.HeaderSDL+import HGamer3D.Bindings.SDL2.HeaderSDLVideo+import HGamer3D.Bindings.SDL2.HeaderSDLEvents+import HGamer3D.Bindings.SDL2.EnumSDLWindowFlags+import HGamer3D.Bindings.SDL2.HeaderSDLMouse+import HGamer3D.Bindings.SDL2.ClassHG3DUtilities++import Foreign.Marshal.Utils+import Control.Monad+import Control.Applicative++-- Enum Definitions for initializing+data EnumWinEventInit = WEV_INIT_VIDEO | WEV_INIT_TIMER | WEV_INIT_EVENTS+instance Enum EnumWinEventInit where+ toEnum 0x20 = WEV_INIT_VIDEO+ toEnum 0x4000 = WEV_INIT_EVENTS+ toEnum 0x01 = WEV_INIT_TIMER++ fromEnum WEV_INIT_VIDEO = 0x20+ fromEnum WEV_INIT_EVENTS = 0x4000+ fromEnum WEV_INIT_TIMER = 0x01++-- show instance for SDLEvent+instance Show SDLEvent where+ show (EvtQuit ts) = "Event-Quit"+ show (EvtKeyUp ts window keyscan keycode keymode) = "Event-KeyUp " ++ (show (fromEnum keyscan))+ show (EvtKeyDown ts window keyscan keycode keymode) = "Event-KeyDown " ++ (show (fromEnum keyscan))+ show (EvtText ts window text) = "Event-Text " ++ text+ show (EvtMouseButtonUp ts window mid button x y) = "Event-MouseButtonUp " ++ (show button) ++ " " ++ (show x) ++ " " ++ (show y) + show (EvtMouseButtonDown ts window mid button x y) = "Event-MouseButtonDown " ++ (show button) ++ " " ++ (show x) ++ " " ++ (show y) + show (EvtMouseMotion ts window mid x y rx ry) = "Event-MouseMotion " ++ (show x) ++ " " ++ (show y) ++ " r: " ++ (show rx) ++ " " ++ (show ry)+ show (EvtWindow ts window weid x y) = "Event-Window " ++ (show (fromEnum weid)) ++ " " ++ (show x) ++ " " ++ (show y)+ show _ = "Specific Event is not in show instance"+++initWinEvent :: [EnumWinEventInit] -> IO Int+initWinEvent flags = do+ res <- sdlInit $ sum (fmap fromEnum flags)+ return res+ ++attachToWindow :: Window -> IO (Ptr SDLWindow)+attachToWindow (Window handle) = do+ res <- createWindowFromHandle handle+ return $ res++openWindow :: String -> Int -> Int -> Int -> Int -> [EnumSDLWindowFlags] -> IO (Ptr SDLWindow)+openWindow title x y w h flags = do+ win <- sdlCreateWindow title x y w h (sum $ fmap fromEnum flags)+ return win++pollWinEvent :: IO (Maybe SDLEvent)+pollWinEvent = do+ (sdlevt, res) <- sdlPollEvent+ let r = case res of+ 0 -> Nothing+ 1 -> Just sdlevt+ _ -> Nothing+ return r++quitWinEvent :: IO ()+quitWinEvent = sdlQuit++showCursor :: Bool -> IO Bool+showCursor flag = do+ ival <- sdlShowCursor (fromBool flag)+ return (toBool ival)+ +initHGamer3D = initWinEvent +exitHGamer3D = quitWinEvent+loopHGamer3D = pollWinEvent
+ LICENSE view
@@ -0,0 +1,42 @@+LICENSE +------- + +(c) 2011-2014 Peter Althainz + + +HGamer3D (http://www.hgamer3d.org) +---------------------------------- + +HGamer3D is licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + +Source Code +----------- +You can obtain the latest version of the source code under http://www.bitbucket.org/althainz/HGamer3D + + +Open Source Software Used - Module HGamer3D +------------------------------------------- + +HGamer3D uses a number of open source software libraries. You are responsible to comply to the licenses of those packages and the licenses of software used by those packages if you use HGamer3D. + +The HGamer3D module uses the following Haskell libraries from Hackage: + +base, license: BSD3 +containers, license: BSD3 +text, license: BSD3 +directory, license: BSD3 +mtl, license: BSD3 +FindBin, license: BSD3 +monad-loops, license: PublicDomain, BSD3 similar +split, license: BSD3 +netwire, license: BSD3 +HGamer3D-Data, license: Apache 2.0 +HGamer3D-Ogre-Binding, license: Apache 2.0 and dependencies see in that module +HGamer3D-SFML-Binding, license: Apache 2.0 and dependencies see in that module +HGamer3D-CEGUI-Binding, license: Apache 2.0 and dependencies see in that module +HGamer3D-Enet-Binding, license: Apache 2.0 and dependencies see in that module
+ Setup.hs view
@@ -0,0 +1,22 @@+-- This source file is part of HGamer3D +-- (A project to enable 3D game development in Haskell) +-- For the latest info, see http://www.hgamer3d.org +-- +-- (c) 2011-2013 Peter Althainz +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +-- Setup.hs + +import Distribution.Simple +main = defaultMain