Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all: run vfmt over files #761

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions audio.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ pub type AudioCallback = fn (userdata voidptr, stream &u8, len int)
@[typedef]
pub struct C.SDL_AudioSpec {
pub:
freq int // DSP frequency -- samples per second
format AudioFormat // C.SDL_AudioFormat Audio data format
channels u8 // Number of channels: 1 mono, 2 stereo
silence u8 // Audio buffer silence value (calculated)
samples u16 // Audio buffer size in sample FRAMES (total samples divided by channel count)
padding u16 // Necessary for some compile environments
size u32 // Audio buffer size in bytes (calculated)
freq int // DSP frequency -- samples per second
format AudioFormat // C.SDL_AudioFormat Audio data format
channels u8 // Number of channels: 1 mono, 2 stereo
silence u8 // Audio buffer silence value (calculated)
samples u16 // Audio buffer size in sample FRAMES (total samples divided by channel count)
padding u16 // Necessary for some compile environments
size u32 // Audio buffer size in bytes (calculated)
callback AudioCallback // C.SDL_AudioCallback // Callback that feeds the audio device (NULL to use SDL_QueueAudio()).
userdata voidptr // Userdata passed to callback (ignored for NULL callbacks).
}
Expand Down Expand Up @@ -210,17 +210,17 @@ pub type AudioCVTPackedSDLAudioCVT = C.SDL_AUDIOCVT_PACKEDSDL_AudioCVT
@[typedef]
pub struct C.SDL_AudioCVT {
pub:
needed int // Set to 1 if conversion possible
src_format AudioFormat // C.SDL_AudioFormat, Source audio format
dst_format AudioFormat // C.SDL_AudioFormat, Target audio format
rate_incr f64 // Rate conversion increment
buf &u8 // Buffer to hold entire audio data
len int // Length of original audio buffer
len_cvt int // Length of converted audio buffer
len_mult int // buffer must be len*len_mult big
len_ratio f64 // Given len, final size is len*len_ratio
needed int // Set to 1 if conversion possible
src_format AudioFormat // C.SDL_AudioFormat, Source audio format
dst_format AudioFormat // C.SDL_AudioFormat, Target audio format
rate_incr f64 // Rate conversion increment
buf &u8 // Buffer to hold entire audio data
len int // Length of original audio buffer
len_cvt int // Length of converted audio buffer
len_mult int // buffer must be len*len_mult big
len_ratio f64 // Given len, final size is len*len_ratio
filters [10]AudioFilter // C.SDL_AudioFilter NULL-terminated list of filter functions
filter_index int // Current audio conversion function
filter_index int // Current audio conversion function
}

pub type AudioCVT = C.SDL_AudioCVT
Expand Down
30 changes: 15 additions & 15 deletions blendmode.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,36 @@ module sdl
// BlendMode is the blend mode used in SDL_RenderCopy() and drawing operations.
// BlendMode is SDL_BlendMode
pub enum BlendMode {
@none = C.SDL_BLENDMODE_NONE // 0x00000000, no blending dstRGBA = srcRGBA
blend = C.SDL_BLENDMODE_BLEND // 0x00000001, alpha blending dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) dstA = srcA + (dstA * (1-srcA))
add = C.SDL_BLENDMODE_ADD // 0x00000002, additive blending dstRGB = (srcRGB * srcA) + dstRGB dstA = dstA
mod = C.SDL_BLENDMODE_MOD // 0x00000004, color modulate dstRGB = srcRGB * dstRGB dstA = dstA
mul = C.SDL_BLENDMODE_MUL // 0x00000008, color multiply dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA)) dstA = (srcA * dstA) + (dstA * (1-srcA))
@none = C.SDL_BLENDMODE_NONE // 0x00000000, no blending dstRGBA = srcRGBA
blend = C.SDL_BLENDMODE_BLEND // 0x00000001, alpha blending dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA)) dstA = srcA + (dstA * (1-srcA))
add = C.SDL_BLENDMODE_ADD // 0x00000002, additive blending dstRGB = (srcRGB * srcA) + dstRGB dstA = dstA
mod = C.SDL_BLENDMODE_MOD // 0x00000004, color modulate dstRGB = srcRGB * dstRGB dstA = dstA
mul = C.SDL_BLENDMODE_MUL // 0x00000008, color multiply dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA)) dstA = (srcA * dstA) + (dstA * (1-srcA))
invalid = C.SDL_BLENDMODE_INVALID // 0x7FFFFFFF
}

// BlendOperation is the blend operation used when combining source and destination pixel components
// BlendOperation is C.SDL_BlendOperation
pub enum BlendOperation {
add = C.SDL_BLENDOPERATION_ADD // 0x1, dst + src: supported by all renderers
subtract = C.SDL_BLENDOPERATION_SUBTRACT // 0x2, dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES
add = C.SDL_BLENDOPERATION_ADD // 0x1, dst + src: supported by all renderers
subtract = C.SDL_BLENDOPERATION_SUBTRACT // 0x2, dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES
rev_subtract = C.SDL_BLENDOPERATION_REV_SUBTRACT // 0x3, src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES
minimum = C.SDL_BLENDOPERATION_MINIMUM // 0x4, min(dst, src) : supported by D3D11
maximum = C.SDL_BLENDOPERATION_MAXIMUM // 0x5 max(dst, src) : supported by D3D11
minimum = C.SDL_BLENDOPERATION_MINIMUM // 0x4, min(dst, src) : supported by D3D11
maximum = C.SDL_BLENDOPERATION_MAXIMUM // 0x5 max(dst, src) : supported by D3D11
}

// BlendFactor is the normalized factor used to multiply pixel components
// BlendFactor is C.SDL_BlendFactor
pub enum BlendFactor {
zero = C.SDL_BLENDFACTOR_ZERO // 0x1, 0, 0, 0, 0
one = C.SDL_BLENDFACTOR_ONE // 0x2, 1, 1, 1, 1
src_color = C.SDL_BLENDFACTOR_SRC_COLOR // 0x3, srcR, srcG, srcB, srcA
zero = C.SDL_BLENDFACTOR_ZERO // 0x1, 0, 0, 0, 0
one = C.SDL_BLENDFACTOR_ONE // 0x2, 1, 1, 1, 1
src_color = C.SDL_BLENDFACTOR_SRC_COLOR // 0x3, srcR, srcG, srcB, srcA
one_minus_src_color = C.SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR // 0x4, 1-srcR, 1-srcG, 1-srcB, 1-srcA
src_alpha = C.SDL_BLENDFACTOR_SRC_ALPHA // 0x5, srcA, srcA, srcA, srcA
src_alpha = C.SDL_BLENDFACTOR_SRC_ALPHA // 0x5, srcA, srcA, srcA, srcA
one_minus_src_alpha = C.SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA // 0x6, 1-srcA, 1-srcA, 1-srcA, 1-srcA
dst_color = C.SDL_BLENDFACTOR_DST_COLOR // 0x7, dstR, dstG, dstB, dstA
dst_color = C.SDL_BLENDFACTOR_DST_COLOR // 0x7, dstR, dstG, dstB, dstA
one_minus_dst_color = C.SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR // 0x8, 1-dstR, 1-dstG, 1-dstB, 1-dstA
dst_alpha = C.SDL_BLENDFACTOR_DST_ALPHA // 0x9, dstA, dstA, dstA, dstA
dst_alpha = C.SDL_BLENDFACTOR_DST_ALPHA // 0x9, dstA, dstA, dstA, dstA
one_minus_dst_alpha = C.SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA // 0xA, 1-dstA, 1-dstA, 1-dstA, 1-dstA
}

Expand Down
122 changes: 61 additions & 61 deletions events.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -29,90 +29,90 @@ pub type EventFilter = fn (userdata voidptr, event &Event)

// EventType is C.SDL_EventType
pub enum EventType {
firstevent = C.SDL_FIRSTEVENT // Unused (do not remove)
quit = C.SDL_QUIT // 0x100 User-requested quit
firstevent = C.SDL_FIRSTEVENT // Unused (do not remove)
quit = C.SDL_QUIT // 0x100 User-requested quit
// These application events have special meaning on iOS, see README-ios.md in SDL for details
// The application is being terminated by the OS
// Called on iOS in applicationWillTerminate()
// Called on Android in onDestroy()
app_terminating = C.SDL_APP_TERMINATING
app_terminating = C.SDL_APP_TERMINATING
// The application is low on memory, free memory if possible.
// Called on iOS in applicationDidReceiveMemoryWarning()
// Called on Android in onLowMemory()
app_lowmemory = C.SDL_APP_LOWMEMORY
app_lowmemory = C.SDL_APP_LOWMEMORY
// The application is about to enter the background
// Called on iOS in applicationWillResignActive()
// Called on Android in onPause()
app_willenterbackground = C.SDL_APP_WILLENTERBACKGROUND
app_willenterbackground = C.SDL_APP_WILLENTERBACKGROUND
// The application did enter the background and may not get CPU for some time
// Called on iOS in applicationDidEnterBackground()
// Called on Android in onPause()
app_didenterbackground = C.SDL_APP_DIDENTERBACKGROUND
app_didenterbackground = C.SDL_APP_DIDENTERBACKGROUND
// The application is about to enter the foreground
// Called on iOS in applicationWillEnterForeground()
// Called on Android in onResume()
app_willenterforeground = C.SDL_APP_WILLENTERFOREGROUND
app_willenterforeground = C.SDL_APP_WILLENTERFOREGROUND
// The application is now interactive
// Called on iOS in applicationDidBecomeActive()
// Called on Android in onResume()
app_didenterforeground = C.SDL_APP_DIDENTERFOREGROUND
app_didenterforeground = C.SDL_APP_DIDENTERFOREGROUND
// Display events
displayevent = C.SDL_DISPLAYEVENT // 0x150 Display state change
displayevent = C.SDL_DISPLAYEVENT // 0x150 Display state change
// Window events
windowevent = C.SDL_WINDOWEVENT // 0x200 Window state change
syswmevent = C.SDL_SYSWMEVENT
windowevent = C.SDL_WINDOWEVENT // 0x200 Window state change
syswmevent = C.SDL_SYSWMEVENT
// Keyboard events
keydown = C.SDL_KEYDOWN // 0x300, Key pressed
keyup = C.SDL_KEYUP // Key released
textediting = C.SDL_TEXTEDITING // Keyboard text editing (composition)
textinput = C.SDL_TEXTINPUT // Keyboard text input
keymapchanged = C.SDL_KEYMAPCHANGED // Keymap changed due to a system event such as an input language or keyboard layout change.
keydown = C.SDL_KEYDOWN // 0x300, Key pressed
keyup = C.SDL_KEYUP // Key released
textediting = C.SDL_TEXTEDITING // Keyboard text editing (composition)
textinput = C.SDL_TEXTINPUT // Keyboard text input
keymapchanged = C.SDL_KEYMAPCHANGED // Keymap changed due to a system event such as an input language or keyboard layout change.
// Mouse events
mousemotion = C.SDL_MOUSEMOTION // 0x400, Mouse moved
mousebuttondown = C.SDL_MOUSEBUTTONDOWN // Mouse button pressed
mousebuttonup = C.SDL_MOUSEBUTTONUP // Mouse button released
mousewheel = C.SDL_MOUSEWHEEL // Mouse wheel motion
mousemotion = C.SDL_MOUSEMOTION // 0x400, Mouse moved
mousebuttondown = C.SDL_MOUSEBUTTONDOWN // Mouse button pressed
mousebuttonup = C.SDL_MOUSEBUTTONUP // Mouse button released
mousewheel = C.SDL_MOUSEWHEEL // Mouse wheel motion
// Joystick events
joyaxismotion = C.SDL_JOYAXISMOTION // 0x600, Joystick axis motion
joyballmotion = C.SDL_JOYBALLMOTION // Joystick trackball motion
joyhatmotion = C.SDL_JOYHATMOTION // Joystick hat position change
joybuttondown = C.SDL_JOYBUTTONDOWN // Joystick button pressed
joybuttonup = C.SDL_JOYBUTTONUP // Joystick button released
joydeviceadded = C.SDL_JOYDEVICEADDED // A new joystick has been inserted into the system
joydeviceremoved = C.SDL_JOYDEVICEREMOVED // An opened joystick has been removed
joyaxismotion = C.SDL_JOYAXISMOTION // 0x600, Joystick axis motion
joyballmotion = C.SDL_JOYBALLMOTION // Joystick trackball motion
joyhatmotion = C.SDL_JOYHATMOTION // Joystick hat position change
joybuttondown = C.SDL_JOYBUTTONDOWN // Joystick button pressed
joybuttonup = C.SDL_JOYBUTTONUP // Joystick button released
joydeviceadded = C.SDL_JOYDEVICEADDED // A new joystick has been inserted into the system
joydeviceremoved = C.SDL_JOYDEVICEREMOVED // An opened joystick has been removed
// Game controller events
controlleraxismotion = C.SDL_CONTROLLERAXISMOTION // 0x650, Game controller axis motion
controllerbuttondown = C.SDL_CONTROLLERBUTTONDOWN // Game controller button pressed
controllerbuttonup = C.SDL_CONTROLLERBUTTONUP // Game controller button released
controllerdeviceadded = C.SDL_CONTROLLERDEVICEADDED // A new Game controller has been inserted into the system
controllerdeviceremoved = C.SDL_CONTROLLERDEVICEREMOVED // An opened Game controller has been removed
controlleraxismotion = C.SDL_CONTROLLERAXISMOTION // 0x650, Game controller axis motion
controllerbuttondown = C.SDL_CONTROLLERBUTTONDOWN // Game controller button pressed
controllerbuttonup = C.SDL_CONTROLLERBUTTONUP // Game controller button released
controllerdeviceadded = C.SDL_CONTROLLERDEVICEADDED // A new Game controller has been inserted into the system
controllerdeviceremoved = C.SDL_CONTROLLERDEVICEREMOVED // An opened Game controller has been removed
controllerdeviceremapped = C.SDL_CONTROLLERDEVICEREMAPPED // The controller mapping was updated
// Touch events
fingerdown = C.SDL_FINGERDOWN // 0x700
fingerup = C.SDL_FINGERUP
fingermotion = C.SDL_FINGERMOTION
fingerdown = C.SDL_FINGERDOWN // 0x700
fingerup = C.SDL_FINGERUP
fingermotion = C.SDL_FINGERMOTION
// Gesture events
dollargesture = C.SDL_DOLLARGESTURE // 0x800
dollarrecord = C.SDL_DOLLARRECORD
multigesture = C.SDL_MULTIGESTURE
dollargesture = C.SDL_DOLLARGESTURE // 0x800
dollarrecord = C.SDL_DOLLARRECORD
multigesture = C.SDL_MULTIGESTURE
// Clipboard events
clipboardupdate = C.SDL_CLIPBOARDUPDATE // 0x900 The clipboard changed
clipboardupdate = C.SDL_CLIPBOARDUPDATE // 0x900 The clipboard changed
// Drag and drop events
dropfile = C.SDL_DROPFILE // 0x1000 The system requests a file open
droptext = C.SDL_DROPTEXT // text/plain drag-and-drop event
dropbegin = C.SDL_DROPBEGIN // A new set of drops is beginning (NULL filename)
dropcomplete = C.SDL_DROPCOMPLETE // Current set of drops is now complete (NULL filename)
dropfile = C.SDL_DROPFILE // 0x1000 The system requests a file open
droptext = C.SDL_DROPTEXT // text/plain drag-and-drop event
dropbegin = C.SDL_DROPBEGIN // A new set of drops is beginning (NULL filename)
dropcomplete = C.SDL_DROPCOMPLETE // Current set of drops is now complete (NULL filename)
// Audio hotplug events
audiodeviceadded = C.SDL_AUDIODEVICEADDED // 0x1100 A new audio device is available
audiodeviceremoved = C.SDL_AUDIODEVICEREMOVED // An audio device has been removed.
audiodeviceadded = C.SDL_AUDIODEVICEADDED // 0x1100 A new audio device is available
audiodeviceremoved = C.SDL_AUDIODEVICEREMOVED // An audio device has been removed.
// Sensor events
sensorupdate = C.SDL_SENSORUPDATE // 0x1200 A sensor was updated
sensorupdate = C.SDL_SENSORUPDATE // 0x1200 A sensor was updated
// Render events
render_targets_reset = C.SDL_RENDER_TARGETS_RESET // 0x2000 The render targets have been reset and their contents need to be updated
render_device_reset = C.SDL_RENDER_DEVICE_RESET /// The device has been reset and all textures need to be recreated
userevent = C.SDL_USEREVENT // Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use, and should be allocated with SDL_RegisterEvents()
render_targets_reset = C.SDL_RENDER_TARGETS_RESET // 0x2000 The render targets have been reset and their contents need to be updated
render_device_reset = C.SDL_RENDER_DEVICE_RESET /// The device has been reset and all textures need to be recreated
userevent = C.SDL_USEREVENT // Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use, and should be allocated with SDL_RegisterEvents()
// This last event is only for bounding internal arrays
lastevent = C.SDL_LASTEVENT // 0xFFFF
lastevent = C.SDL_LASTEVENT // 0xFFFF
}

// CommonEvent is fields shared by every event
Expand Down Expand Up @@ -258,7 +258,7 @@ pub:
@type EventType // ::SDL_JOYAXISMOTION
timestamp u32 // In milliseconds, populated using SDL_GetTicks()
which JoystickID // The joystick instance id
axis u8 // The joystick axis index
axis u8 // The joystick axis index
padding1 u8
padding2 u8
padding3 u8
Expand All @@ -275,7 +275,7 @@ pub:
@type EventType // ::SDL_JOYBALLMOTION
timestamp u32 // In milliseconds, populated using SDL_GetTicks()
which JoystickID // C.SDL_JoystickID // The joystick instance id
ball u8 // The joystick trackball index
ball u8 // The joystick trackball index
padding1 u8
padding2 u8
padding3 u8
Expand All @@ -292,8 +292,8 @@ pub:
@type EventType // ::SDL_JOYHATMOTION
timestamp u32 // In milliseconds, populated using SDL_GetTicks()
which JoystickID // C.SDL_JoystickID // The joystick instance id
hat u8 // The joystick hat index
value u8 // The hat position value.
hat u8 // The joystick hat index
value u8 // The hat position value.
// See also: ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
// See also: ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
// See also: ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
Expand All @@ -311,8 +311,8 @@ pub:
@type EventType // ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP
timestamp u32 // In milliseconds, populated using SDL_GetTicks()
which JoystickID // C.SDL_JoystickID // The joystick instance id
button u8 // The joystick button index
state u8 // ::SDL_PRESSED or ::SDL_RELEASED
button u8 // The joystick button index
state u8 // ::SDL_PRESSED or ::SDL_RELEASED
padding1 u8
padding2 u8
}
Expand All @@ -337,7 +337,7 @@ pub:
@type EventType // ::SDL_CONTROLLERAXISMOTION
timestamp u32 // In milliseconds, populated using SDL_GetTicks()
which JoystickID // C.SDL_JoystickID // The joystick instance id
axis u8 // The controller axis (SDL_GameControllerAxis)
axis u8 // The controller axis (SDL_GameControllerAxis)
padding1 u8
padding2 u8
padding3 u8
Expand All @@ -354,8 +354,8 @@ pub:
@type EventType // ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP
timestamp u32 // In milliseconds, populated using SDL_GetTicks()
which JoystickID // C.SDL_JoystickID // The joystick instance id
button u8 // The controller button (SDL_GameControllerButton)
state u8 // ::SDL_PRESSED or ::SDL_RELEASED
button u8 // The controller button (SDL_GameControllerButton)
state u8 // ::SDL_PRESSED or ::SDL_RELEASED
padding1 u8
padding2 u8
}
Expand Down Expand Up @@ -545,7 +545,7 @@ pub:
cbutton ControllerButtonEvent // C.SDL_ControllerButtonEvent // Game Controller button event data
cdevice ControllerDeviceEvent // C.SDL_ControllerDeviceEvent // Game Controller device event data
adevice AudioDeviceEvent // C.SDL_AudioDeviceEvent // Audio device event data
sensor SensorEvent // C.SDL_SensorEvent // Sensor event data
sensor SensorEvent // C.SDL_SensorEvent // Sensor event data
//

quit QuitEvent // C.SDL_QuitEvent // Quit request event data
Expand All @@ -554,7 +554,7 @@ pub:
tfinger TouchFingerEvent // C.SDL_TouchFingerEvent // Touch finger event data
mgesture MultiGestureEvent // C.SDL_MultiGestureEvent // Gesture event data
dgesture DollarGestureEvent // C.SDL_DollarGestureEvent // Gesture event data
drop DropEvent // C.SDL_DropEvent // Drag and drop event data
drop DropEvent // C.SDL_DropEvent // Drag and drop event data
// This is necessary for ABI compatibility between Visual C++ and GCC
// Visual C++ will respect the push pack pragma and use 52 bytes for
// this structure, and GCC will use the alignment of the largest datatype
Expand Down
Loading
Loading