Posts Tagged ‘Hardware’

Book Review – Code

April 18th, 2010

I just finished reading Code by Charles Petzold.  This book is like no other I’ve ever read.  This book explains how computers work.   Think about that for a second.  Do you know how a computer actually works?  Really?  This isn’t about double clicking on the blue “E” to access the internet.  This book explains how a machine can take electrical 1’s and 0’s and use them to do math, save files, display graphics, and everything else a computer does.

I love the way the book progresses.  It starts with the most basic of electrical circuits.  Simple light bulb and battery type stuff.  It spends a few chapters building your circuit board chops and BAM!  – he shows you how you can wire a circuit to add binary numbers.  Wow, you can now build a very simple computer.  He continues to add to what you already know piece by piece.   Components are added to the circuit board so that it can now perform subtraction, multiplication, and division.  You learn how a circuit can remember data, the basis of memory.  You learn the issues surrounding floating point math and how they are resolved.  He explains machine code, and how it can be simplified by assembly language, and in turn, high-level languages.

Mixed in with the technical chapters, he adds sections on lighter topics such as Morse code, Braile, alternate (non-base 10) number systems, and more.  He covers how letters can be stored as a series of bits, and why there are 8 bits to a byte.

This book changed the way I think about computers.  I highly recommend it to anyone who wants to understand them better.  Although it assumes no prior knowledge, this book is not for the faint of heart; some of the chapters require tenacity to stay focused and comprehend.  However, I guarantee it will be well worth it.

Re-Map Default Mouse Buttons in Ubuntu Karmic

November 9th, 2009

While setting up a new installation of Ubuntu 9.10 for a friend, I ran into a small issue: she was using a 4 button Kensington trackball mouse, and the default key mappings made little sense.  Naturally, there were no drivers or software available, but after some research I was able to figure out how to manually remap the mouse buttons.

Step 1. Find the name of your device.
This step is pretty simple.  Open up a terminal and type in the command:

xinput list

This will list all of the input devices recognized by the X window system.  The names are in quotes, and should be pretty self-explanatory; any external mice should be near the bottom.

xinput list

Step 2. Find your button numbers
Each mouse button has a unique number to the system, and your next job is to find out what they are.  In your termal window type:

xev

This will open a new smaller window.  Whenever your mouse is over the new window, the terminal will print any input it receives.  This includes both movement and button presses.  For each button on the mouse, press it, and write down what button number it displays.  Don’t forget that scroll up, down, left, and right and wheel click are all treated as different “buttons”.

xev

Step 3. Re-Map the buttons
You can modify your your mappings with the following command (substituting your device name from step 1)

xinput set-button-map "Device Name" 1 2 3 4 5

Running the above command will most likely change nothing, it will map all the buttons to their default functions.  Let’s say your left and right click map to 1 & 3 respectively.  If you wanted to switch them (perhaps for a left-handed user) the command would be:

xinput set-button-map "Device Name" 3 2 1 4 5

In the case of my friend (with a Kensington pro mouse) we needed to swap the 1 & 3 with the 8 & 9 buttons.  That looked like this:

xinput set-button-map "Kensington Pro PS/2" 8 2 9 4 5 6 7 1 3

Note that you can enter as many numbers as you like, up to the number of mouse buttons.  Any numbers you don’t enter will be assumed to be the sequential default.  Thus the following command is equivalent to the one above:

xinput set-button-map "Kensington Pro PS/2" 8 2 9 4 5 6 7 1 3 10 11 12 13

Step 4. Saving your mappings
Once you’ve found the correct sequence of numbers, you can have it load automatically by creating a startup item.  Navigate to the following menu:

System > Preferences > Startup Applications > Add

and enter the following:

Name: Mouse Button Remap
Command: xinput “Device Name” 1 2 3 4 5
Comment: “Swapped the left and right click”

Add Startup

Ta Da! You’re Done!