chalk

kis_input_device.cpp
1/*
2 * Copyright (c) 2006 Adrian Page <adrian@pagenet.plus.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.g
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#include "kis_input_device.h"
20
21#define UNKNOWN_INPUT_DEVICE_ID -1
22#define FIRST_INPUT_DEVICE_ID 0
23
24TQ_INT32 KisInputDevice::NextInputDeviceID = FIRST_INPUT_DEVICE_ID;
25
26KisInputDevice KisInputDevice::Mouse;
27KisInputDevice KisInputDevice::Stylus;
28KisInputDevice KisInputDevice::Eraser;
29KisInputDevice KisInputDevice::Puck;
30KisInputDevice KisInputDevice::Unknown(UNKNOWN_INPUT_DEVICE_ID);
31
32TQValueVector<KisInputDevice> KisInputDevice::InputDevices;
33
34KisInputDevice::KisInputDevice()
35{
36 m_id = UNKNOWN_INPUT_DEVICE_ID;
37}
38
39KisInputDevice KisInputDevice::allocateNextDevice()
40{
41 KisInputDevice inputDevice(NextInputDeviceID);
42 NextInputDeviceID++;
43 InputDevices.append(inputDevice);
44
45 return inputDevice;
46}
47
48KisInputDevice KisInputDevice::allocateInputDevice()
49{
50 allocateDefaultDevicesIfNeeded();
51
52 return allocateNextDevice();
53}
54
55void KisInputDevice::allocateDefaultDevicesIfNeeded()
56{
57 if (NextInputDeviceID == FIRST_INPUT_DEVICE_ID) {
58 Mouse = allocateNextDevice();
59 Stylus = allocateNextDevice();
60 Eraser = allocateNextDevice();
61 Puck = allocateNextDevice();
62 }
63}
64
65TQValueVector<KisInputDevice> KisInputDevice::inputDevices()
66{
67 allocateDefaultDevicesIfNeeded();
68
69 return InputDevices;
70}
71
72KisInputDevice KisInputDevice::mouse()
73{
74 allocateDefaultDevicesIfNeeded();
75 return Mouse;
76}
77
78KisInputDevice KisInputDevice::stylus()
79{
80 allocateDefaultDevicesIfNeeded();
81 return Stylus;
82}
83
84KisInputDevice KisInputDevice::eraser()
85{
86 allocateDefaultDevicesIfNeeded();
87 return Eraser;
88}
89
90KisInputDevice KisInputDevice::puck()
91{
92 allocateDefaultDevicesIfNeeded();
93 return Puck;
94}
95
96KisInputDevice KisInputDevice::unknown()
97{
98 allocateDefaultDevicesIfNeeded();
99 return Unknown;
100}
101