Drop Console and Framebuffer device

fbdev is long legacy and the console was just an ASCII art gimmick
This commit is contained in:
sfan5 2022-07-09 23:53:04 +02:00
parent 074e81f78f
commit a7b306f702
10 changed files with 1 additions and 1604 deletions

View File

@ -16,10 +16,6 @@ namespace irr
/** This device uses the Win32 API and works in all versions of Windows. */
EIDT_WIN32,
//! A device native to Windows CE devices
/** This device works on Windows Mobile, Pocket PC and Microsoft SmartPhone devices */
EIDT_WINCE,
//! A device native to Unix style operating systems.
/** This device uses the X11 windowing system and works in Linux, Solaris, FreeBSD, OSX and
other operating systems which support X11. */
@ -38,18 +34,6 @@ namespace irr
in by defining the _IRR_COMPILE_WITH_SDL_DEVICE_ macro in IrrCompileConfig.h */
EIDT_SDL,
//! A device for raw framebuffer access
/** Best used with embedded devices and mobile systems.
Does not need X11 or other graphical subsystems.
May support hw-acceleration via OpenGL-ES for FBDirect */
EIDT_FRAMEBUFFER,
//! A simple text only device supported by all platforms.
/** This device allows applications to run from the command line without opening a window.
It can render the output of the software drivers to the console as ASCII. It only supports
mouse and keyboard in Windows operating systems. */
EIDT_CONSOLE,
//! This selection allows Irrlicht to choose the best device from the ones available.
/** If this selection is chosen then Irrlicht will try to use the IrrlichtDevice native
to your operating system. If this is unavailable then the X11, SDL and then console device

View File

@ -37,8 +37,6 @@
//! _IRR_COMPILE_WITH_OSX_DEVICE_ for Cocoa native windowing on OSX
//! _IRR_COMPILE_WITH_X11_DEVICE_ for Linux X11 based device
//! _IRR_COMPILE_WITH_SDL_DEVICE_ for platform independent SDL framework
//! _IRR_COMPILE_WITH_CONSOLE_DEVICE_ for no windowing system, used as a fallback
//! _IRR_COMPILE_WITH_FB_DEVICE_ for framebuffer systems
//! Passing defines to the compiler which have NO in front of the _IRR definename is an alternative
//! way which can be used to disable defines (instead of outcommenting them in this header).
@ -52,12 +50,6 @@
#undef _IRR_COMPILE_WITH_SDL_DEVICE_
#endif
//! Comment this line to compile without the fallback console device.
#define _IRR_COMPILE_WITH_CONSOLE_DEVICE_
#ifdef NO_IRR_COMPILE_WITH_CONSOLE_DEVICE_
#undef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
#endif
//! WIN32 for Windows32
//! WIN64 for Windows64
// The windows platform and API support SDL and WINDOW device

View File

@ -98,11 +98,9 @@ namespace irr
/** This setting decides the windowing system used by the device, most device types are native
to a specific operating system and so may not be available.
EIDT_WIN32 is only available on Windows desktops,
EIDT_WINCE is only available on Windows mobile devices,
EIDT_COCOA is only available on Mac OSX,
EIDT_X11 is available on Linux, Solaris, BSD and other operating systems which use X11,
EIDT_SDL is available on most systems if compiled in,
EIDT_CONSOLE is usually available but can only render to text,
EIDT_BEST will select the best available device for your operating system.
Default: EIDT_BEST. */
E_DEVICE_TYPE DeviceType;

View File

@ -1,474 +0,0 @@
// Copyright (C) 2009-2012 Gaz Davidson
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CIrrDeviceConsole.h"
#ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
#include "os.h"
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
// to close the device on terminate signal
irr::CIrrDeviceConsole *DeviceToClose;
#ifdef _IRR_WINDOWS_NT_CONSOLE_
// Callback for Windows
BOOL WINAPI ConsoleHandler(DWORD CEvent)
{
switch(CEvent)
{
case CTRL_C_EVENT:
irr::os::Printer::log("Closing console device", "CTRL+C");
break;
case CTRL_BREAK_EVENT:
irr::os::Printer::log("Closing console device", "CTRL+Break");
break;
case CTRL_CLOSE_EVENT:
irr::os::Printer::log("Closing console device", "User closed console");
break;
case CTRL_LOGOFF_EVENT:
irr::os::Printer::log("Closing console device", "User is logging off");
break;
case CTRL_SHUTDOWN_EVENT:
irr::os::Printer::log("Closing console device", "Computer shutting down");
break;
}
DeviceToClose->closeDevice();
return TRUE;
}
#elif defined(_IRR_POSIX_API_)
// sigterm handler
#include <signal.h>
void sighandler(int sig)
{
irr::core::stringc code = "Signal ";
code += sig;
code += " received";
irr::os::Printer::log("Closing console device", code.c_str());
DeviceToClose->closeDevice();
}
#endif
namespace irr
{
const c8 ASCIIArtChars[] = " .,'~:;!+>=icopjtJY56SB8XDQKHNWM"; //MWNHKQDX8BS65YJtjpoci=+>!;:~',. ";
const u16 ASCIIArtCharsCount = 32;
//const c8 ASCIIArtChars[] = " \xb0\xb1\xf9\xb2\xdb";
//const u16 ASCIIArtCharsCount = 5;
//! constructor
CIrrDeviceConsole::CIrrDeviceConsole(const SIrrlichtCreationParameters& params)
: CIrrDeviceStub(params), IsWindowFocused(true), ConsoleFont(0), OutFile(stdout)
{
DeviceToClose = this;
#ifdef _IRR_WINDOWS_NT_CONSOLE_
MouseButtonStates = 0;
WindowsSTDIn = GetStdHandle(STD_INPUT_HANDLE);
WindowsSTDOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (CreationParams.Fullscreen)
{
PCOORD dimensions = 0;
if (SetConsoleDisplayMode(WindowsSTDOut, CONSOLE_FULLSCREEN_MODE, dimensions))
{
CreationParams.WindowSize.Width = dimensions->X;
CreationParams.WindowSize.Width = dimensions->Y;
}
}
else
{
COORD ConsoleSize;
ConsoleSize.X = CreationParams.WindowSize.Width;
ConsoleSize.X = CreationParams.WindowSize.Height;
SetConsoleScreenBufferSize(WindowsSTDOut, ConsoleSize);
}
// catch windows close/break signals
SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleHandler, TRUE);
#elif defined(_IRR_POSIX_API_)
// catch other signals
signal(SIGABRT, &sighandler);
signal(SIGTERM, &sighandler);
signal(SIGINT, &sighandler);
// set output stream
if (params.WindowId)
OutFile = (FILE*)(params.WindowId);
#endif
#ifdef _IRR_VT100_CONSOLE_
// reset terminal
fprintf(OutFile, "%cc", 27);
// disable line wrapping
fprintf(OutFile, "%c[7l", 27);
#endif
switch (params.DriverType)
{
case video::EDT_SOFTWARE:
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
#else
os::Printer::log("Software driver was not compiled in.", ELL_ERROR);
#endif
break;
case video::EDT_BURNINGSVIDEO:
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this);
#else
os::Printer::log("Burning's Video driver was not compiled in.", ELL_ERROR);
#endif
break;
case video::EDT_DIRECT3D9:
case video::EDT_OPENGL:
os::Printer::log("The console device cannot use hardware drivers yet.", ELL_ERROR);
break;
case video::EDT_NULL:
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
break;
default:
os::Printer::log("Unsupported device.", ELL_ERROR);
break;
}
// set up output buffer
for (u32 y=0; y<CreationParams.WindowSize.Height; ++y)
{
core::stringc str;
str.reserve(CreationParams.WindowSize.Width);
for (u32 x=0; x<CreationParams.WindowSize.Width; ++x)
str += " ";
OutputBuffer.push_back(str);
}
#ifdef _IRR_WINDOWS_NT_CONSOLE_
CursorControl = new CCursorControl(CreationParams.WindowSize);
#endif
if (VideoDriver)
{
createGUIAndScene();
#ifdef _IRR_USE_CONSOLE_FONT_
if (GUIEnvironment)
{
ConsoleFont = new gui::CGUIConsoleFont(this);
gui::IGUISkin *skin = GUIEnvironment->getSkin();
if (skin)
{
for (u32 i=0; i < gui::EGDF_COUNT; ++i)
skin->setFont(ConsoleFont, gui::EGUI_DEFAULT_FONT(i));
}
}
#endif
}
}
//! destructor
CIrrDeviceConsole::~CIrrDeviceConsole()
{
// GUI and scene are dropped in the stub
if (CursorControl)
{
CursorControl->drop();
CursorControl = 0;
}
if (ConsoleFont)
{
ConsoleFont->drop();
ConsoleFont = 0;
}
#ifdef _IRR_VT100_CONSOLE_
// reset terminal
fprintf(OutFile, "%cc", 27);
#endif
}
//! runs the device. Returns false if device wants to be deleted
bool CIrrDeviceConsole::run()
{
// increment timer
os::Timer::tick();
// process Windows console input
#ifdef _IRR_WINDOWS_NT_CONSOLE_
INPUT_RECORD in;
DWORD oldMode;
DWORD count, waste;
// get old input mode
GetConsoleMode(WindowsSTDIn, &oldMode);
SetConsoleMode(WindowsSTDIn, ENABLE_WINDOW_INPUT | ENABLE_MOUSE_INPUT);
GetNumberOfConsoleInputEvents(WindowsSTDIn, &count);
// read keyboard and mouse input
while (count)
{
ReadConsoleInput(WindowsSTDIn, &in, 1, &waste );
switch(in.EventType)
{
case KEY_EVENT:
{
SEvent e;
e.EventType = EET_KEY_INPUT_EVENT;
e.KeyInput.PressedDown = (in.Event.KeyEvent.bKeyDown == TRUE);
e.KeyInput.Control = (in.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED)) != 0;
e.KeyInput.Shift = (in.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED) != 0;
e.KeyInput.Key = EKEY_CODE(in.Event.KeyEvent.wVirtualKeyCode);
e.KeyInput.Char = in.Event.KeyEvent.uChar.UnicodeChar;
postEventFromUser(e);
break;
}
case MOUSE_EVENT:
{
SEvent e;
e.EventType = EET_MOUSE_INPUT_EVENT;
e.MouseInput.X = in.Event.MouseEvent.dwMousePosition.X;
e.MouseInput.Y = in.Event.MouseEvent.dwMousePosition.Y;
e.MouseInput.Wheel = 0.f;
e.MouseInput.ButtonStates =
( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED) ? EMBSM_LEFT : 0 ) |
( (in.Event.MouseEvent.dwButtonState & RIGHTMOST_BUTTON_PRESSED) ? EMBSM_RIGHT : 0 ) |
( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_2ND_BUTTON_PRESSED) ? EMBSM_MIDDLE : 0 ) |
( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_3RD_BUTTON_PRESSED) ? EMBSM_EXTRA1 : 0 ) |
( (in.Event.MouseEvent.dwButtonState & FROM_LEFT_4TH_BUTTON_PRESSED) ? EMBSM_EXTRA2 : 0 );
if (in.Event.MouseEvent.dwEventFlags & MOUSE_MOVED)
{
CursorControl->setPosition(core::position2di(e.MouseInput.X, e.MouseInput.Y));
// create mouse moved event
e.MouseInput.Event = EMIE_MOUSE_MOVED;
postEventFromUser(e);
}
if (in.Event.MouseEvent.dwEventFlags & MOUSE_WHEELED)
{
e.MouseInput.Event = EMIE_MOUSE_WHEEL;
e.MouseInput.Wheel = (in.Event.MouseEvent.dwButtonState & 0xFF000000) ? -1.0f : 1.0f;
postEventFromUser(e);
}
if ( (MouseButtonStates & EMBSM_LEFT) != (e.MouseInput.ButtonStates & EMBSM_LEFT) )
{
e.MouseInput.Event = (e.MouseInput.ButtonStates & EMBSM_LEFT) ? EMIE_LMOUSE_PRESSED_DOWN : EMIE_LMOUSE_LEFT_UP;
postEventFromUser(e);
}
if ( (MouseButtonStates & EMBSM_RIGHT) != (e.MouseInput.ButtonStates & EMBSM_RIGHT) )
{
e.MouseInput.Event = (e.MouseInput.ButtonStates & EMBSM_RIGHT) ? EMIE_RMOUSE_PRESSED_DOWN : EMIE_RMOUSE_LEFT_UP;
postEventFromUser(e);
}
if ( (MouseButtonStates & EMBSM_MIDDLE) != (e.MouseInput.ButtonStates & EMBSM_MIDDLE) )
{
e.MouseInput.Event = (e.MouseInput.ButtonStates & EMBSM_MIDDLE) ? EMIE_MMOUSE_PRESSED_DOWN : EMIE_MMOUSE_LEFT_UP;
postEventFromUser(e);
}
// save current button states
MouseButtonStates = e.MouseInput.ButtonStates;
break;
}
case WINDOW_BUFFER_SIZE_EVENT:
VideoDriver->OnResize(
core::dimension2d<u32>(in.Event.WindowBufferSizeEvent.dwSize.X,
in.Event.WindowBufferSizeEvent.dwSize.Y));
break;
case FOCUS_EVENT:
IsWindowFocused = (in.Event.FocusEvent.bSetFocus == TRUE);
break;
default:
break;
}
GetNumberOfConsoleInputEvents(WindowsSTDIn, &count);
}
// set input mode
SetConsoleMode(WindowsSTDIn, oldMode);
#else
// todo: keyboard input from terminal in raw mode
#endif
return !Close;
}
//! Cause the device to temporarily pause execution and let other processes to run
// This should bring down processor usage without major performance loss for Irrlicht
void CIrrDeviceConsole::yield()
{
#ifdef _IRR_WINDOWS_API_
Sleep(1);
#else
struct timespec ts = {0,0};
nanosleep(&ts, NULL);
#endif
}
//! Pause execution and let other processes to run for a specified amount of time.
void CIrrDeviceConsole::sleep(u32 timeMs, bool pauseTimer)
{
const bool wasStopped = Timer ? Timer->isStopped() : true;
#ifdef _IRR_WINDOWS_API_
Sleep(timeMs);
#else
struct timespec ts;
ts.tv_sec = (time_t) (timeMs / 1000);
ts.tv_nsec = (long) (timeMs % 1000) * 1000000;
if (pauseTimer && !wasStopped)
Timer->stop();
nanosleep(&ts, NULL);
#endif
if (pauseTimer && !wasStopped)
Timer->start();
}
//! sets the caption of the window
void CIrrDeviceConsole::setWindowCaption(const wchar_t* text)
{
#ifdef _IRR_WINDOWS_NT_CONSOLE_
SetConsoleTitleW(text);
#endif
}
//! returns if window is active. if not, nothing need to be drawn
bool CIrrDeviceConsole::isWindowActive() const
{
// there is no window, but we always assume it is active
return true;
}
//! returns if window has focus
bool CIrrDeviceConsole::isWindowFocused() const
{
return IsWindowFocused;
}
//! returns if window is minimized
bool CIrrDeviceConsole::isWindowMinimized() const
{
return false;
}
//! presents a surface in the client area
bool CIrrDeviceConsole::present(video::IImage* surface, void* windowId, core::rect<s32>* src)
{
if (surface)
{
for (u32 y=0; y < surface->getDimension().Height; ++y)
{
for (u32 x=0; x< surface->getDimension().Width; ++x)
{
// get average pixel
u32 avg = surface->getPixel(x,y).getAverage() * (ASCIIArtCharsCount-1);
avg /= 255;
OutputBuffer[y] [x] = ASCIIArtChars[avg];
}
}
}
#ifdef _IRR_USE_CONSOLE_FONT_
for (u32 i=0; i< Text.size(); ++i)
{
s32 y = Text[i].Pos.Y;
if ( y < (s32)OutputBuffer.size() && y > 0)
for (u32 c=0; c < Text[i].Text.size() && c + Text[i].Pos.X < OutputBuffer[y].size(); ++c)
//if (Text[i].Text[c] != ' ')
OutputBuffer[y] [c+Text[i].Pos.X] = Text[i].Text[c];
}
Text.clear();
#endif
// draw output
for (u32 y=0; y<OutputBuffer.size(); ++y)
{
setTextCursorPos(0,y);
fprintf(OutFile, "%s", OutputBuffer[y].c_str());
}
return surface != 0;
}
//! notifies the device that it should close itself
void CIrrDeviceConsole::closeDevice()
{
// return false next time we run()
Close = true;
}
//! Sets if the window should be resizable in windowed mode.
void CIrrDeviceConsole::setResizable(bool resize)
{
// do nothing
}
//! Minimize the window.
void CIrrDeviceConsole::minimizeWindow()
{
// do nothing
}
//! Maximize window
void CIrrDeviceConsole::maximizeWindow()
{
// do nothing
}
//! Restore original window size
void CIrrDeviceConsole::restoreWindow()
{
// do nothing
}
void CIrrDeviceConsole::setTextCursorPos(s16 x, s16 y)
{
#ifdef _IRR_WINDOWS_NT_CONSOLE_
// move WinNT cursor
COORD Position;
Position.X = x;
Position.Y = y;
SetConsoleCursorPosition(WindowsSTDOut, Position);
#elif defined(_IRR_VT100_CONSOLE_)
// send escape code
fprintf(OutFile, "%c[%d;%dH", 27, y, x);
#else
// not implemented
#endif
}
void CIrrDeviceConsole::addPostPresentText(s16 X, s16 Y, const wchar_t *text)
{
SPostPresentText p;
p.Text = text;
p.Pos.X = X;
p.Pos.Y = Y;
Text.push_back(p);
}
} // end namespace irr
#endif // _IRR_COMPILE_WITH_CONSOLE_DEVICE_

View File

@ -1,332 +0,0 @@
// Copyright (C) 2009-2012 Gaz Davidson
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_IRR_DEVICE_CONSOLE_H_INCLUDED__
#define __C_IRR_DEVICE_CONSOLE_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
//#define _IRR_USE_CONSOLE_FONT_
#include "SIrrCreationParameters.h"
#include "CIrrDeviceStub.h"
#include "IImagePresenter.h"
// for console font
#include "IGUIFont.h"
#ifdef _IRR_WINDOWS_API_
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define _IRR_WINDOWS_NT_CONSOLE_
#else
#include <time.h>
#endif
// for now we assume all other terminal types are VT100
#ifndef _IRR_WINDOWS_NT_CONSOLE_
#define _IRR_VT100_CONSOLE_
#endif
namespace irr
{
class CIrrDeviceConsole : public CIrrDeviceStub, video::IImagePresenter
{
public:
//! constructor
CIrrDeviceConsole(const SIrrlichtCreationParameters& params);
//! destructor
virtual ~CIrrDeviceConsole();
//! runs the device. Returns false if device wants to be deleted
virtual bool run() _IRR_OVERRIDE_;
//! Cause the device to temporarily pause execution and let other processes to run
// This should bring down processor usage without major performance loss for Irrlicht
virtual void yield() _IRR_OVERRIDE_;
//! Pause execution and let other processes to run for a specified amount of time.
virtual void sleep(u32 timeMs, bool pauseTimer) _IRR_OVERRIDE_;
//! sets the caption of the window
virtual void setWindowCaption(const wchar_t* text) _IRR_OVERRIDE_;
//! returns if window is active. if not, nothing need to be drawn
virtual bool isWindowActive() const _IRR_OVERRIDE_;
//! returns if window has focus
virtual bool isWindowFocused() const _IRR_OVERRIDE_;
//! returns if window is minimized
virtual bool isWindowMinimized() const _IRR_OVERRIDE_;
//! returns current window position (not supported for this device)
virtual core::position2di getWindowPosition() _IRR_OVERRIDE_
{
return core::position2di(-1, -1);
}
//! presents a surface in the client area
virtual bool present(video::IImage* surface, void* windowId=0, core::rect<s32>* src=0) _IRR_OVERRIDE_;
//! notifies the device that it should close itself
virtual void closeDevice() _IRR_OVERRIDE_;
//! Sets if the window should be resizable in windowed mode.
virtual void setResizable(bool resize=false) _IRR_OVERRIDE_;
//! Minimizes the window.
virtual void minimizeWindow() _IRR_OVERRIDE_;
//! Maximizes the window.
virtual void maximizeWindow() _IRR_OVERRIDE_;
//! Restores the window size.
virtual void restoreWindow() _IRR_OVERRIDE_;
//! Get the device type
virtual E_DEVICE_TYPE getType() const _IRR_OVERRIDE_
{
return EIDT_CONSOLE;
}
void addPostPresentText(s16 X, s16 Y, const wchar_t *text);
//! Implementation of the win32 console mouse cursor
class CCursorControl : public gui::ICursorControl
{
public:
CCursorControl(const core::dimension2d<u32>& wsize)
: WindowSize(wsize), InvWindowSize(0.0f, 0.0f), IsVisible(true), UseReferenceRect(false)
{
if (WindowSize.Width!=0)
InvWindowSize.Width = 1.0f / WindowSize.Width;
if (WindowSize.Height!=0)
InvWindowSize.Height = 1.0f / WindowSize.Height;
}
//! Changes the visible state of the mouse cursor.
virtual void setVisible(bool visible) _IRR_OVERRIDE_
{
if(visible != IsVisible)
{
IsVisible = visible;
setPosition(CursorPos.X, CursorPos.Y);
}
}
//! Returns if the cursor is currently visible.
virtual bool isVisible() const _IRR_OVERRIDE_
{
return IsVisible;
}
//! Sets the new position of the cursor.
virtual void setPosition(const core::position2d<f32> &pos) _IRR_OVERRIDE_
{
setPosition(pos.X, pos.Y);
}
//! Sets the new position of the cursor.
virtual void setPosition(f32 x, f32 y) _IRR_OVERRIDE_
{
if (!UseReferenceRect)
setPosition((s32)(x*WindowSize.Width), (s32)(y*WindowSize.Height));
else
setPosition((s32)(x*ReferenceRect.getWidth()), (s32)(y*ReferenceRect.getHeight()));
}
//! Sets the new position of the cursor.
virtual void setPosition(const core::position2d<s32> &pos) _IRR_OVERRIDE_
{
setPosition(pos.X, pos.Y);
}
//! Sets the new position of the cursor.
virtual void setPosition(s32 x, s32 y) _IRR_OVERRIDE_
{
setInternalCursorPosition(core::position2di(x,y));
}
//! Returns the current position of the mouse cursor.
virtual const core::position2d<s32>& getPosition(bool updateCursor) _IRR_OVERRIDE_
{
return CursorPos;
}
//! Returns the current position of the mouse cursor.
virtual core::position2d<f32> getRelativePosition(bool updateCursor) _IRR_OVERRIDE_
{
if (!UseReferenceRect)
{
return core::position2d<f32>(CursorPos.X * InvWindowSize.Width,
CursorPos.Y * InvWindowSize.Height);
}
return core::position2d<f32>(CursorPos.X / (f32)ReferenceRect.getWidth(),
CursorPos.Y / (f32)ReferenceRect.getHeight());
}
//! Sets an absolute reference rect for calculating the cursor position.
virtual void setReferenceRect(core::rect<s32>* rect=0) _IRR_OVERRIDE_
{
if (rect)
{
ReferenceRect = *rect;
UseReferenceRect = true;
// prevent division through zero and uneven sizes
if (!ReferenceRect.getHeight() || ReferenceRect.getHeight()%2)
ReferenceRect.LowerRightCorner.Y += 1;
if (!ReferenceRect.getWidth() || ReferenceRect.getWidth()%2)
ReferenceRect.LowerRightCorner.X += 1;
}
else
UseReferenceRect = false;
}
//! Updates the internal cursor position
void setInternalCursorPosition(const core::position2di &pos)
{
CursorPos = pos;
if (UseReferenceRect)
CursorPos -= ReferenceRect.UpperLeftCorner;
}
private:
core::position2d<s32> CursorPos;
core::dimension2d<u32> WindowSize;
core::dimension2d<f32> InvWindowSize;
bool IsVisible;
bool UseReferenceRect;
core::rect<s32> ReferenceRect;
};
private:
//! Set the position of the text caret
void setTextCursorPos(s16 x, s16 y);
// text to be added after drawing the screen
struct SPostPresentText
{
core::position2d<s16> Pos;
core::stringc Text;
};
bool IsWindowFocused;
core::array<core::stringc> OutputBuffer;
gui::IGUIFont *ConsoleFont;
core::array<SPostPresentText> Text;
FILE *OutFile;
#ifdef _IRR_WINDOWS_NT_CONSOLE_
HANDLE WindowsSTDIn, WindowsSTDOut;
u32 MouseButtonStates;
#endif
};
#ifdef _IRR_USE_CONSOLE_FONT_
namespace gui
{
class CGUIConsoleFont : public IGUIFont
{
public:
CGUIConsoleFont(CIrrDeviceConsole* device) : Device(device) { }
//! Draws some text and clips it to the specified rectangle if wanted.
virtual void draw(const wchar_t* text, const core::rect<s32>& position,
video::SColor color, bool hcenter=false, bool vcenter=false,
const core::rect<s32>* clip=0) _IRR_OVERRIDE_
{
core::rect<s32> Area = clip ? *clip : position;
if (Area.UpperLeftCorner.X < 0)
Area.UpperLeftCorner.X = 0;
if (Area.UpperLeftCorner.Y < 0)
Area.UpperLeftCorner.Y = 0;
core::position2d<s16> pos;
// centre vertically
pos.Y = vcenter ? (position.UpperLeftCorner.Y + position.LowerRightCorner.Y) / 2 : position.UpperLeftCorner.Y;
// nothing to display?
if (pos.Y < Area.UpperLeftCorner.Y || pos.Y > Area.LowerRightCorner.Y)
return;
tempText = text;
// centre horizontally
pos.X = hcenter ? position.getCenter().X - ( tempText.size() / 2) : position.UpperLeftCorner.X;
// clip
u32 xlclip = 0,
xrclip = 0;
// get right clip
if (pos.X + (s32)tempText.size() > Area.LowerRightCorner.X)
xrclip = Area.LowerRightCorner.X - pos.X;
// get left clip
if (pos.X < Area.UpperLeftCorner.X)
xlclip = Area.UpperLeftCorner.X - pos.X;
// totally clipped?
if ((s32)tempText.size() - xlclip - xrclip < 0)
return;
// null terminate the string
if (xrclip > 0)
tempText[xrclip] = L'\0';
Device->addPostPresentText(pos.X + xlclip, pos.Y, &(tempText.c_str()[xlclip]));
}
//! Calculates the dimension of some text.
virtual core::dimension2d<u32> getDimension(const wchar_t* text) const _IRR_OVERRIDE_
{
return core::dimension2d<u32>(wcslen(text),1);
}
//! Calculates the index of the character in the text which is on a specific position.
virtual s32 getCharacterFromPos(const wchar_t* text, s32 pixel_x) const _IRR_OVERRIDE_ { return pixel_x; } _IRR_OVERRIDE_;
//! No kerning
virtual void setKerningWidth (s32 kerning) _IRR_OVERRIDE_ { }
virtual void setKerningHeight (s32 kerning) _IRR_OVERRIDE_ { }
virtual s32 getKerningWidth(const wchar_t* thisLetter=0, const wchar_t* previousLetter=0) const _IRR_OVERRIDE_ {return 0;}
virtual s32 getKerningHeight() const _IRR_OVERRIDE_ { return 0;}
virtual void setInvisibleCharacters( const wchar_t *s ) _IRR_OVERRIDE_ { }
// I guess this is an OS specific font
virtual EGUI_FONT_TYPE getType() const _IRR_OVERRIDE_ { return EGFT_OS; }
private:
CIrrDeviceConsole* Device;
core::stringw tempText;
};
} // end namespace gui
#endif // _IRR_USE_CONSOLE_FONT_
} // end namespace irr
#endif // _IRR_COMPILE_WITH_CONSOLE_DEVICE_
#endif // __C_IRR_DEVICE_CONSOLE_H_INCLUDED__

