colorchord/colorchord2/outdrivers.c

83 lines
1.6 KiB
C
Raw Permalink Normal View History

2015-07-29 07:56:18 +02:00
//Copyright 2015 <>< Charles Lohr under the ColorChord License.
2015-01-07 04:51:39 +01:00
#include "outdrivers.h"
#include <string.h>
#include "parameters.h"
#include "os_generic.h"
#include <stdio.h>
#include <stdlib.h>
2020-05-20 05:19:58 +02:00
#if defined(WINDOWS) || defined(WIN32) || defined(WIN64) \
|| defined(_WIN32) || defined(_WIN64)
#ifndef strdup
#define strdup _strdup
#endif
#endif
2015-06-26 23:00:04 +02:00
int force_white = 0;
unsigned char OutLEDs[MAX_LEDS*3];
int UsedLEDs;
2015-01-07 04:51:39 +01:00
struct OutDriverListElem ODList[MAX_OUT_DRIVERS];
const char OutDriverParameters[MAX_OUT_DRIVER_STRING];
void NullUpdate(void * id, struct NoteFinder*nf)
{
}
void NullParams(void * id )
{
}
struct DriverInstances * null( )
{
printf( "Null lights driver initialized.\n" );
struct DriverInstances * ret = malloc( sizeof( struct DriverInstances ) );
ret->id = 0;
ret->Func = NullUpdate;
ret->Params = NullParams;
return ret;
}
REGISTER_OUT_DRIVER(null);
struct DriverInstances * SetupOutDriver( const char * drivername )
2015-01-07 04:51:39 +01:00
{
int i;
for( i = 0; i < MAX_OUT_DRIVERS; i++ )
{
if( ODList[i].Name && strcmp( drivername, ODList[i].Name ) == 0 )
2015-01-07 04:51:39 +01:00
{
printf( "Found: %s %p\n", ODList[i].Name, ODList[i].Init );
return ODList[i].Init( );
break;
}
}
if( i == MAX_OUT_DRIVERS )
{
fprintf( stderr, "Error: Could not find outdriver.\n" );
}
return 0;
}
void RegOutDriver( const char * ron, struct DriverInstances * (*Init)( ) )
{
int i;
for( i = 0; i < MAX_OUT_DRIVERS; i++ )
{
if( ODList[i].Name == 0 )
{
ODList[i].Name = strdup( ron );
ODList[i].Init = Init;
break;
}
}
if( i == MAX_OUT_DRIVERS )
{
fprintf( stderr, "Error: Too many outdrivers registered.\n" );
exit( -55 );
}
}