fixed whitespace conflict
This commit is contained in:
commit
da325bc7a4
2 changed files with 55 additions and 55 deletions
|
|
@ -950,48 +950,63 @@ type
|
||||||
|
|
||||||
TEventAction* = enum # Application visibility event structure
|
TEventAction* = enum # Application visibility event structure
|
||||||
ADDEVENT, PEEKEVENT, GETEVENT
|
ADDEVENT, PEEKEVENT, GETEVENT
|
||||||
|
|
||||||
|
PActiveEvent* = ptr TActiveEvent
|
||||||
TActiveEvent*{.final.} = object # SDL_ACTIVEEVENT
|
TActiveEvent*{.final.} = object # SDL_ACTIVEEVENT
|
||||||
# Keyboard event structure
|
# Keyboard event structure
|
||||||
|
kind*: TEventKind
|
||||||
gain*: byte # Whether given states were gained or lost (1/0)
|
gain*: byte # Whether given states were gained or lost (1/0)
|
||||||
state*: byte # A mask of the focus states
|
state*: byte # A mask of the focus states
|
||||||
|
|
||||||
|
PKeyboardEvent = ptr TKeyboardEvent
|
||||||
TKeyboardEvent*{.final.} = object # SDL_KEYDOWN or SDL_KEYUP
|
TKeyboardEvent*{.final.} = object # SDL_KEYDOWN or SDL_KEYUP
|
||||||
# Mouse motion event structure
|
# Mouse motion event structure
|
||||||
|
kind*: TEventKind
|
||||||
which*: byte # The keyboard device index
|
which*: byte # The keyboard device index
|
||||||
state*: byte # SDL_PRESSED or SDL_RELEASED
|
state*: byte # SDL_PRESSED or SDL_RELEASED
|
||||||
keysym*: TKeySym
|
keysym*: TKeySym
|
||||||
|
|
||||||
|
PMouseMotionEvent = ptr TMouseMotionEvent
|
||||||
TMouseMotionEvent*{.final.} = object # SDL_MOUSEMOTION
|
TMouseMotionEvent*{.final.} = object # SDL_MOUSEMOTION
|
||||||
# Mouse button event structure
|
# Mouse button event structure
|
||||||
|
kind*: TEventKind
|
||||||
which*: byte # The mouse device index
|
which*: byte # The mouse device index
|
||||||
state*: byte # The current button state
|
state*: byte # The current button state
|
||||||
x*, y*: UInt16 # The X/Y coordinates of the mouse
|
x*, y*: UInt16 # The X/Y coordinates of the mouse
|
||||||
xrel*: int16 # The relative motion in the X direction
|
xrel*: int16 # The relative motion in the X direction
|
||||||
yrel*: int16 # The relative motion in the Y direction
|
yrel*: int16 # The relative motion in the Y direction
|
||||||
|
|
||||||
|
PMouseButtonEvent = ptr TMouseButtonEvent
|
||||||
TMouseButtonEvent*{.final.} = object # SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP
|
TMouseButtonEvent*{.final.} = object # SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP
|
||||||
# Joystick axis motion event structure
|
# Joystick axis motion event structure
|
||||||
|
kind*: TEventKind
|
||||||
which*: byte # The mouse device index
|
which*: byte # The mouse device index
|
||||||
button*: byte # The mouse button index
|
button*: byte # The mouse button index
|
||||||
state*: byte # SDL_PRESSED or SDL_RELEASED
|
state*: byte # SDL_PRESSED or SDL_RELEASED
|
||||||
x*: UInt16 # The X coordinates of the mouse at press time
|
x*: UInt16 # The X coordinates of the mouse at press time
|
||||||
y*: UInt16 # The Y coordinates of the mouse at press time
|
y*: UInt16 # The Y coordinates of the mouse at press time
|
||||||
|
|
||||||
|
PJoyAxisEvent = ptr TJoyAxisEvent
|
||||||
TJoyAxisEvent*{.final.} = object # SDL_JOYAXISMOTION
|
TJoyAxisEvent*{.final.} = object # SDL_JOYAXISMOTION
|
||||||
# Joystick trackball motion event structure
|
# Joystick trackball motion event structure
|
||||||
|
kind*: TEventKind
|
||||||
which*: byte # The joystick device index
|
which*: byte # The joystick device index
|
||||||
axis*: byte # The joystick axis index
|
axis*: byte # The joystick axis index
|
||||||
value*: int16 # The axis value (range: -32768 to 32767)
|
value*: int16 # The axis value (range: -32768 to 32767)
|
||||||
|
|
||||||
|
PJoyBallEvent = ptr TJoyBallEvent
|
||||||
TJoyBallEvent*{.final.} = object # SDL_JOYAVBALLMOTION
|
TJoyBallEvent*{.final.} = object # SDL_JOYAVBALLMOTION
|
||||||
# Joystick hat position change event structure
|
# Joystick hat position change event structure
|
||||||
|
kind*: TEventKind
|
||||||
which*: byte # The joystick device index
|
which*: byte # The joystick device index
|
||||||
ball*: byte # The joystick trackball index
|
ball*: byte # The joystick trackball index
|
||||||
xrel*: int16 # The relative motion in the X direction
|
xrel*: int16 # The relative motion in the X direction
|
||||||
yrel*: int16 # The relative motion in the Y direction
|
yrel*: int16 # The relative motion in the Y direction
|
||||||
|
|
||||||
|
PJoyHatEvent = ptr TJoyHatEvent
|
||||||
TJoyHatEvent*{.final.} = object # SDL_JOYHATMOTION */
|
TJoyHatEvent*{.final.} = object # SDL_JOYHATMOTION */
|
||||||
# Joystick button event structure
|
# Joystick button event structure
|
||||||
|
kind*: TEventKind
|
||||||
which*: byte # The joystick device index */
|
which*: byte # The joystick device index */
|
||||||
hat*: byte # The joystick hat index */
|
hat*: byte # The joystick hat index */
|
||||||
value*: byte # The hat position value:
|
value*: byte # The hat position value:
|
||||||
|
|
@ -1000,22 +1015,27 @@ type
|
||||||
# 6 5 4
|
# 6 5 4
|
||||||
# Note that zero means the POV is centered.
|
# Note that zero means the POV is centered.
|
||||||
|
|
||||||
|
PJoyButtonEvent = ptr TJoyButtonEvent
|
||||||
TJoyButtonEvent*{.final.} = object # SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP
|
TJoyButtonEvent*{.final.} = object # SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP
|
||||||
# The "window resized" event
|
# The "window resized" event
|
||||||
# When you get this event, you are
|
# When you get this event, you are
|
||||||
# responsible for setting a new video
|
# responsible for setting a new video
|
||||||
# mode with the new width and height.
|
# mode with the new width and height.
|
||||||
|
kind*: TEventKind
|
||||||
which*: byte # The joystick device index
|
which*: byte # The joystick device index
|
||||||
button*: byte # The joystick button index
|
button*: byte # The joystick button index
|
||||||
state*: byte # SDL_PRESSED or SDL_RELEASED
|
state*: byte # SDL_PRESSED or SDL_RELEASED
|
||||||
|
|
||||||
|
PResizeEvent = ptr TResizeEvent
|
||||||
TResizeEvent*{.final.} = object # SDL_VIDEORESIZE
|
TResizeEvent*{.final.} = object # SDL_VIDEORESIZE
|
||||||
# A user-defined event type
|
# A user-defined event type
|
||||||
|
kind*: TEventKind
|
||||||
w*: cint # New width
|
w*: cint # New width
|
||||||
h*: cint # New height
|
h*: cint # New height
|
||||||
|
|
||||||
PUserEvent* = ptr TUserEvent
|
PUserEvent* = ptr TUserEvent
|
||||||
TUserEvent*{.final.} = object # SDL_USEREVENT through SDL_NUMEVENTS-1
|
TUserEvent*{.final.} = object # SDL_USEREVENT through SDL_NUMEVENTS-1
|
||||||
|
kind*: TEventKind
|
||||||
code*: cint # User defined event code
|
code*: cint # User defined event code
|
||||||
data1*: Pointer # User defined data pointer
|
data1*: Pointer # User defined data pointer
|
||||||
data2*: Pointer # User defined data pointer
|
data2*: Pointer # User defined data pointer
|
||||||
|
|
@ -1094,63 +1114,21 @@ else:
|
||||||
type
|
type
|
||||||
PSysWMEvent* = ptr TSysWMEvent
|
PSysWMEvent* = ptr TSysWMEvent
|
||||||
TSysWMEvent*{.final.} = object
|
TSysWMEvent*{.final.} = object
|
||||||
|
kind*: TEventKind
|
||||||
msg*: PSysWMmsg
|
msg*: PSysWMmsg
|
||||||
|
|
||||||
|
PExposeEvent = ptr TExposeEvent
|
||||||
|
TExposeEvent*{.final.} = object
|
||||||
|
kind*: TEventKind
|
||||||
|
|
||||||
|
PQuitEvent = ptr TQuitEvent
|
||||||
|
TQuitEvent*{.final.} = object
|
||||||
|
kind*: TEventKind
|
||||||
|
|
||||||
PEvent* = ptr TEvent
|
PEvent* = ptr TEvent
|
||||||
TEvent*{.final.} = object
|
TEvent*{.final.} = object
|
||||||
# This function sets up a filter to process all events before they
|
kind*: TEventKind
|
||||||
# change internal state and are posted to the internal event queue.
|
pad: array[0..19, byte]
|
||||||
# The filter is protypted as:
|
|
||||||
case kind*: TEventKind # SDL_NOEVENT, SDL_QUITEV: ();
|
|
||||||
of ACTIVEEVENT:
|
|
||||||
gain*: byte # Whether given states were gained or lost (1/0)
|
|
||||||
state*: byte # A mask of the focus states
|
|
||||||
of KEYDOWN, KEYUP:
|
|
||||||
keystate*: byte # SDL_PRESSED or SDL_RELEASED
|
|
||||||
scancode*: byte # hardware specific scancode
|
|
||||||
sym*: TKey # SDL virtual keysym
|
|
||||||
modifier*: TMod # current key modifiers
|
|
||||||
unicode*: UInt16 # translated character
|
|
||||||
of MOUSEMOTION:
|
|
||||||
motionState*: byte # The current button state
|
|
||||||
motionX*, motionY*: UInt16 # The X/Y coordinates of the mouse
|
|
||||||
xrel*: int16 # The relative motion in the X direction
|
|
||||||
yrel*: int16 # The relative motion in the Y direction
|
|
||||||
of MOUSEBUTTONDOWN, MOUSEBUTTONUP:
|
|
||||||
button*: byte # The mouse button index
|
|
||||||
buttonState*: byte # SDL_PRESSED or SDL_RELEASED
|
|
||||||
align: byte
|
|
||||||
x*: UInt16 # The X coordinates of the mouse at press time
|
|
||||||
y*: UInt16 # The Y coordinates of the mouse at press time
|
|
||||||
of JOYAXISMOTION:
|
|
||||||
axis*: byte # The joystick axis index
|
|
||||||
value*: int16 # The axis value (range: -32768 to 32767)
|
|
||||||
of JOYBALLMOTION:
|
|
||||||
ball*: byte # The joystick trackball index
|
|
||||||
joyXrel*: int16 # The relative motion in the X direction
|
|
||||||
joyYrel*: int16 # The relative motion in the Y direction
|
|
||||||
|
|
||||||
of JOYHATMOTION:
|
|
||||||
hat*: byte # The joystick hat index
|
|
||||||
hatValue*: byte # The hat position value:
|
|
||||||
# 8 1 2
|
|
||||||
# 7 0 3
|
|
||||||
# 6 5 4
|
|
||||||
# Note that zero means the POV is centered.
|
|
||||||
|
|
||||||
of JOYBUTTONDOWN, JOYBUTTONUP:
|
|
||||||
joybutton*: byte # The joystick button index
|
|
||||||
joyState*: byte # SDL_PRESSED or SDL_RELEASED
|
|
||||||
|
|
||||||
of VIDEORESIZE:
|
|
||||||
w*: cint # New width
|
|
||||||
h*: cint # New height
|
|
||||||
of USEREVENT:
|
|
||||||
code*: cint # User defined event code
|
|
||||||
data1*: Pointer # User defined data pointer
|
|
||||||
data2*: Pointer # User defined data pointer
|
|
||||||
else: nil
|
|
||||||
|
|
||||||
|
|
||||||
TEventFilter* = proc (event: PEvent): int{.cdecl.} # SDL_video.h types
|
TEventFilter* = proc (event: PEvent): int{.cdecl.} # SDL_video.h types
|
||||||
# Useful data types
|
# Useful data types
|
||||||
|
|
@ -1303,7 +1281,29 @@ type # This is the system-independent thread info struc
|
||||||
TByteArray* = array[0..32767, int8]
|
TByteArray* = array[0..32767, int8]
|
||||||
PWordArray* = ptr TWordArray
|
PWordArray* = ptr TWordArray
|
||||||
TWordArray* = array[0..16383, int16] # Generic procedure pointer
|
TWordArray* = array[0..16383, int16] # Generic procedure pointer
|
||||||
TProcedure* = proc () #------------------------------------------------------------------------------
|
TProcedure* = proc ()
|
||||||
|
|
||||||
|
type TEventSeq = set[TEventKind]
|
||||||
|
template evconv(procName: expr, ptrName: typeDesc, assertions: TEventSeq): stmt =
|
||||||
|
proc `procName`*(event: PEvent): ptrName =
|
||||||
|
assert(assertions.contains(event.kind))
|
||||||
|
result = cast[ptrName](event)
|
||||||
|
|
||||||
|
evconv(EvActive, PActiveEvent, {ACTIVEEVENT})
|
||||||
|
evconv(EvKeyboard, PKeyboardEvent, {KEYDOWN, KEYUP})
|
||||||
|
evconv(EvMouseMotion, PMouseMotionEvent, {MOUSEMOTION})
|
||||||
|
evconv(EvMouseButton, PMouseButtonEvent, {MOUSEBUTTONDOWN, MOUSEBUTTONUP})
|
||||||
|
evconv(EvJoyAxis, PJoyAxisEvent,{JOYAXISMOTION})
|
||||||
|
evconv(EvJoyBall, PJoyBallEvent, {JOYBALLMOTION})
|
||||||
|
evconv(EvJoyHat, PJoyHatEvent, {JOYHATMOTION})
|
||||||
|
evconv(EvJoyButton, PJoyButtonEvent, {JOYBUTTONDOWN, JOYBUTTONUP})
|
||||||
|
evconv(EvResize, PResizeEvent, {VIDEORESIZE})
|
||||||
|
evconv(EvExpose, PExposeEvent, {VIDEOEXPOSE})
|
||||||
|
evconv(EvQuit, PQuitEvent, {QUITEV})
|
||||||
|
evconv(EvUser, PUserEvent, {USEREVENT})
|
||||||
|
evconv(EvSysWM, PSysWMEvent, {SYSWMEVENT})
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------------
|
||||||
# initialization
|
# initialization
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# This function loads the SDL dynamically linked library and initializes
|
# This function loads the SDL dynamically linked library and initializes
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue