Beispiel #1
0
void lcd_close (void)
{
	lgLcdDeInit ();
	xfree (lbh);
	lbh = NULL;
	bitmap = NULL;
	inited = 0;
}
Beispiel #2
0
void CLCDOutput::Shutdown(void)
{
    CloseAndDisconnect();
    if(0 == InterlockedDecrement(&lInitCount))
    {
        lgLcdDeInit();
    }
    LCDUIASSERT(lInitCount >= 0);
}
Beispiel #3
0
G15LCDEngineLGLCD::~G15LCDEngineLGLCD() {
    if (llcContext.device != LGLCD_INVALID_DEVICE) {
        lgLcdClose(llcContext.device);
        llcContext.device = LGLCD_INVALID_DEVICE;
    }
    if (llcceConnect.connection != LGLCD_INVALID_CONNECTION) {
        lgLcdDisconnect(llcceConnect.connection);
        llcceConnect.connection = LGLCD_INVALID_CONNECTION;
    }
    lgLcdDeInit();
}
//************************************************************************
// Closes the connection with the LCD
//************************************************************************
bool CLCDConnectionLogitech::Shutdown()
{
	m_bConnected = false;

	SetVolumeWheelHook(false);

	Disconnect();

	if (LGLCD_INVALID_CONNECTION != m_hDevice)
		lgLcdDisconnect(m_hConnection);

	lgLcdDeInit();

	return true;
}
void LH_LgLcdCallbackThread::run()
{
    int index, retv;
    lgLcdConnectContextEx connectContextEx;

    bw_cxt.connection = LGLCD_INVALID_CONNECTION;
    bw_cxt.deviceType = LGLCD_DEVICE_BW;
    bw_cxt.onSoftbuttonsChanged.softbuttonsChangedCallback = LH_LogitechButtonCB;
    bw_cxt.onSoftbuttonsChanged.softbuttonsChangedContext = this;
    bw_cxt.device = LGLCD_INVALID_DEVICE;

    qvga_cxt.connection = LGLCD_INVALID_CONNECTION;
    qvga_cxt.deviceType = LGLCD_DEVICE_QVGA;
    qvga_cxt.onSoftbuttonsChanged.softbuttonsChangedCallback = LH_LogitechButtonCB;
    qvga_cxt.onSoftbuttonsChanged.softbuttonsChangedContext = this;
    qvga_cxt.device = LGLCD_INVALID_DEVICE;

    while( stayAlive() )
    {
        /* Ignore errors here to avoid spamming errors when G15 broken on not present */
        if( lgLcdInit() == ERROR_SUCCESS )
        {
            memset( &connectContextEx, 0, sizeof(connectContextEx) );
            connectContextEx.appFriendlyName = appname_;
            connectContextEx.isPersistent = 0;
            connectContextEx.isAutostartable = 0;
            connectContextEx.onConfigure.configCallback = NULL;
            connectContextEx.onConfigure.configContext = NULL;
            connectContextEx.connection = LGLCD_INVALID_CONNECTION;
            connectContextEx.dwAppletCapabilitiesSupported = LGLCD_APPLET_CAP_BW | LGLCD_APPLET_CAP_QVGA;
            connectContextEx.onNotify.notificationCallback = LH_LogitechCB;
            connectContextEx.onNotify.notifyContext = this;

            retv = lgLcdConnectEx( &connectContextEx );
            /* Don't report file not found errors */
            if( retv != -1 && retv != ERROR_FILE_NOT_FOUND && retv != ERROR_ALREADY_EXISTS && LCD_ERR( retv ) )
            {
                QTime last_enum;
                last_enum.start();
                online_ = true;

                while( stayAlive() && online_ )
                {
                    sem_.tryAcquire( 1, 100 );
                    if( !stayAlive() ) break;
                    if( !render( connectContextEx.connection ) ) break;
                }

                if( bw_cxt.device != LGLCD_INVALID_DEVICE )
                {
                    lgLcdClose( bw_cxt.device );
                    bw_cxt.device = LGLCD_INVALID_DEVICE;
                }

                if( qvga_cxt.device != LGLCD_INVALID_DEVICE )
                {
                    lgLcdClose( qvga_cxt.device );
                    qvga_cxt.device = LGLCD_INVALID_DEVICE;
                }

                if( online_ )
                {
                    retv = lgLcdDisconnect(connectContextEx.connection);
                    if( retv != ERROR_PIPE_NOT_CONNECTED ) LCD_ERR( retv );
                    online_ = false;
                }

                connectContextEx.connection = LGLCD_INVALID_CONNECTION;
            }

            lgLcdDeInit();
        }
        for( index=0; stayAlive() && index<20; index ++ ) msleep(100);
    }

    return;
}
Beispiel #6
0
extern "C" LCDWRAPPER_API int deinitLCD()
{
	delete events;
	delete abc;
	return lgLcdDeInit();
}
Beispiel #7
0
int main(int argc, char *argv[]) {
	int dwErr;
	BOOL bDetect = FALSE;
	int i;
	lgLcdConnectContextEx conn;
	lgLcdOpenByTypeContext ctx;
	lgLcdBitmap160x43x1 bitmap;

	if (argc > 1 && (strcmp(argv[1], "/detect") == 0)) {
		warn("Detect mode!");
		bDetect = TRUE;
	} else if (!(argc > 1) || (strcmp(argv[1], "/mumble") != 0)) {
		CFUserNotificationDisplayAlert(0, 0, NULL,  NULL, NULL, CFSTR("Nothing to see here"), CFSTR("This program is run by Mumble, and should not be started separately."), CFSTR("OK"), NULL, NULL, NULL);
		return 0;
	}

	/*
	 * Clear and set up initial structures.
	 */
	memset(&conn, 0, sizeof(conn));
	memset(&ctx, 0, sizeof(ctx));
	memset(&bitmap, 0, sizeof(bitmap));

	conn.appFriendlyName = G15_WIDGET_NAME;
	conn.isAutostartable = FALSE;
	conn.isPersistent = FALSE;
	conn.dwAppletCapabilitiesSupported =LGLCD_APPLET_CAP_BASIC | LGLCD_APPLET_CAP_BW;
	conn.connection = LGLCD_INVALID_CONNECTION;

	/*
	 * Initialize and connect.
	 */
	dwErr = lgLcdInit();
	if (dwErr != ERROR_SUCCESS)
		die(G15_ERR_INIT, "Unable to initialize Logitech LCD library. (Error: %i)", dwErr);

	dwErr = lgLcdConnectEx(&conn);
	if (dwErr != ERROR_SUCCESS)
		die(G15_ERR_CONNECT, "Unable to connect to Logitech LCD manager. (Error: %i)", dwErr);

	ctx.connection = conn.connection;
	ctx.device = LGLCD_INVALID_DEVICE;
	ctx.deviceType =LGLCD_DEVICE_BW;

	dwErr = lgLcdOpenByType(&ctx);

	warn("That returned %d %d", dwErr, ERROR_SUCCESS);

	if (bDetect)
		return (dwErr != ERROR_SUCCESS);
	else if (dwErr != ERROR_SUCCESS)
		die(G15_ERR_OPEN, "Unable to open device. (Error: %i)", dwErr);

	/*
	 * Diplay buffer format.
	 */
	bitmap.hdr.Format = LGLCD_BMP_FORMAT_160x43x1;

	/*
	 * Main drawing loop.
	 */
	while (1) {
		int ret;
		int remain = 0;
		BYTE bPriority;

		ret = read(0, &bPriority, 1);
		if (ret == -1 || ret != 1)
			die(G15_ERR_READFILE, "Error while reading priority.");

		do {
			ret = read(0, bitmap.pixels + remain, G15_MAX_FBMEM - remain);
			if (ret < 1)
				die(G15_ERR_READFILE, "Error while reading framebuffer. %d (%s)", ret, strerror(errno));
			remain += ret;
		} while (remain < G15_MAX_FBMEM);

		dwErr = lgLcdUpdateBitmap(ctx.device, (const lgLcdBitmapHeader *) &bitmap, bPriority ? LGLCD_SYNC_UPDATE(LGLCD_PRIORITY_ALERT) : LGLCD_SYNC_UPDATE(LGLCD_PRIORITY_NORMAL));
		if (dwErr != ERROR_SUCCESS)
			warn("Unable to update bitmap for device #%i successfully. (Error: %i)", i, dwErr);
	}

	/*
	 * Close device connections.
	 */
	dwErr = lgLcdClose(ctx.device);
	if (dwErr != ERROR_SUCCESS)
		die(G15_ERR_CLOSE, "Unable to close LCD device. (Error: %i)", dwErr);

	/*
	 * Disconnect from LCD monitor.
	 */
	dwErr = lgLcdDisconnect(conn.connection);
	if (dwErr != ERROR_SUCCESS)
		die(G15_ERR_DISCONNECT, "Unable to disconnect from LCD manager. (Error: %i)", dwErr);

	/*
	 * Deinitialize G15 library.
	 */
	dwErr = lgLcdDeInit();
	if (dwErr != ERROR_SUCCESS)
		die(G15_ERR_DEINIT, "Unable to deinitialize LCD library. (Error: %i)", dwErr);

	warn("Terminated successfully.");

	return 0;
}