Descent3/ddio/lnxkey_null.cpp
2024-05-24 22:18:14 +03:00

97 lines
2.4 KiB
C++

/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
--- HISTORICAL COMMENTS FOLLOW ---
* $Logfile: /DescentIII/Main/ddio_lnx/lnxkey_null.cpp $
* $Revision: 1.2 $
* $Date: 2004/02/25 00:04:06 $
* $Author: ryan $
*
* Linux NULL keyboard routines
*
* $Log: lnxkey_null.cpp,v $
* Revision 1.2 2004/02/25 00:04:06 ryan
* Removed loki_utils dependency and ported to MacOS X (runs, but incomplete).
*
* Revision 1.1.1.1 2000/04/18 00:00:33 icculus
* initial checkin
*
*
* 2 7/14/99 9:06p Jeff
* added comment header
*
* $NoKeywords: $
*/
#include "ddio.h"
extern volatile struct tLnxKeys {
union {
int up_ticks;
float up_time;
};
union {
int down_ticks;
float down_time;
};
bool status;
} LKeys[DDIO_MAX_KEYS];
bool ddio_null_InternalKeyInit(ddio_init_info *init_info) {
// reset key list
for (int i = 0; i < DDIO_MAX_KEYS; i++) {
LKeys[i].down_ticks = 0;
LKeys[i].up_ticks = 0;
LKeys[i].status = false;
}
return true;
}
void ddio_null_InternalKeyClose() {}
bool ddio_null_InternalKeyState(uint8_t key) { return LKeys[key].status; }
void ddio_null_InternalKeySuspend() {}
void ddio_null_InternalKeyResume() {}
float ddio_null_InternalKeyDownTime(uint8_t key) {
float down_time = 0.0f;
if (LKeys[key].status) {
float timer = timer_GetTime();
down_time = timer - LKeys[key].down_time;
LKeys[key].down_time = timer;
} else {
down_time = LKeys[key].up_time - LKeys[key].down_time;
LKeys[key].down_time = LKeys[key].up_time = 0.0f;
}
return down_time;
}
void ddio_null_InternalResetKey(uint8_t key) {
LKeys[key].down_time = 0.0f;
LKeys[key].up_time = 0.0f;
LKeys[key].status = false;
}
bool ddio_null_KeyFrame() { return true; }
void ddio_null_InternalKeyFrame(void) {}