View File

@ -1,536 +0,0 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// Copyright (C) 2007-2012 Christian Stehno
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CIrrDeviceFB.h"
#ifdef _IRR_COMPILE_WITH_FB_DEVICE_
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/utsname.h>
#include <time.h>
#include <errno.h>
#include "IEventReceiver.h"
#include "os.h"
#include "CTimer.h"
#include "irrString.h"
#include "Keycodes.h"
#include "COSOperator.h"
#include "CColorConverter.h"
#include "SIrrCreationParameters.h"
#include "CEGLManager.h"
#include <linux/input.h>
namespace irr
{
namespace video
{
#ifdef _IRR_COMPILE_WITH_OGLES1_
IVideoDriver* createOGLES1Driver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io, video::IContextManager* contextManager);
#endif
#ifdef _IRR_COMPILE_WITH_OGLES2_
IVideoDriver* createOGLES2Driver(const SIrrlichtCreationParameters& params,
io::IFileSystem* io, video::IContextManager* contextManager);
#endif
}
}
namespace irr
{
//! constructor
CIrrDeviceFB::CIrrDeviceFB(const SIrrlichtCreationParameters& params)
: CIrrDeviceStub(params), Framebuffer(-1), EventDevice(-1), SoftwareImage(0),
Pitch(0), FBColorFormat(video::ECF_A8R8G8B8), Close(false)
{
#ifdef _DEBUG
setDebugName("CIrrDeviceFB");
#endif
// print version, distribution etc.
// thx to LynxLuna for pointing me to the uname function
core::stringc linuxversion;
struct utsname FBInfo;
uname(&FBInfo);
linuxversion += FBInfo.sysname;
linuxversion += " ";
linuxversion += FBInfo.release;
linuxversion += " ";
linuxversion += FBInfo.version;
linuxversion += " ";
linuxversion += FBInfo.machine;
Operator = new COSOperator(linuxversion);
os::Printer::log(linuxversion.c_str(), ELL_INFORMATION);
// create window
if (params.DriverType != video::EDT_NULL)
{
// create the window, only if we do not use the null device
if (!createWindow(params.WindowSize, params.Bits))
return;
}
// create cursor control
CursorControl = new CCursorControl(this, params.DriverType == video::EDT_NULL);
// create driver
createDriver();
if (!VideoDriver)
return;
createGUIAndScene();
}
//! destructor
CIrrDeviceFB::~CIrrDeviceFB()
{
if (SoftwareImage)
munmap(SoftwareImage, CreationParams.WindowSize.Height*Pitch);
// go back to previous format
if (ioctl(Framebuffer, FBIOPUT_VSCREENINFO, &oldscreeninfo) <0)
perror("Restoring old fb mode");
if (KeyboardDevice != -1)
if (ioctl(KeyboardDevice, KDSETMODE, &KeyboardMode) <0)
perror("Restoring keyboard mode");
if (EventDevice != -1)
close(EventDevice);
if (KeyboardDevice != -1)
close(KeyboardDevice);
if (Framebuffer != -1)
close(Framebuffer);
}
bool CIrrDeviceFB::createWindow(const core::dimension2d<u32>& windowSize, u32 bits)
{
char buf[256];
CreationParams.WindowSize.Width = windowSize.Width;
CreationParams.WindowSize.Height = windowSize.Height;
KeyboardDevice = open("/dev/tty", O_RDWR);
if (KeyboardDevice == -1)
perror("Open keyboard");
if (ioctl(KeyboardDevice, KDGETMODE, &KeyboardMode) <0)
perror("Read keyboard mode");
if (ioctl(KeyboardDevice, KDSETMODE, KD_GRAPHICS) <0)
perror("Set keyboard mode");
Framebuffer=open("/dev/fb/0", O_RDWR);
if (Framebuffer == -1)
{
Framebuffer=open("/dev/fb0", O_RDWR);
if (Framebuffer == -1)
{
perror("Open framebuffer");
return false;
}
}
EventDevice = open("/dev/input/event0", O_RDONLY | O_NONBLOCK);
if (EventDevice == -1)
perror("Open event device");
// make format settings
ioctl(Framebuffer, FBIOGET_FSCREENINFO, &fbfixscreeninfo);
ioctl(Framebuffer, FBIOGET_VSCREENINFO, &oldscreeninfo);
snprintf_irr(buf, 256, "Original resolution: %d x %d\nARGB%d%d%d%d\n",oldscreeninfo.xres,oldscreeninfo.yres,
oldscreeninfo.transp.length,oldscreeninfo.red.length,oldscreeninfo.green.length,oldscreeninfo.blue.length);
os::Printer::log(buf);
memcpy(&fbscreeninfo, &oldscreeninfo, sizeof(struct fb_var_screeninfo));
if (CreationParams.DriverType != video::EDT_NULL)
{
fbscreeninfo.xres = fbscreeninfo.xres_virtual = CreationParams.WindowSize.Width;
fbscreeninfo.yres = fbscreeninfo.yres_virtual = CreationParams.WindowSize.Height;
fbscreeninfo.bits_per_pixel = 16;
fbscreeninfo.red.offset = 10;
fbscreeninfo.red.length = 5;
fbscreeninfo.green.offset = 5;
fbscreeninfo.green.length = 5;
fbscreeninfo.blue.offset = 0;
fbscreeninfo.blue.length = 5;
fbscreeninfo.transp.offset = 15;
fbscreeninfo.transp.length = 1;
ioctl(Framebuffer, FBIOPUT_VSCREENINFO, &fbscreeninfo);
ioctl(Framebuffer, FBIOGET_VSCREENINFO, &fbscreeninfo);
snprintf_irr(buf, 256, "New resolution: %d x %d (%d x %d)\nARGB%d%d%d%d\n",fbscreeninfo.xres,fbscreeninfo.yres,fbscreeninfo.xres_virtual,fbscreeninfo.yres_virtual,
fbscreeninfo.transp.length,fbscreeninfo.red.length,fbscreeninfo.green.length,fbscreeninfo.blue.length);
os::Printer::log(buf);
CreationParams.WindowSize.Width = fbscreeninfo.xres;
CreationParams.WindowSize.Height = fbscreeninfo.yres;
CreationParams.Bits = fbscreeninfo.bits_per_pixel;
Pitch = fbfixscreeninfo.line_length;
if (fbscreeninfo.bits_per_pixel == 16)
{
if (fbscreeninfo.transp.length == 0)
FBColorFormat = video::ECF_R5G6B5;
else
FBColorFormat = video::ECF_A1R5G5B5;
}
else
{
if (fbscreeninfo.transp.length == 0)
FBColorFormat = video::ECF_R8G8B8;
else
FBColorFormat = video::ECF_A8R8G8B8;
}
if (MAP_FAILED==(SoftwareImage=(u8*)mmap(0, CreationParams.WindowSize.Height*Pitch, PROT_READ|PROT_WRITE, MAP_SHARED, Framebuffer, 0)))
{
perror("mmap render target");
return false;
}
}
return true;
}
//! create the driver
void CIrrDeviceFB::createDriver()
{
switch(CreationParams.DriverType)
{
case video::EDT_SOFTWARE:
#ifdef _IRR_COMPILE_WITH_SOFTWARE_
VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
#else
os::Printer::log("No Software driver support compiled in.", ELL_WARNING);
#endif
break;
case video::EDT_BURNINGSVIDEO:
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this);
#else
os::Printer::log("Burning's video driver was not compiled in.", ELL_WARNING);
#endif
break;
case video::EDT_OGLES2:
#ifdef _IRR_COMPILE_WITH_OGLES2_
{
video::SExposedVideoData data;
s32 width = 0;
s32 height = 0;
NativeDisplayType display = fbGetDisplay(0);
fbGetDisplayGeometry(display, &width, &height);
data.OpenGLFB.Window = (void*)fbCreateWindow(display, 0, 0, width, height);
ContextManager = new video::CEGLManager();
ContextManager->initialize(CreationParams, data);
VideoDriver = video::createOGLES2Driver(CreationParams, FileSystem, ContextManager);
}
#else
os::Printer::log("No OpenGL-ES2 support compiled in.", ELL_ERROR);
#endif
break;
case video::EDT_OGLES1:
#ifdef _IRR_COMPILE_WITH_OGLES1_
{
video::SExposedVideoData data;
s32 width = 0;
s32 height = 0;
NativeDisplayType display = fbGetDisplay(0);
fbGetDisplayGeometry(display, &width, &height);
data.OpenGLFB.Window = (void*)fbCreateWindow(display, 0, 0, width, height);
ContextManager = new video::CEGLManager();
ContextManager->initialize(CreationParams, data);
VideoDriver = video::createOGLES1Driver(CreationParams, FileSystem, ContextManager);
}
#else
os::Printer::log("No OpenGL-ES1 support compiled in.", ELL_ERROR);
#endif
break;
case video::DEPRECATED_EDT_DIRECT3D8_NO_LONGER_EXISTS:
case video::EDT_OPENGL:
case video::EDT_DIRECT3D9:
os::Printer::log("This driver is not available in FB. Try Software renderer.",
ELL_WARNING);
break;
default:
VideoDriver = video::createNullDriver(FileSystem, CreationParams.WindowSize);
break;
}
}
//! runs the device. Returns false if device wants to be deleted
bool CIrrDeviceFB::run()
{
os::Timer::tick();
struct input_event ev;
if (EventDevice>=0)
{
if ((read(EventDevice, &ev, sizeof(input_event)) < 0) &&
errno != EAGAIN)
perror("Read input event");
if (ev.type == EV_KEY)
{
irr::SEvent irrevent;
irrevent.EventType = irr::EET_KEY_INPUT_EVENT;
irrevent.KeyInput.PressedDown = (ev.value == 1);
switch (ev.code)
{
case KEY_RIGHTCTRL:
case KEY_LEFTCTRL:
irrevent.KeyInput.Control = true;
break;
case KEY_RIGHTSHIFT:
case KEY_LEFTSHIFT:
irrevent.KeyInput.Shift = true;
break;
case KEY_ESC:
irrevent.KeyInput.Key = (EKEY_CODE)0x1B;
break;
case KEY_SPACE:
irrevent.KeyInput.Key = (EKEY_CODE)0x20;
break;
case KEY_UP:
irrevent.KeyInput.Key = (EKEY_CODE)0x26;
break;
case KEY_LEFT:
irrevent.KeyInput.Key = (EKEY_CODE)0x25;
break;
case KEY_RIGHT:
irrevent.KeyInput.Key = (EKEY_CODE)0x27;
break;
case KEY_DOWN:
irrevent.KeyInput.Key = (EKEY_CODE)0x28;
break;
case KEY_A:
irrevent.KeyInput.Key = (EKEY_CODE)0x41;
break;
case KEY_B:
irrevent.KeyInput.Key = (EKEY_CODE)0x42;
break;
case KEY_C:
irrevent.KeyInput.Key = (EKEY_CODE)0x43;
break;
case KEY_D:
irrevent.KeyInput.Key = (EKEY_CODE)0x44;
break;
case KEY_E:
irrevent.KeyInput.Key = (EKEY_CODE)0x45;
break;
case KEY_F:
irrevent.KeyInput.Key = (EKEY_CODE)0x46;
break;
case KEY_G:
irrevent.KeyInput.Key = (EKEY_CODE)0x47;
break;
case KEY_H:
irrevent.KeyInput.Key = (EKEY_CODE)0x48;
break;
case KEY_I:
irrevent.KeyInput.Key = (EKEY_CODE)0x49;
break;
case KEY_J:
irrevent.KeyInput.Key = (EKEY_CODE)0x4A;
break;
case KEY_K:
irrevent.KeyInput.Key = (EKEY_CODE)0x4B;
break;
case KEY_L:
irrevent.KeyInput.Key = (EKEY_CODE)0x4C;
break;
case KEY_M:
irrevent.KeyInput.Key = (EKEY_CODE)0x4D;
break;
case KEY_N:
irrevent.KeyInput.Key = (EKEY_CODE)0x4E;
break;
case KEY_O:
irrevent.KeyInput.Key = (EKEY_CODE)0x4F;
break;
case KEY_P:
irrevent.KeyInput.Key = (EKEY_CODE)0x50;
break;
case KEY_Q:
irrevent.KeyInput.Key = (EKEY_CODE)0x51;
break;
case KEY_R:
irrevent.KeyInput.Key = (EKEY_CODE)0x52;
break;
case KEY_S:
irrevent.KeyInput.Key = (EKEY_CODE)0x53;
break;
case KEY_T:
irrevent.KeyInput.Key = (EKEY_CODE)0x54;
break;
case KEY_U:
irrevent.KeyInput.Key = (EKEY_CODE)0x55;
break;
case KEY_V:
irrevent.KeyInput.Key = (EKEY_CODE)0x56;
break;
case KEY_W:
irrevent.KeyInput.Key = (EKEY_CODE)0x57;
break;
case KEY_X:
irrevent.KeyInput.Key = (EKEY_CODE)0x58;
break;
case KEY_Y:
irrevent.KeyInput.Key = (EKEY_CODE)0x59;
break;
case KEY_Z:
irrevent.KeyInput.Key = (EKEY_CODE)0x5A;
break;
default:
irrevent.KeyInput.Key = (EKEY_CODE)0;
break;
}
postEventFromUser(irrevent);
}
}
return !Close;
}
//! Pause the current process for the minimum time allowed only to allow other processes to execute
void CIrrDeviceFB::yield()
{
struct timespec ts = {0,0};
nanosleep(&ts, NULL);
}
//! Pause execution and let other processes to run for a specified amount of time.
void CIrrDeviceFB::sleep(u32 timeMs, bool pauseTimer=false)
{
bool wasStopped = Timer ? Timer->isStopped() : true;
struct timespec ts;
ts.tv_sec = (time_t) (timeMs / 1000);
ts.tv_nsec = (long) (timeMs % 1000) * 1000000;
if (pauseTimer && !wasStopped)
Timer->stop();
nanosleep(&ts, NULL);
if (pauseTimer && !wasStopped)
Timer->start();
}
//! presents a surface in the client area
bool CIrrDeviceFB::present(video::IImage* image, void* windowId, core::rect<s32>* src )
{
// this is only necessary for software drivers.
if (CreationParams.DriverType != video::EDT_SOFTWARE && CreationParams.DriverType != video::EDT_BURNINGSVIDEO)
return false;
if (!SoftwareImage)
return false;
u8* destData = SoftwareImage;
u32 srcwidth = (u32)image->getDimension().Width;
u32 srcheight = (u32)image->getDimension().Height;
// clip images
srcheight = core::min_(srcheight, CreationParams.WindowSize.Height);
srcwidth = core::min_(srcwidth, CreationParams.WindowSize.Width);
u8* srcdata = (u8*)image->lock();
for (u32 y=0; y<srcheight; ++y)
{
video::CColorConverter::convert_viaFormat(srcdata, image->getColorFormat(), srcwidth, destData, FBColorFormat);
srcdata+=image->getPitch();
destData+=Pitch;
}
image->unlock();
msync(SoftwareImage,CreationParams.WindowSize.Width*CreationParams.WindowSize.Height,MS_ASYNC);
return true;
}
//! notifies the device that it should close itself
void CIrrDeviceFB::closeDevice()
{
Close = true;
}
//! returns if window is active. if not, nothing need to be drawn
bool CIrrDeviceFB::isWindowActive() const
{
return true;
}
//! returns if window has focus
bool CIrrDeviceFB::isWindowFocused() const
{
return true;
}
//! returns if window is minimized
bool CIrrDeviceFB::isWindowMinimized() const
{
return false;
}
//! sets the caption of the window
void CIrrDeviceFB::setWindowCaption(const wchar_t* text)
{
}
//! Sets if the window should be resizeable in windowed mode.
void CIrrDeviceFB::setResizable(bool resize)
{
}
//! Minimizes window
void CIrrDeviceFB::minimizeWindow()
{
}
//! Maximizes window
void CIrrDeviceFB::maximizeWindow()
{
}
//! Restores original window size
void CIrrDeviceFB::restoreWindow()
{
}
//! Returns the type of this device
E_DEVICE_TYPE CIrrDeviceFB::getType() const
{
return EIDT_FRAMEBUFFER;
}
} // end namespace irr
#endif // _IRR_USE_FB_DEVICE_

View File

@ -1,215 +0,0 @@
// Copyright (C) 2002-2007 Nikolaus Gebhardt
// Copyright (C) 2007-2012 Christian Stehno
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_IRR_DEVICE_FB_H_INCLUDED__
#define __C_IRR_DEVICE_FB_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_FB_DEVICE_
#include "CIrrDeviceStub.h"
#include "SIrrCreationParameters.h"
#include "IrrlichtDevice.h"
#include "IImagePresenter.h"
#include "ICursorControl.h"
#define KeySym s32
#include <linux/fb.h>
#include <linux/kd.h>
namespace irr
{
class CIrrDeviceFB : public CIrrDeviceStub, public video::IImagePresenter
{
public:
//! constructor
CIrrDeviceFB(const SIrrlichtCreationParameters& params);
//! destructor
virtual ~CIrrDeviceFB();
//! runs the device. Returns false if device wants to be deleted
virtual bool run() _IRR_OVERRIDE_;
//! Cause the device to temporarily pause execution and let other processes to run
// This should bring down processor usage without major performance loss for Irrlicht
virtual void yield() _IRR_OVERRIDE_;
//! Pause execution and let other processes to run for a specified amount of time.
virtual void sleep(u32 timeMs, bool pauseTimer) _IRR_OVERRIDE_;
//! sets the caption of the window
virtual void setWindowCaption(const wchar_t* text) _IRR_OVERRIDE_;
//! returns if window is active. if not, nothing need to be drawn
virtual bool isWindowActive() const _IRR_OVERRIDE_;
//! returns if window has focus
virtual bool isWindowFocused() const _IRR_OVERRIDE_;
//! returns if window is minimized
virtual bool isWindowMinimized() const _IRR_OVERRIDE_;
//! Minimizes window
virtual void minimizeWindow() _IRR_OVERRIDE_;
//! Maximizes window
virtual void maximizeWindow() _IRR_OVERRIDE_;
//! Restores original window size
virtual void restoreWindow() _IRR_OVERRIDE_;
//! returns current window position (not supported for this device)
virtual core::position2di getWindowPosition() _IRR_OVERRIDE_
{
return core::position2di(-1, -1);
}
//! presents a surface in the client area
virtual bool present(video::IImage* surface, void* windowId = 0, core::rect<s32>* src=0 ) _IRR_OVERRIDE_;
//! notifies the device that it should close itself
virtual void closeDevice() _IRR_OVERRIDE_;
//! Sets if the window should be resizeable in windowed mode.
virtual void setResizable(bool resize=false) _IRR_OVERRIDE_;
//! Returns the type of this device
virtual E_DEVICE_TYPE getType() const _IRR_OVERRIDE_;
private:
//! create the driver
void createDriver();
bool createWindow(const core::dimension2d<u32>& windowSize, u32 bits);
//! Implementation of the cursor control
class CCursorControl : public gui::ICursorControl
{
public:
CCursorControl(CIrrDeviceFB* dev, bool null)
: Device(dev), IsVisible(true), Null(null)
{
Device->grab();
}
~CCursorControl()
{
Device->drop();
}
//! Changes the visible state of the mouse cursor.
virtual void setVisible(bool visible) _IRR_OVERRIDE_
{
IsVisible = visible;
}
//! Returns if the cursor is currently visible.
virtual bool isVisible() const _IRR_OVERRIDE_
{
return IsVisible;
}
//! Sets the new position of the cursor.
virtual void setPosition(const core::position2d<f32> &pos) _IRR_OVERRIDE_
{
setPosition(pos.X, pos.Y);
}
//! Sets the new position of the cursor.
virtual void setPosition(f32 x, f32 y) _IRR_OVERRIDE_
{
setPosition((s32)(x*Device->CreationParams.WindowSize.Width), (s32)(y*Device->CreationParams.WindowSize.Height));
}
//! Sets the new position of the cursor.
virtual void setPosition(const core::position2d<s32> &pos) _IRR_OVERRIDE_
{
setPosition(pos.X, pos.Y);
}
//! Sets the new position of the cursor.
virtual void setPosition(s32 x, s32 y) _IRR_OVERRIDE_
{
}
//! Returns the current position of the mouse cursor.
virtual const core::position2d<s32>& getPosition(bool updateCursor) _IRR_OVERRIDE_
{
if ( updateCursor )
updateCursorPos();
return CursorPos;
}
//! Returns the current position of the mouse cursor.
virtual core::position2d<f32> getRelativePosition(bool updateCursor) _IRR_OVERRIDE_
{
if ( updateCursor)
updateCursorPos();
return core::position2d<f32>(CursorPos.X / (f32)Device->CreationParams.WindowSize.Width,
CursorPos.Y / (f32)Device->CreationParams.WindowSize.Height);
}
virtual void setReferenceRect(core::rect<s32>* rect=0) _IRR_OVERRIDE_
{
}
private:
void updateCursorPos()
{
}
core::position2d<s32> CursorPos;
CIrrDeviceFB* Device;
bool IsVisible;
bool Null;
};
friend class CCursorControl;
int Framebuffer;
int EventDevice;
int KeyboardDevice;
struct fb_fix_screeninfo fbfixscreeninfo;
struct fb_var_screeninfo fbscreeninfo;
struct fb_var_screeninfo oldscreeninfo;
long KeyboardMode;
u8* SoftwareImage;
u32 Pitch;
video::ECOLOR_FORMAT FBColorFormat;
bool Close;
struct SKeyMap
{
SKeyMap() {}
SKeyMap(s32 x11, s32 win32)
: X11Key(x11), Win32Key(win32)
{
}
KeySym X11Key;
s32 Win32Key;
bool operator<(const SKeyMap& o) const
{
return X11Key<o.X11Key;
}
};
core::array<SKeyMap> KeyMap;
};
} // end namespace irr
#endif // _IRR_USE_FB_DEVICE_
#endif // __C_IRR_DEVICE_FB_H_INCLUDED__

View File

@ -222,10 +222,8 @@ add_library(IRRIOOBJ OBJECT
add_library(IRROTHEROBJ OBJECT
CIrrDeviceSDL.cpp
CIrrDeviceLinux.cpp
CIrrDeviceConsole.cpp
CIrrDeviceStub.cpp
CIrrDeviceWin32.cpp
CIrrDeviceFB.cpp
CLogger.cpp
COSOperator.cpp
Irrlicht.cpp

View File

@ -13,7 +13,7 @@
#include "fast_atof.h"
#if defined(_IRR_OGLES1_USE_EXTPOINTER_)
#if defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) || defined(_IRR_COMPILE_WITH_FB_DEVICE_) || defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
#if defined(_IRR_COMPILE_WITH_ANDROID_DEVICE_) || defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
#include <EGL/egl.h>
#else
#include <GLES/egl.h>

View File

@ -26,18 +26,10 @@ static const char* const copyright = "Irrlicht Engine (c) 2002-2017 Nikolaus Geb
#include "CIrrDeviceOSX.h"
#endif
#ifdef _IRR_COMPILE_WITH_FB_DEVICE_
#include "CIrrDeviceFB.h"
#endif
#ifdef _IRR_COMPILE_WITH_SDL_DEVICE_
#include "CIrrDeviceSDL.h"
#endif
#ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
#include "CIrrDeviceConsole.h"
#endif
#ifdef _IRR_COMPILE_WITH_IOS_DEVICE_
#include "CIrrDeviceiOS.h"
#endif
@ -103,16 +95,6 @@ namespace irr
dev = new CIrrDeviceSDL(params);
#endif
#ifdef _IRR_COMPILE_WITH_FB_DEVICE_
if (params.DeviceType == EIDT_FRAMEBUFFER || (!dev && params.DeviceType == EIDT_BEST))
dev = new CIrrDeviceFB(params);
#endif
#ifdef _IRR_COMPILE_WITH_CONSOLE_DEVICE_
if (params.DeviceType == EIDT_CONSOLE || (!dev && params.DeviceType == EIDT_BEST))
dev = new CIrrDeviceConsole(params);
#endif
if (dev && !dev->getVideoDriver() && params.DriverType != video::EDT_NULL)
{
dev->closeDevice(); // destroy window