-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AsyncUserInput: add interface UserInputHandler
To remove global variables eventually.
- Loading branch information
1 parent
321c391
commit 930b846
Showing
10 changed files
with
90 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,31 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
// Copyright The Music Player Daemon Project | ||
|
||
#ifndef ASYNC_USER_INPUT_HXX | ||
#define ASYNC_USER_INPUT_HXX | ||
#pragma once | ||
|
||
#include "event/PipeEvent.hxx" | ||
|
||
#include <curses.h> | ||
|
||
class UserInputHandler; | ||
|
||
class AsyncUserInput { | ||
PipeEvent stdin_event; | ||
|
||
WINDOW &w; | ||
|
||
UserInputHandler &handler; | ||
|
||
public: | ||
AsyncUserInput(EventLoop &event_loop, WINDOW &_w) noexcept; | ||
AsyncUserInput(EventLoop &event_loop, WINDOW &_w, | ||
UserInputHandler &_handler) noexcept; | ||
|
||
// TODO remove this kludge | ||
void InjectKey(int key) noexcept; | ||
|
||
private: | ||
void OnSocketReady(unsigned flags) noexcept; | ||
}; | ||
|
||
void | ||
keyboard_unread(EventLoop &event_loop, int key) noexcept; | ||
|
||
#endif | ||
keyboard_unread(int key) noexcept; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
// Copyright The Music Player Daemon Project | ||
|
||
#pragma once | ||
|
||
#include "config.h" | ||
|
||
#include <curses.h> | ||
|
||
enum class Command : unsigned; | ||
struct Point; | ||
|
||
class UserInputHandler { | ||
public: | ||
virtual bool OnCommand(Command cmd) noexcept = 0; | ||
|
||
#ifdef HAVE_GETMOUSE | ||
virtual bool OnMouse(Point p, mmask_t bstate) noexcept = 0; | ||
#endif | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters