joyreg.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* $OpenBSD: joyreg.h,v 1.5 2007/11/29 10:53:54 deraadt Exp $ */
  2. /* $NetBSD: joy.c,v 1.3 1996/05/05 19:46:15 christos Exp $ */
  3. /*-
  4. * Copyright (c) 1995 Jean-Marc Zucconi
  5. * All rights reserved.
  6. *
  7. * Ported to NetBSD by Matthieu Herrb <matthieu@laas.fr>
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions
  11. * are met:
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer
  14. * in this position and unchanged.
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in the
  17. * documentation and/or other materials provided with the distribution.
  18. * 3. The name of the author may not be used to endorse or promote products
  19. * derived from this software without specific prior written permission
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  22. * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  23. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  24. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  25. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  26. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  30. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. */
  33. /*
  34. * The game port can manage 4 buttons and 4 variable resistors (usually 2
  35. * joysticks, each with 2 buttons and 2 pots.) via the port at address 0x201.
  36. * Getting the state of the buttons is done by reading the game port;
  37. * buttons 1-4 correspond to bits 4-7 and resistors 1-4 (X1, Y1, X2, Y2)
  38. * to bits 0-3. If button 1 (resp 2, 3, 4) is pressed, the bit 4 (resp 5,
  39. * 6, 7) is set to 0 to get the value of a resistor, write the value 0xff
  40. * at port and wait until the corresponding bit returns to 0.
  41. */
  42. /*
  43. * The formulae below only work if u is ``not too large''.
  44. */
  45. #define USEC2TICKS(u) (((u) * 19549) >> 14)
  46. #define TICKS2USEC(u) (((u) * 3433) >> 12)
  47. #define JOYPART(d) (minor(d) & 1)
  48. #define JOYUNIT(d) minor(d) >> 1 & 3
  49. #ifndef JOY_TIMEOUT
  50. #define JOY_TIMEOUT 2000 /* 2 milliseconds */
  51. #endif
  52. #define JOY_NPORTS 1
  53. struct joy_softc {
  54. struct device sc_dev;
  55. int port;
  56. int x_off[2], y_off[2];
  57. int timeout[2];
  58. };
  59. int joyopen(dev_t, int, int, struct proc *);
  60. int joyclose(dev_t, int, int, struct proc *);