aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/inputtypes.cpp
blob: 770b03dedd5c7053951028d2908cfc3bfe188a97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include "inputtypes.h"

const CursorNavigationCommand CursorNavigationCommand::Up(1.0, 270.0);
const CursorNavigationCommand CursorNavigationCommand::Down(1.0, 90.0);
const CursorNavigationCommand CursorNavigationCommand::Left(1.0, 180.0);
const CursorNavigationCommand CursorNavigationCommand::Right(1.0, 0.0);

CursorNavigationCommand::CursorNavigationCommand()
    :magnitude(-1), angle(-1), action(NoAction)
{}

CursorNavigationCommand::CursorNavigationCommand(float magnitude, int angle)
    :magnitude(magnitude), angle(angle), action(NoAction)
{}

//test if this commands angle is between given angles. clockwise from begin to end
bool CursorNavigationCommand::angleIsBetween(int begin, int end) const
{
    if (begin > end)
        return angle >= begin || angle <= end;
    else
        return angle >= begin && angle <= end;
}