Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************/
- /******************************************************************************/
- //"2024-11-21\include\kit\misc.hpp":
- //THIS LIBRARY WAS MADE TO USE SDL2 VERSION 2.28.2
- #ifndef _INC_MISC_HPP
- #define _INC_MISC_HPP
- #include "commondef.hpp"
- #include "_misc_memory.hpp"
- #include "_misc_Mutex.hpp"
- #include "_misc_Thread.hpp"
- #include "_misc_func.hpp"
- #include "_misc_time.hpp"
- #include "_misc_Event.hpp"
- #include "_misc_EventWatch.hpp"
- #include "_misc_fileio.hpp"
- #endif /* _INC_MISC_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"2024-11-21\include\kit\video.hpp":
- //THIS LIBRARY WAS MADE TO USE SDL2 VERSION 2.28.2
- #ifndef _INC_VIDEO_HPP
- #define _INC_VIDEO_HPP
- #include "commondef.hpp"
- #include "_video_Window.hpp"
- #include "_video_PixelFmt.hpp"
- #include "_video_Surface.hpp"
- #include "_video_BFont_Surface.hpp"
- #endif /* _INC_VIDEO_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"2024-11-21\include\kit\_audio_AudioData.hpp":
- #ifndef _INC__AUDIO_AUDIODATA_HPP
- #define _INC__AUDIO_AUDIODATA_HPP
- #include "commondef.hpp"
- #include "_audio_types.hpp"
- namespace kit {
- struct AudioDataHeader;
- //like Surface, the pointer this returns must have been allocated with
- //memory:alloc specifically (NOT memory::allocSIMD!)
- //->samples must not use a separate allocation! samples must be contiguous
- //and on the same memory block as the header itself!
- //(basically, header_ptr->samples = (u8*)header_ptr+header_ptr->headerSize)
- typedef AudioDataHeader* (*AudioDataLoaderCallback)(const char* filePath);
- typedef void (*AudioDataSaverCallback)(const char* filePath, AudioDataHeader& header_in);
- //(like Surface, when saving OR loading, filePath will never be nullptr by the
- //time the callback is invoked, so you don't need to worry about checking for it)
- //(not an actual callback, but rather the lack of one)
- #define AudioDataLoadKPM ((AudioDataLoaderCallback)nullptr)
- #define AudioDataSaveKPM ((AudioDataSaverCallback)nullptr)
- AudioDataHeader* AudioDataLoadWAV(const char* filePath);
- void AudioDataSaveWAV(const char* filePath, AudioDataHeader& header_in);
- AudioDataHeader* AudioDataLoadQOA(const char* filePath);
- void AudioDataSaveQOA(const char* filePath, AudioDataHeader& header_in);
- AudioDataHeader* AudioDataLoadOGG(const char* filePath);
- //(there is no saver callback for ogg currently!)
- #define KIT_MAGIC_KPM (0x4D78506B) // = "kPxM" (no null terminator)
- struct AudioDataHeader { //72B (0x48B)
- u32 magic; // (0x00) = KIT_MAGIC_KPM = 0x4D78506B = "kPxM"
- u16 format; // (0x04) = one of AudioSampleFormatEnum if fmt_version == 1
- u16 headerSize; // (0x06) = must be >=sizeof(AudioDataHeader)
- u64 dataSize; // (0x08) = size of audio data, in bytes
- u64 loopStart; // (0x10) = which sample to loop back to
- u64 loopEnd; // (0x18) = which sample to jump back to loopStart on
- u64 numSamples; // (0x20) = # of sample frames in audio data
- u32 sampleRate; // (0x28) = the audio data's sample rate, in Hz
- u32 bitRate; // (0x2C) = the audio's bit rate (per second)
- u16 loopCount; // (0x30) = # of times to loop audio (0 = no loop, 0xFFFF = inf loop)
- u16 channels; // (0x32) = # of interlaced channels in the audio data
- u8 _reserved; // (0x34)
- u8 fmt_version; // (0x35) = 0=kit_w32, 1=kit_sdl2
- u8 mode; // (0x36) = 0 for normal PCM or float data types
- u8 metadata_type; // (0x37) = 0 for no metadata
- void* samples; // (0x38) = the audio's sample data (appears as nullptr in file)
- void* userdata; // (0x40) = user-defined (also appears nullptr in file)
- // (0x48) = (start of sample data, assuming a .kpm file)
- void printHeader(const char* name = nullptr);
- };
- class AudioData { //24B
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- u16 _padding16;
- //used by both the 'only allocate' constructors
- void _allocate_hdr(u16 headerSize, u64 dataSize,
- const char* funcName = nullptr);
- //used by both of the 'load from file' constructors
- void _construct_file(const char* filePath, AudioDataLoaderCallback callback,
- const char* funcName = nullptr);
- public:
- //after exiting the constructor, hdr->samples is safe to use with SIMD
- //vector instructions/intriniscs (AudioDataLoaderCallbacks must
- //still use memory::alloc instead of allocSIMD though)!
- AudioDataHeader* hdr;
- Stereo_f32 volume = {1.0f, 1.0f};
- //create with everything zeroed out, except headerSize, dataSize, and samples
- AudioData(u16 headerSize, u64 dataSize)
- { _allocate_hdr(headerSize, dataSize); }
- //create with zeroed out sample data
- AudioData(AudioSampleFormatEnum format,
- u64 numSamples, u16 channels, u32 sampleRate);
- //create from an audio file of a specific file format
- //(may reduce binary size if you only plan to use 1 file type or something)
- AudioData(const char* filePath, AudioDataLoaderCallback callback)
- { _construct_file(filePath, callback); }
- //create from an audio file of any supported format (.kpm, .wav, .qoa, .ogg)
- AudioData(const char* filePath);
- ~AudioData();
- inline void printHeader(const char* name = nullptr)
- { if(hdr != nullptr) hdr->printHeader(name); }
- //(this will overwrite any file named filePath! make sure to check
- //with fileio::exists() unless you intend to overwrite the previous file)
- void saveAudio(const char* filePath, AudioDataSaverCallback callback);
- //the conversion method used is slightly inaccurate for a number of reasons.
- //this function only serves as a convenience, where accuracy isn't
- //needed beyond sounding more or less the same.
- void convertFormat(AudioSampleFormatEnum format);
- //(this will return early if hdr->format == format,
- //since no conversion would be necessary)
- };
- }; /* namespace kit */
- #endif /* _INC__AUDIO_AUDIODATA_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"2024-11-21\include\kit\_audio_AudioDevice.hpp":
- #ifndef _INC__AUDIO_AUDIODEVICE_HPP
- #define _INC__AUDIO_AUDIODEVICE_HPP
- #include "commondef.hpp"
- #include "_audio_types.hpp"
- namespace kit {
- //if disableFadeDelay == false, audio will be muted for 90ms
- //before fading in over the course of 10ms (100ms in total).
- //if disableFadeDelay == true, only the 10ms fade-in will occur
- class AudioDevice { //64B
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- u16 _padding16;
- GenOpqPtr _opq = nullptr;
- //(device starts in a paused state!)
- void _construct(const char* name,
- const AudioDeviceInfo& desired,
- bool disableFadeDelay = false,
- bool indexed = true);
- public:
- const AudioDeviceInfo info;
- //(internally calls SDL_GetAudioDeviceName to get device's name)
- AudioDevice(s32 index, //-1 to use default device
- const AudioDeviceInfo& desired,
- bool disableFadeDelay = false);
- AudioDevice(const char* name, //nullptr to use default device
- const AudioDeviceInfo& desired,
- bool disableFadeDelay = false)
- { _construct(name, desired, disableFadeDelay, false); }
- //this will abruptly stop audio playback with no fade-out, so make sure
- //to have the device be completely paused by the time this is called!
- //(it's technically fine to do this without pausing, but it sounds terrible)
- ~AudioDevice();
- inline bool isValid() { return _valid; }
- inline bool isConstructing(){ return _constructing; }
- bool isPlaying(); //'is the user callback actually getting called?'
- bool isActive(); //'is the underlying SDL device actually writing to DAC?'
- //(^^returning true does not necessarily mean
- //that the callback is actually being called!)
- void setCallback(AudioCallback callback);
- void setUserdata(void* userdata);
- void setPlayback(bool playing);
- //false, true = wait 10ms, wait 100ms (or also just 10ms if disableFadeDelay)
- void setPlaybackAndWait(bool playing);
- inline void play() { setPlayback(true ); }
- inline void pause(){ setPlayback(false); }
- inline void playAndWait() { setPlaybackAndWait(true ); }
- inline void pauseAndWait(){ setPlaybackAndWait(false); }
- void lock(bool locked = true);
- inline void unlock(){ lock(false); }
- };
- }; /* namespace kit */
- #endif /* _INC__AUDIO_AUDIODEVICE_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"2024-11-21\include\kit\_audio_AudioStream.hpp":
- #ifndef _INC__AUDIO_AUDIOSTREAM_HPP
- #define _INC__AUDIO_AUDIOSTREAM_HPP
- #include "commondef.hpp"
- #include "_audio_types.hpp"
- namespace kit {
- //converts an audio buffer to that of a different type,
- //for example, mono s16 @ 44.1kHz -> stereo f32 @ 48kHz
- class AudioStream { //112B
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- u16 _padding16;
- GenOpqPtr _opq = nullptr;
- public:
- //(only .sampleRate, .sampleFormat, and .numChannels are actually used here)
- const AudioDeviceInfo src; //what will be converted to dst
- const AudioDeviceInfo dst; //what to convert src to
- AudioStream(const AudioDeviceInfo* src_p, const AudioDeviceInfo* dst_p);
- ~AudioStream();
- inline bool isValid() { return _valid; }
- inline bool isConstructing(){ return _constructing; }
- //returns # of converted bytes ready to be read from with a call to get()
- //(if 0 is returned, you can call flush() to make available whatever is
- // left in the buffer. though this might cause audio dropouts if you
- // intend on making additional calls to put() to the stream!)
- u32 getAvailableBytes();
- //tell the stream that you're done sending data, and anything being
- //buffered should be converted/resampled and made available immediately
- void flush();
- //clear any pending data in the stream without converting it
- void clear();
- //read from converted data into buffer_dst
- //returns number of bytes read from stream (to a max of buffer_size bytes)
- u32 get(void* buffer_dst, u32 buffer_size);
- //write samples (from buffer_src) to stream to be converted
- //(buffer_size is also in bytes here)
- void put(void* buffer_src, u32 buffer_size);
- };
- }; /* namespace kit */
- #endif /* _INC__AUDIO_AUDIOSTREAM_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"2024-11-21\include\kit\_audio_func.hpp":
- #ifndef _INC__AUDIO_FUNC_HPP
- #define _INC__AUDIO_FUNC_HPP
- #include "commondef.hpp"
- #include "_audio_types.hpp"
- namespace kit {
- namespace audiofunc {
- //if name_p != nullptr, *name_p will be filled with the name of the device
- //(memory is allocated here; call memory::free() on it to prevent leaks!)
- //(also, this function can potentially be quite expensive, so don't call it often!)
- AudioDeviceInfo getDefaultDevInfo(char** name_p = nullptr, bool isInput = false);
- AudioDeviceInfo getDeviceInfo(s32 index, bool isInput);
- //returns -1 if explicit device list could not be determined
- //(doesn't necessarily mean an error, but call getLastSysError() just in case)
- s32 getNumDevices(bool isInput);
- //the returned pointer (utf-8 encoded) is managed internally and should not be freed
- //if you want to reference/store the string long-term, it should be copied, as the returned
- //pointer will become invalid the next time certain SDL functions are called internally
- //(also, the returned value and its associated index reflect the latest call to
- //getNumDevices(), so that should be called in order to redetect available hardware)
- const char* getDeviceName(u32 index, bool isInput);
- //(only useful in debug build!)
- void printAudioDeviceInfo(const AudioDeviceInfo& info);
- }; /* namespace audiofunc */
- }; /* namespace kit */
- #endif /* _INC__AUDIO_FUNC_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"2024-11-21\include\kit\_audio_SoundEngine.hpp":
- #ifndef _INC__AUDIO_SOUNDENGINE_HPP
- #define _INC__AUDIO_SOUNDENGINE_HPP
- #include "commondef.hpp"
- #include "_audio_types.hpp"
- namespace kit {
- //WARNING: IF A CURRENTLY PLAYING AUDIO CLIP IS DESTROYED BEFORE
- //SOUNDENGINE, AN ACCESS VIOLATION MIGHT OCCUR IF ACTIVELY MIXING!
- struct _SoundEngineTrack;
- class SoundEngine { //40B
- u32 _type;
- bool _valid = false;
- bool _constructing = true;
- u16 _tracks_len = 64;
- _SoundEngineTrack* _tracks = nullptr;
- GenOpqPtr _lock = nullptr;
- u16 _padding16;
- u8 _padding8;
- public:
- //(ALL TRACKS MUST BE FULLY STOPPED BEFORE CHANGING SAMPLERATE,
- //AS SAMPLERATE IS USED TO CALCULATE SOME AUDIO CLIP INFO!)
- bool stopIfVolumeIsZero = true;
- f32 sampleRate = 48000.0f; //the *device's* sample rate, in Hz
- Stereo_f32 volumeMaster = {1.0f, 1.0f};
- //(only the left channel of volumeMaster
- //is used if the source audio is mono)
- SoundEngine(u16 numTracks = 64, f32 _sampleRate = 48000.0f);
- ~SoundEngine();
- bool isTrackPlaying(u16 track);
- u16 getActiveTracks();
- inline u16 getTrackCount(){ return _tracks_len; }
- //sets the volume multiplier of a given track,
- //or all active tracks if track == 0xFFFF
- //when forced == true, the volume state is set instantly, instead of
- //being interpolated over the course of the next call to mixTracks()
- void setVolume(f32 volumeL, f32 volumeR,
- u16 track = 0xFFFF, bool forced = false);
- //sets the speed multiplier of a given track,
- //or all active tracks if track == 0xFFFF
- //forced has the same behavior as setVolume
- void setSpeed(f64 speedNew,
- u16 track = 0xFFFF, bool forced = false);
- //sets the change in volume over time for a given track.
- //or all active tracks if track == 0xFFFF
- //deltaSeconds is the time it will take for the volume
- //to go from 0.0x -> 1.0x (or vice versa)
- void setVolumeDelta(f32 deltaSecondsL, f32 deltaSecondsR,
- u16 track = 0xFFFF);
- //same behavior as setVolumeDelta, except it's applied to the speed multiplier
- void setSpeedDelta(f64 deltaSeconds,
- u16 track = 0xFFFF);
- //returns the track the audio was queued into,
- //or 0xFFFF if no empty track was found
- u16 play(const AudioData& audio, //(only f32 or Stereo_f32 samples allowed!)
- f32 volumeL = 1.0f, f32 volumeR = 1.0f, f64 speed = 1.0);
- //(make sure to stop all tracks before freeing any instances of AudioData,
- //as to avoid any issues related to dangling pointers and whatnot)
- //(also, unless forced is set to true, this function
- //won't work if stopIfVolumeIsZero is false!)
- void stop(u16 track = 0xFFFF, bool forced = false);
- //returns false if timeout is reached, true otherwise
- //(timeoutMS = 0 to wait indefinitely)
- bool waitForTrack(u64 timeoutMS = 0, u16 track = 0xFFFF);
- //buffer_len is in elements, not bytes
- //returns referenceTimestamp, or 0 on error
- //(call getLastSysError() for error details)
- u64 mixTracks(Stereo_f32* buffer, size_t buffer_len,
- u64 referenceTimestamp = kit::time::getMS());
- };
- }; /* namespace kit */
- #endif /* _INC__AUDIO_SOUNDENGINE_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"2024-11-21\include\kit\_audio_types.hpp":
- #ifndef _INC__AUDIO_TYPES_HPP
- #define _INC__AUDIO_TYPES_HPP
- #include "commondef.hpp"
- namespace kit {
- #define KIT_AUDIO_BITSIZE(x) (x & (0xFF ))
- #define KIT_AUDIO_ISFLOAT(x) (x & (1<< 8))
- #define KIT_AUDIO_ISBIGENDIAN(x) (x & (1<<12))
- #define KIT_AUDIO_ISSIGNED(x) (x & (1<<15))
- #define KIT_AUDIO_BYTESIZE(x) (KIT_AUDIO_BITSIZE(x)/8)
- //(big-endian sample formats are not supported currently)
- enum AudioSampleFormatEnum {
- SMPFMT_U8 = 0x0008, //unsigned 8-bit samples
- SMPFMT_S8 = 0x8008, // signed 8-bit samples
- SMPFMT_U16LSB = 0x0010, //unsigned 16-bit samples
- SMPFMT_S16LSB = 0x8010, // signed 16-bit samples
- SMPFMT_S32LSB = 0x8020, // signed 32-bit samples
- SMPFMT_F32LSB = 0x8120, //32-bit floating point samples
- SMPFMT_U16MSB = 0x1010, //same as LSB, except with big-endian byte order
- SMPFMT_S16MSB = 0x9010, //same as LSB, except with big-endian byte order
- SMPFMT_S32MSB = 0x9020, //same as LSB, except with big-endian byte order
- SMPFMT_F32MSB = 0x9120, //same as LSB, except with big-endian byte order
- //unsupported by SDL2-based audio devices/streams
- //(as in, what AudioDevice/AudioStream use),
- //but these can be used with AudioData instances
- SMPFMT_S24LSB = 0x8018, // signed 24-bit samples
- SMPFMT_F64LSB = 0x8140, //64-bit floating point samples
- SMPFMT_S24MSB = 0x9018, //same as LSB, except with big-endian byte order
- SMPFMT_F64MSB = 0x9140, //same as LSB, except with big-endian byte order
- //aliases
- SMPFMT_U16 = SMPFMT_U16LSB,
- SMPFMT_S16 = SMPFMT_S16LSB,
- SMPFMT_S24 = SMPFMT_S24LSB,
- SMPFMT_S32 = SMPFMT_S32LSB,
- SMPFMT_F32 = SMPFMT_F32LSB,
- SMPFMT_F64 = SMPFMT_F64LSB,
- //may also be used as a wildcard
- //(as in this may be associated with a value != 0xFFFF)
- SMPFMT_UKNOWN = 0xFFFF,
- };
- struct AudioDeviceInfo; //forward declaration
- //returns:
- //< 0: abort playback (pause without fade-out)
- //= 0: continue playing
- //> 0: pause playback (pause with fade-out)
- //(also, _buffer will already be aligned and padded for use
- //with vector operations, like those in SSE and AVX!)
- typedef s32 (*AudioCallback)(void* _buffer, const AudioDeviceInfo& info);
- /* (taken from the SDL2 wiki):
- For multi-channel audio, the default SDL channel mapping is:
- 2: FL FR (stereo)
- 3: FL FR LFE (2.1 surround)
- 4: FL FR BL BR (quad)
- 5: FL FR LFE BL BR (4.1 surround)
- 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)
- 7: FL FR FC LFE BC SL SR (6.1 surround)
- 8: FL FR FC LFE BL BR SL SR (7.1 surround)
- */
- struct AudioDeviceInfo { //48B
- u64 timeStartTicks = 0; //timestamp (in ticks) at start of callback (read-only)
- u64 timeStartMS = 0; //timestamp (in ms) at start of callback (read-only)
- u32 deviceID = 0; //(read-only)
- u32 sampleRate = 0; //0 to use device's default (must be <= KIT_S32_MAX)
- u16 sampleFrames = 0; //0 to use device's default (powers of 2 *recommended* when manually setting)
- u16 sampleFormat = SMPFMT_F32; //samples are f32 by default
- u8 sampleFrameSize = 0; //size of a single sample frame, in bytes (read only)
- u8 numChannels = 0; //0 to use device's default
- bool isInput = false; //is this a recording device? (rendering/output otherwise)
- bool zeroBuffer = false; //'memset 0 the audio buffer before calling callback?' (output devs only)
- AudioCallback callback = nullptr;
- void* userdata = nullptr; //optional, unlike callback
- };
- //(s24 IS NOT INCLUDED HERE)
- union Mono_smp {
- u8 * u8_ ;
- s8 * s8_ ;
- u16* u16_;
- s16* s16_;
- s32* s32_;
- f32* f32_;
- f64* f64_;
- void* data;
- Mono_smp(void* _data) : data(_data) {}
- };
- //(s24 IS NOT INCLUDED HERE)
- struct Stereo_u8 {
- u8 l, r;
- inline Stereo_u8(){}
- inline Stereo_u8(u8 _v) : l(_v), r(_v) {}
- inline Stereo_u8(u8 _l, u8 _r) : l(_l), r(_r) {}
- };
- struct Stereo_s8 {
- s8 l, r;
- inline Stereo_s8(){}
- inline Stereo_s8(s8 _v) : l(_v), r(_v) {}
- inline Stereo_s8(s8 _l, s8 _r) : l(_l), r(_r) {}
- };
- struct Stereo_u16 {
- u16 l, r;
- inline Stereo_u16(){}
- inline Stereo_u16(u16 _v) : l(_v), r(_v) {}
- inline Stereo_u16(u16 _l, u16 _r) : l(_l), r(_r) {}
- };
- struct Stereo_s16 {
- s16 l, r;
- inline Stereo_s16(){}
- inline Stereo_s16(s16 _v) : l(_v), r(_v) {}
- inline Stereo_s16(s16 _l, s16 _r) : l(_l), r(_r) {}
- };
- struct Stereo_s32 {
- s32 l, r;
- inline Stereo_s32(){}
- inline Stereo_s32(s32 _v) : l(_v), r(_v) {}
- inline Stereo_s32(s32 _l, s32 _r) : l(_l), r(_r) {}
- };
- struct Stereo_f32 {
- f32 l, r;
- inline Stereo_f32(){}
- inline Stereo_f32(f32 _v) : l(_v), r(_v) {}
- inline Stereo_f32(f32 _l, f32 _r) : l(_l), r(_r) {}
- };
- struct Stereo_f64 {
- f64 l, r;
- inline Stereo_f64(){}
- inline Stereo_f64(f64 _v) : l(_v), r(_v) {}
- inline Stereo_f64(f64 _l, f64 _r) : l(_l), r(_r) {}
- };
- union Stereo_smp {
- Stereo_u8* u8_ ;
- Stereo_s8* s8_ ;
- Stereo_u16* u16_;
- Stereo_s16* s16_;
- Stereo_s32* s32_;
- Stereo_f32* f32_;
- Stereo_f64* f64_;
- void* data;
- Stereo_smp(void* _data) : data(_data) {}
- };
- }; /* namespace kit */
- #endif /* _INC__AUDIO_TYPES_HPP */
- /******************************************************************************/
- /******************************************************************************/
- //"2024-11-21\include\kit\_misc_Event.hpp":
- #ifndef _INC__MISC_EVENT_HPP
- #define _INC__MISC_EVENT_HPP
- #include "commondef.hpp"
- namespace kit {
- #define KIT_EVENT_ID(_id) ( (_id) & 0xFFFF0000 )
- #define KIT_SUBEVENT_ID(_sub_id) ( (_sub_id) & 0xFFFF )
- #define _KIT_INC_ETYPE(_previous_type) ( (_previous_type) + 0x00010000 )
- enum EventTypesEnum {
- KEVENT_NULL = 0x00000000,
- //(common is not an actual event that occurs,
- //it just includes what the other events have in common)
- KEVENT_COMMON = _KIT_INC_ETYPE(KEVENT_NULL), //Event_Common
- KEVENT_DISPLAY = _KIT_INC_ETYPE(KEVENT_COMMON), //Event_Display
- KEVENT_DISPLAY_ORIENTATION = KEVENT_DISPLAY | 0x0001, //display orientation has changed to data1
- KEVENT_DISPLAY_DISCONNECTED = KEVENT_DISPLAY | 0x0002, //display has been removed from the system
- KEVENT_DISPLAY_CONNECTED = KEVENT_DISPLAY | 0x0003, //display has been added to the system
- KEVENT_DISPLAY_MOVED = KEVENT_DISPLAY | 0x0004, //display has changed position
- KEVENT_WIN = _KIT_INC_ETYPE(KEVENT_DISPLAY), //Event_Window
- KEVENT_WIN_EXPOSED = KEVENT_WIN | 0x0001, //window has been exposed and should be redrawn
- KEVENT_WIN_HIDDEN = KEVENT_WIN | 0x0002, //window has been hidden
- KEVENT_WIN_SHOWN = KEVENT_WIN | 0x0003, //window has been shown
- KEVENT_WIN_MOVED = KEVENT_WIN | 0x0004, //window has been moved to dataX, dataY
- KEVENT_WIN_RESIZED = KEVENT_WIN | 0x0005, //window has been resized to dataX, dataY
- KEVENT_WIN_SIZE_CHANGED = KEVENT_WIN | 0x0006, //window size has changed, via API, system, or user.
- KEVENT_WIN_RESTORED = KEVENT_WIN | 0x0007, //window has been restored to normal size and position
- KEVENT_WIN_MINIMIZED = KEVENT_WIN | 0x0008, //window has been minimized
- KEVENT_WIN_MAXIMIZED = KEVENT_WIN | 0x0009, //window has been maximized
- KEVENT_WIN_MFOCUS_LOST = KEVENT_WIN | 0x000A, //window has lost mouse focus (mouse left window)
- KEVENT_WIN_MFOCUS_GAINED = KEVENT_WIN | 0x000B, //window has gained mouse focus (mouse entered window)
- KEVENT_WIN_KFOCUS_LOST = KEVENT_WIN | 0x000C, //window has lost keyboard focus
- KEVENT_WIN_KFOCUS_GAINED = KEVENT_WIN | 0x000D, //window has gained keyboard focus
- KEVENT_WIN_CLOSE = KEVENT_WIN | 0x000E, //window manager requests that the window be closed
- KEVENT_WIN_TAKE_FOCUS = KEVENT_WIN | 0x000F, //window is being offered a focus (should set window input focus on itself or a subwindow, or ignore)
- KEVENT_WIN_HIT_TEST = KEVENT_WIN | 0x0010, //window had a hit test that wasn't HITTEST_NORMAL.
- KEVENT_WIN_ICCPROF_CHANGED = KEVENT_WIN | 0x0011, //the ICC profile of the window's display has changed.
- KEVENT_WIN_DISPLAY_CHANGED = KEVENT_WIN | 0x0012, //window has been moved to display data1.
- KEVENT_KEY = _KIT_INC_ETYPE(KEVENT_WIN), //Event_Key
- KEVENT_KEY_DOWN = KEVENT_KEY | 0x0001,
- KEVENT_KEY_UP = KEVENT_KEY | 0x0002,
- KEVENT_KEYMAPCHANGED = _KIT_INC_ETYPE(KEVENT_KEY), //(N/A); keymap changed by a input language/layout system event
- KEVENT_MOUSE = _KIT_INC_ETYPE(KEVENT_KEYMAPCHANGED), //Event_Mouse
- KEVENT_MOUSE_MOVED = KEVENT_MOUSE | 0x0001,
- KEVENT_MOUSE_UP = KEVENT_MOUSE | 0x0002,
- KEVENT_MOUSE_DOWN = KEVENT_MOUSE | 0x0003,
- KEVENT_MOUSE_WHEEL = KEVENT_MOUSE | 0x0004,
- KEVENT_JOY = _KIT_INC_ETYPE(KEVENT_MOUSE), //Event_Joystick
- KEVENT_JOY_AXIS = KEVENT_JOY | 0x0001,
- KEVENT_JOY_TRACKBALL = KEVENT_JOY | 0x0002,
- KEVENT_JOY_HAT = KEVENT_JOY | 0x0003,
- KEVENT_JOY_BUTTON_UP = KEVENT_JOY | 0x0004,
- KEVENT_JOY_BUTTON_DOWN = KEVENT_JOY | 0x0005,
- KEVENT_JOY_DEVICE_REMOVED = KEVENT_JOY | 0x0006,
- KEVENT_JOY_DEVICE_ADDED = KEVENT_JOY | 0x0007,
- KEVENT_JOY_BATTERY = KEVENT_JOY | 0x0008,
- KEVENT_CTLR = _KIT_INC_ETYPE(KEVENT_JOY), //Event_GameController
- KEVENT_CTLR_AXIS = KEVENT_CTLR | 0x0001,
- KEVENT_CTLR_BUTTON_UP = KEVENT_CTLR | 0x0002,
- KEVENT_CTLR_BUTTON_DOWN = KEVENT_CTLR | 0x0003,
- KEVENT_CTLR_DEVICE_REMOVED = KEVENT_CTLR | 0x0004,
- KEVENT_CTLR_DEVICE_ADDED = KEVENT_CTLR | 0x0005,
- KEVENT_CTLR_DEVICE_REMAPPED = KEVENT_CTLR | 0x0006,
- KEVENT_CTLR_TOUCHPAD_UP = KEVENT_CTLR | 0x0007,
- KEVENT_CTLR_TOUCHPAD_DOWN = KEVENT_CTLR | 0x0008,
- KEVENT_CTLR_TOUCHPAD_MOVED = KEVENT_CTLR | 0x0009,
- KEVENT_CTLR_SENSOR = KEVENT_CTLR | 0x000A,
- KEVENT_ADEV = _KIT_INC_ETYPE(KEVENT_CTLR), //Event_AudioDevice
- KEVENT_ADEV_ADDED = KEVENT_ADEV | 0x0001,
- KEVENT_ADEV_REMOVED = KEVENT_ADEV | 0x0002,
- KEVENT_DROP = _KIT_INC_ETYPE(KEVENT_ADEV), //Event_Drop
- KEVENT_DROP_FILE = KEVENT_DROP | 0x0001, //system requests a file to open
- KEVENT_DROP_TEXT = KEVENT_DROP | 0x0002, //text/plain drag-and-drop event
- KEVENT_DROP_BEGIN = KEVENT_DROP | 0x0003, //new set of drops beginning (filePath=nullptr)
- KEVENT_DROP_COMPLETE = KEVENT_DROP | 0x0004, //current set of drops complete (filePath=nullptr)
- KEVENT_QUIT = _KIT_INC_ETYPE(KEVENT_DROP), //Event_Quit
- KEVENT_USER = _KIT_INC_ETYPE(KEVENT_QUIT), //Event_User
- KEVENT_RENDER = _KIT_INC_ETYPE(KEVENT_USER), //(N/A)
- KEVENT_RENDER_TARGETS_RESET = KEVENT_RENDER | 0x0001,
- KEVENT_RENDER_DEVICE_RESET = KEVENT_RENDER | 0x0002,
- KEVENT_CLIPBOARDUPDATE = _KIT_INC_ETYPE(KEVENT_RENDER), //(N/A)
- KEVENT_UNKNOWN = 0xFFFFFFFF,
- NUM_KEVENT_TYPES = KEVENT_CLIPBOARDUPDATE >> 16,
- };
- /*+KEVENT_COMMON+*/
- struct Event_Common { //8B
- u32 type;
- u32 timestamp; //in milliseconds, same as getMS_32
- };
- /*-KEVENT_COMMON-*/
- /*+KEVENT_DISPLAY+*/
- struct Event_Display { //16B
- u32 type;
- u32 timestamp;
- u32 id; //index of associated display
- s32 data;
- };
- /*-KEVENT_DISPLAY-*/
- /*+KEVENT_WIN+*/
- enum Event_Window_HitTestEnum {
- WIN_HITTEST_NORMAL, // Region is normal. No special properties.
- WIN_HITTEST_DRAGGABLE, // Region can drag entire window.
- WIN_HITTEST_RESIZE_TOPLEFT,
- WIN_HITTEST_RESIZE_TOP,
- WIN_HITTEST_RESIZE_TOPRIGHT,
- WIN_HITTEST_RESIZE_RIGHT,
- WIN_HITTEST_RESIZE_BOTTOMRIGHT,
- WIN_HITTEST_RESIZE_BOTTOM,
- WIN_HITTEST_RESIZE_BOTTOMLEFT,
- WIN_HITTEST_RESIZE_LEFT
- };
- struct Event_Window { //24B
- u32 type;
- u32 timestamp;
- u32 id; //index of associated window
- u32 _padding32;
- union { s32 data1, x; };
- union { s32 data2, y; };
- };
- /*-KEVENT_WIN-*/
- /*+KEVENT_KEY+*/
- //(these enums are mostly ripped directly from
- //SDL2's header files! please don't sue me! D:)
- enum Event_Key_PhysicalEnum { //aka scancodes
- PKEY_UNKNOWN = 0,
- /**
- * \name Usage page 0x07
- *
- * These values are from usage page 0x07 (USB keyboard page).
- */
- /* @{ */
- PKEY_A = 4,
- PKEY_B = 5,
- PKEY_C = 6,
- PKEY_D = 7,
- PKEY_E = 8,
- PKEY_F = 9,
- PKEY_G = 10,
- PKEY_H = 11,
- PKEY_I = 12,
- PKEY_J = 13,
- PKEY_K = 14,
- PKEY_L = 15,
- PKEY_M = 16,
- PKEY_N = 17,
- PKEY_O = 18,
- PKEY_P = 19,
- PKEY_Q = 20,
- PKEY_R = 21,
- PKEY_S = 22,
- PKEY_T = 23,
- PKEY_U = 24,
- PKEY_V = 25,
- PKEY_W = 26,
- PKEY_X = 27,
- PKEY_Y = 28,
- PKEY_Z = 29,
- PKEY_1 = 30,
- PKEY_2 = 31,
- PKEY_3 = 32,
- PKEY_4 = 33,
- PKEY_5 = 34,
- PKEY_6 = 35,
- PKEY_7 = 36,
- PKEY_8 = 37,
- PKEY_9 = 38,
- PKEY_0 = 39,
- PKEY_RETURN = 40,
- PKEY_ESCAPE = 41,
- PKEY_BACKSPACE = 42,
- PKEY_TAB = 43,
- PKEY_SPACE = 44,
- PKEY_MINUS = 45,
- PKEY_EQUALS = 46,
- PKEY_LEFTBRACKET = 47,
- PKEY_RIGHTBRACKET = 48,
- PKEY_BACKSLASH = 49, /**< Located at the lower left of the return
- * key on ISO keyboards and at the right end
- * of the QWERTY row on ANSI keyboards.
- * Produces REVERSE SOLIDUS (backslash) and
- * VERTICAL LINE in a US layout, REVERSE
- * SOLIDUS and VERTICAL LINE in a UK Mac
- * layout, NUMBER SIGN and TILDE in a UK
- * Windows layout, DOLLAR SIGN and POUND SIGN
- * in a Swiss German layout, NUMBER SIGN and
- * APOSTROPHE in a German layout, GRAVE
- * ACCENT and POUND SIGN in a French Mac
- * layout, and ASTERISK and MICRO SIGN in a
- * French Windows layout.
- */
- PKEY_NONUSHASH = 50, /**< ISO USB keyboards actually use this code
- * instead of 49 for the same key, but all
- * OSes I've seen treat the two codes
- * identically. So, as an implementor, unless
- * your keyboard generates both of those
- * codes and your OS treats them differently,
- * you should generate PKEY_BACKSLASH
- * instead of this code. As a user, you
- * should not rely on this code because SDL
- * will never generate it with most (all?)
- * keyboards.
- */
- PKEY_SEMICOLON = 51,
- PKEY_APOSTROPHE = 52,
- PKEY_GRAVE = 53, /**< Located in the top left corner (on both ANSI
- * and ISO keyboards). Produces GRAVE ACCENT and
- * TILDE in a US Windows layout and in US and UK
- * Mac layouts on ANSI keyboards, GRAVE ACCENT
- * and NOT SIGN in a UK Windows layout, SECTION
- * SIGN and PLUS-MINUS SIGN in US and UK Mac
- * layouts on ISO keyboards, SECTION SIGN and
- * DEGREE SIGN in a Swiss German layout (Mac:
- * only on ISO keyboards), CIRCUMFLEX ACCENT and
- * DEGREE SIGN in a German layout (Mac: only on
- * ISO keyboards), SUPERSCRIPT TWO and TILDE in a
- * French Windows layout, COMMERCIAL AT and
- * NUMBER SIGN in a French Mac layout on ISO
- * keyboards, and LESS-THAN SIGN and GREATER-THAN
- * SIGN in a Swiss German, German, or French Mac
- * layout on ANSI keyboards.
- */
- PKEY_COMMA = 54,
- PKEY_PERIOD = 55,
- PKEY_SLASH = 56,
- PKEY_CAPSLOCK = 57,
- PKEY_F1 = 58,
- PKEY_F2 = 59,
- PKEY_F3 = 60,
- PKEY_F4 = 61,
- PKEY_F5 = 62,
- PKEY_F6 = 63,
- PKEY_F7 = 64,
- PKEY_F8 = 65,
- PKEY_F9 = 66,
- PKEY_F10 = 67,
- PKEY_F11 = 68,
- PKEY_F12 = 69,
- PKEY_PRINTSCREEN = 70,
- PKEY_SCROLLLOCK = 71,
- PKEY_PAUSE = 72,
- PKEY_INSERT = 73, /**< insert on PC, help on some Mac keyboards (but
- does send code 73, not 117) */
- PKEY_HOME = 74,
- PKEY_PAGEUP = 75,
- PKEY_DELETE = 76,
- PKEY_END = 77,
- PKEY_PAGEDOWN = 78,
- PKEY_RIGHT = 79,
- PKEY_LEFT = 80,
- PKEY_DOWN = 81,
- PKEY_UP = 82,
- PKEY_NUMLOCKCLEAR = 83, /**< num lock on PC, clear on Mac keyboards */
- PKEY_KP_DIVIDE = 84,
- PKEY_KP_MULTIPLY = 85,
- PKEY_KP_MINUS = 86,
- PKEY_KP_PLUS = 87,
- PKEY_KP_ENTER = 88,
- PKEY_KP_1 = 89,
- PKEY_KP_2 = 90,
- PKEY_KP_3 = 91,
- PKEY_KP_4 = 92,
- PKEY_KP_5 = 93,
- PKEY_KP_6 = 94,
- PKEY_KP_7 = 95,
- PKEY_KP_8 = 96,
- PKEY_KP_9 = 97,
- PKEY_KP_0 = 98,
- PKEY_KP_PERIOD = 99,
- PKEY_NONUSBACKSLASH = 100, /**< This is the additional key that ISO
- * keyboards have over ANSI ones,
- * located between left shift and Y.
- * Produces GRAVE ACCENT and TILDE in a
- * US or UK Mac layout, REVERSE SOLIDUS
- * (backslash) and VERTICAL LINE in a
- * US or UK Windows layout, and
- * LESS-THAN SIGN and GREATER-THAN SIGN
- * in a Swiss German, German, or French
- * layout. */
- PKEY_APPLICATION = 101, /**< windows contextual menu, compose */
- PKEY_POWER = 102, /**< The USB document says this is a status flag,
- * not a physical key - but some Mac keyboards
- * do have a power key. */
- PKEY_KP_EQUALS = 103,
- PKEY_F13 = 104,
- PKEY_F14 = 105,
- PKEY_F15 = 106,
- PKEY_F16 = 107,
- PKEY_F17 = 108,
- PKEY_F18 = 109,
- PKEY_F19 = 110,
- PKEY_F20 = 111,
- PKEY_F21 = 112,
- PKEY_F22 = 113,
- PKEY_F23 = 114,
- PKEY_F24 = 115,
- PKEY_EXECUTE = 116,
- PKEY_HELP = 117, /**< AL Integrated Help Center */
- PKEY_MENU = 118, /**< Menu (show menu) */
- PKEY_SELECT = 119,
- PKEY_STOP = 120, /**< AC Stop */
- PKEY_AGAIN = 121, /**< AC Redo/Repeat */
- PKEY_UNDO = 122, /**< AC Undo */
- PKEY_CUT = 123, /**< AC Cut */
- PKEY_COPY = 124, /**< AC Copy */
- PKEY_PASTE = 125, /**< AC Paste */
- PKEY_FIND = 126, /**< AC Find */
- PKEY_MUTE = 127,
- PKEY_VOLUMEUP = 128,
- PKEY_VOLUMEDOWN = 129,
- /* not sure whether there's a reason to enable these */
- /* PKEY_LOCKINGCAPSLOCK = 130, */
- /* PKEY_LOCKINGNUMLOCK = 131, */
- /* PKEY_LOCKINGSCROLLLOCK = 132, */
- PKEY_KP_COMMA = 133,
- PKEY_KP_EQUALSAS400 = 134,
- PKEY_INTERNATIONAL1 = 135, /**< used on Asian keyboards, see
- footnotes in USB doc */
- PKEY_INTERNATIONAL2 = 136,
- PKEY_INTERNATIONAL3 = 137, /**< Yen */
- PKEY_INTERNATIONAL4 = 138,
- PKEY_INTERNATIONAL5 = 139,
- PKEY_INTERNATIONAL6 = 140,
- PKEY_INTERNATIONAL7 = 141,
- PKEY_INTERNATIONAL8 = 142,
- PKEY_INTERNATIONAL9 = 143,
- PKEY_LANG1 = 144, /**< Hangul/English toggle */
- PKEY_LANG2 = 145, /**< Hanja conversion */
- PKEY_LANG3 = 146, /**< Katakana */
- PKEY_LANG4 = 147, /**< Hiragana */
- PKEY_LANG5 = 148, /**< Zenkaku/Hankaku */
- PKEY_LANG6 = 149, /**< reserved */
- PKEY_LANG7 = 150, /**< reserved */
- PKEY_LANG8 = 151, /**< reserved */
- PKEY_LANG9 = 152, /**< reserved */
- PKEY_ALTERASE = 153, /**< Erase-Eaze */
- PKEY_SYSREQ = 154,
- PKEY_CANCEL = 155, /**< AC Cancel */
- PKEY_CLEAR = 156,
- PKEY_PRIOR = 157,
- PKEY_RETURN2 = 158,
- PKEY_SEPARATOR = 159,
- PKEY_OUT = 160,
- PKEY_OPER = 161,
- PKEY_CLEARAGAIN = 162,
- PKEY_CRSEL = 163,
- PKEY_EXSEL = 164,
- PKEY_KP_00 = 176,
- PKEY_KP_000 = 177,
- PKEY_THOUSANDSSEPARATOR = 178,
- PKEY_DECIMALSEPARATOR = 179,
- PKEY_CURRENCYUNIT = 180,
- PKEY_CURRENCYSUBUNIT = 181,
- PKEY_KP_LEFTPAREN = 182,
- PKEY_KP_RIGHTPAREN = 183,
- PKEY_KP_LEFTBRACE = 184,
- PKEY_KP_RIGHTBRACE = 185,
- PKEY_KP_TAB = 186,
- PKEY_KP_BACKSPACE = 187,
- PKEY_KP_A = 188,
- PKEY_KP_B = 189,
- PKEY_KP_C = 190,
- PKEY_KP_D = 191,
- PKEY_KP_E = 192,
- PKEY_KP_F = 193,
- PKEY_KP_XOR = 194,
- PKEY_KP_POWER = 195,
- PKEY_KP_PERCENT = 196,
- PKEY_KP_LESS = 197,
- PKEY_KP_GREATER = 198,
- PKEY_KP_AMPERSAND = 199,
- PKEY_KP_DBLAMPERSAND = 200,
- PKEY_KP_VERTICALBAR = 201,
- PKEY_KP_DBLVERTICALBAR = 202,
- PKEY_KP_COLON = 203,
- PKEY_KP_HASH = 204,
- PKEY_KP_SPACE = 205,
- PKEY_KP_AT = 206,
- PKEY_KP_EXCLAM = 207,
- PKEY_KP_MEMSTORE = 208,
- PKEY_KP_MEMRECALL = 209,
- PKEY_KP_MEMCLEAR = 210,
- PKEY_KP_MEMADD = 211,
- PKEY_KP_MEMSUBTRACT = 212,
- PKEY_KP_MEMMULTIPLY = 213,
- PKEY_KP_MEMDIVIDE = 214,
- PKEY_KP_PLUSMINUS = 215,
- PKEY_KP_CLEAR = 216,
- PKEY_KP_CLEARENTRY = 217,
- PKEY_KP_BINARY = 218,
- PKEY_KP_OCTAL = 219,
- PKEY_KP_DECIMAL = 220,
- PKEY_KP_HEXADECIMAL = 221,
- PKEY_LCTRL = 224,
- PKEY_LSHIFT = 225,
- PKEY_LALT = 226, /**< alt, option */
- PKEY_LGUI = 227, /**< windows, command (apple), meta */
- PKEY_RCTRL = 228,
- PKEY_RSHIFT = 229,
- PKEY_RALT = 230, /**< alt gr, option */
- PKEY_RGUI = 231, /**< windows, command (apple), meta */
- PKEY_MODE = 257, /**< I'm not sure if this is really not covered
- * by any of the above, but since there's a
- * special KEYMOD_MODE for it I'm adding it here
- */
- /* @} *//* Usage page 0x07 */
- /**
- * \name Usage page 0x0C
- *
- * These values are mapped from usage page 0x0C (USB consumer page).
- * See https://usb.org/sites/default/files/hut1_2.pdf
- *
- * There are way more keys in the spec than we can represent in the
- * current scancode range, so pick the ones that commonly come up in
- * real world usage.
- */
- /* @{ */
- PKEY_AUDIONEXT = 258,
- PKEY_AUDIOPREV = 259,
- PKEY_AUDIOSTOP = 260,
- PKEY_AUDIOPLAY = 261,
- PKEY_AUDIOMUTE = 262,
- PKEY_MEDIASELECT = 263,
- PKEY_WWW = 264, /**< AL Internet Browser */
- PKEY_MAIL = 265,
- PKEY_CALCULATOR = 266, /**< AL Calculator */
- PKEY_COMPUTER = 267,
- PKEY_AC_SEARCH = 268, /**< AC Search */
- PKEY_AC_HOME = 269, /**< AC Home */
- PKEY_AC_BACK = 270, /**< AC Back */
- PKEY_AC_FORWARD = 271, /**< AC Forward */
- PKEY_AC_STOP = 272, /**< AC Stop */
- PKEY_AC_REFRESH = 273, /**< AC Refresh */
- PKEY_AC_BOOKMARKS = 274, /**< AC Bookmarks */
- /* @} *//* Usage page 0x0C */
- /**
- * \name Walther keys
- *
- * These are values that Christian Walther added (for mac keyboard?).
- */
- /* @{ */
- PKEY_BRIGHTNESSDOWN = 275,
- PKEY_BRIGHTNESSUP = 276,
- PKEY_DISPLAYSWITCH = 277, /**< display mirroring/dual display
- switch, video mode switch */
- PKEY_KBDILLUMTOGGLE = 278,
- PKEY_KBDILLUMDOWN = 279,
- PKEY_KBDILLUMUP = 280,
- PKEY_EJECT = 281,
- PKEY_SLEEP = 282, /**< SC System Sleep */
- PKEY_APP1 = 283,
- PKEY_APP2 = 284,
- /* @} *//* Walther keys */
- /**
- * \name Usage page 0x0C (additional media keys)
- *
- * These values are mapped from usage page 0x0C (USB consumer page).
- */
- /* @{ */
- PKEY_AUDIOREWIND = 285,
- PKEY_AUDIOFASTFORWARD = 286,
- /* @} *//* Usage page 0x0C (additional media keys) */
- /**
- * \name Mobile keys
- *
- * These are values that are often used on mobile phones.
- */
- /* @{ */
- PKEY_SOFTLEFT = 287, /**< Usually situated below the display on phones and
- used as a multi-function feature key for selecting
- a software defined function shown on the bottom left
- of the display. */
- PKEY_SOFTRIGHT = 288, /**< Usually situated below the display on phones and
- used as a multi-function feature key for selecting
- a software defined function shown on the bottom right
- of the display. */
- PKEY_CALL = 289, /**< Used for accepting phone calls. */
- PKEY_ENDCALL = 290, /**< Used for rejecting phone calls. */
- /* @} *//* Mobile keys */
- /* Add any other keys here. */
- KIT_NUM_PKEYS = 512 /**< not a key, just marks the number of scancodes
- for array bounds */
- };
- #define _KIT_PKEY_MASK (1<<30)
- #define KIT_PKEY_TO_VKEY(X) (X | _KIT_PKEY_MASK)
- enum Event_Key_VirtualEnum {
- VKEY_UNKNOWN = 0,
- VKEY_RETURN = '\r',
- VKEY_ESCAPE = '\x1B',
- VKEY_BACKSPACE = '\b',
- VKEY_TAB = '\t',
- VKEY_SPACE = ' ',
- VKEY_EXCLAIM = '!',
- VKEY_QUOTEDBL = '"',
- VKEY_HASH = '#',
- VKEY_PERCENT = '%',
- VKEY_DOLLAR = '$',
- VKEY_AMPERSAND = '&',
- VKEY_QUOTE = '\'',
- VKEY_LEFTPAREN = '(',
- VKEY_RIGHTPAREN = ')',
- VKEY_ASTERISK = '*',
- VKEY_PLUS = '+',
- VKEY_COMMA = ',',
- VKEY_MINUS = '-',
- VKEY_PERIOD = '.',
- VKEY_SLASH = '/',
- VKEY_0 = '0',
- VKEY_1 = '1',
- VKEY_2 = '2',
- VKEY_3 = '3',
- VKEY_4 = '4',
- VKEY_5 = '5',
- VKEY_6 = '6',
- VKEY_7 = '7',
- VKEY_8 = '8',
- VKEY_9 = '9',
- VKEY_COLON = ':',
- VKEY_SEMICOLON = ';',
- VKEY_LESS = '<',
- VKEY_EQUALS = '=',
- VKEY_GREATER = '>',
- VKEY_QUESTION = '?',
- VKEY_AT = '@',
- /*
- Skip uppercase letters
- */
- VKEY_LEFTBRACKET = '[',
- VKEY_BACKSLASH = '\\',
- VKEY_RIGHTBRACKET = ']',
- VKEY_CARET = '^',
- VKEY_UNDERSCORE = '_',
- VKEY_BACKQUOTE = '`',
- VKEY_a = 'a',
- VKEY_b = 'b',
- VKEY_c = 'c',
- VKEY_d = 'd',
- VKEY_e = 'e',
- VKEY_f = 'f',
- VKEY_g = 'g',
- VKEY_h = 'h',
- VKEY_i = 'i',
- VKEY_j = 'j',
- VKEY_k = 'k',
- VKEY_l = 'l',
- VKEY_m = 'm',
- VKEY_n = 'n',
- VKEY_o = 'o',
- VKEY_p = 'p',
- VKEY_q = 'q',
- VKEY_r = 'r',
- VKEY_s = 's',
- VKEY_t = 't',
- VKEY_u = 'u',
- VKEY_v = 'v',
- VKEY_w = 'w',
- VKEY_x = 'x',
- VKEY_y = 'y',
- VKEY_z = 'z',
- VKEY_CAPSLOCK = KIT_PKEY_TO_VKEY(PKEY_CAPSLOCK),
- VKEY_F1 = KIT_PKEY_TO_VKEY(PKEY_F1),
- VKEY_F2 = KIT_PKEY_TO_VKEY(PKEY_F2),
- VKEY_F3 = KIT_PKEY_TO_VKEY(PKEY_F3),
- VKEY_F4 = KIT_PKEY_TO_VKEY(PKEY_F4),
- VKEY_F5 = KIT_PKEY_TO_VKEY(PKEY_F5),
- VKEY_F6 = KIT_PKEY_TO_VKEY(PKEY_F6),
- VKEY_F7 = KIT_PKEY_TO_VKEY(PKEY_F7),
- VKEY_F8 = KIT_PKEY_TO_VKEY(PKEY_F8),
- VKEY_F9 = KIT_PKEY_TO_VKEY(PKEY_F9),
- VKEY_F10 = KIT_PKEY_TO_VKEY(PKEY_F10),
- VKEY_F11 = KIT_PKEY_TO_VKEY(PKEY_F11),
- VKEY_F12 = KIT_PKEY_TO_VKEY(PKEY_F12),
- VKEY_PRINTSCREEN = KIT_PKEY_TO_VKEY(PKEY_PRINTSCREEN),
- VKEY_SCROLLLOCK = KIT_PKEY_TO_VKEY(PKEY_SCROLLLOCK),
- VKEY_PAUSE = KIT_PKEY_TO_VKEY(PKEY_PAUSE),
- VKEY_INSERT = KIT_PKEY_TO_VKEY(PKEY_INSERT),
- VKEY_HOME = KIT_PKEY_TO_VKEY(PKEY_HOME),
- VKEY_PAGEUP = KIT_PKEY_TO_VKEY(PKEY_PAGEUP),
- VKEY_DELETE = '\x7F',
- VKEY_END = KIT_PKEY_TO_VKEY(PKEY_END),
- VKEY_PAGEDOWN = KIT_PKEY_TO_VKEY(PKEY_PAGEDOWN),
- VKEY_RIGHT = KIT_PKEY_TO_VKEY(PKEY_RIGHT),
- VKEY_LEFT = KIT_PKEY_TO_VKEY(PKEY_LEFT),
- VKEY_DOWN = KIT_PKEY_TO_VKEY(PKEY_DOWN),
- VKEY_UP = KIT_PKEY_TO_VKEY(PKEY_UP),
- VKEY_NUMLOCKCLEAR = KIT_PKEY_TO_VKEY(PKEY_NUMLOCKCLEAR),
- VKEY_KP_DIVIDE = KIT_PKEY_TO_VKEY(PKEY_KP_DIVIDE),
- VKEY_KP_MULTIPLY = KIT_PKEY_TO_VKEY(PKEY_KP_MULTIPLY),
- VKEY_KP_MINUS = KIT_PKEY_TO_VKEY(PKEY_KP_MINUS),
- VKEY_KP_PLUS = KIT_PKEY_TO_VKEY(PKEY_KP_PLUS),
- VKEY_KP_ENTER = KIT_PKEY_TO_VKEY(PKEY_KP_ENTER),
- VKEY_KP_1 = KIT_PKEY_TO_VKEY(PKEY_KP_1),
- VKEY_KP_2 = KIT_PKEY_TO_VKEY(PKEY_KP_2),
- VKEY_KP_3 = KIT_PKEY_TO_VKEY(PKEY_KP_3),
- VKEY_KP_4 = KIT_PKEY_TO_VKEY(PKEY_KP_4),
- VKEY_KP_5 = KIT_PKEY_TO_VKEY(PKEY_KP_5),
- VKEY_KP_6 = KIT_PKEY_TO_VKEY(PKEY_KP_6),
- VKEY_KP_7 = KIT_PKEY_TO_VKEY(PKEY_KP_7),
- VKEY_KP_8 = KIT_PKEY_TO_VKEY(PKEY_KP_8),
- VKEY_KP_9 = KIT_PKEY_TO_VKEY(PKEY_KP_9),
- VKEY_KP_0 = KIT_PKEY_TO_VKEY(PKEY_KP_0),
- VKEY_KP_PERIOD = KIT_PKEY_TO_VKEY(PKEY_KP_PERIOD),
- VKEY_APPLICATION = KIT_PKEY_TO_VKEY(PKEY_APPLICATION),
- VKEY_POWER = KIT_PKEY_TO_VKEY(PKEY_POWER),
- VKEY_KP_EQUALS = KIT_PKEY_TO_VKEY(PKEY_KP_EQUALS),
- VKEY_F13 = KIT_PKEY_TO_VKEY(PKEY_F13),
- VKEY_F14 = KIT_PKEY_TO_VKEY(PKEY_F14),
- VKEY_F15 = KIT_PKEY_TO_VKEY(PKEY_F15),
- VKEY_F16 = KIT_PKEY_TO_VKEY(PKEY_F16),
- VKEY_F17 = KIT_PKEY_TO_VKEY(PKEY_F17),
- VKEY_F18 = KIT_PKEY_TO_VKEY(PKEY_F18),
- VKEY_F19 = KIT_PKEY_TO_VKEY(PKEY_F19),
- VKEY_F20 = KIT_PKEY_TO_VKEY(PKEY_F20),
- VKEY_F21 = KIT_PKEY_TO_VKEY(PKEY_F21),
- VKEY_F22 = KIT_PKEY_TO_VKEY(PKEY_F22),
- VKEY_F23 = KIT_PKEY_TO_VKEY(PKEY_F23),
- VKEY_F24 = KIT_PKEY_TO_VKEY(PKEY_F24),
- VKEY_EXECUTE = KIT_PKEY_TO_VKEY(PKEY_EXECUTE),
- VKEY_HELP = KIT_PKEY_TO_VKEY(PKEY_HELP),
- VKEY_MENU = KIT_PKEY_TO_VKEY(PKEY_MENU),
- VKEY_SELECT = KIT_PKEY_TO_VKEY(PKEY_SELECT),
- VKEY_STOP = KIT_PKEY_TO_VKEY(PKEY_STOP),
- VKEY_AGAIN = KIT_PKEY_TO_VKEY(PKEY_AGAIN),
- VKEY_UNDO = KIT_PKEY_TO_VKEY(PKEY_UNDO),
- VKEY_CUT = KIT_PKEY_TO_VKEY(PKEY_CUT),
- VKEY_COPY = KIT_PKEY_TO_VKEY(PKEY_COPY),
- VKEY_PASTE = KIT_PKEY_TO_VKEY(PKEY_PASTE),
- VKEY_FIND = KIT_PKEY_TO_VKEY(PKEY_FIND),
- VKEY_MUTE = KIT_PKEY_TO_VKEY(PKEY_MUTE),
- VKEY_VOLUMEUP = KIT_PKEY_TO_VKEY(PKEY_VOLUMEUP),
- VKEY_VOLUMEDOWN = KIT_PKEY_TO_VKEY(PKEY_VOLUMEDOWN),
- VKEY_KP_COMMA = KIT_PKEY_TO_VKEY(PKEY_KP_COMMA),
- VKEY_KP_EQUALSAS400 = KIT_PKEY_TO_VKEY(PKEY_KP_EQUALSAS400),
- VKEY_ALTERASE = KIT_PKEY_TO_VKEY(PKEY_ALTERASE),
- VKEY_SYSREQ = KIT_PKEY_TO_VKEY(PKEY_SYSREQ),
- VKEY_CANCEL = KIT_PKEY_TO_VKEY(PKEY_CANCEL),
- VKEY_CLEAR = KIT_PKEY_TO_VKEY(PKEY_CLEAR),
- VKEY_PRIOR = KIT_PKEY_TO_VKEY(PKEY_PRIOR),
- VKEY_RETURN2 = KIT_PKEY_TO_VKEY(PKEY_RETURN2),
- VKEY_SEPARATOR = KIT_PKEY_TO_VKEY(PKEY_SEPARATOR),
- VKEY_OUT = KIT_PKEY_TO_VKEY(PKEY_OUT),
- VKEY_OPER = KIT_PKEY_TO_VKEY(PKEY_OPER),
- VKEY_CLEARAGAIN = KIT_PKEY_TO_VKEY(PKEY_CLEARAGAIN),
- VKEY_CRSEL = KIT_PKEY_TO_VKEY(PKEY_CRSEL),
- VKEY_EXSEL = KIT_PKEY_TO_VKEY(PKEY_EXSEL),
- VKEY_KP_00 = KIT_PKEY_TO_VKEY(PKEY_KP_00),
- VKEY_KP_000 = KIT_PKEY_TO_VKEY(PKEY_KP_000),
- VKEY_THOUSANDSSEPARATOR = KIT_PKEY_TO_VKEY(PKEY_THOUSANDSSEPARATOR),
- VKEY_DECIMALSEPARATOR = KIT_PKEY_TO_VKEY(PKEY_DECIMALSEPARATOR),
- VKEY_CURRENCYUNIT = KIT_PKEY_TO_VKEY(PKEY_CURRENCYUNIT),
- VKEY_CURRENCYSUBUNIT = KIT_PKEY_TO_VKEY(PKEY_CURRENCYSUBUNIT),
- VKEY_KP_LEFTPAREN = KIT_PKEY_TO_VKEY(PKEY_KP_LEFTPAREN),
- VKEY_KP_RIGHTPAREN = KIT_PKEY_TO_VKEY(PKEY_KP_RIGHTPAREN),
- VKEY_KP_LEFTBRACE = KIT_PKEY_TO_VKEY(PKEY_KP_LEFTBRACE),
- VKEY_KP_RIGHTBRACE = KIT_PKEY_TO_VKEY(PKEY_KP_RIGHTBRACE),
- VKEY_KP_TAB = KIT_PKEY_TO_VKEY(PKEY_KP_TAB),
- VKEY_KP_BACKSPACE = KIT_PKEY_TO_VKEY(PKEY_KP_BACKSPACE),
- VKEY_KP_A = KIT_PKEY_TO_VKEY(PKEY_KP_A),
- VKEY_KP_B = KIT_PKEY_TO_VKEY(PKEY_KP_B),
- VKEY_KP_C = KIT_PKEY_TO_VKEY(PKEY_KP_C),
- VKEY_KP_D = KIT_PKEY_TO_VKEY(PKEY_KP_D),
- VKEY_KP_E = KIT_PKEY_TO_VKEY(PKEY_KP_E),
- VKEY_KP_F = KIT_PKEY_TO_VKEY(PKEY_KP_F),
- VKEY_KP_XOR = KIT_PKEY_TO_VKEY(PKEY_KP_XOR),
- VKEY_KP_POWER = KIT_PKEY_TO_VKEY(PKEY_KP_POWER),
- VKEY_KP_PERCENT = KIT_PKEY_TO_VKEY(PKEY_KP_PERCENT),
- VKEY_KP_LESS = KIT_PKEY_TO_VKEY(PKEY_KP_LESS),
- VKEY_KP_GREATER = KIT_PKEY_TO_VKEY(PKEY_KP_GREATER),
- VKEY_KP_AMPERSAND = KIT_PKEY_TO_VKEY(PKEY_KP_AMPERSAND),
- VKEY_KP_DBLAMPERSAND = KIT_PKEY_TO_VKEY(PKEY_KP_DBLAMPERSAND),
- VKEY_KP_VERTICALBAR = KIT_PKEY_TO_VKEY(PKEY_KP_VERTICALBAR),
- VKEY_KP_DBLVERTICALBAR = KIT_PKEY_TO_VKEY(PKEY_KP_DBLVERTICALBAR),
- VKEY_KP_COLON = KIT_PKEY_TO_VKEY(PKEY_KP_COLON),
- VKEY_KP_HASH = KIT_PKEY_TO_VKEY(PKEY_KP_HASH),
- VKEY_KP_SPACE = KIT_PKEY_TO_VKEY(PKEY_KP_SPACE),
- VKEY_KP_AT = KIT_PKEY_TO_VKEY(PKEY_KP_AT),
- VKEY_KP_EXCLAM = KIT_PKEY_TO_VKEY(PKEY_KP_EXCLAM),
- VKEY_KP_MEMSTORE = KIT_PKEY_TO_VKEY(PKEY_KP_MEMSTORE),
- VKEY_KP_MEMRECALL = KIT_PKEY_TO_VKEY(PKEY_KP_MEMRECALL),
- VKEY_KP_MEMCLEAR = KIT_PKEY_TO_VKEY(PKEY_KP_MEMCLEAR),
- VKEY_KP_MEMADD = KIT_PKEY_TO_VKEY(PKEY_KP_MEMADD),
- VKEY_KP_MEMSUBTRACT = KIT_PKEY_TO_VKEY(PKEY_KP_MEMSUBTRACT),
- VKEY_KP_MEMMULTIPLY = KIT_PKEY_TO_VKEY(PKEY_KP_MEMMULTIPLY),
- VKEY_KP_MEMDIVIDE = KIT_PKEY_TO_VKEY(PKEY_KP_MEMDIVIDE),
- VKEY_KP_PLUSMINUS = KIT_PKEY_TO_VKEY(PKEY_KP_PLUSMINUS),
- VKEY_KP_CLEAR = KIT_PKEY_TO_VKEY(PKEY_KP_CLEAR),
- VKEY_KP_CLEARENTRY = KIT_PKEY_TO_VKEY(PKEY_KP_CLEARENTRY),
- VKEY_KP_BINARY = KIT_PKEY_TO_VKEY(PKEY_KP_BINARY),
- VKEY_KP_OCTAL = KIT_PKEY_TO_VKEY(PKEY_KP_OCTAL),
- VKEY_KP_DECIMAL = KIT_PKEY_TO_VKEY(PKEY_KP_DECIMAL),
- VKEY_KP_HEXADECIMAL = KIT_PKEY_TO_VKEY(PKEY_KP_HEXADECIMAL),
- VKEY_LCTRL = KIT_PKEY_TO_VKEY(PKEY_LCTRL),
- VKEY_LSHIFT = KIT_PKEY_TO_VKEY(PKEY_LSHIFT),
- VKEY_LALT = KIT_PKEY_TO_VKEY(PKEY_LALT),
- VKEY_LGUI = KIT_PKEY_TO_VKEY(PKEY_LGUI),
- VKEY_RCTRL = KIT_PKEY_TO_VKEY(PKEY_RCTRL),
- VKEY_RSHIFT = KIT_PKEY_TO_VKEY(PKEY_RSHIFT),
- VKEY_RALT = KIT_PKEY_TO_VKEY(PKEY_RALT),
- VKEY_RGUI = KIT_PKEY_TO_VKEY(PKEY_RGUI),
- VKEY_MODE = KIT_PKEY_TO_VKEY(PKEY_MODE),
- VKEY_AUDIONEXT = KIT_PKEY_TO_VKEY(PKEY_AUDIONEXT),
- VKEY_AUDIOPREV = KIT_PKEY_TO_VKEY(PKEY_AUDIOPREV),
- VKEY_AUDIOSTOP = KIT_PKEY_TO_VKEY(PKEY_AUDIOSTOP),
- VKEY_AUDIOPLAY = KIT_PKEY_TO_VKEY(PKEY_AUDIOPLAY),
- VKEY_AUDIOMUTE = KIT_PKEY_TO_VKEY(PKEY_AUDIOMUTE),
- VKEY_MEDIASELECT = KIT_PKEY_TO_VKEY(PKEY_MEDIASELECT),
- VKEY_WWW = KIT_PKEY_TO_VKEY(PKEY_WWW),
- VKEY_MAIL = KIT_PKEY_TO_VKEY(PKEY_MAIL),
- VKEY_CALCULATOR = KIT_PKEY_TO_VKEY(PKEY_CALCULATOR),
- VKEY_COMPUTER = KIT_PKEY_TO_VKEY(PKEY_COMPUTER),
- VKEY_AC_SEARCH = KIT_PKEY_TO_VKEY(PKEY_AC_SEARCH),
- VKEY_AC_HOME = KIT_PKEY_TO_VKEY(PKEY_AC_HOME),
- VKEY_AC_BACK = KIT_PKEY_TO_VKEY(PKEY_AC_BACK),
- VKEY_AC_FORWARD = KIT_PKEY_TO_VKEY(PKEY_AC_FORWARD),
- VKEY_AC_STOP = KIT_PKEY_TO_VKEY(PKEY_AC_STOP),
- VKEY_AC_REFRESH = KIT_PKEY_TO_VKEY(PKEY_AC_REFRESH),
- VKEY_AC_BOOKMARKS = KIT_PKEY_TO_VKEY(PKEY_AC_BOOKMARKS),
- VKEY_BRIGHTNESSDOWN = KIT_PKEY_TO_VKEY(PKEY_BRIGHTNESSDOWN),
- VKEY_BRIGHTNESSUP = KIT_PKEY_TO_VKEY(PKEY_BRIGHTNESSUP),
- VKEY_DISPLAYSWITCH = KIT_PKEY_TO_VKEY(PKEY_DISPLAYSWITCH),
- VKEY_KBDILLUMTOGGLE = KIT_PKEY_TO_VKEY(PKEY_KBDILLUMTOGGLE),
- VKEY_KBDILLUMDOWN = KIT_PKEY_TO_VKEY(PKEY_KBDILLUMDOWN),
- VKEY_KBDILLUMUP = KIT_PKEY_TO_VKEY(PKEY_KBDILLUMUP),
- VKEY_EJECT = KIT_PKEY_TO_VKEY(PKEY_EJECT),
- VKEY_SLEEP = KIT_PKEY_TO_VKEY(PKEY_SLEEP),
- VKEY_APP1 = KIT_PKEY_TO_VKEY(PKEY_APP1),
- VKEY_APP2 = KIT_PKEY_TO_VKEY(PKEY_APP2),
- VKEY_AUDIOREWIND = KIT_PKEY_TO_VKEY(PKEY_AUDIOREWIND),
- VKEY_AUDIOFASTFORWARD = KIT_PKEY_TO_VKEY(PKEY_AUDIOFASTFORWARD),
- VKEY_SOFTLEFT = KIT_PKEY_TO_VKEY(PKEY_SOFTLEFT),
- VKEY_SOFTRIGHT = KIT_PKEY_TO_VKEY(PKEY_SOFTRIGHT),
- VKEY_CALL = KIT_PKEY_TO_VKEY(PKEY_CALL),
- VKEY_ENDCALL = KIT_PKEY_TO_VKEY(PKEY_ENDCALL),
- };
- enum Event_Key_ModifierFlagsEnum {
- KEYMOD_NONE = 0x0000,
- KEYMOD_LSHIFT = 0x0001,
- KEYMOD_RSHIFT = 0x0002,
- //(4 bits are skipped here)
- KEYMOD_LCTRL = 0x0040,
- KEYMOD_RCTRL = 0x0080,
- KEYMOD_LALT = 0x0100,
- KEYMOD_RALT = 0x0200,
- KEYMOD_LGUI = 0x0400,
- KEYMOD_RGUI = 0x0800,
- KEYMOD_LWIN = KEYMOD_LGUI,
- KEYMOD_RWIN = KEYMOD_RGUI,
- KEYMOD_NUM = 0x1000, //num lock
- KEYMOD_CAPS = 0x2000, //caps lock
- KEYMOD_MODE = 0x4000, //altgraph
- KEYMOD_SCROLL = 0x8000, //scroll lock
- KEYMOD_CTRL = ( KEYMOD_LCTRL | KEYMOD_RCTRL ),
- KEYMOD_SHIFT = ( KEYMOD_LSHIFT | KEYMOD_RSHIFT ),
- KEYMOD_ALT = ( KEYMOD_LALT | KEYMOD_RALT ),
- KEYMOD_GUI = ( KEYMOD_LGUI | KEYMOD_RGUI ),
- KEYMOD_WIN = ( KEYMOD_LWIN | KEYMOD_RWIN ),
- };
- union Event_Key_Mod { //2B
- struct {
- //low byte
- u16 lshift : 1;
- u16 rshift : 1;
- u16 _unused : 4;
- u16 lctrl : 1;
- u16 rctrl : 1;
- //high byte
- u16 lalt : 1;
- u16 ralt : 1;
- u16 lgui : 1;
- u16 rgui : 1;
- u16 num : 1;
- u16 caps : 1;
- u16 mode : 1;
- u16 scroll : 1;
- };
- u16 all;
- };
- struct Event_Key_Sym { //8B
- s32 vkey; //virtual key code
- u16 pkey; //physical key code (scancode)
- union { //some combination of Event_Key_ModifiersEnum flags (if any)
- u16 kmods;
- Event_Key_Mod kmod;
- };
- };
- struct Event_Key { //24B
- u32 type;
- u32 timestamp;
- u32 window; //window with keyboard focus, if any
- bool pressed; //key was released otherwise
- bool repeat; //'is this the result of holding a key down?' (useful for text input!)
- u16 _padding16;
- union {
- struct {
- s32 vkey; //virtual key code
- u16 pkey; //physical key code (scancode)
- u16 kmods; //some combination of Event_Key_ModifiersEnum flags (if any)
- };
- Event_Key_Sym sym;
- };
- };
- /*-KEVENT_KEY-*/
- /*+KEVENT_MOUSE+*/
- //for KEVENT_MOUSE_MOVED events, multiple of these
- //flags can be active simultaneously, whereas
- //for MOUSE_UP/DOWN events, only <=1 can be set
- enum Event_Mouse_ButtonFlagsEnum {
- MOUSE_BUTTON_LEFT = 0x01,
- MOUSE_BUTTON_MIDDLE = 0x02,
- MOUSE_BUTTON_RIGHT = 0x04,
- MOUSE_BUTTON_X1 = 0x08,
- MOUSE_BUTTON_X2 = 0x10,
- };
- //(internal note: mouse instance IDs are ignored)
- struct Event_Mouse { //40B
- u32 type;
- u32 timestamp;
- u32 window; //current window with mouse focus, if any
- u8 button; //which mouse button(s) are pressed (see Event_Mouse_ButtonFlagsEnum)
- bool pressed; //otherwise button was released
- bool dblClick; //'is double click?' (single click otherwise);
- bool flipped; //indicates whether x or y are flipped during mouse wheel events (*=-1 to flip back)
- s32 x, y; //coordinates, relative to window
- s32 dx, dy; //delta x&y (coordinates relative to last recorded position)
- f32 pdx, pdy; //precise delta x&y (only set by MOUSE_WHEEL events)
- };
- /*-KEVENT_MOUSE-*/
- /*+KEVENT_JOY+*/
- enum Event_Joystick_BatteryEnum {
- JOY_BATTERY_UNKNOWN = -1,
- JOY_BATTERY_EMPTY, // <= 5%
- JOY_BATTERY_LOW, // <= 20%
- JOY_BATTERY_MEDIUM, // <= 70%
- JOY_BATTERY_FULL, // <= 100%
- JOY_BATTERY_WIRED,
- JOY_BATTERY_MAX,
- };
- enum Event_Joystick_HatEnum {
- JOY_HAT_CENTERED = 0x00,
- JOY_HAT_UP = 0x01,
- JOY_HAT_RIGHT = 0x02,
- JOY_HAT_DOWN = 0x04,
- JOY_HAT_LEFT = 0x08,
- JOY_HAT_RIGHTUP = (JOY_HAT_RIGHT|JOY_HAT_UP ),
- JOY_HAT_RIGHTDOWN = (JOY_HAT_RIGHT|JOY_HAT_DOWN),
- JOY_HAT_LEFTUP = (JOY_HAT_LEFT |JOY_HAT_UP ),
- JOY_HAT_LEFTDOWN = (JOY_HAT_LEFT |JOY_HAT_DOWN),
- };
- struct Event_Joystick_Axis { //4B
- u8 which;
- u8 _padding8;
- s16 value;
- } __attribute__((packed));
- struct Event_Joystick_Trackball { //12B
- u8 which;
- u8 _padding8;
- s16 dx, dy; //movement delta
- u16 _padding16; //(extra explicit padding added, since
- u32 _padding32; //trackball is the largest subevent)
- } __attribute__((packed));
- struct Event_Joystick_Hat { //2B
- u8 which;
- u8 value; //see Event_Joystick_HatEnum
- } __attribute__((packed));
- struct Event_Joystick_Button { //2B
- u8 which;
- bool pressed;
- } __attribute__((packed));
- struct Event_Joystick_Device { //2B
- u8 _padding8;
- bool added; //device was removed if false
- } __attribute__((packed));
- struct Event_Joystick_Battery { //2B
- u8 _padding8;
- s8 level; //see Event_Joystick_BatteryEnum
- } __attribute__((packed));
- struct Event_Joystick { //24B
- u32 type;
- u32 timestamp;
- u32 id; //associated joystick instance
- union {
- Event_Joystick_Axis axis; // 4B
- Event_Joystick_Trackball trackball; //12B
- Event_Joystick_Hat hat; // 2B
- Event_Joystick_Button button; // 2B
- Event_Joystick_Device device; // 2B; redundant, but included for consistency
- Event_Joystick_Battery battery; // 2B
- };
- };
- /*-KEVENT_JOY-*/
- /*+KEVENT_CTLR+*/
- enum Event_GameController_AxisEnum {
- CTLR_AXIS_INVALID = -1,
- CTLR_AXIS_LEFTX,
- CTLR_AXIS_LEFTY,
- CTLR_AXIS_RIGHTX,
- CTLR_AXIS_RIGHTY,
- CTLR_AXIS_TRIGGERLEFT,
- CTLR_AXIS_TRIGGERRIGHT,
- CTLR_AXIS_MAX,
- };
- enum Event_GameController_ButtonEnum {
- CTLR_BUTTON_INVALID = -1,
- CTLR_BUTTON_A,
- CTLR_BUTTON_B,
- CTLR_BUTTON_X,
- CTLR_BUTTON_Y,
- CTLR_BUTTON_BACK,
- CTLR_BUTTON_GUIDE,
- CTLR_BUTTON_START,
- CTLR_BUTTON_LEFTSTICK,
- CTLR_BUTTON_RIGHTSTICK,
- CTLR_BUTTON_LEFTSHOULDER,
- CTLR_BUTTON_RIGHTSHOULDER,
- CTLR_BUTTON_DPAD_UP,
- CTLR_BUTTON_DPAD_DOWN,
- CTLR_BUTTON_DPAD_LEFT,
- CTLR_BUTTON_DPAD_RIGHT,
- CTLR_BUTTON_MISC1, //Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button
- CTLR_BUTTON_PADDLE1, //Xbox Elite paddle P1 (upper left, facing the back)
- CTLR_BUTTON_PADDLE2, //Xbox Elite paddle P3 (upper right, facing the back)
- CTLR_BUTTON_PADDLE3, //Xbox Elite paddle P2 (lower left, facing the back)
- CTLR_BUTTON_PADDLE4, //Xbox Elite paddle P4 (lower right, facing the back)
- CTLR_BUTTON_TOUCHPAD, //PS4/PS5 touchpad button
- CTLR_BUTTON_MAX,
- };
- enum Event_GameController_SensorEnum {
- CTLR_SENSOR_INVALID = -1, //Returned for an invalid sensor
- CTLR_SENSOR_UNKNOWN, //Unknown sensor type
- CTLR_SENSOR_ACCEL, //Accelerometer
- CTLR_SENSOR_GYRO, //Gyroscope
- CTLR_SENSOR_ACCEL_L, //Accelerometer for left Joy-Con controller and Wii nunchuk
- CTLR_SENSOR_GYRO_L, //Gyroscope for left Joy-Con controller
- CTLR_SENSOR_ACCEL_R, //Accelerometer for right Joy-Con controller
- CTLR_SENSOR_GYRO_R, //Gyroscope for right Joy-Con controller
- };
- /**
- * Accelerometer sensor
- *
- * The accelerometer returns the current acceleration in SI meters per
- * second squared. This measurement includes the force of gravity, so
- * a device at rest will have an value of KIT_STANDARD_GRAVITY away
- * from the center of the earth, which is a positive Y value.
- *
- * values[0]: Acceleration on the x axis
- * values[1]: Acceleration on the y axis
- * values[2]: Acceleration on the z axis
- *
- * For phones held in portrait mode and game controllers held in front of you,
- * the axes are defined as follows:
- * -X ... +X : left ... right
- * -Y ... +Y : bottom ... top
- * -Z ... +Z : farther ... closer
- *
- * The axis data is not changed when the phone is rotated.
- */
- //#define SDL_STANDARD_GRAVITY 9.80665f
- #define KIT_STANDARD_GRAVITY 9.80665f //for macro naming consistency
- /**
- * Gyroscope sensor
- *
- * The gyroscope returns the current rate of rotation in radians per second.
- * The rotation is positive in the counter-clockwise direction. That is,
- * an observer looking from a positive location on one of the axes would
- * see positive rotation on that axis when it appeared to be rotating
- * counter-clockwise.
- *
- * values[0]: Angular speed around the x axis (pitch)
- * values[1]: Angular speed around the y axis (yaw)
- * values[2]: Angular speed around the z axis (roll)
- *
- * For phones held in portrait mode and game controllers held in front of you,
- * the axes are defined as follows:
- * -X ... +X : left ... right
- * -Y ... +Y : bottom ... top
- * -Z ... +Z : farther ... closer
- *
- * The axis data is not changed when the phone or controller is rotated.
- */
- struct Event_GameController_Axis { //4B
- u8 which; //see Event_GameController_AxisEnum
- u8 _padding8;
- s16 value;
- } __attribute__((packed));
- struct Event_GameController_Button { //2B
- u8 which; //see Event_GameController_ButtonEnum
- bool pressed;
- } __attribute__((packed));
- struct Event_GameController_Device { //2B
- u16 subtype; //lower 16-bits of .type
- } __attribute__((packed));
- struct Event_GameController_Touchpad { //20B
- s32 which;
- s32 finger;
- f32 x, y; //from top-left going southeast, normalized; 0.0f -> 1.0f
- f32 pressure;
- } __attribute__((packed));
- struct Event_GameController_Sensor { //28B
- s32 which; //see Event_GameController_SensorEnum
- u32 _padding32;
- f32 data[3];
- u64 timestamp_us; //time at the point of sensor read, in microseconds
- //(if the hardware provides that information)
- } __attribute__((packed));
- struct Event_GameController { //40B
- u32 type;
- u32 timestamp;
- s32 id; //joystick instance id (unless subtype is DEVICE_x)
- //^^ specifically for DEVICE_x:
- // joy device index for ADDED, instance id for REMOVED/REMAPPED
- union {
- Event_GameController_Axis axis; // 4B
- Event_GameController_Button button; // 2B
- Event_GameController_Device device; // 2B; redundant, but included for consistency
- Event_GameController_Touchpad touchpad; //20B
- Event_GameController_Sensor sensor; //28B
- };
- };
- /*-KEVENT_CTLR-*/
- /*+KEVENT_ADEV+*/
- struct Event_AudioDevice { //16B
- u32 type;
- u32 timestamp;
- u32 id;
- bool isInput; //false = output/rendering, true = input/recording
- u8 _padding8;
- u16 _padding16;
- };
- /*-KEVENT_ADEV-*/
- /*+KEVENT_DROP+*/
- struct Event_Drop { //24B
- u32 type;
- u32 timestamp;
- u32 window; //which window the file was dropped on, if any
- u32 _padding32;
- char* filePath; //should be freed with memory::free; nullptr on DROP_BEGIN/COMPLETE
- };
- /*-KEVENT_DROP-*/
- /*+KEVENT_QUIT+*/
- struct Event_Quit { //8B
- u32 type;
- u32 timestamp;
- };
- /*-KEVENT_QUIT-*/
- /*+KEVENT_USER+*/
- struct Event_User { //24B
- u32 type;
- u32 timestamp;
- u32 window;
- s32 id; //user-defined
- void* data1; //user-defined
- void* data2; //user-defined
- };
- /*-KEVENT_USER-*/
- union Event { //<whatever the largest event is>B
- struct {
- u32 type;
- u32 timestamp;
- };
- Event_Common common; // 8B
- Event_Display display; //16B
- Event_Window win; //24B
- Event_Key key; //24B
- Event_Mouse mouse; //40B
- Event_Joystick joy; //24B
- Event_GameController ctlr; //40B
- Event_AudioDevice adev; //16B
- Event_Drop drop; //24B
- Event_Quit quit; // 8B
- Event_User user; //24B
- Event() : type(KEVENT_NULL) {}
- };
- }; /* namespace kit */
- #endif /* _INC__MISC_EVENT_HPP */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement