Expanding on test engineer's answer:
First, a couple facts about the levels: The idle (mark) state of the line should be less than -3V (and not less than -15) when an RS232-compliant device is connected. Conversely, the idle state of a TTL-serial device should be between 0 and 0.8 V.
So, I think the easiest way to detect which type of device is connected is something like the following:
simulate this circuit – Schematic created using CircuitLab
For TTL-level signals, the device will pull up Rx pin on the board to 5V, and so the microcontroller sense pin will see a logic high. When an RS232-compliant device is attached, the idle state of the line will be between -3V and -15V. The two resistors form a divider, so the sense pin will see less than 0.8V (when the input is -3V). D1 prevents the sense pin from going more than a few hundred millivolts below ground for stronger signals, and the D2 zener protects against positive inputs greater than +5V (the RS232 space state).
Depending on the baud rate your scanner uses, the above circuit may even be sufficient to condition the input (ie, you might be able to connect both the micro-controller's RX pin and sense pin to the line labeled "To uController sense pin." The one difficulty with this is that RS232 uses negative voltages to represent 1's and positive voltages to represent 0's, which the opposite of what is used in TTL-land. To fix this, you'll want to add an XOR gate, like so:
simulate this circuit
Now, the "from uC invert" line is connected to an output on your micro. When it's high, it inverts the received signal, and when low passes it normally.