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