[Add] Implemented Input decices.
This commit is contained in:
parent
a277545963
commit
60366c7ad0
@ -31,6 +31,9 @@ bool CreateInput(void) {
|
|||||||
|
|
||||||
memcpy(keyboard.keys, tempKeys, sizeof(char) * keyboard.keycount);
|
memcpy(keyboard.keys, tempKeys, sizeof(char) * keyboard.keycount);
|
||||||
mouse.buttons = SDL_GetMouseState(&mouse.dx, &mouse.dy);
|
mouse.buttons = SDL_GetMouseState(&mouse.dx, &mouse.dy);
|
||||||
|
if(&keyboard > 0 || &mouse > 0){
|
||||||
|
Debug::logger->message("Input device registered");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,4 +82,5 @@ bool MouseStillUp(int button) { return(!_curr_mouse(button) && !_old_mouse(b
|
|||||||
void DestroyInput(void) {
|
void DestroyInput(void) {
|
||||||
free(keyboard.keys);
|
free(keyboard.keys);
|
||||||
free(keyboard.oldKeys);
|
free(keyboard.oldKeys);
|
||||||
|
Debug::logger->message("Input device destroyed");
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
|
|
||||||
|
#include "../System/Debug.h"
|
||||||
|
|
||||||
typedef struct mouse_s {
|
typedef struct mouse_s {
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
int oldx, oldy;
|
int oldx, oldy;
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
|
|
||||||
#include "../System/Debug.h"
|
#include "../System/Debug.h"
|
||||||
#include "Game.h"
|
|
||||||
#include "../Sprite/Sprite.h"
|
#include "../Sprite/Sprite.h"
|
||||||
#include "../Texture/Texture.h"
|
#include "../Texture/Texture.h"
|
||||||
|
#include "Game.h"
|
||||||
|
|
||||||
Game::Game(void) {
|
Game::Game(void) {
|
||||||
_rotationAngle = 0.0f;
|
_rotationAngle = 0.0f;
|
||||||
@ -57,6 +57,7 @@ void Game::Render(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Game::Shutdown(void) {
|
void Game::Shutdown(void) {
|
||||||
|
Debug::logger->message("\n ----- Cleaning Engine -----");
|
||||||
delete _testSprite->GetTexture();
|
delete _testSprite->GetTexture();
|
||||||
delete _testSprite;
|
delete _testSprite;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include "../IO/Input.h"
|
||||||
|
|
||||||
class Sprite;
|
class Sprite;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ LGLXWindow::LGLXWindow(void) :
|
|||||||
_height(0),
|
_height(0),
|
||||||
_bpp(0),
|
_bpp(0),
|
||||||
_GL3Supported(false)
|
_GL3Supported(false)
|
||||||
{}
|
{ CreateInput(); }
|
||||||
|
|
||||||
LGLXWindow::~LGLXWindow(void) {
|
LGLXWindow::~LGLXWindow(void) {
|
||||||
|
|
||||||
@ -188,7 +188,7 @@ void LGLXWindow::Destroy(void) {
|
|||||||
XF86VidModeSwitchToMode(_display, _screenID, &_XF86DeskMode);
|
XF86VidModeSwitchToMode(_display, _screenID, &_XF86DeskMode);
|
||||||
XF86VidModeSetViewPort(_display, _screenID, 0, 0);
|
XF86VidModeSetViewPort(_display, _screenID, 0, 0);
|
||||||
}
|
}
|
||||||
|
DestroyInput();
|
||||||
XCloseDisplay(_display);
|
XCloseDisplay(_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,6 +219,9 @@ void LGLXWindow::ProcessEvents(void) {
|
|||||||
break;
|
break;
|
||||||
case KeyRelease:
|
case KeyRelease:
|
||||||
{
|
{
|
||||||
|
if(KeyStillUp(SDLK_SPACE)) {
|
||||||
|
Debug::logger->message("Testing Input!");
|
||||||
|
}
|
||||||
// Code here NAW!
|
// Code here NAW!
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -239,4 +242,3 @@ float LGLXWindow::GetElapsedSeconds(void) {
|
|||||||
_lastTime = currentTime;
|
_lastTime = currentTime;
|
||||||
return float(diff) / 1000.0f;
|
return float(diff) / 1000.0f;
|
||||||
}
|
}
|
||||||
|
|
@ -35,6 +35,8 @@ private:
|
|||||||
// Check to see if the window is still running FFS.
|
// Check to see if the window is still running FFS.
|
||||||
bool _isRunning;
|
bool _isRunning;
|
||||||
|
|
||||||
|
keyboard_t keyboard;
|
||||||
|
|
||||||
Game* GetAttachedGame(void) { return _game; }
|
Game* GetAttachedGame(void) { return _game; }
|
||||||
|
|
||||||
unsigned int _lastTime;
|
unsigned int _lastTime;
|
||||||
|
@ -69,8 +69,7 @@ int main(int argc, char** argv) {
|
|||||||
programWindow.SwapBuffers();
|
programWindow.SwapBuffers();
|
||||||
}
|
}
|
||||||
game.Shutdown(); // Free any resouces.
|
game.Shutdown(); // Free any resouces.
|
||||||
Debug::closeLog();
|
|
||||||
programWindow.Destroy(); // Destroy the program window.
|
programWindow.Destroy(); // Destroy the program window.
|
||||||
|
Debug::closeLog();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user