Logitech Cordless Click! Plus under Gentoo Linux

Several years ago I wanted a new mouse.

I was assigned to multiple projects at work and bounced between three different labs and my office desk. The environment in some of the labs was less than pristine and the only ‘mice’ I seemed to be able to get from our IT guys were mechanical. Due to the working environment, the mouse would need cleaning several times a day and was driving me crazy. I got the idea that I could buy my own wireless digital mouse and carry it from lab to lab. So, for fathers day, Cathy and Christopher made me the proud new owner of a Logitech Cordless Click! Plus mouse.

Eventually, our labs were upgraded to digital mice and I brought my Cordless Click! Plus home to my linux system. Basic functionality worked fine out of the box. That is, cursor movement, left button, right button, middle button, and scrolling up and down. What didn’t work was the extra buttons. This wasn’t that big of a deal for me because I rarely used them.

Several years later Compiz appeared on the Linux scene and I was eager to try it out. While I was floored by all of the eye-candy, one feature particularly wowed me. It was what is now called the scale feature. My understanding is that this feature is known as Expose in OSX. In my Compiz setup, the Scale feature was activated by moving the mouse pointer to the upper right corner of the screen. When you did this, all of the windows on my computer would scale out to a thumbnail, the size depending on the number of windows open. Then, I could pick which window I wanted to work with. The sliding and scaling is all done in very organic movements (like all things in Compiz). While this feature is great, it was also annoying for each time I let my mouse pointer stray too close to the the dreaded corner, I could only watch helplessly as my windows scaled to thumbnails. Then I would have to figure out which window to select so that I could go back to work. As you can imagine, what had great potential to be a productivity enhancement became a productivity deterrent. I realized that if I could remap one of the unused buttons on my Cordless Click! Plus to this Scale feature, I would regain my productivity.

Of course, this was not as straightforward as I had hoped and so I want to document what I did here, so that, firstly I have a record that I can use again if necessary, and secondly, so that others with this mouse may benefit.

Ultimately, what proved to be the most help was a Gentoo HowTo titled: HOWTO Advanced Mouse.

First, the kernel has to be set-up properly.

Device Drivers  --->
    Input Device Support  --->
        <*> Event Interface

    USB Support  --->
        <*> USB Human Interface Device (full HID) support
        [*] HID input layer support

Next you have to install evdev support for Xorg

#emerge xf86-input-evdev

You’ll need some info about the hardware. To get it, you can type:

#cat /proc/bus/input/devices

Here is what the results look like on my system:

I: Bus=0003 Vendor=046d Product=c510 Version=0110
N: Name=”Logitech USB Receiver”
P: Phys=usb-0000:00:0a.0-4/input0
S: Sysfs=/class/input/input2
U: Uniq=
H: Handlers=mouse1 event2
B: EV=20017
B: KEY=ffff0000 0 0 0 0 0 0 0 0
B: REL=143
B: MSC=10
B: LED=ff00

Armed with this information, edit /etc/X11/xorg.conf as follows:

Section "InputDevice"
        Identifier  "Mouse0"
        Driver      "evdev"
        Option      "Device" "/dev/input/event2"
EndSection
And thats all of the changes.  Don't forget to restart X, either by logging out and hitting ctrl-alt-backspace, or rebooting.
The HowTo I referenced above is really a better source for information.

I wanted to provided the important bits here just in case that HowTo one day becomes unavailable.

Voting is free, or is it?

Seth Godin blogged about voting in his blog yesterday (5 FEB 08) Lessons from Voting.  I love reading Seth’s blog but I believe he made an error and I would like to make my case for why I think it is an error.  As his first point, Seth states that “voting is free”.  I think I know what he is saying here, that it doesn’t cost us anything to register, or to place our vote, so why not just do it.  However, I spent five years of my life making sure that we have that right.  My father and grandfather paid even more.  Many have even paid with their lives to make sure that we can just show up and vote.  This is not a new or unique argument, and I am sure that you have heard it before, but I hope it is never forgotten.

Project 365 Abort

Well, it is fairly obvious that my participation in Project 365 lasted all of 1 day. Oh well, my work schedule right now is horrendous. I leave the house well before the sun comes up and get home well after the sun goes down (even on weekends). There is only just so many pictures that I can take around the house. Maybe next year.

