aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8.1/source/Irrlicht/CIrrDeviceFB.h
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8.1/source/Irrlicht/CIrrDeviceFB.h')
-rw-r--r--libraries/irrlicht-1.8.1/source/Irrlicht/CIrrDeviceFB.h207
1 files changed, 207 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8.1/source/Irrlicht/CIrrDeviceFB.h b/libraries/irrlicht-1.8.1/source/Irrlicht/CIrrDeviceFB.h
new file mode 100644
index 0000000..07a9aca
--- /dev/null
+++ b/libraries/irrlicht-1.8.1/source/Irrlicht/CIrrDeviceFB.h
@@ -0,0 +1,207 @@
1// Copyright (C) 2002-2007 Nikolaus Gebhardt
2// Copyright (C) 2007-2012 Christian Stehno
3// This file is part of the "Irrlicht Engine".
4// For conditions of distribution and use, see copyright notice in irrlicht.h
5
6#ifndef __C_IRR_DEVICE_FB_H_INCLUDED__
7#define __C_IRR_DEVICE_FB_H_INCLUDED__
8
9#include "IrrCompileConfig.h"
10
11#ifdef _IRR_COMPILE_WITH_FB_DEVICE_
12
13#include "CIrrDeviceStub.h"
14#include "SIrrCreationParameters.h"
15#include "IrrlichtDevice.h"
16#include "IImagePresenter.h"
17#include "ICursorControl.h"
18
19#define KeySym s32
20#include <linux/fb.h>
21#include <linux/kd.h>
22
23namespace irr
24{
25 class CIrrDeviceFB : public CIrrDeviceStub, public video::IImagePresenter
26 {
27 public:
28
29 //! constructor
30 CIrrDeviceFB(const SIrrlichtCreationParameters& params);
31
32 //! destructor
33 virtual ~CIrrDeviceFB();
34
35 //! runs the device. Returns false if device wants to be deleted
36 virtual bool run();
37
38 //! Cause the device to temporarily pause execution and let other processes to run
39 // This should bring down processor usage without major performance loss for Irrlicht
40 virtual void yield();
41
42 //! Pause execution and let other processes to run for a specified amount of time.
43 virtual void sleep(u32 timeMs, bool pauseTimer);
44
45 //! sets the caption of the window
46 virtual void setWindowCaption(const wchar_t* text);
47
48 //! returns if window is active. if not, nothing need to be drawn
49 virtual bool isWindowActive() const;
50
51 //! returns if window has focus
52 virtual bool isWindowFocused() const;
53
54 //! returns if window is minimized
55 virtual bool isWindowMinimized() const;
56
57 //! Minimizes window
58 virtual void minimizeWindow();
59
60 //! Maximizes window
61 virtual void maximizeWindow();
62
63 //! Restores original window size
64 virtual void restoreWindow();
65
66 //! presents a surface in the client area
67 virtual bool present(video::IImage* surface, void* windowId = 0, core::rect<s32>* src=0 );
68
69 //! notifies the device that it should close itself
70 virtual void closeDevice();
71
72 //! Sets if the window should be resizeable in windowed mode.
73 virtual void setResizable(bool resize=false);
74
75 //! Returns the type of this device
76 virtual E_DEVICE_TYPE getType() const;
77
78 private:
79
80 //! create the driver
81 void createDriver();
82
83 bool createWindow(const core::dimension2d<u32>& windowSize, u32 bits);
84
85 //! Implementation of the cursor control
86 class CCursorControl : public gui::ICursorControl
87 {
88 public:
89
90 CCursorControl(CIrrDeviceFB* dev, bool null)
91 : Device(dev), IsVisible(true), Null(null)
92 {
93 Device->grab();
94 }
95
96 ~CCursorControl()
97 {
98 Device->drop();
99 }
100
101 //! Changes the visible state of the mouse cursor.
102 virtual void setVisible(bool visible)
103 {
104 IsVisible = visible;
105 }
106
107 //! Returns if the cursor is currently visible.
108 virtual bool isVisible() const
109 {
110 return IsVisible;
111 }
112
113 //! Sets the new position of the cursor.
114 virtual void setPosition(const core::position2d<f32> &pos)
115 {
116 setPosition(pos.X, pos.Y);
117 }
118
119 //! Sets the new position of the cursor.
120 virtual void setPosition(f32 x, f32 y)
121 {
122 setPosition((s32)(x*Device->CreationParams.WindowSize.Width), (s32)(y*Device->CreationParams.WindowSize.Height));
123 }
124
125 //! Sets the new position of the cursor.
126 virtual void setPosition(const core::position2d<s32> &pos)
127 {
128 setPosition(pos.X, pos.Y);
129 }
130
131 //! Sets the new position of the cursor.
132 virtual void setPosition(s32 x, s32 y)
133 {
134 }
135
136 //! Returns the current position of the mouse cursor.
137 virtual const core::position2d<s32>& getPosition()
138 {
139 updateCursorPos();
140 return CursorPos;
141 }
142
143 //! Returns the current position of the mouse cursor.
144 virtual core::position2d<f32> getRelativePosition()
145 {
146 updateCursorPos();
147 return core::position2d<f32>(CursorPos.X / (f32)Device->CreationParams.WindowSize.Width,
148 CursorPos.Y / (f32)Device->CreationParams.WindowSize.Height);
149 }
150
151 virtual void setReferenceRect(core::rect<s32>* rect=0)
152 {
153 }
154
155 private:
156
157 void updateCursorPos()
158 {
159 }
160
161 core::position2d<s32> CursorPos;
162 CIrrDeviceFB* Device;
163 bool IsVisible;
164 bool Null;
165 };
166
167 friend class CCursorControl;
168
169 int Framebuffer;
170 int EventDevice;
171 int KeyboardDevice;
172 struct fb_fix_screeninfo fbfixscreeninfo;
173 struct fb_var_screeninfo fbscreeninfo;
174 struct fb_var_screeninfo oldscreeninfo;
175 long KeyboardMode;
176 u8* SoftwareImage;
177
178 u32 Pitch;
179 video::ECOLOR_FORMAT FBColorFormat;
180 bool Close;
181
182 struct SKeyMap
183 {
184 SKeyMap() {}
185 SKeyMap(s32 x11, s32 win32)
186 : X11Key(x11), Win32Key(win32)
187 {
188 }
189
190 KeySym X11Key;
191 s32 Win32Key;
192
193 bool operator<(const SKeyMap& o) const
194 {
195 return X11Key<o.X11Key;
196 }
197 };
198
199 core::array<SKeyMap> KeyMap;
200 };
201
202
203} // end namespace irr
204
205#endif // _IRR_USE_FB_DEVICE_
206#endif // __C_IRR_DEVICE_FB_H_INCLUDED__
207