Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include "stdafx.h"

#include "Headers/EventHandler.h"
#include "Headers/InputInterface.h"
#include "Core/Headers/Kernel.h"

namespace Divide {
namespace Input {

EventHandler::EventHandler(InputInterface *pApp, InputAggregatorInterface& eventListener)
    : _eventListener(eventListener),
      _pApplication(pApp),
      _pJoystickInterface(nullptr),
      _pEffectMgr(nullptr)
{
}

void EventHandler::initialize(JoystickInterface *pJoystickInterface,
                              EffectManager *pEffectMgr) {
    _pJoystickInterface = pJoystickInterface;
    _pEffectMgr = pEffectMgr;
}

/// Input events are either handled by the kernel
bool EventHandler::onKeyDown(const KeyEvent &arg) {
    return _eventListener.onKeyDown(arg);
}

bool EventHandler::onKeyUp(const KeyEvent &arg) {
    return _eventListener.onKeyUp(arg);
}

bool EventHandler::joystickButtonPressed(const JoystickEvent &arg, JoystickButton button) {
    return _eventListener.joystickButtonPressed(arg, button);
}

bool EventHandler::buttonPressed(const OIS::JoyStickEvent& arg, JoystickButton button) {
    return joystickButtonPressed(JoystickEvent(to_U8(arg.device->getID()), arg), button);
}

bool EventHandler::joystickButtonReleased(const JoystickEvent &arg, JoystickButton button) {
    return _eventListener.joystickButtonReleased(arg, button);
}

bool EventHandler::buttonReleased(const OIS::JoyStickEvent& arg, JoystickButton button) {
    return joystickButtonReleased(JoystickEvent(to_U8(arg.device->getID()), arg), button);
}

bool EventHandler::joystickAxisMoved(const JoystickEvent &arg, I8 axis) {
    return _eventListener.joystickAxisMoved(arg, axis);
}

bool EventHandler::axisMoved(const OIS::JoyStickEvent& arg, int axis) {
    return joystickAxisMoved(JoystickEvent(to_U8(arg.device->getID()), arg), to_I8(axis));
}

bool EventHandler::joystickPovMoved(const JoystickEvent &arg, I8 pov) {
    return _eventListener.joystickPovMoved(arg, pov);
}

bool EventHandler::povMoved(const OIS::JoyStickEvent& arg, int pov) {
    return joystickPovMoved(JoystickEvent(to_U8(arg.device->getID()), arg), to_I8(pov));
}

bool EventHandler::joystickSliderMoved(const JoystickEvent &arg, I8 index) {
    return _eventListener.joystickSliderMoved(arg, index);
}

bool EventHandler::sliderMoved(const OIS::JoyStickEvent& arg, int index) {
    return joystickSliderMoved(JoystickEvent(to_U8(arg.device->getID()), arg), to_I8(index));
}

bool EventHandler::joystickvector3Moved(const JoystickEvent &arg, I8 index) {
    return _eventListener.joystickvector3Moved(arg, index);
}

bool EventHandler::vector3Moved(const OIS::JoyStickEvent& arg, int index) {
    return joystickvector3Moved(JoystickEvent(to_U8(arg.device->getID()), arg), to_I8(index));
}

bool EventHandler::mouseMoved(const MouseEvent &arg) {
    return _eventListener.mouseMoved(arg);
}

bool EventHandler::mouseMoved(const OIS::MouseEvent &arg) {
    return mouseMoved(MouseEvent(to_U8(arg.device->getID()), arg));
}

bool EventHandler::mouseButtonPressed(const MouseEvent &arg, MouseButton id) {
    return _eventListener.mouseButtonPressed(arg, id);
}

bool EventHandler::mousePressed(const OIS::MouseEvent& arg, OIS::MouseButtonID id) {
    return mouseButtonPressed(MouseEvent(to_U8(arg.device->getID()), arg), id);
}

bool EventHandler::mouseButtonReleased(const MouseEvent &arg, MouseButton id) {
    return _eventListener.mouseButtonReleased(arg, id);
}

bool EventHandler::mouseReleased(const OIS::MouseEvent& arg, OIS::MouseButtonID id) {
    return mouseButtonReleased(MouseEvent(to_U8(arg.device->getID()), arg), id);
}

bool EventHandler::keyPressed(const OIS::KeyEvent &arg) {
    KeyEvent &key =
        Attorney::InputInterfaceEvent::getKeyRef(*_pApplication, to_U32(arg.key));
    key._text = arg.text;
    key._pressed = true;
    key._deviceIndex = to_U8(arg.device->getID());
    return onKeyDown(key);
}

bool EventHandler::keyReleased(const OIS::KeyEvent &arg) {
    KeyEvent &key =
        Attorney::InputInterfaceEvent::getKeyRef(*_pApplication, to_U32(arg.key));
    key._text = arg.text;
    key._pressed = false;
    key._deviceIndex = to_U8(arg.device->getID());
    return onKeyUp(key);
}

//////////// Effect variables applier functions
////////////////////////////////////////////////
// These functions apply the given Variables to the given OIS::Effect

// Variable force "Force" + optional "AttackFactor" constant, on a
// OIS::ConstantEffect
void forceVariableApplier(MapVariables &mapVars, OIS::Effect *pEffect) {
    D64 dForce = mapVars[_ID("Force")]->getValue();
    D64 dAttackFactor = 1.0;
    if (mapVars.find(_ID("AttackFactor")) != std::end(mapVars))
        dAttackFactor = mapVars[_ID("AttackFactor")]->getValue();

    OIS::ConstantEffect *pConstForce =
        dynamic_cast<OIS::ConstantEffect *>(pEffect->getForceEffect());
    pConstForce->level = (I16)dForce;
    pConstForce->envelope.attackLevel = (U16)std::fabs(dForce * dAttackFactor);
    pConstForce->envelope.fadeLevel =
        (U16)std::fabs(dForce);  // Fade never reached, in fact.
}

// Variable "Period" on an OIS::PeriodicEffect
void periodVariableApplier(MapVariables &mapVars, OIS::Effect *pEffect) {
    D64 dPeriod = mapVars[_ID("Period")]->getValue();

    OIS::PeriodicEffect *pPeriodForce =
        dynamic_cast<OIS::PeriodicEffect *>(pEffect->getForceEffect());
    pPeriodForce->period = to_U32(dPeriod);
}

};  // namespace Input
};  // namespace Divide

Commits for Divide-Framework/trunk/Source Code/Platform/Input/EventHandler.cpp

Diff revisions: vs.
Revision Author Commited Message
970 Diff Diff IonutCava picture IonutCava Mon 13 Nov, 2017 17:16:44 +0000

[Ionut]
- ImWindow <-> DisplayWindow fixes

969 Diff Diff IonutCava picture IonutCava Mon 13 Nov, 2017 00:15:57 +0000

[Ionut]
- Further improve DisplayWindow <-> Input relationship
- Add Flip-Y 2D camera (D3D style projection)
- Fix IMGUI rendering
- Add IMGUI sample and IMWINDOW sample rendering at the same time
- Improve IMWINDOW multi-window support
— Bug: nothing rendering in child platform windows
- Add draw command to move render context from one window to another

952 Diff Diff IonutCava picture IonutCava Wed 25 Oct, 2017 00:35:37 +0000

[Ionut]
- Added the CEGUI rendering project to our solution for easier modification, debugging and integration
- Updated to OIS 1.4
- Some updates to the WindowHandle struct

  • Only compiled in Debug*
890 Diff Diff IonutCava picture IonutCava Sun 14 May, 2017 20:54:59 +0000

[Ionut]
- Add pre-compiled header support
- Initial code for per-stage tessellation computation

867 Diff Diff IonutCava picture IonutCava Mon 20 Feb, 2017 17:01:12 +0000

[IonutCava]
- Rename to_XNN and to_const_XNN functions to reflect the target data type they are converting to.
- Cleanup Angle namespace and remove all “inDegrees” parameters from rotation functions. Use aliases to differentiate between Degree and Radian parameters.
- Profile guided optimizations.

816 Diff Diff IonutCava picture IonutCava Fri 13 Jan, 2017 17:05:20 +0000

[IonutCava]
- Allow per player scene state and input source
— Add SceneStatePerPlayer class
— Add device index to InputParams objects.
— ToDo: map players to devide indices

804 Diff Diff IonutCava picture IonutCava Thu 01 Dec, 2016 17:20:59 +0000

[IonutCava]
- Singleton elimination update Part I: get it to compile
— The following classes are no longer Singletons: GFXDevice, GL_API, DX_API, SFXWrapper, FmodWrapper, SDLWrapper, ALWrapper, PXDevice, InputInterface, RenderPassManager, SceneManager and ResourceManager;
— Refactor system to a Context / Component based implementation (Pass relevant context to objects: e.g. GFXDevice object to Textures, GUI to GUIElements, etc)
— Make devices and managers components of the kernel
— Allow multiple Resource caches to co-exist. This may prove useful for later when a more fragmented memory model is need (per frame / per scene / global caches / etc)

  • next steps: part II – cleanup/refactor new code, part III – optimise code, part IV – remove remaining Singletons (e.g. Application, ParamHandler, FrameListenerManager, Recast, PostFX and DebugInterface)
680 Diff Diff IonutCava picture IonutCava Thu 14 Apr, 2016 16:15:38 +0000

[IonutCava]
- Added a mat2 class (untested)
- Added static asserts to matrices, vectors and quaternions to allow only arithmetic (sans bool) data types
- Added more vector unit tests
- Added unit tests for matrices
- D32 finally renamed to D64 as the VC++ compiler is considered as the reference compiler

577 Diff Diff IonutCava picture IonutCava Fri 20 Nov, 2015 15:59:10 +0000

[IonutCava]
- Replace all string indexed maps with unsigned long long indexed maps and add both compile time and runtime hashing functions to convert strings to the proper indices
— Balancing the calls between _ID and _ID_RT can reduce map lookup overhead, especially with ParamHandler and Locale::get

458 IonutCava picture IonutCava Tue 02 Jun, 2015 16:26:18 +0000

[Ionut]
- More Linux port work