You can use a PlayStation 2 emulator to play PS2 games on your computer. Note that it is illegal to play a PS2 game on your computer if you don't own a hard copy of the game and a PS2 console. Instead of playing the PS2 game with your keyboard, you can configure an analog controller to work with your emulator.
Launch your PS2 emulator. Click "Configure" or "Options."
Select "Configure" under the "Controller 1" or "Controller 2" option in the menu.
Click down on the analog stick you want to set. Depending on the controller, you'll usually have two options for the analog stick: setting the Y axis and setting the X axis. Some controllers require you to simply click and move the analog stick to establish Y and X axis settings.
Move the stick to the left, then to the right to set the X axis. Move the stick up, then down to set the Y axis. Click "OK" to confirm the configuration.