4dsdev
Views: 1,610,081 Main | Rules/FAQ | Memberlist | Active users | Last posts | Calendar | Stats | Online users | Search 11-23-24 08:02 AM
Guest:

0 users reading Code for HID | 1 bot

Main - Homebrew discussion - Code for HID Show post layouts | New reply


kasai07
Posted on 09-11-16 01:56 PM (rev. 2 of 09-14-16 02:08 PM) Link | #1088
Hello
sorry for my english
i'm french and I do not know too much English
here's what I did

size_t HID_Flag()
{
return i2cReadRegister(I2C_DEV_MCU, 0x10);
}
size_t Level3D()
{
return i2cReadRegister(I2C_DEV_MCU, 0x08);
}
size_t VolumeLevel()
{
return i2cReadRegister(I2C_DEV_MCU, 0x09);
}
size_t BatteryLevel()
{
return i2cReadRegister(I2C_DEV_MCU, 0x0B);
}
#define BUTTON_POWER 1
#define BUTTON_HOME 8
#define BUTTON_WIFI10
u32 padflag_state;


u32 InputWait() {
static u64 delay = 0;
u32 pad_state_old = HID_STATE;
delay = (delay) ? 72 : 128;
timer_start();
u32 HIDFlag = 0;

while (true) {
padflag_state = 0;

HIDFlag = HID_Flag();
if (HIDFlag == 0x01){padflag_state = BUTTON_POWER;return 0;}
if (HIDFlag == 0x04){padflag_state = BUTTON_HOME;return 0;}
if (HIDFlag == 0x10){padflag_state = BUTTON_WIFI;return 0;}

u32 pad_state = HID_STATE;
if (!(~pad_state & BUTTON_ANY)) { // no buttons pressed
pad_state_old = pad_state;
delay = 0;
continue;
}
if ((pad_state == pad_state_old) &&
(!(~pad_state & BUTTON_ARROW) ||
(delay && (timer_msec() < delay))))
continue;
//Make sure the key is pressed
u32 t_pressed = 0;
for(; (t_pressed < 0x13000) && (pad_state == HID_STATE); t_pressed++);

if (t_pressed >= 0x13000)return ~pad_state;

}
}



} else if (padflag_state == BUTTON_POWER) {
DeinitFS();
PowerOff();
} else if (padflag_state == BUTTON_HOME) {
DeinitFS();
Reboot();
}

missing buttons works


profi200
Posted on 09-11-16 02:00 PM Link | #1090
...and what does not work?

kasai07
Posted on 09-11-16 06:26 PM Link | #1091

sorry
it worked before
but not the stop button and home


Main - Homebrew discussion - Code for HID Show post layouts | New reply

Page rendered in 0.013 seconds. (2048KB of memory used)
MySQL - queries: 26, rows: 67/67, time: 0.006 seconds.
[powered by Acmlm] Acmlmboard 2.064 (2018-07-20)
© 2005-2008 Acmlm, Xkeeper, blackhole89 et al.