diff --git a/HGamer3D.cabal b/HGamer3D.cabal
--- a/HGamer3D.cabal
+++ b/HGamer3D.cabal
@@ -1,5 +1,5 @@
 Name:                HGamer3D
-Version:             0.9.0
+Version:             0.9.5
 Synopsis:            Toolset for the Haskell Game Programmer
 Description:         
 	HGamer3D is a toolset for developing 3D games in the programming 
@@ -18,7 +18,7 @@
 Library
   Build-Depends:     base >= 4.9 && < 4.10, containers, bytestring, text, filepath, directory, vect, binary-serialise-cbor, clock, cereal, fresco-binding
 
-  Exposed-modules:   HGamer3D.Data.Angle, HGamer3D.Data.Colour, HGamer3D.Data.LMH, HGamer3D.Data.GameTime, HGamer3D.Data.ScreenRect, HGamer3D.Data.Transform3D, HGamer3D.Data.Visible, HGamer3D.Data.TypeSynonyms, HGamer3D.Data.Vector, HGamer3D.Data.Window, HGamer3D.Data.PlayCmd, HGamer3D.Data.Parent, HGamer3D.Data.Geometry2D, HGamer3D.Data, HGamer3D.Util.FileLocation, HGamer3D.Util.UniqueName, HGamer3D.Util.Variable, HGamer3D.Util, HGamer3D.Graphics3D.Camera, HGamer3D.Graphics3D.Graphics3DCommand, HGamer3D.Graphics3D.Geometry, HGamer3D.Graphics3D.Graphics3DConfig, HGamer3D.Graphics3D.Light, HGamer3D.Graphics3D.Material, HGamer3D.Input.Mouse, HGamer3D.Input.Keyboard, HGamer3D.Input.Joystick, HGamer3D.Input.InputEventHandler, HGamer3D.Input, HGamer3D.Graphics3D, HGamer3D.GUI.UIElement, HGamer3D.GUI.Button, HGamer3D.GUI.EditText, HGamer3D.GUI.DropDownList, HGamer3D.GUI.Slider, HGamer3D.GUI.Text, HGamer3D.GUI.CheckBox, HGamer3D.GUI, HGamer3D.Audio.SoundSource, HGamer3D.Audio.SoundListener, HGamer3D.Audio.Volume, HGamer3D.Audio, HGamer3D
+  Exposed-modules:   HGamer3D.Data.Angle, HGamer3D.Data.Colour, HGamer3D.Data.LMH, HGamer3D.Data.GameTime, HGamer3D.Data.ScreenRect, HGamer3D.Data.Transform3D, HGamer3D.Data.Visible, HGamer3D.Data.TypeSynonyms, HGamer3D.Data.Label, HGamer3D.Data.LogMessage, HGamer3D.Data.Vector, HGamer3D.Data.Window, HGamer3D.Data.PlayCmd, HGamer3D.Data.Parent, HGamer3D.Data.Geometry2D, HGamer3D.Data, HGamer3D.Data.WindowEvent, HGamer3D.Util.FileLocation, HGamer3D.Util.UniqueName, HGamer3D.Util.Variable, HGamer3D.Util, HGamer3D.Graphics3D.Scene, HGamer3D.Graphics3D.Skybox, HGamer3D.Graphics3D.Particles, HGamer3D.Graphics3D.Camera, HGamer3D.Graphics3D.Text3D, HGamer3D.Graphics3D.Graphics3DCommand, HGamer3D.Graphics3D.Geometry, HGamer3D.Graphics3D.Graphics3DConfig, HGamer3D.Graphics3D.Light, HGamer3D.Graphics3D.Material, HGamer3D.Input.Mouse, HGamer3D.Input.Keyboard, HGamer3D.Input.Joystick, HGamer3D.Input, HGamer3D.Graphics3D, HGamer3D.GUI.UIElement, HGamer3D.GUI.Sprite, HGamer3D.GUI.Button, HGamer3D.GUI.EditText, HGamer3D.GUI.DropDownList, HGamer3D.GUI.Slider, HGamer3D.GUI.Text, HGamer3D.GUI.CheckBox, HGamer3D.GUI, HGamer3D.Audio.SoundSource, HGamer3D.Audio.SoundListener, HGamer3D.Audio.Volume, HGamer3D.Audio, HGamer3D
 
   Other-modules:     
 
diff --git a/HGamer3D.hs b/HGamer3D.hs
--- a/HGamer3D.hs
+++ b/HGamer3D.hs
@@ -44,6 +44,7 @@
 --    ctParent,
     EntityTree (..),
     newET,
+    delET,
 
     (<:),
     (<|),
@@ -96,14 +97,13 @@
             ctGraphics3DCommand #: NoCmd
             ]
 
-        eih <- newE hg3d [
-            ctInputEventHandler #: DefaultEventHandler,
+        ere <- newE hg3d [
             ctExitRequestedEvent #: ()
             ]
 
         -- create callback loop, handle windows exit command
         forkIO $ do
-            registerReceiverCBS cbs eih ctExitRequestedEvent (\_ -> writeVar varExit True >> return ())
+            registerReceiverCBS cbs ere ctExitRequestedEvent (\_ -> writeVar varExit True >> return ())
             forever $ (stepCBS cbs)
 
         -- create game logic loop
@@ -171,13 +171,16 @@
   [(_, e1)] <- createET hg3d (ETNode (Just "label") clist) parent
   let l1 = case label of
             Just l -> [(l, e1)]
-            Nothing -> [] 
+            Nothing -> [("", e1)] 
   l2 <- createET hg3d (ETList tlist) (Just e1)
   return (l1 ++ l2)
 
-newET :: HG3D -> [EntityTree] -> IO (M.Map String Entity)
-newET hg3d et = createET hg3d (ETList et) Nothing >>= \l -> return (M.fromList l)
+newET :: HG3D -> [EntityTree] -> IO ([(String, Entity)])
+newET hg3d et = createET hg3d (ETList et) Nothing 
 
+delET :: [(String, Entity)] -> IO ()
+delET l = mapM (\(s, e) -> delE e) l >> return ()
+
 (<:) :: String -> [(Word64, Component)] -> EntityTree
 label <: clist = ETNode (Just label) clist
 
@@ -190,5 +193,5 @@
 (-|) :: () -> ([(Word64, Component)], [EntityTree]) -> EntityTree
 () -| (clist, tlist) = ETChild Nothing clist tlist
 
-(#) :: (M.Map String Entity) -> String -> Entity
-m # s = fromJust $ M.lookup s m
+(#) :: [(String, Entity)] -> String -> Entity
+m # s = snd . head $ (filter (\(s', e) -> s == s') m)
diff --git a/HGamer3D/Data.hs b/HGamer3D/Data.hs
--- a/HGamer3D/Data.hs
+++ b/HGamer3D/Data.hs
@@ -29,6 +29,8 @@
     module HGamer3D.Data.LMH,
     module HGamer3D.Data.GameTime,
     module HGamer3D.Data.Visible,
+    module HGamer3D.Data.Label,
+    module HGamer3D.Data.LogMessage,
 
     -- * Geometry Datatypes
     module HGamer3D.Data.Vector,
@@ -42,7 +44,8 @@
     module HGamer3D.Data.Parent,
 
     -- * Implementation 
-    module HGamer3D.Data.Window
+    module HGamer3D.Data.Window,
+    module HGamer3D.Data.WindowEvent
 )
 
 where
@@ -52,12 +55,15 @@
 import HGamer3D.Data.LMH
 import HGamer3D.Data.GameTime
 import HGamer3D.Data.Visible
+import HGamer3D.Data.Label
+import HGamer3D.Data.LogMessage
 import HGamer3D.Data.ScreenRect
 import HGamer3D.Data.Geometry2D
 import HGamer3D.Data.Transform3D
 import HGamer3D.Data.TypeSynonyms
 import HGamer3D.Data.Vector
 import HGamer3D.Data.Window
+import HGamer3D.Data.WindowEvent
 import HGamer3D.Data.PlayCmd
 import HGamer3D.Data.Parent
 
diff --git a/HGamer3D/Data/Label.hs b/HGamer3D/Data/Label.hs
new file mode 100644
--- /dev/null
+++ b/HGamer3D/Data/Label.hs
@@ -0,0 +1,17 @@
+module HGamer3D.Data.Label where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+type Label = Text
+
+ctLabel :: ComponentType Label
+ctLabel = ComponentType 0xf98939ae4b0d693a
+
diff --git a/HGamer3D/Data/LogMessage.hs b/HGamer3D/Data/LogMessage.hs
new file mode 100644
--- /dev/null
+++ b/HGamer3D/Data/LogMessage.hs
@@ -0,0 +1,25 @@
+module HGamer3D.Data.LogMessage where
+
+import Fresco
+import HGamer3D.Graphics3D.Graphics3DConfig
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data LogMessage = LogMessage {
+    logMessageLevel::LogLevel,
+    logMessageMessage::Text
+    } deriving (Eq, Read, Show)
+
+ctLogMessage :: ComponentType LogMessage
+ctLogMessage = ComponentType 0x1c94738af20a0ac6
+
+instance Serialise LogMessage where
+    encode (LogMessage v1 v2) = encodeListLen 2 <> encode v1 <> encode v2
+    decode = decodeListLenOf 2 >> LogMessage <$> decode <*> decode
+
diff --git a/HGamer3D/Data/Visible.hs b/HGamer3D/Data/Visible.hs
--- a/HGamer3D/Data/Visible.hs
+++ b/HGamer3D/Data/Visible.hs
@@ -2,11 +2,11 @@
 	Visible Datatype
 	HGamer3D Library (A project to enable 3D game development in Haskell)
 	Copyright 2011-2017 Peter Althainz
-	
+
 	Distributed under the Apache License, Version 2.0
 	(See attached file LICENSE or copy at 
 	http://www.apache.org/licenses/LICENSE-2.0)
- 
+
 	file: HGamer3D/Data/Visible.hs
 -}
 
diff --git a/HGamer3D/Data/WindowEvent.hs b/HGamer3D/Data/WindowEvent.hs
new file mode 100644
--- /dev/null
+++ b/HGamer3D/Data/WindowEvent.hs
@@ -0,0 +1,31 @@
+module HGamer3D.Data.WindowEvent where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data ScreenModeEvent = ScreenModeEvent {
+    screenModeEventWidth::Int,
+    screenModeEventHeight::Int,
+    screenModeEventFullscreen::Bool,
+    screenModeEventBorderless::Bool
+    } deriving (Eq, Read, Show)
+
+ctScreenModeEvent :: ComponentType ScreenModeEvent
+ctScreenModeEvent = ComponentType 0x7534a286d000125c
+
+type ExitRequestedEvent = ()
+
+ctExitRequestedEvent :: ComponentType ExitRequestedEvent
+ctExitRequestedEvent = ComponentType 0xbd86f89ddca9280f
+
+instance Serialise ScreenModeEvent where
+    encode (ScreenModeEvent v1 v2 v3 v4) = encodeListLen 4 <> encode v1 <> encode v2 <> encode v3 <> encode v4
+    decode = decodeListLenOf 4 >> ScreenModeEvent <$> decode <*> decode <*> decode <*> decode
+
diff --git a/HGamer3D/GUI.hs b/HGamer3D/GUI.hs
--- a/HGamer3D/GUI.hs
+++ b/HGamer3D/GUI.hs
@@ -20,6 +20,7 @@
     , module HGamer3D.GUI.Slider
     , module HGamer3D.GUI.DropDownList
     , module HGamer3D.GUI.CheckBox
+    , module HGamer3D.GUI.Sprite
 )
 
 
@@ -32,5 +33,6 @@
 import HGamer3D.GUI.Slider
 import HGamer3D.GUI.DropDownList
 import HGamer3D.GUI.CheckBox
+import HGamer3D.GUI.Sprite
 
 
diff --git a/HGamer3D/GUI/Sprite.hs b/HGamer3D/GUI/Sprite.hs
new file mode 100644
--- /dev/null
+++ b/HGamer3D/GUI/Sprite.hs
@@ -0,0 +1,24 @@
+module HGamer3D.GUI.Sprite where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data Sprite = Sprite {
+    spriteResource::Text,
+    spriteOpacity::Float
+    } deriving (Eq, Read, Show)
+
+ctSprite :: ComponentType Sprite
+ctSprite = ComponentType 0x39b4f64b33f5cb41
+
+instance Serialise Sprite where
+    encode (Sprite v1 v2) = encodeListLen 2 <> encode v1 <> encode v2
+    decode = decodeListLenOf 2 >> Sprite <$> decode <*> decode
+
diff --git a/HGamer3D/Graphics3D.hs b/HGamer3D/Graphics3D.hs
--- a/HGamer3D/Graphics3D.hs
+++ b/HGamer3D/Graphics3D.hs
@@ -29,6 +29,10 @@
   module HGamer3D.Graphics3D.Material,
   module HGamer3D.Graphics3D.Graphics3DCommand,
   module HGamer3D.Graphics3D.Graphics3DConfig,
+  module HGamer3D.Graphics3D.Scene,
+  module HGamer3D.Graphics3D.Skybox,
+  module HGamer3D.Graphics3D.Text3D,
+  module HGamer3D.Graphics3D.Particles,
 )
 
 where
@@ -39,5 +43,9 @@
 import HGamer3D.Graphics3D.Material
 import HGamer3D.Graphics3D.Graphics3DCommand
 import HGamer3D.Graphics3D.Graphics3DConfig
+import HGamer3D.Graphics3D.Scene
+import HGamer3D.Graphics3D.Skybox
+import HGamer3D.Graphics3D.Text3D
+import HGamer3D.Graphics3D.Particles
 
 
diff --git a/HGamer3D/Graphics3D/Particles.hs b/HGamer3D/Graphics3D/Particles.hs
new file mode 100644
--- /dev/null
+++ b/HGamer3D/Graphics3D/Particles.hs
@@ -0,0 +1,26 @@
+module HGamer3D.Graphics3D.Particles where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data Particles = ParticleEffectResource Text
+    deriving (Eq, Read, Show)
+
+ctParticles :: ComponentType Particles
+ctParticles = ComponentType 0x5009dcc85ea5f959
+
+instance Serialise Particles where
+    encode (ParticleEffectResource v1) = encodeListLen 2 <>  encode (0::Int) <> encode v1
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (ParticleEffectResource <$> decode)
+
diff --git a/HGamer3D/Graphics3D/Scene.hs b/HGamer3D/Graphics3D/Scene.hs
new file mode 100644
--- /dev/null
+++ b/HGamer3D/Graphics3D/Scene.hs
@@ -0,0 +1,30 @@
+module HGamer3D.Graphics3D.Scene where
+
+import Fresco
+
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data Scene = XmlScene Text
+    | BinaryScene Text
+    deriving (Eq, Read, Show)
+
+ctScene :: ComponentType Scene
+ctScene = ComponentType 0x829863cdd141007e
+
+instance Serialise Scene where
+    encode (XmlScene v1) = encodeListLen 2 <>  encode (0::Int) <> encode v1
+    encode (BinaryScene v1) = encodeListLen 2 <>  encode (1::Int) <> encode v1
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (XmlScene <$> decode)
+            1 -> (BinaryScene <$> decode)
+
diff --git a/HGamer3D/Graphics3D/Skybox.hs b/HGamer3D/Graphics3D/Skybox.hs
new file mode 100644
--- /dev/null
+++ b/HGamer3D/Graphics3D/Skybox.hs
@@ -0,0 +1,26 @@
+module HGamer3D.Graphics3D.Skybox where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data Skybox = SkyboxMaterial Text
+    deriving (Eq, Read, Show)
+
+ctSkybox :: ComponentType Skybox
+ctSkybox = ComponentType 0x457ac00afe66a3a4
+
+instance Serialise Skybox where
+    encode (SkyboxMaterial v1) = encodeListLen 2 <>  encode (0::Int) <> encode v1
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (SkyboxMaterial <$> decode)
+
diff --git a/HGamer3D/Graphics3D/Text3D.hs b/HGamer3D/Graphics3D/Text3D.hs
new file mode 100644
--- /dev/null
+++ b/HGamer3D/Graphics3D/Text3D.hs
@@ -0,0 +1,55 @@
+module HGamer3D.Graphics3D.Text3D where
+
+import Fresco
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data FaceCameraMode = FCNone
+    | FCRotateXYZ
+    | FCRotateY
+    | FCLookatXYZ
+    | FCLookatY
+    | FCLookatMixed
+    | FCDirection
+    deriving (Eq, Read, Show)
+
+data Text3D = Text3D {
+    text3DFont::Text,
+    text3DFontSize::Int,
+    text3DFCMode::FaceCameraMode,
+    text3DFixedScreenSize::Bool
+    } deriving (Eq, Read, Show)
+
+ctText3D :: ComponentType Text3D
+ctText3D = ComponentType 0x620bb5dd7dfca052
+
+instance Serialise FaceCameraMode where
+    encode (FCNone) = encodeListLen 1 <>  encode (0::Int) 
+    encode (FCRotateXYZ) = encodeListLen 1 <>  encode (1::Int) 
+    encode (FCRotateY) = encodeListLen 1 <>  encode (2::Int) 
+    encode (FCLookatXYZ) = encodeListLen 1 <>  encode (3::Int) 
+    encode (FCLookatY) = encodeListLen 1 <>  encode (4::Int) 
+    encode (FCLookatMixed) = encodeListLen 1 <>  encode (5::Int) 
+    encode (FCDirection) = encodeListLen 1 <>  encode (6::Int) 
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (pure FCNone)
+            1 -> (pure FCRotateXYZ)
+            2 -> (pure FCRotateY)
+            3 -> (pure FCLookatXYZ)
+            4 -> (pure FCLookatY)
+            5 -> (pure FCLookatMixed)
+            6 -> (pure FCDirection)
+
+instance Serialise Text3D where
+    encode (Text3D v1 v2 v3 v4) = encodeListLen 4 <> encode v1 <> encode v2 <> encode v3 <> encode v4
+    decode = decodeListLenOf 4 >> Text3D <$> decode <*> decode <*> decode <*> decode
+
diff --git a/HGamer3D/Input.hs b/HGamer3D/Input.hs
--- a/HGamer3D/Input.hs
+++ b/HGamer3D/Input.hs
@@ -25,8 +25,7 @@
 (
     module HGamer3D.Input.Mouse,
     module HGamer3D.Input.Keyboard,
-    module HGamer3D.Input.Joystick,
-    module HGamer3D.Input.InputEventHandler
+    module HGamer3D.Input.Joystick
 )
 
 where
@@ -34,6 +33,5 @@
 import HGamer3D.Input.Mouse
 import HGamer3D.Input.Keyboard
 import HGamer3D.Input.Joystick
-import HGamer3D.Input.InputEventHandler
 
 
diff --git a/HGamer3D/Input/InputEventHandler.hs b/HGamer3D/Input/InputEventHandler.hs
deleted file mode 100644
--- a/HGamer3D/Input/InputEventHandler.hs
+++ /dev/null
@@ -1,80 +0,0 @@
-{-
-	Input Event handler and settings
-	HGamer3D Library (A project to enable 3D game development in Haskell)
-	Copyright 2015 - 2017 Peter Althainz
-	
-	Distributed under the Apache License, Version 2.0
-	(See attached file LICENSE or copy at 
-	http://www.apache.org/licenses/LICENSE-2.0)
- 
-	file: HGamer3D/Input/Mouse.hs
--}
-
--- | Module providing settings for all input events (Mouse, Keyboard, Joystick)
-module HGamer3D.Input.InputEventHandler
-where
-
-import Fresco
-import Data.Binary.Serialise.CBOR
-import Data.Binary.Serialise.CBOR.Encoding
-import Data.Binary.Serialise.CBOR.Decoding
-
-import Data.Text
-import Data.Monoid
-import Control.Applicative
-
-
-data InputEventType = IEMouseButtonUp
-    | IEMouseButtonDown
-    | IEMouseMove
-    | IEMouseButtonWheel
-    | IEMouseVisible
-    | IEKeyUp
-    | IEKeyDown
-    | IEExitRequested
-    deriving (Eq, Read, Show)
-
-data InputEventHandler = DefaultEventHandler
-    | SpecificEventHandler [InputEventType]
-    deriving (Eq, Read, Show)
-
-ctInputEventHandler :: ComponentType InputEventHandler
-ctInputEventHandler = ComponentType 0xfc0edefcebcb5878
-
-type ExitRequestedEvent = ()
-
-ctExitRequestedEvent :: ComponentType ExitRequestedEvent
-ctExitRequestedEvent = ComponentType 0x824517eb48d5c653
-
-instance Serialise InputEventType where
-    encode (IEMouseButtonUp) = encodeListLen 1 <>  encode (0::Int) 
-    encode (IEMouseButtonDown) = encodeListLen 1 <>  encode (1::Int) 
-    encode (IEMouseMove) = encodeListLen 1 <>  encode (2::Int) 
-    encode (IEMouseButtonWheel) = encodeListLen 1 <>  encode (3::Int) 
-    encode (IEMouseVisible) = encodeListLen 1 <>  encode (4::Int) 
-    encode (IEKeyUp) = encodeListLen 1 <>  encode (5::Int) 
-    encode (IEKeyDown) = encodeListLen 1 <>  encode (6::Int) 
-    encode (IEExitRequested) = encodeListLen 1 <>  encode (7::Int) 
-    decode = do
-        decodeListLen
-        i <- decode :: Decoder s Int
-        case i of
-            0 -> (pure IEMouseButtonUp)
-            1 -> (pure IEMouseButtonDown)
-            2 -> (pure IEMouseMove)
-            3 -> (pure IEMouseButtonWheel)
-            4 -> (pure IEMouseVisible)
-            5 -> (pure IEKeyUp)
-            6 -> (pure IEKeyDown)
-            7 -> (pure IEExitRequested)
-
-instance Serialise InputEventHandler where
-    encode (DefaultEventHandler) = encodeListLen 1 <>  encode (0::Int) 
-    encode (SpecificEventHandler v1) = encodeListLen 2 <>  encode (1::Int) <> encode v1
-    decode = do
-        decodeListLen
-        i <- decode :: Decoder s Int
-        case i of
-            0 -> (pure DefaultEventHandler)
-            1 -> (SpecificEventHandler <$> decode)
-
diff --git a/HGamer3D/Input/Joystick.hs b/HGamer3D/Input/Joystick.hs
--- a/HGamer3D/Input/Joystick.hs
+++ b/HGamer3D/Input/Joystick.hs
@@ -12,11 +12,137 @@
 
 -- | Module providing the Joystick functionality and settings
 module HGamer3D.Input.Joystick
-(
-)
 
 where
 
 import Fresco
-import HGamer3D.Data
+import Data.Binary.Serialise.CBOR
+import Data.Binary.Serialise.CBOR.Encoding
+import Data.Binary.Serialise.CBOR.Decoding
+
+import Data.Text
+import Data.Monoid
+import Control.Applicative
+
+
+data Joystick = Joystick {
+    -- | index of joystick, starting at 0 (first one)
+    joystickIndex::Int
+    } deriving (Eq, Read, Show)
+
+ctJoystick :: ComponentType Joystick
+ctJoystick = ComponentType 0xe5ea0d693a04ff71
+
+data JoystickEvent = NoJoystickEvent
+    | ButtonDown Int -- ^ Button Id 
+    | ButtonUp Int -- ^ Button Id 
+    | AxisMove Int Float -- ^ Axis Id, Move Position 
+    | HatMove Int Int -- ^ Axis Id, Hat Position 
+    | JoystickChange Int Int -- ^ joystick plugged, unplugged, min, max indicees 
+    deriving (Eq, Read, Show)
+
+ctJoystickEvent :: ComponentType JoystickEvent
+ctJoystickEvent = ComponentType 0x1cdc5b0a65479346
+
+data JoystickButton = A
+    | B
+    | Back
+    | DPadDown
+    | DPadLeft
+    | DPadRight
+    | DPadUp
+    | Guide
+    | LeftShoulder
+    | LeftStick
+    | RightShoulder
+    | RightStick
+    | Start
+    | X
+    | Y
+    deriving (Eq, Read, Show)
+
+data JoystickAxis = LeftX
+    | LeftY
+    | RightX
+    | RightY
+    | TriggerLeft
+    | TriggerRight
+    deriving (Eq, Read, Show)
+
+instance Serialise Joystick where
+    encode (Joystick v1) = encodeListLen 1 <> encode v1
+    decode = decodeListLenOf 1 >> Joystick <$> decode
+
+instance Serialise JoystickEvent where
+    encode (NoJoystickEvent) = encodeListLen 1 <>  encode (0::Int) 
+    encode (ButtonDown v1) = encodeListLen 2 <>  encode (1::Int) <> encode v1
+    encode (ButtonUp v1) = encodeListLen 2 <>  encode (2::Int) <> encode v1
+    encode (AxisMove v1 v2) = encodeListLen 3 <>  encode (3::Int) <> encode v1<> encode v2
+    encode (HatMove v1 v2) = encodeListLen 3 <>  encode (4::Int) <> encode v1<> encode v2
+    encode (JoystickChange v1 v2) = encodeListLen 3 <>  encode (5::Int) <> encode v1<> encode v2
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (pure NoJoystickEvent)
+            1 -> (ButtonDown <$> decode)
+            2 -> (ButtonUp <$> decode)
+            3 -> (AxisMove <$> decode <*> decode)
+            4 -> (HatMove <$> decode <*> decode)
+            5 -> (JoystickChange <$> decode <*> decode)
+
+instance Serialise JoystickButton where
+    encode (A) = encodeListLen 1 <>  encode (0::Int) 
+    encode (B) = encodeListLen 1 <>  encode (1::Int) 
+    encode (Back) = encodeListLen 1 <>  encode (2::Int) 
+    encode (DPadDown) = encodeListLen 1 <>  encode (3::Int) 
+    encode (DPadLeft) = encodeListLen 1 <>  encode (4::Int) 
+    encode (DPadRight) = encodeListLen 1 <>  encode (5::Int) 
+    encode (DPadUp) = encodeListLen 1 <>  encode (6::Int) 
+    encode (Guide) = encodeListLen 1 <>  encode (7::Int) 
+    encode (LeftShoulder) = encodeListLen 1 <>  encode (8::Int) 
+    encode (LeftStick) = encodeListLen 1 <>  encode (9::Int) 
+    encode (RightShoulder) = encodeListLen 1 <>  encode (10::Int) 
+    encode (RightStick) = encodeListLen 1 <>  encode (11::Int) 
+    encode (Start) = encodeListLen 1 <>  encode (12::Int) 
+    encode (X) = encodeListLen 1 <>  encode (13::Int) 
+    encode (Y) = encodeListLen 1 <>  encode (14::Int) 
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (pure A)
+            1 -> (pure B)
+            2 -> (pure Back)
+            3 -> (pure DPadDown)
+            4 -> (pure DPadLeft)
+            5 -> (pure DPadRight)
+            6 -> (pure DPadUp)
+            7 -> (pure Guide)
+            8 -> (pure LeftShoulder)
+            9 -> (pure LeftStick)
+            10 -> (pure RightShoulder)
+            11 -> (pure RightStick)
+            12 -> (pure Start)
+            13 -> (pure X)
+            14 -> (pure Y)
+
+instance Serialise JoystickAxis where
+    encode (LeftX) = encodeListLen 1 <>  encode (0::Int) 
+    encode (LeftY) = encodeListLen 1 <>  encode (1::Int) 
+    encode (RightX) = encodeListLen 1 <>  encode (2::Int) 
+    encode (RightY) = encodeListLen 1 <>  encode (3::Int) 
+    encode (TriggerLeft) = encodeListLen 1 <>  encode (4::Int) 
+    encode (TriggerRight) = encodeListLen 1 <>  encode (5::Int) 
+    decode = do
+        decodeListLen
+        i <- decode :: Decoder s Int
+        case i of
+            0 -> (pure LeftX)
+            1 -> (pure LeftY)
+            2 -> (pure RightX)
+            3 -> (pure RightY)
+            4 -> (pure TriggerLeft)
+            5 -> (pure TriggerRight)
+
 
diff --git a/HGamer3D/Input/Keyboard.hs b/HGamer3D/Input/Keyboard.hs
--- a/HGamer3D/Input/Keyboard.hs
+++ b/HGamer3D/Input/Keyboard.hs
@@ -37,7 +37,7 @@
     deriving (Eq, Read, Show)
 
 ctKeyEvent :: ComponentType KeyEvent
-ctKeyEvent = ComponentType 0x5ba1617fb50e97e5
+ctKeyEvent = ComponentType 0x07995a794e698f4b
 
 instance Serialise KeyData where
     encode (KeyData v1 v2 v3) = encodeListLen 3 <> encode v1 <> encode v2 <> encode v3
diff --git a/HGamer3D/Input/Mouse.hs b/HGamer3D/Input/Mouse.hs
--- a/HGamer3D/Input/Mouse.hs
+++ b/HGamer3D/Input/Mouse.hs
@@ -24,17 +24,13 @@
 import Control.Applicative
 
 
-data MouseMode = Absolute
-    | Relative
-    | Wrap
+data MouseMode = MMAbsolute
+    | MMRelative
+    | MMWrap
     deriving (Eq, Read, Show)
 
-data MouseConfig = MouseConfig {
-    mouseConfigMode::MouseMode
-    } deriving (Eq, Read, Show)
-
-ctMouseConfig :: ComponentType MouseConfig
-ctMouseConfig = ComponentType 0xa532f43b1c1c6bc7
+ctMouse :: ComponentType MouseMode
+ctMouse = ComponentType 0x07669c3c292bf265
 
 data MouseButtonData = MouseButtonData {
     mouseButtonDataButton::Int,
@@ -65,23 +61,19 @@
     deriving (Eq, Read, Show)
 
 ctMouseEvent :: ComponentType MouseEvent
-ctMouseEvent = ComponentType 0x27eaf3fd46595d08
+ctMouseEvent = ComponentType 0x8a73da7bdfbe4ccc
 
 instance Serialise MouseMode where
-    encode (Absolute) = encodeListLen 1 <>  encode (0::Int) 
-    encode (Relative) = encodeListLen 1 <>  encode (1::Int) 
-    encode (Wrap) = encodeListLen 1 <>  encode (2::Int) 
+    encode (MMAbsolute) = encodeListLen 1 <>  encode (0::Int) 
+    encode (MMRelative) = encodeListLen 1 <>  encode (1::Int) 
+    encode (MMWrap) = encodeListLen 1 <>  encode (2::Int) 
     decode = do
         decodeListLen
         i <- decode :: Decoder s Int
         case i of
-            0 -> (pure Absolute)
-            1 -> (pure Relative)
-            2 -> (pure Wrap)
-
-instance Serialise MouseConfig where
-    encode (MouseConfig v1) = encodeListLen 1 <> encode v1
-    decode = decodeListLenOf 1 >> MouseConfig <$> decode
+            0 -> (pure MMAbsolute)
+            1 -> (pure MMRelative)
+            2 -> (pure MMWrap)
 
 instance Serialise MouseButtonData where
     encode (MouseButtonData v1 v2 v3) = encodeListLen 3 <> encode v1 <> encode v2 <> encode v3
