Sunday, November 10, 2013

SyntaxHighlighter Highlighting in new Blogger Templates

I've been having issues with SyntaxHighlighter with my new Blogger theme, so I'm using this post to get the bugs worked out.

SELECT *
FROM users
WHERE user_hasClue = true;


I was having issues with posting XML code, but I think I've resolved them.
Here's an example of my XML problems. The image below and the code above it should be the same:

 
  
  
  
  
  
  
  
  
  
  
 
 
  
  
  
  
  
  
  
  
  
  
 
 
  
  
  
  
  
  
  
 


For a period of time, the XML code snippets looked like this:


The two StackOverflow questions that have been helpful in researching this topic are here:

http://stackoverflow.com/questions/12464924/blogger-syntaxhighlighter-doesnt-work-at-all 

http://stackoverflow.com/questions/6849890/syntax-highlighter-3-0-not-working-on-blogspot/15328620#15328620

Here is the stuff I added to the "head" of my template HTML (feel free to use it if it's helpful):


Wiimotes (with Classic Controllers) and RetroPIE - a HOWTO

This tutorial shows how to get one to four wiimotes (the controller of Nintendo Wii) running with RetroPie with or without a classic controller (attached to the wiimote).

This is a repost (not original material).  It originally was posted by "rolsch" in the RetroPIE forums here:
http://blog.petrockblock.com/forums/topic/tutorial-to-get-wiimotes-with-classic-controllers-to-work-with-retropie/
This guide is also available on the RetroPIE wiki, but it's just too cool not to share.

Prerequisites


1. For the following I assume that RetroPi was installed and is running with other controls (like keyboard, joystick etc.). I followed the excellent tutorial http://supernintendopi.wordpress.com/2013/01/23/an-a-to-z-beginners-guide-to-installing-retropie-on-a-raspberry-pi/ for this (using the “RetroPie Project SD Card Image”).

2. You have a blue-tooth dongle (sometimes called blue-tooth adapter). For a list of dongles known to work with Raspberry Pi see http://elinux.org/RPi_USB_Bluetooth_adapters#Working_Bluetooth_adapters ).

Note: Put the dongle in one of the USB ports of the Raspberry Pi directly, don’t put it into a USB hub (I read somewhere that it doesn’t work even with an active USB hub).

Installation


Now install the needed parts:

sudo apt-get install bluetooth 
sudo apt-get install python-cwiid 
sudo apt-get install wminput

Getting the wiimotes to work


The "uinput" device needs to work with non-root users. To do so, create a file called /etc/udev/rules.d/wiimote.rules with the following line:
KERNEL==“uinput“, MODE:=“0666“

Reboot the Raspberry Pi to make this change active.

. Check that the blue-tooth dongle works: Command
/etc/init.d/bluetooth status
should return that bluetooth is working

. Scan for the wiimotes. Start
hcitool scan
and press 1+2 on your wiimote(s). After a short while, the output should be something like

Scanning ...
        00:19:1D:87:90:38 Nintendo RVL-CNT-01
00:19:1D:88:EF:12 Nintendo RVL-CNT-01
Take a note of the addresses of your wiimotes (the 00:19:1D:87:90:38 in the output above), we need that later.
Note: If the scan is not successful try it again. Sometimes you need to try it several times (I read that somewhere, but it always worked for me the first time).

Correct usage of wminput

For every wiimote, we need one wminput command to map the wiimote (and the classic controller) buttons to something emulationstation and the emulators can work with. wminput comes with configuration files (in directory /etc/cwiid/wminput). I created my own configuration file, which works if you use a wiimote with or without a classic controller. Create the file /home/pi/mywminput with the following content:

Classic.Dpad.X = ABS_X
Classic.Dpad.Y = ABS_Y
Classic.LStick.X = ABS_HAT0X
Classic.LStick.Y = ABS_HAT0Y
Classic.RStick.X = ABS_HAT1X
Classic.RStick.Y = ABS_HAT1Y
Classic.A = BTN_A
Classic.B = BTN_B
Classic.X = BTN_X
Classic.Y = BTN_Y
Classic.Minus = BTN_SELECT
Classic.Plus  = BTN_START
Classic.Home  = BTN_MODE
Classic.L  = BTN_TL
Classic.R  = BTN_TR
Classic.ZL = BTN_TL2
Classic.ZR = BTN_TR2
Wiimote.A = BTN_A
Wiimote.B = BTN_B
Wiimote.Dpad.X = -ABS_Y
Wiimote.Dpad.Y = ABS_X
Wiimote.Minus = BTN_SELECT
Wiimote.Plus = BTN_START
Wiimote.Home = BTN_MODE
Wiimote.1 = BTN_X
Wiimote.2 = BTN_Y
If the Raspberry Pi is started and emulationstation starts, we want to register the wiimotes so they can be used with emulationstation and the emulators.
I did it the following way:
mkdir /home/pi/bin
create file /home/pi/bin/attachwii.sh with the following content:

#!/bin/bash
hcitool dev | grep hci >/dev/null
if test $? -eq 0 ; then
wminput -d -c  /home/pi/mywminput 00:19:1D:92:90:38 &
wminput -d -c  /home/pi/mywminput 00:19:1D:84:EF:33 &
else
echo "Blue-tooth adapter not present!"
fi
Note: You need one wminput line for every wiimote you want to use (i.e. the above is for two wiimotes)
Note 2: You need to replace the addresses of the wiimotes above by the addresses of your wiimotes (shown by command "hcitool scan" as shown above).
make the script executable with
chmod 775 /home/pi/bin/attachwii.sh
have the script be started just before emulationstation starts. To do so, edit the file /etc/profile
The last line should be
[ -n "${SSH_CONNECTION}" ] || emulationstation
right before this line, add the line
/home/pi/bin/attachwii.sh
and save the file.

If you now do a reboot, wait until emulationstation has been started. When it did, press 1+2 on all of your wiimotes to register the wiimotes. Now you can "tell" emulationstation and the emulators to use the wiimotes (and the classic controllers). Here are my configuration files.
For emulationstation:
Content of /home/pi/.emulationstation/es_input.cfg for two wiimotes:


 
  
  
  
  
  
  
  
  
  
  
 
 
  
  
  
  
  
  
  
  
  
  
 
 
  
  
  
  
  
  
  
 


For retroarch:
End of file /home/pi/RetroPi/configs/all/retroarch.cfg (for two wiimotes):

input_player1_joypad_index = "0"
input_player1_b_btn = "0"
input_player1_y_btn = "2"
input_player1_select_btn = "8"
input_player1_start_btn = "9"
input_player1_up_axis = "+1"
input_player1_down_axis = "-1"
input_player1_left_axis = "-0"
input_player1_right_axis = "+0"
input_player1_a_btn = "1"
input_player1_x_btn = "3"
input_player1_l_btn = "4"
input_player1_r_btn = "5"
input_player1_l2_btn = "6"
input_player1_r2_btn = "7"
input_player1_l3_btn = "10"
input_player1_r3_btn = "10"
input_player1_l_x_plus_axis = "+2"
input_player1_l_x_minus_axis = "-2"
input_player1_l_y_plus_axis = "-3"
input_player1_l_y_minus_axis = "+3"
input_player1_r_x_plus_axis = "+4"
input_player1_r_x_minus_axis = "-4"
input_player1_r_y_plus_axis = "-5"
input_player1_r_y_minus_axis = "+5"
input_player2_joypad_index = "1"
input_player2_b_btn = "1"
input_player2_y_btn = "3"
input_player2_select_btn = "8"
input_player2_start_btn = "9"
input_player2_up_axis = "+1"
input_player2_down_axis = "-1"
input_player2_left_axis = "-0"
input_player2_right_axis = "+0"
input_player2_a_btn = "0"
input_player2_x_btn = "2"
input_player2_l_btn = "4"
input_player2_r_btn = "5"
input_player2_l2_btn = "6"
input_player2_r2_btn = "7"
input_player2_l3_btn = "10"
input_player2_r3_btn = "10"
input_player2_l_x_plus_axis = "+2"
input_player2_l_x_minus_axis = "-2"
input_player2_l_y_plus_axis = "-3"
input_player2_l_y_minus_axis = "+3"
input_player2_r_x_plus_axis = "+4"
input_player2_r_x_minus_axis = "-4"
input_player2_r_y_plus_axis = "-5"
input_player2_r_y_minus_axis = "+5"
Make sure that the settings are only one time in retroarch.cfg file (i.e. if you have a line
input_player1_b_btn = "0"
in the retroarch.cfg file before adding my lines, remove (or out-comment) the whole section. If you want to use more than two wiimotes, search for the line
input_player1_joypad_index = 0
in retroarch.cfg and add the a corresponding line for the other wiimotes. For example you should have the following lines in retroarch.cfg for four wiimotes:

input_player1_joypad_index = 0
input_player2_joypad_index = 1
input_player3_joypad_index = 2
input_player4_joypad_index = 3
Finally, add the following two lines at the end of /home/pi/RetroPi/configs/all/retroarch.cfg:

input_enable_hotkey_btn = "0"
input_exit_emulator_btn = "1"
This will exit the emulator when you press A+B simultaneously on the wiimote (or the classic controller).

Note: the config files above work for wiimotes with or without classic controller.
Note 2: If you want to use the wiimote (i.e. not only the classic controller) and you are using my config files, you need to hold the wiimote horizontally (with the power button on the right).

Hope that helps.