summaryrefslogtreecommitdiffhomepage
path: root/gui/keyboard.h
blob: ea35d372d59b49ad2066b2786dc06b40bb9dc0f9 (plain)
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
#pragma once

/* Copyright (c) 2015, 2017 Stanislaw Halik
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 */

#include "export.hpp"

#ifdef _WIN32
#   include "logic/win32-shortcuts.h"
#   include "dinput/keybinding-worker.hpp"
#endif

#include "ui_keyboard_listener.h"

#include <QDialog>
#include <QtEvents>

class OTR_GUI_EXPORT keyboard_listener : public QDialog
{
    Q_OBJECT

#ifdef _WIN32
    void receive_key(const Key& k);

    KeybindingWorker::Token token{[this](const Key& k) {receive_key(k);}};
#else
    void keyPressEvent(QKeyEvent* event) override;
#endif

    Ui_keyboard_listener ui;

public:
    keyboard_listener(QWidget* parent = nullptr);
signals:
    void key_pressed(QKeySequence k);
    void joystick_button_pressed(QString guid, int idx, bool held);
};