Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Unsupported Software
  • Search

Dell sk8135 keyboard multimedia keys and knob working in KDE

This forum covers all Gentoo-related software not officially supported by Gentoo. Ebuilds/software posted here might harm the health and stability of your system(s), and are not supported by Gentoo developers. Bugs/errors caused by ebuilds from overlays.gentoo.org are covered by this forum, too.
Post Reply
Advanced search
3 posts • Page 1 of 1
Author
Message
Kulfaangaren!
Apprentice
Apprentice
Posts: 176
Joined: Sat Jan 11, 2003 5:53 am
Location: Borås, Sweden

Dell sk8135 keyboard multimedia keys and knob working in KDE

  • Quote

Post by Kulfaangaren! » Thu May 31, 2007 7:45 pm

I got one of these keyboards at work and found some old C-code on the Ubuntu forums on how to get the volume knob to work.
I rewrote it to not use Xosd and added support for the multimedia keys with Amarok.
Amarok has got it's own OSD so Xosd was not needed.
It should be very easy to modify it to support any media player that supports dcop or similar command line client, it would be a matter of just changing a few strings.

Original code and posts can be found here - http://ubuntuforums.org/showthread.php?p=2610422

In hopes that someone might find this useful I add the code here :)

sk8135-pcm_plus_mediakeys.c:

Code: Select all

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 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.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 *-------------------------------------------------------------------------
 * by Mathieu Virbel, for sk-8135 keyboard (25/11/05)
 * based on http://www.frogmouth.net/hid-doco/c537.html examples.
 * Rewritten by Fredrik Larsson <ekerim at gmail.com> (31/05/07)
 *	- Approx 95+% of code rewritten
 *	- Removed dependency of aumix
 *	- Removed dependency of xosd
 *	- Added dependency to Amarok
 *	- All media keys works on Amarok via dcop system call
 *	- Added support for all the media keys (other special keys not handled)
 * Modified 01/06/07 (Fredrik)
 *  - Removed unnecessary if-else handling mute differently then other keys.
 *
 * Even though I know this is kind of an ugly hack I thought perhaps someone would find it useful.
 * Using system() to interact with dcop and Amarok is not the most elegant way.
 * I will most likely write a KDE app with a nice little tray icon and much more flexibility when KDE4 is released.
 * Have fun.
 *
 * // Fredrik
 *
 * You need :
 * - kernel headers (Tested with Gentoo linux-2.6.18-suspend2-r1 kernel source)
 * - X11 (Tested with xorg-x11-7.2)
 * - KDE (Tested with 3.5.5)
 * - Amarok (Tested with 1.4.5)
 * - Read rights to the correct event device (modify the udev rules and make the events MODE="0644")
 *
 * Compilation & Installation:
 *  gcc sk8135-pcm_plus_mediakeys.c -o sk8135-pcm
 *  mv sk8135-pcm /usr/bin/
 *
 * Test example:
 *  Use 'cat /proc/bus/input/devices' to find the Dell keyboard event devices and try them all (usually two of them).
 *  My correct device was /dev/input/event5
 *
 *  nohup sk8135-pcm /dev/input/event5 >/dev/null 2>&1 &
 *-------------------------------------------------------------------------
 */

#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/input.h>
#include <string.h>

