001package com.pi4j.wiringpi; 002 003/* 004 * #%L 005 * ********************************************************************** 006 * ORGANIZATION : Pi4J 007 * PROJECT : Pi4J :: Java Library (Core) 008 * FILENAME : Nes.java 009 * 010 * This file is part of the Pi4J project. More information about 011 * this project can be found here: http://www.pi4j.com/ 012 * ********************************************************************** 013 * %% 014 * Copyright (C) 2012 - 2016 Pi4J 015 * %% 016 * This program is free software: you can redistribute it and/or modify 017 * it under the terms of the GNU Lesser General Public License as 018 * published by the Free Software Foundation, either version 3 of the 019 * License, or (at your option) any later version. 020 * 021 * This program is distributed in the hope that it will be useful, 022 * but WITHOUT ANY WARRANTY; without even the implied warranty of 023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 024 * GNU General Lesser Public License for more details. 025 * 026 * You should have received a copy of the GNU General Lesser Public 027 * License along with this program. If not, see 028 * <http://www.gnu.org/licenses/lgpl-3.0.html>. 029 * #L% 030 */ 031 032 033import com.pi4j.util.NativeLibraryLoader; 034 035/** 036 * <p> 037 * Before using the Pi4J library, you need to ensure that the Java VM in configured with access to 038 * the following system libraries: 039 * <ul> 040 * <li>pi4j</li> 041 * <li>wiringPi</li> 042 * </ul> 043 * <blockquote> This library depends on the wiringPi native system library.</br> (developed by 044 * Gordon Henderson @ <a href="http://wiringpi.com/">http://wiringpi.com/</a>) 045 * </blockquote> 046 * </p> 047 * 048 * @see <a href="http://www.pi4j.com/">http://www.pi4j.com/</a> 049 * @see <a 050 * href="http://wiringpi.com/dev-lib/">http://wiringpi.com/dev-lib/</a> 051 * @author Robert Savage (<a 052 * href="http://www.savagehomeautomation.com">http://www.savagehomeautomation.com</a>) 053 */ 054public class Nes { 055 056 public static final int NES_RIGHT = 0x01; 057 public static final int NES_LEFT = 0x02; 058 public static final int NES_DOWN = 0x04; 059 public static final int NES_UP = 0x08; 060 public static final int NES_START = 0x10; 061 public static final int NES_SELECT = 0x20; 062 public static final int NES_B = 0x40; 063 public static final int NES_A = 0x80; 064 public static final int PULSE_TIME = 25; 065 public static final int MAX_NES_JOYSTICKS = 8; 066 067 // private constructor 068 private Nes() { 069 // forbid object construction 070 } 071 072 static { 073 // Load the platform library 074 NativeLibraryLoader.load("libpi4j.so"); 075 } 076 077 /** 078 * <p>setupNesJoystick:</p> 079 * 080 * <p>Create a new NES joystick interface, program the pins, etc.</p> 081 * 082 * @param dPin data pin 083 * @param cPin clock pin 084 * @param lPin pin number 085 * @return return joystick handle 086 */ 087 public static native int setupNesJoystick(int dPin, int cPin, int lPin); 088 089 /** 090 * <p>readNesJoystick:</p> 091 * 092 * <p>Do a single scan of the NES Joystick.</p> 093 * 094 * @param joystick joystick handle 095 * @return return value 096 */ 097 public static native int readNesJoystick(int joystick); 098}