Selection of one of these input devices is done by setting the experimental variable switchtype to a numerical code that describes the device. Table scode contains the currently valid code values. The default is switchtype 0 which enables keyboard input. Code values from 1 to 19 are reserved for switchboard devices. Values from 1 to 5 are reserved for switchboards connected to the game port connector. Values from 11 to 16 are used by switches connected to one of the parallel printer connectors.
It must be clear, however, that not every PXL program allows input from every arbitrary device. There may be programs that definitely require a certain device in order to work properly. Suppose you want to measure response times. Using the keyboard as a response device will be a bad idea in this case, since there will be a considerable delay between the subject's response and the software interrupt that is needed to detect it. Thus a program to measure response time may require a switchboard. In this case the program will check the current value of switchtype before it starts. If the switchtype value is not appropriate, the program will issue a fatal error message and stop execution.
Thus switchtype has two functions: it tells PXL programs about the type of response device available, and it allows the user to select one device if several are available and the program is able to use different devices. Most programs are able to use any of the three devices possible. In these cases the variable switchtype may be used to tell the respective program which type of switch should be used. Note that the command line option -t n may also be used to set the default input device. This mechanism is described in Chapter run. As described in Chapter exvars an assignment in a program's parameter file overrides the defaults. In some cases it is not sufficient to set the input device. It may also be necessary to tell a program the exact input codes in order to decide what are correct and false responses. An example is the program rtm. Figure sboard gives the input codes for the switches of switch boards. The input codes for keyboard input are the corresponding ASCII values or the keyboard scan codes.
If the keyboard is used as a response device one may want to disable the keyboard break mechanism in order to prevent the subject from being able to kill the program. This is possible by setting
keybreak = OFFin the parameter file. By default the experimental variable keybreak is ON.
Note from Table scode that the switchtype codes for switches do not stand for the number of switches but for the configuration. Thus number 4 is a switchboard with four switches in a single row, while number 5 stand for 4 switches in a square. Figure sboard shows the suggested configurations for switch boards and the corresponding numbering schema.
PXL uses several ports and masks to access the switchboards. All of these may also be redefined for adapting the software to non-standard devices. The parameters are collected in the integer array switchmask. It is possible to install a special switch board for response collection provided the mechanism for reading the board's bit pattern is compatible with PXL's own mechanism to read parallel input switches. The general schema is to have an 8-bit parallel input port to read from. The switch port is read by the instruction:
p = inp(SWITCHPORT) & SWITCHSLCTReading the port until there are at least two identical inputs is some save guarding against mechanical switch vibrations, although this is not perfect. SWITCHPORT is the port address of the input port and SWITCHSLCT is a pattern mask for selecting only special bits of the input pattern.
The input port may also be initialized. This is simply done by writing an initialization pattern SWITCHINIT to the control port address SWITCHCTRL:
outp(SWITCHCTRL, SWITCHINIT);Since the input bit polarity of any input port strongly depends on the port hardware a mask is applied to each input pattern such that pressing a switch always results in a logical 1 for the respective bit while a logical 0 always represents an open switch. Thus the hardware port pattern pis modified by the expression
(p & SWITCHAND) ^ SWITCHXORbefore it is handed over to the calling program.
Response switches usually have special patterns which are related to special meanings for experimental programs. An example is a program for adjusting some stimulus intensity. Such a program needs at least 3 keys: one for up, one for down, and one to indicate that the adjustment is finished. These keys are selected by binary patterns which are used to mask off certain bits of the input ports.
All the parameters for an input switch board are stored in the array switchmask. The list of definitions in Table swmask shows the meaning of the different entries of switchmask. The array switchmask may be redefined in parameter files. The following example defines the patterns for an 8-bit parallel input port at port address 0x104(= 260) with initialization port address at 0x107 (=263):
switchmask = [260,263,155,255,255,255,255,85,170,12,3,48,192,1]Note that the parameter switchtype is not affected by changing switchmask. In fact, the default values of switchmask are those belonging to the built in mask values for switchtype. One may change only selected entries of switchmask by inserting only those entries which have to be changed. All the entries which are not to be changed have to be set to -1.
switchnumbers = [0, 0, 0, 0, 1, 2, 3, 4]Note that bits 0 to 3 are not used with game port switches since the single switches are connected to bits 4 to 7 of the game input port. For printer port switches the default is
switchnumbers = [0, 0, 0, 1, 2, 3, 4, 5]The array switchnumbers may also be redefined in a parameter file.
Mouse event numbers are switchnumbers = [1, 2, 3] depending on the number of buttons available. The event numbers for keyboard input are identical to the key's scan code combined with the extended ASCII code for the respective key. The test program event.exe may be used to find out the event numbers of any response device.
yeskey = 19200 /* 0x4B00, cursor left */ nokey = 19712 /* 0x4D00, cursor right */ stopkey = 20224 /* 0x4F00, END */These correspond to the left and right arrow key and the END-key. The test program event.exe (Chap. demos) returns the switch number of any response event.
Back to table of contents