{
const c8 *alias;
u8 device_type;
- u32 key, mod;
+ u32 key;
u32 alias_hash;
}
_input_aliases[] =
{ "RIGHT_ALT", k_input_device_keyboard, .key = GLFW_KEY_RIGHT_ALT },
{ "RIGHT_SUPER", k_input_device_keyboard, .key = GLFW_KEY_RIGHT_SUPER },
{ "MENU", k_input_device_keyboard, .key = GLFW_KEY_MENU },
- { "SHIFT", k_input_device_keyboard, .mod = GLFW_MOD_SHIFT },
- { "CONTROL", k_input_device_keyboard, .mod = GLFW_MOD_CONTROL },
- { "ALT", k_input_device_keyboard, .mod = GLFW_MOD_ALT },
- { "SUPER", k_input_device_keyboard, .mod = GLFW_MOD_SUPER },
+ { "SHIFT", k_input_device_modifier, .key = GLFW_MOD_SHIFT },
+ { "CONTROL", k_input_device_modifier, .key = GLFW_MOD_CONTROL },
+ { "ALT", k_input_device_modifier, .key = GLFW_MOD_ALT },
+ { "SUPER", k_input_device_modifier, .key = GLFW_MOD_SUPER },
};
static struct input_alias *_input_alias_find( const c8 *alias, u32 alias_length )
struct input_alias *alias = _input_alias_find( buttons, length );
if( alias )
{
- if( new_bind.device )
+ if( (alias->device_type == k_input_device_keyboard) || (alias->device_type == k_input_device_mouse) )
{
- if( alias->device_type != new_bind.device )
+ if( new_bind.device )
{
- $log( $error, {"Device mismatch while parsing buttons"} );
+ $log( $error, {"Cannot specify more than one normal buttons in bind"} );
return -1;
}
- }
- else
+ new_bind.id = alias->key;
new_bind.device = alias->device_type;
-
- if( (alias->device_type == k_input_device_keyboard) || (alias->device_type == k_input_device_mouse) )
+ }
+ else if( alias->device_type == k_input_device_modifier )
{
- if( alias->key )
- {
- if( new_bind.id )
- {
- $log( $error, {"Cannot specify more than one normal buttons in bind"} );
- return -1;
- }
- new_bind.id = alias->key;
- }
- else //mod
+ if( new_bind.device )
{
- if( new_bind.id )
- {
- $log( $error, {"Modifiers must come first"} );
- return -1;
- }
- new_bind.modifiers |= alias->mod;
+ $log( $error, {"Modifiers must come first"} );
+ return -1;
}
+ new_bind.modifiers |= alias->key;
}
else
{
if( (input->type == k_input_type_action) || (input->type == k_input_type_button) )
{
+ bool allow_activation = 1;
if( input->type == k_input_type_action )
- {
if( bind->modifiers != mods )
- continue;
- }
+ allow_activation = 0;
- if( action == GLFW_REPEAT || action == GLFW_PRESS )
- {
- ASSERT_CRITICAL( state->button.repeat_count < 255 );
- state->button.repeat_count ++;
- }
-
- if( action == GLFW_PRESS )
+ if( allow_activation && (action == GLFW_PRESS) )
{
ASSERT_CRITICAL( state->button.activation_count < 255 );
state->button.activation_count ++;
- if( input->type == k_input_type_button )
- {
- ASSERT_CRITICAL( state->button.hold_count < 255 );
- state->button.hold_count ++;
- }
+ ASSERT_CRITICAL( state->button.hold_count < 255 );
+ state->button.hold_count ++;
+ }
+
+ if( state->button.hold_count && allow_activation && (action == GLFW_REPEAT || action == GLFW_PRESS) )
+ {
+ ASSERT_CRITICAL( state->button.repeat_count < 255 );
+ state->button.repeat_count ++;
}
if( action == GLFW_RELEASE )
{
- if( input->type == k_input_type_button )
+ if( state->button.hold_count )
{
- ASSERT_CRITICAL( state->button.hold_count > 0 );
state->button.hold_count --;
state->button.release_count ++;
}
}
}
-void stretchy_delete( struct stretchy_allocator *stretchy, u32 index )
+void stretchy_shrink( struct stretchy_allocator *stretchy )
{
- if( (stretchy->count > 1) && (index != stretchy->count-1) )
- {
- buffer_copy( stretchy_get( stretchy, stretchy->count-1 ), stretchy->element_size,
- stretchy_get( stretchy, index ), stretchy->element_size );
- }
+ ASSERT_CRITICAL( stretchy->count );
stretchy->count --;
i32 i, offset;
stretchy->segments[i] = NULL;
}
}
+
+void stretchy_delete( struct stretchy_allocator *stretchy, u32 index )
+{
+ if( (stretchy->count > 1) && (index != stretchy->count-1) )
+ {
+ buffer_copy( stretchy_get( stretchy, stretchy->count-1 ), stretchy->element_size,
+ stretchy_get( stretchy, index ), stretchy->element_size );
+ }
+ stretchy_shrink( stretchy );
+}
{" zig cc -Wall -Wno-unused-function -std=c11 -D_DEFAULT_SOURCE -lm \\\n"},
{" -include \"common_api.h\" \\\n"} );
- if( use_tsan ) $v_string( &command_string, {" -fsanitize=thread -lasan \\\n"} );
- if( use_asan ) $v_string( &command_string, {" -fsanitize=address -lasan \\\n"} );
- $v_string( &command_string, { " -O" }, $unsigned( optimise ), {" \\\n"} );
+ if( use_tsan ) $v_string( &command_string, {" -fsanitize=thread -lasan -L/lib/x86_64-linux-gnu \\\n"} );
+ if( use_asan ) $v_string( &command_string, {" -fsanitize=address -lasan -L/lib/x86_64-linux-gnu \\\n"} );
+ $v_string( &command_string, { " -O" }, $unsigned( optimise ) );
+ if( optimise == 0 ) $v_string( &command_string, { " -ggdb" } );
+ $v_string( &command_string, {" \\\n"} );
$v_string( &command_string, {" -target "}, {string_get(&tripple_string)}, {" "} );
if( platform == k_platform_windows )