www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

sourisPS2.h (3344B)


      1 #ifndef PC_SOURIS_PS2_SOURIS_PS2_H
      2 #define PC_SOURIS_PS2_SOURIS_PS2_H
      3 
      4 #include <pc/kbc/kbc.h>
      5 
      6 #define SOURIS_PS2_DEFINIR_RESOLUTION 0xe8
      7 #define SOURIS_PS2_DEMANDER_PAQUET 0xeb
      8 #define SOURIS_PS2_OBTENIR_MOUSE_ID 0xf2
      9 #define SOURIS_PS2_DEFINIR_FREQUENCE 0xf3
     10 #define SOURIS_PS2_AUTO_PAQUETS 0xf4
     11 #define SOURIS_PS2_DESACTIVER_PAQUETS 0xf5
     12 #define SOURIS_PS2_RESET 0xff
     13 
     14 #define SOURIS_PS2_ACK 0xfa
     15 #define SOURIS_PS2_RESET_1 0xaa
     16 #define SOURIS_PS2_RESET_2 0x00
     17 
     18 #define ENVOYER 1
     19 #define RECEVOIR 2
     20 #define ENVOYER_V 3
     21 #define RECEVOIR_V 4
     22 #define RECEVOIR_OU_PAS 42 /* Que la force soit avec la souris */
     23 #define COMMANDE 5
     24 
     25 
     26 
     27 static const uint8 DialogueDefinirResolution[] = {
     28 	ENVOYER, SOURIS_PS2_DEFINIR_RESOLUTION,
     29 	RECEVOIR, SOURIS_PS2_ACK,
     30 	ENVOYER_V, 0,
     31 	RECEVOIR, SOURIS_PS2_ACK
     32 };
     33 
     34 static const uint8 DialogueDemanderPaquet[] = {
     35 	ENVOYER, SOURIS_PS2_DEMANDER_PAQUET,
     36 	RECEVOIR, SOURIS_PS2_ACK
     37 };
     38 
     39 static const uint8 DialogueObtenirMouseID[] = {
     40 	ENVOYER, SOURIS_PS2_OBTENIR_MOUSE_ID,
     41 	RECEVOIR, SOURIS_PS2_ACK,
     42 	RECEVOIR_V, 0
     43 };
     44 
     45 static const uint8 DialogueDefinirFrequence[] = {
     46 	ENVOYER, SOURIS_PS2_DEFINIR_FREQUENCE,
     47 	RECEVOIR, SOURIS_PS2_ACK,
     48 	ENVOYER_V, 0,
     49 	RECEVOIR, SOURIS_PS2_ACK
     50 };
     51 
     52 static const uint8 DialogueAutoPaquets[] = {
     53 	ENVOYER, SOURIS_PS2_AUTO_PAQUETS,
     54 	RECEVOIR, SOURIS_PS2_ACK
     55 };
     56 
     57 static const uint8 DialogueDesactiverPaquets[] = {
     58 	ENVOYER, SOURIS_PS2_DESACTIVER_PAQUETS,
     59 	RECEVOIR, SOURIS_PS2_ACK
     60 };
     61 
     62 static const uint8 DialogueReset[] = {
     63 	ENVOYER, SOURIS_PS2_RESET,
     64 	RECEVOIR_OU_PAS, SOURIS_PS2_ACK,
     65 	RECEVOIR, SOURIS_PS2_RESET_1,
     66 	RECEVOIR, SOURIS_PS2_RESET_2
     67 };
     68 
     69 static const uint8 DialogueObtenirCompaqStatusByte[] = {
     70 	COMMANDE, KBC_DEMMANDE_LECTURE_COMPAQ_STATUS_BYTE,
     71 	RECEVOIR_V, 0
     72 	/* RECEVOIR_OU_PAS, 0xd8 Certaines versions de Bochs envoient mystérieusement cet octet. */
     73 };
     74 
     75 static const uint8 DialogueDefinirCompaqStatusByte[] = {
     76 	COMMANDE, KBC_DEMMANDE_ECRITURE_COMPAQ_STATUS_BYTE,
     77 	ENVOYER_V, 0
     78 	/* RECEVOIR_OU_PAS, SOURIS_PS2_ACK */
     79 };
     80 
     81 
     82 
     83 typedef struct PaquetSourisPS2_1 {
     84 	uint8 boutonGauche:1;
     85 	uint8 boutonDroite:1;
     86 	uint8 boutonMilieu:1;
     87 	uint8 un:1;
     88 	uint8 xNegatif:1;
     89 	uint8 yNegatif:1;
     90 	uint8 xOverflow:1;
     91 	uint8 yOverflow:1;
     92 } PaquetSourisPS2_1;
     93 
     94 typedef enum {
     95 	MOLETTE_DEFILEMENT_AUCUN = 0,
     96 	MOLETTE_DEFILEMENT_HAUT = 1,
     97 	MOLETTE_DEFILEMENT_BAS = 0xf,
     98 	MOLETTE_DEFILEMENT_GAUCHE = 0xe,
     99 	MOLETTE_DEFILEMENT_DROITE = 2
    100 } ModeDefilementSourisPS2;
    101 
    102 typedef struct PaquetSourisPS2_4 {
    103 	uint8 ignorer:2;
    104 	uint8 bouton5:1;
    105 	uint8 bouton4:1;
    106 	ModeDefilementSourisPS2 modeDefilement:4;
    107 } PaquetSourisPS2_4;
    108 
    109 
    110 typedef enum {
    111 	ETAT_GESTIONNAIRE_SOURIS_PS2_ATTENTE,
    112 	ETAT_GESTIONNAIRE_SOURIS_PS2_PAQUET,
    113 	ETAT_GESTIONNAIRE_SOURIS_PS2_DIALOGUE
    114 } EtatGestionnaireSourisPS2;
    115 
    116 typedef void (*FonctionRappelSourisPS2) (bool erreur);
    117 
    118 typedef struct DialogueSourisPS2 {
    119 	const uint8* sequence;
    120 	int longueur;
    121 	uint8* parametre;
    122 	FonctionRappelSourisPS2 rappel;
    123 } DialogueSourisPS2;
    124 
    125 
    126 typedef struct EtatSourisPS2 {
    127 	uint8 resolution;
    128 	uint8 frequence;
    129 	uint8 mouseID;
    130 	uint8 compaqStatusByte;
    131 	bool resetPotentiel;
    132 	uint8 paquets[4];
    133 	int paquet;
    134 	bool paquetsDoiventEtreZero;
    135 	bool debordementXY;
    136 	DialogueSourisPS2 dialogue;
    137 	int etapeDialogue;
    138 	EtatGestionnaireSourisPS2 etatGestionnaireSourisPS2;
    139 	
    140 	/* DEBUG */
    141 	int32 curseur_x;
    142 	int32 curseur_y;
    143 	uint32 couleur;
    144 } EtatSourisPS2;
    145 
    146 #endif