InputService stub
This commit is contained in:
@@ -245,6 +245,9 @@
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl">
|
||||
<File
|
||||
RelativePath=".\src\include\AbstractedInput.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\include\Application.h">
|
||||
</File>
|
||||
@@ -529,6 +532,9 @@
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV3\GroupInstance.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV3\InputService.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\source\DataModelV3\Instance.cpp">
|
||||
</File>
|
||||
|
||||
8
src/include/AbstractedInput.h
Normal file
8
src/include/AbstractedInput.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
namespace B3D{
|
||||
namespace AbstractedInput{
|
||||
static const unsigned char MOUSE_LEFT = 0x01;
|
||||
static const unsigned char MOUSE_RIGHT = 0x02;
|
||||
static const unsigned char MOUSE_MIDDLE = 0x03;
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ class CameraController;
|
||||
class Application { // : public GApp {
|
||||
public:
|
||||
Application(HWND parentWindow);
|
||||
void Boop();
|
||||
virtual ~Application() {}
|
||||
virtual void exitApplication();
|
||||
virtual void onInit();
|
||||
@@ -72,13 +71,15 @@ class Application { // : public GApp {
|
||||
HWND _hwndToolbox;
|
||||
HWND _buttonTest;
|
||||
HWND _hwndRenderer;
|
||||
//TODO make list
|
||||
DataModelInstance* _dataModel;
|
||||
G3D::TextureRef shadowMap;
|
||||
std::string _title;
|
||||
//TODO deprecated?
|
||||
bool _dragging;
|
||||
//TODO deprecated
|
||||
int _mode;
|
||||
//Can be moved?
|
||||
GAppSettings _settings;
|
||||
double lightProjX, lightProjY, lightProjNear, lightProjFar;
|
||||
IEBrowser* webBrowser;
|
||||
protected:
|
||||
Stopwatch m_graphicsWatch;
|
||||
|
||||
@@ -1,18 +1,46 @@
|
||||
//Should potentially make a "Service" class
|
||||
#pragma once
|
||||
#include "Instance.h"
|
||||
#include "PartInstance.h"
|
||||
|
||||
namespace B3D{
|
||||
|
||||
struct MousePoint{
|
||||
Vector3 position;
|
||||
B3D::PartInstance * target;
|
||||
MousePoint(Vector3 pos, PartInstance * targ)
|
||||
{
|
||||
position = pos;
|
||||
target = targ;
|
||||
}
|
||||
};
|
||||
|
||||
class InputService : public Instance{
|
||||
public:
|
||||
InputService(void);
|
||||
InputService~(void);
|
||||
bool pollKeyState(char keyChar);
|
||||
~InputService(void);
|
||||
|
||||
//Polling
|
||||
int pollKeyState(unsigned char keyCode);
|
||||
int pollMouseX();
|
||||
int pollMouseY();
|
||||
bool pollMouseButton(int button);
|
||||
int pollMouseButton(unsigned char button);
|
||||
bool pollFocus();
|
||||
|
||||
|
||||
//Update Input
|
||||
void updateMouse(int x, int y);
|
||||
void updateFocus(bool focus);
|
||||
|
||||
//Signal
|
||||
void signalKeyState(unsigned char keyCode, bool isDown);
|
||||
void signalMouseButtonState(unsigned char button, bool isDown);
|
||||
void signalMouseWheelState(int step);
|
||||
|
||||
|
||||
private:
|
||||
int mouseX, mouseY;
|
||||
|
||||
}
|
||||
Ray lastRay;
|
||||
bool hasFocus;
|
||||
};
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
//TODO holy shit
|
||||
#include <G3DAll.h>
|
||||
#include <initguid.h>
|
||||
#include <iomanip>
|
||||
@@ -30,12 +31,6 @@
|
||||
#include "Faces.h"
|
||||
#define LEGACY_LOAD_G3DFUN_LEVEL
|
||||
|
||||
static bool mouseMovedBeginMotion = false;
|
||||
static POINT oldGlobalMouse;
|
||||
Vector2 oldMouse = Vector2(0,0);
|
||||
float moveRate = 0.5;
|
||||
float wasPropShown = 0;
|
||||
|
||||
using namespace B3D;
|
||||
|
||||
void Application::clearInstances()
|
||||
@@ -499,7 +494,6 @@ void Application::onMouseRightUp(int x,int y)
|
||||
}
|
||||
void Application::onMouseMoved(int x,int y)
|
||||
{
|
||||
oldMouse = Vector2(mouse.x, mouse.y);
|
||||
mouse.oldx = mouse.x;
|
||||
mouse.oldy = mouse.y;
|
||||
mouse.x = x;
|
||||
|
||||
54
src/source/DataModelV3/InputService.cpp
Normal file
54
src/source/DataModelV3/InputService.cpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#include "DataModelV3/InputService.h"
|
||||
#include "win32Defines.h"
|
||||
|
||||
using namespace B3D;
|
||||
|
||||
InputService::InputService(void) : Instance()
|
||||
{
|
||||
name = "Mouse";
|
||||
}
|
||||
|
||||
InputService::~InputService(void)
|
||||
{
|
||||
}
|
||||
|
||||
//Poll state
|
||||
int InputService::pollKeyState(unsigned char keyCode){
|
||||
return GetHoldKeyState(keyCode);
|
||||
}
|
||||
int InputService::pollMouseX(){
|
||||
return mouseX;
|
||||
}
|
||||
int InputService::pollMouseY(){
|
||||
return mouseY;
|
||||
}
|
||||
int InputService::pollMouseButton(unsigned char button){
|
||||
return GetHoldKeyState(button);
|
||||
}
|
||||
bool InputService::pollFocus(){
|
||||
return hasFocus;
|
||||
}
|
||||
|
||||
|
||||
//Update Input
|
||||
void InputService::updateMouse(int x, int y){
|
||||
mouseX = x;
|
||||
mouseY = y;
|
||||
}
|
||||
void InputService::updateFocus(bool focus){
|
||||
hasFocus = focus;
|
||||
}
|
||||
|
||||
//Signal
|
||||
void InputService::signalKeyState(unsigned char keyCode, bool isDown){
|
||||
//TODO Signal Service
|
||||
}
|
||||
void InputService::signalMouseButtonState(unsigned char button, bool isDown){
|
||||
//TODO Signal service
|
||||
}
|
||||
void InputService::signalMouseWheelState(int step){
|
||||
//TODO Signal service
|
||||
}
|
||||
|
||||
//Targeting and mouse actions
|
||||
//TODO camera instance
|
||||
Reference in New Issue
Block a user