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 - 2013 Pi4J 015 * %% 016 * Licensed under the Apache License, Version 2.0 (the "License"); 017 * you may not use this file except in compliance with the License. 018 * You may obtain a copy of the License at 019 * 020 * http://www.apache.org/licenses/LICENSE-2.0 021 * 022 * Unless required by applicable law or agreed to in writing, software 023 * distributed under the License is distributed on an "AS IS" BASIS, 024 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 025 * See the License for the specific language governing permissions and 026 * limitations under the License. 027 * #L% 028 */ 029 030 031import com.pi4j.util.NativeLibraryLoader; 032 033/** 034 * <p> 035 * Before using the Pi4J library, you need to ensure that the Java VM in configured with access to 036 * the following system libraries: 037 * <ul> 038 * <li>pi4j</li> 039 * <li>wiringPi</li> 040 * </ul> 041 * <blockquote> This library depends on the wiringPi native system library.</br> (developed by 042 * Gordon Henderson @ <a href="https://projects.drogon.net/">https://projects.drogon.net/</a>) 043 * </blockquote> 044 * </p> 045 * 046 * @see <a href="http://www.pi4j.com/">http://www.pi4j.com/</a> 047 * @see <a 048 * href="https://projects.drogon.net/raspberry-pi/gertboard/analog-inout/">https://projects.drogon.net/raspberry-pi/gertboard/analog-inout/</a> 049 * @author Robert Savage (<a 050 * href="http://www.savagehomeautomation.com">http://www.savagehomeautomation.com</a>) 051 */ 052public class Nes { 053 054 public static final int NES_RIGHT = 0x01; 055 public static final int NES_LEFT = 0x02; 056 public static final int NES_DOWN = 0x04; 057 public static final int NES_UP = 0x08; 058 public static final int NES_START = 0x10; 059 public static final int NES_SELECT = 0x20; 060 public static final int NES_B = 0x40; 061 public static final int NES_A = 0x80; 062 public static final int PULSE_TIME = 25; 063 public static final int MAX_NES_JOYSTICKS = 8; 064 065 // private constructor 066 private Nes() { 067 // forbid object construction 068 } 069 070 static { 071 // Load the platform library 072 NativeLibraryLoader.load("pi4j", "libpi4j.so"); 073 } 074 075 /** 076 * <p>setupNesJoystick:</p> 077 * 078 * <p>Create a new NES joystick interface, program the pins, etc.</p> 079 * 080 * @param dPin 081 * @param cPin 082 * @param lPin 083 * @return return value 084 */ 085 public static native int setupNesJoystick(int dPin, int cPin, int lPin); 086 087 /** 088 * <p>readNesJoystick:</p> 089 * 090 * <p>Do a single scan of the NES Joystick.</p> 091 * 092 * @param joystick 093 * @return return value 094 */ 095 public static native int readNesJoystick(int joystick); 096}