diff options
author | Andrey Nazarov <skuller@skuller.net> | 2011-12-20 14:37:44 +0400 |
---|---|---|
committer | Andrey Nazarov <skuller@skuller.net> | 2012-04-03 01:25:47 +0400 |
commit | b3e271a53de2610de173f9b2bda5d15dd4d78909 (patch) | |
tree | d567b91dadac42e168bcb13db5fe93ffbc7e1533 /src/in_lirc.c | |
parent | ca4a019a74b11aa21fea2a03c6dff3b183463aab (diff) |
Massive coding style change.
Use linux style brackets. Pad operators with spaces. Unpad parenthesis,
except for ‘if’, ‘for’, ‘while’ constructs.
Diffstat (limited to 'src/in_lirc.c')
-rw-r--r-- | src/in_lirc.c | 85 |
1 files changed, 44 insertions, 41 deletions
diff --git a/src/in_lirc.c b/src/in_lirc.c index 0af53e5..287d4d2 100644 --- a/src/in_lirc.c +++ b/src/in_lirc.c @@ -8,7 +8,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -43,90 +43,93 @@ static struct { ioentry_t *io; } lirc; -void Lirc_GetEvents( void ) { +void Lirc_GetEvents(void) +{ char *code, *str; int ret, key; unsigned time; - if( !lirc.initialized || !lirc.io->canread ) { + if (!lirc.initialized || !lirc.io->canread) { return; } - while( ( ret = lirc_nextcode( &code ) ) == 0 && code ) { + while ((ret = lirc_nextcode(&code)) == 0 && code) { time = Sys_Milliseconds(); - Com_DPrintf( "%s: %u %s\n", __func__, time, code ); - while( ( ret = lirc_code2char( lirc.config, code, &str ) ) == 0 && str ) { - if( *str == '@' ) { - key = Key_StringToKeynum( str + 1 ); - if( key > 0 ) { - Key_Event( key, qtrue, time ); - Key_Event( key, qfalse, time ); + Com_DPrintf("%s: %u %s\n", __func__, time, code); + while ((ret = lirc_code2char(lirc.config, code, &str)) == 0 && str) { + if (*str == '@') { + key = Key_StringToKeynum(str + 1); + if (key > 0) { + Key_Event(key, qtrue, time); + Key_Event(key, qfalse, time); } } else { - Cbuf_AddText( &cmd_buffer, str ); - Cbuf_AddText( &cmd_buffer, "\n" ); + Cbuf_AddText(&cmd_buffer, str); + Cbuf_AddText(&cmd_buffer, "\n"); } } - free( code ); - if( ret ) { + free(code); + if (ret) { goto error; } } - if( ret ) { + if (ret) { error: - Com_EPrintf( "Error reading from LIRC.\n" ); - Cvar_Reset( lirc_enable ); + Com_EPrintf("Error reading from LIRC.\n"); + Cvar_Reset(lirc_enable); Lirc_Shutdown(); } } -void Lirc_Shutdown( void ) { - if( !lirc.initialized ) { +void Lirc_Shutdown(void) +{ + if (!lirc.initialized) { return; } - lirc_freeconfig( lirc.config ); - IO_Remove( lirc.fd ); + lirc_freeconfig(lirc.config); + IO_Remove(lirc.fd); lirc_deinit(); - memset( &lirc, 0, sizeof( lirc ) ); + memset(&lirc, 0, sizeof(lirc)); } -static void lirc_param_changed( cvar_t *self ) { +static void lirc_param_changed(cvar_t *self) +{ Lirc_Shutdown(); Lirc_Init(); } -qboolean Lirc_Init( void ) { - lirc_enable = Cvar_Get( "lirc_enable", "0", 0 ); +qboolean Lirc_Init(void) +{ + lirc_enable = Cvar_Get("lirc_enable", "0", 0); lirc_enable->changed = lirc_param_changed; - lirc_config = Cvar_Get( "lirc_config", "", CVAR_NOSET ); + lirc_config = Cvar_Get("lirc_config", "", CVAR_NOSET); //lirc_config->changed = lirc_param_changed; - if( !lirc_enable->integer ) { + if (!lirc_enable->integer) { return qfalse; } - lirc.fd = lirc_init( APPLICATION, 0 ); - if( lirc.fd == -1 ) { - Com_EPrintf( "Failed to initialize LIRC.\n" ); - Cvar_Reset( lirc_enable ); + lirc.fd = lirc_init(APPLICATION, 0); + if (lirc.fd == -1) { + Com_EPrintf("Failed to initialize LIRC.\n"); + Cvar_Reset(lirc_enable); return qfalse; } - if( lirc_readconfig( lirc_config->string[0] ? lirc_config->string : NULL, - &lirc.config, NULL ) != 0 ) - { - Com_EPrintf( "Failed to read LIRC config.\n" ); + if (lirc_readconfig(lirc_config->string[0] ? lirc_config->string : NULL, + &lirc.config, NULL) != 0) { + Com_EPrintf("Failed to read LIRC config.\n"); lirc_deinit(); - Cvar_Reset( lirc_enable ); + Cvar_Reset(lirc_enable); return qfalse; } - - fcntl( lirc.fd, F_SETFL, fcntl( lirc.fd, F_GETFL, 0 ) | FNDELAY ); - lirc.io = IO_Add( lirc.fd ); + + fcntl(lirc.fd, F_SETFL, fcntl(lirc.fd, F_GETFL, 0) | FNDELAY); + lirc.io = IO_Add(lirc.fd); lirc.io->wantread = qtrue; - Com_Printf( "LIRC interface initialized.\n" ); + Com_Printf("LIRC interface initialized.\n"); lirc.initialized = qtrue; return qtrue; |