Merge branch 'master' of git://github.com/erikcharlebois/factor
commit
d762c8bfb3
|
@ -0,0 +1,93 @@
|
|||
! Copyright (C) 2010 Erik Charlebois
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: help.markup help.crossref help.stylesheet help.topics help.syntax
|
||||
definitions io prettyprint summary arrays math sequences vocabs strings
|
||||
see xml.data hashtables ;
|
||||
IN: collada
|
||||
|
||||
ABOUT: "collada"
|
||||
|
||||
ARTICLE: "collada" "Conversion of COLLADA assets"
|
||||
"The " { $vocab-link "collada" } " vocabulary implements words for converting COLLADA assets to data suitable for use with OpenGL. See the COLLADA documentation at " { $url "http://collada.org" } "." ;
|
||||
|
||||
HELP: model
|
||||
{ $class-description "Tuple of a packed attribute buffer, index buffer and vertex format suitable for a single OpenGL draw call." } ;
|
||||
|
||||
HELP: source
|
||||
{ $class-description "Tuple of a vertex attribute semantic, offset in triangle index buffer and float data for a single vertex attribute." } ;
|
||||
|
||||
HELP: up-axis
|
||||
{ $description "Dynamically-scoped variable with the up axis of the tags being read." } ;
|
||||
|
||||
HELP: unit-ratio
|
||||
{ $description "Scaling ratio for the coordinates of the tags being read." } ;
|
||||
|
||||
HELP: missing-attr
|
||||
{ $description "An error thrown when an attribute is missing from a tag." } ;
|
||||
|
||||
HELP: missing-child
|
||||
{ $description "An error thrown when a child is missing from a tag." } ;
|
||||
|
||||
HELP: string>numbers ( string -- number-seq )
|
||||
{ $values { "string" string } { "number-seq" sequence } }
|
||||
{ $description "Splits a string on whitespace and converts the elements to a number sequence" } ;
|
||||
|
||||
HELP: x-up { $class-description "Right-handed 3D coordinate system where X is up." } ;
|
||||
HELP: y-up { $class-description "Right-handed 3D coordinate system where Y is up." } ;
|
||||
HELP: z-up { $class-description "Right-handed 3D coordinate system where Z is up." } ;
|
||||
|
||||
HELP: >y-up-axis!
|
||||
{ $values { "sequence" sequence } { "from-axis" rh-up } { "sequence" sequence } }
|
||||
{ $description "Destructively swizzles the first three elements of the input sequence to a right-handed 3D coordinate system where Y is up and returns the modified sequence." } ;
|
||||
|
||||
HELP: source>seq
|
||||
{ $values { "source-tag" tag } { "up-axis" rh-up } { "scale" number } { "sequence" sequence } }
|
||||
{ $description "Convert the " { $emphasis "float_array" } " in a " { $emphasis "source tag" } " to a sequence of number sequences according to the element stride. The values are scaled according to " { $emphasis "scale" } " and swizzled from " { $emphasis "up-axis" } " so that the Y coordinate points up." } ;
|
||||
|
||||
HELP: source>pair
|
||||
{ $values { "source-tag" tag } { "pair" pair } }
|
||||
{ $description "Convert the source tag to an id and number sequence pair." } ;
|
||||
|
||||
HELP: mesh>sources
|
||||
{ $values { "mesh-tag" tag } { "hashtable" pair } }
|
||||
{ $description "Convert the mesh tag's source elements to a hashtable from id to number sequence." } ;
|
||||
|
||||
HELP: mesh>vertices
|
||||
{ $values { "mesh-tag" tag } { "pair" pair } }
|
||||
{ $description "Convert the mesh tag's vertices element to a pair for further lookup in " { $link collect-sources } ". " } ;
|
||||
|
||||
HELP: collect-sources
|
||||
{ $values { "sources" hashtable } { "vertices" pair } { "inputs" tag sequence } { "soures" sequence } }
|
||||
{ $description "Look up the sources for these " { $emphasis "input" } " elements and return a sequence of " { $link source } " tuples." } ;
|
||||
|
||||
HELP: group-indices
|
||||
{ $values { "index-stride" number } { "triangle-count" number } { indices "sequence" } { "grouped-indices" sequence } }
|
||||
{ $description "Groups the index sequence by triangle and then groups each triangle's indices by vertex." } ;
|
||||
|
||||
HELP: triangles>numbers
|
||||
{ $values { "triangles-tag" tag } { "number-seq" sequence } }
|
||||
{ $description "Converts the triangle data in a triangles tag from string form to a sequence of numbers." } ;
|
||||
|
||||
HELP: largest-offset+1
|
||||
{ $values { "source-seq" sequence } { "largest-offset+1" number } }
|
||||
{ $description "Finds the largest offset in the sequence of " { $link source } " tuples and adds 1, which is the index stride for " { $link group-indices } "." } ;
|
||||
|
||||
HELP: <model>
|
||||
{ $values { "attribute-buffer" sequence } { "index-buffer" sequence } { "sources" sequence } { "model" model } }
|
||||
{ $description "Converts the inputs to a form suitable for use with " { $vocab-link "gpu" } " and constructs a " { $link model } "." } ;
|
||||
|
||||
HELP: soa>aos
|
||||
{ $values { "triangles-indices" sequence } { "sources" sequence } { "attribute-buffer" sequence } { "index-buffer" sequence } }
|
||||
{ $description "Swizzles the input sources from a structure of arrays form to an array of structures form and generates a new index buffer." } ;
|
||||
|
||||
HELP: triangles>model
|
||||
{ $values { "sources" sequence } { "vertices" pair } { "triangles-tag" tag } { "model" model } }
|
||||
{ $description "Creates a " { $link model } " tuple from the given triangles tag, source set and vertices pair." } ;
|
||||
|
||||
HELP: mesh>triangles
|
||||
{ $values { "souces" sequence } { "vertices" pair } { "mesh-tag" tag } { "models" sequence } }
|
||||
{ $description "Creates a sequence of models from the triangles in the mesh tag." } ;
|
||||
|
||||
HELP: mesh>models
|
||||
{ $values { "mesh-tag" tag } { "models" sequence } }
|
||||
{ $description "Converts a triangle mesh to a set of models suitable for rendering with OpenGL." } ;
|
|
@ -0,0 +1,182 @@
|
|||
! Copyright (C) 2010 Erik Charlebois
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors arrays assocs grouping hashtables kernel
|
||||
locals math math.parser sequences sequences.deep
|
||||
specialized-arrays.instances.alien.c-types.float
|
||||
specialized-arrays.instances.alien.c-types.uint splitting xml
|
||||
xml.data xml.traversal math.order
|
||||
namespaces combinators images gpu.shaders io ;
|
||||
IN: collada
|
||||
|
||||
TUPLE: model attribute-buffer index-buffer vertex-format ;
|
||||
TUPLE: source semantic offset data ;
|
||||
|
||||
SYMBOLS: up-axis unit-ratio ;
|
||||
|
||||
ERROR: missing-attr tag attr ;
|
||||
ERROR: missing-child tag child-name ;
|
||||
|
||||
: string>numbers ( string -- number-seq )
|
||||
" \t\n" split [ string>number ] map ;
|
||||
|
||||
: x/ ( tag child-name -- child-tag )
|
||||
[ tag-named ]
|
||||
[ rot dup [ drop missing-child ] unless 2nip ]
|
||||
2bi ; inline
|
||||
|
||||
: x@ ( tag attr-name -- attr-value )
|
||||
[ attr ]
|
||||
[ rot dup [ drop missing-attr ] unless 2nip ]
|
||||
2bi ; inline
|
||||
|
||||
: xt ( tag -- content ) children>string ;
|
||||
|
||||
: x* ( tag child-name quot -- seq )
|
||||
[ tags-named ] dip map ; inline
|
||||
|
||||
SINGLETONS: x-up y-up z-up ;
|
||||
|
||||
UNION: rh-up x-up y-up z-up ;
|
||||
|
||||
GENERIC: >y-up-axis! ( seq from-axis -- seq )
|
||||
M: x-up >y-up-axis!
|
||||
drop dup
|
||||
[
|
||||
[ 0 swap nth ]
|
||||
[ 1 swap nth neg ]
|
||||
[ 2 swap nth ] tri
|
||||
swap -rot
|
||||
] [
|
||||
[ 2 swap set-nth ]
|
||||
[ 1 swap set-nth ]
|
||||
[ 0 swap set-nth ] tri
|
||||
] bi ;
|
||||
M: y-up >y-up-axis! drop ;
|
||||
M: z-up >y-up-axis!
|
||||
drop dup
|
||||
[
|
||||
[ 0 swap nth ]
|
||||
[ 1 swap nth neg ]
|
||||
[ 2 swap nth ] tri
|
||||
swap
|
||||
] [
|
||||
[ 2 swap set-nth ]
|
||||
[ 1 swap set-nth ]
|
||||
[ 0 swap set-nth ] tri
|
||||
] bi ;
|
||||
|
||||
: source>seq ( source-tag up-axis scale -- sequence )
|
||||
rot
|
||||
[ "float_array" x/ xt string>numbers [ * ] with map ]
|
||||
[ nip "technique_common" x/ "accessor" x/ "stride" x@ string>number ] 2bi
|
||||
<groups>
|
||||
[ swap >y-up-axis! ] with map ;
|
||||
|
||||
: source>pair ( source-tag -- pair )
|
||||
[ "id" x@ ]
|
||||
[ up-axis get unit-ratio get source>seq ] bi 2array ;
|
||||
|
||||
: mesh>sources ( mesh-tag -- hashtable )
|
||||
"source" [ source>pair ] x* >hashtable ;
|
||||
|
||||
: mesh>vertices ( mesh-tag -- pair )
|
||||
"vertices" x/
|
||||
[ "id" x@ ]
|
||||
[ "input"
|
||||
[
|
||||
[ "semantic" x@ ]
|
||||
[ "source" x@ ] bi 2array
|
||||
] x*
|
||||
] bi 2array ;
|
||||
|
||||
:: collect-sources ( sources vertices inputs -- sources )
|
||||
inputs
|
||||
[| input |
|
||||
input "source" x@ rest vertices first =
|
||||
[
|
||||
vertices second [| vertex |
|
||||
vertex first
|
||||
input "offset" x@ string>number
|
||||
vertex second rest sources at source boa
|
||||
] map
|
||||
]
|
||||
[
|
||||
input [ "semantic" x@ ]
|
||||
[ "offset" x@ string>number ]
|
||||
[ "source" x@ rest sources at ] tri source boa
|
||||
] if
|
||||
] map flatten ;
|
||||
|
||||
: group-indices ( index-stride triangle-count indices -- grouped-indices )
|
||||
dup length rot / <groups> swap [ <groups> ] curry map ;
|
||||
|
||||
: triangles>numbers ( triangles-tag -- number-seq )
|
||||
"p" x/ children>string " \t\n" split [ string>number ] map ;
|
||||
|
||||
: largest-offset+1 ( source-seq -- largest-offset+1 )
|
||||
[ offset>> ] [ max ] map-reduce 1 + ;
|
||||
|
||||
: <model> ( attribute-buffer index-buffer sources -- model )
|
||||
[ flatten >float-array ]
|
||||
[ flatten >uint-array ]
|
||||
[
|
||||
[
|
||||
{
|
||||
[ semantic>> ]
|
||||
[ drop float-components ]
|
||||
[ data>> first length ]
|
||||
[ drop f ]
|
||||
} cleave vertex-attribute boa
|
||||
] map
|
||||
] tri* model boa ;
|
||||
|
||||
:: soa>aos ( triangles-indices sources -- attribute-buffer index-buffer )
|
||||
V{ } clone :> attribute-buffer
|
||||
V{ } clone :> index-buffer
|
||||
H{ } clone :> inverse-attribute-buffer
|
||||
triangles-indices [
|
||||
[
|
||||
[| triangle-index triangle-offset |
|
||||
triangle-index triangle-offset sources
|
||||
[| index offset source |
|
||||
source offset>> offset = [
|
||||
index source data>> nth
|
||||
] [ f ] if
|
||||
] with with map sift flatten :> attributes
|
||||
|
||||
attributes inverse-attribute-buffer at [
|
||||
index-buffer push
|
||||
] [
|
||||
attribute-buffer length
|
||||
[ attributes inverse-attribute-buffer set-at ]
|
||||
[ index-buffer push ] bi
|
||||
attributes attribute-buffer push
|
||||
] if*
|
||||
] each-index
|
||||
] each
|
||||
] each
|
||||
attribute-buffer index-buffer ;
|
||||
|
||||
: triangles>model ( sources vertices triangles-tag -- model )
|
||||
[ "input" tags-named collect-sources ] keep swap
|
||||
|
||||
[
|
||||
largest-offset+1 swap
|
||||
[ "count" x@ string>number ] [ triangles>numbers ] bi
|
||||
group-indices
|
||||
]
|
||||
[
|
||||
[ soa>aos ] keep <model>
|
||||
] bi ;
|
||||
|
||||
: mesh>triangles ( sources vertices mesh-tag -- models )
|
||||
"triangles" tags-named [ triangles>model ] with with map ;
|
||||
|
||||
: mesh>models ( mesh-tag -- models )
|
||||
[
|
||||
{ { up-axis z-up } { unit-ratio 0.5 } } [
|
||||
mesh>sources
|
||||
] bind
|
||||
]
|
||||
[ mesh>vertices ]
|
||||
[ mesh>triangles ] tri ;
|
|
@ -0,0 +1,195 @@
|
|||
! Copyright (C) 2010 Erik Charlebois
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors alien.c-types arrays classes.struct combinators
|
||||
combinators.short-circuit game.loop game.worlds gpu gpu.buffers
|
||||
gpu.util.wasd gpu.framebuffers gpu.render gpu.shaders gpu.state
|
||||
gpu.textures gpu.util grouping http.client images images.loader
|
||||
io io.encodings.ascii io.files io.files.temp kernel locals math
|
||||
math.matrices math.vectors.simd math.parser math.vectors
|
||||
method-chains namespaces sequences splitting threads ui ui.gadgets
|
||||
ui.gadgets.worlds ui.pixel-formats specialized-arrays
|
||||
specialized-vectors literals collada fry xml xml.traversal sequences.deep
|
||||
|
||||
opengl.gl
|
||||
prettyprint ;
|
||||
FROM: alien.c-types => float ;
|
||||
SPECIALIZED-ARRAY: float
|
||||
SPECIALIZED-VECTOR: uint
|
||||
IN: collada.viewer
|
||||
|
||||
GLSL-SHADER: collada-vertex-shader vertex-shader
|
||||
uniform mat4 mv_matrix, p_matrix;
|
||||
uniform vec3 light_position;
|
||||
|
||||
attribute vec3 POSITION;
|
||||
attribute vec3 NORMAL;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 position = mv_matrix * vec4(POSITION, 1.0);
|
||||
gl_Position = p_matrix * position;
|
||||
}
|
||||
;
|
||||
|
||||
GLSL-SHADER: collada-fragment-shader fragment-shader
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = vec4(1, 1, 0, 1);
|
||||
}
|
||||
;
|
||||
|
||||
GLSL-PROGRAM: collada-program
|
||||
collada-vertex-shader collada-fragment-shader ;
|
||||
|
||||
GLSL-SHADER: debug-vertex-shader vertex-shader
|
||||
uniform mat4 mv_matrix, p_matrix;
|
||||
uniform vec3 light_position;
|
||||
|
||||
attribute vec3 POSITION;
|
||||
attribute vec3 COLOR;
|
||||
varying vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = p_matrix * mv_matrix * vec4(POSITION, 1.0);
|
||||
color = vec4(COLOR, 1);
|
||||
}
|
||||
;
|
||||
|
||||
GLSL-SHADER: debug-fragment-shader fragment-shader
|
||||
varying vec4 color;
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = color;
|
||||
}
|
||||
;
|
||||
|
||||
GLSL-PROGRAM: debug-program debug-vertex-shader debug-fragment-shader ;
|
||||
|
||||
UNIFORM-TUPLE: collada-uniforms < mvp-uniforms
|
||||
{ "light-position" vec3-uniform f } ;
|
||||
|
||||
TUPLE: collada-state
|
||||
models
|
||||
vertex-arrays
|
||||
index-vectors ;
|
||||
|
||||
TUPLE: collada-world < wasd-world
|
||||
{ collada collada-state } ;
|
||||
|
||||
VERTEX-FORMAT: collada-vertex
|
||||
{ "POSITION" float-components 3 f }
|
||||
{ "NORMAL" float-components 3 f } ;
|
||||
|
||||
VERTEX-FORMAT: debug-vertex
|
||||
{ "POSITION" float-components 3 f }
|
||||
{ "COLOR" float-components 3 f } ;
|
||||
|
||||
: <collada-buffers> ( models -- buffers )
|
||||
! drop
|
||||
! float-array{ -0.5 0 0 1 0 0 0 1 0 0 1 0 0.5 0 0 0 0 1 }
|
||||
! uint-array{ 0 1 2 }
|
||||
! f model boa 1array
|
||||
[
|
||||
[ attribute-buffer>> underlying>> static-upload draw-usage vertex-buffer byte-array>buffer ]
|
||||
[ index-buffer>> underlying>> static-upload draw-usage index-buffer byte-array>buffer ]
|
||||
[ index-buffer>> length ] tri 3array
|
||||
] map ;
|
||||
|
||||
: fill-collada-state ( collada-state -- )
|
||||
dup models>> <collada-buffers>
|
||||
[
|
||||
[
|
||||
first collada-program <program-instance> collada-vertex buffer>vertex-array
|
||||
] map >>vertex-arrays drop
|
||||
]
|
||||
[
|
||||
[
|
||||
[ second ] [ third ] bi
|
||||
'[ _ 0 <buffer-ptr> _ uint-indexes <index-elements> ] call
|
||||
] map >>index-vectors drop
|
||||
] 2bi ;
|
||||
|
||||
: <collada-state> ( -- collada-state )
|
||||
collada-state new
|
||||
#! "C:/Users/erikc/Downloads/mech.dae"
|
||||
"/Users/erikc/Documents/mech.dae"
|
||||
file>xml "mesh" deep-tags-named [ mesh>models ] map flatten >>models ;
|
||||
|
||||
M: collada-world begin-game-world
|
||||
init-gpu
|
||||
{ 0.0 0.0 2.0 } 0 0 set-wasd-view
|
||||
<collada-state> [ fill-collada-state drop ] [ >>collada drop ] 2bi ;
|
||||
|
||||
: <collada-uniforms> ( world -- uniforms )
|
||||
[ wasd-mv-matrix ] [ wasd-p-matrix ] bi
|
||||
{ -10000.0 10000.0 10000.0 } ! light position
|
||||
collada-uniforms boa ;
|
||||
|
||||
: draw-line ( world from to color -- )
|
||||
[ 3 head ] tri@ dup -rot append -rot append swap append >float-array
|
||||
underlying>> stream-upload draw-usage vertex-buffer byte-array>buffer
|
||||
debug-program <program-instance> debug-vertex buffer>vertex-array
|
||||
|
||||
{ 0 1 } >uint-array stream-upload draw-usage index-buffer byte-array>buffer
|
||||
2 '[ _ 0 <buffer-ptr> _ uint-indexes <index-elements> ] call
|
||||
|
||||
rot <collada-uniforms>
|
||||
|
||||
{
|
||||
{ "primitive-mode" [ 3drop lines-mode ] }
|
||||
{ "uniforms" [ nip nip ] }
|
||||
{ "vertex-array" [ drop drop ] }
|
||||
{ "indexes" [ drop nip ] }
|
||||
} 3<render-set> render ;
|
||||
|
||||
: draw-lines ( world lines -- )
|
||||
3 <groups> [ first3 draw-line ] with each ; inline
|
||||
|
||||
: draw-axes ( world -- )
|
||||
{ { 0 0 0 } { 1 0 0 } { 1 0 0 }
|
||||
{ 0 0 0 } { 0 1 0 } { 0 1 0 }
|
||||
{ 0 0 0 } { 0 0 1 } { 0 0 1 } } draw-lines ;
|
||||
|
||||
: draw-collada ( world -- )
|
||||
GL_COLOR_BUFFER_BIT glClear
|
||||
|
||||
[
|
||||
triangle-lines dup t <triangle-state> set-gpu-state
|
||||
[ collada>> vertex-arrays>> ]
|
||||
[ collada>> index-vectors>> ]
|
||||
[ <collada-uniforms> ]
|
||||
tri
|
||||
[
|
||||
{
|
||||
{ "primitive-mode" [ 3drop triangles-mode ] }
|
||||
{ "uniforms" [ nip nip ] }
|
||||
{ "vertex-array" [ drop drop ] }
|
||||
{ "indexes" [ drop nip ] }
|
||||
} 3<render-set> render
|
||||
] curry 2each
|
||||
]
|
||||
[
|
||||
draw-axes
|
||||
]
|
||||
bi ;
|
||||
|
||||
M: collada-world draw-world*
|
||||
draw-collada ;
|
||||
|
||||
M: collada-world wasd-movement-speed drop 1/16. ;
|
||||
M: collada-world wasd-near-plane drop 1/32. ;
|
||||
M: collada-world wasd-far-plane drop 1024.0 ;
|
||||
|
||||
GAME: collada-game {
|
||||
{ world-class collada-world }
|
||||
{ title "Collada Viewer" }
|
||||
{ pixel-format-attributes {
|
||||
windowed
|
||||
double-buffered
|
||||
} }
|
||||
{ grab-input? t }
|
||||
{ use-game-input? t }
|
||||
{ pref-dim { 1024 768 } }
|
||||
{ tick-interval-micros $[ 60 fps ] }
|
||||
} ;
|
|
@ -18,6 +18,7 @@ HOOK: instance-id game-input-backend ( controller -- id )
|
|||
|
||||
HOOK: read-controller game-input-backend ( controller -- controller-state )
|
||||
HOOK: calibrate-controller game-input-backend ( controller -- )
|
||||
HOOK: vibrate-controller game-input-backend ( controller motor1 motor2 -- )
|
||||
|
||||
HOOK: read-keyboard game-input-backend ( -- keyboard-state )
|
||||
|
||||
|
@ -90,7 +91,7 @@ M: mouse-state clone
|
|||
call-next-method dup buttons>> clone >>buttons ;
|
||||
|
||||
{
|
||||
{ [ os windows? ] [ "game.input.dinput" require ] }
|
||||
{ [ os windows? ] [ "game.input.xinput" require ] }
|
||||
{ [ os macosx? ] [ "game.input.iokit" require ] }
|
||||
{ [ t ] [ ] }
|
||||
} cond
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Erik Charlebois
|
|
@ -0,0 +1 @@
|
|||
XInput backend for game.input, borrows keyboard and mouse handling from game.input.dinput
|
|
@ -0,0 +1,2 @@
|
|||
unportable
|
||||
games
|
|
@ -0,0 +1,142 @@
|
|||
USING: game.input math math.order kernel macros fry sequences quotations
|
||||
arrays windows.directx.xinput combinators accessors windows.types
|
||||
game.input.dinput sequences.private namespaces classes.struct
|
||||
windows.errors windows.com.syntax io.encodings.utf16n alien.strings ;
|
||||
IN: game.input.xinput
|
||||
|
||||
SINGLETON: xinput-game-input-backend
|
||||
|
||||
xinput-game-input-backend game-input-backend set-global
|
||||
|
||||
<PRIVATE
|
||||
: >axis ( short -- float )
|
||||
32768 /f ; inline
|
||||
: >trigger ( byte -- float )
|
||||
255 /f ; inline
|
||||
: >vibration ( float -- short )
|
||||
65535 * >fixnum 0 65535 clamp ; inline
|
||||
MACRO: map-index-compose ( seq quot -- seq )
|
||||
'[ '[ _ execute _ ] _ compose ] map-index 1quotation ;
|
||||
|
||||
: fill-buttons ( button-bitmap -- button-array )
|
||||
10 0.0 <array> dup rot >fixnum
|
||||
{ XINPUT_GAMEPAD_START
|
||||
XINPUT_GAMEPAD_BACK
|
||||
XINPUT_GAMEPAD_LEFT_THUMB
|
||||
XINPUT_GAMEPAD_RIGHT_THUMB
|
||||
XINPUT_GAMEPAD_LEFT_SHOULDER
|
||||
XINPUT_GAMEPAD_RIGHT_SHOULDER
|
||||
XINPUT_GAMEPAD_A
|
||||
XINPUT_GAMEPAD_B
|
||||
XINPUT_GAMEPAD_X
|
||||
XINPUT_GAMEPAD_Y }
|
||||
[ [ bitand ] dip swap 0 = [ 2drop ] [ 1.0 -rot swap set-nth ] if ]
|
||||
map-index-compose 2cleave ;
|
||||
|
||||
: >pov ( byte -- symbol )
|
||||
{
|
||||
pov-neutral
|
||||
pov-up
|
||||
pov-down
|
||||
pov-neutral
|
||||
pov-left
|
||||
pov-up-left
|
||||
pov-down-left
|
||||
pov-neutral
|
||||
pov-right
|
||||
pov-up-right
|
||||
pov-down-right
|
||||
pov-neutral
|
||||
pov-neutral
|
||||
pov-neutral
|
||||
pov-neutral
|
||||
pov-neutral
|
||||
} nth ;
|
||||
|
||||
: fill-controller-state ( XINPUT_STATE -- controller-state )
|
||||
Gamepad>> controller-state new dup rot
|
||||
{
|
||||
[ wButtons>> HEX: f bitand >pov swap (>>pov) ]
|
||||
[ wButtons>> fill-buttons swap (>>buttons) ]
|
||||
[ sThumbLX>> >axis swap (>>x) ]
|
||||
[ sThumbLY>> >axis swap (>>y) ]
|
||||
[ sThumbRX>> >axis swap (>>rx) ]
|
||||
[ sThumbRY>> >axis swap (>>ry) ]
|
||||
[ bLeftTrigger>> >trigger swap (>>z) ]
|
||||
[ bRightTrigger>> >trigger swap (>>rz) ]
|
||||
} 2cleave ;
|
||||
PRIVATE>
|
||||
|
||||
M: xinput-game-input-backend (open-game-input)
|
||||
TRUE XInputEnable
|
||||
create-dinput
|
||||
create-device-change-window
|
||||
find-keyboard
|
||||
find-mouse
|
||||
add-wm-devicechange ;
|
||||
|
||||
M: xinput-game-input-backend (close-game-input)
|
||||
remove-wm-devicechange
|
||||
release-mouse
|
||||
release-keyboard
|
||||
close-device-change-window
|
||||
delete-dinput
|
||||
FALSE XInputEnable ;
|
||||
|
||||
M: xinput-game-input-backend (reset-game-input)
|
||||
global [
|
||||
{
|
||||
+dinput+ +keyboard-device+ +keyboard-state+
|
||||
+controller-devices+ +controller-guids+
|
||||
+device-change-window+ +device-change-handle+
|
||||
} [ off ] each
|
||||
] bind ;
|
||||
|
||||
M: xinput-game-input-backend get-controllers
|
||||
{ 0 1 2 3 } ;
|
||||
|
||||
M: xinput-game-input-backend product-string
|
||||
dup number?
|
||||
[ drop "Controller (Xbox 360 Wireless Receiver for Windows)" ]
|
||||
[ handle>> device-info tszProductName>> utf16n alien>string ]
|
||||
if ;
|
||||
|
||||
M: xinput-game-input-backend product-id
|
||||
dup number?
|
||||
[ drop GUID: {02a1045e-0000-0000-0000-504944564944} ]
|
||||
[ handle>> device-info guidProduct>> ]
|
||||
if ;
|
||||
|
||||
M: xinput-game-input-backend instance-id
|
||||
dup number?
|
||||
[ drop GUID: {c6075b30-fbca-11de-8001-444553540000} ]
|
||||
[ handle>> device-guid ]
|
||||
if ;
|
||||
|
||||
M: xinput-game-input-backend read-controller
|
||||
XINPUT_STATE <struct> [ XInputGetState ] keep
|
||||
swap drop fill-controller-state ;
|
||||
|
||||
M: xinput-game-input-backend calibrate-controller drop ;
|
||||
|
||||
M: xinput-game-input-backend vibrate-controller
|
||||
[ >vibration ] bi@ XINPUT_VIBRATION <struct-boa> XInputSetState drop ;
|
||||
|
||||
M: xinput-game-input-backend read-keyboard
|
||||
+keyboard-device+ get
|
||||
[ +keyboard-state+ get [ keys>> underlying>> get-device-state ] keep ]
|
||||
[ ] [ f ] with-acquisition ;
|
||||
|
||||
M: xinput-game-input-backend read-mouse
|
||||
+mouse-device+ get [ +mouse-buffer+ get MOUSE-BUFFER-SIZE read-device-buffer ]
|
||||
[ fill-mouse-state ] [ f ] with-acquisition ;
|
||||
|
||||
M: xinput-game-input-backend reset-mouse
|
||||
+mouse-device+ get [ f MOUSE-BUFFER-SIZE read-device-buffer ]
|
||||
[ 2drop ] [ ] with-acquisition
|
||||
+mouse-state+ get
|
||||
0 >>dx
|
||||
0 >>dy
|
||||
0 >>scroll-dx
|
||||
0 >>scroll-dy
|
||||
drop ;
|
|
@ -0,0 +1 @@
|
|||
Erik Charlebois
|
|
@ -0,0 +1,290 @@
|
|||
! Copyright (C) 2010 Erik Charlebois
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors images images.loader io io.binary kernel
|
||||
locals math sequences io.encodings.ascii io.encodings.string
|
||||
calendar math.ranges math.parser colors arrays hashtables
|
||||
ui.pixel-formats combinators continuations ;
|
||||
IN: images.tga
|
||||
|
||||
SINGLETON: tga-image
|
||||
"tga" tga-image register-image-class
|
||||
|
||||
ERROR: bad-tga-header ;
|
||||
ERROR: bad-tga-footer ;
|
||||
ERROR: bad-tga-extension-size ;
|
||||
ERROR: bad-tga-timestamp ;
|
||||
ERROR: bad-tga-unsupported ;
|
||||
|
||||
: read-id-length ( -- byte )
|
||||
1 read le> ; inline
|
||||
|
||||
: read-color-map-type ( -- byte )
|
||||
1 read le> dup
|
||||
{ 0 1 } member? [ bad-tga-header ] unless ;
|
||||
|
||||
: read-image-type ( -- byte )
|
||||
1 read le> dup
|
||||
{ 0 1 2 3 9 10 11 } member? [ bad-tga-header ] unless ; inline
|
||||
|
||||
: read-color-map-first ( -- short )
|
||||
2 read le> ; inline
|
||||
|
||||
: read-color-map-length ( -- short )
|
||||
2 read le> ; inline
|
||||
|
||||
: read-color-map-entry-size ( -- byte )
|
||||
1 read le> ; inline
|
||||
|
||||
: read-x-origin ( -- short )
|
||||
2 read le> ; inline
|
||||
|
||||
: read-y-origin ( -- short )
|
||||
2 read le> ; inline
|
||||
|
||||
: read-image-width ( -- short )
|
||||
2 read le> ; inline
|
||||
|
||||
: read-image-height ( -- short )
|
||||
2 read le> ; inline
|
||||
|
||||
: read-pixel-depth ( -- byte )
|
||||
1 read le> ; inline
|
||||
|
||||
: read-image-descriptor ( -- alpha-bits pixel-order )
|
||||
1 read le>
|
||||
[ 7 bitand ] [ 24 bitand -3 shift ] bi ; inline
|
||||
|
||||
: read-image-id ( length -- image-id )
|
||||
read ; inline
|
||||
|
||||
: read-color-map ( type length elt-size -- color-map )
|
||||
pick 1 = [ 8 align 8 / * read ] [ 2drop f ] if swap drop ; inline
|
||||
|
||||
: read-image-data ( width height depth -- image-data )
|
||||
8 align 8 / * * read ; inline
|
||||
|
||||
: read-extension-area-offset ( -- offset )
|
||||
4 read le> ; inline
|
||||
|
||||
: read-developer-directory-offset ( -- offset )
|
||||
4 read le> ; inline
|
||||
|
||||
: read-signature ( -- )
|
||||
18 read ascii decode "TRUEVISION-XFILE.\0" = [ bad-tga-footer ] unless ; inline
|
||||
|
||||
: read-extension-size ( -- )
|
||||
2 read le> 495 = [ bad-tga-extension-size ] unless ; inline
|
||||
|
||||
: read-author-name ( -- string )
|
||||
41 read ascii decode [ 0 = ] trim ; inline
|
||||
|
||||
: read-author-comments ( -- string )
|
||||
4 iota [ drop 81 read ascii decode [ 0 = ] trim ] map concat ; inline
|
||||
|
||||
: read-date-timestamp ( -- timestamp )
|
||||
timestamp new
|
||||
2 read le> dup 12 [1,b] member? [ bad-tga-timestamp ] unless >>month
|
||||
2 read le> dup 31 [1,b] member? [ bad-tga-timestamp ] unless >>day
|
||||
2 read le> >>year
|
||||
2 read le> dup 23 [0,b] member? [ bad-tga-timestamp ] unless >>hour
|
||||
2 read le> dup 59 [0,b] member? [ bad-tga-timestamp ] unless >>minute
|
||||
2 read le> dup 59 [0,b] member? [ bad-tga-timestamp ] unless >>second ; inline
|
||||
|
||||
: read-job-name ( -- string )
|
||||
41 read ascii decode [ 0 = ] trim ; inline
|
||||
|
||||
: read-job-time ( -- duration )
|
||||
duration new
|
||||
2 read le> >>hour
|
||||
2 read le> dup 59 [0,b] member? [ bad-tga-timestamp ] unless >>minute
|
||||
2 read le> dup 59 [0,b] member? [ bad-tga-timestamp ] unless >>second ; inline
|
||||
|
||||
: read-software-id ( -- string )
|
||||
41 read ascii decode [ 0 = ] trim ; inline
|
||||
|
||||
: read-software-version ( -- string )
|
||||
2 read le> 100 /f number>string
|
||||
1 read ascii decode append [ " " = ] trim ; inline
|
||||
|
||||
:: read-key-color ( -- color )
|
||||
1 read le> 255 /f :> alpha
|
||||
1 read le> 255 /f
|
||||
1 read le> 255 /f
|
||||
1 read le> 255 /f
|
||||
alpha <rgba> ; inline
|
||||
|
||||
: read-pixel-aspect-ratio ( -- aspect-ratio )
|
||||
2 read le> 2 read le> /f ; inline
|
||||
|
||||
: read-gamma-value ( -- gamma-value )
|
||||
2 read le> 2 read le> /f ; inline
|
||||
|
||||
: read-color-correction-offset ( -- offset )
|
||||
4 read le> ; inline
|
||||
|
||||
: read-postage-stamp-offset ( -- offset )
|
||||
4 read le> ; inline
|
||||
|
||||
: read-scan-line-offset ( -- offset )
|
||||
4 read le> ; inline
|
||||
|
||||
: read-premultiplied-alpha ( -- boolean )
|
||||
1 read le> 4 = ; inline
|
||||
|
||||
: read-scan-line-table ( height -- scan-offsets )
|
||||
iota [ drop 4 read le> ] map ; inline
|
||||
|
||||
: read-postage-stamp-image ( depth -- postage-data )
|
||||
8 align 8 / 1 read le> 1 read le> * * read ; inline
|
||||
|
||||
:: read-color-correction-table ( -- correction-table )
|
||||
256 iota
|
||||
[
|
||||
drop
|
||||
4 iota
|
||||
[
|
||||
drop
|
||||
2 read le> 65535 /f :> alpha
|
||||
2 read le> 65535 /f
|
||||
2 read le> 65535 /f
|
||||
2 read le> 65535 /f
|
||||
alpha <rgba>
|
||||
] map
|
||||
] map ; inline
|
||||
|
||||
: read-developer-directory ( -- developer-directory )
|
||||
2 read le> iota
|
||||
[
|
||||
drop
|
||||
2 read le>
|
||||
4 read le>
|
||||
4 read le>
|
||||
3array
|
||||
] map ; inline
|
||||
|
||||
: read-developer-areas ( developer-directory -- developer-area-map )
|
||||
[
|
||||
[ first ]
|
||||
[ dup third second seek-absolute seek-input read ] bi 2array
|
||||
] map >hashtable ; inline
|
||||
|
||||
:: read-tga ( -- image )
|
||||
#! Read header
|
||||
read-id-length :> id-length
|
||||
read-color-map-type :> map-type
|
||||
read-image-type :> image-type
|
||||
read-color-map-first :> map-first
|
||||
read-color-map-length :> map-length
|
||||
read-color-map-entry-size :> map-entry-size
|
||||
read-x-origin :> x-origin
|
||||
read-y-origin :> y-origin
|
||||
read-image-width :> image-width
|
||||
read-image-height :> image-height
|
||||
read-pixel-depth :> pixel-depth
|
||||
read-image-descriptor :> ( alpha-bits pixel-order )
|
||||
id-length read-image-id :> image-id
|
||||
map-type map-length map-entry-size read-color-map :> color-map-data
|
||||
image-width image-height pixel-depth read-image-data :> image-data
|
||||
|
||||
[
|
||||
#! Read optional footer
|
||||
26 seek-end seek-input
|
||||
read-extension-area-offset :> extension-offset
|
||||
read-developer-directory-offset :> directory-offset
|
||||
read-signature
|
||||
|
||||
#! Read optional extension section
|
||||
extension-offset 0 =
|
||||
[
|
||||
extension-offset seek-absolute seek-input
|
||||
read-extension-size
|
||||
read-author-name :> author-name
|
||||
read-author-comments :> author-comments
|
||||
read-date-timestamp :> date-timestamp
|
||||
read-job-name :> job-name
|
||||
read-job-time :> job-time
|
||||
read-software-id :> software-id
|
||||
read-software-version :> software-version
|
||||
read-key-color :> key-color
|
||||
read-pixel-aspect-ratio :> aspect-ratio
|
||||
read-gamma-value :> gamma-value
|
||||
read-color-correction-offset :> color-correction-offset
|
||||
read-postage-stamp-offset :> postage-stamp-offset
|
||||
read-scan-line-offset :> scan-line-offset
|
||||
read-premultiplied-alpha :> premultiplied-alpha
|
||||
|
||||
color-correction-offset 0 =
|
||||
[
|
||||
color-correction-offset seek-absolute seek-input
|
||||
read-color-correction-table :> color-correction-table
|
||||
] unless
|
||||
|
||||
postage-stamp-offset 0 =
|
||||
[
|
||||
postage-stamp-offset seek-absolute seek-input
|
||||
pixel-depth read-postage-stamp-image :> postage-data
|
||||
] unless
|
||||
|
||||
scan-line-offset seek-absolute seek-input
|
||||
image-height read-scan-line-table :> scan-offsets
|
||||
|
||||
#! Read optional developer section
|
||||
directory-offset 0 =
|
||||
[ f ]
|
||||
[
|
||||
directory-offset seek-absolute seek-input
|
||||
read-developer-directory read-developer-areas
|
||||
] if :> developer-areas
|
||||
] unless
|
||||
] ignore-errors
|
||||
|
||||
#! Only 24-bit uncompressed RGB and 32-bit uncompressed ARGB are supported.
|
||||
#! Other formats would need to be converted to work within the image class.
|
||||
map-type 0 = [ bad-tga-unsupported ] unless
|
||||
image-type 2 = [ bad-tga-unsupported ] unless
|
||||
pixel-depth { 24 32 } member? [ bad-tga-unsupported ] unless
|
||||
pixel-order { 0 2 } member? [ bad-tga-unsupported ] unless
|
||||
|
||||
#! Create image instance
|
||||
image new
|
||||
alpha-bits 0 = [ RGB ] [ ARGB ] if >>component-order
|
||||
{ image-width image-height } >>dim
|
||||
pixel-order 0 = >>upside-down?
|
||||
image-data >>bitmap
|
||||
ubyte-components >>component-type ;
|
||||
|
||||
M: tga-image stream>image
|
||||
drop [ read-tga ] with-input-stream ;
|
||||
|
||||
M: tga-image image>stream
|
||||
drop
|
||||
[
|
||||
component-order>> { RGB ARGB } member? [ bad-tga-unsupported ] unless
|
||||
] keep
|
||||
|
||||
B{ 0 } write #! id-length
|
||||
B{ 0 } write #! map-type
|
||||
B{ 2 } write #! image-type
|
||||
B{ 0 0 0 0 0 } write #! color map first, length, entry size
|
||||
B{ 0 0 0 0 } write #! x-origin, y-origin
|
||||
{
|
||||
[ dim>> first 2 >le write ]
|
||||
[ dim>> second 2 >le write ]
|
||||
[ component-order>>
|
||||
{
|
||||
{ RGB [ B{ 24 } write ] }
|
||||
{ ARGB [ B{ 32 } write ] }
|
||||
} case
|
||||
]
|
||||
[
|
||||
dup component-order>>
|
||||
{
|
||||
{ RGB [ 0 ] }
|
||||
{ ARGB [ 8 ] }
|
||||
} case swap
|
||||
upside-down?>> [ 0 ] [ 2 ] if 3 shift bitor
|
||||
1 >le write
|
||||
]
|
||||
[ bitmap>> write ]
|
||||
} cleave ;
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: alien alien.c-types alien.syntax parser namespaces
|
||||
kernel math windows.types generalizations math.bitwise
|
||||
classes.struct literals windows.kernel32 ;
|
||||
classes.struct literals windows.kernel32 system accessors ;
|
||||
IN: windows.user32
|
||||
|
||||
! HKL for ActivateKeyboardLayout
|
||||
|
@ -608,6 +608,181 @@ CONSTANT: MF_HELP HEX: 4000
|
|||
CONSTANT: MF_RIGHTJUSTIFY HEX: 4000
|
||||
CONSTANT: MF_MOUSESELECT HEX: 8000
|
||||
|
||||
TYPEDEF: HANDLE HRAWINPUT
|
||||
: GET_RAWINPUT_CODE_WPARAM ( wParam -- n ) HEX: ff bitand ; inline
|
||||
|
||||
CONSTANT: RIM_INPUT 0
|
||||
CONSTANT: RIM_INPUTSINK 1
|
||||
|
||||
CONSTANT: RIM_TYPEMOUSE 0
|
||||
CONSTANT: RIM_TYPEKEYBOARD 1
|
||||
CONSTANT: RIM_TYPEHID 2
|
||||
|
||||
STRUCT: RAWINPUTHEADER
|
||||
{ dwType DWORD }
|
||||
{ dwSize DWORD }
|
||||
{ hDevice HANDLE }
|
||||
{ wParam WPARAM } ;
|
||||
TYPEDEF: RAWINPUTHEADER* PRAWINPUTHEADER
|
||||
TYPEDEF: RAWINPUTHEADER* LPRAWINPUTHEADER
|
||||
STRUCT: RAWMOUSE_BUTTONS_USBUTTONS
|
||||
{ usButtonFlags USHORT }
|
||||
{ usButtonData USHORT } ;
|
||||
|
||||
UNION-STRUCT: RAWMOUSE_BUTTONS
|
||||
{ ulButtons ULONG }
|
||||
{ usButtons RAWMOUSE_BUTTONS_USBUTTONS } ;
|
||||
STRUCT: RAWMOUSE
|
||||
{ usFlags USHORT }
|
||||
{ uButtons RAWMOUSE_BUTTONS }
|
||||
{ ulRawButtons ULONG }
|
||||
{ lLastX LONG }
|
||||
{ lLastY LONG }
|
||||
{ ulExtraInformation ULONG } ;
|
||||
TYPEDEF: RAWMOUSE* PRAWMOUSE
|
||||
TYPEDEF: RAWMOUSE* LPRAWMOUSE
|
||||
|
||||
CONSTANT: RI_MOUSE_LEFT_BUTTON_DOWN HEX: 0001
|
||||
CONSTANT: RI_MOUSE_LEFT_BUTTON_UP HEX: 0002
|
||||
CONSTANT: RI_MOUSE_RIGHT_BUTTON_DOWN HEX: 0004
|
||||
CONSTANT: RI_MOUSE_RIGHT_BUTTON_UP HEX: 0008
|
||||
CONSTANT: RI_MOUSE_MIDDLE_BUTTON_DOWN HEX: 0010
|
||||
CONSTANT: RI_MOUSE_MIDDLE_BUTTON_UP HEX: 0020
|
||||
|
||||
: RI_MOUSE_BUTTON_1_DOWN ( -- n ) RI_MOUSE_LEFT_BUTTON_DOWN ; inline
|
||||
: RI_MOUSE_BUTTON_1_UP ( -- n ) RI_MOUSE_LEFT_BUTTON_UP ; inline
|
||||
: RI_MOUSE_BUTTON_2_DOWN ( -- n ) RI_MOUSE_RIGHT_BUTTON_DOWN ; inline
|
||||
: RI_MOUSE_BUTTON_2_UP ( -- n ) RI_MOUSE_RIGHT_BUTTON_UP ; inline
|
||||
: RI_MOUSE_BUTTON_3_DOWN ( -- n ) RI_MOUSE_MIDDLE_BUTTON_DOWN ; inline
|
||||
: RI_MOUSE_BUTTON_3_UP ( -- n ) RI_MOUSE_MIDDLE_BUTTON_UP ; inline
|
||||
|
||||
CONSTANT: RI_MOUSE_BUTTON_4_DOWN HEX: 0040
|
||||
CONSTANT: RI_MOUSE_BUTTON_4_UP HEX: 0080
|
||||
CONSTANT: RI_MOUSE_BUTTON_5_DOWN HEX: 0100
|
||||
CONSTANT: RI_MOUSE_BUTTON_5_UP HEX: 0200
|
||||
CONSTANT: RI_MOUSE_WHEEL HEX: 0400
|
||||
|
||||
CONSTANT: MOUSE_MOVE_RELATIVE 0
|
||||
CONSTANT: MOUSE_MOVE_ABSOLUTE 1
|
||||
CONSTANT: MOUSE_VIRTUAL_DESKTOP HEX: 02
|
||||
CONSTANT: MOUSE_ATTRIBUTES_CHANGED HEX: 04
|
||||
CONSTANT: MOUSE_MOVE_NOCOALESCE HEX: 08
|
||||
|
||||
STRUCT: RAWKEYBOARD
|
||||
{ MakeCode USHORT }
|
||||
{ Flags USHORT }
|
||||
{ Reserved USHORT }
|
||||
{ VKey USHORT }
|
||||
{ Message UINT }
|
||||
{ ExtraInformation ULONG } ;
|
||||
TYPEDEF: RAWKEYBOARD* PRAWKEYBOARD
|
||||
TYPEDEF: RAWKEYBOARD* LPRAWKEYBOARD
|
||||
|
||||
CONSTANT: KEYBOARD_OVERRUN_MAKE_CODE HEX: FF
|
||||
|
||||
CONSTANT: RI_KEY_MAKE 0
|
||||
CONSTANT: RI_KEY_BREAK 1
|
||||
CONSTANT: RI_KEY_E0 2
|
||||
CONSTANT: RI_KEY_E1 4
|
||||
CONSTANT: RI_KEY_TERMSRV_SET_LED 8
|
||||
CONSTANT: RI_KEY_TERMSRV_SHADOW HEX: 10
|
||||
|
||||
STRUCT: RAWHID
|
||||
{ dwSizeHid DWORD }
|
||||
{ dwCount DWORD }
|
||||
{ bRawData BYTE[1] } ;
|
||||
TYPEDEF: RAWHID* PRAWHID
|
||||
TYPEDEF: RAWHID* LPRAWHID
|
||||
|
||||
UNION-STRUCT: RAWINPUT_UNION
|
||||
{ mouse RAWMOUSE }
|
||||
{ keyboard RAWKEYBOARD }
|
||||
{ hid RAWHID } ;
|
||||
STRUCT: RAWINPUT
|
||||
{ header RAWINPUTHEADER }
|
||||
{ data RAWINPUT_UNION } ;
|
||||
TYPEDEF: RAWINPUT* PRAWINPUT
|
||||
TYPEDEF: RAWINPUT* LPRAWINPUT
|
||||
|
||||
: RAWINPUT_ALIGN ( x -- y )
|
||||
cpu x86.32 = [ 4 ] [ 8 ] if align ; inline
|
||||
: NEXTRAWINPUTBLOCK ( struct -- next-struct )
|
||||
dup header>> dwSize>> swap <displaced-alien> RAWINPUT_ALIGN RAWINPUT memory>struct ; inline
|
||||
|
||||
CONSTANT: RID_INPUT HEX: 10000003
|
||||
CONSTANT: RID_HEADER HEX: 10000005
|
||||
CONSTANT: RIDI_PREPARSEDDATA HEX: 20000005
|
||||
CONSTANT: RIDI_DEVICENAME HEX: 20000007
|
||||
CONSTANT: RIDI_DEVICEINFO HEX: 2000000b
|
||||
|
||||
STRUCT: RID_DEVICE_INFO_MOUSE
|
||||
{ dwId DWORD }
|
||||
{ dwNumberOfButtons DWORD }
|
||||
{ dwSampleRate DWORD }
|
||||
{ fHasHorizontalWheel BOOL } ;
|
||||
TYPEDEF: RID_DEVICE_INFO_MOUSE* PRID_DEVICE_INFO_MOUSE
|
||||
|
||||
STRUCT: RID_DEVICE_INFO_KEYBOARD
|
||||
{ dwType DWORD }
|
||||
{ dwSubType DWORD }
|
||||
{ dwKeyboardMode DWORD }
|
||||
{ dwNumberOfFunctionKeys DWORD }
|
||||
{ dwNumberOfIndicators DWORD }
|
||||
{ dwNumberOfKeysTotal DWORD } ;
|
||||
TYPEDEF: RID_DEVICE_INFO_KEYBOARD* PRID_DEVICE_INFO_KEYBOARD
|
||||
|
||||
STRUCT: RID_DEVICE_INFO_HID
|
||||
{ dwVendorId DWORD }
|
||||
{ dwProductId DWORD }
|
||||
{ dwVersionNumber DWORD }
|
||||
{ usUsagePage USHORT }
|
||||
{ usUsage USHORT } ;
|
||||
TYPEDEF: RID_DEVICE_INFO_HID* PRID_DEVICE_INFO_HID
|
||||
|
||||
UNION-STRUCT: RID_DEVICE_INFO_UNION
|
||||
{ mouse RID_DEVICE_INFO_MOUSE }
|
||||
{ keyboard RID_DEVICE_INFO_KEYBOARD }
|
||||
{ hid RID_DEVICE_INFO_HID } ;
|
||||
STRUCT: RID_DEVICE_INFO
|
||||
{ cbSize DWORD }
|
||||
{ dwType DWORD }
|
||||
{ data RID_DEVICE_INFO_UNION } ;
|
||||
TYPEDEF: RID_DEVICE_INFO* PRID_DEVICE_INFO
|
||||
TYPEDEF: RID_DEVICE_INFO* LPRID_DEVICE_INFO
|
||||
|
||||
STRUCT: RAWINPUTDEVICE
|
||||
{ usUsagePage USHORT }
|
||||
{ usUsage USHORT }
|
||||
{ dwFlags DWORD }
|
||||
{ hwndTarget HWND } ;
|
||||
TYPEDEF: RAWINPUTDEVICE* PRAWINPUTDEVICE
|
||||
TYPEDEF: RAWINPUTDEVICE* LPRAWINPUTDEVICE
|
||||
TYPEDEF: RAWINPUTDEVICE* PCRAWINPUTDEVICE
|
||||
|
||||
CONSTANT: RIDEV_REMOVE HEX: 00000001
|
||||
CONSTANT: RIDEV_EXCLUDE HEX: 00000010
|
||||
CONSTANT: RIDEV_PAGEONLY HEX: 00000020
|
||||
CONSTANT: RIDEV_NOLEGACY HEX: 00000030
|
||||
CONSTANT: RIDEV_INPUTSINK HEX: 00000100
|
||||
CONSTANT: RIDEV_CAPTUREMOUSE HEX: 00000200
|
||||
CONSTANT: RIDEV_NOHOTKEYS HEX: 00000200
|
||||
CONSTANT: RIDEV_APPKEYS HEX: 00000400
|
||||
CONSTANT: RIDEV_EXINPUTSINK HEX: 00001000
|
||||
CONSTANT: RIDEV_DEVNOTIFY HEX: 00002000
|
||||
CONSTANT: RIDEV_EXMODEMASK HEX: 000000F0
|
||||
|
||||
: RIDEV_EXMODE ( mode -- x ) RIDEV_EXMODEMASK bitand ; inline
|
||||
|
||||
CONSTANT: GIDC_ARRIVAL 1
|
||||
CONSTANT: GIDC_REMOVAL 2
|
||||
|
||||
: GET_DEVICE_CHANGE_WPARAM ( wParam -- x ) HEX: ffff bitand ; inline
|
||||
|
||||
STRUCT: RAWINPUTDEVICELIST
|
||||
{ hDevice HANDLE }
|
||||
{ dwType DWORD } ;
|
||||
TYPEDEF: RAWINPUTDEVICELIST* PRAWINPUTDEVICELIST
|
||||
|
||||
LIBRARY: user32
|
||||
|
||||
FUNCTION: HKL ActivateKeyboardLayout ( HKL hkl, UINT Flags ) ;
|
||||
|
@ -775,7 +950,7 @@ ALIAS: CreateWindowEx CreateWindowExW
|
|||
! FUNCTION: DefFrameProcW
|
||||
! FUNCTION: DefMDIChildProcA
|
||||
! FUNCTION: DefMDIChildProcW
|
||||
! FUNCTION: DefRawInputProc
|
||||
FUNCTION: LRESULT DefRawInputProc ( PRAWINPUT* paRawInput, INT nInput, UINT cbSizeHeader ) ;
|
||||
FUNCTION: LRESULT DefWindowProcW ( HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam ) ;
|
||||
ALIAS: DefWindowProc DefWindowProcW
|
||||
! FUNCTION: DeleteMenu
|
||||
|
@ -985,13 +1160,14 @@ FUNCTION: int GetPriorityClipboardFormat ( UINT* paFormatPriorityList, int cForm
|
|||
! FUNCTION: GetPropA
|
||||
! FUNCTION: GetPropW
|
||||
! FUNCTION: GetQueueStatus
|
||||
! FUNCTION: GetRawInputBuffer
|
||||
! FUNCTION: GetRawInputData
|
||||
! FUNCTION: GetRawInputDeviceInfoA
|
||||
! FUNCTION: GetRawInputDeviceInfoW
|
||||
! FUNCTION: GetRawInputDeviceList
|
||||
FUNCTION: UINT GetRawInputBuffer ( PRAWINPUT pData, PUINT pcbSize, UINT cbSizeHeader ) ;
|
||||
FUNCTION: UINT GetRawInputData ( HRAWINPUT hRawInput, UINT uiCommand, LPVOID pData, PUINT pcbSize, UINT cbSizeHeader ) ;
|
||||
FUNCTION: UINT GetRawInputDeviceInfoA ( HANDLE hDevice, UINT uiCommand, LPVOID pData, PUINT pcbSize ) ;
|
||||
FUNCTION: UINT GetRawInputDeviceInfoW ( HANDLE hDevice, UINT uiCommand, LPVOID pData, PUINT pcbSize ) ;
|
||||
ALIAS: GetRawInputDeviceInfo GetRawInputDeviceInfoW
|
||||
FUNCTION: UINT GetRawInputDeviceList ( PRAWINPUTDEVICELIST pRawInputDeviceList, PUINT puiNumDevices, UINT cbSize ) ;
|
||||
FUNCTION: UINT GetRegisteredRawInputDevices ( PRAWINPUTDEVICE pRawInputDevices, PUINT puiNumDevices, UINT cbSize ) ;
|
||||
! FUNCTION: GetReasonTitleFromReasonCode
|
||||
! FUNCTION: GetRegisteredRawInputDevices
|
||||
! FUNCTION: GetScrollBarInfo
|
||||
! FUNCTION: GetScrollInfo
|
||||
! FUNCTION: GetScrollPos
|
||||
|
@ -1266,7 +1442,7 @@ ALIAS: RegisterDeviceNotification RegisterDeviceNotificationW
|
|||
! FUNCTION: RegisterHotKey
|
||||
! FUNCTION: RegisterLogonProcess
|
||||
! FUNCTION: RegisterMessagePumpHook
|
||||
! FUNCTION: RegisterRawInputDevices
|
||||
FUNCTION: BOOL RegisterRawInputDevices ( PCRAWINPUTDEVICE pRawInputDevices, UINT uiNumDevices, UINT cbSize ) ;
|
||||
! FUNCTION: RegisterServicesProcess
|
||||
! FUNCTION: RegisterShellHookWindow
|
||||
! FUNCTION: RegisterSystemThread
|
||||
|
|
|
@ -159,13 +159,13 @@
|
|||
"MEMO" "MEMO:" "METHOD"
|
||||
"SYNTAX"
|
||||
"PREDICATE" "PRIMITIVE"
|
||||
"STRUCT" "TAG" "TUPLE" "UNION-STRUCT"
|
||||
"UNION"))
|
||||
|
||||
(defconst fuel-syntax--no-indent-def-starts '("ARTICLE"
|
||||
"HELP"
|
||||
"SINGLETONS"
|
||||
"SYMBOLS"
|
||||
"TUPLE"
|
||||
"VARS"))
|
||||
|
||||
(defconst fuel-syntax--indent-def-start-regex
|
||||
|
|
Loading…
Reference in New Issue