[tetris] drop Release events

pull/2250/head
nick black 3 years ago
parent 41282e47e1
commit 5f82a49065
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -1,16 +0,0 @@
#ifndef __NCPP_INPUT_HH
#define __NCPP_INPUT_HH
#include <notcurses/notcurses.h>
namespace ncpp
{
struct EvType
{
static constexpr unsigned Silent = ncinput::NCTYPE_UNKNOWN;
static constexpr unsigned Press = ncinput::NCTYPE_PRESS;
static constexpr unsigned Repeat = ncinput::NCTYPE_REPEAT;
static constexpr unsigned Release = ncinput::NCTYPE_RELEASE;
};
}
#endif

@ -112,11 +112,6 @@ namespace ncpp
static constexpr char32_t ScrollDown = NCKEY_SCROLL_DOWN;
static constexpr char32_t Return = NCKEY_RETURN;
static constexpr int TypeUnknown = ncinput::NCTYPE_UNKNOWN;
static constexpr int TypePress = ncinput::NCTYPE_PRESS;
static constexpr int TypeRepeat = ncinput::NCTYPE_REPEAT;
static constexpr int TypeRelease = ncinput::NCTYPE_RELEASE;
static bool IsMouse (char32_t ch) noexcept
{
return nckey_mouse_p (ch);
@ -127,5 +122,14 @@ namespace ncpp
return nckey_supppuab_p (ch);
}
};
struct EvType
{
static constexpr unsigned Unknown = ncinput::NCTYPE_UNKNOWN;
static constexpr unsigned Press = ncinput::NCTYPE_PRESS;
static constexpr unsigned Repeat = ncinput::NCTYPE_REPEAT;
static constexpr unsigned Release = ncinput::NCTYPE_RELEASE;
};
}
#endif

@ -225,13 +225,13 @@ void Ticker(ncpp::NotCurses* nc) {
char evtype_to_char(ncinput* ni){
switch(ni->evtype){
case NCKey::TypeUnknown:
case EvType::Unknown:
return 'u';
case NCKey::TypePress:
case EvType::Press:
return 'P';
case NCKey::TypeRepeat:
case EvType::Repeat:
return 'R';
case NCKey::TypeRelease:
case EvType::Release:
return 'L';
}
return 'X';

@ -6,6 +6,9 @@ bool IOLoop(ncpp::NotCurses& nc, Tetris& t, std::atomic_bool& gameover) {
if(input == 'q'){
break;
}
if(ni.evtype == ncpp::EvType::Release){
continue;
}
ncmtx.lock();
switch(input){
case NCKEY_LEFT: case 'h': t.MoveLeft(); break;

Loading…
Cancel
Save