mirror of
https://github.com/glest/glest-source.git
synced 2025-02-24 11:42:31 +01:00
A few changes to allow for better keyboard state detection
This commit is contained in:
parent
198d2aeb98
commit
02d0781b40
@ -25,6 +25,7 @@
|
||||
#include "network_interface.h"
|
||||
#include "sound_renderer.h"
|
||||
#include "ImageReaders.h"
|
||||
#include "renderer.h"
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
@ -199,7 +200,23 @@ void MainWindow::eventMouseWheel(int x, int y, int zDelta) {
|
||||
}
|
||||
|
||||
void MainWindow::eventKeyDown(char key){
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c][%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
||||
program->keyDown(key);
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(key == vkReturn) {
|
||||
SDL_keysym keystate = Window::getKeystate();
|
||||
if(keystate.mod & (KMOD_LALT | KMOD_RALT)) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ALT-ENTER pressed\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//Renderer &renderer= Renderer::getInstance();
|
||||
//renderer.reloadResources();
|
||||
//renderer.init();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::eventKeyUp(char key){
|
||||
|
@ -113,6 +113,7 @@ private:
|
||||
static Vec2i mousePos;
|
||||
static bool isKeyPressedDown;
|
||||
static bool isFullScreen;
|
||||
static SDL_keysym keystate;
|
||||
|
||||
static void setLastMouseEvent(unsigned int lastMouseEvent) {Window::lastMouseEvent = lastMouseEvent;}
|
||||
static unsigned int getLastMouseEvent() {return Window::lastMouseEvent;}
|
||||
@ -123,6 +124,8 @@ private:
|
||||
static const Vec2i &getMousePos() {return Window::mousePos;}
|
||||
static void setMousePos(const Vec2i &mousePos) {Window::mousePos = mousePos;}
|
||||
|
||||
static void setKeystate(SDL_keysym state) { keystate = state; }
|
||||
|
||||
protected:
|
||||
int w, h;
|
||||
|
||||
@ -133,6 +136,7 @@ public:
|
||||
static void setupGraphicsScreen(int depthBits=-1, int stencilBits=-1);
|
||||
static const bool getIsFullScreen() { return isFullScreen; }
|
||||
static void setIsFullScreen(bool value) { isFullScreen = value; }
|
||||
static SDL_keysym getKeystate() { return keystate; }
|
||||
|
||||
Window();
|
||||
virtual ~Window();
|
||||
|
@ -118,12 +118,19 @@ void createGlFontBitmaps(uint32 &base, const string &type, int size, int width,
|
||||
int p = i - fontInfo->min_char_or_byte2;
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] p = %d fontInfo->per_char = %p\n",__FILE__,__FUNCTION__,__LINE__,p,fontInfo->per_char);
|
||||
if(fontInfo->per_char == NULL) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] type = [%s] p = %d fontInfo->per_char = %p\n",__FILE__,__FUNCTION__,__LINE__,type.c_str(),p,fontInfo->per_char);
|
||||
|
||||
XCharStruct *charinfo = &(fontInfo->min_bounds);
|
||||
int charWidth = charinfo->rbearing - charinfo->lbearing;
|
||||
//int charWidth = charinfo->rbearing - charinfo->lbearing;
|
||||
//int charHeight = charinfo->ascent + charinfo->descent;
|
||||
//int spanLength = (charWidth + 7) / 8;
|
||||
|
||||
metrics.setWidth(i, static_cast<float> (charWidth));
|
||||
if(charinfo != NULL) {
|
||||
metrics.setWidth(i, static_cast<float> (charinfo->width));
|
||||
}
|
||||
else {
|
||||
metrics.setWidth(i, static_cast<float>(6));
|
||||
}
|
||||
}
|
||||
else {
|
||||
metrics.setWidth(i, static_cast<float> (
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "sdl_private.h"
|
||||
#include "noimpl.h"
|
||||
#include "util.h"
|
||||
#include "SDL_syswm.h"
|
||||
#include "SDL_syswm.h"
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace Shared::Util;
|
||||
@ -40,6 +40,7 @@ Vec2i Window::mousePos;
|
||||
MouseState Window::mouseState;
|
||||
bool Window::isKeyPressedDown = false;
|
||||
bool Window::isFullScreen = false;
|
||||
SDL_keysym Window::keystate;
|
||||
|
||||
// ========== PUBLIC ==========
|
||||
|
||||
@ -118,6 +119,7 @@ bool Window::handleEvent() {
|
||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Window::isKeyPressedDown = true;
|
||||
keystate = event.key.keysym;
|
||||
/* handle ALT+Return */
|
||||
if(event.key.keysym.sym == SDLK_RETURN
|
||||
&& (event.key.keysym.mod & (KMOD_LALT | KMOD_RALT))) {
|
||||
@ -125,6 +127,7 @@ bool Window::handleEvent() {
|
||||
toggleFullscreen();
|
||||
}
|
||||
if(global_window) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
global_window->eventKeyDown(getKey(event.key.keysym));
|
||||
global_window->eventKeyPress(static_cast<char>(event.key.keysym.unicode));
|
||||
}
|
||||
@ -133,6 +136,7 @@ bool Window::handleEvent() {
|
||||
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Window::isKeyPressedDown = false;
|
||||
keystate = event.key.keysym;
|
||||
|
||||
if(global_window) {
|
||||
global_window->eventKeyUp(getKey(event.key.keysym));
|
||||
|
Loading…
x
Reference in New Issue
Block a user