src/SpacenavReceiver.h
author František Kučera <franta-hg@frantovo.cz>
Thu, 07 Mar 2019 14:55:56 +0100
branchv_0
changeset 4 1383ad1c4f57
parent 3 6baa91ac3199
child 6 49560660d230
permissions -rw-r--r--
SpacenavWrapper
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
/**
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
 * Spacenav Demo Qt
4
1383ad1c4f57 SpacenavWrapper
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
     3
 * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
1
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
 *
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     5
 * This program is free software: you can redistribute it and/or modify
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
 * the Free Software Foundation, either version 3 of the License, or
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
 * (at your option) any later version.
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
 *
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
 * This program is distributed in the hope that it will be useful,
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
 * GNU General Public License for more details.
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
 *
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
 */
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
#pragma once
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
#include <QObject>
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
#include <QThread>
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
4
1383ad1c4f57 SpacenavWrapper
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    23
#include "SpacenavWrapper.h"
1383ad1c4f57 SpacenavWrapper
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    24
1383ad1c4f57 SpacenavWrapper
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    25
Q_DECLARE_METATYPE(SpacenavWrapper::Event)
1
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
class SpacenavReceiver : public QThread {
4
1383ad1c4f57 SpacenavWrapper
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    28
	Q_OBJECT
1383ad1c4f57 SpacenavWrapper
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    29
private:
1383ad1c4f57 SpacenavWrapper
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    30
	SpacenavWrapper spnav;
1
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
public:
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
	SpacenavReceiver() : QThread() {
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
	}
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
	void run() {
4
1383ad1c4f57 SpacenavWrapper
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    38
		while (true) {
1383ad1c4f57 SpacenavWrapper
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    39
			SpacenavWrapper::Event e = spnav.waitEvent();
1383ad1c4f57 SpacenavWrapper
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    40
			emit spacenavEvent(e);
1
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
		}
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
	}
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
signals:
4
1383ad1c4f57 SpacenavWrapper
František Kučera <franta-hg@frantovo.cz>
parents: 3
diff changeset
    45
	void spacenavEvent(SpacenavWrapper::Event e);
1
2a3e9f07c128 receive spacenav events (in separate thread) and print them on stderr
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
};