English   German
  #1  
Old 09-10-2002, 16:49
Norad Norad is offline
-= TeamSpeak User =-
 
Join Date: Jun 2002
Location: Germany
Posts: 10
Norad is on a distinguished road
Lightbulb Keyboard unter Linux

Hi
Ich hab da im kleinen GNOME2-Applet led_applet evtl. eine mögliche Lösung zum Tastaturauslesen gefunden. Das Dingen liegt auf led_applet-0.3.tar.gz.
Hier mal ein paar evtl. brauchbare Zeilen:
Code:
#include <X11/XKBlib.h>
Code:
XkbSelectEvents(applet->rootwin, XkbUseCoreKbd, XkbIndicatorStateNotifyMask, XkbIndicatorStateNotifyMask)
Code:
static unsigned int 
get_lockmask(LedApplet *applet)
{
	int i;
	unsigned int mask = 0;
	XkbDescPtr xkb;

	g_assert(applet);
	
	if (!(xkb = XkbGetKeyboard(applet->rootwin, XkbAllComponentsMask, XkbUseCoreKbd)))
		return 0;
	
	if (!xkb->names)
		return 0;
    
	for(i = 0;i <= XkbNumVirtualMods;i++)
	{                                         
		unsigned int tmp = 0;
		char* name = NULL;
		if (!xkb->names->vmods[i])
			continue;

		name = XGetAtomName(xkb->dpy, xkb->names->vmods[i]);
		if (name)
		{
			if (!strcmp(name, "Caps Lock") && applet->on[CAPSLOCK])
			{
				XkbVirtualModsToReal(xkb, 1 << i, &tmp);
				if (!tmp)
					tmp = 2; /* Hack to make it work. Maybe a bug in xkb? */
			}
			if (!strcmp(name, "NumLock") && applet->on[NUMLOCK])
				XkbVirtualModsToReal(xkb, 1 << i, &tmp);
			if (!strcmp(name, "ScrollLock") && applet->on[SCROLLLOCK])
				XkbVirtualModsToReal(xkb, 1 << i, &tmp);
			mask += tmp;
		}
	}
	XkbFreeKeyboard(xkb, 0, True);
	return mask;
}
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 21:04.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Add to Bookmarks   |   Printview   |   Contact Us   |   Legal Notices