int main (int argc, char **argv) {
    int fd = -1;        		/* the file descriptor for the device */
    int yalv;           		/* loop counter */
    size_t read_bytes;  		/* how many bytes were read */
    struct input_event ev[64];	/* the events (up to 64 at once) */
	char buffer[50];			/* buffer for all system commands */

    /* read() requires a file descriptor, so we check for one, and then open it */
    if (argc != 2) {
		fprintf(stderr, "usage: %s <event-device> (Example %s /dev/input/event5)\n", argv[0], argv[0]);
		exit(1);
    }
    if ((fd = open(argv[1], O_RDONLY)) < 0) {
		perror("Failed to open event device");
		exit(1);
    }

	/*
	 * Main loop...
	 */
	while (1) {
		/* Read event data */
		read_bytes = read(fd, ev, sizeof(struct input_event) * 64);

		if (read_bytes < (int) sizeof(struct input_event)) {
			perror("Failed to read events");
			exit (1);
		}

		/* Process each event... */
		for (yalv = 0; yalv < (int) (read_bytes / sizeof(struct input_event)); yalv++) {
			switch ( ev[yalv].type ) {
				case 1: {
					if ( ev[yalv].value == 1 ) {
						/* Make sure the buffers are filled with zeroes. */
						bzero( (char *)buffer, 50 );

					        /*
						 * Handle all other code values...
						 *
						 *	Implemented codes:
						 *	113		-	Mute
						 *	163		-	Next track
						 *	164		-	Toggle Play/Pause
						 *	165		-	Previous track
						 *	166		-	Stop
						 *	171		-	Start/Show player
						 *
						 *	Unimplemented codes:
						 *	128		-	Browser Stop
						 *	140		-	Calculator
						 *	144		-	"My Computer"
						 *	155		-	Mail
						 *	158		-	Browser Prev
						 *	159		-	Browser Next
						 *	172		-	Browser Home
						 *	173		-	Browser Reload
						 */
						switch ( ev[yalv].code ) {
							case 113: { /* Mute */
								strcpy( (char *)buffer, "dcop amarok player mute" );
								break;
							}
							case 163: { /* Next track */
								strcpy( (char *)buffer, "dcop amarok player next" );
								break;
							}
							case 164: { /* Toggle play/pause */
								strcpy( (char *)buffer, "dcop amarok player playPause" );
								break;
							}
							case 165: { /* Previous track */
								strcpy( (char *)buffer, "dcop amarok player prev" );
								break;
							}
							case 166: { /* Stop */
								strcpy( (char *)buffer, "dcop amarok player stop" );
								break;
							}
							case 171: { /* Start/Show Amarok */
								strcpy( (char *)buffer, "dcopstart amarok" );
								break;
							}
						}

						/* Perform the command. */
						system(buffer);
					}

					break;
				}
 				case 3: {
					/* Only handle event if it is code 32 (volume movement) and the volume actually changed. */
					if ( ev[yalv].code == 32 && ev[yalv].value != 0 ) {
						bzero( (char *)buffer, 50 );
						sprintf(buffer, "dcop amarok player setVolumeRelative %d", ev[yalv].value);
						system(buffer);
					}

					break;
				}
			}
		}
	}

	close(fd);

	exit(0);
}
[Edit: 01/06/07 - Changed code slightly, unnecessary if-else removed.]
Top
SLOWGOLD17
n00b
n00b
Posts: 1
Joined: Sat Jan 22, 2011 6:16 pm

Help with my sk8135

  • Quote

Post by SLOWGOLD17 » Sat Jan 22, 2011 6:28 pm

I HAVE A SK-8135 I JUST GOT IT THE KEYBOARD WORKS FINE BUT THE MULTI-MEDIA KEYS DO NOT WORK AT ALL NEITHER DOES THE INTERNET, EMAIL CALCULATOR, ETC. IF YOU COULD HELP THAT WOULD BE GREAT I DONT KNOW ANYTHING ABOUT CODE.

CHRIS1733@LIVE.COM
EMAIL ME OR IM ME PLEASE
Top
Kulfaangaren!
Apprentice
Apprentice
Posts: 176
Joined: Sat Jan 11, 2003 5:53 am
Location: Borås, Sweden

  • Quote

Post by Kulfaangaren! » Sat Jan 22, 2011 6:52 pm

Hello

I'm not sure you need this ugly piece of hack any more, I use the same SK-8135 but at least the multimedia keys works without this piece of crap when I use KDE4.

If you find that you still need this, look at the unimplemented codes, they should be listing the codes for all the keys on my version of the keyboard ...
* Unimplemented codes:
* 128 - Browser Stop
* 140 - Calculator
* 144 - "My Computer"
* 155 - Mail
* 158 - Browser Prev
* 159 - Browser Next
* 172 - Browser Home
* 173 - Browser Reload

.. then copy and modify one of the case-blocks to handle whatever you need it to handle. I believe you can add any command line as the second argument to strcpy() and have system() execute them.
For example you could have the KCalc calculator start. I never tested this though and I never took the time to investigate if there were any way to control the browser back,forward,next,home or stop but I suspect there isn't....not using this code.
Please add [SOLVED] to the subject of your original post when you feel that your problem is resolved.
Join the 'adopt an unanswered post' initiative today
Top
Post Reply

3 posts • Page 1 of 1

Return to “Unsupported Software”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic