Decouple <cstdint>

This commit is contained in:
Martin Natano
2023-04-20 12:34:12 +02:00
parent bcea05dd67
commit aa87f85eef
167 changed files with 1533 additions and 1307 deletions
@@ -13,7 +13,8 @@
#include <fcntl.h>
#endif
#include <errno.h>
#include <cerrno>
#include <cstdint>
#include <sys/types.h>
#include <sys/stat.h>
#include <linux/input.h>
@@ -69,7 +70,7 @@ struct EventDevice
static std::vector<EventDevice *> g_apEventDevices;
static bool BitIsSet( const uint8_t *pArray, uint32_t iBit )
static bool BitIsSet( const std::uint8_t *pArray, std::uint32_t iBit )
{
return !!(pArray[iBit/8] & (1<<(iBit%8)));
}
@@ -98,14 +99,14 @@ bool EventDevice::Open( RString sFile, InputDevice dev )
if( ioctl(m_iFD, EVIOCGVERSION, &iVersion) == -1 )
LOG->Warn( "ioctl(EVIOCGVERSION): %s", strerror(errno) );
else
LOG->Info( "Event driver: v%i.%i.%i", (iVersion >> 16) & 0xFF, (iVersion >> 8) & 0xFF, iVersion & 0xFF );
LOG->Info( "Event driver: v%i.%i.%i", (iVersion >> 16) & 0xFF, (iVersion >> 8) & 0xFF, iVersion & 0xFF );
}
char szName[1024];
if( ioctl(m_iFD, EVIOCGNAME(sizeof(szName)), szName) == -1 )
{
LOG->Warn( "ioctl(EVIOCGNAME): %s", strerror(errno) );
m_sName = "(unknown)";
}
else
@@ -125,7 +126,7 @@ bool EventDevice::Open( RString sFile, InputDevice dev )
DevInfo.version, m_sName.c_str() );
}
uint8_t iABSMask[ABS_MAX/8 + 1];
std::uint8_t iABSMask[ABS_MAX/8 + 1];
memset( iABSMask, 0, sizeof(iABSMask) );
if( ioctl(m_iFD, EVIOCGBIT(EV_ABS, sizeof(iABSMask)), iABSMask) < 0 )
LOG->Warn( "ioctl(EVIOCGBIT(EV_ABS)): %s", strerror(errno) );
@@ -142,12 +143,12 @@ bool EventDevice::Open( RString sFile, InputDevice dev )
}
}
uint8_t iKeyMask[KEY_MAX/8 + 1];
std::uint8_t iKeyMask[KEY_MAX/8 + 1];
memset( iKeyMask, 0, sizeof(iKeyMask) );
if( ioctl(m_iFD, EVIOCGBIT(EV_KEY, sizeof(iKeyMask)), iKeyMask) < 0 )
LOG->Warn( "ioctl(EVIOCGBIT(EV_KEY)): %s", strerror(errno) );
uint8_t iEventTypes[EV_MAX/8];
std::uint8_t iEventTypes[EV_MAX/8];
memset( iEventTypes, 0, sizeof(iEventTypes) );
if( ioctl(m_iFD, EVIOCGBIT(0, EV_MAX), iEventTypes) == -1 )
LOG->Warn( "ioctl(EV_MAX): %s", strerror(errno) );
@@ -170,7 +171,7 @@ bool EventDevice::Open( RString sFile, InputDevice dev )
LOG->Info( " Event types: %s", join(", ", setEventTypes).c_str() );
}
int iTotalKeys = 0;
for( int i = 0; i < KEY_MAX; ++i )
{
@@ -273,7 +274,7 @@ InputHandler_Linux_Event::InputHandler_Linux_Event()
if( ! g_apEventDevices.empty() ) // LinuxInputManager found at least one valid device for us
StartThread();
}
InputHandler_Linux_Event::~InputHandler_Linux_Event()
{
if( m_InputThread.IsCreated() ) StopThread();
@@ -310,7 +311,7 @@ bool InputHandler_Linux_Event::TryDevice(RString devfile)
g_apEventDevices.push_back( pDev );
}
if( hotplug ) StartThread();
m_NextDevice = enum_add2(m_NextDevice, 1);
m_bDevicesChanged = true;
return true;
@@ -339,7 +340,7 @@ void InputHandler_Linux_Event::InputThread()
fd_set fdset;
FD_ZERO( &fdset );
int iMaxFD = -1;
for( int i = 0; i < (int) g_apEventDevices.size(); ++i )
{
int iFD = g_apEventDevices[i]->m_iFD;
@@ -400,7 +401,7 @@ void InputHandler_Linux_Event::InputThread()
ButtonPressed( DeviceInput(g_apEventDevices[i]->m_Dev, enum_add2(JOY_BUTTON_1, iNum), event.value != 0, now) );
break;
}
case EV_ABS: {
ASSERT_M( event.code < ABS_MAX, ssprintf("%i", event.code) );
DeviceButton neg = g_apEventDevices[i]->aiAbsMappingLow[event.code];
@@ -435,7 +436,7 @@ void InputHandler_Linux_Event::GetDevicesAndDescriptions( std::vector<InputDevic
EventDevice *pDev = g_apEventDevices[i];
vDevicesOut.push_back( InputDeviceInfo(pDev->m_Dev, pDev->m_sName) );
}
m_bDevicesChanged = false;
}
@@ -443,7 +444,7 @@ void InputHandler_Linux_Event::GetDevicesAndDescriptions( std::vector<InputDevic
* (c) 2003-2008 Glenn Maynard
* (c) 2013 Ben "root" Anderson
* All rights reserved.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -453,7 +454,7 @@ void InputHandler_Linux_Event::GetDevicesAndDescriptions( std::vector<InputDevic
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF