Function DetectControllers

From Uzebox Wiki
Jump to: navigation, search
Prototype

unsigned char DetectControllers();

Description

Detects what devices are connected to the game ports.

Parameters

None

Returns

Devices connected:

b1:b0 = 00 -> No controller connected in P1 port
        01 -> Gamepad connected in P1 port
        10 -> Mouse connected in P1 port
        11 -> Reserved
b3:b2 = 00 -> No controller connected in P2 port
        01 -> Gamepad connected in P2 port
        10 -> Mouse connected in P2 port
        11 -> Reserved
Video Modes

All

Since

V3

Notes

If a mouse is expected to be connected, the first time this function is called, enough time must be given to the mouse to settle by calling WaitVsync(8) before invoking this function.

Example:

 WaitVsync(6); //This is only required initially if a mouse is connected
 unsigned char cntl=DetectControllers();
 if(cntl&2){
      Print(5,1,PSTR("A MOUSE IS CONNECTED IN P1 PORT"));
  }