I am planning to take the camera to Virginia next month, but I probably won’t have much time to take pictures and I am sure that cameras will not be allowed where I will be working.

1,000,000 Lines of Code

Jack Ganssle has an article at Embedded.Com where he puts One Million Lines of Code into perspective. It is definitely worth a read. If you are an embedded programmer and are not familiar with Jack and his writing, you need to go to Embedded.Com and start reading. Jack is an embedded genius.

A Million Lines of Code

Time

It’s 2008 and I am starting a new project. Project365 is a project where you take and document one photo a day for a year. The idea is that you have a visual record of where you have been for the year, and hopefully, your photography will get a little better along the way.

An important theme for me in 2008 will be time. I want to spend more time with Christopher and Cathy. Unfortunately, as the year begins, I will have to spend more time at work. Soon, I will have to spend weeks at a time out of state. Once that is done, I will have more time to spend where it matters the most, with my family.

Miro Samek, State Charts, etc.

Object Oriented Programming and C

Around the year 2000, after I had been at Lockheed Martin for about a year, I was tasked with rewriting our engineering interface GUI to bring it up to date and make it more flexible. The original GUI was written in a toolkit called XForms and we wanted to stay with this toolkit. The strength of XForms was that it was well thought out and simple. So simple that, with only a month of experience, and never having written for X windows before, I became productive and able to maintain the original GUI after only a half-day of learning. However, XForms’ weakness was that it was not very powerful. After a year of using and maintaining the original GUI, I knew what I wanted the new version to do but I was having trouble getting XForms to do what I wanted. What little GUI programming experience I had outside of XForms was with JAVA and I wanted to think of my XForms development in an object oriented way. Unfortunately, XForms was written to be used with C and I was having trouble mapping my object oriented ideas to C and the XForms way of doing things.

Somehow I stumbled onto the article Portable Inheritance and Polymorphism in C by Miro Samek published in Embedded Systems Programming, 1997. This article got me thinking in a new way. I was no longer bogged down and I was able to finish the new GUI project fairly successfully. I never actually used Dr. Samek’s code, but the ideas changed how I approached every programming project since. I carried around the printout of that article for years and I have a copy of the original sitting on my desk as I type this.

State Machines

I was first introduced to state machines in my Intro to Logic Design class in college. While I thought it was an interesting exercise, I just didn’t get it. The following semester, in my Computer Science 101 class, we were assigned an exercise which involved tokenizing a C source code file. Most of the class, including myself, was paralyzed, unsure of just how to approach this problem or where to start. The prof., sensing this, spent a class showing us how to get started using a state machine. Everything clicked, and I suddenly realized how elegant a state machine based design could be. It amazes me that so many software developers opt for complex and convoluted if…else clauses when many problems can be solved much more elegantly using a state machine.

Roughly 10 years later, I was struggling with maintaining and adding functionality to about 3000 lines of someone else’s code. Code that desperately wanted to be a state machine but instead had been implemented as a complex, convoluted if…else tree that sometimes nested to 10 levels deep and tracked state using about two dozen boolean flags. By this time, I had implemented the state machine solution dozens of times on other projects, and even a couple times on this project, but was having trouble figuring out how exactly to implement the state machine without changing the logic (probably because I was unable to completely comprehend what the logic was). One problem I was wrestling with was that I had always designed my state machines in the past to be unique solutions to the problem at hand. I was starting to think that there had to be a general purpose approach that would work in many more cases, maybe even all cases. I started searching around on the Internet and slowly started tracking down a system known as the Quantum Platform. I realized that I was on the brink of one of those life changing software development discoveries similar to discovering the Portable Inheritance and Polymorphism in C article years earlier. Eventually, I discovered, to my amazement, that the Quantum Platform was developed and documented in a book called Practical Statecharts in C/C++ written by the very same Miro Samek! I haven’t actually used the Quantum Framework yet (although I hope to on a future project), but the portions of the book that I have read gave me enough ideas to solve my 3000 lines of spaghetti code and convince me to consider the Quantum Framework for my next project.

First Post

Well, I finally got my own page up and running.  I plan on posting on various topics that interest me.  Primarily about software development (especially real-time software development).  Maybe some posts about coffee.  Possibly some book reviews.  And anything else that comes to mind.