[Add] Implemented Input decices.

This commit is contained in:
Rtch90 2012-04-08 18:16:35 +01:00
parent a277545963
commit 60366c7ad0
7 changed files with 247 additions and 236 deletions

View File

@ -31,6 +31,9 @@ bool CreateInput(void) {
memcpy(keyboard.keys, tempKeys, sizeof(char) * keyboard.keycount);
mouse.buttons = SDL_GetMouseState(&mouse.dx, &mouse.dy);
if(&keyboard > 0 || &mouse > 0){
Debug::logger->message("Input device registered");
}
return true;
}
@ -79,4 +82,5 @@ bool MouseStillUp(int button) { return(!_curr_mouse(button) && !_old_mouse(b
void DestroyInput(void) {
free(keyboard.keys);
free(keyboard.oldKeys);
Debug::logger->message("Input device destroyed");
}

View File

@ -1,6 +1,8 @@
#pragma once
#include <SDL/SDL.h>
#include "../System/Debug.h"
typedef struct mouse_s {
int dx, dy;
int oldx, oldy;

View File

@ -6,9 +6,9 @@
#include <GL/glu.h>
#include "../System/Debug.h"
#include "Game.h"
#include "../Sprite/Sprite.h"
#include "../Texture/Texture.h"
#include "Game.h"
Game::Game(void) {
_rotationAngle = 0.0f;
@ -57,6 +57,7 @@ void Game::Render(void) {
}
void Game::Shutdown(void) {
Debug::logger->message("\n ----- Cleaning Engine -----");
delete _testSprite->GetTexture();
delete _testSprite;
}

View File

@ -1,4 +1,5 @@
#pragma once
#include "../IO/Input.h"
class Sprite;

View File

@ -36,7 +36,7 @@ LGLXWindow::LGLXWindow(void) :
_height(0),
_bpp(0),
_GL3Supported(false)
{}
{ CreateInput(); }
LGLXWindow::~LGLXWindow(void) {
@ -188,7 +188,7 @@ void LGLXWindow::Destroy(void) {
XF86VidModeSwitchToMode(_display, _screenID, &_XF86DeskMode);
XF86VidModeSetViewPort(_display, _screenID, 0, 0);
}
DestroyInput();
XCloseDisplay(_display);
}
@ -219,6 +219,9 @@ void LGLXWindow::ProcessEvents(void) {
break;
case KeyRelease:
{
if(KeyStillUp(SDLK_SPACE)) {
Debug::logger->message("Testing Input!");
}
// Code here NAW!
}
break;
@ -239,4 +242,3 @@ float LGLXWindow::GetElapsedSeconds(void) {
_lastTime = currentTime;
return float(diff) / 1000.0f;
}

View File

@ -35,6 +35,8 @@ private:
// Check to see if the window is still running FFS.
bool _isRunning;
keyboard_t keyboard;
Game* GetAttachedGame(void) { return _game; }
unsigned int _lastTime;

View File

@ -69,8 +69,7 @@ int main(int argc, char** argv) {
programWindow.SwapBuffers();
}
game.Shutdown(); // Free any resouces.
Debug::closeLog();
programWindow.Destroy(); // Destroy the program window.
Debug::closeLog();
return 0;
}