mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
rainbow: some small fixes, SDLFb first shot..
git-svn-id: svn://ultimatepp.org/upp/trunk@3607 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
6d7a351867
commit
0c95fb07d9
28 changed files with 565 additions and 67 deletions
|
|
@ -19,7 +19,7 @@ Image MakeDragImage(const Image& arrow, Image sample);
|
|||
|
||||
Image MakeDragImage(const Image& arrow, const Image& arrow98, Image sample)
|
||||
{
|
||||
#if PLATFORM_WIN32
|
||||
#ifdef PLATFORM_WIN32
|
||||
if(IsWin2K())
|
||||
return MakeDragImage(arrow, sample);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -136,9 +136,4 @@ public:
|
|||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#ifndef PLATFORM_WIN32
|
||||
#include <CtrlCore/stdids.h>
|
||||
#include "vkcodes.h" //FIXME
|
||||
#endif
|
||||
|
||||
#define GUIPLATFORM_INCLUDE_AFTER <Framebuffer/After.h>
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ bool Ctrl::ProcessEvents(bool *quit)
|
|||
SweepMkImageCache();
|
||||
DoPaint(invalid);
|
||||
invalid.Clear();
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Ctrl::EventLoop0(Ctrl *ctrl)
|
||||
|
|
@ -246,7 +246,7 @@ void Ctrl::EventLoop0(Ctrl *ctrl)
|
|||
|
||||
bool quit = false;
|
||||
ProcessEvents(&quit);
|
||||
while(!FBEndSession() && !quit && ctrl ? ctrl->IsOpen() && ctrl->InLoop() : GetTopCtrls().GetCount())
|
||||
while(!FBEndSession() && !quit && (ctrl ? ctrl->IsOpen() && ctrl->InLoop() : GetTopCtrls().GetCount()))
|
||||
{
|
||||
// LLOG(GetSysTime() << " % " << (unsigned)msecs() % 10000 << ": EventLoop / GuiSleep");
|
||||
SyncCaret();
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
#ifndef _LinuxFb_LinuxFb_h
|
||||
#define _LinuxFb_LinuxFb_h
|
||||
#ifndef _LinuxFb_LinuxFb_h_
|
||||
#define _LinuxFb_LinuxFb_h_
|
||||
|
||||
#include <CtrlCore/CtrlCore.h>
|
||||
#include <Framebuffer/Framebuffer.h>
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
#include <CtrlCore/stdids.h>
|
||||
#include "vkcodes.h" //FIXME
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
file
|
||||
LinuxFb.h,
|
||||
LinuxFbLocal.h,
|
||||
Local.h,
|
||||
Keys.h,
|
||||
Proc.cpp;
|
||||
|
|
|
|||
13
rainbow/LinuxFb/LinuxFbLocal.h
Normal file
13
rainbow/LinuxFb/LinuxFbLocal.h
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
#ifndef _LinuxFb_LinuxFbLocal_h
|
||||
#define _LinuxFb_LinuxFbLocal_h
|
||||
|
||||
#include <CtrlCore/CtrlCore.h>
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
extern bool fbEndSession;
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
#ifdef PLATFORM_POSIX
|
||||
|
||||
void FBInit(const String& fbdevice);
|
||||
void FBDeInit();
|
||||
|
||||
#define GUI_APP_MAIN \
|
||||
void GuiMainFn_();\
|
||||
|
|
@ -9,6 +11,7 @@ int main(int argc, const char **argv, const char **envptr) { \
|
|||
FBInit("/dev/fb0"); \
|
||||
GuiMainFn_(); \
|
||||
UPP::Ctrl::CloseTopCtrls(); \
|
||||
FBDeInit(); \
|
||||
UPP::UsrLog("---------- About to delete this log of LinuxFB..."); \
|
||||
UPP::DeleteUsrLog(); \
|
||||
return UPP::GetExitCode(); \
|
||||
|
|
@ -17,3 +20,4 @@ int main(int argc, const char **argv, const char **envptr) { \
|
|||
void GuiMainFn_()
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "LinuxFb.h"
|
||||
#include "LinuxFbLocal.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -16,6 +16,7 @@ NAMESPACE_UPP
|
|||
struct fb_fix_screeninfo finfo;
|
||||
long int screensize = 0;
|
||||
char *fbp = 0;
|
||||
bool fbEndSession = false;
|
||||
|
||||
//FIXME get input events
|
||||
bool GetShift() { return false; }//!!(GetKeyState(VK_SHIFT) & 0x8000); }
|
||||
|
|
@ -29,7 +30,7 @@ bool GetMouseMiddle() { return false; }//!!(GetKeyState(VK_MBUTTON) & 0x8000); }
|
|||
|
||||
bool FBEndSession()
|
||||
{
|
||||
return false;//fbEndSession;
|
||||
return fbEndSession;
|
||||
}
|
||||
|
||||
bool FBIsWaitingEvent()
|
||||
|
|
@ -60,48 +61,11 @@ void FBSleep(int ms)
|
|||
// MsgWaitForMultipleObjects(0, NULL, FALSE, ms, QS_ALLINPUT);
|
||||
}
|
||||
|
||||
void FBUpdate(const Vector<Rect>& inv)
|
||||
{
|
||||
// if(fbHWND)
|
||||
// for(int i = 0; i < inv.GetCount(); i++)
|
||||
// ::InvalidateRect(fbHWND, inv[i], false);
|
||||
|
||||
//FIXME direct paint
|
||||
//here currently just copy over
|
||||
/*
|
||||
int x = 0, y = 0;
|
||||
long int location = 0;
|
||||
x = 100; y = 100; // Where we are going to put the pixel
|
||||
|
||||
// Figure out where in memory to put the pixel
|
||||
for (y = 100; y < 300; y++)
|
||||
for (x = 100; x < 300; x++) {
|
||||
|
||||
location = (x+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +
|
||||
(y+vinfo.yoffset) * finfo.line_length;
|
||||
|
||||
if (vinfo.bits_per_pixel == 32) {
|
||||
*(fbp + location) = 100; // Some blue
|
||||
*(fbp + location + 1) = 15+(x-100)/2; // A little green
|
||||
*(fbp + location + 2) = 200-(y-100)/5; // A lot of red
|
||||
*(fbp + location + 3) = 0; // No transparency
|
||||
} else { //assume 16bpp
|
||||
int b = 10;
|
||||
int g = (x-100)/6; // A little green
|
||||
int r = 31-(y-100)/16; // A lot of red
|
||||
unsigned short int t = r<<11 | g << 5 | b;
|
||||
*((unsigned short int*)(fbp + location)) = t;
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
memcpy(fbp, (const char*)~framebuffer, framebuffer.GetLength() * sizeof(RGBA));
|
||||
}
|
||||
|
||||
void FBUpdate(const Rect& inv)
|
||||
{
|
||||
// if(fbHWND)
|
||||
// ::InvalidateRect(fbHWND, inv, false);
|
||||
const ImageBuffer& framebuffer = Ctrl::GetFrameBuffer();
|
||||
memcpy(fbp, (const char*)~framebuffer, framebuffer.GetLength() * sizeof(RGBA));
|
||||
}
|
||||
|
||||
|
|
@ -143,13 +107,13 @@ void FBInit(const String& fbdevice)
|
|||
}
|
||||
RLOG("The framebuffer device was mapped to memory successfully.\n");
|
||||
|
||||
//FIXME
|
||||
/*
|
||||
Ctrl::SetFramebufferSize(Size(vinfo.xres, vinfo.yres));
|
||||
}
|
||||
|
||||
void FBDeInit();
|
||||
{
|
||||
munmap(fbp, screensize);
|
||||
close(fbfd);
|
||||
*/
|
||||
|
||||
framebuffer.Create(vinfo.xres, vinfo.yres);
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -9,11 +9,14 @@ uses(WINFB) WinFb;
|
|||
|
||||
uses(LINUXFB) LinuxFb;
|
||||
|
||||
uses(SDLFB) SDLFb;
|
||||
|
||||
file
|
||||
Draw.cpp;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI WINFB",
|
||||
"" = "GUI LINUXFB",
|
||||
"" = "GUI WINGL";
|
||||
"" = "GUI WINGL",
|
||||
"" = "GUI SDLFB";
|
||||
|
||||
|
|
|
|||
|
|
@ -6,4 +6,5 @@
|
|||
#include "WinGl/init"
|
||||
#include "WinFb/init"
|
||||
#include "LinuxFb/init"
|
||||
#include "SDLFb/init"
|
||||
#endif
|
||||
|
|
|
|||
7
rainbow/SDLFb/After.h
Normal file
7
rainbow/SDLFb/After.h
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#ifndef _SDLFb_After_h_
|
||||
#define _SDLFb_After_h_
|
||||
|
||||
#include <Framebuffer/After.h>
|
||||
|
||||
|
||||
#endif
|
||||
113
rainbow/SDLFb/Keys.h
Normal file
113
rainbow/SDLFb/Keys.h
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
#ifndef _SDLFb_Keys_h_
|
||||
#define _SDLFb_Keys_h_
|
||||
K_BACK = SDLK_BACKSPACE + K_DELTA,
|
||||
K_BACKSPACE = SDLK_BACKSPACE + K_DELTA,
|
||||
|
||||
K_TAB = SDLK_TAB,
|
||||
|
||||
K_SPACE = SDLK_SPACE,
|
||||
|
||||
K_RETURN = SDLK_RETURN,
|
||||
K_ENTER = K_RETURN,
|
||||
|
||||
K_SHIFT_KEY = SDLK_LSHIFT + K_DELTA,
|
||||
K_CTRL_KEY = SDLK_LCTRL + K_DELTA,
|
||||
K_ALT_KEY = SDLK_LALT + K_DELTA,
|
||||
K_CAPSLOCK = SDLK_CAPSLOCK + K_DELTA,
|
||||
K_ESCAPE = SDLK_ESCAPE + K_DELTA,
|
||||
K_PRIOR = SDLK_PAGEUP + K_DELTA,
|
||||
K_PAGEUP = SDLK_PAGEUP + K_DELTA,
|
||||
K_NEXT = SDLK_PAGEDOWN + K_DELTA,
|
||||
K_PAGEDOWN = SDLK_PAGEDOWN + K_DELTA,
|
||||
K_END = SDLK_END + K_DELTA,
|
||||
K_HOME = SDLK_HOME + K_DELTA,
|
||||
K_LEFT = SDLK_LEFT + K_DELTA,
|
||||
K_UP = SDLK_UP + K_DELTA,
|
||||
K_RIGHT = SDLK_RIGHT + K_DELTA,
|
||||
K_DOWN = SDLK_DOWN + K_DELTA,
|
||||
K_INSERT = SDLK_INSERT + K_DELTA,
|
||||
K_DELETE = SDLK_DELETE + K_DELTA,
|
||||
|
||||
K_NUMPAD0 = SDLK_KP0 + K_DELTA,
|
||||
K_NUMPAD1 = SDLK_KP1 + K_DELTA,
|
||||
K_NUMPAD2 = SDLK_KP2 + K_DELTA,
|
||||
K_NUMPAD3 = SDLK_KP3 + K_DELTA,
|
||||
K_NUMPAD4 = SDLK_KP4 + K_DELTA,
|
||||
K_NUMPAD5 = SDLK_KP5 + K_DELTA,
|
||||
K_NUMPAD6 = SDLK_KP6 + K_DELTA,
|
||||
K_NUMPAD7 = SDLK_KP7 + K_DELTA,
|
||||
K_NUMPAD8 = SDLK_KP8 + K_DELTA,
|
||||
K_NUMPAD9 = SDLK_KP9 + K_DELTA,
|
||||
K_MULTIPLY = SDLK_KP_MULTIPLY + K_DELTA,
|
||||
K_ADD = SDLK_KP_PLUS + K_DELTA,
|
||||
K_SEPARATOR = SDLK_KP_PERIOD + K_DELTA,
|
||||
K_SUBTRACT = SDLK_KP_MINUS + K_DELTA,
|
||||
K_DECIMAL = SDLK_KP_PERIOD + K_DELTA,
|
||||
K_DIVIDE = SDLK_KP_DIVIDE + K_DELTA,
|
||||
K_SCROLL = SDLK_SCROLLOCK + K_DELTA,
|
||||
|
||||
K_F1 = SDLK_F1 + K_DELTA,
|
||||
K_F2 = SDLK_F2 + K_DELTA,
|
||||
K_F3 = SDLK_F3 + K_DELTA,
|
||||
K_F4 = SDLK_F4 + K_DELTA,
|
||||
K_F5 = SDLK_F5 + K_DELTA,
|
||||
K_F6 = SDLK_F6 + K_DELTA,
|
||||
K_F7 = SDLK_F7 + K_DELTA,
|
||||
K_F8 = SDLK_F8 + K_DELTA,
|
||||
K_F9 = SDLK_F9 + K_DELTA,
|
||||
K_F10 = SDLK_F10 + K_DELTA,
|
||||
K_F11 = SDLK_F11 + K_DELTA,
|
||||
K_F12 = SDLK_F12 + K_DELTA,
|
||||
|
||||
K_A = 'A' + K_DELTA,
|
||||
K_B = 'B' + K_DELTA,
|
||||
K_C = 'C' + K_DELTA,
|
||||
K_D = 'D' + K_DELTA,
|
||||
K_E = 'E' + K_DELTA,
|
||||
K_F = 'F' + K_DELTA,
|
||||
K_G = 'G' + K_DELTA,
|
||||
K_H = 'H' + K_DELTA,
|
||||
K_I = 'I' + K_DELTA,
|
||||
K_J = 'J' + K_DELTA,
|
||||
K_K = 'K' + K_DELTA,
|
||||
K_L = 'L' + K_DELTA,
|
||||
K_M = 'M' + K_DELTA,
|
||||
K_N = 'N' + K_DELTA,
|
||||
K_O = 'O' + K_DELTA,
|
||||
K_P = 'P' + K_DELTA,
|
||||
K_Q = 'Q' + K_DELTA,
|
||||
K_R = 'R' + K_DELTA,
|
||||
K_S = 'S' + K_DELTA,
|
||||
K_T = 'T' + K_DELTA,
|
||||
K_U = 'U' + K_DELTA,
|
||||
K_V = 'V' + K_DELTA,
|
||||
K_W = 'W' + K_DELTA,
|
||||
K_X = 'X' + K_DELTA,
|
||||
K_Y = 'Y' + K_DELTA,
|
||||
K_Z = 'Z' + K_DELTA,
|
||||
K_0 = '0' + K_DELTA,
|
||||
K_1 = '1' + K_DELTA,
|
||||
K_2 = '2' + K_DELTA,
|
||||
K_3 = '3' + K_DELTA,
|
||||
K_4 = '4' + K_DELTA,
|
||||
K_5 = '5' + K_DELTA,
|
||||
K_6 = '6' + K_DELTA,
|
||||
K_7 = '7' + K_DELTA,
|
||||
K_8 = '8' + K_DELTA,
|
||||
K_9 = '9' + K_DELTA,
|
||||
|
||||
K_CTRL_LBRACKET = K_CTRL|219|K_DELTA,
|
||||
K_CTRL_RBRACKET = K_CTRL|221|K_DELTA,
|
||||
K_CTRL_MINUS = K_CTRL|0xbd|K_DELTA,
|
||||
K_CTRL_GRAVE = K_CTRL|0xc0|K_DELTA,
|
||||
K_CTRL_SLASH = K_CTRL|0xbf|K_DELTA,
|
||||
K_CTRL_BACKSLASH = K_CTRL|0xdc|K_DELTA,
|
||||
K_CTRL_COMMA = K_CTRL|0xbc|K_DELTA,
|
||||
K_CTRL_PERIOD = K_CTRL|0xbe|K_DELTA,
|
||||
K_CTRL_SEMICOLON = K_CTRL|0xbe|K_DELTA,
|
||||
K_CTRL_EQUAL = K_CTRL|0xbb|K_DELTA,
|
||||
K_CTRL_APOSTROPHE= K_CTRL|0xde|K_DELTA,
|
||||
|
||||
K_BREAK = SDLK_BREAK + K_DELTA,
|
||||
|
||||
#endif
|
||||
45
rainbow/SDLFb/Local.h
Normal file
45
rainbow/SDLFb/Local.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#ifndef _SDLFb_Local_h_
|
||||
#define _SDLFb_Local_h_
|
||||
|
||||
void FBInit();
|
||||
void FBDeInit();
|
||||
|
||||
#ifdef PLATFORM_WIN32
|
||||
#define GUI_APP_MAIN \
|
||||
void GuiMainFn_(); \
|
||||
\
|
||||
extern "C" int main(int argc, char *argv[]) { \
|
||||
UPP::AppInit__(argc, (const char **)argv); \
|
||||
FBInit(); \
|
||||
GuiMainFn_(); \
|
||||
UPP::Ctrl::CloseTopCtrls(); \
|
||||
FBDeInit(); \
|
||||
UPP::UsrLog("---------- About to delete this log of SDLFB..."); \
|
||||
UPP::DeleteUsrLog(); \
|
||||
return UPP::GetExitCode(); \
|
||||
} \
|
||||
\
|
||||
void GuiMainFn_()
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_POSIX
|
||||
#define GUI_APP_MAIN \
|
||||
void GuiMainFn_(); \
|
||||
\
|
||||
extern "C" int main(int argc, const char **argv, const char **envptr) { \
|
||||
UPP::AppInit__(argc, argv, envptr); \
|
||||
FBInit(); \
|
||||
GuiMainFn_(); \
|
||||
UPP::Ctrl::CloseTopCtrls(); \
|
||||
FBDeInit(); \
|
||||
UPP::UsrLog("---------- About to delete this log of SDLFB..."); \
|
||||
UPP::DeleteUsrLog(); \
|
||||
return UPP::GetExitCode(); \
|
||||
} \
|
||||
\
|
||||
void GuiMainFn_()
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
49
rainbow/SDLFb/Proc.cpp
Normal file
49
rainbow/SDLFb/Proc.cpp
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
#include "SDLFbLocal.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) LOG(x)
|
||||
|
||||
//GetModState ??
|
||||
bool GetShift() { uint8* ka = SDL_GetKeyState(NULL); return ka[SDLK_LSHIFT] || ka[SDLK_RSHIFT]; }
|
||||
bool GetCtrl() { uint8* ka = SDL_GetKeyState(NULL); return ka[SDLK_LCTRL] || ka[SDLK_RCTRL]; }
|
||||
bool GetAlt() { uint8* ka = SDL_GetKeyState(NULL); return ka[SDLK_LALT] || ka[SDLK_RALT]; }
|
||||
bool GetCapsLock() { uint8* ka = SDL_GetKeyState(NULL); return ka[SDLK_CAPSLOCK]; }
|
||||
bool GetMouseLeft() { return (SDL_GetMouseState(NULL,NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)); }
|
||||
bool GetMouseRight() { return (SDL_GetMouseState(NULL,NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)); }
|
||||
bool GetMouseMiddle() { return (SDL_GetMouseState(NULL,NULL) & SDL_BUTTON(SDL_BUTTON_MIDDLE)); }
|
||||
|
||||
dword fbKEYtoK(dword chr) {
|
||||
if(chr == SDLK_TAB)
|
||||
chr = K_TAB;
|
||||
else
|
||||
if(chr == SDLK_SPACE)
|
||||
chr = K_SPACE;
|
||||
else
|
||||
if(chr == SDLK_RETURN)
|
||||
chr = K_RETURN;
|
||||
else
|
||||
chr = chr + K_DELTA;
|
||||
if(chr == K_ALT_KEY || chr == K_CTRL_KEY || chr == K_SHIFT_KEY)
|
||||
return chr;
|
||||
if(GetCtrl()) chr |= K_CTRL;
|
||||
if(GetAlt()) chr |= K_ALT;
|
||||
if(GetShift()) chr |= K_SHIFT;
|
||||
return chr;
|
||||
}
|
||||
|
||||
void HandleUserEvents(SDL_Event* event)
|
||||
{
|
||||
/*
|
||||
switch (event->user.code) {
|
||||
case RUN_GAME_LOOP:
|
||||
GameLoop();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
9
rainbow/SDLFb/SDLFb.h
Normal file
9
rainbow/SDLFb/SDLFb.h
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#ifndef _SDLFb_SDLFb_h_
|
||||
#define _SDLFb_SDLFb_h_
|
||||
|
||||
#include <Framebuffer/Framebuffer.h>
|
||||
|
||||
//make keysym known to K_ enum in CtrlCore.h
|
||||
#include "SDLWrap.h"
|
||||
|
||||
#endif
|
||||
21
rainbow/SDLFb/SDLFb.upp
Normal file
21
rainbow/SDLFb/SDLFb.upp
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
library(MSC) "SDL SDLmain";
|
||||
|
||||
library(GCC WIN32 !SHARED) "SDL.dll SDLmain mingw32";
|
||||
|
||||
library(GCC WIN32 SHARED) "SDL SDLmain mingw32";
|
||||
|
||||
library(LINUX) "SDL SDLmain";
|
||||
|
||||
library(FREEBSD) "SDL SDLmain X11 Xext Xrandr Xrender vga vgl aa usbhid ncurses";
|
||||
|
||||
link(MSC DEBUG) /NODEFAULTLIB:msvcrt.lib;
|
||||
|
||||
file
|
||||
SDLWrap.h,
|
||||
SDLFb.h,
|
||||
SDLFbLocal.h,
|
||||
Local.h,
|
||||
Keys.h,
|
||||
Win.cpp,
|
||||
Proc.cpp;
|
||||
|
||||
17
rainbow/SDLFb/SDLFbLocal.h
Normal file
17
rainbow/SDLFb/SDLFbLocal.h
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#ifndef _SDLFb_SDLFbLocal_h
|
||||
#define _SDLFb_SDLFbLocal_h
|
||||
|
||||
#include <CtrlCore/CtrlCore.h>
|
||||
|
||||
//has to go second
|
||||
#include "SDLWrap.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
extern bool fbEndSession;
|
||||
void HandleUserEvents(SDL_Event* event);
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
||||
11
rainbow/SDLFb/SDLWrap.h
Normal file
11
rainbow/SDLFb/SDLWrap.h
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef _SDLFb_SDLWrap_h_
|
||||
#define _SDLFb_SDLWrap_h_
|
||||
|
||||
#ifdef COMPILER_MSC
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
#ifdef COMPILER_GCC
|
||||
#include <SDL/SDL.h>
|
||||
#endif
|
||||
|
||||
#endif
|
||||
208
rainbow/SDLFb/Win.cpp
Normal file
208
rainbow/SDLFb/Win.cpp
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
#include "SDLFbLocal.h"
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
dword fbKEYtoK(dword chr);
|
||||
|
||||
SDL_Surface * screen = NULL;
|
||||
bool fbEndSession = false;
|
||||
int videoflags = 0;
|
||||
int height = 0;
|
||||
int width = 0;
|
||||
int bpp = 0;
|
||||
|
||||
SDL_Surface *CreateScreen(int w, int h, int bpp, int flags)
|
||||
{
|
||||
SDL_Surface * screen = SDL_SetVideoMode(w, h, bpp, flags);
|
||||
if(!screen)
|
||||
{
|
||||
Cout() << Format("Couldn't set display mode: %s\n", SDL_GetError());
|
||||
return NULL;
|
||||
}
|
||||
Cout() << Format("Screen is in %s mode\n", (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed");
|
||||
return screen;
|
||||
}
|
||||
|
||||
bool FBEndSession()
|
||||
{
|
||||
return fbEndSession;
|
||||
}
|
||||
|
||||
bool FBIsWaitingEvent()
|
||||
{
|
||||
SDL_PumpEvents();
|
||||
SDL_Event events;
|
||||
int tc = SDL_PeepEvents(&events, 1, SDL_PEEKEVENT, SDL_EVENTMASK(SDL_ALLEVENTS));
|
||||
return (tc>0);
|
||||
}
|
||||
|
||||
bool FBProcessEvent(bool *quit)
|
||||
{
|
||||
SDL_Event event;
|
||||
if(SDL_PollEvent(&event)) {
|
||||
switch(event.type) {
|
||||
case SDL_ACTIVEEVENT: //SDL_ActiveEvent
|
||||
break;
|
||||
case SDL_KEYDOWN:
|
||||
case SDL_KEYUP: //SDL_KeyboardEvent
|
||||
{
|
||||
String msgdump;
|
||||
switch(event.type)
|
||||
{
|
||||
case SDL_KEYDOWN: msgdump << "SDL_KEYDOWN"; break;
|
||||
case SDL_KEYUP: msgdump << "SDL_KEYUP"; break;
|
||||
}
|
||||
// msgdump << " wParam = 0x" << FormatIntHex(wParam, 8)
|
||||
// << ", lParam = 0x" << FormatIntHex(lParam, 8);
|
||||
msgdump << (int)event.key.keysym.sym;
|
||||
RLOG(msgdump);
|
||||
|
||||
bool b = false;
|
||||
dword keycode = 0;
|
||||
if(event.type == SDL_KEYDOWN) {
|
||||
keycode = fbKEYtoK((dword)event.key.keysym.sym);
|
||||
if(keycode != K_SPACE) //dont send space on keydown
|
||||
b = Ctrl::DoKeyFB(keycode, 1);
|
||||
|
||||
//send respective keyup things as char events as well
|
||||
keycode = (dword)event.key.keysym.unicode;
|
||||
if((keycode != 127 && keycode > 32 && keycode < 255)
|
||||
|| (keycode == 32 && fbKEYtoK(SDLK_SPACE) == K_SPACE))
|
||||
b = Ctrl::DoKeyFB(keycode, 1);
|
||||
|
||||
}
|
||||
else
|
||||
if(event.type == SDL_KEYUP)
|
||||
{
|
||||
keycode = fbKEYtoK((dword)event.key.keysym.sym) | K_KEYUP;
|
||||
b = Ctrl::DoKeyFB(keycode, 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEMOTION: //SDL_MouseMotionEvent
|
||||
Ctrl::DoMouseFB(Ctrl::MOUSEMOVE, Point(event.motion.x, event.motion.y));
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN: //SDL_MouseButtonEvent, FIXME DoubleClick
|
||||
{
|
||||
Point p(event.button.x, event.button.y);
|
||||
switch(event.button.button)
|
||||
{
|
||||
case SDL_BUTTON_LEFT: Ctrl::DoMouseFB(Ctrl::LEFTDOWN, p); break;
|
||||
case SDL_BUTTON_RIGHT: Ctrl::DoMouseFB(Ctrl::RIGHTDOWN, p); break;
|
||||
case SDL_BUTTON_MIDDLE: Ctrl::DoMouseFB(Ctrl::MIDDLEDOWN, p); break;
|
||||
case SDL_BUTTON_WHEELUP: Ctrl::DoMouseFB(Ctrl::MOUSEWHEEL, p, +120); break;
|
||||
case SDL_BUTTON_WHEELDOWN: Ctrl::DoMouseFB(Ctrl::MOUSEWHEEL, p, -120); break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
{
|
||||
Point p(event.button.x, event.button.y);
|
||||
switch(event.button.button)
|
||||
{
|
||||
case SDL_BUTTON_LEFT: Ctrl::DoMouseFB(Ctrl::LEFTUP, p); break;
|
||||
case SDL_BUTTON_RIGHT: Ctrl::DoMouseFB(Ctrl::RIGHTUP, p); break;
|
||||
case SDL_BUTTON_MIDDLE: Ctrl::DoMouseFB(Ctrl::MIDDLEUP, p); break;
|
||||
case SDL_BUTTON_WHEELUP: Ctrl::DoMouseFB(Ctrl::MOUSEWHEEL, p, +120); break;
|
||||
case SDL_BUTTON_WHEELDOWN: Ctrl::DoMouseFB(Ctrl::MOUSEWHEEL, p, -120); break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SDL_JOYAXISMOTION: //SDL_JoyAxisEvent
|
||||
break;
|
||||
case SDL_JOYBALLMOTION: //SDL_JoyBallEvent
|
||||
break;
|
||||
case SDL_JOYHATMOTION: //SDL_JoyHatEvent
|
||||
break;
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
case SDL_JOYBUTTONUP: //SDL_JoyButtonEvent
|
||||
break;
|
||||
case SDL_VIDEORESIZE: //SDL_ResizeEvent
|
||||
{
|
||||
width = event.resize.w;
|
||||
height = event.resize.h;
|
||||
|
||||
SDL_FreeSurface(screen);
|
||||
screen = CreateScreen(width, height, bpp, videoflags);
|
||||
ASSERT(screen);
|
||||
Ctrl::SetFramebufferSize(Size(width, height));
|
||||
}
|
||||
break;
|
||||
case SDL_VIDEOEXPOSE: //SDL_ExposeEvent
|
||||
break;
|
||||
case SDL_QUIT: //SDL_QuitEvent
|
||||
if(quit) *quit = true;
|
||||
break;
|
||||
case SDL_USEREVENT: //SDL_UserEvent
|
||||
HandleUserEvents(&event);
|
||||
break;
|
||||
case SDL_SYSWMEVENT: //SDL_SysWMEvent
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
} // End switch
|
||||
return true;
|
||||
} // End while
|
||||
return false;
|
||||
}
|
||||
|
||||
void FBSleep(int ms)
|
||||
{
|
||||
Sleep(ms); //sleep should be wakeable with input
|
||||
}
|
||||
|
||||
void FBUpdate(const Rect& inv)
|
||||
{
|
||||
//The invalidated areas accumulate in the update region until the region is processed when the next WM_PAINT message occurs
|
||||
SDL_LockSurface(screen);
|
||||
|
||||
const ImageBuffer& framebuffer = Ctrl::GetFrameBuffer();
|
||||
|
||||
memcpy(screen->pixels, (const char*)~framebuffer, framebuffer.GetLength() * sizeof(RGBA));
|
||||
SDL_UnlockSurface(screen);
|
||||
SDL_Flip(screen);
|
||||
}
|
||||
|
||||
void FBInit()
|
||||
{
|
||||
GuiLock __;
|
||||
|
||||
Ctrl::InitFB();
|
||||
|
||||
if(SDL_Init(SDL_INIT_VIDEO) < 0)
|
||||
{
|
||||
Cout() << Format("Couldn't initialize SDL: %s\n", SDL_GetError());
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_EnableUNICODE(1);
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL/2);
|
||||
|
||||
const SDL_VideoInfo* vi = SDL_GetVideoInfo();
|
||||
//ASSERT(vi->hw_available);
|
||||
|
||||
width = vi->current_w;
|
||||
height = vi->current_h;
|
||||
//width = 600;
|
||||
//height = 400;
|
||||
bpp = vi->vfmt->BitsPerPixel;
|
||||
ASSERT(bpp == 32);
|
||||
|
||||
//FIXME adjustable
|
||||
videoflags = SDL_HWSURFACE | SDL_HWACCEL | SDL_DOUBLEBUF | SDL_RESIZABLE;// | SDL_NOFRAME | SDL_FULLSCREEN;
|
||||
|
||||
screen = CreateScreen(width, height, bpp, videoflags);
|
||||
ASSERT(screen);
|
||||
Ctrl::SetFramebufferSize(Size(width, height));
|
||||
|
||||
// Csizeinit();
|
||||
}
|
||||
|
||||
void FBDeInit()
|
||||
{
|
||||
SDL_FreeSurface(screen);
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
3
rainbow/SDLFb/init
Normal file
3
rainbow/SDLFb/init
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#ifndef _SDLFb_icpp_init_stub
|
||||
#define _SDLFb_icpp_init_stub
|
||||
#endif
|
||||
|
|
@ -19,9 +19,11 @@ Image MakeDragImage(const Image& arrow, Image sample);
|
|||
|
||||
Image MakeDragImage(const Image& arrow, const Image& arrow98, Image sample)
|
||||
{
|
||||
#ifdef PLATFORM_WIN32
|
||||
if(IsWin2K())
|
||||
return MakeDragImage(arrow, sample);
|
||||
else
|
||||
#endif
|
||||
return arrow98;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,6 +69,12 @@ void SystemDraw::DrawLineOp(int x1, int y1, int x2, int y2, int width, Color col
|
|||
GuiLock __;
|
||||
}
|
||||
|
||||
void SystemDraw::DrawImageOp(int x, int y, int cx, int cy, const Image& img, const Rect& src, Color color)
|
||||
{
|
||||
GuiLock __;
|
||||
StdDrawImage(*this, x, y, cx, cy, img, src, color);
|
||||
}
|
||||
|
||||
void SystemDraw::DrawPolyPolylineOp(const Point *vertices, int vertex_count,
|
||||
const int *counts, int count_count,
|
||||
int width, Color color, Color doxor)
|
||||
|
|
|
|||
|
|
@ -59,6 +59,15 @@ Image ImageDraw::GetStraight() const
|
|||
return Image();
|
||||
}
|
||||
|
||||
Draw& ImageDraw::Alpha()
|
||||
{
|
||||
if(!has_alpha) {
|
||||
alpha.DrawRect(size, GrayColor(0));
|
||||
has_alpha = true;
|
||||
}
|
||||
return alpha;
|
||||
}
|
||||
|
||||
ImageDraw::ImageDraw(Size sz)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,9 +4,15 @@ uses
|
|||
CtrlLib,
|
||||
RichEdit,
|
||||
PdfDraw,
|
||||
plugin\jpg,
|
||||
Skeleton,
|
||||
WinFb;
|
||||
plugin\jpg;
|
||||
|
||||
uses(WINFB) Framebuffer;
|
||||
|
||||
uses(SKELETON) Skeleton;
|
||||
|
||||
uses(WINFB) WinFb;
|
||||
|
||||
uses(WINALT) WinAlt;
|
||||
|
||||
file
|
||||
UWord.cpp,
|
||||
|
|
@ -14,5 +20,6 @@ file
|
|||
|
||||
mainconfig
|
||||
"" = "GUI WINFB",
|
||||
"" = "GUI WINALT",
|
||||
"" = "GUI SKELETON";
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include "RichEdit/init"
|
||||
#include "PdfDraw/init"
|
||||
#include "plugin\jpg/init"
|
||||
#include "Framebuffer/init"
|
||||
#include "Skeleton/init"
|
||||
#include "WinFb/init"
|
||||
#include "WinAlt/init"
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
NAMESPACE_UPP
|
||||
|
||||
HWND fbHWND;
|
||||
bool fbEndSession;
|
||||
bool fbEndSession = false;
|
||||
|
||||
bool FBEndSession()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
#ifndef _WinFb_WinFb_h
|
||||
#define _WinFb_WinFb_h
|
||||
|
||||
#include <CtrlCore/CtrlCore.h>
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
|
@ -9,4 +12,4 @@ void fbUpdate(HDC hdc, const Rect& r);
|
|||
|
||||
END_UPP_NAMESPACE
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -14,10 +14,17 @@
|
|||
|
||||
#ifdef flagLINUXFB
|
||||
#define GUIPLATFORM_KEYCODES_INCLUDE <LinuxFb/Keys.h>
|
||||
#define GUIPLATFORM_INCLUDE <Framebuffer/Framebuffer.h>
|
||||
#define GUIPLATFORM_INCLUDE <LinuxFb/LinuxFb.h>
|
||||
#define FRAMEBUFFER_INCLUDE <LinuxFb/Local.h>
|
||||
#endif
|
||||
|
||||
#ifdef flagSDLFB
|
||||
#define GUIPLATFORM_KEYCODES_INCLUDE <SDLFb/Keys.h>
|
||||
//need to make SDL_keysym.h known before K_ enum
|
||||
#define GUIPLATFORM_INCLUDE <SDLFb/SDLFb.h>
|
||||
#define FRAMEBUFFER_INCLUDE <SDLFb/Local.h>
|
||||
#endif
|
||||
|
||||
#ifdef flagWINGL
|
||||
#define GUIPLATFORM_INCLUDE <WinGl/WinGl.h>
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue